MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / _replace

Function _replace

utils/custom_init_isort.py:188–197  ·  view source on GitHub ↗
(match)

Source from the content-addressed store, hash-verified

186
187 # This inner function sort imports between [ ].
188 def _replace(match):
189 imports = match.groups()[0]
190 # If there is one import only, nothing to do.
191 if "," not in imports:
192 return f"[{imports}]"
193 keys = [part.strip().replace('"', "") for part in imports.split(",")]
194 # We will have a final empty element if the line finished with a comma.
195 if len(keys[-1]) == 0:
196 keys = keys[:-1]
197 return "[" + ", ".join([f'"{k}"' for k in sort_objects(keys)]) + "]"
198
199 lines = import_statement.split("\n")
200 if len(lines) > 3:

Callers

nothing calls this directly

Calls 1

sort_objectsFunction · 0.85

Tested by

no test coverage detected