Graph cache
===========

Parsing a large source tree can take a while

    >>> from findimports import ModuleGraph
    >>> graph = ModuleGraph()
    >>> graph.parsePathname(sample_tree)
    >>> 'box.cat' in graph.modules
    True

we can save a cache of all the information

    >>> graph.writeCache('sample.importcache')

and load it later

    >>> newgraph = ModuleGraph()
    >>> 'box.cat' in newgraph.modules
    False
    >>> newgraph.readCache('sample.importcache')
    >>> 'box.cat' in newgraph.modules
    True

If you pass a filename that ends in '.importcache' on the command line,
it'll get loaded

    >>> newgraph = ModuleGraph()
    >>> 'box.cat' in newgraph.modules
    False
    >>> newgraph.parsePathname('sample.importcache')
    >>> 'box.cat' in newgraph.modules
    True

This is hooked up to the --write-cache command-line argument:

    >>> import os
    >>> os.unlink('sample.importcache')

    >>> from findimports import main
    >>> exitcode = main(['findimports', '--write-cache=sample.importcache', sample_tree, '-pN'])
    apple:
    <BLANKLINE>
    box:
      decoy
    decoy:
    <BLANKLINE>
    orange:
    <BLANKLINE>

    >>> exitcode = main(['findimports', 'sample.importcache', '-p'])
    apple:
      os
      sys
    box:
      decoy
      gc
    decoy:
    <BLANKLINE>
    orange:
      gc

