GRAYBYTE WORDPRESS FILE MANAGER2927

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /opt/hc_python/lib/python3.12/site-packages/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /opt/hc_python/lib/python3.12/site-packages//cfgv.py
from __future__ import annotations

import collections
import contextlib
import os.path
import re
import sys


class ValidationError(ValueError):
    def __init__(self, error_msg, ctx=None):
        super().__init__(error_msg)
        self.error_msg = error_msg
        self.ctx = ctx

    def __str__(self):
        out = '\n'
        err = self
        while err.ctx is not None:
            out += f'==> {err.ctx}\n'
            err = err.error_msg
        out += f'=====> {err.error_msg}'
        return out


MISSING = collections.namedtuple('Missing', ())()
type(MISSING).__repr__ = lambda self: 'MISSING'


@contextlib.contextmanager
def validate_context(msg):
    try:
        yield
    except ValidationError as e:
        _, _, tb = sys.exc_info()
        raise ValidationError(e, ctx=msg).with_traceback(tb) from None


@contextlib.contextmanager
def reraise_as(tp):
    try:
        yield
    except ValidationError as e:
        _, _, tb = sys.exc_info()
        raise tp(e).with_traceback(tb) from None


def _dct_noop(self, dct):
    pass


def _check_optional(self, dct):
    if self.key not in dct:
        return
    with validate_context(f'At key: {self.key}'):
        self.check_fn(dct[self.key])


def _apply_default_optional(self, dct):
    dct.setdefault(self.key, self.default)


def _remove_default_optional(self, dct):
    if dct.get(self.key, MISSING) == self.default:
        del dct[self.key]


def _require_key(self, dct):
    if self.key not in dct:
        raise ValidationError(f'Missing required key: {self.key}')


def _check_required(self, dct):
    _require_key(self, dct)
    _check_optional(self, dct)


@property
def _check_fn_recurse(self):
    def check_fn(val):
        validate(val, self.schema)
    return check_fn


def _apply_default_required_recurse(self, dct):
    dct[self.key] = apply_defaults(dct[self.key], self.schema)


def _remove_default_required_recurse(self, dct):
    dct[self.key] = remove_defaults(dct[self.key], self.schema)


def _apply_default_optional_recurse(self, dct):
    if self.key not in dct:
        _apply_default_optional(self, dct)
    _apply_default_required_recurse(self, dct)


def _remove_default_optional_recurse(self, dct):
    if self.key in dct:
        _remove_default_required_recurse(self, dct)
        _remove_default_optional(self, dct)


def _get_check_conditional(inner):
    def _check_conditional(self, dct):
        if dct.get(self.condition_key, MISSING) == self.condition_value:
            inner(self, dct)
        elif (
                self.condition_key in dct and
                self.ensure_absent and self.key in dct
        ):
            if hasattr(self.condition_value, 'describe_opposite'):
                explanation = self.condition_value.describe_opposite()
            else:
                explanation = f'is not {self.condition_value!r}'
            raise ValidationError(
                f'Expected {self.key} to be absent when {self.condition_key} '
                f'{explanation}, found {self.key}: {dct[self.key]!r}',
            )
    return _check_conditional


def _apply_default_conditional_optional(self, dct):
    if dct.get(self.condition_key, MISSING) == self.condition_value:
        _apply_default_optional(self, dct)


def _remove_default_conditional_optional(self, dct):
    if dct.get(self.condition_key, MISSING) == self.condition_value:
        _remove_default_optional(self, dct)


def _apply_default_conditional_recurse(self, dct):
    if dct.get(self.condition_key, MISSING) == self.condition_value:
        _apply_default_required_recurse(self, dct)


def _remove_default_conditional_recurse(self, dct):
    if dct.get(self.condition_key, MISSING) == self.condition_value:
        _remove_default_required_recurse(self, dct)


def _no_additional_keys_check(self, dct):
    extra = sorted(set(dct) - set(self.keys))
    if extra:
        extra_s = ', '.join(str(x) for x in extra)
        keys_s = ', '.join(str(x) for x in self.keys)
        raise ValidationError(
            f'Additional keys found: {extra_s}.  '
            f'Only these keys are allowed: {keys_s}',
        )


