Skip to content

Latest commit

 

History

History
975 lines (701 loc) · 50 KB

File metadata and controls

975 lines (701 loc) · 50 KB


Changelog

26.04.2026 v1.9.7

  • Restructured CLI commands under a single xulbux-lib entry point:
    • xulbux-lib shows library info.
    • xulbux-lib fc (new) parses and renders a string's format codes as ANSI console output.
  • Added .get() method to ParsedArgData for safe index access on parsed argument values.
  • Added missing __init__.py files to the base and cli subpackages.
  • Fixed ModuleNotFoundError caused by mypyc compiling __init__.py files, which broke subpackage imports.
  • Simplified CI workflows to use pip's build isolation instead of manually specifying build dependencies.
  • Fixed a small bug in ProgressBar, where it would only overwrite and not actually clear the previous line.
  • Added a new constant ANSI.COLOR_VARIANTS_MAP, which contains all possible color variants that can be used in formatting.
  • Made it possible to also pass console default colors to title_bg_color in Console.log(), instead of only custom RGBA or HEXA colors.
  • Added a new format key link:… to FormatCodes, which allows you to create hyperlinks in the console output with the syntax [link:URL](display text).

BREAKING CHANGES:

  • The ANSI.COLOR_MAP constant is now a set for better lookup performance, as the color order doesn't matter there.
  • All Console methods that allow console default colors as input for their color params, now actually validate the given color, raising an error if it's not valid.
  • The default for box_bg_color in Console.log_box_filled() is now the console foreground color (None) instead of br:green.

13.04.2026 v1.9.6

  • The compiled version of the library now includes the type stub files (.pyi), so type checkers can properly check types.
  • Made all type hints in the whole library way more strict and accurate.
  • Removed leftover unnecessary runtime type-checks in several methods throughout the whole library.

BREAKING CHANGES:

  • All methods that should use positional-only and/or keyword-only params, now actually enforce that by using the / and * syntax in the method definitions.
  • Renamed the Spinner class from the console module to Throbber, since that name is closer to what it's actually used for.
  • Changed the name of the TypeAlias DataStructure to DataObj because that name is shorter and more general.
  • Changed both names DataStructureTypes and IndexIterableTypes to DataObjTT and IndexIterableTT respectively (TT stands for type-tuple).
  • Made the return value of String.single_char_repeats() always be int and not int | bool.

25.01.2026 v1.9.5

  • Added a new class property Console.encoding, which returns the encoding used by the console (e.g. utf-8, cp1252, …).
  • Added multiple new class properties to the System class:
    • is_linux Whether the current OS is Linux or not.
    • is_mac Whether the current OS is macOS or not.
    • is_unix Whether the current OS is a Unix-like OS (Linux, macOS, BSD, …) or not.
    • hostname The network hostname of the current machine.
    • username The current user's username.
    • os_name The name of the operating system (e.g. Windows, Linux, …).
    • os_version The version of the operating system.
    • architecture The CPU architecture (e.g. x86_64, ARM, …).
    • cpu_count The number of CPU cores available.
    • python_version The Python version string (e.g. 3.10.4).
  • Created a two new TypeAliases:
    • ArgParseConfig Matches the command-line-parsing configuration of a single argument.
    • ArgParseConfigs Matches the command-line-parsing configurations of multiple arguments, packed in a dictionary.
  • Added a new attribute flag to the ArgData TypedDict and the ArgResult class, which contains the specific flag that was found or None for positional args.

BREAKING CHANGES:

  • Rewrote Console.get_args() for a different parsing functionality:
    • Flagged values are now too saved to lists, so now only the values attribute is used for all argument types.
    • The results of parsed command-line arguments are also no longer differentiated between regular flagged arguments and positional "before"/"after" arguments.
    • The param allow_spaces was removed, and therefore a new param flag_value_sep was added, which specifies the character/s used to separate flags from their values.
      This means, flags can new only receive values when the separator is present (e.g. --flag=value or --flag = value).
  • Combined the custom TypedDict classes ArgResultRegular and ArgResultPositional into a single TypedDict class ArgData, which is now used for all parsed command-line arguments.
  • Renamed the classes Args and ArgResult to ParsedArgs and ParsedArgData, to better describe their purpose.
  • Renamed the attribute is_positional to is_pos everywhere, so its name isn't that long.

06.01.2026 v1.9.4

  • Added a new base module base.decorators which contains custom decorators used throughout the library.
  • Made mypy_extensions an optional dependency by wrapping all uses of mypy_extensions.mypyc_attr in a custom decorator that acts as a no-op if mypy_extensions is not installed.
  • The methods from the env_path module that modify the PATH environment variable, no longer sort all paths alphabetically, but keep the original order, to not mess with the user's intended PATH order.
  • Added a new TypeAlias PathsList to the base.types module, which matches a list of paths as strings or pathlib.Path objects.

