]> git.openstreetmap.org Git - nominatim.git/commitdiff
remove default parameter for namedtuple
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 6 Jul 2021 07:54:11 +0000 (09:54 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Tue, 6 Jul 2021 20:57:42 +0000 (22:57 +0200)
This is only available in Python 3.7.

nominatim/config.py
nominatim/tokenizer/icu_variants.py

index 72aaf0bd6b436ed78322f39ccec34feb560d542d..a8436440b9f5ca78670ba9fe9e1cc8e3979ece96 100644 (file)
@@ -68,9 +68,9 @@ class Configuration:
         """
         try:
             return int(self.__getattr__(name))
-        except ValueError:
+        except ValueError as exp:
             LOG.fatal("Invalid setting NOMINATIM_%s. Needs to be a number.", name)
-            raise UsageError("Configuration error.")
+            raise UsageError("Configuration error.") from exp
 
 
     def get_libpq_dsn(self):
index 5148f3e2decff2b7027665a06019969e1409fb94..9ebe36849e50efbcc8896794bc3c983e65320da5 100644 (file)
@@ -7,12 +7,11 @@ import json
 _ICU_VARIANT_PORPERTY_FIELDS = ['lang']
 
 
-class ICUVariantProperties(namedtuple('_ICUVariantProperties', _ICU_VARIANT_PORPERTY_FIELDS,
-                                      defaults=(None, )*len(_ICU_VARIANT_PORPERTY_FIELDS))):
+class ICUVariantProperties(namedtuple('_ICUVariantProperties', _ICU_VARIANT_PORPERTY_FIELDS)):
     """ Data container for saving properties that describe when a variant
         should be applied.
 
-        Porperty instances are hashable.
+        Property instances are hashable.
     """
     @classmethod
     def from_rules(cls, _):
@@ -52,7 +51,7 @@ def unpickle_variant_set(variant_string):
     """
     data = json.loads(variant_string)
 
-    properties = {int(k): ICUVariantProperties(**v) for k, v in data['properties'].items()}
-    print(properties)
+    properties = {int(k): ICUVariantProperties.from_rules(v)
+                  for k, v in data['properties'].items()}
 
     return set((ICUVariant(src, repl, properties[pid]) for src, repl, pid in data['variants']))