def fromXMI(filename): """ generates workshop-flavored python from xmi """ NS = { "xmi": "http://schema.omg.org/spec/XMI/2.1", "uml": "http://schema.omg.org/spec/UML/2.0", } doc = xml(open(filename).read()) for node in doc.xpath("//@xmi:type[string()='uml:Class']/..", NS): className = node.xpath("string(@name)") if modelClassExists(className): print "skipping existing class %s" % className else: addToModel(className, className.lower()) with outstream("model/%s.py" % className, 'a') as out: for attr in node.xpath("ownedAttribute"): out(indent(code_for_attr( name = attr.xpath("string(@name)"), type = attr.xpath('string(@type)')[:-3] or 'str', default = attr.xpath('string(defaultValue/@value)')))) print "added class %s" % className
def fromXMI(filename): """ generates workshop-flavored python from xmi """ NS = { "xmi": "http://schema.omg.org/spec/XMI/2.1", "uml": "http://schema.omg.org/spec/UML/2.0", } doc = xml(open(filename).read()) for node in doc.xpath("//@xmi:type[string()='uml:Class']/..", NS): className = node.xpath("string(@name)") if modelClassExists(className): print "skipping existing class %s" % className else: addToModel(className, className.lower()) with outstream("model/%s.py" % className, 'a') as out: for attr in node.xpath("ownedAttribute"): out( indent( code_for_attr(name=attr.xpath("string(@name)"), type=attr.xpath('string(@type)')[:-3] or 'str', default=attr.xpath( 'string(defaultValue/@value)')))) print "added class %s" % className
def dump(scope, depth=0): line = "%s%s:" % (obj.get_name, su.get_body_region(obj)) print handy.indent('# '*depth, line) scope = obj.get_scope()
def dump(scope, depth=0): line = "%s%s:" % (obj.get_name, su.get_body_region(obj)) print handy.indent('# ' * depth, line) scope = obj.get_scope()