Skip to main content

cjm-psl-utils

This file will become your README and also the index of your documentation.

Install

pip install cjm_psl_utils

How to use

get_source_code

from cjm_psl_utils.core import get_source_code
get_source_code(get_source_code, markdown=True)
def get_source_code(obj:object, # The object whose source code you want to retrieve.
                    markdown=False, # Return the source code formatted as markdown
                    remove_documentation=False): # Remove docstrings and comments
    """
    Returns the source code of an object, with an optional markdown formatting.
    """
    # Get the source code of the object
    source = inspect.getsource(obj)
    
    # If the remove_documentation flag is set to True, remove docstrings and comments
    if remove_documentation:
        in_docstring = False
        lines = source.split('\n')
        source = ''
        # Remove docstrings
        for line in lines:
            if line.strip().startswith(('\'\'\'', '\"\"\"')):
                in_docstring = not in_docstring
            elif not in_docstring:
                source += line + '\n'
        # Remove comments
        source = '\n'.join([line for line in source.split('\n')
                            if not line.strip().startswith(('#'))])
        source = source.replace('\n\n', '\n')

    if markdown:
        # Format the source code as markdown code block
        source = f"```python\n{source}\n```"

        # Check if the code is running in Jupyter Notebook
        try:
            get_ipython
            from IPython.display import Markdown
            # Format the source code as an IPython Markdown object
            source = Markdown(source)
        except NameError:
            # If not in Jupyter Notebook, do nothing
            pass
    # Return the formatted source code
    return source

file_extract

from cjm_psl_utils.core import file_extract
from pathlib import Path
fname = "../images/images.zip"
dest = Path("./images")
print(dest.exists())
file_extract(fname, dest)
print(dest.exists())
print(list(os.walk(dest))[0][2])
False
True
['cat.jpg']

Metadata

Release files for cjm-psl-utils 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cjm-psl-utils 0.0.4
File Size Uploaded Provenance
cjm-psl-utils-0.0.4.tar.gz 5.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cjm-psl-utils 0.0.4
File Interpreter ABI Platform
cjm_psl_utils-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / cjm-psl-utils-0.0.4.tar.gz

Download URL cjm-psl-utils-0.0.4.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
eec200f9f2ccfe4e2df01e0f22bd8483afde77377130bd8282e628c6762fe755
BLAKE2b-256 checksum
How to use checksums
0a69a01b731b34adce7613dfbc6cac4ed031667fe0fa6d0dd7a0e06dfb7486f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Release files / cjm_psl_utils-0.0.4-py3-none-any.whl

Download URL cjm_psl_utils-0.0.4-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b1d291d43fa5234b8664a069eb802e91d1aaa40424a814c2d6a2ce15288136d
BLAKE2b-256 checksum
How to use checksums
cc90d2a82488979d96a0bf783c7e51d75a37ce5c06f1641b4b073cf6d9a164b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Security for cjm-psl-utils 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page