summaryrefslogtreecommitdiffstats
path: root/hwdb/parse_hwdb.py
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-11-03 03:48:08 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-11-03 03:48:43 +0100
commit1258f088981ac62efd846de91922eef033302e76 (patch)
treea42d449077f6ccebe141053478ad0ed51e8437f8 /hwdb/parse_hwdb.py
parenttest-compression: allow the file to compress to be specified (diff)
downloadsystemd-1258f088981ac62efd846de91922eef033302e76.tar.xz
systemd-1258f088981ac62efd846de91922eef033302e76.zip
parse_hwdb: add import fallback for python2
Diffstat (limited to 'hwdb/parse_hwdb.py')
-rwxr-xr-xhwdb/parse_hwdb.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/hwdb/parse_hwdb.py b/hwdb/parse_hwdb.py
index 2540c8c2f6..5d4c5ea64d 100755
--- a/hwdb/parse_hwdb.py
+++ b/hwdb/parse_hwdb.py
@@ -49,6 +49,12 @@ except ImportError:
ecodes = None
print('WARNING: evdev is not available')
+try:
+ from functools import lru_cache
+except ImportError:
+ # don't do caching on old python
+ lru_cache = lambda: (lambda f: f)
+
EOL = LineEnd().suppress()
EMPTYLINE = LineStart() + LineEnd()
COMMENTLINE = pythonStyleComment + EOL
@@ -62,7 +68,7 @@ TYPES = {'mouse': ('usb', 'bluetooth', 'ps2', '*'),
'keyboard': ('name', ),
}
-@functools.lru_cache()
+@lru_cache()
def hwdb_grammar():
ParserElement.setDefaultWhitespaceChars('')
@@ -83,7 +89,7 @@ def hwdb_grammar():
return grammar
-@functools.lru_cache()
+@lru_cache()
def property_grammar():
ParserElement.setDefaultWhitespaceChars(' ')