xulbux 1.6.9__py3-none-any.whl → 1.7.0__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.

xulbux/xx_path.py CHANGED
@@ -23,9 +23,9 @@ class _ScriptDir:
23
23
  base_path = _os.path.dirname(_sys.executable)
24
24
  else:
25
25
  main_module = _sys.modules["__main__"]
26
- if hasattr(main_module, "__file__"):
26
+ if hasattr(main_module, "__file__") and main_module.__file__ is not None:
27
27
  base_path = _os.path.dirname(_os.path.abspath(main_module.__file__))
28
- elif (hasattr(main_module, "__spec__") and main_module.__spec__ and getattr(main_module.__spec__, "origin", None)):
28
+ elif (hasattr(main_module, "__spec__") and main_module.__spec__ and main_module.__spec__.origin is not None):
29
29
  base_path = _os.path.dirname(_os.path.abspath(main_module.__spec__.origin))
30
30
  else:
31
31
  raise RuntimeError("Can only get base directory if accessed from a file.")
@@ -34,15 +34,15 @@ class _ScriptDir:
34
34
 
35
35
  class Path:
36
36
 
37
- cwd: str = _Cwd()
37
+ cwd: str = _Cwd() # type: ignore[assignment]
38
38
  """The path to the current working directory."""
39
- script_dir: str = _ScriptDir()
39
+ script_dir: str = _ScriptDir() # type: ignore[assignment]
40
40
  """The path to the directory of the current script."""
41
41
 
42
42
  @staticmethod
43
43
  def extend(
44
44
  rel_path: str,
45
- search_in: str | list[str] = None,
45
+ search_in: Optional[str | list[str]] = None,
46
46
  raise_error: bool = False,
47
47
  use_closest_match: bool = False,
48
48
  ) -> Optional[str]:
@@ -120,7 +120,7 @@ class Path:
120
120
  @staticmethod
121
121
  def extend_or_make(
122
122
  rel_path: str,
123
- search_in: str | list[str] = None,
123
+ search_in: Optional[str | list[str]] = None,
124
124
  prefer_script_dir: bool = True,
125
125
  use_closest_match: bool = False,
126
126
  ) -> str:
@@ -136,7 +136,7 @@ class Path:
136
136
  If `use_closest_match` is true, it is possible to have typos in the `search_in` path/s
137
137
  and it will still find the file if it is under one of those paths."""
138
138
  try:
139
- return Path.extend(rel_path, search_in, raise_error=True, use_closest_match=use_closest_match)
139
+ return str(Path.extend(rel_path, search_in, raise_error=True, use_closest_match=use_closest_match))
140
140
  except PathNotFoundError:
141
141
  normalized_rel_path = _os.path.normpath(rel_path)
142
142
  base = Path.script_dir if prefer_script_dir else _os.getcwd()
xulbux/xx_regex.py CHANGED
@@ -1,7 +1,12 @@
1
+ from typing import TypeAlias, Optional
1
2
  import regex as _rx
2
3
  import re as _re
3
4
 
4
5
 
6
+ Pattern: TypeAlias = _re.Pattern[str] | _rx.Pattern[str]
7
+ Match: TypeAlias = _re.Match[str] | _rx.Match[str]
8
+
9
+
5
10
  class Regex:
6
11
 
7
12
  @staticmethod
@@ -63,7 +68,7 @@ class Regex:
63
68
  return rf'({"" if is_group else "?:"}(?:(?!{ignore_pattern}).)*(?:(?!{Regex.outside_strings(disallowed_pattern)}).)*)'
64
69
 
65
70
  @staticmethod
66
- def func_call(func_name: str = None) -> str:
71
+ def func_call(func_name: Optional[str] = None) -> str:
67
72
  """Match a function call, and get back two groups:
68
73
  1. function name
69
74
  2. the function's arguments\n
xulbux/xx_system.py CHANGED
@@ -14,7 +14,7 @@ class _IsElevated:
14
14
  if _os.name == "nt":
15
15
  return _ctypes.windll.shell32.IsUserAnAdmin() != 0
16
16
  elif _os.name == "posix":
17
- return _os.geteuid() == 0
17
+ return _os.geteuid() == 0 # type: ignore[attr-defined]
18
18
  except Exception:
19
19
  pass
20
20
  return False
@@ -22,7 +22,7 @@ class _IsElevated:
22
22
 
23
23
  class System:
24
24
 
