]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.10/Lib/functools.py
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.10 / Lib / functools.py
diff --git a/AppPkg/Applications/Python/Python-2.7.10/Lib/functools.py b/AppPkg/Applications/Python/Python-2.7.10/Lib/functools.py
deleted file mode 100644 (file)
index b267245..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-"""functools.py - Tools for working with functions and callable objects\r
-"""\r
-# Python module wrapper for _functools C module\r
-# to allow utilities written in Python to be added\r
-# to the functools module.\r
-# Written by Nick Coghlan <ncoghlan at gmail.com>\r
-#   Copyright (C) 2006 Python Software Foundation.\r
-# See C source code for _functools credits/copyright\r
-\r
-from _functools import partial, reduce\r
-\r
-# update_wrapper() and wraps() are tools to help write\r
-# wrapper functions that can handle naive introspection\r
-\r
-WRAPPER_ASSIGNMENTS = ('__module__', '__name__', '__doc__')\r
-WRAPPER_UPDATES = ('__dict__',)\r
-def update_wrapper(wrapper,\r
-                   wrapped,\r
-                   assigned = WRAPPER_ASSIGNMENTS,\r
-                   updated = WRAPPER_UPDATES):\r
-    """Update a wrapper function to look like the wrapped function\r
-\r
-       wrapper is the function to be updated\r
-       wrapped is the original function\r
-       assigned is a tuple naming the attributes assigned directly\r
-       from the wrapped function to the wrapper function (defaults to\r
-       functools.WRAPPER_ASSIGNMENTS)\r
-       updated is a tuple naming the attributes of the wrapper that\r
-       are updated with the corresponding attribute from the wrapped\r
-       function (defaults to functools.WRAPPER_UPDATES)\r
-    """\r
-    for attr in assigned:\r
-        setattr(wrapper, attr, getattr(wrapped, attr))\r
-    for attr in updated:\r
-        getattr(wrapper, attr).update(getattr(wrapped, attr, {}))\r
-    # Return the wrapper so this can be used as a decorator via partial()\r
-    return wrapper\r
-\r
-def wraps(wrapped,\r
-          assigned = WRAPPER_ASSIGNMENTS,\r
-          updated = WRAPPER_UPDATES):\r
-    """Decorator factory to apply update_wrapper() to a wrapper function\r
-\r
-       Returns a decorator that invokes update_wrapper() with the decorated\r
-       function as the wrapper argument and the arguments to wraps() as the\r
-       remaining arguments. Default arguments are as for update_wrapper().\r
-       This is a convenience function to simplify applying partial() to\r
-       update_wrapper().\r
-    """\r
-    return partial(update_wrapper, wrapped=wrapped,\r
-                   assigned=assigned, updated=updated)\r
-\r
-def total_ordering(cls):\r
-    """Class decorator that fills in missing ordering methods"""\r
-    convert = {\r
-        '__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),\r
-                   ('__le__', lambda self, other: self < other or self == other),\r
-                   ('__ge__', lambda self, other: not self < other)],\r
-        '__le__': [('__ge__', lambda self, other: not self <= other or self == other),\r
-                   ('__lt__', lambda self, other: self <= other and not self == other),\r
-                   ('__gt__', lambda self, other: not self <= other)],\r
-        '__gt__': [('__lt__', lambda self, other: not (self > other or self == other)),\r
-                   ('__ge__', lambda self, other: self > other or self == other),\r
-                   ('__le__', lambda self, other: not self > other)],\r
-        '__ge__': [('__le__', lambda self, other: (not self >= other) or self == other),\r
-                   ('__gt__', lambda self, other: self >= other and not self == other),\r
-                   ('__lt__', lambda self, other: not self >= other)]\r
-    }\r
-    roots = set(dir(cls)) & set(convert)\r
-    if not roots:\r
-        raise ValueError('must define at least one ordering operation: < > <= >=')\r
-    root = max(roots)       # prefer __lt__ to __le__ to __gt__ to __ge__\r
-    for opname, opfunc in convert[root]:\r
-        if opname not in roots:\r
-            opfunc.__name__ = opname\r
-            opfunc.__doc__ = getattr(int, opname).__doc__\r
-            setattr(cls, opname, opfunc)\r
-    return cls\r
-\r
-def cmp_to_key(mycmp):\r
-    """Convert a cmp= function into a key= function"""\r
-    class K(object):\r
-        __slots__ = ['obj']\r
-        def __init__(self, obj, *args):\r
-            self.obj = obj\r
-        def __lt__(self, other):\r
-            return mycmp(self.obj, other.obj) < 0\r
-        def __gt__(self, other):\r
-            return mycmp(self.obj, other.obj) > 0\r
-        def __eq__(self, other):\r
-            return mycmp(self.obj, other.obj) == 0\r
-        def __le__(self, other):\r
-            return mycmp(self.obj, other.obj) <= 0\r
-        def __ge__(self, other):\r
-            return mycmp(self.obj, other.obj) >= 0\r
-        def __ne__(self, other):\r
-            return mycmp(self.obj, other.obj) != 0\r
-        def __hash__(self):\r
-            raise TypeError('hash not implemented')\r
-    return K\r