Skip to content

ImportRecord

Handsdown API Index / Handsdown / AST Parser / Node Records / ImportRecord

Auto-generated documentation for handsdown.ast_parser.node_records.import_record module.

ImportRecord

Show source in import_record.py:12

Wrapper for an ast.Import and ast.ImportFrom nodes.

Arguments

  • node - AST node.
  • alias - AST node with import alias.

Signature

class ImportRecord(NodeRecord):
    def __init__(self, node: ASTImport, alias: ast.alias) -> None:
        ...

See also

ImportRecord().get_import_string

Show source in import_record.py:32

Get import string from a node.

Returns

An absolute import string.

Signature

def get_import_string(self) -> ImportString:
    ...

See also

ImportRecord().match

Show source in import_record.py:55

Check if name matches or stats with a local name.

Examples

import_node = ast.parse('from my_module import Name as LocalName')
import_record = ImportRecord(import_node)

import_record.match('LocalName')
True

import_record.match('LocalName.child')
True

import_record.match('OtherName')
False

import_record.match('LocalNameOther')
False

Returns

True if name is imported object itself on one of his children.

Signature

def match(self, name: str) -> Optional[ImportString]:
    ...

See also