(
cls,
to_chop: _PathRepresentation,
path: PathRegistry,
debug: bool = False,
)
| 931 | |
| 932 | @classmethod |
| 933 | def _chop_path( |
| 934 | cls, |
| 935 | to_chop: _PathRepresentation, |
| 936 | path: PathRegistry, |
| 937 | debug: bool = False, |
| 938 | ) -> Optional[_PathRepresentation]: |
| 939 | i = -1 |
| 940 | |
| 941 | for i, (c_token, p_token) in enumerate( |
| 942 | zip(to_chop, path.natural_path) |
| 943 | ): |
| 944 | if isinstance(c_token, str): |
| 945 | if i == 0 and ( |
| 946 | c_token.endswith(f":{_DEFAULT_TOKEN}") |
| 947 | or c_token.endswith(f":{_WILDCARD_TOKEN}") |
| 948 | ): |
| 949 | return to_chop |
| 950 | elif ( |
| 951 | c_token != f"{_RELATIONSHIP_TOKEN}:{_WILDCARD_TOKEN}" |
| 952 | and c_token != p_token.key # type: ignore |
| 953 | ): |
| 954 | return None |
| 955 | |
| 956 | if c_token is p_token: |
| 957 | continue |
| 958 | elif ( |
| 959 | isinstance(c_token, InspectionAttr) |
| 960 | and insp_is_mapper(c_token) |
| 961 | and insp_is_mapper(p_token) |
| 962 | and c_token.isa(p_token) |
| 963 | ): |
| 964 | continue |
| 965 | |
| 966 | else: |
| 967 | return None |
| 968 | return to_chop[i + 1 :] |
| 969 | |
| 970 | |
| 971 | class Load(_AbstractLoad): |
no test coverage detected