Skip to content
XulbuX edited this page Feb 18, 2025 · 69 revisions

$\color{#8085FF}\Huge\textsf{XulbuX}$


$\color{#8085FF}\textsf{XulbuX}$ is a library which includes a lot of really helpful classes, types and functions.
For the libraries latest changes, see the change log.


Installation

To install the library and all its dependencies, open a console and run the command:

pip install xulbux

To upgrade the library to the latest available version, run the following command in your console:

pip install --upgrade xulbux

Usage

Import the full library under the alias xx, so it's constants, classes, types and functions are accessible with xx.CONSTANT.value, xx.Class.method(), xx.type() and xx.function():

import xulbux as xx

So you don't have to write the alias xx in front of everything, you can import the library's contents directly:

# CONSTANTS
from xulbux import COLOR, CHARS, ANSI
# Classes
from xulbux import Code, Color, Console, ...
# types
from xulbux import rgba, hsla, hexa

Modules

advanced code-string operations (changing the indent, finding function calls, ...)
everything around colors (converting, blending, searching colors in strings, ...)
advanced actions related to the console (pretty logging, advanced inputs, ...)
advanced operations with data structures (compare, generate path ID's, pretty print/format, ...)
getting and editing the PATH variable (get paths, check for paths, add paths, ...)
advanced working with files (create files, rename file-extensions, ...)
easy pretty printing with custom format codes (print, inputs, custom format codes to ANSI, ...)

xx_json

advanced working with json files (read, create, update, ...)

xx_path

advanced path operations (get paths, smart-extend relative paths, delete paths, ...)

xx_regex

generated regex pattern-templates (match bracket- and quote pairs, match colors, ...)
helpful actions when working with strings. (normalize, escape, decompose, ...)

xx_system

advanced system actions (restart with message, check installed Python libs, ...)

Example Usage

This is what it could look like using this module for a simple color converter:

from xulbux import COLOR                 # CONSTANTS
from xulbux import FormatCodes, Console  # Classes
from xulbux import hexa                  # types


def main() -> None:

    # LET THE USER ENTER A HEXA COLOR IN ANY HEXA FORMAT
    input_clr = FormatCodes.input(
      "\n[b](Enter a HEXA color in any format) [dim](>) "
    )

    # 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 COLOR INTO A hexa() COLOR
        hexa_color = hexa(input_clr)

    except ValueError:
        # ANNOUNCE THE ERROR 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 TYPES
    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 TYPES
    FormatCodes.print(f"[b](HEXA:) [i|white]({hexa_color})")
    FormatCodes.print(f"[b](RGBA:) [i|white]({rgba_color})")
    FormatCodes.print(f"[b](HSLA:) [i|white]({hsla_color})\n")


if __name__ == "__main__":
    main()



★⠀Python Library by XulbuX⠀★

Project Links

Testing and Formatting

Classifiers

  • Intended Audience:
    • Developers
  • License:
    • OSI Approved
    • MIT License
  • Operating Systems:
    • Full Library: OS Independent
  • Supported Python Versions:
    • Python 3.13
    • Python 3.12
    • Python 3.11
    • Python 3.10
  • Topics:
    • Libraries
    • Python Modules
    • Software Development

The XulbuX Logo
Clone this wiki locally