xulbux 1.7.3__py3-none-any.whl → 1.8.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of xulbux might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
- from ._consts_ import COLOR
2
- from .xx_format_codes import FormatCodes
3
- from .xx_string import String
1
+ from .base.consts import COLOR
2
+ from .format_codes import FormatCodes
3
+ from .string import String
4
4
 
5
5
  from typing import TypeAlias, Optional, Union, Any
6
6
  import base64 as _base64
@@ -420,11 +420,11 @@ class Data:
420
420
  elif not isinstance(_syntax_highlighting, dict):
421
421
  raise TypeError(f"Expected 'syntax_highlighting' to be a dict or bool. Got: {type(_syntax_highlighting)}")
422
422
  _syntax_hl = {
423
- "str": (f"[{COLOR.blue}]", "[_c]"),
424
- "number": (f"[{COLOR.magenta}]", "[_c]"),
425
- "literal": (f"[{COLOR.cyan}]", "[_c]"),
426
- "type": (f"[i|{COLOR.lightblue}]", "[_i|_c]"),
427
- "punctuation": (f"[{COLOR.darkgray}]", "[_c]"),
423
+ "str": (f"[{COLOR.BLUE}]", "[_c]"),
424
+ "number": (f"[{COLOR.MAGENTA}]", "[_c]"),
425
+ "literal": (f"[{COLOR.CYAN}]", "[_c]"),
426
+ "type": (f"[i|{COLOR.LIGHT_BLUE}]", "[_i|_c]"),
427
+ "punctuation": (f"[{COLOR.DARK_GRAY}]", "[_c]"),
428
428
  }