BREAKING CHANGES:

  • Renamed the module path to file_sys and its main class Path to FileSys, so you can better use it alongside the built-in pathlib.Path class without always needing to import one of them under an alias.
  • Renamed most FileSys methods to better describe their functionality:
    • Path.extend() is now FileSys.extend_path()
    • Path.extend_or_make() is now FileSys.extend_or_make_path()
  • Renamed the param use_closest_match in FileSys.extend_path() and FileSys.extend_or_make_path() to fuzzy_match, since that name is more commonly used for that functionality.
  • Updated all library methods that work with paths to accept pathlib.Path objects additionally to strings, as path inputs.
  • Also, all library methods that return paths now return pathlib.Path objects instead of strings.

01.01.2026 v1.9.3 Big Update 🚀

𝓗𝓪𝓹𝓹𝔂 𝟚𝟘𝟚𝟞 🎉

  • Added a new method Color.str_to_hsla() to parse HSLA colors from strings.
  • Changed the default syntax highlighting for Data.to_str() and therefore also Data.print() to use console default colors.
  • Added the missing but needed dunder methods to the Args and ArgResult classes and the rgba, hsla and hexa color objects for better usability and type checking.
  • Added three new methods to Args:
    • get() returns the argument result for a given alias, or a default value if not found
    • existing() yields only the existing arguments as tuples of (alias, ArgResult)
    • missing() yields only the missing arguments as tuples of (alias, ArgResult)
  • Added a new attribute is_positional to ArgResult, which indicates whether the argument is a positional argument or not.
  • The ArgResult class now also has a dict() method, which returns the argument result as a dictionary.
  • Added new properties is_tty and supports_color to the Console class, home to the Path class and is_win to the System class.
  • Added the option to add format specifiers to the {current}, {total} and {percentage} placeholders in the bar_format and limited_bar_format of ProgressBar.
  • Finally fixed the C901 'Console.get_args' is too complex (39) linting error by refactoring the method into its own helper class.
  • Changed the string- and repr-representations of the rgba and hsla color objects and newly implemented it for the Args and ArgResult classes.
  • Made internal, global constants, which's values never change, into Final constants for better type checking.
  • The names of all internal classes and methods are all no longer prefixed with a double underscore (__), but a single underscore (_) instead.
  • Changed all methods defined as @staticmethod to @classmethod where applicable, to improve inheritance capabilities.
  • Adjusted the whole library's type hints to be way more strict and accurate, using mypy as static type checker.
  • Change the class-property definitions to be defined via metaclass and using @property decorators, to make them compatible with mypyc.
  • Unnest all the nested methods in the whole library for compatibility with mypyc.
  • The library is now compiled using mypyc when installing, which makes it run significantly faster. Benchmarking results:
    • Simple methods like data and color operations had a speed improvement of around 50%.
    • Complex methods like console logging had a speed improvement of up to 230%!

BREAKING CHANGES:

  • Renamed Data.to_str() to Data.render(), since that describes its functionality better (especially with the syntax highlighting option).
  • Renamed the constant ANSI.ESCAPED_CHAR to ANSI.CHAR_ESCAPED for better consistency with the other constant names.
  • Removed the general Pattern and Match type aliases from the base.types module (they are pointless since you should always use a specific type and not "type1 OR typeB").
  • Removed the _ prefix from the param _syntax_highlighting in Data.render(), since it's no longer just for internal use.

16.12.2025 v1.9.2

  • Added a new class LazyRegex to the regex module, which is used to define regex patterns that are only compiled when they are used for the first time.
  • Removed unnecessary character escaping in the precompiled regex patterns in the console module.
  • Removed all the runtime type-checks that can also be checked using static type-checking tools, since you're supposed to use type checkers in modern python anyway, and to improve performance.
  • Renamed the internal class method FormatCodes.__config_console() to FormatCodes._config_console() to make it callable, but still indicate that it's internal.
  • Fixed a small bug where Console.log_box_…() would crash, when calling it without providing any *values (content for inside the box).

BREAKING CHANGES:

  • The arguments when calling Console.get_args() are no longer specified in a single dictionary, but now each argument is passed as a separate keyword argument.
    You can still use a dictionary just fine by simply unpacking it with **, like this:
    Console.get_args(**{"arg": {"-a", "--arg"}})
  • Replaced the internal _COMPILED regex pattern dictionaries with LazyRegex objects so it won't compile all regex patterns on library import, but only when they are used for the first time, which improves the library's import time.
  • Renamed the internal _COMPILED regex pattern dictionaries to _PATTERNS for better clarity.
  • Removed the import of the ProgressBar class from the __init__.py file, since it's not an important main class that should be imported directly.
  • Renamed the constant CLR to CLI_COLORS and the constant HELP to CLI_HELP in the cli.help module.
  • Changed the default value of the strip_spaces param in Regex.brackets() from True to False, since this is more intuitive behavior.

26.11.2025 v1.9.1

  • Unified the module and class docstring styles throughout the whole library.
  • Moved the Protocol ProgressUpdater from the console module to the types module.
  • Added throttling to the ProgressBar update methods to impact the actual process' performance as little as possible.
  • Added a new class Spinner to the console module, which is used to display a spinner animation in the console during an ongoing process.

