404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.145.60.114: ~ $
from operator import setitem
from typing import Any, Callable, Optional

from testfixtures import not_there


# Should be Literal[setattr, getattr] but Python 3.8 only.
Setter = Callable[[Any, str, Any], None]


class Resolved:

    def __init__(self, container: Any, setter: Setter, name: str, found: Any):
        self.container: Any = container
        self.setter: Setter = setter
        self.name: str = name
        self.found: Any = found

    def __repr__(self):
        return f'<Resolved: {self.found}>'


def resolve(dotted_name: str, container: Optional[Any] = None) -> Resolved:
    names = dotted_name.split('.')
    used = names.pop(0)
    if container is None:
        found = __import__(used)
        container = found
    else:
        assert not used, 'Absolute traversal not allowed when container supplied'
        used = ''
        found = container
    setter = None
    name = None
    for name in names:
        container = found
        used += '.' + name
        try:
            found = getattr(found, name)
            setter = setattr
        except AttributeError:
            try:
                __import__(used)
            except ImportError:
                setter = setitem
                try:
                    found = found[name]  # pragma: no branch
                except KeyError:
                    found = not_there  # pragma: no branch
                except TypeError:
                    try:
                        name = int(name)
                    except ValueError:
                        setter = setattr
                        found = not_there
                    else:
                        found = found[name]  # pragma: no branch
            else:
                found = getattr(found, name)
                setter = getattr
    return Resolved(container, setter, name, found)


class _Reference:

    @classmethod
    def classmethod(cls):  # pragma: no cover
        pass

    @staticmethod
    def staticmethod(cls):  # pragma: no cover
        pass


class_type = type(_Reference)
classmethod_type = type(_Reference.classmethod)

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
tests Folder 0755
__init__.py File 1.19 KB 0644
comparison.py File 39.14 KB 0644
compat.py File 224 B 0644
components.py File 1.31 KB 0644
datetime.py File 24.42 KB 0644
django.py File 2.88 KB 0644
logcapture.py File 10.75 KB 0644
mock.py File 1.21 KB 0644
outputcapture.py File 4.69 KB 0644
popen.py File 9.89 KB 0644
replace.py File 12.15 KB 0644
resolve.py File 2.05 KB 0644
rmtree.py File 2.52 KB 0644
shouldraise.py File 3.58 KB 0644
shouldwarn.py File 2.21 KB 0644
sybil.py File 2.28 KB 0644
tempdirectory.py File 12.89 KB 0644
twisted.py File 4.8 KB 0644
utils.py File 2.74 KB 0644
version.txt File 6 B 0644