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.0.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.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: justsdk-2.4.0.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.0.tar.gz
Algorithm Hash digest
SHA256 4bd3a5d891a6b4ed6c7803dce635837e5f5c765d418b95cdbe8f8959ea856550
MD5 46e73a576ab37eb787039a0c14c966fc
BLAKE2b-256 60dbbae2c46d49e237869915c8c86632df02cb2c780064756a558dd5f9538cfc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: justsdk-2.4.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38e4cda79f455167a3767526adc3760764d317b4def8d93e5f48965d4a696b90
MD5 1460192765f20b84f44f7e1d077c4140
BLAKE2b-256 a9337a96dd6f40b567553d815050c25afbdd2f875ada9dc58d418bac28f0c1b3

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