core.py 851 B

1234567891011121314151617181920212223242526272829303132333435
  1. from .tickets import Ticket
  2. TICKET_TYPES = Ticket.TICKET_TYPES
  3. TICKET_STATUSES_NAMES = Ticket.TICKET_STATUSES_NAMES
  4. TICKET_TYPES_CHOICES = Ticket.TICKET_TYPES_CHOICES
  5. LIFE_CYCLE_DICT = Ticket.LIFE_CYCLE_DICT
  6. def gen_diagram(x):
  7. (i, name, data) = x
  8. output = 'strict digraph G {\n'
  9. unique_status = list(set(item for sublist in data for item in sublist))
  10. for k in unique_status:
  11. v = name + '_' + TICKET_STATUSES_NAMES[k]
  12. output += f' {k} [label="{v}"]\n'
  13. output += ' \n'
  14. for i, x in enumerate(data):
  15. # output += f' subgraph cluster_{i} {{\n'
  16. output += ' ' + ' -> '.join(list(map(str, x))) + ';\n'
  17. # output += ' }\n'
  18. output += '}\n'
  19. return output
  20. # FIXME: Доделать модуль
  21. # Gen diagrams: python -m tickets.lib.core
  22. print(gen_diagram(TICKET_TYPES[1]))