def _warn_additional_keys_check(self, dct):
    extra = sorted(set(dct) - set(self.keys))
    if extra:
        self.callback(extra, self.keys, dct)


Required = collections.namedtuple('Required', ('key', 'check_fn'))
Required.check = _check_required
Required.apply_default = _dct_noop
Required.remove_default = _dct_noop
RequiredRecurse = collections.namedtuple('RequiredRecurse', ('key', 'schema'))
RequiredRecurse.check = _check_required
RequiredRecurse.check_fn = _check_fn_recurse
RequiredRecurse.apply_default = _apply_default_required_recurse
RequiredRecurse.remove_default = _remove_default_required_recurse
Optional = collections.namedtuple('Optional', ('key', 'check_fn', 'default'))
Optional.check = _check_optional
Optional.apply_default = _apply_default_optional
Optional.remove_default = _remove_default_optional
OptionalRecurse = collections.namedtuple(
    'OptionalRecurse', ('key', 'schema', 'default'),
)
OptionalRecurse.check = _check_optional
OptionalRecurse.check_fn = _check_fn_recurse
OptionalRecurse.apply_default = _apply_default_optional_recurse
OptionalRecurse.remove_default = _remove_default_optional_recurse
OptionalNoDefault = collections.namedtuple(
    'OptionalNoDefault', ('key', 'check_fn'),
)
OptionalNoDefault.check = _check_optional
OptionalNoDefault.apply_default = _dct_noop
OptionalNoDefault.remove_default = _dct_noop
Conditional = collections.namedtuple(
    'Conditional',
    ('key', 'check_fn', 'condition_key', 'condition_value', 'ensure_absent'),
)
Conditional.__new__.__defaults__ = (False,)
Conditional.check = _get_check_conditional(_check_required)
Conditional.apply_default = _dct_noop
Conditional.remove_default = _dct_noop
ConditionalOptional = collections.namedtuple(
    'ConditionalOptional',
    (
        'key', 'check_fn', 'default', 'condition_key', 'condition_value',
        'ensure_absent',
    ),
)
ConditionalOptional.__new__.__defaults__ = (False,)
ConditionalOptional.check = _get_check_conditional(_check_optional)
ConditionalOptional.apply_default = _apply_default_conditional_optional
ConditionalOptional.remove_default = _remove_default_conditional_optional
ConditionalRecurse = collections.namedtuple(
    'ConditionalRecurse',
    ('key', 'schema', 'condition_key', 'condition_value', 'ensure_absent'),
)
ConditionalRecurse.__new__.__defaults__ = (False,)
ConditionalRecurse.check = _get_check_conditional(_check_required)
ConditionalRecurse.check_fn = _check_fn_recurse
ConditionalRecurse.apply_default = _apply_default_conditional_recurse
ConditionalRecurse.remove_default = _remove_default_conditional_recurse
NoAdditionalKeys = collections.namedtuple('NoAdditionalKeys', ('keys',))
NoAdditionalKeys.check = _no_additional_keys_check
NoAdditionalKeys.apply_default = _dct_noop
NoAdditionalKeys.remove_default = _dct_noop
WarnAdditionalKeys = collections.namedtuple(
    'WarnAdditionalKeys', ('keys', 'callback'),
)
WarnAdditionalKeys.check = _warn_additional_keys_check
WarnAdditionalKeys.apply_default = _dct_noop
WarnAdditionalKeys.remove_default = _dct_noop


class Map(collections.namedtuple('Map', ('object_name', 'id_key', 'items'))):
    __slots__ = ()

    def __new__(cls, object_name, id_key, *items):
        return super().__new__(cls, object_name, id_key, items)

    def check(self, v):
        if not isinstance(v, dict):
            raise ValidationError(
                f'Expected a {self.object_name} map but got a '
                f'{type(v).__name__}',
            )
        if self.id_key is None:
            context = f'At {self.object_name}()'
        else:
            key_v_s = v.get(self.id_key, MISSING)
            context = f'At {self.object_name}({self.id_key}={key_v_s!r})'
        with validate_context(context):
            for item in self.items:
                item.check(v)

    def apply_defaults(self, v):
        ret = v.copy()
        for item in self.items:
            item.apply_default(ret)
        return ret

    def remove_defaults(self, v):
        ret = v.copy()
        for item in self.items:
            item.remove_default(ret)
        return ret


