Skip to content

rocky/python-filecache

Repository files navigation

CircleCI Pypi Installs License Supported Python Versions

packagestatus

Synopsis

The pyficache module allows one to get any line from any file, caching lines of the file on first access to the file. Although the file may be any file, this package is more tailored to the case where the file is a Python script.

Here, the file is parsed to determine statement bounderies, and a copies of the file syntax-highlighted are also saved.

Also saved is file information such as when the file was last modified and a SHA1 of the file. These are useful in determining if the file has changed and verifying the contents of the file.

By caching contents, access is sped up when small small random sets of lines are read from a single file, in particular in a debugger to show source lines.

A file path can be remapped to another path. This is useful for example when debugging remotely and the remote file path may be different from the path on a local filesystem. In the trepan3 and trepan2 debuggers, eval and exec strings are saved in a temporary file and then the pseudo-filename <string> is remapped to that temporary file name.

Similarly lines within a file can be remapped to other lines. This may be useful in preprocessors or template systems where ones wants to make a correspondence between the template file and the expanded Python file as seen in a tool using that underlying Python file such as a debugger or profiler.

Summary

Credits

This is a port of the my Ruby linecache module which in turn is based on the Python linecache module.

xdis provides the cool stuff to figure out the lines containing Python statements.

About

module for Python module for reading and caching lines. This may be useful for example in a debugger where the same lines are shown many times.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •