Skip to main content

Just a lightweight development kit.

Project description

PyPI

justsdk

cat

This is a collection of my commonly used functions that I figured would be nice to have in a library.

Installation

pip install justsdk

or visit #history for legacy versions.

Usage

Get started by importing the package:

import justsdk

1. Colored Print

*from color_print.py

Print colored messages to the console with optional timestamps.
Simple as that, expected output: [MESSAGE_TYPE] YOUR_MESSAGE_HERE

screenshot

1.1. Convenience Functions

  • Most of the time, you’ll use the convenience functions::

    justsdk.print_success(
        message="YOUR_MESSAGE_HERE",
        newline_before=False,  # Add a newline before [MESSAGE_TYPE]
        newline_after=False,   # Add a newline after [MESSAGE_TYPE]
        file=None,             # Print to a specific file (default: sys.stdout)
        show_timestamp=False
    )
    
  • Available functions:

    • print_success() — Green
    • print_warning() — Yellow
    • print_error() — Red
    • print_info() — Magenta
    • print_debug() — Cyan

1.2. Initiating ColorPrinter Object

  • Else, you can have more control by creating an instance:

    from justsdk import ColorPrinter
    
    
    printer = ColorPrinter(
        file=None,
        use_color=True,
        show_timestamp=False,  # Show timestamp in each message (based on your timezone)
        quiet=False
    )
    printer.success("YOUR_MESSAGE_HERE")
    

2. File Utilities

*from file_utils.py

Handy functions for reading, writing, and pretty-printing files in JSON/YAML formats (and others treated as plain text)

2.1. Reading Files

  • Read a single file (auto-detects JSON/YAML/text):

    justsdk.read_file(
        file_path="YOUR_FILE_PATH_HERE",
        encoding="utf-8",
        use_orjson=True
    )
    
  • Returns the parsed data (dict/list for JSON/YAML, str for text).

  • Optional arguments:

    • encoding="utf-8" — File encoding
    • use_orjson=True — Use orjson for JSON files (just faster & better)

2.2. Writing Files

  • Write data to a file (auto-detects JSON/YAML/text):

    justsdk.write_file(
        data={"a": 1, "b": 2},
        file_path="YOUR_OUTPUT.json",
        indent=2,            # Indentation level (JSON only)
        sort_keys=True,      # Sort dictionary keys
        use_orjson=True,
        encoding="utf-8",
        ensure_ascii=False,
        atomic=False         # Atomic write (safu for critical data)
    )
    
  • Creates parent directories if needed.

  • Returns True on success, else False.

  • Raises ValueError if data is None.

2.3. Pretty-Print Data

  • Print data in JSON or YAML format (optionally colorized):

    justsdk.print_data(
        data={"a": 1, "b": 2},
        data_type="json",  # or "yaml", "yml"
        indent=2,
        sort_keys=False,
        use_orjson=True,
        colorize=False
    )
    
  • If colorize=True, uses pygments for syntax highlighting.

2.4. Batch Operations

  • Read multiple files at once:

    justsdk.read_files(["a.json", "b.yaml"])
    # Returns: {Path("a.json"): {...}, Path("b.yaml"): {...}}
    
    • dict mapping paths to parsed data
  • Write multiple files at once:

    justsdk.write_files({
        "a.json": {"x": 1},
        "b.yaml": {"y": 2}
    })
    # Returns: {Path("a.json"): True, Path("b.yaml"): True}
    
    • dict mapping paths to ops status (True/False)

License

This project is under the MIT License — see the LICENSE file for details.

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

justsdk-2.4.1.tar.gz (127.0 kB view details)

Uploaded Source

Built Distribution

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

justsdk-2.4.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file justsdk-2.4.1.tar.gz.

File metadata

  • Download URL: justsdk-2.4.1.tar.gz
  • Upload date:
  • Size: 127.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for justsdk-2.4.1.tar.gz
Algorithm Hash digest
SHA256 082e43607dc521896dfe443ff47505bf86dda2d3277353bf2e9b282019acae0d
MD5 2a4b32282d22fe1647a5d2854c6dcdde
BLAKE2b-256 19056d33d25ddd02e691fa4b1cafe0de0919e0b2d358bf2b8f1d838ccf6f2637

See more details on using hashes here.

File details

Details for the file justsdk-2.4.1-py3-none-any.whl.

File metadata

  • Download URL: justsdk-2.4.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for justsdk-2.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 306acd681ea33f66464762548e6d666c009f8af14870ab1a40b0589c89f986ab
MD5 b93833e38ee85cbe636a8ad64b649e03
BLAKE2b-256 bcefd8f7af2e6d61c3d44f9d8ec3dbb53681ec7f91d6aab3b9e0b293c557ec2b

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