home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2807 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  6.2 KB  |  216 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  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 TypeError('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 TypeError('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 TypeError('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 s + ' ' * n
  118.  
  119.  
  120. def rjust(s, width):
  121.     n = width - len(s)
  122.     if n <= 0:
  123.         return s
  124.     return ' ' * n + s
  125.  
  126.  
  127. def center(s, width):
  128.     n = width - len(s)
  129.     if n <= 0:
  130.         return s
  131.     half = n / 2
  132.     if n % 2 and width % 2:
  133.         half = half + 1
  134.     
  135.     return ' ' * half + s + ' ' * (n - half)
  136.  
  137.  
  138. def zfill(x, width):
  139.     if type(x) == type(''):
  140.         s = x
  141.     else:
  142.         s = repr(x)
  143.     n = len(s)
  144.     if n >= width:
  145.         return s
  146.     sign = ''
  147.     if s[0] in ('-', '+'):
  148.         sign = s[0]
  149.         s = s[1:]
  150.     
  151.     return sign + '0' * (width - n) + s
  152.  
  153.  
  154. def expandtabs(s, tabsize = 8):
  155.     res = line = ''
  156.     for c in s:
  157.         if c == '\t':
  158.             c = ' ' * (tabsize - len(line) % tabsize)
  159.         
  160.         line = line + c
  161.         if c == '\n':
  162.             res = res + line
  163.             line = ''
  164.             continue
  165.     
  166.     return res + line
  167.  
  168.  
  169. def translate(s, table, deletions = ''):
  170.     return s.translate(table, deletions)
  171.  
  172.  
  173. def capitalize(s):
  174.     return s.capitalize()
  175.  
  176.  
  177. def capwords(s, sep = None):
  178.     if not sep:
  179.         pass
  180.     return join(map(capitalize, s.split(sep)), ' ')
  181.  
  182. _idmapL = None
  183.  
  184. def maketrans(fromstr, tostr):
  185.     global _idmapL
  186.     if len(fromstr) != len(tostr):
  187.         raise ValueError, 'maketrans arguments must have same length'
  188.     len(fromstr) != len(tostr)
  189.     if not _idmapL:
  190.         _idmapL = list(_idmap)
  191.     
  192.     L = _idmapL[:]
  193.     fromstr = map(ord, fromstr)
  194.     for i in range(len(fromstr)):
  195.         L[fromstr[i]] = tostr[i]
  196.     
  197.     return join(L, '')
  198.  
  199.  
  200. def replace(s, old, new, maxsplit = 0):
  201.     return s.replace(old, new, maxsplit)
  202.  
  203.  
  204. try:
  205.     ''.upper
  206. except AttributeError:
  207.     from stringold import *
  208.  
  209.  
  210. try:
  211.     from strop import maketrans, lowercase, uppercase, whitespace
  212.     letters = lowercase + uppercase
  213. except ImportError:
  214.     pass
  215.  
  216.