<EOL>self._make_prefix()<EOL>fromlines,tolines = self._tab_newline_replace(fromlines,tolines)<EOL>if context:<EOL><INDENT>context_lines = numlines<EOL><DEDENT>else:<EOL><INDENT>context_lines = None<EOL><DEDENT>diffs = _mdiff(fromlines,tolines,context_lines,linejunk=self._linejunk,<EOL>charjunk=self._charjunk)<EOL>if self._wrapcolumn:<EOL><INDENT>diffs = self._line_wrapper(diffs)<EOL><DEDENT>fromlist,tolist,flaglist = self._collect_lines(diffs)<EOL>fromlist,tolist,flaglist,next_href,next_id = self._convert_flags(<EOL>fromlist,tolist,flaglist,context,numlines)<EOL>s = []<EOL>fmt = '<STR_LIT>' +'<STR_LIT>'<EOL>for i in range(len(flaglist)):<EOL><INDENT>if flaglist[i] is None:<EOL><INDENT>if i > <NUM_LIT:0>:<EOL><INDENT>s.append('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>s.append( fmt % (next_id[i],next_href[i],fromlist[i],<EOL>next_href[i],tolist[i]))<EOL><DEDENT><DEDENT>if fromdesc or todesc:<EOL><INDENT>header_row = '<STR_LIT>' % (<EOL>'<STR_LIT>',<EOL>'<STR_LIT>' % fromdesc,<EOL>'<STR_LIT>',<EOL>'<STR_LIT>' % todesc)<EOL><DEDENT>else:<EOL><INDENT>header_row = '<STR_LIT>'<EOL><DEDENT>table = self._table_template % dict(<EOL>data_rows='<STR_LIT>'.join(s),<EOL>header_row=header_row,<EOL>prefix=self._prefix[<NUM_LIT:1>])<EOL>return table.replace('<STR_LIT>','<STR_LIT>').replace('<STR_LIT>','<STR_LIT>').replace('<STR_LIT>','<STR_LIT>').replace('<STR_LIT>','<STR_LIT>').replace('<STR_LIT:\t>','<STR_LIT>')<EOL>

Returns HTML table of side by side comparison with change highlights

        Arguments:
        fromlines -- list of "from" lines
        tolines -- list of "to" lines
        fromdesc -- "from" file column header string
        todesc -- "to" file column header string
        context -- set to True for contextual differences (defaults to False
            which shows full differences).
        numlines -- number of context lines.  When context is set True,
            controls number of lines displayed before and after the change.
            When context is False, controls the number of lines to place
            the "next" link anchors before the next change (so click of
            "next" link jumps to just before the change).


global cache<EOL>cache = {}<EOL>


if filename in cache:<EOL><INDENT>return cache[filename][<NUM_LIT:2>]<EOL><DEDENT>try:<EOL><INDENT>return updatecache(filename, module_globals)<EOL><DEDENT>except MemoryError:<EOL><INDENT>clearcache()<EOL>return []<EOL><DEDENT>

Get the lines for a file from the cache.
    Update the cache if it doesn't contain an entry for this file already.


if filename is None:<EOL><INDENT>filenames = cache.keys()<EOL><DEDENT>else:<EOL><INDENT>if filename in cache:<EOL><INDENT>filenames = [filename]<EOL><DEDENT>else:<EOL><INDENT>return<EOL><DEDENT><DEDENT>for filename in filenames:<EOL><INDENT>size, mtime, lines, fullname = cache[filename]<EOL>if mtime is None:<EOL><INDENT>continue   <EOL><DEDENT>try:<EOL><INDENT>stat = os.stat(fullname)<EOL><DEDENT>except os.error:<EOL><INDENT>del cache[filename]<EOL>continue<EOL><DEDENT>if size != stat.st_size or mtime != stat.st_mtime:<EOL><INDENT>del cache[filename]<EOL><DEDENT><DEDENT>

Discard cache entries that are out of date.
    (This is not checked upon each call!)


if filename in cache:<EOL><INDENT>del cache[filename]<EOL><DEDENT>if not filename or (filename.startswith('<STR_LIT:<>') and filename.endswith('<STR_LIT:>>')):<EOL><INDENT>return []<EOL><DEDENT>fullname = filename<EOL>try:<EOL><INDENT>stat = os.stat(fullname)<EOL><DEDENT>except OSError:<EOL><INDENT>basename = filename<EOL>if module_globals and '<STR_LIT>' in module_globals:<EOL><INDENT>name = module_globals.get('<STR_LIT>')<EOL>loader = module_globals['<STR_LIT>']<EOL>get_source = getattr(loader, '<STR_LIT>', None)<EOL>if name and get_source:<EOL><INDENT>try:<EOL><INDENT>data = get_source(name)<EOL><DEDENT>except (ImportError, IOError):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if data is None:<EOL><INDENT>return []<EOL><DEDENT>cache[filename] = (<EOL>len(data), None,<EOL>[line+'<STR_LIT:\n>' for line in data.splitlines()], fullname<EOL>)<EOL>return cache[filename][<NUM_LIT:2>]<EOL><DEDENT><DEDENT><DEDENT>if os.path.isabs(filename):<EOL><INDENT>return []<EOL><DEDENT>for dirname in sys.path:<EOL><INDENT>try:<EOL><INDENT>fullname = os.path.join(dirname, basename)<EOL><DEDENT>except (TypeError, AttributeError):<EOL><INDENT>continue<EOL><DEDENT>try:<EOL><INDENT>stat = os.stat(fullname)<EOL>break<EOL><DEDENT>except os.error:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return []<EOL><DEDENT><DEDENT>try:<EOL><INDENT>with open(fullname, '<STR_LIT>') as fp:<EOL><INDENT>lines = fp.readlines()<EOL><DEDENT><DEDENT>except IOError:<EOL><INDENT>return []<EOL><DEDENT>if lines and not lines[-<NUM_LIT:1>].endswith('<STR_LIT:\n>'):<EOL><INDENT>lines[-<NUM_LIT:1>] += '<STR_LIT:\n>'<EOL><DEDENT>size, mtime = stat.st_size, stat.st_mtime<EOL>cache[filename] = size, mtime, lines, fullname<EOL>return lines<EOL>

Update a cache entry and return its list of lines.
    If something's wrong, print a message, discard the cache entry,
    and return an empty list.


m = self.create_message(msg)<EOL>i = <NUM_LIT:0><EOL>for n, a in m.getaddrlist('<STR_LIT:to>') + m.getaddrlist('<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>mn, ma = results[i][<NUM_LIT:0>], results[i][<NUM_LIT:1>]<EOL><DEDENT>except IndexError:<EOL><INDENT>print('<STR_LIT>', repr(n), repr(a))<EOL>continue<EOL><DEDENT>i = i + <NUM_LIT:1><EOL>self.assertEqual(mn, n,<EOL>"<STR_LIT>" % (mn, n))<EOL>self.assertEqual(ma, a,<EOL>"<STR_LIT>" % (ma, a))<EOL>if mn == n and ma == a:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>', repr(n), repr(a))<EOL><DEDENT><DEDENT>out = m.getdate('<STR_LIT:date>')<EOL>if out:<EOL><INDENT>self.assertEqual(out,<EOL>(<NUM_LIT>, <NUM_LIT:1>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>),<EOL>"<STR_LIT>")<EOL><DEDENT>


<EOL>with warnings.catch_warnings(record=True) as w:<EOL><INDENT>sys.modules['<STR_LIT>'].simplefilter("<STR_LIT>")<EOL>yield WarningsRecorder(w)<EOL><DEDENT>reraise = [warning.message for warning in w]<EOL>missing = []<EOL>for msg, cat in filters:<EOL><INDENT>seen = False<EOL>for exc in reraise[:]:<EOL><INDENT>message = str(exc)<EOL>if (re.match(msg, message, re.I) and<EOL>issubclass(exc.__class__, cat)):<EOL><INDENT>seen = True<EOL>reraise.remove(exc)<EOL><DEDENT><DEDENT>if not seen and not quiet:<EOL><INDENT>missing.append((msg, cat.__name__))<EOL><DEDENT><DEDENT>if reraise:<EOL><INDENT>raise AssertionError("<STR_LIT>" % reraise[<NUM_LIT:0>])<EOL><DEDENT>if missing:<EOL><INDENT>raise AssertionError("<STR_LIT>" %<EOL>missing[<NUM_LIT:0>])<EOL><DEDENT>

Catch the warnings, then check if all the expected
    warnings have been raised and re-raise unexpected warnings.
    If 'quiet' is True, only re-raise the unexpected warnings.


quiet = kwargs.get('<STR_LIT>')<EOL>if not filters:<EOL><INDENT>filters = (("<STR_LIT>", Warning),)<EOL>if quiet is None:<EOL><INDENT>quiet = True<EOL><DEDENT><DEDENT>return _filterwarnings(filters, quiet)<EOL>

Context manager to silence warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default True without argument,
         default False if some filters are defined)

    Without argument, it defaults to:
        check_warnings(("", Warning), quiet=True)


if sys.py3kwarning:<EOL><INDENT>if not filters:<EOL><INDENT>filters = (("<STR_LIT>", DeprecationWarning),)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>filters = ()<EOL><DEDENT>return _filterwarnings(filters, kwargs.get('<STR_LIT>'))<EOL>

Context manager to silence py3k warnings.

    Accept 2-tuples as positional arguments:
        ("message regexp", WarningCategory)

    Optional argument:
     - if 'quiet' is True, it does not fail if a filter catches nothing
        (default False)

    Without argument, it defaults to:
        check_py3k_warnings(("", DeprecationWarning), quiet=False)


