Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)
Return an import statement in the form:
from package import name_leafs

        def FromImport(package_name, name_leafs):
    """ Return an import statement in the form:
        from package import name_leafs"""
    # XXX: May not handle dotted imports properly (eg, package_name='foo.bar')
    #assert package_name == '.' or '.' not in package_name, "FromImport has "\
    #       "not been tested with dotted package names -- use at your own "\
    #       "peril!"

    for leaf in name_leafs:
        # Pull the leaves out of their old tree
        leaf.remove()

    children = [Leaf(token.NAME, u"from"),
                Leaf(token.NAME, package_name, prefix=u" "),
                Leaf(token.NAME, u"import", prefix=u" "),
                Node(syms.import_as_names, name_leafs)]
    imp = Node(syms.import_from, children)
    return imp
        


src/p/y/py3kwarn-HEAD/py3kwarn2to3/fixes/fix_urllib.py   py3kwarn(Download)
# Local imports
from py3kwarn2to3.fixes.fix_imports import alternates, FixImports
from py3kwarn2to3.fixer_util import (Name, Comma, FromImport, Newline,
                                find_indentation, Node, syms)
 
                    names.append(Comma())
                names.extend(handle_name(elts[-1], pref))
                new = FromImport(module, names)
                if not first or node.parent.prefix.endswith(indentation):
                    new.prefix = indentation

src/p/y/py3kwarn-0.4.4/py3kwarn2to3/fixes/fix_urllib.py   py3kwarn(Download)
# Local imports
from py3kwarn2to3.fixes.fix_imports import alternates, FixImports
from py3kwarn2to3.fixer_util import (Name, Comma, FromImport, Newline,
                                find_indentation, Node, syms)
 
                    names.append(Comma())
                names.extend(handle_name(elts[-1], pref))
                new = FromImport(module, names)
                if not first or node.parent.prefix.endswith(indentation):
                    new.prefix = indentation