You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
939 B

  1. from collections import OrderedDict
  2. def positional(actions):
  3. groups = OrderedDict([('Positional Arguments', []), ('Optional Arguments', [])])
  4. for action in actions:
  5. if action['group_name'] == 'Positional Arguments':
  6. groups['Positional Arguments'].append(action)
  7. else:
  8. groups['Optional Arguments'].append(action)
  9. return groups
  10. def requiredAndOptional(actions):
  11. groups = OrderedDict([('Required', []), ('Optional', [])])
  12. for action in actions:
  13. if action['required']:
  14. groups['Required'].append(action)
  15. else:
  16. groups['Optional'].append(action)
  17. return groups
  18. def argparseGroups(actions):
  19. groups = OrderedDict()
  20. for action in actions:
  21. if action['group_name'] not in groups:
  22. groups[action['group_name']] = []
  23. groups[action['group_name']].append(action)
  24. return groups