BREAKING CHANGES:

  • Made the value input into the params bar_format and limited_bar_format of ProgressBar be a list/tuple of strings instead of a single string, so the user can define multiple formats for different console widths.
  • Added a new param sep: str = " " to the ProgressBar class, which is used to join multiple bar-format strings.
  • Renamed the class property Console.wh to Console.size, since it describes the property better.
  • Renamed the class property Console.usr to Console.user, since it describes the property better.
  • Added missing type checking to methods in the path module.

21.11.2025 v1.9.0 Big Update 🚀

  • Standardized the docstrings for all public methods in the whole library to use the same style and structure.
  • Replaced left over single quotes with double quotes for consistency.
  • Fixed a bug inside Data.remove_empty_items(), where types other than strings where passed to String.is_empty(), which caused an exception.
  • Refactored/reformatted the code of the whole library, to introduce more clear code structure with more room to breathe.
  • Made the really complex regex patterns in the Regex class all multi-line for better readability.
  • Added a new internal method Regex._clean(), which is used to clean up the regex patterns, defined as multi-line strings.
  • Moved custom exception classes to their own file base/exceptions.py, so the user can easily import them all from the same place.
  • Moved custom types to their own file base/types.py, so the user can easily import them all from the same place.
  • Removed unnecessary duplicate code in several methods throughout the library.
  • Introduced some minor performance improvements in a few methods, that might be called very often in a short time span.
  • Added a small description to the docstrings of all modules and their main classes.

BREAKING CHANGES:

  • The find_args param from the method Console.get_args() now only accepts sets for the flags instead of lists/tuples, since the order of flags doesn't matter and sets have better performance for lookups.
  • Added missing type checking to all public methods in the whole library, so now they will all throw errors if the params aren't of the expected type.
  • Removed the second definitions of constants in with lowercase names in the ANSI class inside the consts module, so now you can only access them with their uppercase names (e.g. ANSI.CHAR instead of ANSI.char).

14.11.2025 v1.8.5

  • Made the help command xulbux-help new primarily use console default colors so it fits the user's console theme.
  • Changed the default box_bg_color in Console.log_box_filled() from green to br:green.
  • Fixed a bug in all methods of FormatCodes, where as soon as you used more than a single modifier format code (e.g. [ll] or [++]), it was treated as invalid and ignored.
  • Added a new method FormatCodes.escape() which will escape all valid formatting codes in a string.
  • Again refactored the whole CHANGELOG.md to use actual sentences and add a BREAKING CHANGES section to more clearly highlight breaking changes.

BREAKING CHANGES:

  • Removed the *c and *color formatting codes, since the user should just use the code default to achieve the exact same instead.
  • Renamed the method FormatCodes.remove_formatting() to FormatCodes.remove().

11.11.2025 v1.8.4

𝓢𝓲𝓷𝓰𝓵𝓮𝓼 𝓓𝓪𝔂 🥇😉

  • Adjusted Regex.hsla_str() to not include optional degree (°) and percent (%) symbols in the captured groups.
  • Fixed that Regex.hexa_str() couldn't match HEXA colors anywhere inside a string, but only if the whole string was just the HEXA color.
  • Added _ArgResultRegular and _ArgResultPositional TypedDict classes for better type hints in Args.dict() and Args.items() methods.

BREAKING CHANGES:

  • The method Console.get_args() no longer tries to convert found arg values to their respective types, since that caused too many unwanted, wrong type conversions.
  • ArgResult now has separate properties for different argument types to improve type safety and eliminate the need for type casting when accessing argument values:
    • value: Optional[str] for regular flagged arguments
    • values: list[str] for positional "before"/"after" arguments

08.10.2025 v1.8.3

  • Adjusted the look of the prompts and inputs of the System.check_libs() method.
  • Added a new param to System.check_libs():
    missing_libs_msgs: tuple[str, str] = (…) two messages: The first one is displayed when missing libraries are found. The second one is the confirmation message before installing missing libraries.
  • Adjusted error messages throughout the whole library to all be structured about the same.
  • Fixed a small bug in FormatCodes.__config_console(), where it would cause an exception, because it tried to configure Windows specific console settings on non-Windows systems.
  • The Console.get_args() method will now treat everything as values (even if it starts with - or --) unless it's specified in the find_args param.
  • Added two new params to all the Console.log() presets:
    • exit_code: int = 0 the exit code to use if exit is true
    • reset_ansi: bool = True whether to reset all ANSI formatting after pausing/exiting or not
  • Made the type hints and value checks for Console.get_args() more strict.
  • You can now insert horizontal rules inside a Console.log_box_bordered() by putting {hr} in the text.
  • Made it possible to also update the title within a ProgressBar.progress_context() using the returned callable with the new kwarg label.

BREAKING CHANGES:

  • Reordered the params of Console.pause_exit() to be more logical.

