# Path: py3kwarn2to3/fixer_util.py
# def Name(name, prefix=None):
#     """Return a NAME leaf"""
#     return Leaf(token.NAME, name, prefix=prefix)


from .. import fixer_base
from ..fixer_util import Name
# Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.

"""Fixer that changes xrange(...) into range(...)."""

# Local imports


class FixXrange(fixer_base.BaseFix):

    BM_compatible = True
    PATTERN = """
              power<
                 (name='xrange') trailer< '(' args=any ')' >
              rest=any* >
              """

    def transform(self, node, results):
        name = results["name"]

# Path: py3kwarn2to3/fixer_util.py
# def Name(name, prefix=None):
#     """Return a NAME leaf"""
#     return Leaf(token.NAME, name, prefix=prefix)


# Path: py3kwarn2to3/fixes/fix_xrange.py
from .. import fixer_base
from ..fixer_util import Name

# Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.

"""Fixer that changes xrange(...) into range(...)."""

# Local imports


class FixXrange(fixer_base.BaseFix):

    BM_compatible = True
    PATTERN = """
              power<
                 (name='xrange') trailer< '(' args=any ')' >
              rest=any* >
              """

    def transform(self, node, results):
        name = results["name"]

        name.replace(Name(u"range", prefix=name.prefix))