Проверка шаблона шины для iOS
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

generateServiceSectionGeneratedActions.py 2.9KB

1 год назад
1 год назад
1 год назад
1 год назад
1 год назад
1 год назад
1 год назад
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. from generation.sectionGeneratedActionShouldLoad import *
  2. def generateServiceSectionGeneratedActions(c):
  3. base = f"{c.dir}/templates/service-section-generated-action"
  4. fmtBusModel = c.readFile(f"{base}-bus-model")
  5. fmtCommon = c.readFile(base)
  6. fmtInstant = c.readFile(f"{base}-instant")
  7. fmtRelay = c.readFile(f"{base}-relay")
  8. fmtInstantDelay = c.readFile(f"{base}-instant-delay")
  9. fmtInstantRelay = c.readFile(f"{base}-instant-relay")
  10. fmtInstantModel = c.readFile(f"{base}-instant-model")
  11. fmtInstantShouldResetCore = c.readFile(f"{base}-instant-shouldResetCore")
  12. fmtModel = c.readFile(f"{base}-model")
  13. fmtShouldResetCore = c.readFile(f"{base}-shouldResetCore")
  14. canRelay = "🚀model" in c.structure.service.actions
  15. if canRelay:
  16. c.serviceSectionGeneratedActions += "\n".join(fmtRelay + [''])
  17. for key in c.structure.service.actions:
  18. value = c.structure.service.actions[key]
  19. # Шаблонные действия.
  20. if value == "":
  21. # busModel.
  22. if key == "busModel":
  23. c.serviceSectionGeneratedActions += "\n".join(fmtBusModel) + "\n"
  24. continue
  25. # instant model.
  26. if key == "🚀model":
  27. c.serviceSectionGeneratedActions += "\n".join(fmtInstantModel) + "\n"
  28. continue
  29. # model.
  30. if key == "model":
  31. c.serviceSectionGeneratedActions += "\n".join(fmtModel) + "\n"
  32. continue
  33. # shouldLoad*.
  34. shouldLoad = "shouldLoad"
  35. if key.startswith(shouldLoad):
  36. c.serviceSectionGeneratedActions += sectionGeneratedActionShouldLoad(key, "service", c)
  37. continue
  38. # instant shouldResetCore.
  39. if key == "🚀shouldResetCore":
  40. c.serviceSectionGeneratedActions += "\n".join(fmtInstantShouldResetCore) + "\n"
  41. continue
  42. # shouldResetCore.
  43. if key == "shouldResetCore":
  44. c.serviceSectionGeneratedActions += "\n".join(fmtShouldResetCore) + "\n"
  45. continue
  46. continue
  47. output = ""
  48. action = key
  49. template = fmtCommon
  50. # Действие без receive(on:)
  51. if action.startswith("🚀"):
  52. action = action[1:]
  53. template = fmtInstantRelay if canRelay else fmtInstant
  54. # Действие c .delay(on:)
  55. if action.startswith("⏳"):
  56. action = action[1:]
  57. template = fmtInstantDelay
  58. for fmt in template:
  59. ln = fmt \
  60. .replace("%SHOULD%", action) \
  61. .replace("%SINK%", value) \
  62. .replace("%MODULE%", c.module)
  63. output += ln + "\n"
  64. c.serviceSectionGeneratedActions += output