]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Lib/stringold.py
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / stringold.py
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Lib/stringold.py b/AppPkg/Applications/Python/Python-2.7.2/Lib/stringold.py
deleted file mode 100644 (file)
index 5282341..0000000
+++ /dev/null
@@ -1,432 +0,0 @@
-# module 'string' -- A collection of string operations\r
-\r
-# Warning: most of the code you see here isn't normally used nowadays.  With\r
-# Python 1.6, many of these functions are implemented as methods on the\r
-# standard string object. They used to be implemented by a built-in module\r
-# called strop, but strop is now obsolete itself.\r
-\r
-"""Common string manipulations.\r
-\r
-Public module variables:\r
-\r
-whitespace -- a string containing all characters considered whitespace\r
-lowercase -- a string containing all characters considered lowercase letters\r
-uppercase -- a string containing all characters considered uppercase letters\r
-letters -- a string containing all characters considered letters\r
-digits -- a string containing all characters considered decimal digits\r
-hexdigits -- a string containing all characters considered hexadecimal digits\r
-octdigits -- a string containing all characters considered octal digits\r
-\r
-"""\r
-from warnings import warnpy3k\r
-warnpy3k("the stringold module has been removed in Python 3.0", stacklevel=2)\r
-del warnpy3k\r
-\r
-# Some strings for ctype-style character classification\r
-whitespace = ' \t\n\r\v\f'\r
-lowercase = 'abcdefghijklmnopqrstuvwxyz'\r
-uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\r
-letters = lowercase + uppercase\r
-digits = '0123456789'\r
-hexdigits = digits + 'abcdef' + 'ABCDEF'\r
-octdigits = '01234567'\r
-\r
-# Case conversion helpers\r
-_idmap = ''\r
-for i in range(256): _idmap = _idmap + chr(i)\r
-del i\r
-\r
-# Backward compatible names for exceptions\r
-index_error = ValueError\r
-atoi_error = ValueError\r
-atof_error = ValueError\r
-atol_error = ValueError\r
-\r
-# convert UPPER CASE letters to lower case\r
-def lower(s):\r
-    """lower(s) -> string\r
-\r
-    Return a copy of the string s converted to lowercase.\r
-\r
-    """\r
-    return s.lower()\r
-\r
-# Convert lower case letters to UPPER CASE\r
-def upper(s):\r
-    """upper(s) -> string\r
-\r
-    Return a copy of the string s converted to uppercase.\r
-\r
-    """\r
-    return s.upper()\r
-\r
-# Swap lower case letters and UPPER CASE\r
-def swapcase(s):\r
-    """swapcase(s) -> string\r
-\r
-    Return a copy of the string s with upper case characters\r
-    converted to lowercase and vice versa.\r
-\r
-    """\r
-    return s.swapcase()\r
-\r
-# Strip leading and trailing tabs and spaces\r
-def strip(s):\r
-    """strip(s) -> string\r
-\r
-    Return a copy of the string s with leading and trailing\r
-    whitespace removed.\r
-\r
-    """\r
-    return s.strip()\r
-\r
-# Strip leading tabs and spaces\r
-def lstrip(s):\r
-    """lstrip(s) -> string\r
-\r
-    Return a copy of the string s with leading whitespace removed.\r
-\r
-    """\r
-    return s.lstrip()\r
-\r
-# Strip trailing tabs and spaces\r
-def rstrip(s):\r
-    """rstrip(s) -> string\r
-\r
-    Return a copy of the string s with trailing whitespace\r
-    removed.\r
-\r
-    """\r
-    return s.rstrip()\r
-\r
-\r
-# Split a string into a list of space/tab-separated words\r
-def split(s, sep=None, maxsplit=0):\r
-    """split(str [,sep [,maxsplit]]) -> list of strings\r
-\r
-    Return a list of the words in the string s, using sep as the\r
-    delimiter string.  If maxsplit is nonzero, splits into at most\r
-    maxsplit words If sep is not specified, any whitespace string\r
-    is a separator.  Maxsplit defaults to 0.\r
-\r
-    (split and splitfields are synonymous)\r
-\r
-    """\r
-    return s.split(sep, maxsplit)\r
-splitfields = split\r
-\r
-# Join fields with optional separator\r
-def join(words, sep = ' '):\r
-    """join(list [,sep]) -> string\r
-\r
-    Return a string composed of the words in list, with\r
-    intervening occurrences of sep.  The default separator is a\r
-    single space.\r
-\r
-    (joinfields and join are synonymous)\r
-\r
-    """\r
-    return sep.join(words)\r
-joinfields = join\r
-\r
-# for a little bit of speed\r
-_apply = apply\r
-\r
-# Find substring, raise exception if not found\r
-def index(s, *args):\r
-    """index(s, sub [,start [,end]]) -> int\r
-\r
-    Like find but raises ValueError when the substring is not found.\r
-\r
-    """\r
-    return _apply(s.index, args)\r
-\r
-# Find last substring, raise exception if not found\r
-def rindex(s, *args):\r
-    """rindex(s, sub [,start [,end]]) -> int\r
-\r
-    Like rfind but raises ValueError when the substring is not found.\r
-\r
-    """\r
-    return _apply(s.rindex, args)\r
-\r
-# Count non-overlapping occurrences of substring\r
-def count(s, *args):\r
-    """count(s, sub[, start[,end]]) -> int\r
-\r
-    Return the number of occurrences of substring sub in string\r
-    s[start:end].  Optional arguments start and end are\r
-    interpreted as in slice notation.\r
-\r
-    """\r
-    return _apply(s.count, args)\r
-\r
-# Find substring, return -1 if not found\r
-def find(s, *args):\r
-    """find(s, sub [,start [,end]]) -> in\r
-\r
-    Return the lowest index in s where substring sub is found,\r
-    such that sub is contained within s[start,end].  Optional\r
-    arguments start and end are interpreted as in slice notation.\r
-\r
-    Return -1 on failure.\r
-\r
-    """\r
-    return _apply(s.find, args)\r
-\r
-# Find last substring, return -1 if not found\r
-def rfind(s, *args):\r
-    """rfind(s, sub [,start [,end]]) -> int\r
-\r
-    Return the highest index in s where substring sub is found,\r
-    such that sub is contained within s[start,end].  Optional\r
-    arguments start and end are interpreted as in slice notation.\r
-\r
-    Return -1 on failure.\r
-\r
-    """\r
-    return _apply(s.rfind, args)\r
-\r
-# for a bit of speed\r
-_float = float\r
-_int = int\r
-_long = long\r
-_StringType = type('')\r
-\r
-# Convert string to float\r
-def atof(s):\r
-    """atof(s) -> float\r
-\r
-    Return the floating point number represented by the string s.\r
-\r
-    """\r
-    if type(s) == _StringType:\r
-        return _float(s)\r
-    else:\r
-        raise TypeError('argument 1: expected string, %s found' %\r
-                        type(s).__name__)\r
-\r
-# Convert string to integer\r
-def atoi(*args):\r
-    """atoi(s [,base]) -> int\r
-\r
-    Return the integer represented by the string s in the given\r
-    base, which defaults to 10.  The string s must consist of one\r
-    or more digits, possibly preceded by a sign.  If base is 0, it\r
-    is chosen from the leading characters of s, 0 for octal, 0x or\r
-    0X for hexadecimal.  If base is 16, a preceding 0x or 0X is\r
-    accepted.\r
-\r
-    """\r
-    try:\r
-        s = args[0]\r
-    except IndexError:\r
-        raise TypeError('function requires at least 1 argument: %d given' %\r
-                        len(args))\r
-    # Don't catch type error resulting from too many arguments to int().  The\r
-    # error message isn't compatible but the error type is, and this function\r
-    # is complicated enough already.\r
-    if type(s) == _StringType:\r
-        return _apply(_int, args)\r
-    else:\r
-        raise TypeError('argument 1: expected string, %s found' %\r
-                        type(s).__name__)\r
-\r
-\r
-# Convert string to long integer\r
-def atol(*args):\r
-    """atol(s [,base]) -> long\r
-\r
-    Return the long integer represented by the string s in the\r
-    given base, which defaults to 10.  The string s must consist\r
-    of one or more digits, possibly preceded by a sign.  If base\r
-    is 0, it is chosen from the leading characters of s, 0 for\r
-    octal, 0x or 0X for hexadecimal.  If base is 16, a preceding\r
-    0x or 0X is accepted.  A trailing L or l is not accepted,\r
-    unless base is 0.\r
-\r
-    """\r
-    try:\r
-        s = args[0]\r
-    except IndexError:\r
-        raise TypeError('function requires at least 1 argument: %d given' %\r
-                        len(args))\r
-    # Don't catch type error resulting from too many arguments to long().  The\r
-    # error message isn't compatible but the error type is, and this function\r
-    # is complicated enough already.\r
-    if type(s) == _StringType:\r
-        return _apply(_long, args)\r
-    else:\r
-        raise TypeError('argument 1: expected string, %s found' %\r
-                        type(s).__name__)\r
-\r
-\r
-# Left-justify a string\r
-def ljust(s, width):\r
-    """ljust(s, width) -> string\r
-\r
-    Return a left-justified version of s, in a field of the\r
-    specified width, padded with spaces as needed.  The string is\r
-    never truncated.\r
-\r
-    """\r
-    n = width - len(s)\r
-    if n <= 0: return s\r
-    return s + ' '*n\r
-\r
-# Right-justify a string\r
-def rjust(s, width):\r
-    """rjust(s, width) -> string\r
-\r
-    Return a right-justified version of s, in a field of the\r
-    specified width, padded with spaces as needed.  The string is\r
-    never truncated.\r
-\r
-    """\r
-    n = width - len(s)\r
-    if n <= 0: return s\r
-    return ' '*n + s\r
-\r
-# Center a string\r
-def center(s, width):\r
-    """center(s, width) -> string\r
-\r
-    Return a center version of s, in a field of the specified\r
-    width. padded with spaces as needed.  The string is never\r
-    truncated.\r
-\r
-    """\r
-    n = width - len(s)\r
-    if n <= 0: return s\r
-    half = n/2\r
-    if n%2 and width%2:\r
-        # This ensures that center(center(s, i), j) = center(s, j)\r
-        half = half+1\r
-    return ' '*half +  s + ' '*(n-half)\r
-\r
-# Zero-fill a number, e.g., (12, 3) --> '012' and (-3, 3) --> '-03'\r
-# Decadent feature: the argument may be a string or a number\r
-# (Use of this is deprecated; it should be a string as with ljust c.s.)\r
-def zfill(x, width):\r
-    """zfill(x, width) -> string\r
-\r
-    Pad a numeric string x with zeros on the left, to fill a field\r
-    of the specified width.  The string x is never truncated.\r
-\r
-    """\r
-    if type(x) == type(''): s = x\r
-    else: s = repr(x)\r
-    n = len(s)\r
-    if n >= width: return s\r
-    sign = ''\r
-    if s[0] in ('-', '+'):\r
-        sign, s = s[0], s[1:]\r
-    return sign + '0'*(width-n) + s\r
-\r
-# Expand tabs in a string.\r
-# Doesn't take non-printing chars into account, but does understand \n.\r
-def expandtabs(s, tabsize=8):\r
-    """expandtabs(s [,tabsize]) -> string\r
-\r
-    Return a copy of the string s with all tab characters replaced\r
-    by the appropriate number of spaces, depending on the current\r
-    column, and the tabsize (default 8).\r
-\r
-    """\r
-    res = line = ''\r
-    for c in s:\r
-        if c == '\t':\r
-            c = ' '*(tabsize - len(line) % tabsize)\r
-        line = line + c\r
-        if c == '\n':\r
-            res = res + line\r
-            line = ''\r
-    return res + line\r
-\r
-# Character translation through look-up table.\r
-def translate(s, table, deletions=""):\r
-    """translate(s,table [,deletechars]) -> string\r
-\r
-    Return a copy of the string s, where all characters occurring\r
-    in the optional argument deletechars are removed, and the\r
-    remaining characters have been mapped through the given\r
-    translation table, which must be a string of length 256.\r
-\r
-    """\r
-    return s.translate(table, deletions)\r
-\r
-# Capitalize a string, e.g. "aBc  dEf" -> "Abc  def".\r
-def capitalize(s):\r
-    """capitalize(s) -> string\r
-\r
-    Return a copy of the string s with only its first character\r
-    capitalized.\r
-\r
-    """\r
-    return s.capitalize()\r
-\r
-# Capitalize the words in a string, e.g. " aBc  dEf " -> "Abc Def".\r
-def capwords(s, sep=None):\r
-    """capwords(s, [sep]) -> string\r
-\r
-    Split the argument into words using split, capitalize each\r
-    word using capitalize, and join the capitalized words using\r
-    join. Note that this replaces runs of whitespace characters by\r
-    a single space.\r
-\r
-    """\r
-    return join(map(capitalize, s.split(sep)), sep or ' ')\r
-\r
-# Construct a translation string\r
-_idmapL = None\r
-def maketrans(fromstr, tostr):\r
-    """maketrans(frm, to) -> string\r
-\r
-    Return a translation table (a string of 256 bytes long)\r
-    suitable for use in string.translate.  The strings frm and to\r
-    must be of the same length.\r
-\r
-    """\r
-    if len(fromstr) != len(tostr):\r
-        raise ValueError, "maketrans arguments must have same length"\r
-    global _idmapL\r
-    if not _idmapL:\r
-        _idmapL = list(_idmap)\r
-    L = _idmapL[:]\r
-    fromstr = map(ord, fromstr)\r
-    for i in range(len(fromstr)):\r
-        L[fromstr[i]] = tostr[i]\r
-    return join(L, "")\r
-\r
-# Substring replacement (global)\r
-def replace(s, old, new, maxsplit=0):\r
-    """replace (str, old, new[, maxsplit]) -> string\r
-\r
-    Return a copy of string str with all occurrences of substring\r
-    old replaced by new. If the optional argument maxsplit is\r
-    given, only the first maxsplit occurrences are replaced.\r
-\r
-    """\r
-    return s.replace(old, new, maxsplit)\r
-\r
-\r
-# XXX: transitional\r
-#\r
-# If string objects do not have methods, then we need to use the old string.py\r
-# library, which uses strop for many more things than just the few outlined\r
-# below.\r
-try:\r
-    ''.upper\r
-except AttributeError:\r
-    from stringold import *\r
-\r
-# Try importing optional built-in module "strop" -- if it exists,\r
-# it redefines some string operations that are 100-1000 times faster.\r
-# It also defines values for whitespace, lowercase and uppercase\r
-# that match <ctype.h>'s definitions.\r
-\r
-try:\r
-    from strop import maketrans, lowercase, uppercase, whitespace\r
-    letters = lowercase + uppercase\r
-except ImportError:\r
-    pass                                          # Use the original versions\r