import re


def get_imported_name(module):
    """Return only imported name from pyflakes full module path.

    Example:
    - `a.b.Foo` -> `Foo`
    - `a as b` -> b

    """
    if '.' in module:
        name = module.split('.')[-1]
    elif re.search(r'\bas\b', module):
        name = re.split(r'\bas\b', module)[-1]
    else:
        name = module
    # str() to force python 2 to not use unicode
    return str(name.strip())