MCPcopy Create free account
hub / github.com/piccolo-orm/piccolo / bundle

Method bundle

piccolo/querystring.py:167–204  ·  view source on GitHub ↗
(
        self,
        start_index: int = 1,
        bundled: Optional[list[Fragment]] = None,
        combined_args: Optional[list] = None,
    )

Source from the content-addressed store, hash-verified

165 return template.format(*converted_args)
166
167 def bundle(
168 self,
169 start_index: int = 1,
170 bundled: Optional[list[Fragment]] = None,
171 combined_args: Optional[list] = None,
172 ):
173 # Split up the string, separating by {}.
174 fragments = [
175 Fragment(prefix=i[0]) for i in Formatter().parse(self.template)
176 ]
177
178 bundled = [] if bundled is None else bundled
179 combined_args = [] if combined_args is None else combined_args
180
181 for index, fragment in enumerate(fragments):
182 try:
183 value = self.args[index]
184 except IndexError:
185 # trailing element
186 fragment.no_arg = True
187 bundled.append(fragment)
188 else:
189 if isinstance(value, QueryString):
190 fragment.no_arg = True
191 bundled.append(fragment)
192
193 start_index, _, _ = value.bundle(
194 start_index=start_index,
195 bundled=bundled,
196 combined_args=combined_args,
197 )
198 else:
199 fragment.index = start_index
200 bundled.append(fragment)
201 start_index += 1
202 combined_args.append(value)
203
204 return (start_index, bundled, combined_args)
205
206 def compile_string(
207 self, engine_type: str = "postgres"

Callers 2

__str__Method · 0.95
compile_stringMethod · 0.95

Calls 2

FragmentClass · 0.85
appendMethod · 0.45

Tested by

no test coverage detected