Пример #1
0
 def visit_from(self, node, parent):
     """visit a From node by returning a fresh instance of it"""
     names = [(alias.name, alias.asname) for alias in node.names]
     newnode = new.From(node.module or '', names, node.level or None)
     _set_infos(node, newnode, parent)
     # store From names to add them to locals after building
     self._from_nodes.append(newnode)
     return newnode
Пример #2
0
def transform_flask_from_long(node):
    '''Translates a flask.ext.wtf from-style import into a non-magical import.

    Translates:
        from flask.ext.wtf import Form
        from flask.ext.admin.model import InlineFormAdmin
    Into:
        from flask_wtf import Form
        from flask_admin.model import InlineFormAdmin

    '''
    actual_module_name = make_non_magical_flask_import(node.modname)
    new_node = nodes.From(actual_module_name, node.names, node.level)
    copy_node_info(node, new_node)
    mark_transformed(new_node)
    return new_node