MCPcopy Create free account
hub / github.com/tortoise/tortoise-orm / split_reference

Method split_reference

tortoise/apps.py:148–161  ·  view source on GitHub ↗

Validate, if reference follow the official naming conventions. Throws a ConfigurationError with a hopefully helpful message. If successful, returns the app and the model name. :raises ConfigurationError: If reference is invalid.

(reference: str)

Source from the content-addressed store, hash-verified

146 )
147
148 def split_reference(reference: str) -> tuple[str, str]:
149 """
150 Validate, if reference follow the official naming conventions. Throws a
151 ConfigurationError with a hopefully helpful message. If successful,
152 returns the app and the model name.
153
154 :raises ConfigurationError: If reference is invalid.
155 """
156 if len(items := reference.split(".")) != 2: # pragma: nocoverage
157 raise ConfigurationError(
158 f"'{reference}' is not a valid model reference Bad Reference."
159 " Should be something like '<appname>.<modelname>'."
160 )
161 return items[0], items[1]
162
163 def init_fk_o2o_field(model: type[Model], field: str, is_o2o: bool = False) -> None:
164 fk_object = cast(

Callers

nothing calls this directly

Calls 1

ConfigurationErrorClass · 0.90

Tested by

no test coverage detected