]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
parse_hwdb: add import fallback for python2 4547/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 3 Nov 2016 02:48:08 +0000 (22:48 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 3 Nov 2016 02:48:43 +0000 (22:48 -0400)
hwdb/parse_hwdb.py

index 2540c8c2f639dd309e9e475d20fccf2b1ab5debc..5d4c5ea64df1babca4f8128911a409168bc70209 100755 (executable)
@@ -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(' ')