diff --git a/odml/format.py b/odml/format.py index ffbb2918..48f0f64a 100644 --- a/odml/format.py +++ b/odml/format.py @@ -4,6 +4,7 @@ and mappings of xml-attributes to their python class equivalents """ + class Format(object): _map = {} _rev_map = None @@ -29,6 +30,7 @@ def __iter__(self): def create(self, *args, **kargs): return getattr(odml, self.__class__.__name__)(*args, **kargs) + class Value(Format): _name = "value" _args = { @@ -44,6 +46,7 @@ class Value(Format): } _map = {'type': 'dtype'} + class Property(Format): _name = "property" _args = { @@ -60,6 +63,7 @@ class Property(Format): 'type': 'dtype' } + class Section(Format): _name = "section" _args = { @@ -79,6 +83,7 @@ class Section(Format): 'property': 'properties', } + class Document(Format): _name = "odML" _args = { diff --git a/odml/tools/dumper.py b/odml/tools/dumper.py index 2cd3df77..a60c7716 100644 --- a/odml/tools/dumper.py +++ b/odml/tools/dumper.py @@ -2,6 +2,7 @@ Dumps ODML-Structures """ + def get_props(obj, props): out = [] for p in props: @@ -11,6 +12,7 @@ def get_props(obj, props): out.append("%s=%s" % (p, repr(x))) return ", ".join(out) + def dumpSection(section, indent=1): if section is None: return @@ -25,6 +27,7 @@ def dumpSection(section, indent=1): for sub in section.sections: dumpSection(sub, indent * 2) + def dumpDoc(doc): for sec in doc: dumpSection(sec)