@@ -33,7 +33,8 @@ def to_dict(self, odml_document):
3333 tag = getattr (odml_document , attr )
3434
3535 if tag :
36- parsed_doc [attr ] = tag
36+ # Always use the arguments key attribute name when saving
37+ parsed_doc [i ] = tag
3738
3839 return parsed_doc
3940
@@ -60,7 +61,8 @@ def get_sections(self, section_list):
6061 tag = getattr (section , attr )
6162
6263 if tag :
63- section_dict [attr ] = tag
64+ # Always use the arguments key attribute name when saving
65+ section_dict [i ] = tag
6466
6567 section_seq .append (section_dict )
6668
@@ -89,7 +91,8 @@ def get_properties(props_list):
8991 prop .dtype .endswith ("-tuple" ) and len (prop .value ) > 0 :
9092 prop_dict ["value" ] = "(%s)" % ";" .join (prop .value [0 ])
9193 else :
92- prop_dict [attr ] = tag
94+ # Always use the arguments key attribute name when saving
95+ prop_dict [i ] = tag
9396
9497 props_seq .append (prop_dict )
9598
@@ -128,9 +131,9 @@ def to_odml(self, parsed_doc):
128131 raise ParserException ("Invalid odML document: Could not find odml-version." )
129132
130133 elif self .parsed_doc .get ('odml-version' ) != FORMAT_VERSION :
131- msg = ("Cannot read file: invalid odML document format version '%s'. \n "
132- "This package supports odML format versions: '%s' ."
133- % ( self .parsed_doc .get ('odml-version' ), FORMAT_VERSION ))
134+ msg = ("Cannot parse odML document with format version '%s'. \n "
135+ "\t Use the 'tools.VersionConverter' to import previous odML formats ."
136+ % self .parsed_doc .get ('odml-version' ))
134137 raise InvalidVersionException (msg )
135138
136139 self .parsed_doc = self .parsed_doc ['Document' ]
@@ -143,7 +146,8 @@ def to_odml(self, parsed_doc):
143146 if attr == 'sections' :
144147 doc_secs = self .parse_sections (self .parsed_doc ['sections' ])
145148 elif attr :
146- doc_attrs [i ] = self .parsed_doc [i ]
149+ # Make sure to always use the correct odml format attribute name
150+ doc_attrs [odmlfmt .Document .map (attr )] = self .parsed_doc [i ]
147151
148152 doc = odmlfmt .Document .create (** doc_attrs )
149153 for sec in doc_secs :
@@ -166,7 +170,8 @@ def parse_sections(self, section_list):
166170 elif attr == 'sections' :
167171 children_secs = self .parse_sections (section ['sections' ])
168172 elif attr :
169- sec_attrs [attr ] = section [attr ]
173+ # Make sure to always use the correct odml format attribute name
174+ sec_attrs [odmlfmt .Section .map (attr )] = section [attr ]
170175
171176 sec = odmlfmt .Section .create (** sec_attrs )
172177 for prop in sec_props :
@@ -188,7 +193,8 @@ def parse_properties(self, props_list):
188193 for i in _property :
189194 attr = self .is_valid_attribute (i , odmlfmt .Property )
190195 if attr :
191- prop_attrs [attr ] = _property [attr ]
196+ # Make sure to always use the correct odml format attribute name
197+ prop_attrs [odmlfmt .Property .map (attr )] = _property [attr ]
192198
193199 prop = odmlfmt .Property .create (** prop_attrs )
194200 odml_props .append (prop )
0 commit comments