Проверка шаблона шины для iOS
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

generateServiceSectionGeneratedActions.py 2.6KB

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