Проверка шаблона шины для iOS
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.

48 lines
1.7KB

  1. from generation.shortenName import *
  2. from generation.pipeBusSource import *
  3. from generation.pipeFormat import *
  4. from generation.pipeSource import *
  5. def sectionGeneratedPipes(entity, sub, c):
  6. fmtBusPipe = c.readFile(f"{c.dir}/templates/section-generated-pipe-src-bus")[0]
  7. fmtExRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-ex-recent")
  8. fmtRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-recent")
  9. fmtSet = c.readFile(f"{c.dir}/templates/section-generated-pipe-set")
  10. fmtToggle = c.readFile(f"{c.dir}/templates/section-generated-pipe-toggle")
  11. fmtToggleNil = c.readFile(f"{c.dir}/templates/section-generated-pipe-toggleNil")
  12. output = ""
  13. for key in entity.pipes:
  14. values = entity.pipes[key]
  15. # EX_NAME.
  16. firstLetter = key[:1].capitalize()
  17. exName = f"""ex{firstLetter}{key[1:]}"""
  18. # PIPE.
  19. pipe = "pipeValue"
  20. if "toggle" in values:
  21. pipe = "pipe"
  22. # SHORT_SRC.
  23. shortSrc = shortenName(key)
  24. # SRC.
  25. src = pipeSource(key, entity)
  26. # Bus.
  27. if src.startswith("K."):
  28. src = pipeBusSource(key, entity, src, c.structure, fmtBusPipe)
  29. fmtPipe = pipeFormat(fmtExRecent, fmtRecent, fmtSet, fmtToggle, fmtToggleNil, key, entity)
  30. for fmt in fmtPipe:
  31. ln = fmt \
  32. .replace("%EX_NAME%", exName) \
  33. .replace("%NAME%", key) \
  34. .replace("%PIPE%", pipe) \
  35. .replace("%SHORT_SRC%", shortSrc) \
  36. .replace("%SRC%", src) \
  37. .replace("%SUB%", sub)
  38. output += ln + "\n"
  39. return output