✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ beluga.o2switch.net ​🇻​♯➤ 4.18.0-553.123.2.lve.el8.x86_64 #1 SMP 🇾​♯➤ 2026

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 185.154.139.77 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.216.254
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ 𝗔𝗟𝗟 𝗪𝗢𝗥𝗞𝗜𝗡𝗚....

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /opt/alt/python37/lib64/python3.7/site-packages/twisted/python//formmethod.py
# -*- test-case-name: twisted.test.test_formmethod -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.


"""
Form-based method objects.

This module contains support for descriptive method signatures that can be used
to format methods.
"""

import calendar

from twisted.python._oldstyle import _oldStyle


class FormException(Exception):
    """An error occurred calling the form method.
    """
    def __init__(self, *args, **kwargs):
        Exception.__init__(self, *args)
        self.descriptions = kwargs


class InputError(FormException):
    """
    An error occurred with some input.
    """



@_oldStyle
class Argument:
    """Base class for form arguments."""

    # default value for argument, if no other default is given
    defaultDefault = None

    def __init__(self, name, default=None, shortDesc=None,
                 longDesc=None, hints=None, allowNone=1):
        self.name = name
        self.allowNone = allowNone
        if default is None:
            default = self.defaultDefault
        self.default = default
        self.shortDesc = shortDesc
        self.longDesc = longDesc
        if not hints:
            hints = {}
        self.hints = hints

    def addHints(self, **kwargs):
        self.hints.update(kwargs)

    def getHint(self, name, default=None):
        return self.hints.get(name, default)

    def getShortDescription(self):
        return self.shortDesc or self.name.capitalize()

    def getLongDescription(self):
        return self.longDesc or '' #self.shortDesc or "The %s." % self.name

    def coerce(self, val):
        """Convert the value to the correct format."""
        raise NotImplementedError("implement in subclass")


class String(Argument):
    """A single string.
    """
    defaultDefault = ''
    min = 0
    max = None

    def __init__(self, name, default=None, shortDesc=None,
                 longDesc=None, hints=None, allowNone=1, min=0, max=None):
        Argument.__init__(self, name, default=default, shortDesc=shortDesc,
                          longDesc=longDesc, hints=hints, allowNone=allowNone)
        self.min = min
        self.max = max

    def coerce(self, val):
        s = str(val)
        if len(s) < self.min:
            raise InputError("Value must be at least %s characters long" % self.min)
        if self.max != None and len(s) > self.max:
            raise InputError("Value must be at most %s characters long" % self.max)
        return str(val)


class Text(String):
    """A long string.
    """


class Password(String):
    """A string which should be obscured when input.
    """


class VerifiedPassword(String):
    """A string that should be obscured when input and needs verification."""

    def coerce(self, vals):
        if len(vals) != 2 or vals[0] != vals[1]:
            raise InputError("Please enter the same password twice.")
        s = str(vals[0])
        if len(s) < self.min:
            raise InputError("Value must be at least %s characters long" % self.min)
        if self.max != None and len(s) > self.max:
            raise InputError("Value must be at most %s characters long" % self.max)
        return s


class Hidden(String):
    """A string which is not displayed.

    The passed default is used as the value.
    """


class Integer(Argument):
    """A single integer.
    """
    defaultDefault = None

    def __init__(self, name, allowNone=1, default=None, shortDesc=None,
                 longDesc=None, hints=None):
        #although Argument now has allowNone, that was recently added, and
        #putting it at the end kept things which relied on argument order
        #from breaking.  However, allowNone originally was in here, so
        #I have to keep the same order, to prevent breaking code that
        #depends on argument order only
        Argument.__init__(self, name, default, shortDesc, longDesc, hints,
                          allowNone)

    def coerce(self, val):
        if not val.strip() and self.allowNone:
            return None
        try:
            return int(val)
        except ValueError:
            raise InputError("%s is not valid, please enter a whole number, e.g. 10" % val)


class IntegerRange(Integer):

    def __init__(self, name, min, max, allowNone=1, default=None, shortDesc=None,
                 longDesc=None, hints=None):
        self.min = min
        self.max = max
        Integer.__init__(self, name, allowNone=allowNone, default=default, shortDesc=shortDesc,
                         longDesc=longDesc, hints=hints)

    def coerce(self, val):
        result = Integer.coerce(self, val)
        if self.allowNone and result == None:
            return result
        if result < self.min:
            raise InputError("Value %s is too small, it should be at least %s" % (result, self.min))
        if result > self.max:
            raise InputError("Value %s is too large, it should be at most %s" % (result, self.max))
        return result


