mirror of
https://github.com/stevenrobertson/cuburn.git
synced 2025-02-05 11:40:04 -05:00
Change a method's arguments arbitrarily
This commit is contained in:
parent
4ab18c06e0
commit
f057108360
@ -255,9 +255,6 @@ class XMLGenomeParser(object):
|
|||||||
self.parser.StartElementHandler = self.start_element
|
self.parser.StartElementHandler = self.start_element
|
||||||
self.parser.EndElementHandler = self.end_element
|
self.parser.EndElementHandler = self.end_element
|
||||||
|
|
||||||
def parse(self, file):
|
|
||||||
self.parser.ParseFile(file)
|
|
||||||
|
|
||||||
def start_element(self, name, attrs):
|
def start_element(self, name, attrs):
|
||||||
if name == 'flame':
|
if name == 'flame':
|
||||||
assert self._flame is None
|
assert self._flame is None
|
||||||
@ -276,6 +273,12 @@ class XMLGenomeParser(object):
|
|||||||
self.flames.append(self._flame)
|
self.flames.append(self._flame)
|
||||||
self._flame = None
|
self._flame = None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse(cls, src):
|
||||||
|
parser = cls()
|
||||||
|
parser.parser.Parse(src, True)
|
||||||
|
return parser.flames
|
||||||
|
|
||||||
def convert_flame(flame):
|
def convert_flame(flame):
|
||||||
"""
|
"""
|
||||||
Convert an XML flame (as returned by XMLGenomeParser) into a plain dict
|
Convert an XML flame (as returned by XMLGenomeParser) into a plain dict
|
||||||
@ -372,12 +375,11 @@ def convert_affine(aff, animate=False):
|
|||||||
|
|
||||||
def convert_file(path):
|
def convert_file(path):
|
||||||
"""Quick one-shot conversion for an XML genome."""
|
"""Quick one-shot conversion for an XML genome."""
|
||||||
p = GenomeParser()
|
flames = XMLGenomeParser.parse(open(path).read())
|
||||||
p.parse(open(path))
|
if len(flames) > 10:
|
||||||
if len(p.flames) > 10:
|
|
||||||
warnings.warn("Lot of flames in this file. Sure it's not a "
|
warnings.warn("Lot of flames in this file. Sure it's not a "
|
||||||
"frame-based animation?")
|
"frame-based animation?")
|
||||||
for flame in p.flames:
|
for flame in flames:
|
||||||
yield convert_flame(flame)
|
yield convert_flame(flame)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user