if verbose:<EOL><INDENT>runner = unittest.TextTestRunner(sys.stdout, verbosity=<NUM_LIT:2>)<EOL><DEDENT>else:<EOL><INDENT>runner = BasicTestRunner()<EOL><DEDENT>result = runner.run(suite)<EOL>if not result.wasSuccessful():<EOL><INDENT>if len(result.errors) == <NUM_LIT:1> and not result.failures:<EOL><INDENT>err = result.errors[<NUM_LIT:0>][<NUM_LIT:1>]<EOL><DEDENT>elif len(result.failures) == <NUM_LIT:1> and not result.errors:<EOL><INDENT>err = result.failures[<NUM_LIT:0>][<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>err = "<STR_LIT>"<EOL>if not verbose:<EOL><INDENT>err += "<STR_LIT>"<EOL><DEDENT><DEDENT>raise TestFailed(err)<EOL><DEDENT>

Run tests from a unittest.TestSuite-derived class.


<EOL>if hasattr(os, '<STR_LIT>'):<EOL><INDENT>any_process = -<NUM_LIT:1><EOL>while True:<EOL><INDENT>try:<EOL><INDENT>pid, status = os.waitpid(any_process, os.WNOHANG)<EOL>if pid == <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT><DEDENT>except:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>

Use this function at the end of test_main() whenever sub-processes
    are started.  This will help ensure that no extra children (zombies)
    stick around to hog resources and create problems when looking
    for refleaks.


def __init__(self, f, n, wait_before_exit=False):

self.f = f<EOL>self.n = n<EOL>self.started = []<EOL>self.finished = []<EOL>self._can_exit = not wait_before_exit<EOL>def task():<EOL><INDENT>tid = get_ident()<EOL>self.started.append(tid)<EOL>try:<EOL><INDENT>f()<EOL><DEDENT>finally:<EOL><INDENT>self.finished.append(tid)<EOL>while not self._can_exit:<EOL><INDENT>_wait()<EOL><DEDENT><DEDENT><DEDENT>try:<EOL><INDENT>for i in range(n):<EOL><INDENT>start_new_thread(task, ())<EOL><DEDENT><DEDENT>except:<EOL><INDENT>self._can_exit = True<EOL>raise<EOL><DEDENT>

Construct a bunch of `n` threads running the same function `f`.
If `wait_before_exit` is True, the threads won't terminate until
do_finish() is called.


for i in seqn:<EOL><INDENT>yield i<EOL><DEDENT>


return {<NUM_LIT:1>:<NUM_LIT:2>, "<STR_LIT>":"<STR_LIT>", "<STR_LIT>":(<NUM_LIT:1>,<NUM_LIT:2>,<NUM_LIT:3>)}<EOL>

Return a dictionary of values which are invariant by storage
        in the object under test.


return self.type2test()<EOL>


x = self._empty_mapping()<EOL>for key, value in list(data.items()):<EOL><INDENT>x[key] = value<EOL><DEDENT>return x<EOL>

Return a mapping object with the value contained in data
        dictionary


def encode(in_file, out_file, name=None, mode=None):

<EOL>opened_files = []<EOL>try:<EOL><INDENT>if in_file == '<STR_LIT:->':<EOL><INDENT>in_file = sys.stdin<EOL><DEDENT>elif isinstance(in_file, str):<EOL><INDENT>if name is None:<EOL><INDENT>name = os.path.basename(in_file)<EOL><DEDENT>if mode is None:<EOL><INDENT>try:<EOL><INDENT>mode = os.stat(in_file).st_mode<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>in_file = open(in_file, '<STR_LIT:rb>')<EOL>opened_files.append(in_file)<EOL><DEDENT>if out_file == '<STR_LIT:->':<EOL><INDENT>out_file = sys.stdout<EOL><DEDENT>elif isinstance(out_file, str):<EOL><INDENT>out_file = open(out_file, '<STR_LIT:wb>')<EOL>opened_files.append(out_file)<EOL><DEDENT>if name is None:<EOL><INDENT>name = '<STR_LIT:->'<EOL><DEDENT>if mode is None:<EOL><INDENT>mode = <NUM_LIT><EOL><DEDENT>out_file.write('<STR_LIT>' % ((mode&<NUM_LIT>),name))<EOL>data = in_file.read(<NUM_LIT>)<EOL>while len(data) > <NUM_LIT:0>:<EOL><INDENT>out_file.write(binascii.b2a_uu(data))<EOL>data = in_file.read(<NUM_LIT>)<EOL><DEDENT>out_file.write('<STR_LIT>')<EOL><DEDENT>finally:<EOL><INDENT>for f in opened_files:<EOL><INDENT>f.close()<EOL><DEDENT><DEDENT>


def decode(in_file, out_file=None, mode=None, quiet=<NUM_LIT:0>):

<EOL>opened_files = []<EOL>if in_file == '<STR_LIT:->':<EOL><INDENT>in_file = sys.stdin<EOL><DEDENT>elif isinstance(in_file, str):<EOL><INDENT>in_file = open(in_file)<EOL>opened_files.append(in_file)<EOL><DEDENT>try:<EOL><INDENT>while True:<EOL><INDENT>hdr = in_file.readline()<EOL>if not hdr:<EOL><INDENT>raise Error('<STR_LIT>')<EOL><DEDENT>if not hdr.startswith('<STR_LIT>'):<EOL><INDENT>continue<EOL><DEDENT>hdrfields = hdr.split('<STR_LIT:U+0020>', <NUM_LIT:2>)<EOL>if len(hdrfields) == <NUM_LIT:3> and hdrfields[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>int(hdrfields[<NUM_LIT:1>], <NUM_LIT:8>)<EOL>break<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>if out_file is None:<EOL><INDENT>out_file = hdrfields[<NUM_LIT:2>].rstrip()<EOL>if os.path.exists(out_file):<EOL><INDENT>raise Error('<STR_LIT>' % out_file)<EOL><DEDENT><DEDENT>if mode is None:<EOL><INDENT>mode = int(hdrfields[<NUM_LIT:1>], <NUM_LIT:8>)<EOL><DEDENT>if out_file == '<STR_LIT:->':<EOL><INDENT>out_file = sys.stdout<EOL><DEDENT>elif isinstance(out_file, str):<EOL><INDENT>fp = open(out_file, '<STR_LIT:wb>')<EOL>try:<EOL><INDENT>os.path.chmod(out_file, mode)<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>out_file = fp<EOL>opened_files.append(out_file)<EOL><DEDENT>s = in_file.readline()<EOL>while s and s.strip() != '<STR_LIT:end>':<EOL><INDENT>try:<EOL><INDENT>data = binascii.a2b_uu(s)<EOL><DEDENT>except binascii.Error as v:<EOL><INDENT>nbytes = (((ord(s[<NUM_LIT:0>])-<NUM_LIT:32>) & <NUM_LIT>) * <NUM_LIT:4> + <NUM_LIT:5>) // <NUM_LIT:3><EOL>data = binascii.a2b_uu(s[:nbytes])<EOL>if not quiet:<EOL><INDENT>sys.stderr.write("<STR_LIT>" % v)<EOL><DEDENT><DEDENT>out_file.write(data)<EOL>s = in_file.readline()<EOL><DEDENT>if not s:<EOL><INDENT>raise Error('<STR_LIT>')<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>for f in opened_files:<EOL><INDENT>f.close()<EOL><DEDENT><DEDENT>


def loadTestsFromName(self, name, module=None):

parts = name.split('<STR_LIT:.>')<EOL>if module is None:<EOL><INDENT>parts_copy = parts[:]<EOL>while parts_copy:<EOL><INDENT>try:<EOL><INDENT>module = __import__('<STR_LIT:.>'.join(parts_copy))<EOL>break<EOL><DEDENT>except ImportError:<EOL><INDENT>del parts_copy[-<NUM_LIT:1>]<EOL>if not parts_copy:<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT>parts = parts[<NUM_LIT:1>:]<EOL><DEDENT>obj = module<EOL>for part in parts:<EOL><INDENT>parent, obj = obj, getattr(obj, part)<EOL><DEDENT>if isinstance(obj, types.ModuleType):<EOL><INDENT>return self.loadTestsFromModule(obj)<EOL><DEDENT>elif isinstance(obj, type) and issubclass(obj, case.TestCase):<EOL><INDENT>return self.loadTestsFromTestCase(obj)<EOL><DEDENT>elif (isinstance(obj, types.UnboundMethodType) and<EOL>isinstance(parent, type) and<EOL>issubclass(parent, case.TestCase)):<EOL><INDENT>name = parts[-<NUM_LIT:1>]<EOL>inst = parent(name)<EOL>return self.suiteClass([inst])<EOL><DEDENT>elif isinstance(obj, suite.TestSuite):<EOL><INDENT>return obj<EOL><DEDENT>elif hasattr(obj, '<STR_LIT>'):<EOL><INDENT>test = obj()<EOL>if isinstance(test, suite.TestSuite):<EOL><INDENT>return test<EOL><DEDENT>elif isinstance(test, case.TestCase):<EOL><INDENT>return self.suiteClass([test])<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>" %<EOL>(obj, test))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>" % obj)<EOL><DEDENT>

Return a suite of all tests cases given a string specifier.

        The name may resolve either to a module, a test case class, a
        test method within a test case class, or a callable object which
        returns a TestCase or TestSuite instance.

        The method optionally resolves the names relative to a given module.


def loadTestsFromNames(self, names, module=None):

suites = [self.loadTestsFromName(name, module) for name in names]<EOL>return self.suiteClass(suites)<EOL>

Return a suite of all tests cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.


funcobj.__isabstractmethod__ = True<EOL>return funcobj<EOL>

A decorator indicating abstract methods.

    Requires that the metaclass is ABCMeta or derived from it.  A
    class that has a metaclass derived from ABCMeta cannot be
    instantiated unless all of its abstract methods are overridden.
    The abstract methods can be called using any of the normal
    'super' call mechanisms.

    Usage:

        class C:
            __metaclass__ = ABCMeta
            @abstractmethod
            def my_abstract_method(self, ...):
                ...


if not isinstance(subclass, type):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if issubclass(subclass, cls):<EOL><INDENT>return  <EOL><DEDENT>if issubclass(cls, subclass):<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>cls._abc_registry.add(subclass)<EOL>ABCMeta._abc_invalidation_counter += <NUM_LIT:1><EOL>


print >> file, "<STR_LIT>" % (cls.__module__, cls.__name__)<EOL>print >> file, "<STR_LIT>" % ABCMeta._abc_invalidation_counter<EOL>for name in sorted(cls.__dict__.keys()):<EOL><INDENT>if name.startswith("<STR_LIT>"):<EOL><INDENT>value = getattr(cls, name)<EOL>print >> file, "<STR_LIT>" % (name, value)<EOL><DEDENT><DEDENT>


<EOL>subclass = getattr(instance, '<STR_LIT>', None)<EOL>if subclass is not None and subclass in cls._abc_cache:<EOL><INDENT>return True<EOL><DEDENT>subtype = type(instance)<EOL><INDENT>if subtype is _InstanceType:<EOL><INDENT>subtype = subclass<EOL><DEDENT><DEDENT>if subtype is subclass or subclass is None:<EOL><INDENT>if (cls._abc_negative_cache_version ==<EOL>ABCMeta._abc_invalidation_counter and<EOL>subtype in cls._abc_negative_cache):<EOL><INDENT>return False<EOL><DEDENT>return cls.__subclasscheck__(subtype)<EOL><DEDENT>return (cls.__subclasscheck__(subclass) or<EOL>cls.__subclasscheck__(subtype))<EOL>


<EOL>if subclass in cls._abc_cache:<EOL><INDENT>return True<EOL><DEDENT>if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:<EOL><INDENT>cls._abc_negative_cache = _weakrefset.WeakSet()<EOL>cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter<EOL><DEDENT>elif subclass in cls._abc_negative_cache:<EOL><INDENT>return False<EOL><DEDENT>ok = cls.__subclasshook__(subclass)<EOL>if ok is not NotImplemented:<EOL><INDENT>assert isinstance(ok, bool)<EOL>if ok:<EOL><INDENT>cls._abc_cache.add(subclass)<EOL><DEDENT>else:<EOL><INDENT>cls._abc_negative_cache.add(subclass)<EOL><DEDENT>return ok<EOL><DEDENT>if cls in getattr(subclass, '<STR_LIT>', ()):<EOL><INDENT>cls._abc_cache.add(subclass)<EOL>return True<EOL><DEDENT>for rcls in cls._abc_registry:<EOL><INDENT>if issubclass(subclass, rcls):<EOL><INDENT>cls._abc_cache.add(subclass)<EOL>return True<EOL><DEDENT><DEDENT>for scls in cls.__subclasses__():<EOL><INDENT>if issubclass(subclass, scls):<EOL><INDENT>cls._abc_cache.add(subclass)<EOL>return True<EOL><DEDENT><DEDENT>cls._abc_negative_cache.add(subclass)<EOL>return False<EOL>


if file is None:<EOL><INDENT>file = sys.stderr<EOL><DEDENT>for filename, lineno, name, line in extracted_list:<EOL><INDENT>_print(file,<EOL>'<STR_LIT>' % (filename,lineno,name))<EOL>if line:<EOL><INDENT>_print(file, '<STR_LIT>' % line.strip())<EOL><DEDENT><DEDENT>

Print the list of tuples as returned by extract_tb() or
    extract_stack() as a formatted stack trace to the given file.


list = []<EOL>for filename, lineno, name, line in extracted_list:<EOL><INDENT>item = '<STR_LIT>' % (filename,lineno,name)<EOL>if line:<EOL><INDENT>item = item + '<STR_LIT>' % line.strip()<EOL><DEDENT>list.append(item)<EOL><DEDENT>return list<EOL>

Format a list of traceback entry tuples for printing.

    Given a list of tuples as returned by extract_tb() or
    extract_stack(), return a list of strings ready for printing.
    Each string in the resulting list corresponds to the item with the
    same index in the argument list.  Each string ends in a newline;
    the strings may contain internal newlines as well, for those items
    whose source text line is not None.


def print_tb(tb, limit=None, file=None):

if file is None:<EOL><INDENT>file = sys.stderr<EOL><DEDENT>if limit is None:<EOL><INDENT>if hasattr(sys, '<STR_LIT>'):<EOL><INDENT>limit = sys.tracebacklimit<EOL><DEDENT><DEDENT>n = <NUM_LIT:0><EOL>while tb is not None and (limit is None or n < limit):<EOL><INDENT>f = tb.tb_frame<EOL>lineno = tb.tb_lineno<EOL>co = f.f_code<EOL>filename = co.co_filename<EOL>name = co.co_name<EOL>_print(file,<EOL>'<STR_LIT>' % (filename, lineno, name))<EOL>linecache.checkcache(filename)<EOL>line = linecache.getline(filename, lineno, f.f_globals)<EOL>if line: _print(file, '<STR_LIT:U+0020>' + line.strip())<EOL>tb = tb.tb_next<EOL>n = n+<NUM_LIT:1><EOL><DEDENT>

Print up to 'limit' stack trace entries from the traceback 'tb'.

    If 'limit' is omitted or None, all entries are printed.  If 'file'
    is omitted or None, the output goes to sys.stderr; otherwise
    'file' should be an open file or file-like object with a write()
    method.


return format_list(extract_tb(tb, limit))<EOL>

A shorthand for 'format_list(extract_tb(tb, limit))'.


if limit is None:<EOL><INDENT>if hasattr(sys, '<STR_LIT>'):<EOL><INDENT>limit = sys.tracebacklimit<EOL><DEDENT><DEDENT>list = []<EOL>n = <NUM_LIT:0><EOL>while tb is not None and (limit is None or n < limit):<EOL><INDENT>f = tb.tb_frame<EOL>lineno = tb.tb_lineno<EOL>co = f.f_code<EOL>filename = co.co_filename<EOL>name = co.co_name<EOL>linecache.checkcache(filename)<EOL>line = linecache.getline(filename, lineno, f.f_globals)<EOL>if line: line = line.strip()<EOL>else: line = None<EOL>list.append((filename, lineno, name, line))<EOL>tb = tb.tb_next<EOL>n = n+<NUM_LIT:1><EOL><DEDENT>return list<EOL>

Return list of up to limit pre-processed entries from traceback.

    This is useful for alternate formatting of stack traces.  If
    'limit' is omitted or None, all entries are extracted.  A
    pre-processed stack trace entry is a quadruple (filename, line
    number, function name, text) representing the information that is
    usually printed for a stack trace.  The text is a string with
    leading and trailing whitespace stripped; if the source is not
    available it is None.


def print_exception(etype, value, tb, limit=None, file=None):

if file is None:<EOL><INDENT>file = open('<STR_LIT>', '<STR_LIT:w>')<EOL><DEDENT>if tb:<EOL><INDENT>_print(file, '<STR_LIT>')<EOL>print_tb(tb, limit, file)<EOL><DEDENT>lines = format_exception_only(etype, value)<EOL>for line in lines:<EOL><INDENT>_print(file, line, '<STR_LIT>')<EOL><DEDENT>

Print exception up to 'limit' stack trace entries from 'tb' to 'file'.

    This differs from print_tb() in the following ways: (1) if
    traceback is not None, it prints a header "Traceback (most recent
    call last):"; (2) it prints the exception type and value after the
    stack trace; (3) if type is SyntaxError and value has the
    appropriate format, it prints the line where the syntax error
    occurred with a caret on the next line indicating the approximate
    position of the error.


def format_exception(etype, value, tb, limit = None):

