Skip to content

Commit

Permalink
pep8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
notiel committed Jul 21, 2019
1 parent 4a19a0b commit 53a4aa5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
9 changes: 5 additions & 4 deletions create_qm.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def create_qm_constructor(qm_package: QMTag, Filename: str, filename: str, ctor_
_ = etree.SubElement(qm_ctor, "parameter", name=key, type=ctor_fields[key])
qm_code = etree.SubElement(qm_ctor, "code")
qm_code.text = "%s *me = &%s;\n %s\nQHsm_ctor(&me->super, Q_STATE_CAST(&%s_initial));" % (Filename, filename,
ctor_code, Filename)
ctor_code, Filename)


def create_qm_files(qm_model: QMTag, modelnames: [str], player_signal: [str], event_fields: dict, hcode: str,
Expand Down Expand Up @@ -588,7 +588,8 @@ def create_qm_files(qm_model: QMTag, modelnames: [str], player_signal: [str], ev
% (modelname, modelname, Modelname)

modelname = modelnames[0]
h_code = Template(t.read()).substitute({"hcode": hcode, "declare": declare, "declares": declares, "filename_h": name + "_h",
h_code = Template(t.read()).substitute({"hcode": hcode, "declare": declare,
"declares": declares, "filename_h": name + "_h",
"event_struct": get_event_struct(event_fields, modelname),
"player_signals": get_enum(player_signal)})
qm_text.text = h_code
Expand All @@ -604,7 +605,7 @@ def prepare_qm():


def create_qm(qm_package: QMTag, modelname: str, start_state: str, start_action: str,
notes: List[Dict[str, Any]], states: List[State], coords: List[int]) \
notes: List[Dict[str, Any]], states: List[State], coords: Tuple[int, int, int , int]) \
-> Tuple[Dict[str, str], str, str, str, Dict[str, str]]:
"""
function creates xml from list os states with trsnsitions using special rools and writes in to .qm file
Expand Down Expand Up @@ -638,7 +639,7 @@ def create_qm(qm_package: QMTag, modelname: str, start_state: str, start_action:
hcode = '\n//Start of h code from diagram\n' + '\n'.join([s for s in text.split('\n')[1:] if s]) + \
'\n//End of h code from diagram\n'
if text.startswith("Code for cpp-file:"):
cppcode = '\n//Start of c code from diagram\n'+'\n'.join([s for s in text.split('\n')[1:] if s])+\
cppcode = '\n//Start of c code from diagram\n'+'\n'.join([s for s in text.split('\n')[1:] if s]) +\
"\n//End of c code from diagram\n"
if text.startswith("Constructor code"):
ctor_code = '\n'.join(text.split('\n')[1:])
Expand Down
1 change: 0 additions & 1 deletion graphml.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,3 @@ def get_edge_label_coordinates(edge: Dict[str, Any]) -> Tuple[int, int, int]:
return 0, 0, 0
except KeyError:
continue

8 changes: 3 additions & 5 deletions graphmltoqm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ def get_states_from_graphml(filename: str):
logging.error('UML-diagram %s.graphml does not have start node' % filename)
return list()
# add external trigger and update list of signals with them
player_signal = qm.update_states_with_edges(qm_states, flat_edges, start, player_signal, coords[0], coords[1])
# get notes
notes = [node for node in flat_nodes if gr.is_node_a_note(node)]
return qm_states
_ = qm.update_states_with_edges(qm_states, flat_edges, start, player_signal, coords[0], coords[1])
return qm_states, coords[0], coords[1]


def main(filenames: Union[List[str], str]):
Expand Down Expand Up @@ -68,7 +66,7 @@ def main(filenames: Union[List[str], str]):
flat_nodes = gr.get_flat_nodes(data)
state_nodes = [node for node in flat_nodes if
gr.is_node_a_state(node) or gr.is_node_a_choice(node) or gr.is_node_a_group(node)]
state_nodes.sort(key=lambda st : len(st['id']))
state_nodes.sort(key=lambda st: len(st['id']))
gr.update_qroup_nodes(state_nodes)
state_nodes.sort(key=gr.coord_sort)

Expand Down
3 changes: 1 addition & 2 deletions qm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def testGuard(self):
'UpdateHP(me, me->CharHP + ((oregonPlayerQEvt*)e)->value);;', "test", [], [])
self.assertEqual(res[0].guard, "((((oregonPlayerQEvt*)e)->value+me->CharHP )<GHOUL_HP)")


def testNamewithGuard(self):
res, _ = create_actions('RAD_RCVD[((((oregonPlayerQEvt*)e)->value+me->CharHP )<GHOUL_HP)]/\n '
'UpdateHP(me, me->CharHP + ((oregonPlayerQEvt*)e)->value);;', "test", [], [])
Expand All @@ -109,10 +108,10 @@ def testElseGuard(self):
BeepForPeriod(SHORT_BEEP_MS);""", "test", [], [])
self.assertEqual(res[1].guard, "else")


def testNoTrigger(self):
res, _ = create_actions("a = b / c", "test", [], [])
self.assertEqual(len(res), 0)


if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion service_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def create_eventhandlers_files(path: str, modelname: str, functions: List):
functions_str = '() {\n \n}\n\n//stub function, autogenerated\nvoid'.join(functions)
result += functions_str
result += '() {\n \n}'
with open (os.path.join(path, "eventHadlers.cpp"), 'w') as f:
with open(os.path.join(path, "eventHadlers.cpp"), 'w') as f:
f.write(result)


Expand Down
2 changes: 1 addition & 1 deletion stateclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ class State:
width: int
height: int
parent: Optional['State']
childs: List['State']
childs: List['State']

0 comments on commit 53a4aa5

Please sign in to comment.