25
- is_elevated: bool = _IsElevated()
25
+ is_elevated: bool = _IsElevated() # type: ignore[assignment]
26
26
  """Is `True` if the current process has
27
27
  elevated privileges and `False` otherwise."""
28
28
 
@@ -54,7 +54,7 @@ class System:
54
54
  if len(processes) > 2: # EXCLUDING THE PYTHON PROCESS AND PS
55
55
  raise RuntimeError("Processes are still running. Use the parameter `force=True` to restart anyway.")
56
56
  if prompt:
57
- _subprocess.Popen(["notify-send", "System Restart", prompt])
57
+ _subprocess.Popen(["notify-send", "System Restart", str(prompt)])
58
58
  _time.sleep(wait)
59
59
  try:
60
60
  _subprocess.run(["sudo", "shutdown", "-r", "now"])
@@ -95,7 +95,7 @@ class System:
95
95
  return missing
96
96
 
97
97
  @staticmethod
98
- def elevate(win_title: Optional[str] = None, args: Optional[list] = None) -> bool:
98
+ def elevate(win_title: Optional[str] = None, args: list = []) -> bool:
99
99
  """Attempts to start a new process with elevated privileges.\n
100
100
  ---------------------------------------------------------------------------------
101
101
  The param `win_title` is window the title of the elevated process.
@@ -106,7 +106,7 @@ class System:
106
106
  ---------------------------------------------------------------------------------
107
107
  Returns `True` if the current process already has elevated privileges and raises
108
108
  a `PermissionError` if the user denied the elevation or the elevation failed."""
109
- if System.is_elevated():
109
+ if System.is_elevated:
110
110
  return True
111
111
  if _os.name == "nt": # WINDOWS
112
112
  if win_title:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xulbux
3
- Version: 1.6.9
3
+ Version: 1.7.0
4
4
  Summary: A Python library which includes lots of helpful classes, types and functions aiming to make common programming tasks simpler.
5
5
  Author-email: XulbuX <xulbux.real@gmail.com>
6
6
  License-Expression: MIT
