pyficache


Namepyficache JSON
Version 2.4.0 PyPI version JSON
download
home_pagehttp://github.com/rocky/python-filecache
SummaryCache lines and file information which are generally Python programs
upload_time2025-01-16 00:31:02
maintainerNone
docs_urlNone
authorRocky Bernstein
requires_pythonNone
licenseGPL
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            |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 `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 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
-------

::
    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 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.

.. |License| image:: https://img.shields.io/pypi/l/pyficache.svg
.. _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/
.. |CircleCI| image:: https://dl.circleci.com/status-badge/img/gh/rocky/python-filecache/tree/master.svg?style=svg :target: https://dl.circleci.com/status-badge/redirect/gh/rocky/python-filecache/tree/master
.. |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




            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/rocky/python-filecache",
    "name": "pyficache",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Rocky Bernstein",
    "author_email": "rocky@gnu.org",
    "download_url": "https://files.pythonhosted.org/packages/61/97/72159ece19a5feec21a2629ad7e02bace110113d832fcd1c754cf24e72f8/pyficache-2.4.0.tar.gz",
    "platform": null,
    "description": "|CircleCI| |Pypi Installs| |License| |Supported Python Versions|\n\n|packagestatus|\n\nSynopsis\n--------\n\nThe *pyficache* module allows one to get any line from any file,\ncaching lines of the file on first access to the file. Although the\nfile may be any file, this package is more tailored to the case\nwhere the file is a Python script.\n\nHere, the file is parsed to determine statement bounderies,\nand a copies of the file syntax-highlighted are also saved.\n\nAlso saved is file information such as when the file was last modified\nand a SHA1 of the file. These are useful in determining if the file\nhas changed and verifying the contents of the file.\n\nBy caching contents, access is sped up when small small random sets of lines\nare read from a single file, in particular in a debugger to show\nsource lines.\n\nA file path can be remapped to another path. This is useful for\nexample when debugging remotely and the remote file path may be\ndifferent from the path on a local filesystem. In the `trepan3k <https://pypi.python.org/pypi/trepan3k>`_\nand `trepan2 <https://pypi.python.org/pypi/trepan2>`_ debuggers, *eval* and *exec* strings are\nsaved in a temporary file and then the pseudo-filename `<string>` is\nremapped to that temporary file name.\n\nSimilarly lines within a file can be remapped to other lines. This may\nbe useful in preprocessors or template systems where ones wants to\nmake a correspondence between the template file and the expanded\nPython file as seen in a tool using that underlying Python file such as\na debugger or profiler.\n\nSummary\n-------\n\n::\n    import pyficache\n    filename = __file__ # e.g. '/tmp/myprogram'\n    # return all lines of filename as an array\n    lines = pyficache.getlines(filename)\n\n    # return line 6, and reload all lines if the file has changed.\n    line = pyficache.getline(filename, 6, {'reload_on_change': True})\n\n    # return line 6 syntax highlighted via pygments using style 'colorful'\n    line = pyficache.getline(filename, 6, {'style': 'colorful'})\n\n    pyficache.remap_file('/tmp/myprogram.py', 'another-name')\n    line_from_alias = pyficache.getline('another-name', 6)\n\n    assert __file__, pyficache.remove_remap_file('another-name')\n\n    # another-name is no longer an alias for /tmp/myprogram\n    assert None, pyficache.remove_remap_file('another-name')\n\n    # Clear cache for __file__\n    pyficache.clear_file_cache(__file__)\n\n    # Clear all cached files.\n    pyficache.clear_file_cache()\n\n    # Check for modifications of all cached files.\n    pyficache.update_cache()\n\nCredits\n-------\n\nThis is a port of the my Ruby linecache_ module which in turn is based\non the Python linecache module.\n\nxdis_ provides the cool stuff to figure out the lines containing\nPython statements.\n\n.. |License| image:: https://img.shields.io/pypi/l/pyficache.svg\n.. _xdis: https://pypi.org/project/xdis/\n.. _linecache: https://rubygems.org/gems/linecache\n.. |Downloads| image:: https://img.shields.io/pypi/dm/pyficache.svg :target: https://travis-ci.org/rocky/python-filecache/\n.. |CircleCI| image:: https://dl.circleci.com/status-badge/img/gh/rocky/python-filecache/tree/master.svg?style=svg :target: https://dl.circleci.com/status-badge/redirect/gh/rocky/python-filecache/tree/master\n.. |Supported Python Versions| image:: https://img.shields.io/pypi/pyversions/pyficache.svg\n.. |Pypi Installs| image:: https://pepy.tech/badge/pyficache/month\n.. |packagestatus| image:: https://repology.org/badge/vertical-allrepos/python:pyficache.svg\n\n\n\n",
    "bugtrack_url": null,
    "license": "GPL",
    "summary": "Cache lines and file information which are generally Python programs",
    "version": "2.4.0",
    "project_urls": {
        "Homepage": "http://github.com/rocky/python-filecache"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "60b4e7b0cb21c894fe13bb0f027a137a9dedec415a6c20f8e5425ddfcfbfdf2a",
                "md5": "db8e7d4d5c03249032b0aea4f1e4336c",
                "sha256": "be376d8c4b9a9394214a49edd95a4f363a5029dc02c6e3457d715f95afdecbee"
            },
            "downloads": -1,
            "filename": "pyficache-2.4.0-py2-none-any.whl",
            "has_sig": false,
            "md5_digest": "db8e7d4d5c03249032b0aea4f1e4336c",
            "packagetype": "bdist_wheel",
            "python_version": "py2",
            "requires_python": null,
            "size": 33854,
            "upload_time": "2025-01-16T00:30:30",
            "upload_time_iso_8601": "2025-01-16T00:30:30.159918Z",
            "url": "https://files.pythonhosted.org/packages/60/b4/e7b0cb21c894fe13bb0f027a137a9dedec415a6c20f8e5425ddfcfbfdf2a/pyficache-2.4.0-py2-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "37b6acdbc40cdfc6f60e4ddabc6f78ee0d2077b5f7534fbbd00816fa854e3b33",
                "md5": "471b919054ce4a6b09e27e933bda3d85",
                "sha256": "6074ef4b004cd0474b3bed34480b3632d4415b5ed6ba2e3e400792858a87b55d"
            },
            "downloads": -1,
            "filename": "pyficache-2.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "471b919054ce4a6b09e27e933bda3d85",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 27325,
            "upload_time": "2025-01-16T00:30:32",
            "upload_time_iso_8601": "2025-01-16T00:30:32.605194Z",
            "url": "https://files.pythonhosted.org/packages/37/b6/acdbc40cdfc6f60e4ddabc6f78ee0d2077b5f7534fbbd00816fa854e3b33/pyficache-2.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "619772159ece19a5feec21a2629ad7e02bace110113d832fcd1c754cf24e72f8",
                "md5": "14ffe254634fe204c90eff2b7c095b9f",
                "sha256": "c3ce7b49b9d26a34c255a8b6a361e234f1ebb20d37eecc41de1e9ba58ba553d8"
            },
            "downloads": -1,
            "filename": "pyficache-2.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "14ffe254634fe204c90eff2b7c095b9f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 33583,
            "upload_time": "2025-01-16T00:31:02",
            "upload_time_iso_8601": "2025-01-16T00:31:02.225522Z",
            "url": "https://files.pythonhosted.org/packages/61/97/72159ece19a5feec21a2629ad7e02bace110113d832fcd1c754cf24e72f8/pyficache-2.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-16 00:31:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rocky",
    "github_project": "python-filecache",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "circle": true,
    "requirements": [],
    "tox": true,
    "lcname": "pyficache"
}
        
Elapsed time: 0.46521s