home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Calibre / calibre-0.8.18.msi / file_262 / stringold.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-09-09  |  6.1 KB  |  210 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.7)
  3.  
  4. from warnings import warnpy3k
  5. warnpy3k('the stringold module has been removed in Python 3.0', stacklevel = 2)
  6. del warnpy3k
  7. whitespace = ' \t\n\r\x0b\x0c'
  8. lowercase = 'abcdefghijklmnopqrstuvwxyz'
  9. uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  10. letters = lowercase + uppercase
  11. digits = '0123456789'
  12. hexdigits = digits + 'abcdef' + 'ABCDEF'
  13. octdigits = '01234567'
  14. _idmap = ''
  15. for i in range(256):
  16.     _idmap = _idmap + chr(i)
  17.  
  18. del i
  19. index_error = ValueError
  20. atoi_error = ValueError
  21. atof_error = ValueError
  22. atol_error = ValueError
  23.  
  24. def lower(s):
  25.     return s.lower()
  26.  
  27.  
  28. def upper(s):
  29.     return s.upper()
  30.  
  31.  
  32. def swapcase(s):
  33.     return s.swapcase()
  34.  
  35.  
  36. def strip(s):
  37.     return s.strip()
  38.  
  39.  
  40. def lstrip(s):
  41.     return s.lstrip()
  42.  
  43.  
  44. def rstrip(s):
  45.     return s.rstrip()
  46.  
  47.  
  48. def split(s, sep = None, maxsplit = 0):
  49.     return s.split(sep, maxsplit)
  50.  
  51. splitfields = split
  52.  
  53. def join(words, sep = ' '):
  54.     return sep.join(words)
  55.  
  56. joinfields = join
  57. _apply = apply
  58.  
  59. def index(s, *args):
  60.     return _apply(s.index, args)
  61.  
  62.  
  63. def rindex(s, *args):
  64.     return _apply(s.rindex, args)
  65.  
  66.  
  67. def count(s, *args):
  68.     return _apply(s.count, args)
  69.  
  70.  
  71. def find(s, *args):
  72.     return _apply(s.find, args)
  73.  
  74.  
  75. def rfind(s, *args):
  76.     return _apply(s.rfind, args)
  77.  
  78. _float = float
  79. _int = int
  80. _long = long
  81. _StringType = type('')
  82.  
  83. def atof(s):
  84.     if type(s) == _StringType:
  85.         return _float(s)
  86.     raise None('argument 1: expected string, %s found' % type(s).__name__)
  87.  
  88.  
  89. def atoi(*args):
  90.     
  91.     try:
  92.         s = args[0]
  93.     except IndexError:
  94.         raise TypeError('function requires at least 1 argument: %d given' % len(args))
  95.  
  96.     if type(s) == _StringType:
  97.         return _apply(_int, args)
  98.     raise None('argument 1: expected string, %s found' % type(s).__name__)
  99.  
  100.  
  101. def atol(*args):
  102.     
  103.     try:
  104.         s = args[0]
  105.     except IndexError:
  106.         raise TypeError('function requires at least 1 argument: %d given' % len(args))
  107.  
  108.     if type(s) == _StringType:
  109.         return _apply(_long, args)
  110.     raise None('argument 1: expected string, %s found' % type(s).__name__)
  111.  
  112.  
  113. def ljust(s, width):
  114.     n = width - len(s)
  115.     if n <= 0:
  116.         return s
  117.     return None + ' ' * n
  118.  
  119.  
  120. def rjust(s, width):
  121.     n = width - len(s)
  122.     if n <= 0:
  123.         return s
  124.     return None * n + s
  125.  
  126.  
  127. def center(s, width):
  128.     n = width - len(s)
  129.     if n <= 0:
  130.         return s
  131.     half = None / 2
  132.     if n % 2 and width % 2:
  133.         half = half + 1
  134.     return ' ' * half + s + ' ' * (n - half)
  135.  
  136.  
  137. def zfill(x, width):
  138.     if type(x) == type(''):
  139.         s = x
  140.     else:
  141.         s = repr(x)
  142.     n = len(s)
  143.     if n >= width:
  144.         return s
  145.     sign = None
  146.     if s[0] in ('-', '+'):
  147.         sign = s[0]
  148.         s = s[1:]
  149.     return sign + '0' * (width - n) + s
  150.  
  151.  
  152. def expandtabs(s, tabsize = 8):
  153.     res = line = ''
  154.     for c in s:
  155.         if c == '\t':
  156.             c = ' ' * (tabsize - len(line) % tabsize)
  157.         line = line + c
  158.         if c == '\n':
  159.             res = res + line
  160.             line = ''
  161.             continue
  162.     return res + line
  163.  
  164.  
  165. def translate(s, table, deletions = ''):
  166.     return s.translate(table, deletions)
  167.  
  168.  
  169. def capitalize(s):
  170.     return s.capitalize()
  171.  
  172.  
  173. def capwords(s, sep = None):
  174.     if not sep:
  175.         pass
  176.     return join(map(capitalize, s.split(sep)), ' ')
  177.  
  178. _idmapL = None
  179.  
  180. def maketrans(fromstr, tostr):
  181.     global _idmapL
  182.     if len(fromstr) != len(tostr):
  183.         raise ValueError, 'maketrans arguments must have same length'
  184.     if not _idmapL:
  185.         _idmapL = list(_idmap)
  186.     L = _idmapL[:]
  187.     fromstr = map(ord, fromstr)
  188.     for i in range(len(fromstr)):
  189.         L[fromstr[i]] = tostr[i]
  190.     
  191.     return join(L, '')
  192.  
  193.  
  194. def replace(s, old, new, maxsplit = 0):
  195.     return s.replace(old, new, maxsplit)
  196.  
  197.  
  198. try:
  199.     ''.upper
  200. except AttributeError:
  201.     from stringold import *
  202.  
  203.  
  204. try:
  205.     from strop import maketrans, lowercase, uppercase, whitespace
  206.     letters = lowercase + uppercase
  207. except ImportError:
  208.     pass
  209.  
  210.