Working add_to_handy_menu.py

parent 4b02f39d
......@@ -34,26 +34,24 @@ def add_to_handymenu(user, cmd, category):
except yaml.YAMLError as exc:
print(exc)
lastId = 0
found = False
for app in yml:
lastId = app['id']
lastId = max(app['id'], lastId)
if(app['name'] == category):
print("found")
print(app['apps'])
app['apps'] += [cmd]
print(app['apps'])
found = True
if(not found):
yml += {
yml += [{
'apps': [cmd],
'name': category,
'id': lastId+1,
}
}]
print(yml)
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__':
......
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