Metadata-Version: 2.4
Name: pyficache
Version: 2.5.0
Summary: Cache and colorize lines and file information which are generally Python program or Python Bytecode
Author-email: Rocky Bernstein <rocky@gnu.org>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://pypi.org/project/pyficache/
Project-URL: Downloads, https://github.com/rocky/python-filecache/releases
Keywords: Python debugger,Python bytecode
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Programming Language :: Python :: 3.0
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: PyPy
Description-Content-Type: text/x-rst
License-File: COPYING
Requires-Dist: xdis<6.2.0,>=6.0.0
Requires-Dist: term-background>=1.0.2
Provides-Extra: dev
Requires-Dist: flake8; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Dynamic: license-file

|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 boundaries,
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 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 `trepan3k <https://pypi.python.org/pypi/trepan3k>`_
and `trepan2 <https://pypi.python.org/pypi/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 one 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
-------

.. code:: python

    import pyficache
    filename = __file__ # e.g. '/tmp/myprogram'
     # return all lines of filename as an array
    lines = pyficache.getlines(filename)

     # return line 6, and reload all lines if the file has changed.
    line = pyficache.getline(filename, 6, {'reload_on_change': True})

    # return line 6 syntax highlighted via pygments using style 'colorful'
    line = pyficache.getline(filename, 6, {'style': 'colorful'})

    pyficache.remap_file('/tmp/myprogram.py', 'another-name')
    line_from_alias = pyficache.getline('another-name', 6)

    assert __file__, pyficache.remove_remap_file('another-name')

    # another-name is no longer an alias for /tmp/myprogram
    assert None, pyficache.remove_remap_file('another-name')

    # Clear cache for __file__
     pyficache.clear_file_cache(__file__)

    # Clear all cached files.
    pyficache.clear_file_cache()

    # Check for modifications of all cached files.
    pyficache.update_cache()

Credits
-------

This is a port of 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.

.. |License| image:: https://img.shields.io/pypi/l/pyficache.svg
    :target: https://pypi.python.org/pypi/pyficache
    :alt: License
.. _xdis: https://pypi.org/project/xdis/
.. _linecache: https://rubygems.org/gems/linecache

.. |Downloads| image:: https://img.shields.io/pypi/dm/pyficache.svg
   :target: https://travis-ci.org/rocky/python-filecache/
.. |Supported Python Versions| image:: https://img.shields.io/pypi/pyversions/pyficache.svg
.. |Pypi Installs| image:: https://pepy.tech/badge/pyficache/month
.. |packagestatus| image:: https://repology.org/badge/vertical-allrepos/python:pyficache.svg
		 :target: https://repology.org/project/python:pyficache/versions