if tb:<EOL><INDENT>list = ['<STR_LIT>']<EOL>list = list + format_tb(tb, limit)<EOL><DEDENT>else:<EOL><INDENT>list = []<EOL><DEDENT>list = list + format_exception_only(etype, value)<EOL>return list<EOL>

Format a stack trace and the exception information.

    The arguments have the same meaning as the corresponding arguments
    to print_exception().  The return value is a list of strings, each
    ending in a newline and some containing internal newlines.  When
    these lines are concatenated and printed, exactly the same text is
    printed as does print_exception().


<EOL>if (isinstance(etype, BaseException) or<EOL>isinstance(etype, types.InstanceType) or<EOL>etype is None or type(etype) is str):<EOL><INDENT>return [_format_final_exc_line(etype, value)]<EOL><DEDENT>stype = etype.__name__<EOL>if not issubclass(etype, SyntaxError):<EOL><INDENT>return [_format_final_exc_line(stype, value)]<EOL><DEDENT>lines = []<EOL>try:<EOL><INDENT>msg, (filename, lineno, offset, badline) = value.args<EOL><DEDENT>except Exception:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>filename = filename or "<STR_LIT>"<EOL>lines.append('<STR_LIT>' % (filename, lineno))<EOL>if badline is not None:<EOL><INDENT>lines.append('<STR_LIT>' % badline.strip())<EOL>if offset is not None:<EOL><INDENT>caretspace = badline.rstrip('<STR_LIT:\n>')<EOL>offset = min(len(caretspace), offset) - <NUM_LIT:1><EOL>caretspace = caretspace[:offset].lstrip()<EOL>caretspace = ((c.isspace() and c or '<STR_LIT:U+0020>') for c in caretspace)<EOL>lines.append('<STR_LIT>' % '<STR_LIT>'.join(caretspace))<EOL><DEDENT><DEDENT>value = msg<EOL><DEDENT>lines.append(_format_final_exc_line(stype, value))<EOL>return lines<EOL>

Format the exception part of a traceback.

    The arguments are the exception type and value such as given by
    sys.last_type and sys.last_value. The return value is a list of
    strings, each ending in a newline.

    Normally, the list contains a single string; however, for
    SyntaxError exceptions, it contains several lines that (when
    printed) display detailed information about where the syntax
    error occurred.

    The message indicating which exception occurred is always the last
    string in the list.


valuestr = _some_str(value)<EOL>if value is None or not valuestr:<EOL><INDENT>line = "<STR_LIT>" % etype<EOL><DEDENT>else:<EOL><INDENT>line = "<STR_LIT>" % (etype, valuestr)<EOL><DEDENT>return line<EOL>

Return a list of a single line -- normal case for format_exception_only


if file is None:<EOL><INDENT>file = open('<STR_LIT>', '<STR_LIT:w>')<EOL><DEDENT>try:<EOL><INDENT>etype, value, tb = sys.exc_info()<EOL>print_exception(etype, value, tb, limit, file)<EOL><DEDENT>finally:<EOL><INDENT>etype = value = tb = None<EOL><DEDENT>

Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'.
    (In fact, it uses sys.exc_info() to retrieve the same information
    in a thread-safe way.)


try:<EOL><INDENT>etype, value, tb = sys.exc_info()<EOL>return '<STR_LIT>'.join(format_exception(etype, value, tb, limit))<EOL><DEDENT>finally:<EOL><INDENT>etype = value = tb = None<EOL><DEDENT>


if not hasattr(sys, "<STR_LIT>"):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if file is None:<EOL><INDENT>file = sys.stderr<EOL><DEDENT>print_exception(sys.last_type, sys.last_value, sys.last_traceback,<EOL>limit, file)<EOL>

This is a shorthand for 'print_exception(sys.last_type,
    sys.last_value, sys.last_traceback, limit, file)'.


def print_stack(f=None, limit=None, file=None):

if f is None:<EOL><INDENT>try:<EOL><INDENT>raise ZeroDivisionError<EOL><DEDENT>except ZeroDivisionError:<EOL><INDENT>f = sys.exc_info()[<NUM_LIT:2>].tb_frame.f_back<EOL><DEDENT><DEDENT>print_list(extract_stack(f, limit), file)<EOL>

Print a stack trace from its invocation point.

    The optional 'f' argument can be used to specify an alternate
    stack frame at which to start. The optional 'limit' and 'file'
    arguments have the same meaning as for print_exception().


if f is None:<EOL><INDENT>try:<EOL><INDENT>raise ZeroDivisionError<EOL><DEDENT>except ZeroDivisionError:<EOL><INDENT>f = sys.exc_info()[<NUM_LIT:2>].tb_frame.f_back<EOL><DEDENT><DEDENT>return format_list(extract_stack(f, limit))<EOL>

Shorthand for 'format_list(extract_stack(f, limit))'.


def extract_stack(f=None, limit = None):

if f is None:<EOL><INDENT>try:<EOL><INDENT>raise ZeroDivisionError<EOL><DEDENT>except ZeroDivisionError:<EOL><INDENT>f = sys.exc_info()[<NUM_LIT:2>].tb_frame.f_back<EOL><DEDENT><DEDENT>if limit is None:<EOL><INDENT>if hasattr(sys, '<STR_LIT>'):<EOL><INDENT>limit = sys.tracebacklimit<EOL><DEDENT><DEDENT>list = []<EOL>n = <NUM_LIT:0><EOL>while f is not None and (limit is None or n < limit):<EOL><INDENT>lineno = f.f_lineno<EOL>co = f.f_code<EOL>filename = co.co_filename<EOL>name = co.co_name<EOL>linecache.checkcache(filename)<EOL>line = linecache.getline(filename, lineno, f.f_globals)<EOL>if line: line = line.strip()<EOL>else: line = None<EOL>list.append((filename, lineno, name, line))<EOL>f = f.f_back<EOL>n = n+<NUM_LIT:1><EOL><DEDENT>list.reverse()<EOL>return list<EOL>

Extract the raw traceback from the current stack frame.

    The return value has the same format as for extract_tb().  The
    optional 'f' and 'limit' arguments have the same meaning as for
    print_stack().  Each item in the list is a quadruple (filename,
    line number, function name, text), and the entries are in order
    from oldest to newest stack frame.


return tb.tb_lineno<EOL>

Calculate correct line number of traceback given in tb.

    Obsolete in 2.3.


def insort_right(a, x, lo=<NUM_LIT:0>, hi=None):

if lo < <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if hi is None:<EOL><INDENT>hi = len(a)<EOL><DEDENT>while lo < hi:<EOL><INDENT>mid = (lo+hi)//<NUM_LIT:2><EOL>if x < a[mid]: hi = mid<EOL>else: lo = mid+<NUM_LIT:1><EOL><DEDENT>a.insert(lo, x)<EOL>

Insert item x in list a, and keep it sorted assuming a is sorted.

    If x is already in a, insert it to the right of the rightmost x.

    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.


def bisect_right(a, x, lo=<NUM_LIT:0>, hi=None):

if lo < <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if hi is None:<EOL><INDENT>hi = len(a)<EOL><DEDENT>while lo < hi:<EOL><INDENT>mid = (lo+hi)//<NUM_LIT:2><EOL>if x < a[mid]: hi = mid<EOL>else: lo = mid+<NUM_LIT:1><EOL><DEDENT>return lo<EOL>

Return the index where to insert item x in list a, assuming a is sorted.

    The return value i is such that all e in a[:i] have e <= x, and all e in
    a[i:] have e > x.  So if x already appears in the list, a.insert(x) will
    insert just after the rightmost x already there.

    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.


def insort_left(a, x, lo=<NUM_LIT:0>, hi=None):

if lo < <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if hi is None:<EOL><INDENT>hi = len(a)<EOL><DEDENT>while lo < hi:<EOL><INDENT>mid = (lo+hi)//<NUM_LIT:2><EOL>if a[mid] < x: lo = mid+<NUM_LIT:1><EOL>else: hi = mid<EOL><DEDENT>a.insert(lo, x)<EOL>

Insert item x in list a, and keep it sorted assuming a is sorted.

    If x is already in a, insert it to the left of the leftmost x.

    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.


def bisect_left(a, x, lo=<NUM_LIT:0>, hi=None):

if lo < <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if hi is None:<EOL><INDENT>hi = len(a)<EOL><DEDENT>while lo < hi:<EOL><INDENT>mid = (lo+hi)//<NUM_LIT:2><EOL>if a[mid] < x: lo = mid+<NUM_LIT:1><EOL>else: hi = mid<EOL><DEDENT>return lo<EOL>

Return the index where to insert item x in list a, assuming a is sorted.

    The return value i is such that all e in a[:i] have e < x, and all e in
    a[i:] have e >= x.  So if x already appears in the list, a.insert(x) will
    insert just before the leftmost x already there.

    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.


def wrap(text, width=<NUM_LIT>, **kwargs):

w = TextWrapper(width=width, **kwargs)<EOL>return w.wrap(text)<EOL>

Wrap a single paragraph of text, returning a list of wrapped lines.

    Reformat the single paragraph in 'text' so it fits in lines of no
    more than 'width' columns, and return a list of wrapped lines.  By
    default, tabs in 'text' are expanded with string.expandtabs(), and
    all other whitespace characters (including newline) are converted to
    space.  See TextWrapper class for available keyword args to customize
    wrapping behaviour.


def fill(text, width=<NUM_LIT>, **kwargs):

w = TextWrapper(width=width, **kwargs)<EOL>return w.fill(text)<EOL>

Fill a single paragraph of text, returning a new string.

    Reformat the single paragraph in 'text' to fit in lines of no more
    than 'width' columns, and return a new string containing the entire
    wrapped paragraph.  As with wrap(), tabs are expanded and other
    whitespace characters converted to space.  See TextWrapper class for
    available keyword args to customize wrapping behaviour.


<EOL>margin = None<EOL>text = _whitespace_only_re.sub('<STR_LIT>', text)<EOL>indents = _leading_whitespace_re.findall(text)<EOL>for indent in indents:<EOL><INDENT>if margin is None:<EOL><INDENT>margin = indent<EOL><DEDENT>elif indent.startswith(margin):<EOL><INDENT>pass<EOL><DEDENT>elif margin.startswith(indent):<EOL><INDENT>margin = indent<EOL><DEDENT>else:<EOL><INDENT>for i, (x, y) in enumerate(zip(margin, indent)):<EOL><INDENT>if x != y:<EOL><INDENT>margin = margin[:i]<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>margin = margin[:len(indent)]<EOL><DEDENT><DEDENT><DEDENT>if <NUM_LIT:0> and margin:<EOL><INDENT>for line in text.split("<STR_LIT:\n>"):<EOL><INDENT>assert not line or line.startswith(margin),"<STR_LIT>" % (line, margin)<EOL><DEDENT><DEDENT>if margin:<EOL><INDENT>text = re.sub(r'<STR_LIT>' + margin, '<STR_LIT>', text)<EOL><DEDENT>return text<EOL>

Remove any common leading whitespace from every line in `text`.

    This can be used to make triple-quoted strings line up with the left
    edge of the display, while still presenting them in the source code
    in indented form.

    Note that tabs and spaces are both treated as whitespace, but they
    are not equal: the lines "  hello" and "\\thello" are
    considered to have no common leading whitespace.  (This behaviour is
    new in Python 2.5; older versions of this module incorrectly
    expanded tabs before searching for common leading whitespace.)


if self.expand_tabs:<EOL><INDENT>text = '<STR_LIT:U+0020>'.join(('<STR_LIT:U+0020>'.join(text.split('<STR_LIT:\n>'))).split('<STR_LIT:\t>'))<EOL><DEDENT>if self.replace_whitespace:<EOL><INDENT>text = '<STR_LIT:U+0020>'.join('<STR_LIT:U+0020>'.join(text.split('<STR_LIT:\n>')).split('<STR_LIT:\t>'))<EOL><DEDENT>return text<EOL>

_munge_whitespace(text : string) -> string

        Munge whitespace in text: expand tabs and convert all other
        whitespace characters to spaces.  Eg. " foo\\tbar\\n\\nbaz"
        becomes " foo    bar  baz".


if isinstance(text, _unicode):<EOL><INDENT>if self.break_on_hyphens:<EOL><INDENT>pat = self.wordsep_re_uni<EOL><DEDENT>else:<EOL><INDENT>pat = self.wordsep_simple_re_uni<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if self.break_on_hyphens:<EOL><INDENT>pat = self.wordsep_re<EOL><DEDENT>else:<EOL><INDENT>pat = self.wordsep_simple_re<EOL><DEDENT><DEDENT>chunks = pat.split(text)<EOL>chunks = [x for x in chunks if x is not None]<EOL>return chunks<EOL>

_split(text : string) -> [string]

        Split the text to wrap into indivisible chunks.  Chunks are
        not quite the same as words; see _wrap_chunks() for full
        details.  As an example, the text
          Look, goof-ball -- use the -b option!
        breaks into the following chunks:
          'Look,', ' ', 'goof-', 'ball', ' ', '--', ' ',
          'use', ' ', 'the', ' ', '-b', ' ', 'option!'
        if break_on_hyphens is True, or in:
          'Look,', ' ', 'goof-ball', ' ', '--', ' ',
          'use', ' ', 'the', ' ', '-b', ' ', option!'
        otherwise.


i = <NUM_LIT:0><EOL>patsearch = self.sentence_end_re.search<EOL>while i < len(chunks)-<NUM_LIT:1>:<EOL><INDENT>if chunks[i+<NUM_LIT:1>] == "<STR_LIT:U+0020>" and patsearch(chunks[i]):<EOL><INDENT>chunks[i+<NUM_LIT:1>] = "<STR_LIT:U+0020>"<EOL>i += <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>