class Float(Argument):

    defaultDefault = None

    def __init__(self, name, allowNone=1, default=None, shortDesc=None,
                 longDesc=None, hints=None):
        #although Argument now has allowNone, that was recently added, and
        #putting it at the end kept things which relied on argument order
        #from breaking.  However, allowNone originally was in here, so
        #I have to keep the same order, to prevent breaking code that
        #depends on argument order only
        Argument.__init__(self, name, default, shortDesc, longDesc, hints,
                          allowNone)


    def coerce(self, val):
        if not val.strip() and self.allowNone:
            return None
        try:
            return float(val)
        except ValueError:
            raise InputError("Invalid float: %s" % val)


class Choice(Argument):
    """
    The result of a choice between enumerated types.  The choices should
    be a list of tuples of tag, value, and description.  The tag will be
    the value returned if the user hits "Submit", and the description
    is the bale for the enumerated type.  default is a list of all the
    values (seconds element in choices).  If no defaults are specified,
    initially the first item will be selected.  Only one item can (should)
    be selected at once.
    """
    def __init__(self, name, choices=[], default=[], shortDesc=None,
                 longDesc=None, hints=None, allowNone=1):
        self.choices = choices
        if choices and not default:
            default.append(choices[0][1])
        Argument.__init__(self, name, default, shortDesc, longDesc, hints, allowNone=allowNone)

    def coerce(self, inIdent):
        for ident, val, desc in self.choices:
            if ident == inIdent:
                return val
        else:
            raise InputError("Invalid Choice: %s" % inIdent)


class Flags(Argument):
    """
    The result of a checkbox group or multi-menu.  The flags should be a
    list of tuples of tag, value, and description. The tag will be
    the value returned if the user hits "Submit", and the description
    is the bale for the enumerated type.  default is a list of all the
    values (second elements in flags).  If no defaults are specified,
    initially nothing will be selected.  Several items may be selected at
    once.
    """
    def __init__(self, name, flags=(), default=(), shortDesc=None,
                 longDesc=None, hints=None, allowNone=1):
        self.flags = flags
        Argument.__init__(self, name, default, shortDesc, longDesc, hints, allowNone=allowNone)

    def coerce(self, inFlagKeys):
        if not inFlagKeys:
            return []
        outFlags = []
        for inFlagKey in inFlagKeys:
            for flagKey, flagVal, flagDesc in self.flags:
                if inFlagKey == flagKey:
                    outFlags.append(flagVal)
                    break
            else:
                raise InputError("Invalid Flag: %s" % inFlagKey)
        return outFlags


class CheckGroup(Flags):
    pass


class RadioGroup(Choice):
    pass


class Boolean(Argument):
    def coerce(self, inVal):
        if not inVal:
            return 0
        lInVal = str(inVal).lower()
        if lInVal in ('no', 'n', 'f', 'false', '0'):
            return 0
        return 1

class File(Argument):
    def __init__(self, name, allowNone=1, shortDesc=None, longDesc=None,
                 hints=None):
        Argument.__init__(self, name, None, shortDesc, longDesc, hints,
                          allowNone=allowNone)

    def coerce(self, file):
        if not file and self.allowNone:
            return None
        elif file:
            return file
        else:
            raise InputError("Invalid File")

def positiveInt(x):
    x = int(x)
    if x <= 0: raise ValueError
    return x

class Date(Argument):
    """A date -- (year, month, day) tuple."""

    defaultDefault = None

    def __init__(self, name, allowNone=1, default=None, shortDesc=None,
                 longDesc=None, hints=None):
        Argument.__init__(self, name, default, shortDesc, longDesc, hints)
        self.allowNone = allowNone
        if not allowNone:
            self.defaultDefault = (1970, 1, 1)

    def coerce(self, args):
        """Return tuple of ints (year, month, day)."""
        if tuple(args) == ("", "", "") and self.allowNone:
            return None

        try:
            year, month, day = map(positiveInt, args)
        except ValueError:
            raise InputError("Invalid date")
        if (month, day) == (2, 29):
            if not calendar.isleap(year):
                raise InputError("%d was not a leap year" % year)
            else:
                return year, month, day
        try:
            mdays = calendar.mdays[month]
        except IndexError:
            raise InputError("Invalid date")
        if day > mdays:
            raise InputError("Invalid date")
        return year, month, day


