Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
phyrisrose committed Apr 21, 2012
1 parent b9c0388 commit 3ab0797
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
5 changes: 3 additions & 2 deletions structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ class BasicClass(object):
def __init__(self):
self.name = ''
self.type = ''
self.attributes = [] # List of type Object here
self.attributes = '' # List of type Object here
self.functions = [] # List of type Function here
self.internal_type_defs = []
self.vis_list = []
self.predicate_rules = ''

def __repr__(self):
return "%s named %s" % (self.type, self.name)
Expand All @@ -21,7 +22,7 @@ class Function(object):
def __init__(self):
self.name = ''
self.return_type = ''
self.parameter_list = [] # List of type Object here
self.parameter_list = '' # List of type Object here
self.declaration = ''
self.predicate = ''

Expand Down
12 changes: 8 additions & 4 deletions uml_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def gen_uml(self, outfile):

print ET.tostring(self.diagram)
#diagram.write(outfile, True)
tree_string = self.prettify(ET.tostring(self.diagram, 'utf-8'),outfile)
#tree_string = self.prettify(ET.tostring(self.diagram, 'utf-8'),outfile)
tree_string = ET.tostring(self.diagram, 'utf-8')
f = open(outfile, 'w')
f.write(tree_string)

Expand All @@ -37,27 +38,30 @@ def gen_class(self, cur_class):
uxf_coord = ET.SubElement(uxf_class, "coordinates")
uxf_coord_x = ET.SubElement(uxf_coord, "x")
uxf_coord_x.text = str(self.class_x)
self.class_x += 220
self.class_x += 270
uxf_coord_y = ET.SubElement(uxf_coord, "y")
uxf_coord_y.text = '20'
uxf_size_w = ET.SubElement(uxf_coord, "w")
uxf_size_w.text = '200'
uxf_size_w.text = '250'
uxf_size_h = ET.SubElement(uxf_coord, 'h')
uxf_size_h.text = '300'
#Add Class Contents
uxf_attributes = ET.SubElement(uxf_class, "panel_attributes")
class_contents = cur_class.name
class_contents += '\n--\n'
#Add Attributes
'''
if len(cur_class.attributes) > 0:
for attribute in cur_class.attributes:
class_contents += '-' + attribute.name + ': ' + attribute.type + '\n'
class_contents += '--\n'
'''
class_contents += '-' + cur_class.attributes + '\n'
#Add Operations
if len(cur_class.functions) > 0:
for operation in cur_class.functions:

class_contents += operation.name + '(' + str(operation.parameter_list) + ')' + '\n'
class_contents += '#' + operation.name + '(' + str(operation.parameter_list) + ')' + '\n'
uxf_attributes.text = class_contents
uxf_additional_attributes = ET.SubElement(uxf_class, "additional_attributes")

Expand Down
12 changes: 10 additions & 2 deletions xml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,16 @@ def handle_class_def(self, class_def):
self.handle_operation(sub_node, uml_class_obj)
self.classes_list.append(uml_class_obj)

def handle_state(self,sub_node, uml_class_obj):
pass
def handle_state(self, state_node, parent_uml_obj):
for sub_node in state_node.childNodes:
if sub_node.nodeName == 'name':
parent_uml_obj.attributes += '\n?' + self.handle_cdata_tag(sub_node) + '?\n'
elif sub_node.nodeName == 'declaration':
parent_uml_obj.attributes += self.handle_declaration(sub_node)
elif sub_node.nodeName == 'predicate':
parent_uml_obj.predicate_rules += self.handle_cdata_tag(sub_node)



def handle_operation(self, node, parent_uml_obj):
uml_func_obj = Function()
Expand Down

0 comments on commit 3ab0797

Please sign in to comment.