_fix_sentence_endings(chunks : [string])

        Correct for sentence endings buried in 'chunks'.  Eg. when the
        original text contains "... foo.\\nBar ...", munge_whitespace()
        and split() will convert that to [..., "foo.", " ", "Bar", ...]
        which has one too few spaces; this method simply changes the one
        space to two.


def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):

<EOL>if width < <NUM_LIT:1>:<EOL><INDENT>space_left = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>space_left = width - cur_len<EOL><DEDENT>if self.break_long_words:<EOL><INDENT>cur_line.append(reversed_chunks[-<NUM_LIT:1>][:space_left])<EOL>reversed_chunks[-<NUM_LIT:1>] = reversed_chunks[-<NUM_LIT:1>][space_left:]<EOL><DEDENT>elif not cur_line:<EOL><INDENT>cur_line.append(reversed_chunks.pop())<EOL><DEDENT>

_handle_long_word(chunks : [string],
                             cur_line : [string],
                             cur_len : int, width : int)

        Handle a chunk of text (most likely a word, not whitespace) that
        is too long to fit in any line.


lines = []<EOL>if self.width <= <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>" % self.width)<EOL><DEDENT>chunks.reverse()<EOL>while chunks:<EOL><INDENT>cur_line = []<EOL>cur_len = <NUM_LIT:0><EOL>if lines:<EOL><INDENT>indent = self.subsequent_indent<EOL><DEDENT>else:<EOL><INDENT>indent = self.initial_indent<EOL><DEDENT>width = self.width - len(indent)<EOL>if self.drop_whitespace and chunks[-<NUM_LIT:1>].strip() == '<STR_LIT>' and lines:<EOL><INDENT>chunks.pop()<EOL><DEDENT>while chunks:<EOL><INDENT>l = len(chunks[-<NUM_LIT:1>])<EOL>if cur_len + l <= width:<EOL><INDENT>cur_line.append(chunks.pop())<EOL>cur_len += l<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if chunks and len(chunks[-<NUM_LIT:1>]) > width:<EOL><INDENT>self._handle_long_word(chunks, cur_line, cur_len, width)<EOL><DEDENT>if self.drop_whitespace and cur_line and cur_line[-<NUM_LIT:1>].strip() == '<STR_LIT>':<EOL><INDENT>cur_line.pop()<EOL><DEDENT>if cur_line:<EOL><INDENT>lines.append(indent + '<STR_LIT>'.join(cur_line))<EOL><DEDENT><DEDENT>return lines<EOL>

_wrap_chunks(chunks : [string]) -> [string]

        Wrap a sequence of text chunks and return a list of lines of
        length 'self.width' or less.  (If 'break_long_words' is false,
        some lines may be longer than this.)  Chunks correspond roughly
        to words and the whitespace between them: each chunk is
        indivisible (modulo 'break_long_words'), but a line break can
        come between any two chunks.  Chunks should not have internal
        whitespace; ie. a chunk is either all whitespace or a "word".
        Whitespace chunks will be removed from the beginning and end of
        lines, but apart from that whitespace is preserved.


text = self._munge_whitespace(text)<EOL>chunks = self._split(text)<EOL>if self.fix_sentence_endings:<EOL><INDENT>self._fix_sentence_endings(chunks)<EOL><DEDENT>return self._wrap_chunks(chunks)<EOL>

wrap(text : string) -> [string]

        Reformat the single paragraph in 'text' so it fits in lines of
        no more than 'self.width' columns, and return a list of wrapped
        lines.  Tabs in 'text' are expanded with string.expandtabs(),
        and all other whitespace characters (including newline) are
        converted to space.


return "<STR_LIT:\n>".join(self.wrap(text))<EOL>

fill(text : string) -> string

        Reformat the single paragraph in 'text' to fit in lines of no
        more than 'self.width' columns, and return a new string
        containing the entire wrapped paragraph.


global _profile_hook<EOL>_profile_hook = func<EOL>

Set a profile function for all threads started from the threading module.

    The func will be passed to sys.setprofile() for each thread, before its
    run() method is called.


global _trace_hook<EOL>_trace_hook = func<EOL>

Set a trace function for all threads started from the threading module.

    The func will be passed to sys.settrace() for each thread, before its run()
    method is called.


return _RLock(*args, **kwargs)<EOL>

Factory function that returns a new reentrant lock.

    A reentrant lock must be released by the thread that acquired it. Once a
    thread has acquired a reentrant lock, the same thread may acquire it again
    without blocking; the thread must release it once for each time it has
    acquired it.


return _Condition(*args, **kwargs)<EOL>

Factory function that returns a new condition variable object.

    A condition variable allows one or more threads to wait until they are
    notified by another thread.

    If the lock argument is given and not None, it must be a Lock or RLock
    object, and it is used as the underlying lock. Otherwise, a new RLock object
    is created and used as the underlying lock.


return _Semaphore(*args, **kwargs)<EOL>

A factory function that returns a new semaphore.

    Semaphores manage a counter representing the number of release() calls minus
    the number of acquire() calls, plus an initial value. The acquire() method
    blocks if necessary until it can return without making the counter
    negative. If not given, value defaults to 1.


return _BoundedSemaphore(*args, **kwargs)<EOL>

A factory function that returns a new bounded semaphore.

    A bounded semaphore checks to make sure its current value doesn't exceed its
    initial value. If it does, ValueError is raised. In most situations
    semaphores are used to guard resources with limited capacity.

    If the semaphore is released too many times it's a sign of a bug. If not
    given, value defaults to 1.

    Like regular semaphores, bounded semaphores manage a counter representing
    the number of release() calls minus the number of acquire() calls, plus an
    initial value. The acquire() method blocks if necessary until it can return
    without making the counter negative. If not given, value defaults to 1.


return _Event(*args, **kwargs)<EOL>

A factory function that returns a new event.

    Events manage a flag that can be set to true with the set() method and reset
    to false with the clear() method. The wait() method blocks until the flag is
    true.


return _Timer(*args, **kwargs)<EOL>

Factory function to create a Timer object.

    Timers call a function after a specified number of seconds:

        t = Timer(30.0, f, args=[], kwargs={})
        t.start()
        t.cancel()     # stop the timer's action if it's still waiting


try:<EOL><INDENT>return _active[_get_ident()]<EOL><DEDENT>except KeyError:<EOL><INDENT>return _DummyThread()<EOL><DEDENT>

Return the current Thread object, corresponding to the caller's thread of control.

    If the caller's thread of control was not created through the threading
    module, a dummy thread object with limited functionality is returned.


with _active_limbo_lock:<EOL><INDENT>return len(_active) + len(_limbo)<EOL><DEDENT>

Return the number of Thread objects currently alive.

    The returned count is equal to the length of the list returned by
    enumerate().


with _active_limbo_lock:<EOL><INDENT>return list(_active.values()) + list(_limbo.values())<EOL><DEDENT>

Return a list of all Thread objects currently alive.

    The list includes daemonic threads, dummy thread objects created by
    current_thread(), and the main thread. It excludes terminated threads and
    threads that have not yet been started.


me = _get_ident()<EOL>if self.__owner == me:<EOL><INDENT>self.__count = self.__count + <NUM_LIT:1><EOL>if __debug__:<EOL><INDENT>self._note("<STR_LIT>", self, blocking)<EOL><DEDENT>return <NUM_LIT:1><EOL><DEDENT>rc = self.__block.acquire(blocking)<EOL>if rc:<EOL><INDENT>self.__owner = me<EOL>self.__count = <NUM_LIT:1><EOL>if __debug__:<EOL><INDENT>self._note("<STR_LIT>", self, blocking)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if __debug__:<EOL><INDENT>self._note("<STR_LIT>", self, blocking)<EOL><DEDENT><DEDENT>return rc<EOL>

Acquire a lock, blocking or non-blocking.

        When invoked without arguments: if this thread already owns the lock,
        increment the recursion level by one, and return immediately. Otherwise,
        if another thread owns the lock, block until the lock is unlocked. Once
        the lock is unlocked (not owned by any thread), then grab ownership, set
        the recursion level to one, and return. If more than one thread is
        blocked waiting until the lock is unlocked, only one at a time will be
        able to grab ownership of the lock. There is no return value in this
        case.

        When invoked with the blocking argument set to true, do the same thing
        as when called without arguments, and return true.

        When invoked with the blocking argument set to false, do not block. If a
        call without an argument would block, return false immediately;
        otherwise, do the same thing as when called without arguments, and
        return true.


if self.__owner != _get_ident():<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>self.__count = count = self.__count - <NUM_LIT:1><EOL>if not count:<EOL><INDENT>self.__owner = None<EOL>self.__block.release()<EOL>if __debug__:<EOL><INDENT>self._note("<STR_LIT>", self)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if __debug__:<EOL><INDENT>self._note("<STR_LIT>", self)<EOL><DEDENT><DEDENT>

Release a lock, decrementing the recursion level.

        If after the decrement it is zero, reset the lock to unlocked (not owned
        by any thread), and if any other threads are blocked waiting for the
        lock to become unlocked, allow exactly one of them to proceed. If after
        the decrement the recursion level is still nonzero, the lock remains
        locked and owned by the calling thread.

        Only call this method when the calling thread owns the lock. A
        RuntimeError is raised if this method is called when the lock is
        unlocked.

        There is no return value.


if not self._is_owned():<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>waiter = _allocate_lock()<EOL>waiter.acquire()<EOL>self.__waiters.append(waiter)<EOL>saved_state = self._release_save()<EOL>try:    <EOL><INDENT>if timeout is None:<EOL><INDENT>waiter.acquire()<EOL>if __debug__:<EOL><INDENT>self._note("<STR_LIT>", self)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>endtime = _time() + timeout<EOL>delay = <NUM_LIT> <EOL>while True:<EOL><INDENT>gotit = waiter.acquire(<NUM_LIT:0>)<EOL>if gotit:<EOL><INDENT>break<EOL><DEDENT>remaining = endtime - _time()<EOL>if remaining <= <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT>delay = min(delay * <NUM_LIT:2>, remaining, <NUM_LIT>)<EOL>_sleep(delay)<EOL><DEDENT>if not gotit:<EOL><INDENT>if __debug__:<EOL><INDENT>self._note("<STR_LIT>", self, timeout)<EOL><DEDENT>try:<EOL><INDENT>self.__waiters.remove(waiter)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if __debug__:<EOL><INDENT>self._note("<STR_LIT>", self, timeout)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>self._acquire_restore(saved_state)<EOL><DEDENT>

Wait until notified or until a timeout occurs.

        If the calling thread has not acquired the lock when this method is
        called, a RuntimeError is raised.

        This method releases the underlying lock, and then blocks until it is
        awakened by a notify() or notifyAll() call for the same condition
        variable in another thread, or until the optional timeout occurs. Once
        awakened or timed out, it re-acquires the lock and returns.

        When the timeout argument is present and not None, it should be a
        floating point number specifying a timeout for the operation in seconds
        (or fractions thereof).

        When the underlying lock is an RLock, it is not released using its
        release() method, since this may not actually unlock the lock when it
        was acquired multiple times recursively. Instead, an internal interface
        of the RLock class is used, which really unlocks it even when it has
        been recursively acquired several times. Another internal interface is
        then used to restore the recursion level when the lock is reacquired.


if not self._is_owned():<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>__waiters = self.__waiters<EOL>waiters = __waiters[:n]<EOL>if not waiters:<EOL><INDENT>if __debug__:<EOL><INDENT>self._note("<STR_LIT>", self)<EOL><DEDENT>return<EOL><DEDENT>self._note("<STR_LIT>", self, n,<EOL>n!=<NUM_LIT:1> and "<STR_LIT:s>" or "<STR_LIT>")<EOL>for waiter in waiters:<EOL><INDENT>waiter.release()<EOL>try:<EOL><INDENT>__waiters.remove(waiter)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>

Wake up one or more threads waiting on this condition, if any.

        If the calling thread has not acquired the lock when this method is
        called, a RuntimeError is raised.

        This method wakes up at most n of the threads waiting for the condition
        variable; it is a no-op if no threads are waiting.


Wake up all threads waiting on this condition.

        If the calling thread has not acquired the lock when this method
        is called, a RuntimeError is raised.


rc = False<EOL>with self.__cond:<EOL><INDENT>while self.__value == <NUM_LIT:0>:<EOL><INDENT>if not blocking:<EOL><INDENT>break<EOL><DEDENT>if __debug__:<EOL><INDENT>self._note("<STR_LIT>",<EOL>self, blocking, self.__value)<EOL><DEDENT>self.__cond.wait()<EOL><DEDENT>else:<EOL><INDENT>self.__value = self.__value - <NUM_LIT:1><EOL>if __debug__:<EOL><INDENT>self._note("<STR_LIT>",<EOL>self, self.__value)<EOL><DEDENT>rc = True<EOL><DEDENT><DEDENT>return rc<EOL>

Acquire a semaphore, decrementing the internal counter by one.

        When invoked without arguments: if the internal counter is larger than
        zero on entry, decrement it by one and return immediately. If it is zero
        on entry, block, waiting until some other thread has called release() to
        make it larger than zero. This is done with proper interlocking so that
        if multiple acquire() calls are blocked, release() will wake exactly one
        of them up. The implementation may pick one at random, so the order in
        which blocked threads are awakened should not be relied on. There is no
        return value in this case.

        When invoked with blocking set to true, do the same thing as when called
        without arguments, and return true.

        When invoked with blocking set to false, do not block. If a call without
        an argument would block, return false immediately; otherwise, do the
        same thing as when called without arguments, and return true.


