MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / construct_proccode

Function construct_proccode

scratchattach/editor/mutation.py:169–198  ·  view source on GitHub ↗

Create a proccode from strings/ArgumentType enum members/Argument instances :param components: list of strings/Arguments/ArgumentType instances :return: A proccode, e.g. 'move %s steps' or 'say %s for %n seconds'

(*components: ArgumentType | ArgTypes | Argument | str)

Source from the content-addressed store, hash-verified

167
168
169def construct_proccode(*components: ArgumentType | ArgTypes | Argument | str) -> str:
170 """
171 Create a proccode from strings/ArgumentType enum members/Argument instances
172
173 :param components: list of strings/Arguments/ArgumentType instances
174 :return: A proccode, e.g. 'move %s steps' or 'say %s for %n seconds'
175 """
176
177 result = ""
178
179 for comp in components:
180 if isinstance(comp, ArgumentType):
181 result += comp.proc_str
182
183 elif isinstance(comp, ArgTypes):
184 new: ArgumentType = comp.value
185 result += new.proc_str
186
187 elif isinstance(comp, Argument):
188 result += comp.type.proc_str
189
190 elif isinstance(comp, str):
191 result += comp
192
193 else:
194 raise TypeError(f"Unsupported component type: {type(comp)}")
195
196 result += " "
197
198 return result
199
200
201class Mutation(base.BlockSubComponent):

Callers

nothing calls this directly

Calls 1

typeFunction · 0.85

Tested by

no test coverage detected