Tracking of scopes
==================

We have an AST walker that keeps track of scopes and names used in
expressions

    >>> from findimports import find_imports_and_track_names

    >>> with open('marmalade.py', 'w') as f: _ = f.write('''
    ... import os, shutil
    ... def example1():
    ...     import sys, gc
    ...     my_name_is = sys.argv[0]
    ... def example2():
    ...     import sys
    ...     my_whereabouts_are = os.path.abspath(os.getcwd())
    ... def example3():
    ...     import gc
    ...     gc.collect()
    ... ''')

    >>> imports, unused_names = find_imports_and_track_names('marmalade.py')
    >>> for imp in imports:
    ...     print(imp)
    ImportInfo('os', 'marmalade.py', 2, None)
    ImportInfo('shutil', 'marmalade.py', 2, None)
    ImportInfo('sys', 'marmalade.py', 4, None)
    ImportInfo('gc', 'marmalade.py', 4, None)
    ImportInfo('sys', 'marmalade.py', 7, None)
    ImportInfo('gc', 'marmalade.py', 10, None)

    >>> for name in unused_names:
    ...     print(name)
    ImportInfo('shutil', 'marmalade.py', 2, None)
    ImportInfo('gc', 'marmalade.py', 4, None)
    ImportInfo('sys', 'marmalade.py', 7, None)