with self.__cond:<EOL><INDENT>self.__value = self.__value + <NUM_LIT:1><EOL>if __debug__:<EOL><INDENT>self._note("<STR_LIT>",<EOL>self, self.__value)<EOL><DEDENT>self.__cond.notify()<EOL><DEDENT>

Release a semaphore, incrementing the internal counter by one.

        When the counter is zero on entry and another thread is waiting for it
        to become larger than zero again, wake up that thread.


with self.__cond:<EOL><INDENT>if self.__value >= self._initial_value:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>self.__value += <NUM_LIT:1><EOL>self.__cond.notify()<EOL><DEDENT>

Release a semaphore, incrementing the internal counter by one.

        When the counter is zero on entry and another thread is waiting for it
        to become larger than zero again, wake up that thread.

        If the number of releases exceeds the number of acquires,
        raise a ValueError.


return self.__flag<EOL>

Return true if and only if the internal flag is true.


with self.__cond:<EOL><INDENT>self.__flag = True<EOL>self.__cond.notify_all()<EOL><DEDENT>

Set the internal flag to true.

        All threads waiting for the flag to become true are awakened. Threads
        that call wait() once the flag is true will not block at all.


with self.__cond:<EOL><INDENT>self.__flag = False<EOL><DEDENT>

Reset the internal flag to false.

        Subsequently, threads calling wait() will block until set() is called to
        set the internal flag to true again.


with self.__cond:<EOL><INDENT>if not self.__flag:<EOL><INDENT>self.__cond.wait(timeout)<EOL><DEDENT>return self.__flag<EOL><DEDENT>

Block until the internal flag is true.

        If the internal flag is true on entry, return immediately. Otherwise,
        block until another thread calls set() to set the flag to true, or until
        the optional timeout occurs.

        When the timeout argument is present and not None, it should be a
        floating point number specifying a timeout for the operation in seconds
        (or fractions thereof).

        This method returns the internal flag on exit, so it will always return
        True except if a timeout is given and the operation times out.


def __init__(self, group=None, target=None, name=None,<EOL>args=(), kwargs=None, verbose=None):

assert group is None, "<STR_LIT>"<EOL>_Verbose.__init__(self, verbose)<EOL>if kwargs is None:<EOL><INDENT>kwargs = {}<EOL><DEDENT>self.__target = target<EOL>self.__name = str(name or _newname())<EOL>self.__args = args<EOL>self.__kwargs = kwargs<EOL>self.__daemonic = self._set_daemon()<EOL>self.__ident = None<EOL>self.__started = Event()<EOL>self.__stopped = False<EOL>self.__block = Condition(Lock())<EOL>self.__initialized = True<EOL>self.__stderr = _sys.stderr<EOL>

This constructor should always be called with keyword arguments. Arguments are:

        *group* should be None; reserved for future extension when a ThreadGroup
        class is implemented.

        *target* is the callable object to be invoked by the run()
        method. Defaults to None, meaning nothing is called.

        *name* is the thread name. By default, a unique name is constructed of
        the form "Thread-N" where N is a small decimal number.

        *args* is the argument tuple for the target invocation. Defaults to ().

        *kwargs* is a dictionary of keyword arguments for the target
        invocation. Defaults to {}.

        If a subclass overrides the constructor, it must make sure to invoke
        the base class constructor (Thread.__init__()) before doing anything
        else to the thread.


if not self.__initialized:<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>if self.__started.is_set():<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>if __debug__:<EOL><INDENT>self._note("<STR_LIT>", self)<EOL><DEDENT>with _active_limbo_lock:<EOL><INDENT>_limbo[self] = self<EOL><DEDENT>try:<EOL><INDENT>_start_new_thread(self.__bootstrap, ())<EOL><DEDENT>except Exception:<EOL><INDENT>with _active_limbo_lock:<EOL><INDENT>del _limbo[self]<EOL><DEDENT>raise<EOL><DEDENT>self.__started.wait()<EOL>

Start the thread's activity.

        It must be called at most once per thread object. It arranges for the
        object's run() method to be invoked in a separate thread of control.

        This method will raise a RuntimeError if called more than once on the
        same thread object.


try:<EOL><INDENT>if self.__target:<EOL><INDENT>self.__target(*self.__args, **self.__kwargs)<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>del self.__target, self.__args, self.__kwargs<EOL><DEDENT>

Method representing the thread's activity.

        You may override this method in a subclass. The standard run() method
        invokes the callable object passed to the object's constructor as the
        target argument, if any, with sequential and keyword arguments taken
        from the args and kwargs arguments, respectively.


<EOL>try:<EOL><INDENT>with _active_limbo_lock:<EOL><INDENT>del _active[_get_ident()]<EOL><DEDENT><DEDENT>except KeyError:<EOL><INDENT>if '<STR_LIT>' not in _sys.modules:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>

Remove current thread from the dict of currently running threads.


if not self.__initialized:<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>if not self.__started.is_set():<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>if self is current_thread():<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>if __debug__:<EOL><INDENT>if not self.__stopped:<EOL><INDENT>self._note("<STR_LIT>", self)<EOL><DEDENT><DEDENT>self.__block.acquire()<EOL>try:<EOL><INDENT>if timeout is None:<EOL><INDENT>while not self.__stopped:<EOL><INDENT>self.__block.wait()<EOL><DEDENT>if __debug__:<EOL><INDENT>self._note("<STR_LIT>", self)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>deadline = _time() + timeout<EOL>while not self.__stopped:<EOL><INDENT>delay = deadline - _time()<EOL>if delay <= <NUM_LIT:0>:<EOL><INDENT>if __debug__:<EOL><INDENT>self._note("<STR_LIT>", self)<EOL><DEDENT>break<EOL><DEDENT>self.__block.wait(delay)<EOL><DEDENT>else:<EOL><INDENT>if __debug__:<EOL><INDENT>self._note("<STR_LIT>", self)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>self.__block.release()<EOL><DEDENT>

Wait until the thread terminates.

        This blocks the calling thread until the thread whose join() method is
        called terminates -- either normally or through an unhandled exception
        or until the optional timeout occurs.

        When the timeout argument is present and not None, it should be a
        floating point number specifying a timeout for the operation in seconds
        (or fractions thereof). As join() always returns None, you must call
        isAlive() after join() to decide whether a timeout happened -- if the
        thread is still alive, the join() call timed out.

        When the timeout argument is not present or None, the operation will
        block until the thread terminates.

        A thread can be join()ed many times.

        join() raises a RuntimeError if an attempt is made to join the current
        thread as that would cause a deadlock. It is also an error to join() a
        thread before it has been started and attempts to do so raises the same
        exception.


assert self.__initialized, "<STR_LIT>"<EOL>return self.__name<EOL>

A string used for identification purposes only.

        It has no semantics. Multiple threads may be given the same name. The
        initial name is set by the constructor.


assert self.__initialized, "<STR_LIT>"<EOL>return self.__ident<EOL>

Thread identifier of this thread or None if it has not been started.

        This is a nonzero integer. See the thread.get_ident() function. Thread
        identifiers may be recycled when a thread exits and another thread is
        created. The identifier is available even after the thread has exited.


assert self.__initialized, "<STR_LIT>"<EOL>return self.__started.is_set() and not self.__stopped<EOL>

Return whether the thread is alive.

        This method returns True just before the run() method starts until just
        after the run() method terminates. The module function enumerate()
        returns a list of all alive threads.


assert self.__initialized, "<STR_LIT>"<EOL>return self.__daemonic<EOL>

A boolean value indicating whether this thread is a daemon thread (True) or not (False).

        This must be set before start() is called, otherwise RuntimeError is
        raised. Its initial value is inherited from the creating thread; the
        main thread is not a daemon thread and therefore all threads created in
        the main thread default to daemon = False.

        The entire Python program exits when no alive non-daemon threads are
        left.


self.finished.set()<EOL>

Stop the timer if it hasn't finished yet


return (sep or '<STR_LIT:U+0020>').join(x.capitalize() for x in s.split(sep))<EOL>

capwords(s [,sep]) -> string

    Split the argument into words using split, capitalize each
    word using capitalize, and join the capitalized words using
    join.  If the optional second argument sep is absent or None,
    runs of whitespace characters are replaced by a single space
    and leading and trailing whitespace are removed, otherwise
    sep is used to split and join the words.


if len(fromstr) != len(tostr):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>global _idmapL<EOL>if not _idmapL:<EOL><INDENT>_idmapL = list(_idmap)<EOL><DEDENT>L = _idmapL[:]<EOL>fromstr = list(map(ord, fromstr))<EOL>for i in range(len(fromstr)):<EOL><INDENT>L[fromstr[i]] = tostr[i]<EOL><DEDENT>return '<STR_LIT>'.join(L)<EOL>

maketrans(frm, to) -> string

    Return a translation table (a string of 256 bytes long)
    suitable for use in string.translate.  The strings frm and to
    must be of the same length.


return s.lower()<EOL>

lower(s) -> string

    Return a copy of the string s converted to lowercase.


return s.upper()<EOL>

upper(s) -> string

    Return a copy of the string s converted to uppercase.


return s.swapcase()<EOL>

swapcase(s) -> string

    Return a copy of the string s with upper case characters
    converted to lowercase and vice versa.


return s.strip(chars)<EOL>

strip(s [,chars]) -> string

    Return a copy of the string s with leading and trailing
    whitespace removed.
    If chars is given and not None, remove characters in chars instead.
    If chars is unicode, S will be converted to unicode before stripping.


return s.lstrip(chars)<EOL>

lstrip(s [,chars]) -> string

    Return a copy of the string s with leading whitespace removed.
    If chars is given and not None, remove characters in chars instead.


return s.rstrip(chars)<EOL>

rstrip(s [,chars]) -> string

    Return a copy of the string s with trailing whitespace removed.
    If chars is given and not None, remove characters in chars instead.


def split(s, sep=None, maxsplit=-<NUM_LIT:1>):

return s.split(sep, maxsplit)<EOL>

split(s [,sep [,maxsplit]]) -> list of strings

    Return a list of the words in the string s, using sep as the
    delimiter string.  If maxsplit is given, splits at no more than
    maxsplit places (resulting in at most maxsplit+1 words).  If sep
    is not specified or is None, any whitespace string is a separator.

    (split and splitfields are synonymous)


def rsplit(s, sep=None, maxsplit=-<NUM_LIT:1>):

return s.rsplit(sep, maxsplit)<EOL>

rsplit(s [,sep [,maxsplit]]) -> list of strings

    Return a list of the words in the string s, using sep as the
    delimiter string, starting at the end of the string and working
    to the front.  If maxsplit is given, at most maxsplit splits are
    done. If sep is not specified or is None, any whitespace string
    is a separator.


def join(words, sep = '<STR_LIT:U+0020>'):

return sep.join(words)<EOL>

join(list [,sep]) -> string

    Return a string composed of the words in list, with
    intervening occurrences of sep.  The default separator is a
    single space.

    (joinfields and join are synonymous)


return s.index(*args)<EOL>

index(s, sub [,start [,end]]) -> int

    Like find but raises ValueError when the substring is not found.


return s.rindex(*args)<EOL>

rindex(s, sub [,start [,end]]) -> int

    Like rfind but raises ValueError when the substring is not found.


return s.count(*args)<EOL>

count(s, sub[, start[,end]]) -> int

    Return the number of occurrences of substring sub in string
    s[start:end].  Optional arguments start and end are
    interpreted as in slice notation.


return s.find(*args)<EOL>

find(s, sub [,start [,end]]) -> in

    Return the lowest index in s where substring sub is found,
    such that sub is contained within s[start,end].  Optional
    arguments start and end are interpreted as in slice notation.

    Return -1 on failure.


return s.rfind(*args)<EOL>

rfind(s, sub [,start [,end]]) -> int

    Return the highest index in s where substring sub is found,
    such that sub is contained within s[start,end].  Optional
    arguments start and end are interpreted as in slice notation.

    Return -1 on failure.


return _float(s)<EOL>

atof(s) -> float

    Return the floating point number represented by the string s.


return _int(s, base)<EOL>

atoi(s [,base]) -> int

    Return the integer represented by the string s in the given
    base, which defaults to 10.  The string s must consist of one
    or more digits, possibly preceded by a sign.  If base is 0, it
    is chosen from the leading characters of s, 0 for octal, 0x or
    0X for hexadecimal.  If base is 16, a preceding 0x or 0X is
    accepted.


return _long(s, base)<EOL>

atol(s [,base]) -> long

    Return the long integer represented by the string s in the
    given base, which defaults to 10.  The string s must consist
    of one or more digits, possibly preceded by a sign.  If base
    is 0, it is chosen from the leading characters of s, 0 for
    octal, 0x or 0X for hexadecimal.  If base is 16, a preceding
    0x or 0X is accepted.  A trailing L or l is not accepted,
    unless base is 0.


return s.ljust(width, *args)<EOL>

ljust(s, width[, fillchar]) -> string

    Return a left-justified version of s, in a field of the
    specified width, padded with spaces as needed.  The string is
    never truncated.  If specified the fillchar is used instead of spaces.


return s.rjust(width, *args)<EOL>

rjust(s, width[, fillchar]) -> string

    Return a right-justified version of s, in a field of the
    specified width, padded with spaces as needed.  The string is
    never truncated.  If specified the fillchar is used instead of spaces.


return s.center(width, *args)<EOL>

