Commits

rkruppe  committed aeea025

A couple of bug fixes related to yamlreader changes

  • Participants
  • Parent commits 3752d4e
  • Branches experiments

Comments (0)

Files changed (3)

File tutagx/model/misc.py

     # language code -> text
     texts = model.Dict(model.String(), model.String())
 
-    _OID_PATTERN = 'txt/{0["en"]}'
+    _OID_PATTERN = 'txt/{0[en]}'
 
     def __getitem__(self, lang):
         return self.texts[lang]

File tutagx/model/split.py

         cls.__reachable = reachable_types(cls)
 
     @classmethod
-    def load_from_path(my_cls, dirpath, namespace=None):
+    def load_from_path(my_cls, dirpath, context=None):
         log.debug('Loading %s from %r', my_cls.__name__, dirpath)
-        reader = from_yaml.YAMLReader()
+        reader = from_yaml.YAMLReader(context)
         v = reader.validator
         for cls in my_cls.__reachable:
             if cls.is_value_type:

File tutagx/toolutil.py

     and models featuring custom wrappers around that.
     """
     if hasattr(cls, 'load_from_path'):
-        namespace = cls.reader_namespace()
-        obj, errors = cls.load_from_path(path, namespace)
+        context = from_yaml.DecodingContext()
+        obj, errors = cls.load_from_path(path, context)
         lines = tutagx.meta.validate.format_errors(errors)
     else:
         reader = from_yaml.YAMLReader()
+        context = reader.context
         with open(path) as f:
             obj, errors = reader.load(cls, f)
         # This may fail if the data is somehow invalid, and the only real
         # Hence we err on the side of caution and omit it.
         if not errors:
             tutagx.meta.validate.add_errors_for_unreachable(
-                cls, reader.context, obj, errors
+                cls, context, obj, errors
             )
-    return obj, namespace, errors
+    return obj, context, errors
 
 
 def store(obj, path):