Left: | ||
Right: |
OLD | NEW |
---|---|
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 import new | 2 import new |
3 import string | 3 import string |
4 from rational import * | 4 from rational import * |
5 import re | 5 import re |
6 import sys | 6 import sys |
7 import copy | 7 import copy |
8 import lilylib as ly | 8 import lilylib as ly |
9 | 9 |
10 _ = ly._ | 10 _ = ly._ |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 return self.get_work_information ('opus') | 163 return self.get_work_information ('opus') |
164 | 164 |
165 class Identification (Xml_node): | 165 class Identification (Xml_node): |
166 def get_rights (self): | 166 def get_rights (self): |
167 rights = self.get_named_children ('rights') | 167 rights = self.get_named_children ('rights') |
168 ret = [] | 168 ret = [] |
169 for r in rights: | 169 for r in rights: |
170 ret.append (r.get_text ()) | 170 ret.append (r.get_text ()) |
171 return string.join (ret, "\n") | 171 return string.join (ret, "\n") |
172 | 172 |
173 def get_source (self): | |
174 source = self.get_named_children ('source') | |
175 ret = [] | |
176 for r in source: | |
janek
2011/09/22 12:50:43
What does this do?
Can you add a comment explainin
| |
177 ret.append (r.get_text ()) | |
178 return string.join (ret, "\n") | |
179 | |
173 def get_creator (self, type): | 180 def get_creator (self, type): |
174 creators = self.get_named_children ('creator') | 181 creators = self.get_named_children ('creator') |
175 # return the first creator tag that has the particular type | 182 # return the first creator tag that has the particular type |
176 for i in creators: | 183 for i in creators: |
177 if hasattr (i, 'type') and i.type == type: | 184 if hasattr (i, 'type') and i.type == type: |
178 return i.get_text () | 185 return i.get_text () |
179 return None | 186 return None |
180 | 187 |
181 def get_composer (self): | 188 def get_composer (self): |
182 c = self.get_creator ('composer') | 189 c = self.get_creator ('composer') |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 | 235 |
229 def get_file_description (self): | 236 def get_file_description (self): |
230 misc = self.get_named_children ('miscellaneous') | 237 misc = self.get_named_children ('miscellaneous') |
231 for m in misc: | 238 for m in misc: |
232 misc_fields = m.get_named_children ('miscellaneous-field') | 239 misc_fields = m.get_named_children ('miscellaneous-field') |
233 for mf in misc_fields: | 240 for mf in misc_fields: |
234 if hasattr (mf, 'name') and mf.name == 'description': | 241 if hasattr (mf, 'name') and mf.name == 'description': |
235 return mf.get_text ()· | 242 return mf.get_text ()· |
236 return None | 243 return None |
237 | 244 |
238 | 245 def get_miscellaneous (self): |
246 misc = self.get_named_children ('miscellaneous') | |
247 for m in misc: | |
248 misc_fields = m.get_named_children ('miscellaneous-field') | |
249 for mf in misc_fields: | |
250 if hasattr (mf, 'name') and mf.name == 'description': | |
251 return mf.get_text () | |
252 return None | |
Reinhold
2011/09/22 13:26:54
Please don't exactly duplicate get_file_descriptio
Reinhold
2011/09/23 11:42:26
I already gave you the spot where you would have t
| |
239 | 253 |
240 class Duration (Music_xml_node): | 254 class Duration (Music_xml_node): |
241 def get_length (self): | 255 def get_length (self): |
242 dur = int (self.get_text ()) * Rational (1,4) | 256 dur = int (self.get_text ()) * Rational (1,4) |
243 return dur | 257 return dur |
244 | 258 |
245 class Hash_comment (Music_xml_node): | 259 class Hash_comment (Music_xml_node): |
246 pass | 260 pass |
247 class Hash_text (Music_xml_node): | 261 class Hash_text (Music_xml_node): |
248 def dump (self, indent = ''): | 262 def dump (self, indent = ''): |
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1295 | 1309 |
1296 | 1310 |
1297 if __name__ == '__main__': | 1311 if __name__ == '__main__': |
1298 import lxml.etree | 1312 import lxml.etree |
1299 ········ | 1313 ········ |
1300 tree = lxml.etree.parse ('beethoven.xml') | 1314 tree = lxml.etree.parse ('beethoven.xml') |
1301 mxl_tree = lxml_demarshal_node (tree.getroot ()) | 1315 mxl_tree = lxml_demarshal_node (tree.getroot ()) |
1302 ks = class_dict.keys () | 1316 ks = class_dict.keys () |
1303 ks.sort () | 1317 ks.sort () |
1304 print '\n'.join (ks) | 1318 print '\n'.join (ks) |
OLD | NEW |