# Path: py3kwarn2to3/refactor.py
# def refactor(self, items, write=False, doctests_only=False):
#     """Refactor a list of files and directories."""
# 
#     for dir_or_file in items:
#         if os.path.isdir(dir_or_file):
#             self.refactor_dir(dir_or_file, write, doctests_only)
#         else:
#             self.refactor_file(dir_or_file, write, doctests_only)
# 
# Path: py3kwarn2to3/pygram.py
# _GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), "Grammar.txt")
# _PATTERN_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__),
#                                      "PatternGrammar.txt")
# class Symbols(object):
#     def __init__(self, grammar):
# 
# Path: py3kwarn2to3/fixer_base.py
# class BaseFix(object):
# class ConditionalFix(BaseFix):
#     PATTERN = None  # Most subclasses should override with a string literal
#             PC = PatternCompiler()
#     def __init__(self, options, log):
#     def compile_pattern(self):
#     def set_filename(self, filename):
#     def match(self, node):
#     def transform(self, node, results):
#     def new_name(self, template=u"xxx_todo_changeme"):
#     def log_message(self, message):
#     def cannot_convert(self, node, reason=None):
#     def warning(self, node, reason):
#     def start_tree(self, tree, filename):
#     def finish_tree(self, tree, filename):
#     def start_tree(self, *args):
#     def should_skip(self, node):


import sys
import os
import codecs
import tempfile
import shutil
    import unittest2 as unittest
    import unittest
    from StringIO import StringIO
    from io import StringIO
from py3kwarn2to3 import refactor, pygram, fixer_base
from py3kwarn2to3.pgen2 import token
        from myfixes.fix_first import FixFirst
        from myfixes.fix_last import FixLast
        from myfixes.fix_parrot import FixParrot
        from myfixes.fix_preorder import FixPreorder
        from myfixes.fix_explicit import FixExplicit
        self.assertEqual(run(inp), fs(("print_function",)))
        inp = "from __future__ import (generators, print_function)"
        self.assertEqual(run(inp), fs(("generators", "print_function")))
        inp = "from __future__ import (generators, nested_scopes)"
        self.assertEqual(run(inp), fs(("generators", "nested_scopes")))
        inp = """from __future__ import generators
from __future__ import print_function"""
        self.assertEqual(run(inp), fs(("generators", "print_function")))
        invalid = ("from",
                   "from 4",
                   "from x",
                   "from x 5",
                   "from x im",
                   "from x import",
                   "from x import 4",
                   )
        for inp in invalid:
            self.assertEqual(run(inp), empty)
        inp = "'docstring'\nfrom __future__ import print_function"
        self.assertEqual(run(inp), fs(("print_function",)))
        inp = "'docstring'\n'somng'\nfrom __future__ import print_function"
        self.assertEqual(run(inp), empty)
        inp = "# comment\nfrom __future__ import print_function"
        self.assertEqual(run(inp), fs(("print_function",)))
        inp = "# comment\n'doc'\nfrom __future__ import print_function"
        self.assertEqual(run(inp), fs(("print_function",)))
        inp = "class x: pass\nfrom __future__ import print_function"
        self.assertEqual(run(inp), empty)

    def test_get_headnode_dict(self):

# Path: py3kwarn2to3/refactor.py
# def refactor(self, items, write=False, doctests_only=False):
#     """Refactor a list of files and directories."""
# 
#     for dir_or_file in items:
#         if os.path.isdir(dir_or_file):
#             self.refactor_dir(dir_or_file, write, doctests_only)
#         else:
#             self.refactor_file(dir_or_file, write, doctests_only)
# 
# Path: py3kwarn2to3/pygram.py
# _GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), "Grammar.txt")
# _PATTERN_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__),
#                                      "PatternGrammar.txt")
# class Symbols(object):
#     def __init__(self, grammar):
# 
# Path: py3kwarn2to3/fixer_base.py
# class BaseFix(object):
# class ConditionalFix(BaseFix):
#     PATTERN = None  # Most subclasses should override with a string literal
#             PC = PatternCompiler()
#     def __init__(self, options, log):
#     def compile_pattern(self):
#     def set_filename(self, filename):
#     def match(self, node):
#     def transform(self, node, results):
#     def new_name(self, template=u"xxx_todo_changeme"):
#     def log_message(self, message):
#     def cannot_convert(self, node, reason=None):
#     def warning(self, node, reason):
#     def start_tree(self, tree, filename):
#     def finish_tree(self, tree, filename):
#     def start_tree(self, *args):
#     def should_skip(self, node):


# Path: py3kwarn2to3/tests/test_refactor.py
import sys
import os
import codecs
import tempfile
import shutil
    import unittest2 as unittest
    import unittest
    from StringIO import StringIO
    from io import StringIO
from py3kwarn2to3 import refactor, pygram, fixer_base
from py3kwarn2to3.pgen2 import token
        from myfixes.fix_first import FixFirst
        from myfixes.fix_last import FixLast
        from myfixes.fix_parrot import FixParrot
        from myfixes.fix_preorder import FixPreorder
        from myfixes.fix_explicit import FixExplicit

        self.assertEqual(run(inp), fs(("print_function",)))
        inp = "from __future__ import (generators, print_function)"
        self.assertEqual(run(inp), fs(("generators", "print_function")))
        inp = "from __future__ import (generators, nested_scopes)"
        self.assertEqual(run(inp), fs(("generators", "nested_scopes")))
        inp = """from __future__ import generators
from __future__ import print_function"""
        self.assertEqual(run(inp), fs(("generators", "print_function")))
        invalid = ("from",
                   "from 4",
                   "from x",
                   "from x 5",
                   "from x im",
                   "from x import",
                   "from x import 4",
                   )
        for inp in invalid:
            self.assertEqual(run(inp), empty)
        inp = "'docstring'\nfrom __future__ import print_function"
        self.assertEqual(run(inp), fs(("print_function",)))
        inp = "'docstring'\n'somng'\nfrom __future__ import print_function"
        self.assertEqual(run(inp), empty)
        inp = "# comment\nfrom __future__ import print_function"
        self.assertEqual(run(inp), fs(("print_function",)))
        inp = "# comment\n'doc'\nfrom __future__ import print_function"
        self.assertEqual(run(inp), fs(("print_function",)))
        inp = "class x: pass\nfrom __future__ import print_function"
        self.assertEqual(run(inp), empty)

    def test_get_headnode_dict(self):

        class NoneFix(fixer_base.BaseFix):