Skip to main content

Cache and colorize lines and file information which are generally Python program or Python Bytecode

Project description

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyficache-2.6.0.tar.gz (40.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyficache-2.6.0-py314-none-any.whl (35.3 kB view details)

Uploaded Python 3.14

pyficache-2.6.0-py313-none-any.whl (35.3 kB view details)

Uploaded Python 3.13

pyficache-2.6.0-py312-none-any.whl (35.3 kB view details)

Uploaded Python 3.12

pyficache-2.6.0-py311-none-any.whl (35.3 kB view details)

Uploaded Python 3.11

pyficache-2.6.0-py310-none-any.whl (40.3 kB view details)

Uploaded Python 3.10

pyficache-2.6.0-py39-none-any.whl (40.3 kB view details)

Uploaded Python 3.9

pyficache-2.6.0-py38-none-any.whl (40.3 kB view details)

Uploaded Python 3.8

pyficache-2.6.0-py37-none-any.whl (40.2 kB view details)

Uploaded Python 3.7

pyficache-2.6.0-py36-none-any.whl (40.3 kB view details)

Uploaded Python 3.6

File details

Details for the file pyficache-2.6.0.tar.gz.

File metadata

  • Download URL: pyficache-2.6.0.tar.gz
  • Upload date:
  • Size: 40.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pyficache-2.6.0.tar.gz
Algorithm Hash digest
SHA256 4534639b115cd87c6a739890f47b9140c50cde03f42356f8704701212667f9f6
MD5 9b3a7e55e636abdba6c0252d2843edea
BLAKE2b-256 50fdd067e47cbd23b70926eca03c6b48156ea65e5b94b6c45ca492fabced30a0

See more details on using hashes here.

File details

Details for the file pyficache-2.6.0-py314-none-any.whl.

File metadata

  • Download URL: pyficache-2.6.0-py314-none-any.whl
  • Upload date:
  • Size: 35.3 kB
  • Tags: Python 3.14
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pyficache-2.6.0-py314-none-any.whl
Algorithm Hash digest
SHA256 da514d1276cc59dd04631248370702eaf7d489b0d682e07fcbce66fec299dd07
MD5 bb57b721e4c3c656fb003d4fba6f498f
BLAKE2b-256 5ca940173977d55281fd836807a0c1d7bce760f9255fd9c1523310191d5b7f0e

See more details on using hashes here.

File details

Details for the file pyficache-2.6.0-py313-none-any.whl.

File metadata

  • Download URL: pyficache-2.6.0-py313-none-any.whl
  • Upload date:
  • Size: 35.3 kB
  • Tags: Python 3.13
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pyficache-2.6.0-py313-none-any.whl
Algorithm Hash digest
SHA256 e612545e35fef58a3bb4ad849a72338e5bf16f6cf7afa327bd425d1038e714b0
MD5 5edabe27defa9f27bd9653bc00103f0c
BLAKE2b-256 f85e8921796e1074b76a342629a56638b2d7d2522c684d24518e23dc2cefe624

See more details on using hashes here.

File details

Details for the file pyficache-2.6.0-py312-none-any.whl.

File metadata

  • Download URL: pyficache-2.6.0-py312-none-any.whl
  • Upload date:
  • Size: 35.3 kB
  • Tags: Python 3.12
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pyficache-2.6.0-py312-none-any.whl
Algorithm Hash digest
SHA256 1da3db4f1495afcfc1bccbf407bb0973a88b9dd375ec81eb3602322177274be8
MD5 e8bf9eeae8066f7827d14f04cf843210
BLAKE2b-256 4603935413980994f30cf07627a88900fba98cdcdbcfd226585636439680b0b1

See more details on using hashes here.

File details

Details for the file pyficache-2.6.0-py311-none-any.whl.

File metadata

  • Download URL: pyficache-2.6.0-py311-none-any.whl
  • Upload date:
  • Size: 35.3 kB
  • Tags: Python 3.11
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pyficache-2.6.0-py311-none-any.whl
Algorithm Hash digest
SHA256 94f720edc31146f6c64c4d43919e85e30ef896861926fe4fdde479755bad44ae
MD5 28ef1de27cba3bf7d0b09e172971e756
BLAKE2b-256 541ca824cffda36c7fd2be526ea0cf0c99c20ca1477a4b19688b4eed014e970b

See more details on using hashes here.

File details

Details for the file pyficache-2.6.0-py310-none-any.whl.

File metadata

  • Download URL: pyficache-2.6.0-py310-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3.10
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pyficache-2.6.0-py310-none-any.whl
Algorithm Hash digest
SHA256 ea90f129e8c6c615aadaa153df1e4fca3d8cc5f5b8dd05d5782ce766af8ccce3
MD5 a02982a9a5ac36ed1708708d66fced87
BLAKE2b-256 1a7bccb0216357a0833f58a4a2f4ac219626a4c5df9b786bb80c5ade9bb9f0de

See more details on using hashes here.

File details

Details for the file pyficache-2.6.0-py39-none-any.whl.

File metadata

  • Download URL: pyficache-2.6.0-py39-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pyficache-2.6.0-py39-none-any.whl
Algorithm Hash digest
SHA256 d16f090c8d0c79e8841558f1f0cc3849b58c1c058b39ce12895bb6f2bf44c813
MD5 6514dba67b0a064e87091c5da13532e6
BLAKE2b-256 62d00e748fd4b3269cae3fd46a858f91e69c70b0e7d9b5752b44c0be74fa86b4

See more details on using hashes here.

File details

Details for the file pyficache-2.6.0-py38-none-any.whl.

File metadata

  • Download URL: pyficache-2.6.0-py38-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pyficache-2.6.0-py38-none-any.whl
Algorithm Hash digest
SHA256 3d5826e210d19ac50cb91ba2a91ce4214f118f0ce884d8d940af1a1ee99233e3
MD5 769efdfe7f890cdd8d20cb8bcd0bc7d8
BLAKE2b-256 73d9e481c89e60566f01dcd004a1e51513de7f2126935d3c0106701fb0003328

See more details on using hashes here.

File details

Details for the file pyficache-2.6.0-py37-none-any.whl.

File metadata

  • Download URL: pyficache-2.6.0-py37-none-any.whl
  • Upload date:
  • Size: 40.2 kB
  • Tags: Python 3.7
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pyficache-2.6.0-py37-none-any.whl
Algorithm Hash digest
SHA256 504a1ca12282da48a6c55ea0f9bef22b291f86106282f88056fc67bd5a2dbdf5
MD5 4d1199167caa3ccbbf1c3185d362b6b1
BLAKE2b-256 ceb89a9b849acf7bff409e59c61cbbc0191d3fd1cadbb3bbf2852a47ea256b4b

See more details on using hashes here.

File details

Details for the file pyficache-2.6.0-py36-none-any.whl.

File metadata

  • Download URL: pyficache-2.6.0-py36-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pyficache-2.6.0-py36-none-any.whl
Algorithm Hash digest
SHA256 e3bcb7100d2b85791997a6f4c29135bf6d63fa67268a562a1b5f7839e287a883
MD5 70b639b110a4741caf8f8674f103be4f
BLAKE2b-256 28fdcfaaa4d02f5a4990b581a2d1e806c62c61ed6bc34ab6212dc7fc1fa056bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page