11.09.2025 v1.8.2

  • The client command xulbux-help now tells you that there's a newer version of the library available, if you're not using the latest version.
  • Added two new params to Console.input():
    • default_val: Optional[T] = None the default value to return if the input is empty
    • output_type: type[T] = str the type (class) to convert the input to before returning it
  • Added a new class to ProgressBar to the console module.
  • Made small performance improvement in FormatCodes.to_ansi().
  • Added missing docstrings to several public class variables.
  • Added the missing tests for methods in the console module.
  • Added test for the last two modules that didn't have test until now: regex and system.

BREAKING CHANGES:

  • Spaces between a format code and the auto-reset-brackets are no longer allowed, so [red]␣(text) will not be automatically reset and output as ␣(text).

20.08.2025 v1.8.1

  • HOTFIX: Fixed a critical bug which caused the package to not install properly and make the whole library not work.
  • Fixed several small bugs regarding the tabs and text wrapping inside Console.log().
  • Added two new params to Console.log():
    • title_px: int = 1 the horizontal padding (in chars) to the title (if title_bg_color is set)
    • title_mx: int = 2 the horizontal margin (in chars) to the title

BREAKING CHANGES:

  • Renamed the param _console_tabsize form the method Console.log() to tab_size, and it will now just set the size for the log directly instead of specifying, what the console's tab size is.

28.08.2025 v1.8.0⚠️ This release is broken!

  • New options for the param find_args from the method Console.get_args():
    Previously you could only input a dictionary with items like "alias_name": ["-f", "--flag"] that specify an arg's alias and the flags that correspond to it.
    New, instead of flags, you can also once use the literal "before" and once "after", which corresponds to all non-flagged values before or after all flagged values.
  • Changed the default default_color for all Console class input methods to None.
  • Now prompt from Console.pause_exit() also supports custom formatting codes and the method new pauses per default (without exiting).

BREAKING CHANGES:

  • The method Console.restricted_input() now returns an empty string instead of None if the user didn't input anything.
  • Completely rewrote Console.restricted_input(), so now it's actually usable, and renamed it to just Console.input().
  • Removed method Console.pwd_input(), since you can now simply use Console.input(mask_char="*") instead, which does the exact same thing.
  • Removed the CLI command xx-help, since it was redundant because there's already the CLI command xulbux-help.
  • Renamed the previously internal module _consts_ to consts and made it accessible via from xulbux.base.consts import …, since you should be able to use library constants without them being «internal».
  • Removed the xx_ from all the library modules since it's redundant, and without it the imports look more professional and cleaner.
  • The constants form inside the consts module are now all uppercase (except the class methods), to make clear that they're constants.
  • Removed the wildcard imports from the __init__.py file, so now you can only access the main classes directly with from xulbux import … and for the rest you have to import the specific module first.

29.07.2025 v1.7.3

  • Added a new param to the methods Console.log_box_filled() and Console.log_box_bordered():
    indent: int = 0 the indentation of the box (in chars)
  • Fixed a bug in Console.log_box_filled() where the box background color would sometimes not stop at the box's edge, but would continue to the end of the console line.

BREAKING CHANGES:

  • Removed the param title_bg_color from the Console.log() preset methods, since that is part of the preset and doesn't need to be changed by the user.

17.06.2025 v1.7.2

  • The Console.w, Console.h and Console.wh class properties now return a default size if there is no console, instead of throwing an error.
  • It wasn't actually possible to use default console-colors (e.g. "red", "green", …) for the color params in Console.log() so that option was completely removed again.
  • Upgraded the speed of FormatCodes.to_ansi() by adding the internal ability to skip the default_color validation.
  • Fixed type hints for the whole library.
  • Fixed a small bug in Console.pause_exit(), where the key, pressed to unpause wasn't suppressed, so it was written into the next console input after unpausing.

11.06.2025 v1.7.1

  • Fixed an issue with the Color.is_valid_…() and Color.is_valid() methods, where you were not able to input any color without a type mismatch.
  • Added a new method Console.log_box_bordered(), which does the same as Console.log_box_filled(), but with a border instead of a background color.
  • The module xx_format_codes now treats the [*] to-default-color-reset as a normal full-reset, when no default_color is set, instead of just counting it as an invalid format code.
  • Fixed bug where entering a color as HEX integer in the color params of the methods Console.log(), Console.log_box_filled() and Console.log_box_bordered() would not work, because it was not properly converted to a format code.
  • You can now use default console colors (e.g. "red", "green", …) for the color params in Console.log().
  • The methods Console.log_box_filled() and Console.log_box_bordered() no longer right-strip spaces, so you can make multiple log boxes the same width, by adding spaces to the end of the text.

BREAKING CHANGES:

  • Renamed the method Console.log_box() to Console.log_box_filled().

28.05.2025 v1.7.0

  • Fixed a small bug in Console.log() where empty linebreaks where removed.
  • Corrected and added missing type hints for the whole library.
  • Fixed possibly unbound variables for the whole library.
  • Updated the client command xulbux-help.

30.04.2025 v1.6.9

  • Added a new param to the methods FormatCodes.remove_ansi() and FormatCodes.remove_formatting():
    _ignore_linebreaks: bool = False whether to include linebreaks in the removal positions or not
  • Added a new param to method Color.luminance() and to the .grayscale() method of all color types: method: str = "wcag2" the luminance calculation method to use
  • Added a new param to the method File.rename_extension(): full_extension: bool = False whether to treat everything behind the first . as the extension or everything behind the last .
  • Fixed a small bug in Console.log_box() where the leading spaces where removed from the box content.
  • You can now assign default values to args in Console.get_args().

BREAKING CHANGES:

  • Changed the params in Json.create():
    • new_file: str = "config" is now the first param and content: dict the second one
    • new_file: str = "config" is now called json_file: str with no default value
  • The methods Json.update() and Data.set_value_by_path_id() now intake a dictionary as update_values param, instead of a list of strings.
  • Renamed param correct_path in Path.extend() and param correct_paths in File.extend_or_make_path() to use_closest_match, since this name describes its functionality better.
  • Moved the method extend_or_make_path() from the xx_file module to the xx_path module and renamed it to extend_or_make().

18.03.2025 v1.6.8

  • Made it possible to escape formatting codes by putting a slash (/ or \\) at the beginning inside the brackets (e.g. [/red]).
  • New methods for Args (the returned object from Console.get_args()):
    • The len() function can now be used on Args (the returned object from Console.get_args()).
    • The Args object now also has the dict like methods .keys(), .values() and .items().
    • You can also get the args as a dict with the .dict() method.
    • You can now use the in operator on Args.
  • New methods for ArgResult (*a single arg-object from inside Args):
    • You can now use the bool() function on ArgResult to directly see if the arg exists.
  • The methods FormatCodes.remove_ansi() and FormatCodes.remove_formatting() now have a second param get_removals: bool = False:
    If this param is true additionally to the cleaned string, a list of tuples will be returned, where tuple contains the position of the removed formatting/ansi code and the removed code.
  • Fixed a bug in the line wrapping in all logging methods from the xx_console module.
  • Added a new param to the method Console.get_args():
    allow_spaces: bool = False whether to take spaces as separator of arg values or as part of an arg value

26.02.2025 v1.6.7

  • Made the staticmethod System.is_elevated() into a class property, which now can be accessed as System.is_elevated.
  • The method File.create() now throws a custom SameContentFileExistsError exception if a file with the same name and content already exists.
  • Added a bunch more docstrings to class properties and library constants.

BREAKING CHANGES:

  • Restructured the object returned from Console.get_args():
    Before, you accessed an arg's result with args["<arg_alias>"]["value"] and args["<arg_alias>"]["exists"].
    Now, you can directly access the result with args.<arg_alias>.value and args.<arg_alias>.exists.
  • Made the method Path.get(cwd=True) or Path.get(base_dir=True) into two class properties, which now can be accessed as Path.cwd and Path.script_dir.

17.02.2025 v1.6.6

  • Added a new method Console.multiline_input().
  • Added two new params to the method Console.log_box():
    • w_padding: int = 2 the horizontal padding (in chars) to the box content
    • w_full: bool = False whether to make the box be the full console width or not
  • Fixed a small bug in Data.print() where two params passed to Data.to_str() where swapped, which caused an error.
  • The method Data.print() now per default syntax highlights the console output:
    The syntax highlighting colors and styles can now be customized via the new param syntax_highlighting: dict[str, str] = {…}.
  • Added two new methods Data.serialize_bytes() and Data.deserialize_bytes().
  • Made the method String.to_type() be able to also interpret and convert large complex structures.
  • Added the new parameter strip_spaces: bool = True to the method Regex.brackets() which makes it possible to not ignore spaces around the content inside the brackets.
  • Adjusted the Console.log_box() method, so the box background can't be reset to nothing any more.
  • Added a new param to Console.log() (and therefore also to every Console.log() preset):
    format_linebreaks: bool = True when true, indents the text after every linebreak to the level of the previous text

BREAKING CHANGES:

  • Restructured the _consts_ library constants to use @dataclass classes (and simpler structured classes) as much as possible.
  • Renamed the DEFAULT class from the _consts_ to COLOR, whose colors are now directly accessible as variables (e.g. COLOR.red) and not through dictionary keys.
  • Changed the methods Console.w(), Console.h(), Console.wh() and Console.user() to modern class properties instead:
    Console.w current console columns (in text characters)
    Console.h current console lines
    Console.wh a tuple with the console size as (columns, lines)
    Console.usr the current username

29.01.2025 v1.6.5

  • Now the method FormatCodes.to_ansi() automatically converts the param string to a str if it isn't one already.
  • Added a new method FormatCodes.remove_codes().
  • Added a new method FormatCodes.remove_ansi().
  • Added a new method Console.log_box().
  • Changed the default values of two params in the Console.log() method and every log preset:
    • start: str = "\n" changed to start: str = ""
    • end: str = "\n\n" changed to end: str = "\n"
  • Added the params start: str = "", end: str = "\n" and default_color: rgba | hexa = DEFAULT.color["cyan"] to Console.restricted_input() and Console.pwd_input().

22.01.2025 v1.6.4

  • HOTFIX: Fixed a heavy bug, where the library could not be imported after the last update, because of a bug in xx_format_codes.

22.01.2025 v1.6.3⚠️ This release is broken!

  • Fixed a small bug in xx_format_codes:
    Inside print-strings, if there was a ' or " inside an auto-reset-formatting (e.g. [u](there's a quote)), that caused it to not be recognized as valid, and therefore not be automatically reset.
    Now this is fixed and auto-reset-formatting works as expected.
  • Added a new param ignore_in_strings: bool = True to Regex.brackets():
    If this param is true and a bracket is inside a string (e.g. '…' or "…"), it will not be counted as the matching closing bracket.
  • Removed lru_cache from the xx_format_codes module's internal methods, since it was unnecessary.
  • Adjusted FormatCodes.__config_console() so it can only be called once per process.

20.01.2025 v1.6.2

  • Added a new method elevate() to xx_system, which is used to request elevated privileges.
  • Fixed a bug in rgba(), hsla() and hexa():
    Previously, when initializing a color with the alpha channel set to 0.0 (100% transparent), it was saved correctly, but when converted to a different color type or when returned, the alpha channel got ignored, just like if it was None or 1.0 (opaque).
    Now when initializing a color with the alpha channel set to 0.0, this doesn't happen and when converted or returned, the alpha channel is still 0.0.
  • Huge speed and efficiency improvements in xx_color, due to newly added option to initialize a color without validation, which saves time when initializing colors, when we know, that the values are valid.
  • Added a new param reset_ansi: bool = False to FormatCodes.input():
    If this param is true, all formatting will be reset after the user confirmed the input and the program continues.

BREAKING CHANGES:

  • Moved the method is_admin() from xx_console to xx_system.
  • Method hex_int_to_rgba() from xx_color now returns an rgba() object instead of the separate values r, g, b and a.

15.01.2025 v1.6.1

  • Changed the params in File.make_path():
    Previously there were the params filename: str and filetype: str = "" where filename didn't have to have the file extension included, as long as the filetype was set.
    Now these params have become one param file: str which is the file with file extension.
  • Removed all line breaks and other Markdown formatting from docstrings, since not all IDEs support them.

BREAKING CHANGES:

  • Changed the order the params in File.create():
    Until now the param content: str = "" was the first param and file: str = "".
    New the param file: str = "" is the first param and content: str = "" is the second.
  • Renamed File.make_path() to a more descriptive name File.extend_or_make_path() and adjusted the usages of File.create() and File.make_path() inside xx_json accordingly.

07.01.2025 v1.6.0

  • Fixed a small bug in to_camel_case() in the xx_string module:
    Previously, it would return only the first part of the decomposed string.
    Now it correctly returns all decomposed string parts, joined in CamelCase.

21.12.2024 v1.5.9

  • Fixed bugs in method to_ansi() in module xx_format_codes:
    1. The method always returned an empty string, because the color validation was broken, and it would identify all colors as invalid.
      Now the validation Color.is_valid_rgba() and Color.is_valid_hexa() are fixed and now, if a color is identified as invalid, the method returns the original string instead of an empty string.
    2. Previously the method to_ansi() couldn't handle formats inside [] because everything inside the brackets was recognized as an invalid format.
      Now you are able to use formats inside [] (e.g. "[[red](Red text [b](inside) square brackets!)]").
  • Introduced a new test for the xx_format_codes module.
  • Fixed a small bug in the help client-command:
    Added back the default text color.

21.11.2024 v1.5.8

  • Added method String.is_empty() to check if the string is empty.
  • Added method String.escape() to escape special characters in a string.
  • Introduced a new test for xx_data (all methods).
  • Added doc-strings to all the methods in xx_data.
  • Made all the methods from xx_data work wih all the types of data structures (list, tuple, set, frozenset, dict).
  • Added method EnvPath.remove_path().
  • Introduced a new test for xx_env_vars (all methods).
  • Added a hexa_str() preset to the xx_regex module.
  • Introduced a new test for the methods from the Color class in xx_color.

BREAKING CHANGES:

  • Renamed the library from XulbuX to xulbux for better naming conventions.
  • Renamed the module xx_cmd, and it's class Cmd to xx_console and Console.
  • Renamed the module xx_env_vars, and it's class EnvVars to xx_env_path and EnvPath.

15.11.2024 v1.5.7

  • Change the testing modules to be able to run together with the library pytest.
  • Added formatting checks, using black, isort and flake8.
  • Added the script (command) xx-help or xulbux-help.
  • Structured Cmd.restricted_input() a bit nicer, so it appears less complex.
  • Corrected code after Lint with flake8 formatting suggestions.
  • Added additional tests for the custom color types.
  • Updated the whole xx_format_codes module for more efficiency and speed.

BREAKING CHANGES:

  • Moved the help() function to the file _cli_.py, because that's where all the scripts are located (It also was renamed to help_command()).
  • Moved the method normalize_spaces() to xx_string.

11.11.2024 v1.5.6

Again 𝓢𝓲𝓷𝓰𝓵𝓮𝓼 𝓓𝓪𝔂 🥇😉

  • Moved the whole library to its own repository: python-lib-xulbux
  • Updated all connections and links correspondingly.

11.11.2024 v1.5.5

𝓢𝓲𝓷𝓰𝓵𝓮𝓼 𝓓𝓪𝔂 🥇😉

  • Added methods to get the width and height of the console (in characters and lines):
    • Cmd.w() -> int how many text characters the console is wide
    • Cmd.h() -> int how many lines the console is high
    • Cmd.wh() -> tuple[int, int] a tuple with width and height
  • Added the method split_count(string, count) -> list[str] to xx_string.
  • Added doc-strings to every method in xx_string.
  • Updated the Cmd.restricted_input() method to be able to:
    • paste text from the clipboard,
    • select all text to delete everything at once,
    • write and backspace over multiple lines and
    • added support for custom formatting codes in the prompt.
  • Added required non-standard libraries to the project file.
  • Added more metadata to the project file.

06.11.2024 v1.5.4

  • Added a new method normalize_spaces(code) -> str to Code.
  • Added new doc-strings to xx_code and xx_cmd.
  • Added a custom input() method to Cmd, which lets you specify the allowed text characters the user can type, as well as the minimum and maximum length of the input.
  • Added the method pwd_input() to Cmd, which works just like the Cmd.restricted_input() but masks the input characters with *.
  • Restructured the whole library's imports, so the custom types won't get displayed as Any when hovering over a method/function.
  • Fixed bug when trying to get the base directory from a compiled script (EXE):
    Would previously get the path to the temporary extracted directory, which is created when running the EXE file.
    Now it gets the actual base directory of the currently running file.

BREAKING CHANGES:

  • Made the blend() method from all the color types modify the self object as well as returning the result.

30.10.2024 v1.5.3

  • Added the default text color to the _consts_.py so it's easier to change it (and used it in the library).
  • Added a bunch of other default colors to the _consts_.py (and used them in the library).
  • Refactored the whole library's code after the PEPs and The Zen of Python 🫡:
    • Changed the indent to 4 spaces.
    • No more inline control statements.
  • Added new methods to Color:
    • rgba_to_hex(r, g, b, a) -> int
    • hex_to_rgba(hex_int) -> tuple
    • luminance(r, g, b, precision, round_to) -> float|int
  • Fixed the grayscale() method of rgba(), hsla() and hexa():
    The method would previously just return the color, fully desaturated (not grayscale).
    Now this is fixed, and the method uses the luminance formula, to get the actual grayscale value.
  • All the methods in the xx_color module now support HEX integers (e.g. 0x8085FF instead of only strings: "#8085FF" "0x8085FF").

BREAKING CHANGES:

  • Restructured the values in _consts_.py.

28.10.2024 v1.5.2

  • New parameter correct_path:bool in Path.extend(): This makes sure, that typos in the path will only be corrected if this parameter is true.
  • Fixed bug in Path.extend(), where an empty string was taken as a valid path for the current directory ./.
  • Fixed color validation bug:
    Color.is_valid_rgba() and Color.is_valid_hsla() would not accept an alpha channel of None.
    Color.is_valid_rgba() was still checking for an alpha channel from 0 to 255 instead of 0 to 1.
  • Fixed bug for Color.has_alpha():
    Previously, it would return True if the alpha channel was None.
    Now in such cases it will return False.

28.10.2024 v1.5.1

  • Now all methods in xx_color support both HEX prefixes (# and 0x).
  • Added the default HEX prefix to _consts_.py.
  • Fixed bug when initializing a hexa() object:
    Would throw an error, even if the color was valid.

BREAKING CHANGES:

  • Renamed all library files for a better naming convention.

27.10.2024 v1.5.0 Big Update 🚀

  • Added a __help__.py file, which will show some information about the library and how to use it, when it's run as a script or when the help() function is called.
  • Added a lot more metadata to the library:
    __version__ (was already added in update v1.4.2)
    __author__
    __email__
    __license__
    __copyright__
    __url__
    __description__
    __all__

BREAKING CHANGES:

  • Split all classes into separate files, so users can download only parts of the library more easily.

27.10.2024 v1.4.2v1.4.3

  • Path.extend(rel_path) -> abs_path now also extends system variables like %USERPROFILE% and %APPDATA%.
  • Removed unnecessary parts when checking for missing required libraries.
  • You can now get the libraries current version by accessing the attribute XulbuX.__version__.

26.10.2024 v1.4.1

  • Added methods to each color type:
    • is_grayscale() -> self
    • is_opaque() -> self
  • Added additional error checking to the color types.
  • Made error messages for the color types clearer.
  • Updated the blend(other, ratio) method of all color types to use additive blending except for the alpha-channel.
  • Fixed problem with method-chaining for all color types.

25.10.2024 v1.4.0 Big Update 🚀

  • Huge update to the custom color types:
    • Now all type-methods support chaining.
    • Added new methods to each type:
      lighten(amount) -> self
      darken(amount) -> self
      saturate(amount) -> self
      desaturate(amount) -> self
      rotate(hue) -> self
      invert() -> self
      grayscale() -> self
      blend(other, ratio) -> self
      is_dark() -> bool
      is_light() -> bool
      with_alpha(alpha) -> self
      complementary() -> self

23.10.2024 v1.3.1

  • Now the alpha channel will be rounded to maximal 2 decimals, if converting from hexa() to rgba() or hsla().

21.10.2024 v1.3.0 Big Update 🚀

  • Fixed the custom types rgba(), hsla() and hexa():
    • rgba():
      Fixed to_hsla() and to_hexa().
    • hsla():
      Fixed to_rgba() and to_hexa().
    • hexa():
      Fixed to_rgba() and to_hsla().
  • Fixed methods from the Color class:
    Color.has_alpha()
    Color.to_rgba()
    Color.to_hsla()
    Color.to_hexa()
  • Set default value for param allow_alpha: bool to True for methods:
    Color.is_valid_rgba()
    Color.is_valid_hsla()
    Color.is_valid_hexa()
    Color.is_valid()

18.10.2024 v1.2.4v1.2.5

  • Added more info to the README.md as well as additional links.
  • Adjusted the structure inside CHANGELOG.md for a better overview and readability.

BREAKING CHANGES:

  • Renamed the class rgb() to rgba() to communicate, more clearly, that it supports an alpha channel.
  • Renamed the class hsl() to hsla() to communicate, more clearly, that it supports an alpha channel.

18.10.2024 v1.2.3

  • Added project links to the Python-project-file.
  • Made some CHANGELOG.md improvements.
  • Improved README.md.

18.10.2024 v1.2.1v1.2.2

  • Fixed bug in method Path.get(base_dir=True):
    Previously, setting base_dir to True would not return the actual base directory or even cause an error.
    Setting base_dir to True now will return the actual base directory of the current program (except if not running from a file).

17.10.2024 v1.2.0

  • New method in the Path class:
    Path.remove()

17.10.2024 v1.1.9

BREAKING CHANGES:

  • Corrected the naming of classes to comply with Python naming standards.

17.10.2024 v1.1.8

  • Added support for all OSes to the OS-dependent methods.

17.10.2024 v1.1.6v1.1.7

  • Fixed the Cmd.cls() method:
    There was a bug where only on Windows 10, the ANSI formats weren't cleared.

17.10.2024 v1.1.4v1.1.5

  • Added links to the CHANGELOG.md and README.md files.

17.10.2024 v1.1.3

  • Changed the default value of the param compactness: int in the method Data.print() to 1 instead of 0.

17.10.2024 v1.1.1v1.1.2

  • Adjusted the library's description.

16.10.2024 v1.1.0

  • Made it possible to also auto-reset the color and not only the predefined formats, using the auto-reset-format ([format](Automatically resetting)).

16.10.2024 v1.0.9

  • Added a library description, which gets shown if the library base-import is run directly.

  • Made it possible to escape an auto-reset-format ([format](Automatically resetting)) with a slash, so you can still have () brackets behind a [format]:

    FormatCodes.print('[u](Automatically resetting) following text')

    prints: Automatically resetting following text

    FormatCodes.print('[u]/(Automatically resetting) following text')

    prints: (Automatically resetting) following text

16.10.2024 v1.0.7v1.0.8

  • Added input() method to the FormatCodes class, so you can make pretty looking input prompts.
  • Added warning for no network connection when trying to install missing libraries.

15.10.2024 v1.0.6

  • Improved $\color{#8085FF}\textsf{XulbuX}$ library importing:
    Checks for missing required libraries and gives you the option to directly install them, if there are any.
  • Fixed issue where configuration file wasn't created and loaded correctly.

BREAKING CHANGES:

  • Moved constant variables into a separate file.

15.10.2024 v1.0.1v1.0.2v1.0.3v1.0.4v1.0.5

  • Fixed f-string issues for Python 3.10:
    1. Not making use of same quotes inside f-strings any more.
    2. No backslash escaping in f-strings.

14.10.2024 v1.0.0

$\color{#F90}\Huge\textsf{INITIAL RELEASE!\ 🤩🎉}$
At initial release, the library $\color{#8085FF}\textsf{XulbuX}$ looks like this:

# GENERAL LIBRARY
import XulbuX as xx
# CUSTOM TYPES
from XulbuX import rgb, hsl, hexa
Features class, type, function, …
Custom Types: rgb(int, int, int, float)
hsl(int, int, int, float)
hexa(str)
Directory Operations xx.Dir
File Operations xx.File
JSON File Operations xx.Json
System Actions xx.System
Manage Environment Vars xx.EnvVars
CMD Log And Actions xx.Cmd
Pretty Printing xx.FormatCodes
Color Operations xx.Color
Data Operations xx.Data
String Operations xx.String
Code String Operations xx.Code
Regex Pattern Templates xx.Regex