113.0-1
[arch-packages.git] / lirc / trunk / python-yaml-6.patch
blob298cae59635e80a26305de44f0681c5bfb695626
1 From bb6a390633f32942ac10f9b7b7fc01dfbd395a48 Mon Sep 17 00:00:00 2001
2 From: Alec Leamas <leamas.alec@nowhere.net>
3 Date: Fri, 21 Jan 2022 14:00:54 +0100
4 Subject: [PATCH] database.py: Handle new PyYAML interface.
6 ---
7 python-pkg/lirc/database.py | 12 ++++++++----
8 tools/check_configs.py | 4 ++++
9 2 files changed, 12 insertions(+), 4 deletions(-)
11 diff --git a/python-pkg/lirc/database.py b/python-pkg/lirc/database.py
12 index d464c2ab..d1f42c64 100644
13 --- a/python-pkg/lirc/database.py
14 +++ b/python-pkg/lirc/database.py
15 @@ -44,6 +44,10 @@ import sys
17 try:
18 import yaml
19 + try:
20 + from yaml import CLoader as Loader, CDumper as Dumper
21 + except ImportError:
22 + from yaml import Loader, Dumper
23 except ImportError:
24 _YAML_MSG = '''
25 "Cannot import the yaml library. Please install the python3
26 @@ -66,7 +70,7 @@ def _load_kerneldrivers(configdir):
27 '''
29 with open(os.path.join(configdir, "kernel-drivers.yaml")) as f:
30 - cf = yaml.load(f.read())
31 + cf = yaml.load(f.read(), Loader = Loader)
32 drivers = cf['drivers'].copy()
33 for driver in cf['drivers']:
34 if driver == 'default':
35 @@ -132,14 +136,14 @@ class Database(object):
36 yamlpath = configdir
37 db = {}
38 with open(os.path.join(yamlpath, "confs_by_driver.yaml")) as f:
39 - cf = yaml.load(f.read())
40 + cf = yaml.load(f.read(), Loader = Loader)
41 db['lircd_by_driver'] = cf['lircd_by_driver'].copy()
42 db['lircmd_by_driver'] = cf['lircmd_by_driver'].copy()
44 db['kernel-drivers'] = _load_kerneldrivers(configdir)
45 db['drivers'] = db['kernel-drivers'].copy()
46 with open(os.path.join(yamlpath, "drivers.yaml")) as f:
47 - cf = yaml.load(f.read())
48 + cf = yaml.load(f.read(), Loader = Loader)
49 db['drivers'].update(cf['drivers'].copy())
50 for key, d in db['drivers'].items():
51 d['id'] = key
52 @@ -158,7 +162,7 @@ class Database(object):
53 configs = {}
54 for path in glob.glob(configdir + '/*.conf'):
55 with open(path) as f:
56 - cf = yaml.load(f.read())
57 + cf = yaml.load(f.read(), Loader = Loader)
58 configs[cf['config']['id']] = cf['config']
59 db['configs'] = configs
60 self.db = db
61 diff --git a/tools/check_configs.py b/tools/check_configs.py
62 index 1e0d831b..5e458de7 100755
63 --- a/tools/check_configs.py
64 +++ b/tools/check_configs.py
65 @@ -4,6 +4,10 @@
67 import glob
68 import yaml
69 +try:
70 + from yaml import CLoader as Loader, CDumper as Dumper
71 +except ImportError:
72 + from yaml import Loader, Dumper
74 def main():
75 configs = {}
76 --
77 2.34.1