@@ -0,0 +1,21 @@
1
+ xulbux/__init__.py,sha256=TbXPioXPENwpR9t4lvqBBhV4cby0JGdIrSzzdMFYrEc,815
2
+ xulbux/_cli_.py,sha256=J4vfJHLJEYxCZzA_VJUB46w2WGShfdYFoetsLG5PfKo,3428
3
+ xulbux/_consts_.py,sha256=AuYTTmqrP2lawyVGlPLUaP1syxOoPA-ejJGH7WlwFzk,6314
4
+ xulbux/xx_code.py,sha256=w9yO-GPMeaE-xDi-L3VtpPpWpu5jOwagfMsG93aXANE,6106
5
+ xulbux/xx_color.py,sha256=ZEV9AG3MtgNMh4t4VexmBiaperan1pHO4d_VPCdv188,49923
6
+ xulbux/xx_console.py,sha256=WmH6YURaA-Y-LNB-2kZc8SuPxoZim8ZmzsuI01V9vcM,28682
7
+ xulbux/xx_data.py,sha256=nEfVwK6-ILaL3K-bLezKpG1G7117CY5ZgC3BGwANrUE,30886
8
+ xulbux/xx_env_path.py,sha256=x56mKK4lSvU5yMCAs8k0RVIqXWUJcpcHYz5HoZ_RklM,4160
9
+ xulbux/xx_file.py,sha256=KerXOvKS93zIoAt36YTYuZboSmxVFVf2WcOrDcdwXfE,2627
10
+ xulbux/xx_format_codes.py,sha256=fOFidFDBYV-rUXOlYTeKIZarfh9Q1jSUCGYyk8pg-ic,23397
11
+ xulbux/xx_json.py,sha256=V7vdfpvSe9wpktR_c8zG_Meix7x9IRmn66k5nB3HUyo,7457
12
+ xulbux/xx_path.py,sha256=lLAEVZrW0TAwCewlONFVQcQ_8tVn9LTJZVOZpeGvE5s,7673
13
+ xulbux/xx_regex.py,sha256=ejqVs4a-eCSTrSQfENoyl0AVztb8BuI2TNl-wzMQwYw,8048
14
+ xulbux/xx_string.py,sha256=QaTo0TQ9m_2USNgQNaVw5ivQt-A1E-e5x8OpIB3xIlY,5561
15
+ xulbux/xx_system.py,sha256=Tsx4wgztUg46KloqcGeiFkarDoM3EgJLXw3XNxgHBmU,6460
16
+ xulbux-1.7.0.dist-info/licenses/LICENSE,sha256=6NflEcvzFEe8_JFVNCPVwZBwBhlLLd4vqQi8WiX_Xk4,1084
17
+ xulbux-1.7.0.dist-info/METADATA,sha256=symGYQzZhSYyGcwM_dGI3FETAcqgTL-ft90CLtJoNlY,9222
18
+ xulbux-1.7.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ xulbux-1.7.0.dist-info/entry_points.txt,sha256=a3womfLIMZKnOFiyy-xnVb4g2qkZsHR5FbKKkljcGns,94
20
+ xulbux-1.7.0.dist-info/top_level.txt,sha256=FkK4EZajwfP36fnlrPaR98OrEvZpvdEOdW1T5zTj6og,7
21
+ xulbux-1.7.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.0.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,21 +0,0 @@
1
- xulbux/__init__.py,sha256=mpAtWO0eumk7FZt6QS1Wvp7KWBsZd8oseSxUPSpAVJk,815
2
- xulbux/_cli_.py,sha256=SaBlkIx73nfU6r2TbjQVWxOM-R0xTBqOAKtgi2FF-KA,3470
3
- xulbux/_consts_.py,sha256=b85O5sePS18z7CJgrVw0V7v88PIG9qnQ7G2bJL71odk,6287
4
- xulbux/xx_code.py,sha256=laA8osWgIW-QSv6P6Am_c6NocOPf8ZSm20EaVfgOC58,6100
5
- xulbux/xx_color.py,sha256=NdNh-J89PXPhVcdgKBXThbRTnq1UpBg3yn4aG0fmRAE,47602
6
- xulbux/xx_console.py,sha256=MJOE3giA6wZW0-VjJmBZaHqnUhOA6vRF41UdkAPIxgk,28019
7
- xulbux/xx_data.py,sha256=zp-DjMJ_VnC-BQQlqdzdgwhnSRzs0MV356AbIjeGgP4,30696
8
- xulbux/xx_env_path.py,sha256=A54TObZZwDvNZwv0iwHzEbNiCoEvz16OId-gMiUTHdo,4086
9
- xulbux/xx_file.py,sha256=Efd7-1FFsXYGd_cH95FwI8Mg6PaA7H11ArBpdBhyVhE,2597
10
- xulbux/xx_format_codes.py,sha256=QXb7ik_JyZJ6agtWykTerkb6NAPhOtOFh7nMpr-bpWo,22912
11
- xulbux/xx_json.py,sha256=-Wzlg8pUIsLlYJKrlxeoXoPprPn8lGJ2Uqc36WYyk6U,7390
12
- xulbux/xx_path.py,sha256=ZCnRJyIO5nigaKJjxNjfEz_4Z_mhBS0ELyJaLU7Lid0,7561
13
- xulbux/xx_regex.py,sha256=oJ7V2ccQNYbnavvCEIyYGVM8001_pjMV1BRu3NGmMJw,7884
14
- xulbux/xx_string.py,sha256=QaTo0TQ9m_2USNgQNaVw5ivQt-A1E-e5x8OpIB3xIlY,5561
15
- xulbux/xx_system.py,sha256=vHuNzxG6fakd4pJ0esJNfGglUtRbqpGJhPODVJqwcV0,6411
16
- xulbux-1.6.9.dist-info/licenses/LICENSE,sha256=6NflEcvzFEe8_JFVNCPVwZBwBhlLLd4vqQi8WiX_Xk4,1084
17
- xulbux-1.6.9.dist-info/METADATA,sha256=1wGLeAPcJPPDMfhB_JsLCM7mphazUEqyVE4HIfoUbHI,9222
18
- xulbux-1.6.9.dist-info/WHEEL,sha256=ooBFpIzZCPdw3uqIQsOo4qqbA4ZRPxHnOH7peeONza0,91
19
- xulbux-1.6.9.dist-info/entry_points.txt,sha256=a3womfLIMZKnOFiyy-xnVb4g2qkZsHR5FbKKkljcGns,94
20
- xulbux-1.6.9.dist-info/top_level.txt,sha256=FkK4EZajwfP36fnlrPaR98OrEvZpvdEOdW1T5zTj6og,7
21
- xulbux-1.6.9.dist-info/RECORD,,