center(s, width[, fillchar]) -> string

    Return a center version of s, in a field of the specified
    width. padded with spaces as needed.  The string is never
    truncated.  If specified the fillchar is used instead of spaces.


if not isinstance(x, str):<EOL><INDENT>x = repr(x)<EOL><DEDENT>return x.zfill(width)<EOL>

zfill(x, width) -> string

    Pad a numeric string x with zeros on the left, to fill a field
    of the specified width.  The string x is never truncated.


return s.expandtabs(tabsize)<EOL>

expandtabs(s [,tabsize]) -> string

    Return a copy of the string s with all tab characters replaced
    by the appropriate number of spaces, depending on the current
    column, and the tabsize (default 8).


def translate(s, table, deletions="<STR_LIT>"):

if deletions or table is None:<EOL><INDENT>return s.translate(table, deletions)<EOL><DEDENT>else:<EOL><INDENT>return s.translate(table + s[:<NUM_LIT:0>])<EOL><DEDENT>

translate(s,table [,deletions]) -> string

    Return a copy of the string s, where all characters occurring
    in the optional argument deletions are removed, and the
    remaining characters have been mapped through the given
    translation table, which must be a string of length 256.  The
    deletions argument is not allowed for Unicode strings.


return s.capitalize()<EOL>

capitalize(s) -> string

    Return a copy of the string s with only its first character
    capitalized.


def replace(s, old, new, maxreplace=-<NUM_LIT:1>):

return s.replace(old, new, maxreplace)<EOL>

replace (str, old, new[, maxreplace]) -> string

    Return a copy of string str with all occurrences of substring
    old replaced by new. If the optional argument maxreplace is
    given, only the first maxreplace occurrences are replaced.


self.locked = False<EOL>self.queue = deque()<EOL>

Create a new mutex -- initially unlocked.


if self.testandset():<EOL><INDENT>function(argument)<EOL><DEDENT>else:<EOL><INDENT>self.queue.append((function, argument))<EOL><DEDENT>

Lock a mutex, call the function with supplied argument
        when it is acquired.  If the mutex is already locked, place
        function and argument in the queue.


if self.queue:<EOL><INDENT>function, argument = self.queue.popleft()<EOL>function(argument)<EOL><DEDENT>else:<EOL><INDENT>self.locked = False<EOL><DEDENT>

Unlock a mutex.  If the queue is not empty, call the next
        function with its argument.


heap.append(item)<EOL>_siftdown(heap, <NUM_LIT:0>, len(heap)-<NUM_LIT:1>)<EOL>

Push item onto heap, maintaining the heap invariant.


