# Path: py3kwarn2to3/pgen2/driver.py
# class Driver(object):
#     def __init__(self, grammar, convert=None, logger=None):
#     def parse_tokens(self, tokens, debug=False):
#     def parse_stream_raw(self, stream, debug=False):
#     def parse_stream(self, stream, debug=False):
#     def parse_file(self, filename, encoding=None, debug=False):
#     def parse_string(self, text, debug=False):
# def load_grammar(gt="Grammar.txt", gp=None,
#                  save=True, force=False, logger=None):
# def _newer(a, b):
# 
# Path: py3kwarn2to3/pgen2/tokenize.py
# def tokenize(readline, tokeneater=printtoken):
#     """
#     The tokenize() function accepts two parameters: one representing the
#     input stream, and one providing an output mechanism for tokenize().
# 
#     The first parameter, readline, must be a callable object which provides
#     the same interface as the readline() method of built-in file objects.
#     Each call to the function should return one line of input as a string.
# 
#     The second parameter, tokeneater, must also be a callable object. It is
#     called once for each token, with five arguments, corresponding to the
#     tuples generated by generate_tokens().
#     """
#     try:
#         tokenize_loop(readline, tokeneater)
#     except StopTokenizing:
#         pass
# 
# Path: py3kwarn2to3/fixer_util.py
# def find_root(node):
#     """Find the top level namespace."""
#     # Scamper up to the top level namespace
#     while node.type != syms.file_input:
#         assert node.parent, "Tree is insane! root found before "\
#                            "file_input node was found."
#         node = node.parent
#     return node


import os
import sys
import logging
import operator
import collections
    import codecs
            import multiprocessing
    from StringIO import StringIO
    from io import StringIO
from itertools import chain
from .pgen2 import driver, parse, tokenize, token
from .fixer_util import find_root
from . import pytree, pygram
from . import btm_matcher as bm


def get_fixers_from_package(pkg_name):
    """
    Return the fully qualified names for fixers in the package pkg_name.
    """
    return [pkg_name + "." + fix_name
            for fix_name in get_all_fix_names(pkg_name, False)]

def _identity(obj):
    return obj

if sys.version_info < (3, 0):
    _open_with_encoding = codecs.open
    # codecs.open doesn't translate newlines sadly.
    def _from_system_newlines(input):
        return input.replace(u"\r\n", u"\n")
    def _to_system_newlines(input):
        if os.linesep != "\n":
            return input.replace(u"\n", os.linesep)
        else:
            return input
else:
    _open_with_encoding = open
    _from_system_newlines = _identity
    _to_system_newlines = _identity


def _detect_future_features(source):
    have_docstring = False

# Path: py3kwarn2to3/pgen2/driver.py
# class Driver(object):
#     def __init__(self, grammar, convert=None, logger=None):
#     def parse_tokens(self, tokens, debug=False):
#     def parse_stream_raw(self, stream, debug=False):
#     def parse_stream(self, stream, debug=False):
#     def parse_file(self, filename, encoding=None, debug=False):
#     def parse_string(self, text, debug=False):
# def load_grammar(gt="Grammar.txt", gp=None,
#                  save=True, force=False, logger=None):
# def _newer(a, b):
# 
# Path: py3kwarn2to3/pgen2/tokenize.py
# def tokenize(readline, tokeneater=printtoken):
#     """
#     The tokenize() function accepts two parameters: one representing the
#     input stream, and one providing an output mechanism for tokenize().
# 
#     The first parameter, readline, must be a callable object which provides
#     the same interface as the readline() method of built-in file objects.
#     Each call to the function should return one line of input as a string.
# 
#     The second parameter, tokeneater, must also be a callable object. It is
#     called once for each token, with five arguments, corresponding to the
#     tuples generated by generate_tokens().
#     """
#     try:
#         tokenize_loop(readline, tokeneater)
#     except StopTokenizing:
#         pass
# 
# Path: py3kwarn2to3/fixer_util.py
# def find_root(node):
#     """Find the top level namespace."""
#     # Scamper up to the top level namespace
#     while node.type != syms.file_input:
#         assert node.parent, "Tree is insane! root found before "\
#                            "file_input node was found."
#         node = node.parent
#     return node


# Path: py3kwarn2to3/refactor.py
import os
import sys
import logging
import operator
import collections
    import codecs
            import multiprocessing
    from StringIO import StringIO
    from io import StringIO
from itertools import chain
from .pgen2 import driver, parse, tokenize, token
from .fixer_util import find_root
from . import pytree, pygram
from . import btm_matcher as bm



def get_fixers_from_package(pkg_name):
    """
    Return the fully qualified names for fixers in the package pkg_name.
    """
    return [pkg_name + "." + fix_name
            for fix_name in get_all_fix_names(pkg_name, False)]

def _identity(obj):
    return obj

if sys.version_info < (3, 0):
    _open_with_encoding = codecs.open
    # codecs.open doesn't translate newlines sadly.
    def _from_system_newlines(input):
        return input.replace(u"\r\n", u"\n")
    def _to_system_newlines(input):
        if os.linesep != "\n":
            return input.replace(u"\n", os.linesep)
        else:
            return input
else:
    _open_with_encoding = open
    _from_system_newlines = _identity
    _to_system_newlines = _identity


def _detect_future_features(source):
    have_docstring = False

    gen = tokenize.generate_tokens(StringIO(source).readline)