class Array(collections.namedtuple('Array', ('of', 'allow_empty'))):
    __slots__ = ()

    def __new__(cls, of, allow_empty=True):
        return super().__new__(cls, of=of, allow_empty=allow_empty)

    def check(self, v):
        check_array(check_any)(v)
        if not self.allow_empty and not v:
            raise ValidationError(
                f"Expected at least 1 '{self.of.object_name}'",
            )
        for val in v:
            validate(val, self.of)

    def apply_defaults(self, v):
        return [apply_defaults(val, self.of) for val in v]

    def remove_defaults(self, v):
        return [remove_defaults(val, self.of) for val in v]


class Not(collections.namedtuple('Not', ('val',))):
    __slots__ = ()

    def describe_opposite(self):
        return f'is {self.val!r}'

    def __eq__(self, other):
        return other is not MISSING and other != self.val


class NotIn(collections.namedtuple('NotIn', ('values',))):
    __slots__ = ()

    def __new__(cls, *values):
        return super().__new__(cls, values=values)

    def describe_opposite(self):
        return f'is any of {self.values!r}'

    def __eq__(self, other):
        return other is not MISSING and other not in self.values


class In(collections.namedtuple('In', ('values',))):
    __slots__ = ()

    def __new__(cls, *values):
        return super().__new__(cls, values=values)

    def describe_opposite(self):
        return f'is not any of {self.values!r}'

    def __eq__(self, other):
        return other is not MISSING and other in self.values


def check_any(_):
    pass


def check_type(tp, typename=None):
    def check_type_fn(v):
        if not isinstance(v, tp):
            typename_s = typename or tp.__name__
            raise ValidationError(
                f'Expected {typename_s} got {type(v).__name__}',
            )
    return check_type_fn


check_bool = check_type(bool)
check_bytes = check_type(bytes)
check_int = check_type(int)
check_string = check_type(str, typename='string')
check_text = check_type(str, typename='text')


def check_one_of(possible):
    def check_one_of_fn(v):
        if v not in possible:
            possible_s = ', '.join(str(x) for x in sorted(possible))
            raise ValidationError(
                f'Expected one of {possible_s} but got: {v!r}',
            )
    return check_one_of_fn


def check_regex(v):
    try:
        re.compile(v)
    except re.error:
        raise ValidationError(f'{v!r} is not a valid python regex')


def check_array(inner_check):
    def check_array_fn(v):
        if not isinstance(v, (list, tuple)):
            raise ValidationError(
                f'Expected array but got {type(v).__name__!r}',
            )

        for i, val in enumerate(v):
            with validate_context(f'At index {i}'):
                inner_check(val)
    return check_array_fn


def check_and(*fns):
    def check(v):
        for fn in fns:
            fn(v)
    return check


def validate(v, schema):
    schema.check(v)
    return v


def apply_defaults(v, schema):
    return schema.apply_defaults(v)


def remove_defaults(v, schema):
    return schema.remove_defaults(v)


