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