Skip to main content

A Python library to simplify common programming tasks.

Project description

[!IMPORTANT] This library is compatible with Python 3.14, but certain dependencies might not yet support this version.

xulbux

xulbux is a library that contains many useful classes, types, and functions, ranging from console logging and working with colors to file management and system operations. The library is designed to simplify common programming tasks and improve code readability through its collection of tools.

For precise information about the library, see the library's documentation.
For the libraries latest changes and updates, see the change log.

The best modules, you have to check out:

format_codes console color


Installation

Run the following commands in a console with administrator privileges, so the actions take effect for all users.

Install the library and all its dependencies with the command:

pip install xulbux

Upgrade the library and all its dependencies to their latest available version with the command:

pip install --upgrade xulbux

CLI Commands

When the library is installed, the following commands are available in the console:

Command Description
xulbux-help shows some information about the library

Usage

Import the full library under the alias xx, so its modules and main classes are accessible with xx.module.Class, xx.MainClass.method():

import xulbux as xx

So you don't have to import the full library under an alias, you can also import only certain parts of the library's contents:

# LIBRARY SUB MODULES
from xulbux.base.consts import COLOR, CHARS, ANSI
# MODULE MAIN CLASSES
from xulbux import Code, Color, Console, ...
# MODULE SPECIFIC IMPORTS
from xulbux.color import rgba, hsla, hexa

Modules

Main Module Contents
base
Sub Module Contents
consts Constant values used throughout the library.
exceptions Custom exception classes used throughout the library.
types Custom type definitions used throughout the library.
code Code class, which includes methods to work with code strings.
color rgbahslahexaColor classes, which include methods to work with
colors in various formats.
console ConsoleProgressBar classes, which include methods for logging
and other actions within the console.
data Data class, which includes methods to work with nested data structures.
env_path EnvPath class, which includes methods to work with the PATH environment variable.
file File class, which includes methods to work with files and file paths.
format_codes FormatCodes class, which includes methods to print and work with strings that contain
special formatting codes, which are then converted to ANSI codes for pretty console output.
json Json class, which includes methods to read, create and update JSON files,
with support for comments inside the JSON data.
path Path class, which includes methods to work with file and directory paths.
regex Regex class, which includes methods to dynamically generate complex regex patterns
for common use cases.
string String class, which includes various utility methods for string manipulation and conversion.
system System class, which includes methods to interact with the underlying operating system.

Example Usage

This is what it could look like using this library for a simple but ultra good-looking color converter:

from xulbux.base.consts import COLOR, CHARS
from xulbux.color import hexa
from xulbux import Console


def main() -> None:

    # LET THE USER ENTER A HEXA COLOR IN ANY HEXA FORMAT
    input_clr = Console.input(
        "[b](Enter a HEXA color in any format) > ",
        start="\n",
        placeholder="#7075FF",
        max_len=7,
        allowed_chars=CHARS.HEX_DIGITS,
    )

    # ANNOUNCE INDEXING THE INPUT COLOR
    Console.log(
        "INDEX",
        "Indexing the input HEXA color...",
        start="\n",
        title_bg_color=COLOR.BLUE,
    )

    try:
        # TRY TO CONVERT THE INPUT STRING INTO A hexa() OBJECT
        hexa_color = hexa(input_clr)

    except ValueError:
        # ANNOUNCE THE INVALID INPUT COLOR AND EXIT THE PROGRAM
        Console.fail(
            "The input HEXA color is invalid.",
            end="\n\n",
            exit=True,
        )

    # ANNOUNCE STARTING THE CONVERSION
    Console.log(
        "CONVERT",
        "Converting the HEXA color into different types...",
        title_bg_color=COLOR.TANGERINE,
    )

    # CONVERT THE HEXA COLOR INTO THE TWO OTHER COLOR FORMATS
    rgba_color = hexa_color.to_rgba()
    hsla_color = hexa_color.to_hsla()

    # ANNOUNCE THE SUCCESSFUL CONVERSION
    Console.done(
        "Successfully converted color into different types.",
        end="\n\n",
    )

    # PRETTY PRINT THE COLOR IN DIFFERENT FORMATS
    Console.log_box_bordered(
        f"[b](HEXA:) [i|white]({hexa_color})",
        f"[b](RGBA:) [i|white]({rgba_color})",
        f"[b](HSLA:) [i|white]({hsla_color})",
    )


if __name__ == "__main__":
    main()



View this library on PyPI

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

xulbux-1.9.2.tar.gz (92.2 kB view details)

Uploaded Source

Built Distribution

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

xulbux-1.9.2-py3-none-any.whl (68.5 kB view details)

Uploaded Python 3

File details

Details for the file xulbux-1.9.2.tar.gz.

File metadata

  • Download URL: xulbux-1.9.2.tar.gz
  • Upload date:
  • Size: 92.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for xulbux-1.9.2.tar.gz
Algorithm Hash digest
SHA256 adcc4c255f5bc0b7883fc4525dd33fe580d9d7a5ba97c9abcd0a0ae5b6e296aa
MD5 f0482d21250b1f49f3ca3b3fb9615eb0
BLAKE2b-256 4c5f464b97d8a883e906331241c73af952dc94c869d0c35fdbc5e03786684337

See more details on using hashes here.

File details

Details for the file xulbux-1.9.2-py3-none-any.whl.

File metadata

  • Download URL: xulbux-1.9.2-py3-none-any.whl
  • Upload date:
  • Size: 68.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for xulbux-1.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c6a55d94bc60654b5bb38c3fa3d7a5bf17020ac73fc75b46c496bf3225b9ba9f
MD5 e44b20158519720b297e7fc3bbbd4287
BLAKE2b-256 07b73998baaac172839665f7cc9a7d4f911c54370f09f1b0975b8fa02c395100

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