def load_from_filename(
        filename,
        schema,
        load_strategy,
        exc_tp=ValidationError,
        *,
        display_filename=None,
):
    display_filename = display_filename or filename
    with reraise_as(exc_tp):
        if not os.path.isfile(filename):
            raise ValidationError(f'{display_filename} is not a file')

        with validate_context(f'File {display_filename}'):
            try:
                with open(filename, encoding='utf-8') as f:
                    contents = f.read()
            except UnicodeDecodeError as e:
                raise ValidationError(str(e))

            try:
                data = load_strategy(contents)
            except Exception as e:
                raise ValidationError(str(e))

            validate(data, schema)
            return apply_defaults(data, schema)

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
April 04 2025 07:59:49
root / root
0755
Mako-1.3.9.dist-info
--
April 04 2025 08:00:26
root / root
0755
MarkupSafe-3.0.2.dist-info
--
April 04 2025 08:00:21
root / root
0755
MySQLdb
--
April 04 2025 08:00:21
root / root
0755
PySocks-1.7.1.dist-info
--
April 04 2025 08:00:20
root / root
0755
PyYAML-6.0.2.dist-info
--
April 04 2025 08:00:20
root / root
0755
__pycache__
--
April 04 2025 08:05:01
root / root
0755
_yaml
--
April 04 2025 08:00:20
root / root
0755
aenum
--
April 04 2025 08:00:20
root / root
0755
aenum-3.1.15.dist-info
--
April 04 2025 08:00:20
root / root
0755
alembic
--
April 04 2025 08:00:29
root / root
0755
alembic-1.15.1.dist-info
--
April 04 2025 08:00:29
root / root
0755
annotated_types
--
April 04 2025 08:00:22
root / root
0755
annotated_types-0.7.0.dist-info
--
April 04 2025 08:00:22
root / root
0755
certifi
--
April 04 2025 08:00:22
root / root
0755
certifi-2025.1.31.dist-info
--
April 04 2025 08:00:22
root / root
0755
cfgv-3.4.0.dist-info
--
April 04 2025 08:00:22
root / root
0755
charset_normalizer
--
April 04 2025 08:00:22
root / root
0755
charset_normalizer-3.4.1.dist-info
--
April 04 2025 08:00:22
root / root
0755
curl
--
April 04 2025 07:59:57
root / root
0755
dict2xml
--
April 04 2025 08:00:22
root / root
0755
dict2xml-1.7.6.dist-info
--
April 04 2025 08:00:22
root / root
0755
dicttoxml-1.7.16.dist-info
--
April 04 2025 08:00:22
root / root
0755
distlib
--
April 04 2025 08:00:20
root / root
0755
distlib-0.3.9.dist-info
--
April 04 2025 08:00:20
root / root
0755
distro
--
April 04 2025 08:00:22
root / root
0755
distro-1.9.0.dist-info
--
April 04 2025 08:00:22
root / root
0755
dns
--
April 04 2025 08:00:22
root / root
0755
dnspython-2.7.0.dist-info
--
April 04 2025 08:00:22
root / root
0755
filelock
--
April 04 2025 08:00:22
root / root
0755
filelock-3.18.0.dist-info
--
April 04 2025 08:00:22
root / root
0755
greenlet
--
May 23 2025 08:31:29
root / root
0755
greenlet-3.2.2.dist-info
--
May 23 2025 08:31:29
root / root
0755
identify
--
April 04 2025 08:00:22
root / root
0755
identify-2.6.9.dist-info
--
April 04 2025 08:00:22
root / root
0755
idna
--
April 04 2025 08:00:21
root / root
0755
idna-3.10.dist-info
--
April 04 2025 08:00:22
root / root
0755
importlib_metadata
--
May 23 2025 08:31:29
root / root
0755
importlib_metadata-8.7.0.dist-info
--
May 23 2025 08:31:29
root / root
0755
importlib_resources
--
April 04 2025 08:00:21
root / root
0755
importlib_resources-6.5.2.dist-info
--
April 04 2025 08:00:21
root / root
0755
inotify
--
April 04 2025 08:00:21
root / root
0755
inotify-0.2.10.dist-info
--
April 04 2025 08:00:21
root / root
0755
lxml
--
April 04 2025 08:00:21
root / root
0755
lxml-5.3.1.dist-info
--
April 04 2025 08:00:21
root / root
0755
mako
--
April 04 2025 08:00:26
root / root
0755
markupsafe
--
April 04 2025 08:00:21
root / root
0755
mysql
--
April 04 2025 08:00:19
root / root
0755
mysql-0.0.3.dist-info
--
April 04 2025 08:00:26
root / root
0755
mysql_connector-2.2.9.dist-info
--
April 04 2025 08:00:20
root / root
0755
mysqlclient-2.2.7.dist-info
--
April 04 2025 08:00:21
root / root
0755
mysqlx
--
April 04 2025 08:00:19
root / root
0755
nodeenv-1.9.1.dist-info
--
April 04 2025 08:00:21
root / root
0755
nose
--
April 04 2025 08:00:19
root / root
0755
nose-1.3.7.dist-info
--
April 04 2025 08:00:19
root / root
0755
packaging
--
May 23 2025 08:31:29
root / root
0755
packaging-25.0.dist-info
--
May 23 2025 08:31:29
root / root
0755
pip
--
May 23 2025 08:31:17
root / root
0755
pip-25.1.1.dist-info
--
May 23 2025 08:31:18
root / root
0755
platformdirs
--
April 04 2025 08:00:21
root / root
0755
platformdirs-4.3.7.dist-info
--
April 04 2025 08:00:21
root / root
0755
pre_commit
--
April 04 2025 08:00:28
root / root
0755
pre_commit-4.2.0.dist-info
--
April 04 2025 08:00:29
root / root
0755
prometheus_client
--
April 04 2025 08:00:21
root / root
0755
prometheus_client-0.21.1.dist-info
--
April 04 2025 08:00:21
root / root
0755
psutil
--
April 04 2025 08:00:21
root / root
0755
psutil-7.0.0.dist-info
--
April 04 2025 08:00:21
root / root
0755
pycurl-7.45.6.dist-info
--
April 04 2025 07:59:57
root / root
0755
pycurl.libs
--
April 04 2025 07:59:57
root / root
0755
pydantic
--
April 04 2025 08:00:28
root / root
0755
pydantic-2.8.2.dist-info
--
April 04 2025 08:00:28
root / root
0755
pydantic_core
--
April 04 2025 08:00:26
root / root
0755
pydantic_core-2.20.1.dist-info
--
April 04 2025 08:00:26
root / root
0755
pyone
--
April 04 2025 08:00:26
root / root
0755
pyone-6.10.3.dist-info
--
April 04 2025 08:00:28
root / root
0755
requests
--
April 04 2025 08:00:26
root / root
0755
requests-2.32.3.dist-info
--
April 04 2025 08:00:26
root / root
0755
sentry_sdk
--
May 23 2025 08:31:28
root / root
0755
sentry_sdk-2.29.1.dist-info
--
May 23 2025 08:31:28
root / root
0755
six-1.17.0.dist-info
--
April 04 2025 08:00:20
root / root
0755
sqlalchemy
--
April 04 2025 08:00:23
root / root
0755
sqlalchemy-2.0.39.dist-info
--
April 04 2025 08:00:25
root / root
0755
tblib
--
April 04 2025 08:00:20
root / root
0755
tblib-3.1.0.dist-info
--
April 04 2025 08:00:20
root / root
0755
typing_extensions-4.13.1.dist-info
--
April 04 2025 08:00:20
root / root
0755
urllib3
--
April 04 2025 08:00:20
root / root
0755
urllib3-2.3.0.dist-info
--
April 04 2025 08:00:20
root / root
0755
virtualenv
--
April 04 2025 08:00:22
root / root
0755
virtualenv-20.30.0.dist-info
--
April 04 2025 08:00:23
root / root
0755
wheel
--
April 04 2025 08:00:20
root / root
0755
wheel-0.45.1.dist-info
--
April 04 2025 08:00:20
root / root
0755
xmltodict-0.14.2.dist-info
--
April 04 2025 08:00:20
root / root
0755
yaml
--
April 04 2025 08:00:20
root / root
0755
zipp
--
April 04 2025 08:00:20
root / root
0755
zipp-3.21.0.dist-info
--
April 04 2025 08:00:20
root / root
0755
.sentry.conf
0.099 KB
April 04 2025 08:00:36
root / root
0600
NCSentry.py
1.496 KB
March 26 2025 11:05:09
root / root
0644
cfgv.py
11.934 KB
April 04 2025 08:00:22
root / root
0644
dicttoxml.py
14.646 KB
April 04 2025 08:00:22
root / root
0644
nodeenv.py
45.581 KB
April 04 2025 08:00:21
root / root
0644
pycurl.cpython-312-x86_64-linux-gnu.so
717.587 KB
April 04 2025 07:59:57
root / root
0755
six.py
33.89 KB
April 04 2025 08:00:20
root / root
0644
socks.py
30.357 KB
April 04 2025 08:00:20
root / root
0644
sockshandler.py
3.873 KB
April 04 2025 08:00:20
root / root
0644
typing_extensions.py
168.106 KB
April 04 2025 08:00:20
root / root
0644
xmltodict.py
18.047 KB
April 04 2025 08:00:20
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF