|
- from generation.shortenName import *
- from generation.pipeBusSource import *
- from generation.pipeFormat import *
- from generation.pipeSource import *
-
- def sectionGeneratedPipes(entity, sub, c):
- fmtBusPipe = c.readFile(f"{c.dir}/templates/section-generated-pipe-src-bus")[0]
- fmtExRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-ex-recent")
- fmtMany = c.readFile(f"{c.dir}/templates/section-generated-pipe-many")
- fmtRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-recent")
- fmtSet = c.readFile(f"{c.dir}/templates/section-generated-pipe-set")
- fmtToggle = c.readFile(f"{c.dir}/templates/section-generated-pipe-toggle")
- fmtToggleNil = c.readFile(f"{c.dir}/templates/section-generated-pipe-toggleNil")
- output = ""
-
- for key in entity.pipes:
- values = entity.pipes[key]
- print(f"sectionGP-1 key/values: '{key}'/'{values}'")
-
- # EX_NAME.
- firstLetter = key[:1].capitalize()
- exName = f"""ex{firstLetter}{key[1:]}"""
-
- # PIPE.
- pipe = "pipeValue"
- if "toggle" in values:
- pipe = "pipe"
-
- # SHORT_SRC.
- shortSrc = shortenName(key)
-
- # SRC.
- src = pipeSource(key, entity)
- print(f"sectionGP-2 key/src: '{key}'/'{src}'")
- # Bus.
- if src.startswith("K."):
- print(f"sectionGP-3 key: '{key}' bus")
- src = pipeBusSource(key, entity, src, c.structure, fmtBusPipe)
-
- fmtPipe = pipeFormat(fmtExRecent, fmtMany, fmtRecent, fmtSet, fmtToggle, fmtToggleNil, key, entity)
- for fmt in fmtPipe:
- ln = fmt \
- .replace("%EX_NAME%", exName) \
- .replace("%NAME%", key) \
- .replace("%PIPE%", pipe) \
- .replace("%SHORT_SRC%", shortSrc) \
- .replace("%SRC%", src) \
- .replace("%SUB%", sub)
- output += ln + "\n"
-
- return output
|