429
429
  _syntax_hl.update({
430
430
  k: (f"[{v}]", "[_]") if k in _syntax_hl and v not in ("", None) else ("", "")
@@ -564,14 +564,14 @@ class Data:
564
564
  part. The formatting can be changed by simply adding the key with the new
565
565
  value inside the `syntax_highlighting` dictionary.\n
566
566
  The keys with their default values are:
567
- - `str: COLOR.blue`
568
- - `number: COLOR.magenta`
569
- - `literal: COLOR.cyan`
570
- - `type: "i|" + COLOR.lightblue`
571
- - `punctuation: COLOR.darkgray`\n
567
+ - `str: COLOR.BLUE`
568
+ - `number: COLOR.MAGENTA`
569
+ - `literal: COLOR.CYAN`
570
+ - `type: "i|" + COLOR.LIGHT_BLUE`
571
+ - `punctuation: COLOR.DARK_GRAY`\n
572
572
  For no syntax highlighting, set `syntax_highlighting` to `False` or `None`.\n
573
573
  ------------------------------------------------------------------------------
574
- For more detailed information about formatting codes, see `xx_format_codes`
574
+ For more detailed information about formatting codes, see `format_codes`
575
575
  module documentation."""
576
576
  FormatCodes.print(
577
577
  Data.to_str(data, indent, compactness, max_width, sep, as_json, syntax_highlighting),
@@ -1,4 +1,4 @@
1
- from .xx_path import Path
1
+ from .path import Path
2
2
 
3
3
  from typing import Optional
4
4
  import sys as _sys
@@ -1,4 +1,4 @@
1
- from .xx_string import String
1
+ from .string import String
2
2
 
3
3
  import os as _os
4
4
 
@@ -157,10 +157,10 @@ Per default, you can also use `+` and `-` to get lighter and darker `default_col
157
157
  All of these lighten/darken formatting codes are treated as invalid if no `default_color` is set.
158
158
  """
159
159
 
160
- from ._consts_ import ANSI
161
- from .xx_string import String
162
- from .xx_regex import Regex, Match, Pattern
163
- from .xx_color import Color, rgba, Rgba, Hexa
160
+ from .base.consts import ANSI
161
+ from .string import String
162
+ from .regex import Regex, Match, Pattern
163
+ from .color import Color, rgba, Rgba, Hexa
164
164
 
165
165
  from typing import Optional, cast
166
166
  import ctypes as _ctypes
@@ -187,7 +187,7 @@ _PREFIX_RX: dict[str, str] = {
187
187
  _COMPILED: dict[str, Pattern] = { # PRECOMPILE REGULAR EXPRESSIONS
188
188
  "*": _re.compile(r"\[\s*([^]_]*?)\s*\*\s*([^]_]*?)\]"),
189
189
  "*color": _re.compile(r"\[\s*([^]_]*?)\s*\*c(?:olor)?\s*([^]_]*?)\]"),
190
- "ansi_seq": _re.compile(ANSI.char + r"(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])"),
190
+ "ansi_seq": _re.compile(ANSI.CHAR + r"(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])"),
191
191
  "formatting": _rx.compile(
192
192
  Regex.brackets("[", "]", is_group=True, ignore_in_strings=False)
193
193
  + r"(?:\s*([/\\]?)\s*"
@@ -226,7 +226,7 @@ class FormatCodes:
226
226
  """A print function, whose print values can be formatted using formatting codes.\n
227
227
  -----------------------------------------------------------------------------------
228
228
  For exact information about how to use special formatting codes, see the
229
- `xx_format_codes` module documentation."""
229
+ `format_codes` module documentation."""
230
230
  FormatCodes.__config_console()
231
231
  _sys.stdout.write(FormatCodes.to_ansi(sep.join(map(str, values)) + end, default_color, brightness_steps))
232
232
  if flush:
@@ -245,11 +245,11 @@ class FormatCodes:
245
245
  user confirms the input and the program continues to run.\n
246
246
  -------------------------------------------------------------------------
247
247
  For exact information about how to use special formatting codes, see the
248
- `xx_format_codes` module documentation."""
248
+ `format_codes` module documentation."""
249
249
  FormatCodes.__config_console()
250
250
  user_input = input(FormatCodes.to_ansi(str(prompt), default_color, brightness_steps))
251
251
  if reset_ansi:
252
- _sys.stdout.write(f"{ANSI.char}[0m")
252
+ _sys.stdout.write(f"{ANSI.CHAR}[0m")
253
253
  return user_input
254
254
 
255
255
  @staticmethod
@@ -263,7 +263,7 @@ class FormatCodes:
263
263
  """Convert the formatting codes inside a string to ANSI formatting.\n
264
264
  -------------------------------------------------------------------------
265
265
  For exact information about how to use special formatting codes, see the
266
- `xx_format_codes` module documentation."""
266
+ `format_codes` module documentation."""
267
267
  if not isinstance(string, str):
268
268
  string = str(string)
269
269
  use_default, default_specified = False, default_color is not None
@@ -284,7 +284,7 @@ class FormatCodes:
284
284
  string = _COMPILED["*"].sub(r"[\1_\2]", string) # REPLACE `[…|*|…]` WITH `[…|_|…]`
285
285
 
286
286
  def is_valid_color(color: str) -> bool:
287
- return bool((color in ANSI.color_map) or Color.is_valid_rgba(color) or Color.is_valid_hexa(color))
287
+ return bool((color in ANSI.COLOR_MAP) or Color.is_valid_rgba(color) or Color.is_valid_hexa(color))
288
288
 
289
289
  def replace_keys(match: Match) -> str:
290
290
  _formats = formats = match.group(1)
@@ -339,12 +339,12 @@ class FormatCodes:
339
339
  reset_keys.append(f"_{k}")
340
340
  ansi_resets = [
341
341
  r for k in reset_keys if (r := FormatCodes.__get_replacement(k, default_color, brightness_steps)
342
- ).startswith(f"{ANSI.char}{ANSI.start}")
342
+ ).startswith(f"{ANSI.CHAR}{ANSI.START}")
343
343
  ]
344
344
  else:
345
345
  ansi_resets = []
346
- if not (len(ansi_formats) == 1 and ansi_formats[0].count(f"{ANSI.char}{ANSI.start}") >= 1) and not all(
347
- f.startswith(f"{ANSI.char}{ANSI.start}") for f in ansi_formats): # FORMATTING WAS INVALID
346
+ if not (len(ansi_formats) == 1 and ansi_formats[0].count(f"{ANSI.CHAR}{ANSI.START}") >= 1) and not all(
347
+ f.startswith(f"{ANSI.CHAR}{ANSI.START}") for f in ansi_formats): # FORMATTING WAS INVALID
348
348
  return match.group(0)
349
349
  elif formats_escaped: # FORMATTING WAS VALID BUT ESCAPED
350
350
  return f"[{_formats}]({auto_reset_txt})" if auto_reset_txt else f"[{_formats}]"
@@ -363,7 +363,7 @@ class FormatCodes:
363
363
  @staticmethod
364
364
  def escape_ansi(ansi_string: str) -> str:
365
365
  """Escapes all ANSI codes in the string, so they are visible when output to the console."""
366
- return ansi_string.replace(ANSI.char, ANSI.escaped_char)
366
+ return ansi_string.replace(ANSI.CHAR, ANSI.ESCAPED_CHAR)
367
367
 
368
368
  @staticmethod
369
369
  def remove_ansi(
@@ -437,7 +437,7 @@ class FormatCodes:
437
437
  return None
438
438
  _default_color: tuple[int, int, int] = tuple(default_color)[:3]
439
439
  if brightness_steps is None or (format_key and _COMPILED["bg?_default"].search(format_key)):
440
- return (ANSI.seq_bg_color if format_key and _COMPILED["bg_default"].search(format_key) else ANSI.seq_color).format(
440
+ return (ANSI.SEQ_BG_COLOR if format_key and _COMPILED["bg_default"].search(format_key) else ANSI.SEQ_COLOR).format(
441
441
  *_default_color
442
442
  )
443
443
  if format_key is None or not (format_key in _modifiers[0] or format_key in _modifiers[1]):
@@ -459,7 +459,7 @@ class FormatCodes:
459
459
  new_rgb = tuple(Color.adjust_lightness(default_color, (brightness_steps / 100) * adjust))
460
460
  elif modifiers in _modifiers[1]:
461
461
  new_rgb = tuple(Color.adjust_lightness(default_color, -(brightness_steps / 100) * adjust))
462
- return (ANSI.seq_bg_color if is_bg else ANSI.seq_color).format(*new_rgb[:3])
462
+ return (ANSI.SEQ_BG_COLOR if is_bg else ANSI.SEQ_COLOR).format(*new_rgb[:3])
463
463
 
464
464
  @staticmethod
465
465
  def __get_replacement(format_key: str, default_color: Optional[rgba], brightness_steps: int = 20) -> str:
@@ -470,11 +470,11 @@ class FormatCodes:
470
470
  if default_color and (new_default_color := FormatCodes.__get_default_ansi(default_color, format_key,
471
471
  brightness_steps)):
472
472
  return new_default_color
473
- for map_key in ANSI.codes_map:
473
+ for map_key in ANSI.CODES_MAP:
474
474
  if (isinstance(map_key, tuple) and format_key in map_key) or format_key == map_key:
475
475
  return _ANSI_SEQ_1.format(
476
476
  next((
477
- v for k, v in ANSI.codes_map.items() if format_key == k or (isinstance(k, tuple) and format_key in k)
477
+ v for k, v in ANSI.CODES_MAP.items() if format_key == k or (isinstance(k, tuple) and format_key in k)
478
478
  ), None)
479
479
  )
480
480
  rgb_match = _COMPILED["rgb"].match(format_key)
@@ -484,13 +484,13 @@ class FormatCodes:
484
484
  is_bg = rgb_match.group(1)
485
485
  r, g, b = map(int, rgb_match.groups()[1:])
486
486
  if Color.is_valid_rgba((r, g, b)):
487
- return ANSI.seq_bg_color.format(r, g, b) if is_bg else ANSI.seq_color.format(r, g, b)
487
+ return ANSI.SEQ_BG_COLOR.format(r, g, b) if is_bg else ANSI.SEQ_COLOR.format(r, g, b)
488
488
  elif hex_match:
489
489
  is_bg = hex_match.group(1)
490
490
  rgb = Color.to_rgba(hex_match.group(2))
491
491
  return (
492
- ANSI.seq_bg_color.format(rgb[0], rgb[1], rgb[2])
493
- if is_bg else ANSI.seq_color.format(rgb[0], rgb[1], rgb[2])
492
+ ANSI.SEQ_BG_COLOR.format(rgb[0], rgb[1], rgb[2])
493
+ if is_bg else ANSI.SEQ_COLOR.format(rgb[0], rgb[1], rgb[2])
494
494
  )
495
495
  except Exception:
496
496
  pass
@@ -1,6 +1,6 @@
1
- from .xx_data import Data
2
- from .xx_file import File
3
- from .xx_path import Path
1
+ from .data import Data
2
+ from .file import File
3
+ from .path import Path
4
4
 
5
5
  from typing import Any
6
6
  import json as _json
@@ -23,16 +23,16 @@ class _IsElevated:
23
23
  class System:
24
24
 
25
25
  is_elevated: bool = _IsElevated() # type: ignore[assignment]
26
- """Is `True` if the current process has
27
- elevated privileges and `False` otherwise."""
26
+ """Is `True` if the current process has elevated privileges and `False` otherwise."""
28
27
 
29
28
  @staticmethod
30
- def restart(prompt: object = None, wait: int = 0, continue_program: bool = False, force: bool = False) -> None:
31
- """Starts a system restart:
32
- - `prompt` is the message to be displayed in the systems restart notification.
33
- - `wait` is the time to wait until restarting in seconds.
34
- - `continue_program` is whether to continue the current Python program after calling this function.
35
- - `force` is whether to force a restart even if other processes are still running."""
29
+ def restart(prompt: object = "", wait: int = 0, continue_program: bool = False, force: bool = False) -> None:
30
+ """Restarts the system with some advanced options\n
31
+ --------------------------------------------------------------------------------------------------
32
+ - `prompt` -⠀the message to be displayed in the systems restart notification
33
+ - `wait` -⠀the time to wait until restarting in seconds
34
+ - `continue_program` -⠀whether to continue the current Python program after calling this function
35
+ - `force` -⠀whether to force a restart even if other processes are still running"""
36
36
  system = _platform.system().lower()
37
37
  if system == "windows":
38
38
  if not force:
@@ -69,9 +69,9 @@ class System:
69
69
  @staticmethod
70
70
  def check_libs(lib_names: list[str], install_missing: bool = False, confirm_install: bool = True) -> Optional[list[str]]:
71
71
  """Checks if the given list of libraries are installed. If not:
72
- - If `install_missing` is `False` the missing libraries will be returned as a list.
73
- - If `install_missing` is `True` the missing libraries will be installed.
74
- - If `confirm_install` is `True` the user will first be asked if they want to install the missing libraries."""
72
+ - If `install_missing` is false, the missing libraries will be returned as a list.
73
+ - If `install_missing` is true, the missing libraries will be installed.
74
+ - If `confirm_install` is true, the user will first be asked if they want to install the missing libraries."""
75
75
  missing = []
76
76
  for lib in lib_names:
77
77
  try:
@@ -0,0 +1,190 @@
1
+ Metadata-Version: 2.4
2
+ Name: xulbux
3
+ Version: 1.8.1
4
+ Summary: A Python library which includes lots of helpful classes, types and functions aiming to make common programming tasks simpler.
5
+ Author-email: XulbuX <xulbux.real@gmail.com>
6
+ Maintainer-email: XulbuX <xulbux.real@gmail.com>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/XulbuX/PythonLibraryXulbuX
9
+ Project-URL: Documentation, https://github.com/XulbuX/PythonLibraryXulbuX/wiki
10
+ Project-URL: Source Code, https://github.com/XulbuX/PythonLibraryXulbuX/tree/main/src
11
+ Project-URL: Changelog, https://github.com/XulbuX/PythonLibraryXulbuX/blob/main/CHANGELOG.md
12
+ Project-URL: Bug Reports, https://github.com/XulbuX/PythonLibraryXulbuX/issues
13
+ Project-URL: Stats, https://clickpy.clickhouse.com/dashboard/xulbux
14
+ Project-URL: License, https://github.com/XulbuX/PythonLibraryXulbuX/blob/main/LICENSE
15
+ Keywords: args,arguments,attributes,classes,client,cmd,code,codes,color,commands,console,constants,consts,conversion,convert,data,debug,easier,env,environment,error,file,format,formatting,functions,helper,hex,hexa,hsl,hsla,info,input,json,library,log,logging,methods,nice,operations,path,presets,pretty,printing,properties,python,re,regex,rgb,rgba,string,structures,system,tools,types,utility,warn,warning,xulbux
16
+ Classifier: Development Status :: 5 - Production/Stable
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Operating System :: OS Independent
22
+ Classifier: Intended Audience :: Developers
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.10.0
25
+ Description-Content-Type: text/markdown
26
+ Requires-Dist: keyboard>=0.13.5
27
+ Requires-Dist: prompt_toolkit>=3.0.41
28
+ Requires-Dist: pyperclip>=1.9.0
29
+ Requires-Dist: regex>=2023.10.3
30
+ Provides-Extra: dev
31
+ Requires-Dist: black>=23.7.0; extra == "dev"
32
+ Requires-Dist: flake8-pyproject>=1.2.3; extra == "dev"
33
+ Requires-Dist: flake8>=6.1.0; extra == "dev"
34
+ Requires-Dist: isort>=5.12.0; extra == "dev"
35
+ Requires-Dist: pytest>=7.4.2; extra == "dev"
36
+
37
+ # **XulbuX**
38
+
39
+ [![](https://img.shields.io/pypi/v/xulbux?labelColor=404560&color=7075FF)](https://pypi.org/project/xulbux) [![](https://img.shields.io/pepy/dt/xulbux?labelColor=404560&color=7075FF)](https://clickpy.clickhouse.com/dashboard/xulbux) [![](https://img.shields.io/github/license/XulbuX/PythonLibraryXulbuX?labelColor=405555&color=70FFEE)](https://github.com/XulbuX/PythonLibraryXulbuX/blob/main/LICENSE) [![](https://img.shields.io/github/last-commit/XulbuX/PythonLibraryXulbuX?labelColor=554045&color=FF6065)](https://github.com/XulbuX/PythonLibraryXulbuX/commits) [![](https://img.shields.io/github/issues/XulbuX/PythonLibraryXulbuX?labelColor=554045&color=FF6065)](https://github.com/XulbuX/PythonLibraryXulbuX/issues)
40
+
41
+ **XulbuX** is a library that contains many useful classes, types, and functions,
42
+ ranging from console logging and working with colors to file management and system operations.
43
+ The library is designed to simplify common programming tasks and improve code readability through its collection of tools.
44
+
45
+ For precise information about the library, see the library's [**documentation**](https://github.com/XulbuX/PythonLibraryXulbuX/wiki).<br>
46
+ For the libraries latest changes and updates, see the [**change log**](https://github.com/XulbuX/PythonLibraryXulbuX/blob/main/CHANGELOG.md).
47
+
48
+ ### The best modules, you have to check out:
49
+
50
+ [![format_codes](https://img.shields.io/badge/format__codes-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/format_codes) [![console](https://img.shields.io/badge/console-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/console) [![color](https://img.shields.io/badge/color-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/color)
51
+
52
+ <br>
53
+
54
+ ## Installation
55
+
56
+ Run the following commands in a console with administrator privileges, so the actions take effect for all users.
57
+
58
+ Install the library and all its dependencies with the command:
59
+ ```console
60
+ pip install xulbux
61
+ ```
62
+
63
+ Upgrade the library and all its dependencies to their latest available version with the command:
64
+ ```console
65
+ pip install --upgrade xulbux
66
+ ```
67
+
68
+ <br>
69
+
70
+ ## CLI Commands
71
+
72
+ When the library is installed, the following commands are available in the console:
73
+ | Command | Description |
74
+ | :------------ | :--------------------------------------- |
75
+ | `xulbux-help` | shows some information about the library |
76
+
77
+ <br>
78
+
79
+ ## Usage
80
+
81
+ Import the full library under the alias `xx`, so its constants, classes, methods, and types are accessible with `xx.CONSTANT.value`, `xx.Class.method()`, `xx.type()`:
82
+ ```python
83
+ import xulbux as xx
84
+ ```
85
+ 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:
86
+ ```python
87
+ # LIBRARY CONSTANTS
88
+ from xulbux.base.consts import COLOR, CHARS, ANSI
89
+ # Main Classes
90
+ from xulbux import Code, Color, Console, ...
91
+ # module specific imports
92
+ from xulbux.color import rgba, hsla, hexa
93
+ ```
94
+
95
+ <br>
96
+
97
+ ## Modules
98
+
99
+ | Module | Short Description |
100
+ | :-------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------ |
101
+ | [![base](https://img.shields.io/badge/base-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/base) | includes more modules like library constants |
102
+ | [![code](https://img.shields.io/badge/code-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/code) | advanced code-string operations (*changing the indent, finding function calls, ...*) |
103
+ | [![color](https://img.shields.io/badge/color-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/color) | everything around colors (*converting, blending, searching colors in strings, ...*) |
104
+ | [![console](https://img.shields.io/badge/console-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/console) | advanced actions related to the console (*pretty logging, advanced inputs, ...*) |
105
+ | [![data](https://img.shields.io/badge/data-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/data) | advanced operations with data structures (*compare, generate path IDs, pretty print, ...*) |
106
+ | [![env_path](https://img.shields.io/badge/env__path-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/env_path) | getting and editing the PATH variable (*get paths, check for paths, add paths, ...*) |
107
+ | [![file](https://img.shields.io/badge/file-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/file) | advanced working with files (*create files, rename file-extensions, ...*) |
108
+ | [![format_codes](https://img.shields.io/badge/format__codes-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/format_codes) | easy pretty printing using custom format codes (*print, inputs, format codes to ANSI, ...*) |
109
+ | [![json](https://img.shields.io/badge/json-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/json) | advanced working with json files (*read, create, update, ...*) |
110
+ | [![path](https://img.shields.io/badge/path-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/path) | advanced path operations (*get paths, smart-extend relative paths, delete paths, ...*) |
111
+ | [![regex](https://img.shields.io/badge/regex-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/regex) | generated regex pattern-templates (*match bracket- and quote pairs, match colors, ...*) |
112
+ | [![string](https://img.shields.io/badge/string-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/string) | helpful actions when working with strings. (*normalize, escape, decompose, ...*) |
113
+ | [![system](https://img.shields.io/badge/system-FF7E58?style=for-the-badge)](https://github.com/XulbuX/PythonLibraryXulbuX/wiki/system) | advanced system actions (*restart with message, check installed Python libs, ...*) |
114
+
115
+ <br>
116
+
117
+ ## Example Usage
118
+
119
+ This is what it could look like using this library for a simple but ultra good-looking color converter:
120
+ ```python
121
+ from xulbux.base.consts import COLOR, CHARS
122
+ from xulbux.color import hexa
123
+ from xulbux import Console
124
+
125
+
126
+ def main() -> None:
127
+
128
+ # LET THE USER ENTER A HEXA COLOR IN ANY HEXA FORMAT
129
+ input_clr = Console.input(
130
+ "[b](Enter a HEXA color in any format) > ",
131
+ start="\n",
132
+ placeholder="#7075FF",
133
+ max_len=7,
134
+ allowed_chars=CHARS.HEX_DIGITS,
135
+ )
136
+
137
+ # ANNOUNCE INDEXING THE INPUT COLOR
138
+ Console.log(
139
+ "INDEX",
140
+ "Indexing the input HEXA color...",
141
+ start="\n",
142
+ title_bg_color=COLOR.BLUE,
143
+ )
144
+
145
+ try:
146
+ # TRY TO CONVERT THE INPUT COLOR INTO A hexa() COLOR
147
+ hexa_color = hexa(input_clr)
148
+
149
+ except ValueError:
150
+ # ANNOUNCE THE ERROR AND EXIT THE PROGRAM
151
+ Console.fail(
152
+ "The input HEXA color is invalid.",
153
+ end="\n\n",
154
+ exit=True,
155
+ )
156
+
157
+ # ANNOUNCE STARTING THE CONVERSION
158
+ Console.log(
159
+ "CONVERT",
160
+ "Converting the HEXA color into different types...",
161
+ title_bg_color=COLOR.TANGERINE,
162
+ )
163
+
164
+ # CONVERT THE HEXA COLOR INTO THE TWO OTHER COLOR TYPES
165
+ rgba_color = hexa_color.to_rgba()
166
+ hsla_color = hexa_color.to_hsla()
167
+
168
+ # ANNOUNCE THE SUCCESSFUL CONVERSION
169
+ Console.done(
170
+ "Successfully converted color into different types.",
171
+ end="\n\n",
172
+ )
173
+
174
+ # PRETTY PRINT THE COLOR IN DIFFERENT TYPES
175
+ Console.log_box_bordered(
176
+ f"[b](HEXA:) [i|white]({hexa_color})",
177
+ f"[b](RGBA:) [i|white]({rgba_color})",
178
+ f"[b](HSLA:) [i|white]({hsla_color})",
179
+ )
180
+
181
+
182
+ if __name__ == "__main__":
183
+ main()
184
+ ```
185
+
186
+ <br>
187
+ <br>
188
+
189
+ --------------------------------------------------------------
190
+ [View this library on **PyPI**](https://pypi.org/project/xulbux)
@@ -0,0 +1,20 @@
1
+ xulbux/__init__.py,sha256=FkJeare6GgT7xau1OcZVKoLk3uUOULFWdP2DYzOCW58,817
2
+ xulbux/code.py,sha256=CLA3wh6mTvcXTlQgBeFaaLIBciHvXWqVM56rAtfO-JE,6102
3
+ xulbux/color.py,sha256=XCB05xBSEz6-dpX9yVkMB2zTSdTH01MfUazJEthL_zM,49741
4
+ xulbux/console.py,sha256=U9t4Fd_ZGrdhTf8KMKJJqw12aijpur3b9J3rlEgntW4,43164
5
+ xulbux/data.py,sha256=hB9JxrSC7_6kelJ_TwOaapNrlig-jiyNZS3YoiJX8F8,30884
6
+ xulbux/env_path.py,sha256=HGOSffdIDubzczsXe6umyqotrzqhIW83QBkISAamXT8,4157
7
+ xulbux/file.py,sha256=7pa0-WS_DpXq7HRB1fLS6Acd9CM-ozXPpNJvMqCW4fw,2624
8
+ xulbux/format_codes.py,sha256=94VyxnUZI2dS1glteNs7izKYrTI_W2pukFGF5f9k72E,24720
9
+ xulbux/json.py,sha256=Ei5FdCjfM0FrrAEBmuuTcexl7mUY4eirXr-QPct2OS0,7448
10
+ xulbux/path.py,sha256=lLAEVZrW0TAwCewlONFVQcQ_8tVn9LTJZVOZpeGvE5s,7673
11
+ xulbux/regex.py,sha256=_BtMHRDNcD9zF4SL87dQuUVZcYGfZx9H5YNSDiEtzm8,8059
12
+ xulbux/string.py,sha256=QaTo0TQ9m_2USNgQNaVw5ivQt-A1E-e5x8OpIB3xIlY,5561
13
+ xulbux/system.py,sha256=Y5x719Ocwi93VJ6DVE8NR_Js7FQ6QT5wmtjX9FAsw9U,6582
14
+ xulbux/base/consts.py,sha256=HwgI_Cr_U2QznezN17SP1j-gpyf3tsbu_KHMd8aKzyw,5918
15
+ xulbux/cli/help.py,sha256=QtyAqHEC_0p3qvLXdUBlpvjV9khPy70-po7CQOz1Fag,3314
16
+ xulbux-1.8.1.dist-info/METADATA,sha256=Z3S8mdtlmI85R3M3Ks38oUUnx4vzBn91_N3CJabSUIo,11041
17
+ xulbux-1.8.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
+ xulbux-1.8.1.dist-info/entry_points.txt,sha256=aYh89GfiBOB8vw2VPgC6rhBinhnJoAL1kig-3lq_zkg,58
19
+ xulbux-1.8.1.dist-info/top_level.txt,sha256=FkK4EZajwfP36fnlrPaR98OrEvZpvdEOdW1T5zTj6og,7
20
+ xulbux-1.8.1.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ xulbux-help = xulbux.cli.help:show_help
xulbux/_cli_.py DELETED
@@ -1,46 +0,0 @@
1
- from ._consts_ import COLOR
2
- from . import __version__
3
- from .xx_format_codes import FormatCodes
4
- from .xx_console import Console
5
-
6
-
7
- def help_command():
8
- """Show some info about the library, with a brief explanation of how to use it."""
9
- color = {
10
- "class": COLOR.tangerine,
11
- "const": COLOR.red,
12
- "func": COLOR.cyan,
13
- "import": COLOR.neongreen,
14
- "lib": COLOR.orange,
15
- "punctuators": COLOR.darkgray,
16
- "code_border": COLOR.gray,
17
- }
18
- FormatCodes.print(
19
- rf""" [_|b|#7075FF] __ __
20
- [b|#7075FF] _ __ __ __/ / / /_ __ ___ __
21
- [b|#7075FF] | |/ // / / / / / __ \/ / / | |/ /
22
- [b|#7075FF] > , </ /_/ / /_/ /_/ / /_/ /> , <
23
- [b|#7075FF]/_/|_|\____/\__/\____/\____//_/|_| [*|BG:{COLOR.gray}|#000] v[b]{__version__} [*]
24
-
25
- [i|{COLOR.coral}]A TON OF COOL FUNCTIONS, YOU NEED![*]
26
-
27
- [b|#FCFCFF]Usage:[*]
28
- [dim|{color['code_border']}](╭────────────────────────────────────────────────────╮)
29
- [dim|{color['code_border']}](│) [{color['punctuators']}]# CONSTANTS[*] [dim|{color['code_border']}](│)
30
- [dim|{color['code_border']}](│) [{color['import']}]from [{color['lib']}]xulbux [{color['import']}]import [{color['const']}]COLOR[{color['punctuators']}], [{color['const']}]CHARS[{color['punctuators']}], [{color['const']}]ANSI[*] [dim|{color['code_border']}](│)
31
- [dim|{color['code_border']}](│) [{color['punctuators']}]# Classes[*] [dim|{color['code_border']}](│)
32
- [dim|{color['code_border']}](│) [{color['import']}]from [{color['lib']}]xulbux [{color['import']}]import [{color['class']}]Code[{color['punctuators']}], [{color['class']}]Color[{color['punctuators']}], [{color['class']}]Console[{color['punctuators']}], ...[*] [dim|{color['code_border']}](│)
33
- [dim|{color['code_border']}](│) [{color['punctuators']}]# types[*] [dim|{color['code_border']}](│)
34
- [dim|{color['code_border']}](│) [{color['import']}]from [{color['lib']}]xulbux [{color['import']}]import [{color['func']}]rgba[{color['punctuators']}], [{color['func']}]hsla[{color['punctuators']}], [{color['func']}]hexa[*] [dim|{color['code_border']}](│)
35
- [dim|{color['code_border']}](╰────────────────────────────────────────────────────╯)
36
- [b|#FCFCFF]Documentation:[*]
37
- [dim|{color['code_border']}](╭────────────────────────────────────────────────────╮)
38
- [dim|{color['code_border']}](│) [#DADADD]For more information see the GitHub page. [dim|{color['code_border']}](│)
39
- [dim|{color['code_border']}](│) [u|#8085FF](https://github.com/XulbuX/PythonLibraryXulbuX/wiki) [dim|{color['code_border']}](│)
40
- [dim|{color['code_border']}](╰────────────────────────────────────────────────────╯)
41
- [_]
42
- [dim](Press any key to exit...)
43
- """,
44
- default_color=COLOR.text
45
- )
46
- Console.pause_exit(pause=True)