Working add_to_handy_menu.py

parent 4b02f39d
...@@ -34,26 +34,24 @@ def add_to_handymenu(user, cmd, category): ...@@ -34,26 +34,24 @@ def add_to_handymenu(user, cmd, category):
except yaml.YAMLError as exc: except yaml.YAMLError as exc:
print(exc) print(exc)
lastId = 0
found = False found = False
for app in yml: for app in yml:
lastId = app['id'] lastId = max(app['id'], lastId)
if(app['name'] == category): if(app['name'] == category):
print("found")
print(app['apps'])
app['apps'] += [cmd] app['apps'] += [cmd]
print(app['apps'])
found = True found = True
if(not found): if(not found):
yml += { yml += [{
'apps': [cmd], 'apps': [cmd],
'name': category, 'name': category,
'id': lastId+1, 'id': lastId+1,
} }]
print(yml)
with open(path, 'w') as f: with open(path, 'w') as f:
yaml.dump(yml, f, default_flow_style=False) yaml.dump(yml, f, default_flow_style=False, allow_unicode=True)
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment