- Restructured CLI commands under a single
xulbux-libentry point:xulbux-libshows library info.xulbux-lib fc(new) parses and renders a string's format codes as ANSI console output.
- Added
.get()method toParsedArgDatafor safe index access on parsed argument values. - Added missing
__init__.pyfiles to thebaseandclisubpackages. - Fixed
ModuleNotFoundErrorcaused bymypyccompiling__init__.pyfiles, 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_colorinConsole.log(), instead of only custom RGBA or HEXA colors. - Added a new format key
link:…toFormatCodes, which allows you to create hyperlinks in the console output with the syntax[link:URL](display text).
BREAKING CHANGES:
- The
ANSI.COLOR_MAPconstant is now a set for better lookup performance, as the color order doesn't matter there. - All
Consolemethods 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_colorinConsole.log_box_filled()is now the console foreground color (None) instead ofbr:green.
- 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
Spinnerclass from theconsolemodule toThrobber, since that name is closer to what it's actually used for. - Changed the name of the TypeAlias
DataStructuretoDataObjbecause that name is shorter and more general. - Changed both names
DataStructureTypesandIndexIterableTypestoDataObjTTandIndexIterableTTrespectively (TTstands for type-tuple). - Made the return value of
String.single_char_repeats()always beintand notint | bool.
- 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
Systemclass:is_linuxWhether the current OS is Linux or not.is_macWhether the current OS is macOS or not.is_unixWhether the current OS is a Unix-like OS (Linux, macOS, BSD, …) or not.hostnameThe network hostname of the current machine.usernameThe current user's username.os_nameThe name of the operating system (e.g.Windows,Linux, …).os_versionThe version of the operating system.architectureThe CPU architecture (e.g.x86_64,ARM, …).cpu_countThe number of CPU cores available.python_versionThe Python version string (e.g.3.10.4).
- Created a two new TypeAliases:
ArgParseConfigMatches the command-line-parsing configuration of a single argument.ArgParseConfigsMatches the command-line-parsing configurations of multiple arguments, packed in a dictionary.
- Added a new attribute
flagto theArgDataTypedDict and theArgResultclass, which contains the specific flag that was found orNonefor 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
valuesattribute 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_spaceswas removed, and therefore a new paramflag_value_sepwas 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=valueor--flag = value).
- Flagged values are now too saved to lists, so now only the
- Combined the custom TypedDict classes
ArgResultRegularandArgResultPositionalinto a single TypedDict classArgData, which is now used for all parsed command-line arguments. - Renamed the classes
ArgsandArgResulttoParsedArgsandParsedArgData, to better describe their purpose. - Renamed the attribute
is_positionaltois_poseverywhere, so its name isn't that long.
- Added a new base module
base.decoratorswhich contains custom decorators used throughout the library. - Made
mypy_extensionsan optional dependency by wrapping all uses ofmypy_extensions.mypyc_attrin a custom decorator that acts as a no-op ifmypy_extensionsis not installed. - The methods from the
env_pathmodule 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
PathsListto thebase.typesmodule, which matches a list of paths as strings orpathlib.Pathobjects.
BREAKING CHANGES:
- Renamed the module
pathtofile_sysand its main classPathtoFileSys, so you can better use it alongside the built-inpathlib.Pathclass without always needing to import one of them under an alias. - Renamed most
FileSysmethods to better describe their functionality:Path.extend()is nowFileSys.extend_path()Path.extend_or_make()is nowFileSys.extend_or_make_path()
- Renamed the param
use_closest_matchinFileSys.extend_path()andFileSys.extend_or_make_path()tofuzzy_match, since that name is more commonly used for that functionality. - Updated all library methods that work with paths to accept
pathlib.Pathobjects additionally to strings, as path inputs. - Also, all library methods that return paths now return
pathlib.Pathobjects instead of strings.
𝓗𝓪𝓹𝓹𝔂 𝟚𝟘𝟚𝟞 🎉
- 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 alsoData.print()to use console default colors. - Added the missing but needed dunder methods to the
ArgsandArgResultclasses and thergba,hslaandhexacolor 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 foundexisting()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_positionaltoArgResult, which indicates whether the argument is a positional argument or not. - The
ArgResultclass now also has adict()method, which returns the argument result as a dictionary. - Added new properties
is_ttyandsupports_colorto theConsoleclass,hometo thePathclass andis_winto theSystemclass. - Added the option to add format specifiers to the
{current},{total}and{percentage}placeholders in thebar_formatandlimited_bar_formatofProgressBar. - 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
rgbaandhslacolor objects and newly implemented it for theArgsandArgResultclasses. - Made internal, global constants, which's values never change, into
Finalconstants 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
@staticmethodto@classmethodwhere applicable, to improve inheritance capabilities. - Adjusted the whole library's type hints to be way more strict and accurate, using
mypyas static type checker. - Change the class-property definitions to be defined via
metaclassand using@propertydecorators, to make them compatible withmypyc. - Unnest all the nested methods in the whole library for compatibility with
mypyc. - The library is now compiled using
mypycwhen 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()toData.render(), since that describes its functionality better (especially with the syntax highlighting option). - Renamed the constant
ANSI.ESCAPED_CHARtoANSI.CHAR_ESCAPEDfor better consistency with the other constant names. - Removed the general
PatternandMatchtype aliases from thebase.typesmodule (they are pointless since you should always use a specific type and not "type1 OR typeB"). - Removed the
_prefix from the param_syntax_highlightinginData.render(), since it's no longer just for internal use.
- Added a new class
LazyRegexto theregexmodule, 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
consolemodule. - 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()toFormatCodes._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
_COMPILEDregex pattern dictionaries withLazyRegexobjects 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
_COMPILEDregex pattern dictionaries to_PATTERNSfor better clarity. - Removed the import of the
ProgressBarclass from the__init__.pyfile, since it's not an important main class that should be imported directly. - Renamed the constant
CLRtoCLI_COLORSand the constantHELPtoCLI_HELPin thecli.helpmodule. - Changed the default value of the
strip_spacesparam inRegex.brackets()fromTruetoFalse, since this is more intuitive behavior.
- Unified the module and class docstring styles throughout the whole library.
- Moved the Protocol
ProgressUpdaterfrom theconsolemodule to thetypesmodule. - Added throttling to the
ProgressBarupdate methods to impact the actual process' performance as little as possible. - Added a new class
Spinnerto theconsolemodule, 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_formatandlimited_bar_formatofProgressBarbe 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 theProgressBarclass, which is used to join multiple bar-format strings. - Renamed the class property
Console.whtoConsole.size, since it describes the property better. - Renamed the class property
Console.usrtoConsole.user, since it describes the property better. - Added missing type checking to methods in the
pathmodule.
- 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 toString.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
Regexclass 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_argsparam from the methodConsole.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
ANSIclass inside theconstsmodule, so now you can only access them with their uppercase names (e.g.ANSI.CHARinstead ofANSI.char).
- Made the help command
xulbux-helpnew primarily use console default colors so it fits the user's console theme. - Changed the default
box_bg_colorinConsole.log_box_filled()fromgreentobr: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.mdto use actual sentences and add aBREAKING CHANGESsection to more clearly highlight breaking changes.
BREAKING CHANGES:
- Removed the
*cand*colorformatting codes, since the user should just use the codedefaultto achieve the exact same instead. - Renamed the method
FormatCodes.remove_formatting()toFormatCodes.remove().
𝓢𝓲𝓷𝓰𝓵𝓮𝓼 𝓓𝓪𝔂 🥇😉
- 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
_ArgResultRegularand_ArgResultPositionalTypedDict classes for better type hints inArgs.dict()andArgs.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. ArgResultnow 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 argumentsvalues: list[str]for positional"before"/"after"arguments
- 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 thefind_argsparam. - Added two new params to all the
Console.log()presets:
exit_code: int = 0the exit code to use ifexitis truereset_ansi: bool = Truewhether 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 kwarglabel.
BREAKING CHANGES:
- Reordered the params of
Console.pause_exit()to be more logical.
- The client command
xulbux-helpnow 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] = Nonethe default value to return if the input is emptyoutput_type: type[T] = strthe type (class) to convert the input to before returning it
- Added a new class to
ProgressBarto theconsolemodule. - Made small performance improvement in
FormatCodes.to_ansi(). - Added missing docstrings to several public class variables.
- Added the missing tests for methods in the
consolemodule. - Added test for the last two modules that didn't have test until now:
regexandsystem.
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).
- 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 = 1the horizontal padding (in chars) to the title (iftitle_bg_coloris set)title_mx: int = 2the horizontal margin (in chars) to the title
BREAKING CHANGES:
- Renamed the param
_console_tabsizeform the methodConsole.log()totab_size, and it will now just set the size for the log directly instead of specifying, what the console's tab size is.
- New options for the param
find_argsfrom the methodConsole.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_colorfor allConsoleclass input methods toNone. - Now
promptfromConsole.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 ofNoneif the user didn't input anything. - Completely rewrote
Console.restricted_input(), so now it's actually usable, and renamed it to justConsole.input(). - Removed method
Console.pwd_input(), since you can now simply useConsole.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 commandxulbux-help. - Renamed the previously internal module
_consts_toconstsand made it accessible viafrom 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
constsmodule are now all uppercase (except the class methods), to make clear that they're constants. - Removed the wildcard imports from the
__init__.pyfile, so now you can only access the main classes directly withfrom xulbux import …and for the rest you have to import the specific module first.
- Added a new param to the methods
Console.log_box_filled()andConsole.log_box_bordered():
indent: int = 0the 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_colorfrom theConsole.log()preset methods, since that is part of the preset and doesn't need to be changed by the user.
- The
Console.w,Console.handConsole.whclass 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 inConsole.log()so that option was completely removed again. - Upgraded the speed of
FormatCodes.to_ansi()by adding the internal ability to skip thedefault_colorvalidation. - 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.
- Fixed an issue with the
Color.is_valid_…()andColor.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 asConsole.log_box_filled(), but with a border instead of a background color. - The module
xx_format_codesnow treats the[*]to-default-color-reset as a normal full-reset, when nodefault_coloris 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()andConsole.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 inConsole.log(). - The methods
Console.log_box_filled()andConsole.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()toConsole.log_box_filled().
- 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.
- Added a new param to the methods
FormatCodes.remove_ansi()andFormatCodes.remove_formatting():
_ignore_linebreaks: bool = Falsewhether 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 = Falsewhether 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 andcontent: dictthe second onenew_file: str = "config"is now calledjson_file: strwith no default value
- The methods
Json.update()andData.set_value_by_path_id()now intake a dictionary asupdate_valuesparam, instead of a list of strings. - Renamed param
correct_pathinPath.extend()and paramcorrect_pathsinFile.extend_or_make_path()touse_closest_match, since this name describes its functionality better. - Moved the method
extend_or_make_path()from thexx_filemodule to thexx_pathmodule and renamed it toextend_or_make().
- 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 fromConsole.get_args()):- The
len()function can now be used onArgs(the returned object fromConsole.get_args()). - The
Argsobject 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
inoperator onArgs.
- The
- New methods for
ArgResult(*a single arg-object from insideArgs):- You can now use the
bool()function onArgResultto directly see if the arg exists.
- You can now use the
- The methods
FormatCodes.remove_ansi()andFormatCodes.remove_formatting()now have a second paramget_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_consolemodule. - Added a new param to the method
Console.get_args():
allow_spaces: bool = Falsewhether to take spaces as separator of arg values or as part of an arg value
- Made the staticmethod
System.is_elevated()into a class property, which now can be accessed asSystem.is_elevated. - The method
File.create()now throws a customSameContentFileExistsErrorexception 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 withargs["<arg_alias>"]["value"]andargs["<arg_alias>"]["exists"].
Now, you can directly access the result withargs.<arg_alias>.valueandargs.<arg_alias>.exists. - Made the method
Path.get(cwd=True)orPath.get(base_dir=True)into two class properties, which now can be accessed asPath.cwdandPath.script_dir.
- Added a new method
Console.multiline_input(). - Added two new params to the method
Console.log_box():
w_padding: int = 2the horizontal padding (in chars) to the box contentw_full: bool = Falsewhether to make the box be the full console width or not
- Fixed a small bug in
Data.print()where two params passed toData.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 paramsyntax_highlighting: dict[str, str] = {…}. - Added two new methods
Data.serialize_bytes()andData.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 = Trueto the methodRegex.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 everyConsole.log()preset):
format_linebreaks: bool = Truewhen true, indents the text after every linebreak to the level of the previous text
BREAKING CHANGES:
- Restructured the
_consts_library constants to use@dataclassclasses (and simpler structured classes) as much as possible. - Renamed the
DEFAULTclass from the_consts_toCOLOR, 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()andConsole.user()to modern class properties instead:
Console.wcurrent console columns (in text characters)
Console.hcurrent console lines
Console.wha tuple with the console size as (columns, lines)
Console.usrthe current username
- Now the method
FormatCodes.to_ansi()automatically converts the paramstringto astrif 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 tostart: str = ""end: str = "\n\n"changed toend: str = "\n"
- Added the params
start: str = "",end: str = "\n"anddefault_color: rgba | hexa = DEFAULT.color["cyan"]toConsole.restricted_input()andConsole.pwd_input().
- HOTFIX: Fixed a heavy bug, where the library could not be imported after the last update, because of a bug in
xx_format_codes.
- 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 = TruetoRegex.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_cachefrom thexx_format_codesmodule's internal methods, since it was unnecessary. - Adjusted
FormatCodes.__config_console()so it can only be called once per process.
- Added a new method
elevate()toxx_system, which is used to request elevated privileges. - Fixed a bug in
rgba(),hsla()andhexa():
Previously, when initializing a color with the alpha channel set to0.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 wasNoneor1.0(opaque).
Now when initializing a color with the alpha channel set to0.0, this doesn't happen and when converted or returned, the alpha channel is still0.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 = FalsetoFormatCodes.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()fromxx_consoletoxx_system. - Method
hex_int_to_rgba()fromxx_colornow returns anrgba()object instead of the separate valuesr,g,banda.
- Changed the params in
File.make_path():
Previously there were the paramsfilename: strandfiletype: str = ""wherefilenamedidn't have to have the file extension included, as long as thefiletypewas set.
Now these params have become one paramfile: strwhich 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 paramcontent: str = ""was the first param andfile: str = "".
New the paramfile: str = ""is the first param andcontent: str = ""is the second. - Renamed
File.make_path()to a more descriptive nameFile.extend_or_make_path()and adjusted the usages ofFile.create()andFile.make_path()insidexx_jsonaccordingly.
- Fixed a small bug in
to_camel_case()in thexx_stringmodule:
Previously, it would return only the first part of the decomposed string.
Now it correctly returns all decomposed string parts, joined in CamelCase.
- Fixed bugs in method
to_ansi()in modulexx_format_codes:
- The method always returned an empty string, because the color validation was broken, and it would identify all colors as invalid.
Now the validationColor.is_valid_rgba()andColor.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. - 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!)]").
- The method always returned an empty string, because the color validation was broken, and it would identify all colors as invalid.
- Introduced a new test for the
xx_format_codesmodule. - Fixed a small bug in the help client-command:
Added back the default text color.
- 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_datawork 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 thexx_regexmodule. - Introduced a new test for the methods from the
Colorclass inxx_color.
BREAKING CHANGES:
- Renamed the library from
XulbuXtoxulbuxfor better naming conventions. - Renamed the module
xx_cmd, and it's classCmdtoxx_consoleandConsole. - Renamed the module
xx_env_vars, and it's classEnvVarstoxx_env_pathandEnvPath.
- Change the testing modules to be able to run together with the library
pytest. - Added formatting checks, using
black,isortandflake8. - Added the script (command)
xx-helporxulbux-help. - Structured
Cmd.restricted_input()a bit nicer, so it appears less complex. - Corrected code after
Lint with flake8formatting suggestions. - Added additional tests for the custom color types.
- Updated the whole
xx_format_codesmodule 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 tohelp_command()). - Moved the method
normalize_spaces()toxx_string.
Again 𝓢𝓲𝓷𝓰𝓵𝓮𝓼 𝓓𝓪𝔂 🥇😉
- Moved the whole library to its own repository: python-lib-xulbux
- Updated all connections and links correspondingly.
𝓢𝓲𝓷𝓰𝓵𝓮𝓼 𝓓𝓪𝔂 🥇😉
- Added methods to get the width and height of the console (in characters and lines):
Cmd.w() -> inthow many text characters the console is wideCmd.h() -> inthow many lines the console is highCmd.wh() -> tuple[int, int]a tuple with width and height
- Added the method
split_count(string, count) -> list[str]toxx_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.
- Added a new method
normalize_spaces(code) -> strtoCode. - Added new doc-strings to
xx_codeandxx_cmd. - Added a custom
input()method toCmd, 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()toCmd, which works just like theCmd.restricted_input()but masks the input characters with*. - Restructured the whole library's imports, so the custom types won't get displayed as
Anywhen 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 theselfobject as well as returning the result.
- Added the default text color to the
_consts_.pyso 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) -> inthex_to_rgba(hex_int) -> tupleluminance(r, g, b, precision, round_to) -> float|int
- Fixed the
grayscale()method ofrgba(),hsla()andhexa():
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_colormodule now support HEX integers (e.g.0x8085FFinstead of only strings:"#8085FF""0x8085FF").
BREAKING CHANGES:
- Restructured the values in
_consts_.py.
- New parameter
correct_path:boolinPath.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()andColor.is_valid_hsla()would not accept an alpha channel ofNone.
Color.is_valid_rgba()was still checking for an alpha channel from0to255instead of0to1. - Fixed bug for
Color.has_alpha():
Previously, it would returnTrueif the alpha channel wasNone.
Now in such cases it will returnFalse.
- Now all methods in
xx_colorsupport both HEX prefixes (#and0x). - 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.
- Added a
__help__.pyfile, which will show some information about the library and how to use it, when it's run as a script or when thehelp()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.
Path.extend(rel_path) -> abs_pathnow 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__.
- Added methods to each color type:
is_grayscale() -> selfis_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.
- 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
- Now the alpha channel will be rounded to maximal 2 decimals, if converting from
hexa()torgba()orhsla().
- Fixed the custom types
rgba(),hsla()andhexa():
rgba():
Fixedto_hsla()andto_hexa().hsla():
Fixedto_rgba()andto_hexa().hexa():
Fixedto_rgba()andto_hsla().
- Fixed methods from the
Colorclass:
Color.has_alpha()
Color.to_rgba()
Color.to_hsla()
Color.to_hexa() - Set default value for param
allow_alpha: booltoTruefor methods:
Color.is_valid_rgba()
Color.is_valid_hsla()
Color.is_valid_hexa()
Color.is_valid()
- Added more info to the
README.mdas well as additional links. - Adjusted the structure inside
CHANGELOG.mdfor a better overview and readability.
BREAKING CHANGES:
- Renamed the class
rgb()torgba()to communicate, more clearly, that it supports an alpha channel. - Renamed the class
hsl()tohsla()to communicate, more clearly, that it supports an alpha channel.
- Added project links to the Python-project-file.
- Made some
CHANGELOG.mdimprovements. - Improved
README.md.
- Fixed bug in method
Path.get(base_dir=True):
Previously, settingbase_dirtoTruewould not return the actual base directory or even cause an error.
Settingbase_dirtoTruenow will return the actual base directory of the current program (except if not running from a file).
- New method in the
Pathclass:
Path.remove()
BREAKING CHANGES:
- Corrected the naming of classes to comply with Python naming standards.
- Added support for all OSes to the OS-dependent methods.
- Fixed the
Cmd.cls()method:
There was a bug where only on Windows 10, the ANSI formats weren't cleared.
- Added links to the
CHANGELOG.mdandREADME.mdfiles.
- Changed the default value of the param
compactness: intin the methodData.print()to1instead of0.
- Adjusted the library's description.
- Made it possible to also auto-reset the color and not only the predefined formats, using the auto-reset-format (
[format](Automatically resetting)).
-
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 textFormatCodes.print('[u]/(Automatically resetting) following text')
prints:
(Automatically resetting) following text
- Added
input()method to theFormatCodesclass, so you can make pretty looking input prompts. - Added warning for no network connection when trying to install missing libraries.
-
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.
- Fixed
f-stringissues for Python 3.10:- Not making use of same quotes inside f-strings any more.
- No backslash escaping in f-strings.
At initial release, the library
# 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 |