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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import sys
  5. import collections
  6. __all__ = [
  7.     'UserString',
  8.     'MutableString']
  9.  
  10. class UserString(collections.Sequence):
  11.     
  12.     def __init__(self, seq):
  13.         if isinstance(seq, basestring):
  14.             self.data = seq
  15.         elif isinstance(seq, UserString):
  16.             self.data = seq.data[:]
  17.         else:
  18.             self.data = str(seq)
  19.  
  20.     
  21.     def __str__(self):
  22.         return str(self.data)
  23.  
  24.     
  25.     def __repr__(self):
  26.         return repr(self.data)
  27.  
  28.     
  29.     def __int__(self):
  30.         return int(self.data)
  31.  
  32.     
  33.     def __long__(self):
  34.         return long(self.data)
  35.  
  36.     
  37.     def __float__(self):
  38.         return float(self.data)
  39.  
  40.     
  41.     def __complex__(self):
  42.         return complex(self.data)
  43.  
  44.     
  45.     def __hash__(self):
  46.         return hash(self.data)
  47.  
  48.     
  49.     def __cmp__(self, string):
  50.         if isinstance(string, UserString):
  51.             return cmp(self.data, string.data)
  52.         return cmp(self.data, string)
  53.  
  54.     
  55.     def __contains__(self, char):
  56.         return char in self.data
  57.  
  58.     
  59.     def __len__(self):
  60.         return len(self.data)
  61.  
  62.     
  63.     def __getitem__(self, index):
  64.         return self.__class__(self.data[index])
  65.  
  66.     
  67.     def __getslice__(self, start, end):
  68.         start = max(start, 0)
  69.         end = max(end, 0)
  70.         return self.__class__(self.data[start:end])
  71.  
  72.     
  73.     def __add__(self, other):
  74.         if isinstance(other, UserString):
  75.             return self.__class__(self.data + other.data)
  76.         if isinstance(other, basestring):
  77.             return self.__class__(self.data + other)
  78.         return self.__class__(self.data + str(other))
  79.  
  80.     
  81.     def __radd__(self, other):
  82.         if isinstance(other, basestring):
  83.             return self.__class__(other + self.data)
  84.         return self.__class__(str(other) + self.data)
  85.  
  86.     
  87.     def __mul__(self, n):
  88.         return self.__class__(self.data * n)
  89.  
  90.     __rmul__ = __mul__
  91.     
  92.     def __mod__(self, args):
  93.         return self.__class__(self.data % args)
  94.  
  95.     
  96.     def capitalize(self):
  97.         return self.__class__(self.data.capitalize())
  98.  
  99.     
  100.     def center(self, width, *args):
  101.         return self.__class__(self.data.center(width, *args))
  102.  
  103.     
  104.     def count(self, sub, start = 0, end = sys.maxint):
  105.         return self.data.count(sub, start, end)
  106.  
  107.     
  108.     def decode(self, encoding = None, errors = None):
  109.         if encoding:
  110.             if errors:
  111.                 return self.__class__(self.data.decode(encoding, errors))
  112.             return self.__class__(self.data.decode(encoding))
  113.         encoding
  114.         return self.__class__(self.data.decode())
  115.  
  116.     
  117.     def encode(self, encoding = None, errors = None):
  118.         if encoding:
  119.             if errors:
  120.                 return self.__class__(self.data.encode(encoding, errors))
  121.             return self.__class__(self.data.encode(encoding))
  122.         encoding
  123.         return self.__class__(self.data.encode())
  124.  
  125.     
  126.     def endswith(self, suffix, start = 0, end = sys.maxint):
  127.         return self.data.endswith(suffix, start, end)
  128.  
  129.     
  130.     def expandtabs(self, tabsize = 8):
  131.         return self.__class__(self.data.expandtabs(tabsize))
  132.  
  133.     
  134.     def find(self, sub, start = 0, end = sys.maxint):
  135.         return self.data.find(sub, start, end)
  136.  
  137.     
  138.     def index(self, sub, start = 0, end = sys.maxint):
  139.         return self.data.index(sub, start, end)
  140.  
  141.     
  142.     def isalpha(self):
  143.         return self.data.isalpha()
  144.  
  145.     
  146.     def isalnum(self):
  147.         return self.data.isalnum()
  148.  
  149.     
  150.     def isdecimal(self):
  151.         return self.data.isdecimal()
  152.  
  153.     
  154.     def isdigit(self):
  155.         return self.data.isdigit()
  156.  
  157.     
  158.     def islower(self):
  159.         return self.data.islower()
  160.  
  161.     
  162.     def isnumeric(self):
  163.         return self.data.isnumeric()
  164.  
  165.     
  166.     def isspace(self):
  167.         return self.data.isspace()
  168.  
  169.     
  170.     def istitle(self):
  171.         return self.data.istitle()
  172.  
  173.     
  174.     def isupper(self):
  175.         return self.data.isupper()
  176.  
  177.     
  178.     def join(self, seq):
  179.         return self.data.join(seq)
  180.  
  181.     
  182.     def ljust(self, width, *args):
  183.         return self.__class__(self.data.ljust(width, *args))
  184.  
  185.     
  186.     def lower(self):
  187.         return self.__class__(self.data.lower())
  188.  
  189.     
  190.     def lstrip(self, chars = None):
  191.         return self.__class__(self.data.lstrip(chars))
  192.  
  193.     
  194.     def partition(self, sep):
  195.         return self.data.partition(sep)
  196.  
  197.     
  198.     def replace(self, old, new, maxsplit = -1):
  199.         return self.__class__(self.data.replace(old, new, maxsplit))
  200.  
  201.     
  202.     def rfind(self, sub, start = 0, end = sys.maxint):
  203.         return self.data.rfind(sub, start, end)
  204.  
  205.     
  206.     def rindex(self, sub, start = 0, end = sys.maxint):
  207.         return self.data.rindex(sub, start, end)
  208.  
  209.     
  210.     def rjust(self, width, *args):
  211.         return self.__class__(self.data.rjust(width, *args))
  212.  
  213.     
  214.     def rpartition(self, sep):
  215.         return self.data.rpartition(sep)
  216.  
  217.     
  218.     def rstrip(self, chars = None):
  219.         return self.__class__(self.data.rstrip(chars))
  220.  
  221.     
  222.     def split(self, sep = None, maxsplit = -1):
  223.         return self.data.split(sep, maxsplit)
  224.  
  225.     
  226.     def rsplit(self, sep = None, maxsplit = -1):
  227.         return self.data.rsplit(sep, maxsplit)
  228.  
  229.     
  230.     def splitlines(self, keepends = 0):
  231.         return self.data.splitlines(keepends)
  232.  
  233.     
  234.     def startswith(self, prefix, start = 0, end = sys.maxint):
  235.         return self.data.startswith(prefix, start, end)
  236.  
  237.     
  238.     def strip(self, chars = None):
  239.         return self.__class__(self.data.strip(chars))
  240.  
  241.     
  242.     def swapcase(self):
  243.         return self.__class__(self.data.swapcase())
  244.  
  245.     
  246.     def title(self):
  247.         return self.__class__(self.data.title())
  248.  
  249.     
  250.     def translate(self, *args):
  251.         return self.__class__(self.data.translate(*args))
  252.  
  253.     
  254.     def upper(self):
  255.         return self.__class__(self.data.upper())
  256.  
  257.     
  258.     def zfill(self, width):
  259.         return self.__class__(self.data.zfill(width))
  260.  
  261.  
  262.  
  263. class MutableString(UserString, collections.MutableSequence):
  264.     
  265.     def __init__(self, string = ''):
  266.         warnpy3k = warnpy3k
  267.         import warnings
  268.         warnpy3k('the class UserString.MutableString has been removed in Python 3.0', stacklevel = 2)
  269.         self.data = string
  270.  
  271.     __hash__ = None
  272.     
  273.     def __setitem__(self, index, sub):
  274.         if isinstance(index, slice):
  275.             if isinstance(sub, UserString):
  276.                 sub = sub.data
  277.             elif not isinstance(sub, basestring):
  278.                 sub = str(sub)
  279.             
  280.             (start, stop, step) = index.indices(len(self.data))
  281.             if step == -1:
  282.                 start = stop + 1
  283.                 stop = start + 1
  284.                 sub = sub[::-1]
  285.             elif step != 1:
  286.                 raise TypeError, 'invalid step in slicing assignment'
  287.             
  288.             start = min(start, stop)
  289.             self.data = self.data[:start] + sub + self.data[stop:]
  290.         elif index < 0:
  291.             index += len(self.data)
  292.         
  293.         if index < 0 or index >= len(self.data):
  294.             raise IndexError
  295.         index >= len(self.data)
  296.         self.data = self.data[:index] + sub + self.data[index + 1:]
  297.  
  298.     
  299.     def __delitem__(self, index):
  300.         if isinstance(index, slice):
  301.             (start, stop, step) = index.indices(len(self.data))
  302.             if step == -1:
  303.                 start = stop + 1
  304.                 stop = start + 1
  305.             elif step != 1:
  306.                 raise TypeError, 'invalid step in slicing deletion'
  307.             
  308.             start = min(start, stop)
  309.             self.data = self.data[:start] + self.data[stop:]
  310.         elif index < 0:
  311.             index += len(self.data)
  312.         
  313.         if index < 0 or index >= len(self.data):
  314.             raise IndexError
  315.         index >= len(self.data)
  316.         self.data = self.data[:index] + self.data[index + 1:]
  317.  
  318.     
  319.     def __setslice__(self, start, end, sub):
  320.         start = max(start, 0)
  321.         end = max(end, 0)
  322.         if isinstance(sub, UserString):
  323.             self.data = self.data[:start] + sub.data + self.data[end:]
  324.         elif isinstance(sub, basestring):
  325.             self.data = self.data[:start] + sub + self.data[end:]
  326.         else:
  327.             self.data = self.data[:start] + str(sub) + self.data[end:]
  328.  
  329.     
  330.     def __delslice__(self, start, end):
  331.         start = max(start, 0)
  332.         end = max(end, 0)
  333.         self.data = self.data[:start] + self.data[end:]
  334.  
  335.     
  336.     def immutable(self):
  337.         return UserString(self.data)
  338.  
  339.     
  340.     def __iadd__(self, other):
  341.         if isinstance(other, UserString):
  342.             self.data += other.data
  343.         elif isinstance(other, basestring):
  344.             self.data += other
  345.         else:
  346.             self.data += str(other)
  347.         return self
  348.  
  349.     
  350.     def __imul__(self, n):
  351.         self.data *= n
  352.         return self
  353.  
  354.     
  355.     def insert(self, index, value):
  356.         self[index:index] = value
  357.  
  358.  
  359. if __name__ == '__main__':
  360.     import os
  361.     (called_in_dir, called_as) = os.path.split(sys.argv[0])
  362.     (called_as, py) = os.path.splitext(called_as)
  363.     if '-q' in sys.argv:
  364.         from test import test_support
  365.         test_support.verbose = 0
  366.     
  367.     __import__('test.test_' + called_as.lower())
  368.  
  369.