lastelt = heap.pop()    <EOL>if heap:<EOL><INDENT>returnitem = heap[<NUM_LIT:0>]<EOL>heap[<NUM_LIT:0>] = lastelt<EOL>_siftup(heap, <NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>returnitem = lastelt<EOL><DEDENT>return returnitem<EOL>

Pop the smallest item off the heap, maintaining the heap invariant.


returnitem = heap[<NUM_LIT:0>]    <EOL>heap[<NUM_LIT:0>] = item<EOL>_siftup(heap, <NUM_LIT:0>)<EOL>return returnitem<EOL>

Pop and return the current smallest value, and add the new item.

    This is more efficient than heappop() followed by heappush(), and can be
    more appropriate when using a fixed-size heap.  Note that the value
    returned may be larger than item!  That constrains reasonable uses of
    this routine unless written as part of a conditional replacement:

        if item > heap[0]:
            item = heapreplace(heap, item)


if heap and cmp_lt(heap[<NUM_LIT:0>], item):<EOL><INDENT>item, heap[<NUM_LIT:0>] = heap[<NUM_LIT:0>], item<EOL>_siftup(heap, <NUM_LIT:0>)<EOL><DEDENT>return item<EOL>

Fast version of a heappush followed by a heappop.


n = len(x)<EOL>for i in reversed(xrange(n//<NUM_LIT:2>)):<EOL><INDENT>_siftup(x, i)<EOL><DEDENT>

Transform list into a heap, in-place, in O(len(x)) time.


if heap and cmp_lt(item, heap[<NUM_LIT:0>]):<EOL><INDENT>item, heap[<NUM_LIT:0>] = heap[<NUM_LIT:0>], item<EOL>_siftup_max(heap, <NUM_LIT:0>)<EOL><DEDENT>return item<EOL>

Maxheap version of a heappush followed by a heappop.


n = len(x)<EOL>for i in reversed(range(n//<NUM_LIT:2>)):<EOL><INDENT>_siftup_max(x, i)<EOL><DEDENT>

Transform list into a maxheap, in-place, in O(len(x)) time.


if n < <NUM_LIT:0>:<EOL><INDENT>return []<EOL><DEDENT>it = iter(iterable)<EOL>result = list(islice(it, n))<EOL>if not result:<EOL><INDENT>return result<EOL><DEDENT>heapify(result)<EOL>_heappushpop = heappushpop<EOL>for elem in it:<EOL><INDENT>_heappushpop(result, elem)<EOL><DEDENT>result.sort(reverse=True)<EOL>return result<EOL>

Find the n largest elements in a dataset.

    Equivalent to:  sorted(iterable, reverse=True)[:n]


if n < <NUM_LIT:0>:<EOL><INDENT>return []<EOL><DEDENT>it = iter(iterable)<EOL>result = list(islice(it, n))<EOL>if not result:<EOL><INDENT>return result<EOL><DEDENT>_heapify_max(result)<EOL>_heappushpop = _heappushpop_max<EOL>for elem in it:<EOL><INDENT>_heappushpop(result, elem)<EOL><DEDENT>result.sort()<EOL>return result<EOL>

Find the n smallest elements in a dataset.

    Equivalent to:  sorted(iterable)[:n]


newitem = heap[pos]<EOL>while pos > startpos:<EOL><INDENT>parentpos = (pos - <NUM_LIT:1>) >> <NUM_LIT:1><EOL>parent = heap[parentpos]<EOL>if cmp_lt(parent, newitem):<EOL><INDENT>heap[pos] = parent<EOL>pos = parentpos<EOL>continue<EOL><DEDENT>break<EOL><DEDENT>heap[pos] = newitem<EOL>


endpos = len(heap)<EOL>startpos = pos<EOL>newitem = heap[pos]<EOL>childpos = <NUM_LIT:2>*pos + <NUM_LIT:1>    <EOL>while childpos < endpos:<EOL><INDENT>rightpos = childpos + <NUM_LIT:1><EOL>if rightpos < endpos and not cmp_lt(heap[rightpos], heap[childpos]):<EOL><INDENT>childpos = rightpos<EOL><DEDENT>heap[pos] = heap[childpos]<EOL>pos = childpos<EOL>childpos = <NUM_LIT:2>*pos + <NUM_LIT:1><EOL><DEDENT>heap[pos] = newitem<EOL>_siftdown_max(heap, startpos, pos)<EOL>


_heappop, _heapreplace, _StopIteration = heappop, heapreplace, StopIteration<EOL>_len = len<EOL>h = []<EOL>h_append = h.append<EOL>for itnum, it in enumerate(map(iter, iterables)):<EOL><INDENT>try:<EOL><INDENT>next = it.next<EOL>h_append([next(), itnum, next])<EOL><DEDENT>except _StopIteration:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>heapify(h)<EOL>while _len(h) > <NUM_LIT:1>:<EOL><INDENT>try:<EOL><INDENT>while <NUM_LIT:1>:<EOL><INDENT>v, itnum, next = s = h[<NUM_LIT:0>]<EOL>yield v<EOL>s[<NUM_LIT:0>] = next()               <EOL>_heapreplace(h, s)          <EOL><DEDENT><DEDENT>except _StopIteration:<EOL><INDENT>_heappop(h)                     <EOL><DEDENT><DEDENT>if h:<EOL><INDENT>v, itnum, next = h[<NUM_LIT:0>]<EOL>yield v<EOL>for v in next.__self__:<EOL><INDENT>yield v<EOL><DEDENT><DEDENT>

Merge multiple sorted inputs into a single sorted output.

    Similar to sorted(itertools.chain(*iterables)) but returns a generator,
    does not pull the data into memory all at once, and assumes that each of
    the input streams is already sorted (smallest to largest).

    >>> list(merge([1,3,5,7], [0,2,4,8], [5,10,15,20], [], [25]))
    [0, 1, 2, 3, 4, 5, 5, 7, 8, 10, 15, 20, 25]


<EOL>if n == <NUM_LIT:1>:<EOL><INDENT>it = iter(iterable)<EOL>head = list(islice(it, <NUM_LIT:1>))<EOL>if not head:<EOL><INDENT>return []<EOL><DEDENT>if key is None:<EOL><INDENT>return [min(chain(head, it))]<EOL><DEDENT>return [min(chain(head, it), key=key)]<EOL><DEDENT>try:<EOL><INDENT>size = len(iterable)<EOL><DEDENT>except (TypeError, AttributeError):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if n >= size:<EOL><INDENT>return sorted(iterable, key=key)[:n]<EOL><DEDENT><DEDENT>if key is None:<EOL><INDENT>it = izip(iterable, count())                        <EOL>result = _nsmallest(n, it)<EOL>return map(itemgetter(<NUM_LIT:0>), result)                   <EOL><DEDENT>in1, in2 = tee(iterable)<EOL>it = izip(imap(key, in1), count(), in2)                 <EOL>result = _nsmallest(n, it)<EOL>return map(itemgetter(<NUM_LIT:2>), result)                       <EOL>

Find the n smallest elements in a dataset.

    Equivalent to:  sorted(iterable, key=key)[:n]


<EOL>if n == <NUM_LIT:1>:<EOL><INDENT>it = iter(iterable)<EOL>head = list(islice(it, <NUM_LIT:1>))<EOL>if not head:<EOL><INDENT>return []<EOL><DEDENT>if key is None:<EOL><INDENT>return [max(chain(head, it))]<EOL><DEDENT>return [max(chain(head, it), key=key)]<EOL><DEDENT>try:<EOL><INDENT>size = len(iterable)<EOL><DEDENT>except (TypeError, AttributeError):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if n >= size:<EOL><INDENT>return sorted(iterable, key=key, reverse=True)[:n]<EOL><DEDENT><DEDENT>if key is None:<EOL><INDENT>it = izip(iterable, count(<NUM_LIT:0>,-<NUM_LIT:1>))                    <EOL>result = _nlargest(n, it)<EOL>return map(itemgetter(<NUM_LIT:0>), result)                   <EOL><DEDENT>in1, in2 = tee(iterable)<EOL>it = izip(imap(key, in1), count(<NUM_LIT:0>,-<NUM_LIT:1>), in2)             <EOL>result = _nlargest(n, it)<EOL>return map(itemgetter(<NUM_LIT:2>), result)                       <EOL>

Find the n largest elements in a dataset.

    Equivalent to:  sorted(iterable, key=key, reverse=True)[:n]


if encoding == '<STR_LIT>':<EOL><INDENT>import base64<EOL>return base64.decode(input, output)<EOL><DEDENT>if encoding == '<STR_LIT>':<EOL><INDENT>import quopri<EOL>return quopri.decode(input, output)<EOL><DEDENT>if encoding in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>import uu<EOL>return uu.decode(input, output)<EOL><DEDENT>if encoding in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>return output.write(input.read())<EOL><DEDENT>if encoding in decodetab:<EOL><INDENT>pipethrough(input, decodetab[encoding], output)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % encoding)<EOL><DEDENT>

Decode common content-transfer-encodings (base64, quopri, uuencode).


if encoding == '<STR_LIT>':<EOL><INDENT>import base64<EOL>return base64.encode(input, output)<EOL><DEDENT>if encoding == '<STR_LIT>':<EOL><INDENT>import quopri<EOL>return quopri.encode(input, output, <NUM_LIT:0>)<EOL><DEDENT>if encoding in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>import uu<EOL>return uu.encode(input, output)<EOL><DEDENT>if encoding in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>return output.write(input.read())<EOL><DEDENT>if encoding in encodetab:<EOL><INDENT>pipethrough(input, encodetab[encoding], output)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % encoding)<EOL><DEDENT>

Encode common content-transfer-encodings (base64, quopri, uuencode).


i = j = <NUM_LIT:0><EOL>missing = []<EOL>unexpected = []<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>e = expected[i]<EOL>a = actual[j]<EOL>if e < a:<EOL><INDENT>missing.append(e)<EOL>i += <NUM_LIT:1><EOL>while expected[i] == e:<EOL><INDENT>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>elif e > a:<EOL><INDENT>unexpected.append(a)<EOL>j += <NUM_LIT:1><EOL>while actual[j] == a:<EOL><INDENT>j += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>i += <NUM_LIT:1><EOL>try:<EOL><INDENT>while expected[i] == e:<EOL><INDENT>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>finally:<EOL><INDENT>j += <NUM_LIT:1><EOL>while actual[j] == a:<EOL><INDENT>j += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT><DEDENT>except IndexError:<EOL><INDENT>missing.extend(expected[i:])<EOL>unexpected.extend(actual[j:])<EOL>break<EOL><DEDENT><DEDENT>return missing, unexpected<EOL>

Finds elements in only one or the other of two, sorted input lists.

    Returns a two-element tuple of lists.    The first list contains those
    elements in the "expected" list but not in the "actual" list, and the
    second contains those elements in the "actual" list but not in the
    "expected" list.    Duplicate elements in either input list are ignored.


def unorderable_list_difference(expected, actual, ignore_duplicate=False):

missing = []<EOL>unexpected = []<EOL>while expected:<EOL><INDENT>item = expected.pop()<EOL>try:<EOL><INDENT>actual.remove(item)<EOL><DEDENT>except ValueError:<EOL><INDENT>missing.append(item)<EOL><DEDENT>if ignore_duplicate:<EOL><INDENT>for lst in expected, actual:<EOL><INDENT>try:<EOL><INDENT>while True:<EOL><INDENT>lst.remove(item)<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if ignore_duplicate:<EOL><INDENT>while actual:<EOL><INDENT>item = actual.pop()<EOL>unexpected.append(item)<EOL>try:<EOL><INDENT>while True:<EOL><INDENT>actual.remove(item)<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return missing, unexpected<EOL><DEDENT>return missing, actual<EOL>

Same behavior as sorted_list_difference but
    for lists of unorderable items (like dicts).

    As it does a linear search per item (remove) it
    has O(n*n) performance.


<EOL>s, t = list(actual), list(expected)<EOL>m, n = len(s), len(t)<EOL>NULL = object()<EOL>result = []<EOL>for i, elem in enumerate(s):<EOL><INDENT>if elem is NULL:<EOL><INDENT>continue<EOL><DEDENT>cnt_s = cnt_t = <NUM_LIT:0><EOL>for j in range(i, m):<EOL><INDENT>if s[j] == elem:<EOL><INDENT>cnt_s += <NUM_LIT:1><EOL>s[j] = NULL<EOL><DEDENT><DEDENT>for j, other_elem in enumerate(t):<EOL><INDENT>if other_elem == elem:<EOL><INDENT>cnt_t += <NUM_LIT:1><EOL>t[j] = NULL<EOL><DEDENT><DEDENT>if cnt_s != cnt_t:<EOL><INDENT>diff = _Mismatch(cnt_s, cnt_t, elem)<EOL>result.append(diff)<EOL><DEDENT><DEDENT>for i, elem in enumerate(t):<EOL><INDENT>if elem is NULL:<EOL><INDENT>continue<EOL><DEDENT>cnt_t = <NUM_LIT:0><EOL>for j in range(i, n):<EOL><INDENT>if t[j] == elem:<EOL><INDENT>cnt_t += <NUM_LIT:1><EOL>t[j] = NULL<EOL><DEDENT><DEDENT>diff = _Mismatch(<NUM_LIT:0>, cnt_t, elem)<EOL>result.append(diff)<EOL><DEDENT>return result<EOL>

Returns list of (cnt_act, cnt_exp, elem) triples where the counts differ


c = {} <EOL>for elem in iterable:<EOL><INDENT>c[elem] = c.get(elem, <NUM_LIT:0>) + <NUM_LIT:1><EOL><DEDENT>return c<EOL>

Return dict of element counts, in the order they were first seen


<EOL>s, t = _ordered_count(actual), _ordered_count(expected)<EOL>result = []<EOL>for elem, cnt_s in s.items():<EOL><INDENT>cnt_t = t.get(elem, <NUM_LIT:0>)<EOL>if cnt_s != cnt_t:<EOL><INDENT>diff = _Mismatch(cnt_s, cnt_t, elem)<EOL>result.append(diff)<EOL><DEDENT><DEDENT>for elem, cnt_t in t.items():<EOL><INDENT>if elem not in s:<EOL><INDENT>diff = _Mismatch(<NUM_LIT:0>, cnt_t, elem)<EOL>result.append(diff)<EOL><DEDENT><DEDENT>return result<EOL>


def __new__(_cls, actual, expected, value):

return _tuple.__new__(_cls, (actual, expected, value))<EOL>

Create new instance of Mismatch(actual, expected, value)


def _make(cls, iterable, new=tuple.__new__, len=len):

result = new(cls, iterable)<EOL>if len(result) != <NUM_LIT:3>:<EOL><INDENT>raise TypeError('<STR_LIT>' % len(result))<EOL><DEDENT>return result<EOL>

Make a new Mismatch object from a sequence or iterable


return '<STR_LIT>' % self<EOL>

Return a nicely formatted representation string


<EOL>return dict(zip(self._fields, self))<EOL>

Return a new OrderedDict which maps field names to their values


result = _self._make(map(kwds.pop, ('<STR_LIT>', '<STR_LIT>', '<STR_LIT:value>'), _self))<EOL>if kwds:<EOL><INDENT>raise ValueError('<STR_LIT>' % kwds.keys())<EOL><DEDENT>return result<EOL>

Return a new Mismatch object replacing specified fields with new values


return tuple(self)<EOL>

Return self as a plain tuple.  Used by copy and pickle.


pass<EOL>


<EOL>if s in wordmap:<EOL><INDENT>return s<EOL><DEDENT>else:<EOL><INDENT>possibilities = [word for word in list(wordmap.keys())<EOL>if word.startswith(s)]<EOL>if len(possibilities) == <NUM_LIT:1>:<EOL><INDENT>return possibilities[<NUM_LIT:0>]<EOL><DEDENT>elif not possibilities:<EOL><INDENT>raise BadOptionError(s)<EOL><DEDENT>else:<EOL><INDENT>possibilities.sort()<EOL>raise AmbiguousOptionError(s, possibilities)<EOL><DEDENT><DEDENT>

_match_abbrev(s : string, wordmap : {string : Option}) -> string

    Return the string key in 'wordmap' for which 's' is an unambiguous
    abbreviation.  If 's' is found to be ambiguous or doesn't match any of
    'words', raise BadOptionError.


text_width = max(self.width - self.current_indent, <NUM_LIT:11>)<EOL>indent = "<STR_LIT:U+0020>"*self.current_indent<EOL>return textwrap.fill(text,<EOL>text_width,<EOL>initial_indent=indent,<EOL>subsequent_indent=indent)<EOL>

Format a paragraph of free-form text for inclusion in the
help output at the current indentation level.


if option.takes_value():<EOL><INDENT>metavar = option.metavar or option.dest.upper()<EOL>short_opts = [self._short_opt_fmt % (sopt, metavar)<EOL>for sopt in option._short_opts]<EOL>long_opts = [self._long_opt_fmt % (lopt, metavar)<EOL>for lopt in option._long_opts]<EOL><DEDENT>else:<EOL><INDENT>short_opts = option._short_opts<EOL>long_opts = option._long_opts<EOL><DEDENT>if self.short_first:<EOL><INDENT>opts = short_opts + long_opts<EOL><DEDENT>else:<EOL><INDENT>opts = long_opts + short_opts<EOL><DEDENT>return "<STR_LIT:U+002CU+0020>".join(opts)<EOL>

Return a comma-separated list of option strings & metavariables.


for attr in dir(self):<EOL><INDENT>if attr in dict:<EOL><INDENT>dval = dict[attr]<EOL>if dval is not None:<EOL><INDENT>setattr(self, attr, dval)<EOL><DEDENT><DEDENT><DEDENT>

Update the option values from an arbitrary dictionary, but only
use keys from dict that already have a corresponding attribute
in self.  Any keys in dict without a corresponding attribute
are silently ignored.


Update the option values from an arbitrary dictionary,
using all keys from the dictionary regardless of whether
they have a corresponding attribute in self or not.


del self._short_opt<EOL>del self._long_opt<EOL>del self.defaults<EOL>


if type(args[<NUM_LIT:0>]) in (str,):<EOL><INDENT>option = self.option_class(*args, **kwargs)<EOL><DEDENT>elif len(args) == <NUM_LIT:1> and not kwargs:<EOL><INDENT>option = args[<NUM_LIT:0>]<EOL>if not isinstance(option, Option):<EOL><INDENT>raise TypeError("<STR_LIT>" % option)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>self._check_conflict(option)<EOL>self.option_list.append(option)<EOL>option.container = self<EOL>for opt in option._short_opts:<EOL><INDENT>self._short_opt[opt] = option<EOL><DEDENT>for opt in option._long_opts:<EOL><INDENT>self._long_opt[opt] = option<EOL><DEDENT>if option.dest is not None:     <EOL><INDENT>if option.default is not NO_DEFAULT:<EOL><INDENT>self.defaults[option.dest] = option.default<EOL><DEDENT>elif option.dest not in self.defaults:<EOL><INDENT>self.defaults[option.dest] = None<EOL><DEDENT><DEDENT>return option<EOL>

add_option(Option)
           add_option(opt_str, ..., kwarg=val, ...)


OptionContainer.destroy(self)<EOL>del self.option_list<EOL>


OptionContainer.destroy(self)<EOL>for group in self.option_groups:<EOL><INDENT>group.destroy()<EOL><DEDENT>del self.option_list<EOL>del self.option_groups<EOL>del self.formatter<EOL>

Declare that you are done with this OptionParser.  This cleans up
reference cycles so the OptionParser (and all objects referenced by
it) can be garbage-collected promptly.  After calling destroy(), the
OptionParser is unusable.


self.allow_interspersed_args = True<EOL>

Set parsing to not stop on the first non-option, allowing
        interspersing switches with command arguments. This is the
        default behavior. See also disable_interspersed_args() and the
        class documentation description of the attribute
        allow_interspersed_args.


self.allow_interspersed_args = False<EOL>

Set parsing to stop on the first non-option. Use this if
        you have a command processor which runs another command that
        has options of its own and you want to make sure these options
        don't get confused.


def parse_args(self, args=None, values=None):

rargs = self._get_args(args)<EOL>if values is None:<EOL><INDENT>values = self.get_default_values()<EOL><DEDENT>self.rargs = rargs<EOL>self.largs = largs = []<EOL>self.values = values<EOL>try:<EOL><INDENT>stop = self._process_args(largs, rargs, values)<EOL><DEDENT>except (BadOptionError, OptionValueError) as err:<EOL><INDENT>self.error(str(err))<EOL><DEDENT>args = largs + rargs<EOL>return self.check_values(values, args)<EOL>

parse_args(args : [string] = sys.argv[1:],
           values : Values = None)
-> (values : Values, args : [string])

Parse the command-line options found in 'args' (default:
sys.argv[1:]).  Any errors result in a call to 'error()', which
by default prints the usage message to stderr and calls
sys.exit() with an error message.  On success returns a pair
(values, args) where 'values' is a Values instance (with all
your option values) and 'args' is the list of arguments left
over after parsing options.


return (values, args)<EOL>

check_values(values : Values, args : [string])
-> (values : Values, args : [string])

Check that the supplied option values and leftover arguments are
valid.  Returns the option values and leftover arguments
(possibly adjusted, possibly completely new -- whatever you
like).  Default implementation just returns the passed-in
values; subclasses may override as desired.


def _process_args(self, largs, rargs, values):

while rargs:<EOL><INDENT>arg = rargs[<NUM_LIT:0>]<EOL>if arg == "<STR_LIT>":<EOL><INDENT>del rargs[<NUM_LIT:0>]<EOL>return<EOL><DEDENT>elif arg[<NUM_LIT:0>:<NUM_LIT:2>] == "<STR_LIT>":<EOL><INDENT>self._process_long_opt(rargs, values)<EOL><DEDENT>elif arg[:<NUM_LIT:1>] == "<STR_LIT:->" and len(arg) > <NUM_LIT:1>:<EOL><INDENT>self._process_short_opts(rargs, values)<EOL><DEDENT>elif self.allow_interspersed_args:<EOL><INDENT>largs.append(arg)<EOL>del rargs[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return                  <EOL><DEDENT><DEDENT>

_process_args(largs : [string],
                         rargs : [string],
                         values : Values)

        Process command-line arguments and populate 'values', consuming
        options and arguments from 'rargs'.  If 'allow_interspersed_args' is
        false, stop at the first non-option argument.  If true, accumulate any
        interspersed non-option arguments in 'largs'.


return _match_abbrev(opt, self._long_opt)<EOL>

_match_long_opt(opt : string) -> string

        Determine which long option string 'opt' matches, ie. which one
        it is an unambiguous abbreviation for.  Raises BadOptionError if
        'opt' doesn't unambiguously match any long option string.


self.print_usage(sys.stderr)<EOL>self.exit(<NUM_LIT:2>, "<STR_LIT>" % (self.get_prog_name(), msg))<EOL>

error(msg : string)

        Print a usage message incorporating 'msg' to stderr and exit.
        If you override this in a subclass, it should not return -- it
        should either exit or raise an exception.


if self.usage:<EOL><INDENT>print(self.get_usage(), file=file)<EOL><DEDENT>

print_usage(file : file = stdout)

        Print the usage message for the current program (self.usage) to
        'file' (default stdout).  Any occurrence of the string "%prog" in
        self.usage is replaced with the name of the current program
        (basename of sys.argv[0]).  Does nothing if self.usage is empty
        or not defined.


if self.version:<EOL><INDENT>print(self.get_version(), file=file)<EOL><DEDENT>

print_version(file : file = stdout)

        Print the version message for this program (self.version) to
        'file' (default stdout).  As with print_usage(), any occurrence
        of "%prog" in self.version is replaced by the current program's
        name.  Does nothing if self.version is empty or undefined.


if file is None:<EOL><INDENT>file = sys.stdout<EOL><DEDENT>encoding = self._get_encoding(file)<EOL>file.write(self.format_help())<EOL>

print_help(file : file = stdout)

        Print an extended help message, listing all options and any
        help text provided with them, to 'file' (default stdout).


def __init__(self, timefunc, delayfunc):

self._queue = []<EOL>self.timefunc = timefunc<EOL>self.delayfunc = delayfunc<EOL>

Initialize a new instance, passing the time and delay
        functions


def enterabs(self, time, priority, action, argument):

event = Event(time, priority, action, argument)<EOL>heapq.heappush(self._queue, event)<EOL>return event<EOL>

Enter a new event in the queue at an absolute time.
        Returns an ID for the event which can be used to remove it,
        if necessary.


def enter(self, delay, priority, action, argument):

time = self.timefunc() + delay<EOL>return self.enterabs(time, priority, action, argument)<EOL>

A variant that specifies the time as a relative time.
        This is actually the more commonly used interface.


self._queue.remove(event)<EOL>heapq.heapify(self._queue)<EOL>

Remove an event from the queue.
        This must be presented the ID as returned by enter().
        If the event is not in the queue, this raises ValueError.


return not self._queue<EOL>


<EOL>q = self._queue<EOL>delayfunc = self.delayfunc<EOL>timefunc = self.timefunc<EOL>pop = heapq.heappop<EOL>while q:<EOL><INDENT>checked_event = q[<NUM_LIT:0>]<EOL>time, priority, action, argument = checked_event.get_fields()<EOL>now = timefunc()<EOL>if now < time:<EOL><INDENT>delayfunc(time - now)<EOL><DEDENT>else:<EOL><INDENT>event = pop(q)<EOL>if event is checked_event:<EOL><INDENT>action(*argument)<EOL>delayfunc(<NUM_LIT:0>)   <EOL><DEDENT>else:<EOL><INDENT>heapq.heappush(q, event)<EOL><DEDENT><DEDENT><DEDENT>

Execute events until the queue is empty.
        When there is a positive delay until the first event, the
        delay function is called and the event is left in the queue;
        otherwise, the event is removed from the queue and executed
        (its action function is called, passing it the argument).  If
        the delay function returns prematurely, it is simply
        restarted.
        It is legal for both the delay function and the action
        function to modify the queue or to raise an exception;
        exceptions are not caught but the scheduler's state remains
        well-defined so run() may be called again.
        A questionable hack is added to allow other threads to run:
        just after an event is executed, a delay of 0 is executed, to
        avoid monopolizing the CPU when other threads are also
        runnable.


<EOL>events = self._queue[:]<EOL>return map(heapq.heappop, [events]*len(events))<EOL>

An ordered list of upcoming events.
        Events are named tuples with fields for:
            time, priority, action, arguments


if len(s) > <NUM_LIT:1>:<EOL><INDENT>if s.startswith('<STR_LIT:">') and s.endswith('<STR_LIT:">'):<EOL><INDENT>return s[<NUM_LIT:1>:-<NUM_LIT:1>].replace('<STR_LIT>', '<STR_LIT:\\>').replace('<STR_LIT>', '<STR_LIT:">')<EOL><DEDENT>if s.startswith('<STR_LIT:<>') and s.endswith('<STR_LIT:>>'):<EOL><INDENT>return s[<NUM_LIT:1>:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>return s<EOL>


return s.replace('<STR_LIT:\\>', '<STR_LIT>').replace('<STR_LIT:">', '<STR_LIT>')<EOL>


a = AddressList(address)<EOL>lst = a.addresslist<EOL>if not lst:<EOL><INDENT>return (None, None)<EOL><DEDENT>return lst[<NUM_LIT:0>]<EOL>

Parse an address into a (realname, mailaddr) tuple.


if pair[<NUM_LIT:0>]:<EOL><INDENT>return '<STR_LIT:">' + pair[<NUM_LIT:0>] + '<STR_LIT>' + pair[<NUM_LIT:1>] + '<STR_LIT:>>'<EOL><DEDENT>else:<EOL><INDENT>return pair[<NUM_LIT:1>]<EOL><DEDENT>

Dump a (name, address) pair in a canonicalized form.


if not data:<EOL><INDENT>return None<EOL><DEDENT>data = data.split()<EOL>if data[<NUM_LIT:0>][-<NUM_LIT:1>] in ('<STR_LIT:U+002C>', '<STR_LIT:.>') or data[<NUM_LIT:0>].lower() in _daynames:<EOL><INDENT>del data[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>i = data[<NUM_LIT:0>].rfind('<STR_LIT:U+002C>')<EOL>if i >= <NUM_LIT:0>:<EOL><INDENT>data[<NUM_LIT:0>] = data[<NUM_LIT:0>][i+<NUM_LIT:1>:]<EOL><DEDENT><DEDENT>if len(data) == <NUM_LIT:3>: <EOL><INDENT>stuff = data[<NUM_LIT:0>].split('<STR_LIT:->')<EOL>if len(stuff) == <NUM_LIT:3>:<EOL><INDENT>data = stuff + data[<NUM_LIT:1>:]<EOL><DEDENT><DEDENT>if len(data) == <NUM_LIT:4>:<EOL><INDENT>s = data[<NUM_LIT:3>]<EOL>i = s.find('<STR_LIT:+>')<EOL>if i > <NUM_LIT:0>:<EOL><INDENT>data[<NUM_LIT:3>:] = [s[:i], s[i+<NUM_LIT:1>:]]<EOL><DEDENT>else:<EOL><INDENT>data.append('<STR_LIT>') <EOL><DEDENT><DEDENT>if len(data) < <NUM_LIT:5>:<EOL><INDENT>return None<EOL><DEDENT>data = data[:<NUM_LIT:5>]<EOL>[dd, mm, yy, tm, tz] = data<EOL>mm = mm.lower()<EOL>if not mm in _monthnames:<EOL><INDENT>dd, mm = mm, dd.lower()<EOL>if not mm in _monthnames:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>mm = _monthnames.index(mm)+<NUM_LIT:1><EOL>if mm > <NUM_LIT:12>: mm = mm - <NUM_LIT:12><EOL>if dd[-<NUM_LIT:1>] == '<STR_LIT:U+002C>':<EOL><INDENT>dd = dd[:-<NUM_LIT:1>]<EOL><DEDENT>i = yy.find('<STR_LIT::>')<EOL>if i > <NUM_LIT:0>:<EOL><INDENT>yy, tm = tm, yy<EOL><DEDENT>if yy[-<NUM_LIT:1>] == '<STR_LIT:U+002C>':<EOL><INDENT>yy = yy[:-<NUM_LIT:1>]<EOL><DEDENT>if not yy[<NUM_LIT:0>].isdigit():<EOL><INDENT>yy, tz = tz, yy<EOL><DEDENT>if tm[-<NUM_LIT:1>] == '<STR_LIT:U+002C>':<EOL><INDENT>tm = tm[:-<NUM_LIT:1>]<EOL><DEDENT>tm = tm.split('<STR_LIT::>')<EOL>if len(tm) == <NUM_LIT:2>:<EOL><INDENT>[thh, tmm] = tm<EOL>tss = '<STR_LIT:0>'<EOL><DEDENT>elif len(tm) == <NUM_LIT:3>:<EOL><INDENT>[thh, tmm, tss] = tm<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>try:<EOL><INDENT>yy = int(yy)<EOL>dd = int(dd)<EOL>thh = int(thh)<EOL>tmm = int(tmm)<EOL>tss = int(tss)<EOL><DEDENT>except ValueError:<EOL><INDENT>return None<EOL><DEDENT>tzoffset = None<EOL>tz = tz.upper()<EOL>if tz in _timezones:<EOL><INDENT>tzoffset = _timezones[tz]<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>tzoffset = int(tz)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if tzoffset:<EOL><INDENT>if tzoffset < <NUM_LIT:0>:<EOL><INDENT>tzsign = -<NUM_LIT:1><EOL>tzoffset = -tzoffset<EOL><DEDENT>else:<EOL><INDENT>tzsign = <NUM_LIT:1><EOL><DEDENT>tzoffset = tzsign * ( (tzoffset//<NUM_LIT:100>)*<NUM_LIT> + (tzoffset % <NUM_LIT:100>)*<NUM_LIT>)<EOL><DEDENT>return (yy, mm, dd, thh, tmm, tss, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>, tzoffset)<EOL>

Convert a date string to a time tuple.

    Accounts for military timezones.


t = parsedate_tz(data)<EOL>if t is None:<EOL><INDENT>return t<EOL><DEDENT>return t[:<NUM_LIT:9>]<EOL>


if data[<NUM_LIT:9>] is None:<EOL><INDENT>return time.mktime(data[:<NUM_LIT:8>] + (-<NUM_LIT:1>,))<EOL><DEDENT>else:<EOL><INDENT>t = time.mktime(data[:<NUM_LIT:8>] + (<NUM_LIT:0>,))<EOL>return t - data[<NUM_LIT:9>] - time.timezone<EOL><DEDENT>

Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp.


if timeval is None:<EOL><INDENT>timeval = time.time()<EOL><DEDENT>timeval = time.gmtime(timeval)<EOL>return "<STR_LIT>" % (<EOL>("<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>")[timeval[<NUM_LIT:6>]],<EOL>timeval[<NUM_LIT:2>],<EOL>("<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>")[timeval[<NUM_LIT:1>]-<NUM_LIT:1>],<EOL>timeval[<NUM_LIT:0>], timeval[<NUM_LIT:3>], timeval[<NUM_LIT:4>], timeval[<NUM_LIT:5>])<EOL>

Returns time format preferred for Internet standards.

    Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123

    According to RFC 1123, day and month names must always be in
    English.  If not for that, this code could use strftime().  It
    can't because strftime() honors the locale and could generate
    non-English names.


def __init__(self, fp, seekable = <NUM_LIT:1>):

if seekable == <NUM_LIT:1>:<EOL><INDENT>try:<EOL><INDENT>fp.tell()<EOL><DEDENT>except (AttributeError, IOError):<EOL><INDENT>seekable = <NUM_LIT:0><EOL><DEDENT><DEDENT>self.fp = fp<EOL>self.seekable = seekable<EOL>self.startofheaders = None<EOL>self.startofbody = None<EOL>if self.seekable:<EOL><INDENT>try:<EOL><INDENT>self.startofheaders = self.fp.tell()<EOL><DEDENT>except IOError:<EOL><INDENT>self.seekable = <NUM_LIT:0><EOL><DEDENT><DEDENT>self.readheaders()<EOL>if self.seekable:<EOL><INDENT>try:<EOL><INDENT>self.startofbody = self.fp.tell()<EOL><DEDENT>except IOError:<EOL><INDENT>self.seekable = <NUM_LIT:0><EOL><DEDENT><DEDENT>

Initialize the class instance and read the headers.


if not self.seekable:<EOL><INDENT>raise IOError("<STR_LIT>")<EOL><DEDENT>self.fp.seek(self.startofbody)<EOL>

Rewind the file to the start of the body (if seekable).


self.dict = {}<EOL>self.unixfrom = '<STR_LIT>'<EOL>self.headers = lst = []<EOL>self.status = '<STR_LIT>'<EOL>headerseen = "<STR_LIT>"<EOL>firstline = <NUM_LIT:1><EOL>startofline = unread = tell = None<EOL>if hasattr(self.fp, '<STR_LIT>'):<EOL><INDENT>unread = self.fp.unread<EOL><DEDENT>elif self.seekable:<EOL><INDENT>tell = self.fp.tell<EOL><DEDENT>while <NUM_LIT:1>:<EOL><INDENT>if tell:<EOL><INDENT>try:<EOL><INDENT>startofline = tell()<EOL><DEDENT>except IOError:<EOL><INDENT>startofline = tell = None<EOL>self.seekable = <NUM_LIT:0><EOL><DEDENT><DEDENT>line = self.fp.readline()<EOL>if not line:<EOL><INDENT>self.status = '<STR_LIT>'<EOL>break<EOL><DEDENT>if firstline and line.startswith('<STR_LIT>'):<EOL><INDENT>self.unixfrom = self.unixfrom + line<EOL>continue<EOL><DEDENT>firstline = <NUM_LIT:0><EOL>if headerseen and line[<NUM_LIT:0>] in '<STR_LIT>':<EOL><INDENT>lst.append(line)<EOL>x = (self.dict[headerseen] + "<STR_LIT>" + line.strip())<EOL>self.dict[headerseen] = x.strip()<EOL>continue<EOL><DEDENT>elif self.iscomment(line):<EOL><INDENT>continue<EOL><DEDENT>elif self.islast(line):<EOL><INDENT>break<EOL><DEDENT>headerseen = self.isheader(line)<EOL>if headerseen:<EOL><INDENT>lst.append(line)<EOL>self.dict[headerseen] = line[len(headerseen)+<NUM_LIT:1>:].strip()<EOL>continue<EOL><DEDENT>elif headerseen is not None:<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>if not self.dict:<EOL><INDENT>self.status = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>self.status = '<STR_LIT>'<EOL><DEDENT>if unread:<EOL><INDENT>unread(line)<EOL><DEDENT>elif tell:<EOL><INDENT>self.fp.seek(startofline)<EOL><DEDENT>else:<EOL><INDENT>self.status = self.status + '<STR_LIT>'<EOL><DEDENT>break<EOL><DEDENT><DEDENT>

Read header lines.

        Read header lines up to the entirely blank line that terminates them.
        The (normally blank) line that ends the headers is skipped, but not
        included in the returned list.  If a non-header line ends the headers,
        (which is an error), an attempt is made to backspace over it; it is
        never included in the returned list.

        The variable self.status is set to the empty string if all went well,
        otherwise it is an error message.  The variable self.headers is a
        completely uninterpreted list of lines contained in the header (so
        printing them will reproduce the header exactly as it appears in the
        file).


i = line.find('<STR_LIT::>')<EOL>if i > -<NUM_LIT:1>:<EOL><INDENT>return line[:i].lower()<EOL><DEDENT>return None<EOL>

Determine whether a given line is a legal header.

        This method should return the header name, suitably canonicalized.
        You may override this method in order to use Message parsing on tagged
        data in RFC 2822-like formats with special header formats.