class Submit(Choice):
    """Submit button or a reasonable facsimile thereof."""

    def __init__(self, name, choices=[("Submit", "submit", "Submit form")],
                 reset=0, shortDesc=None, longDesc=None, allowNone=0, hints=None):
        Choice.__init__(self, name, choices=choices, shortDesc=shortDesc,
                        longDesc=longDesc, hints=hints)
        self.allowNone = allowNone
        self.reset = reset

    def coerce(self, value):
        if self.allowNone and not value:
            return None
        else:
            return Choice.coerce(self, value)



@_oldStyle
class PresentationHint:
    """
    A hint to a particular system.
    """



@_oldStyle
class MethodSignature:
    """
    A signature of a callable.
    """

    def __init__(self, *sigList):
        """
        """
        self.methodSignature = sigList

    def getArgument(self, name):
        for a in self.methodSignature:
            if a.name == name:
                return a

    def method(self, callable, takesRequest=False):
        return FormMethod(self, callable, takesRequest)



@_oldStyle
class FormMethod:
    """A callable object with a signature."""

    def __init__(self, signature, callable, takesRequest=False):
        self.signature = signature
        self.callable = callable
        self.takesRequest = takesRequest

    def getArgs(self):
        return tuple(self.signature.methodSignature)

    def call(self,*args,**kw):
        return self.callable(*args,**kw)


Current_dir [ 𝗡𝗢𝗧 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
1 Jan 1970 12.00 AM
root / root
0
__pycache__
--
25 Jul 2024 8.43 AM
root / linksafe
0755
_pydoctortemplates
--
25 Jul 2024 8.43 AM
root / linksafe
0755
test
--
25 Jul 2024 8.43 AM
root / linksafe
0755
__init__.py
0.658 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
_appdirs.py
0.77 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
_inotify.py
3.374 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
_oldstyle.py
2.532 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
_release.py
18.34 KB
18 Mar 2020 8.27 AM
root / linksafe
0644
_setup.py
13.946 KB
8 Mar 2020 10.44 AM
root / linksafe
0644
_shellcomp.py
24.248 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
_textattributes.py
8.866 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
_tzhelper.py
3.117 KB
26 May 2019 5.43 AM
root / linksafe
0644
_url.py
0.247 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
compat.py
23.196 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
components.py
13.92 KB
8 Mar 2020 10.44 AM
root / linksafe
0644
constants.py
0.531 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
context.py
3.93 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
deprecate.py
26.316 KB
18 Dec 2019 3.37 AM
root / linksafe
0644
failure.py
26.918 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
fakepwd.py
5.994 KB
26 May 2019 5.43 AM
root / linksafe
0644
filepath.py
57.507 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
formmethod.py
11.191 KB
26 May 2019 5.43 AM
root / linksafe
0644
htmlizer.py
3.458 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
lockfile.py
7.537 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
log.py
21.945 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
logfile.py
9.847 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
modules.py
26.505 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
monkey.py
2.175 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
procutils.py
1.386 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
randbytes.py
3.866 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
rebuild.py
9.051 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
reflect.py
19.021 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
release.py
1.164 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
roots.py
7.23 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
runtime.py
6.07 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
sendmsg.py
3.34 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
shortcut.py
2.2 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
syslog.py
3.643 KB
26 May 2019 5.43 AM
root / linksafe
0644
systemd.py
2.768 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
text.py
5.354 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
threadable.py
3.22 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
threadpool.py
9.609 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
twisted-completion.zsh
1.339 KB
15 Jun 2019 9.59 PM
root / linksafe
0644
url.py
0.238 KB
26 May 2019 5.43 AM
root / linksafe
0644
urlpath.py
8.871 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
usage.py
34.182 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
util.py
27.276 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
versions.py
0.314 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
win32.py
4.216 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
zippath.py
9.021 KB
18 Dec 2019 3.08 AM
root / linksafe
0644
zipstream.py
9.528 KB
18 Dec 2019 3.08 AM
root / linksafe
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF