danielutils 0.9.62__tar.gz → 0.9.64__tar.gz

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.
Files changed (119) hide show
  1. {danielutils-0.9.62 → danielutils-0.9.64}/PKG-INFO +3 -2
  2. {danielutils-0.9.62 → danielutils-0.9.64}/README.md +1 -1
  3. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/__init__.py +1 -1
  4. {danielutils-0.9.62/danielutils/Conversions → danielutils-0.9.64/danielutils/conversions}/specialized_conversions/to_hex.py +1 -1
  5. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/__init__.py +1 -1
  6. danielutils-0.9.64/danielutils/files_and_folders.py +435 -0
  7. danielutils-0.9.64/danielutils/metaclasses/__init__.py +5 -0
  8. {danielutils-0.9.62/danielutils/Reflection → danielutils-0.9.64/danielutils/reflection}/__init__.py +5 -5
  9. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils.egg-info/PKG-INFO +3 -2
  10. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils.egg-info/SOURCES.txt +20 -74
  11. {danielutils-0.9.62 → danielutils-0.9.64}/pyproject.toml +1 -1
  12. {danielutils-0.9.62 → danielutils-0.9.64}/setup.py +1 -1
  13. danielutils-0.9.62/danielutils/MetaClasses/__init__.py +0 -5
  14. {danielutils-0.9.62 → danielutils-0.9.64}/LISENCE +0 -0
  15. /danielutils-0.9.62/danielutils/Aliases.py → /danielutils-0.9.64/danielutils/aliases.py +0 -0
  16. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/Convenience.py +0 -0
  17. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/Counter.py +0 -0
  18. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/Tree.py +0 -0
  19. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/__init__.py +0 -0
  20. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/frange.py +0 -0
  21. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/repl.py +0 -0
  22. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/sorted_builtins/__init__.py +0 -0
  23. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/sorted_builtins/sset.py +0 -0
  24. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/typed_builtins/__init__.py +0 -0
  25. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/typed_builtins/factory.py +0 -0
  26. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/typed_builtins/tdict.py +0 -0
  27. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/typed_builtins/tlist.py +0 -0
  28. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/typed_builtins/tset.py +0 -0
  29. {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.64/danielutils/classes}/typed_builtins/ttuple.py +0 -0
  30. /danielutils-0.9.62/danielutils/Colors.py → /danielutils-0.9.64/danielutils/colors.py +0 -0
  31. {danielutils-0.9.62/danielutils/Conversions → danielutils-0.9.64/danielutils/conversions}/__init__.py +0 -0
  32. {danielutils-0.9.62/danielutils/Conversions → danielutils-0.9.64/danielutils/conversions}/main_conversions.py +0 -0
  33. {danielutils-0.9.62/danielutils/Conversions → danielutils-0.9.64/danielutils/conversions}/specialized_conversions/__init__.py +0 -0
  34. {danielutils-0.9.62/danielutils/Conversions → danielutils-0.9.64/danielutils/conversions}/specialized_conversions/to_int.py +0 -0
  35. /danielutils-0.9.62/danielutils/data_structures/comparer.py → /danielutils-0.9.64/danielutils/data_structures/Comparer.py +0 -0
  36. /danielutils-0.9.62/danielutils/data_structures/graph.py → /danielutils-0.9.64/danielutils/data_structures/Graph.py +0 -0
  37. /danielutils-0.9.62/danielutils/data_structures/heap.py → /danielutils-0.9.64/danielutils/data_structures/Heap.py +0 -0
  38. /danielutils-0.9.62/danielutils/data_structures/node.py → /danielutils-0.9.64/danielutils/data_structures/Node.py +0 -0
  39. /danielutils-0.9.62/danielutils/data_structures/queue.py → /danielutils-0.9.64/danielutils/data_structures/Queue.py +0 -0
  40. /danielutils-0.9.62/danielutils/data_structures/stack.py → /danielutils-0.9.64/danielutils/data_structures/Stack.py +0 -0
  41. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/data_structures/__init__.py +0 -0
  42. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/data_structures/default_dict.py +0 -0
  43. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/data_structures/functions.py +0 -0
  44. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/date.py +0 -0
  45. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/date_time.py +0 -0
  46. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/atomic.py +0 -0
  47. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/attach.py +0 -0
  48. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/chain_decorators.py +0 -0
  49. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/decorate_conditionally.py +0 -0
  50. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/delay_call.py +0 -0
  51. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/deprecate.py +0 -0
  52. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/limit_recursion.py +0 -0
  53. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/memo.py +0 -0
  54. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/overload.py +0 -0
  55. /danielutils-0.9.62/danielutils/Decorators/PartiallyImplemented.py → /danielutils-0.9.64/danielutils/decorators/partially_implemented.py +0 -0
  56. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/processify.py +0 -0
  57. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/property.py +0 -0
  58. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/threadify.py +0 -0
  59. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/timeout.py +0 -0
  60. {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.64/danielutils/decorators}/validate.py +0 -0
  61. /danielutils-0.9.62/danielutils/Exceptions.py → /danielutils-0.9.64/danielutils/exceptions.py +0 -0
  62. {danielutils-0.9.62/danielutils/Functions → danielutils-0.9.64/danielutils/functions}/__init__.py +0 -0
  63. {danielutils-0.9.62/danielutils/Functions → danielutils-0.9.64/danielutils/functions}/areoneof.py +0 -0
  64. {danielutils-0.9.62/danielutils/Functions → danielutils-0.9.64/danielutils/functions}/check_foreach.py +0 -0
  65. {danielutils-0.9.62/danielutils/Functions → danielutils-0.9.64/danielutils/functions}/isoftype.py +0 -0
  66. {danielutils-0.9.62/danielutils/Functions → danielutils-0.9.64/danielutils/functions}/isoneof.py +0 -0
  67. {danielutils-0.9.62/danielutils/Functions → danielutils-0.9.64/danielutils/functions}/powerset.py +0 -0
  68. {danielutils-0.9.62/danielutils/Functions → danielutils-0.9.64/danielutils/functions}/types_subseteq.py +0 -0
  69. {danielutils-0.9.62/danielutils/Generators → danielutils-0.9.64/danielutils/generators}/__init__.py +0 -0
  70. {danielutils-0.9.62/danielutils/Generators → danielutils-0.9.64/danielutils/generators}/conditional_generator.py +0 -0
  71. {danielutils-0.9.62/danielutils/Generators → danielutils-0.9.64/danielutils/generators}/generator_from_stream.py +0 -0
  72. {danielutils-0.9.62/danielutils/Generators → danielutils-0.9.64/danielutils/generators}/join_generators.py +0 -0
  73. /danielutils-0.9.62/danielutils/Internet.py → /danielutils-0.9.64/danielutils/internet.py +0 -0
  74. /danielutils-0.9.62/danielutils/IO.py → /danielutils-0.9.64/danielutils/io.py +0 -0
  75. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/loops.py +0 -0
  76. {danielutils-0.9.62/danielutils/Math → danielutils-0.9.64/danielutils/math}/__init__.py +0 -0
  77. /danielutils-0.9.62/danielutils/Math/Constants.py → /danielutils-0.9.64/danielutils/math/constants.py +0 -0
  78. /danielutils-0.9.62/danielutils/Math/Functions.py → /danielutils-0.9.64/danielutils/math/functions.py +0 -0
  79. {danielutils-0.9.62/danielutils/Math → danielutils-0.9.64/danielutils/math}/math_print.py +0 -0
  80. {danielutils-0.9.62/danielutils/Math → danielutils-0.9.64/danielutils/math}/math_symbols.py +0 -0
  81. {danielutils-0.9.62/danielutils/MetaClasses → danielutils-0.9.64/danielutils/metaclasses}/Interface.py +0 -0
  82. /danielutils-0.9.62/danielutils/MetaClasses/AtomicClassMeta.py → /danielutils-0.9.64/danielutils/metaclasses/atomic_class_meta.py +0 -0
  83. /danielutils-0.9.62/danielutils/MetaClasses/ImplicitDataDeleterMeta.py → /danielutils-0.9.64/danielutils/metaclasses/implicit_data_deleter_meta.py +0 -0
  84. /danielutils-0.9.62/danielutils/MetaClasses/InstanceCacheMeta.py → /danielutils-0.9.64/danielutils/metaclasses/instance_cache_meta.py +0 -0
  85. /danielutils-0.9.62/danielutils/MetaClasses/OverloadMeta.py → /danielutils-0.9.64/danielutils/metaclasses/overload_meta.py +0 -0
  86. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/multi_x.py +0 -0
  87. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/my_tqdm.py +0 -0
  88. /danielutils-0.9.62/danielutils/Path.py → /danielutils-0.9.64/danielutils/path.py +0 -0
  89. /danielutils-0.9.62/danielutils/Print.py → /danielutils-0.9.64/danielutils/print.py +0 -0
  90. /danielutils-0.9.62/danielutils/Reflection/Class.py → /danielutils-0.9.64/danielutils/reflection/class_reflection.py +0 -0
  91. /danielutils-0.9.62/danielutils/Reflection/File.py → /danielutils-0.9.64/danielutils/reflection/file_reflection.py +0 -0
  92. /danielutils-0.9.62/danielutils/Reflection/Function.py → /danielutils-0.9.64/danielutils/reflection/function_reflections.py +0 -0
  93. {danielutils-0.9.62/danielutils/Reflection → danielutils-0.9.64/danielutils/reflection}/get_prev_frame.py +0 -0
  94. {danielutils-0.9.62/danielutils/Reflection → danielutils-0.9.64/danielutils/reflection}/get_traceback.py +0 -0
  95. /danielutils-0.9.62/danielutils/Reflection/Module.py → /danielutils-0.9.64/danielutils/reflection/module_reflections.py +0 -0
  96. /danielutils-0.9.62/danielutils/Reflection/System.py → /danielutils-0.9.64/danielutils/reflection/system_reflections.py +0 -0
  97. /danielutils-0.9.62/danielutils/Relations.py → /danielutils-0.9.64/danielutils/relations.py +0 -0
  98. /danielutils-0.9.62/danielutils/Signals.py → /danielutils-0.9.64/danielutils/signals.py +0 -0
  99. {danielutils-0.9.62/danielutils/Snippets → danielutils-0.9.64/danielutils/snippets}/__init__.py +0 -0
  100. {danielutils-0.9.62/danielutils/Snippets → danielutils-0.9.64/danielutils/snippets}/try_get.py +0 -0
  101. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/system/__init__.py +0 -0
  102. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/system/independent.py +0 -0
  103. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/system/windows/__init__.py +0 -0
  104. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/system/windows/utils/__init__.py +0 -0
  105. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/system/windows/utils/filetime.py +0 -0
  106. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/system/windows/win32_ctime.py +0 -0
  107. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/system/windows/windows.py +0 -0
  108. /danielutils-0.9.62/danielutils/Text.py → /danielutils-0.9.64/danielutils/text.py +0 -0
  109. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/threads/__init__.py +0 -0
  110. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/threads/worker.py +0 -0
  111. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils/threads/worker_pool.py +0 -0
  112. /danielutils-0.9.62/danielutils/Time.py → /danielutils-0.9.64/danielutils/time.py +0 -0
  113. {danielutils-0.9.62/danielutils/University → danielutils-0.9.64/danielutils/university}/__init__.py +0 -0
  114. {danielutils-0.9.62/danielutils/University/Databases → danielutils-0.9.64/danielutils/university/databases}/__init__.py +0 -0
  115. {danielutils-0.9.62/danielutils/University/Databases → danielutils-0.9.64/danielutils/university/databases}/all.py +0 -0
  116. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils.egg-info/dependency_links.txt +0 -0
  117. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils.egg-info/requires.txt +0 -0
  118. {danielutils-0.9.62 → danielutils-0.9.64}/danielutils.egg-info/top_level.txt +0 -0
  119. {danielutils-0.9.62 → danielutils-0.9.64}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: danielutils
3
- Version: 0.9.62
3
+ Version: 0.9.64
4
4
  Summary: A python utils library for things I find useful
5
5
  Home-page: https://github.com/danielnachumdev/danielutils
6
6
  Author: danielnachumdev
@@ -36,6 +36,7 @@ Classifier: Programming Language :: Python :: 3
36
36
  Classifier: Operating System :: Microsoft :: Windows
37
37
  Requires-Python: >=3.8.17
38
38
  Description-Content-Type: text/markdown
39
+ Requires-Dist: tqdm
39
40
 
40
41
 
41
42
  [![Python package](https://github.com/danielnachumdev/danielutils/actions/workflows/python-package.yml/badge.svg)](https://github.com/danielnachumdev/danielutils/actions/workflows/python-package.yml)
@@ -43,7 +44,7 @@ Description-Content-Type: text/markdown
43
44
  [![Python 3.10.11](https://img.shields.io/badge/python-3.10.11-blue.svg)](https://www.python.org/downloads/release/python-31011/)
44
45
  [![gitleaks](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml/badge.svg)](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml)
45
46
  [![CodeQL](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql)
46
- # danielutils v=0.9.62
47
+ # danielutils v=0.9.64
47
48
  A utils library for things that I find useful for my coding workflow.\
48
49
  Feel free to use and / or contribute / improve my code :)
49
50
 
@@ -4,7 +4,7 @@
4
4
  [![Python 3.10.11](https://img.shields.io/badge/python-3.10.11-blue.svg)](https://www.python.org/downloads/release/python-31011/)
5
5
  [![gitleaks](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml/badge.svg)](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml)
6
6
  [![CodeQL](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql)
7
- # danielutils v=0.9.62
7
+ # danielutils v=0.9.64
8
8
  A utils library for things that I find useful for my coding workflow.\
9
9
  Feel free to use and / or contribute / improve my code :)
10
10
 
@@ -3,7 +3,7 @@
3
3
  """
4
4
  from .functions import *
5
5
  from .decorators import *
6
- from .io import *
6
+ from .files_and_folders import *
7
7
  from .system import *
8
8
  from .text import *
9
9
  from .conversions import *
@@ -1,4 +1,4 @@
1
- from ...metaclasses.OverloadMeta import OverloadMeta
1
+ from ...metaclasses.overload_meta import OverloadMeta
2
2
  from ..main_conversions import int_to_hex, char_to_hex
3
3
 
4
4
 
@@ -5,7 +5,7 @@ from .decorate_conditionally import *
5
5
  from .limit_recursion import *
6
6
  from .memo import *
7
7
  from .overload import *
8
- from .PartiallyImplemented import *
8
+ from .partially_implemented import *
9
9
  from .timeout import *
10
10
  from .chain_decorators import *
11
11
  from .threadify import *
@@ -0,0 +1,435 @@
1
+ # -*- coding: utf-8 -*-
2
+ import subprocess
3
+ from typing import IO, Iterator, Generator, Optional, cast, Union, List as t_list
4
+ # import shutil
5
+ from pathlib import Path
6
+ import os
7
+ from .decorators import validate
8
+ from .reflection import get_python_version
9
+ if get_python_version() >= (3, 9):
10
+ from builtins import list as t_list
11
+
12
+ @validate
13
+ def path_exists(path: str) -> bool:
14
+ """checks whether a path exists
15
+
16
+ Args:
17
+ path (str): path to check
18
+
19
+ Returns:
20
+ bool: result of check
21
+ """
22
+ return os.path.exists(path)
23
+
24
+
25
+ @validate
26
+ def file_exists(path: str) -> bool:
27
+ """checks whether a file exists at specified path
28
+
29
+ Args:
30
+ path (str): path to check
31
+
32
+ Returns:
33
+ bool: will return true iff the path exists and it is a path to a file
34
+ """
35
+ return path_exists(path) and is_file(path)
36
+
37
+
38
+ @validate
39
+ def directory_exists(path: str) -> bool:
40
+ """checks whether a directory exists at specified path
41
+
42
+ Args:
43
+ path (str): path to check
44
+
45
+ Returns:
46
+ bool: will return true iff the path exists and it is a path to a directory
47
+ """
48
+ return path_exists(path) and is_directory(path)
49
+
50
+
51
+ @validate
52
+ def delete_file(path: str) -> None:
53
+ """deletes a file if it exists
54
+
55
+ Args:
56
+ path (str): path of file
57
+ """
58
+ if file_exists(path):
59
+ os.remove(path)
60
+
61
+
62
+ @validate
63
+ # type:ignore
64
+ def read_file(path: str, read_bytes: bool = False) -> Union[t_list[str], t_list[bytes]]:
65
+ """read all lines from a file
66
+
67
+ Args:
68
+ path (str): the path to the file
69
+
70
+ Returns:
71
+ list[str]: a list of all the lines in the file
72
+ """
73
+ try:
74
+ if read_bytes:
75
+ with open(path, "rb") as f:
76
+ return f.readlines()
77
+ else:
78
+ with open(path, "r", encoding="mbcs") as f:
79
+ return f.readlines()
80
+ except Exception as e:
81
+ if isinstance(e, UnicodeDecodeError):
82
+ raise UnicodeDecodeError(e.encoding, e.object, e.start, e.end,
83
+ "Can't read byte in file.\nTo use with bytes use: read_bytes = True ") from e
84
+ raise e
85
+
86
+
87
+ @validate
88
+ def is_file(path: str) -> bool:
89
+ """return whether a path represents a file
90
+
91
+ Args:
92
+ path (str): path to check
93
+ """
94
+ return os.path.isfile(path)
95
+
96
+
97
+ @validate
98
+ def is_directory(path: str) -> bool:
99
+ """return whether a path represents a directory
100
+
101
+ Args:
102
+ path (str): path to check
103
+ """
104
+ return os.path.isdir(path)
105
+
106
+
107
+ @validate
108
+ def get_files(path: str) -> t_list[str]:
109
+ """return a list of names of all files inside specified directory
110
+
111
+ Args:
112
+ path (str): directory
113
+
114
+ Returns:
115
+ list[str]: all files
116
+ """
117
+ files_and_directories = get_files_and_directories(path)
118
+ return list(
119
+ filter(lambda name: is_file(os.path.join(path, name)), files_and_directories))
120
+
121
+
122
+ @validate
123
+ def get_files_and_directories(path: str) -> t_list[str]:
124
+ """get a list of all files and directories in specified path
125
+
126
+ Args:
127
+ path (str): path to check
128
+
129
+ Returns:
130
+ list[str]: all files and directories
131
+ """
132
+ return os.listdir(path)
133
+
134
+
135
+ @validate
136
+ def get_directories(path: str) -> t_list[str]:
137
+ """get all directories in specified path
138
+
139
+ Args:
140
+ path (str): path to check
141
+
142
+ Returns:
143
+ list[str]: all directories
144
+ """
145
+ files_and_directories = get_files_and_directories(path)
146
+ return list(
147
+ filter(lambda name: is_directory(os.path.join(path, name)), files_and_directories))
148
+
149
+
150
+ @ validate
151
+ def delete_directory(path: str) -> None:
152
+ """delete a directory and all its contents
153
+
154
+ Args:
155
+ path (str): _description_
156
+ """
157
+ if is_directory(path):
158
+ clear_directory(path)
159
+ os.rmdir(path)
160
+
161
+
162
+ @validate
163
+ def clear_directory(path: str) -> None:
164
+ """clears the content of a directory
165
+
166
+ Args:
167
+ path (str): the path of the directory to clean
168
+ """
169
+ for file in get_files(path):
170
+ delete_file(os.path.join(path, file))
171
+ for subdir in get_directories(path):
172
+ delete_directory(os.path.join(path, subdir))
173
+
174
+
175
+ @validate
176
+ def create_directory(path: str) -> None:
177
+ """create a directory at the specified path if it doesn't already exists
178
+
179
+ Args:
180
+ path (str): the path to create a directory at
181
+ """
182
+ if not directory_exists(path):
183
+ os.makedirs(path)
184
+
185
+
186
+ @validate
187
+ def create_file(path: str) -> None:
188
+ if not file_exists(path):
189
+ with open(path, "w", encoding='utf8') as f:
190
+ pass
191
+
192
+
193
+ @validate
194
+ def get_file_type_from_directory(path: str, file_type: str) -> Iterator[str]:
195
+ """returns all file with specific type from a directory
196
+
197
+ Args:
198
+ path (str): path of directory
199
+ file_type (str): the desired file type. eg: ".png"
200
+
201
+ Returns:
202
+ list[str]: result
203
+ """
204
+ return filter(
205
+ lambda name: Path(os.path.join(path, name)).suffix == file_type,
206
+ get_files(path)
207
+ )
208
+
209
+
210
+ @validate
211
+ def get_file_type_from_directory_recursively(path: str, file_type: str) -> Generator[str, None, None]:
212
+ """_summary_
213
+
214
+ Args:
215
+ path (str): _description_
216
+ file_type (str): _description_
217
+
218
+ Returns:
219
+ _type_: _description_
220
+ """
221
+ yield from filter(
222
+ lambda name: Path(os.path.join(path, name)).suffix == file_type,
223
+ get_files(path)
224
+ )
225
+ for subdir in get_directories(path):
226
+ for v in get_file_type_from_directory_recursively(os.path.join(path, subdir), file_type):
227
+ yield os.path.join(subdir, v)
228
+
229
+
230
+ @validate
231
+ def rename_file(path: str, new_name: str) -> None:
232
+ """renames a file
233
+
234
+ Args:
235
+ path (str): file to rename
236
+ new_name (str): the desired new name
237
+ """
238
+ new_path = "./" + \
239
+ "/".join(Path(path).parts[:-1])+"/"+new_name+Path(path).suffix
240
+ move_file(path, new_path)
241
+
242
+
243
+ @validate
244
+ def move_file(old_path: str, new_path: str) -> None:
245
+ """moves a file
246
+
247
+ Args:
248
+ old_path (str): old path
249
+ new_path (str): new path
250
+ """
251
+ os.rename(old_path, new_path)
252
+
253
+
254
+ @validate
255
+ async def open_file(file_path: str, application_path: str) -> int:
256
+ """open a file with the specified application
257
+
258
+ Args:
259
+ file_path (str): the file to open
260
+ application_path (str): the application to open with
261
+ Returns:
262
+ int: return code
263
+ """
264
+ with subprocess.Popen([application_path, file_path]) as p:
265
+ return p.wait()
266
+
267
+
268
+ # @validate
269
+ # def move_directory(old_path: str, new_path: str) -> None:
270
+ # """moves a directory
271
+ #
272
+ # Args:
273
+ # old_path (str): old path
274
+ # new_path (str): new path
275
+ # """
276
+ # shutil.move(old_path, new_path)
277
+ #
278
+ #
279
+ # @validate
280
+ # def copy_file(src: str, dest: str) -> None:
281
+ # """copies file from src to dest
282
+ #
283
+ # Args:
284
+ # src (str): src
285
+ # dest (str): dest
286
+ # """
287
+ # shutil.copy(src, dest)
288
+ #
289
+ #
290
+ # @validate
291
+ # def copy_directory(src: str, dest: str) -> None:
292
+ # """copies a directory from src to dest
293
+ #
294
+ # Args:
295
+ # src (str): stc
296
+ # dest (str): dest
297
+ # """
298
+ # shutil.copy(src, dest)
299
+ #
300
+
301
+ class IndentedWriter:
302
+ """every class that will inherit this class will have the following functions available
303
+ write() with the same arguments a builtin print()
304
+ indent()
305
+ undent()
306
+
307
+ also, it is expected in the __init__ function to call super().__init__()
308
+ also, the output_stream must be set whether by the first argument io super().__init__(...)
309
+ or by set_stream() explicitly somewhere else.
310
+
311
+ this class will not function properly is the output_stream is not set!
312
+
313
+ """
314
+
315
+ def __init__(self, output_stream: Optional[IO] = None, indent_value: str = "\t"):
316
+ self.indent_level = 0
317
+ self.output_stream: Optional[IO] = output_stream
318
+ self.indent_value = indent_value
319
+
320
+ def write(self, *args, sep=" ", end="\n") -> None:
321
+ """writes the supplied arguments to the output_stream
322
+
323
+ Args:
324
+ sep (str, optional): the str to use as a separator between arguments. Defaults to " ".
325
+ end (str, optional): the str to use as the final value. Defaults to "\n".
326
+
327
+ Raises:
328
+ ValueError: _description_
329
+ """
330
+ if self.output_stream is None:
331
+ raise ValueError(
332
+ "Can't write to an empty stream. the stream must not be None:"
333
+ " either by set_stream or by initialization")
334
+ self.output_stream.write(
335
+ str(self.indent_level*self.indent_value + sep.join(args)+end))
336
+
337
+ def set_stream(self, stream: IO) -> None:
338
+ """explicitly sets the stream
339
+
340
+ Args:
341
+ stream (IO): stream
342
+ """
343
+ self.output_stream = stream
344
+ self.output_stream = cast(IO, self.output_stream)
345
+
346
+ def indent(self) -> None:
347
+ """indents the preceding output with write() by one quantity more
348
+ """
349
+ self.indent_level += 1
350
+
351
+ def undent(self) -> None:
352
+ """un-dents the preceding output with write() by one quantity less
353
+ has a minimum value of 0
354
+ """
355
+ self.indent_level = max(0, self.indent_level-1)
356
+
357
+
358
+ class IndentedWriter2:
359
+ """every class that will inherit this class will have the following functions available
360
+ write() with the same arguments a builtin print()
361
+ indent()
362
+ undent()
363
+
364
+ also, it is expected in the __init__ function to call super().__init__()
365
+ also, the output_stream must be set whether by the first argument io super().__init__(...)
366
+ or by set_stream() explicitly somewhere else.
367
+
368
+ this class will not function properly is the output_stream is not set!
369
+
370
+ """
371
+
372
+ def __init__(self, indent_value: str = "\t"):
373
+ self.indent_level = 0
374
+ self.indent_value = indent_value
375
+ self.buffer: str = ""
376
+
377
+ def to_stream(self, stream: IO[str]) -> None:
378
+ """outputs the buffer to a stream
379
+
380
+ Args:
381
+ stream (IO[str]): the stream to output to
382
+ """
383
+ stream.write(self.buffer)
384
+
385
+ def write(self, *args, sep=" ", end="\n") -> None:
386
+ """writes the supplied arguments to the output_stream
387
+
388
+ Args:
389
+ sep (str, optional): the str to use as a separator between arguments. Defaults to " ".
390
+ end (str, optional): the str to use as the final value. Defaults to "\n".
391
+
392
+ Raises:
393
+ ValueError: _description_
394
+ """
395
+ self.buffer += str(self.indent_level *
396
+ self.indent_value + sep.join(args)+end)
397
+
398
+ def indent(self) -> None:
399
+ """indents the preceding output with write() by one quantity more
400
+ """
401
+ self.indent_level += 1
402
+
403
+ def undent(self) -> None:
404
+ """un-dents the preceding output with write() by one quantity less
405
+ has a minimum value of 0
406
+ """
407
+ self.indent_level = max(0, self.indent_level-1)
408
+
409
+
410
+ __all__ = [
411
+ "path_exists",
412
+ "file_exists",
413
+ "directory_exists",
414
+ "delete_file",
415
+ "read_file",
416
+ "is_file",
417
+ "is_directory",
418
+ "get_files",
419
+ "get_files_and_directories",
420
+ "get_directories",
421
+ "delete_directory",
422
+ "clear_directory",
423
+ "create_directory",
424
+ 'create_file',
425
+ "get_file_type_from_directory",
426
+ "get_file_type_from_directory_recursively",
427
+ "rename_file",
428
+ "move_file",
429
+ "open_file",
430
+ # "move_directory",
431
+ # "copy_file",
432
+ # "copy_directory",
433
+ "IndentedWriter",
434
+ "IndentedWriter2"
435
+ ]
@@ -0,0 +1,5 @@
1
+ from .interface import *
2
+ from .atomic_class_meta import *
3
+ from .implicit_data_deleter_meta import *
4
+ from .instance_cache_meta import *
5
+ from .overload_meta import *
@@ -1,9 +1,9 @@
1
- from .System import * # this has to be first, the order matters!
2
- from .File import *
3
- from .Function import *
1
+ from .system_reflections import * # this has to be first, the order matters!
2
+ from .file_reflection import *
3
+ from .function_reflections import *
4
4
  from .get_traceback import *
5
- from .Module import *
6
- from .Class import *
5
+ from .module_reflections import *
6
+ from .class_reflection import *
7
7
  from .get_prev_frame import *
8
8
  # def get_class(module_name: str, class_name: str) -> type:
9
9
  # """dynammically loads the module and returns the class from this file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: danielutils
3
- Version: 0.9.62
3
+ Version: 0.9.64
4
4
  Summary: A python utils library for things I find useful
5
5
  Home-page: https://github.com/danielnachumdev/danielutils
6
6
  Author: danielnachumdev
@@ -36,6 +36,7 @@ Classifier: Programming Language :: Python :: 3
36
36
  Classifier: Operating System :: Microsoft :: Windows
37
37
  Requires-Python: >=3.8.17
38
38
  Description-Content-Type: text/markdown
39
+ Requires-Dist: tqdm
39
40
 
40
41
 
41
42
  [![Python package](https://github.com/danielnachumdev/danielutils/actions/workflows/python-package.yml/badge.svg)](https://github.com/danielnachumdev/danielutils/actions/workflows/python-package.yml)
@@ -43,7 +44,7 @@ Description-Content-Type: text/markdown
43
44
  [![Python 3.10.11](https://img.shields.io/badge/python-3.10.11-blue.svg)](https://www.python.org/downloads/release/python-31011/)
44
45
  [![gitleaks](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml/badge.svg)](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml)
45
46
  [![CodeQL](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql)
46
- # danielutils v=0.9.62
47
+ # danielutils v=0.9.64
47
48
  A utils library for things that I find useful for my coding workflow.\
48
49
  Feel free to use and / or contribute / improve my code :)
49
50
 
@@ -2,23 +2,13 @@ LISENCE
2
2
  README.md
3
3
  pyproject.toml
4
4
  setup.py
5
- danielutils/Aliases.py
6
- danielutils/Colors.py
7
- danielutils/Exceptions.py
8
- danielutils/IO.py
9
- danielutils/Internet.py
10
- danielutils/Path.py
11
- danielutils/Print.py
12
- danielutils/Relations.py
13
- danielutils/Signals.py
14
- danielutils/Text.py
15
- danielutils/Time.py
16
5
  danielutils/__init__.py
17
6
  danielutils/aliases.py
18
7
  danielutils/colors.py
19
8
  danielutils/date.py
20
9
  danielutils/date_time.py
21
10
  danielutils/exceptions.py
11
+ danielutils/files_and_folders.py
22
12
  danielutils/internet.py
23
13
  danielutils/io.py
24
14
  danielutils/loops.py
@@ -35,59 +25,8 @@ danielutils.egg-info/SOURCES.txt
35
25
  danielutils.egg-info/dependency_links.txt
36
26
  danielutils.egg-info/requires.txt
37
27
  danielutils.egg-info/top_level.txt
38
- danielutils/Classes/Convenience.py
39
- danielutils/Classes/Counter.py
40
- danielutils/Classes/Tree.py
41
- danielutils/Classes/__init__.py
42
- danielutils/Classes/frange.py
43
- danielutils/Conversions/__init__.py
44
- danielutils/Decorators/PartiallyImplemented.py
45
- danielutils/Decorators/__init__.py
46
- danielutils/Decorators/atomic.py
47
- danielutils/Decorators/attach.py
48
- danielutils/Decorators/chain_decorators.py
49
- danielutils/Decorators/decorate_conditionally.py
50
- danielutils/Decorators/delay_call.py
51
- danielutils/Decorators/deprecate.py
52
- danielutils/Decorators/limit_recursion.py
53
- danielutils/Decorators/memo.py
54
- danielutils/Decorators/overload.py
55
- danielutils/Decorators/property.py
56
- danielutils/Decorators/threadify.py
57
- danielutils/Decorators/timeout.py
58
- danielutils/Decorators/validate.py
59
- danielutils/Functions/__init__.py
60
- danielutils/Functions/areoneof.py
61
- danielutils/Functions/check_foreach.py
62
- danielutils/Functions/isoftype.py
63
- danielutils/Functions/isoneof.py
64
- danielutils/Functions/powerset.py
65
- danielutils/Functions/types_subseteq.py
66
- danielutils/Generators/__init__.py
67
- danielutils/Generators/conditional_generator.py
68
- danielutils/Generators/generator_from_stream.py
69
- danielutils/Generators/join_generators.py
70
- danielutils/Math/Constants.py
71
- danielutils/Math/Functions.py
72
- danielutils/Math/__init__.py
73
- danielutils/MetaClasses/AtomicClassMeta.py
74
- danielutils/MetaClasses/ImplicitDataDeleterMeta.py
75
- danielutils/MetaClasses/InstanceCacheMeta.py
76
- danielutils/MetaClasses/Interface.py
77
- danielutils/MetaClasses/OverloadMeta.py
78
- danielutils/MetaClasses/__init__.py
79
- danielutils/Reflection/File.py
80
- danielutils/Reflection/Function.py
81
- danielutils/Reflection/Module.py
82
- danielutils/Reflection/System.py
83
- danielutils/Reflection/__init__.py
84
- danielutils/Reflection/get_prev_frame.py
85
- danielutils/Reflection/get_traceback.py
86
- danielutils/Snippets/__init__.py
87
- danielutils/Snippets/try_get.py
88
- danielutils/University/__init__.py
89
- danielutils/University/Databases/__init__.py
90
- danielutils/University/Databases/all.py
28
+ danielutils/classes/Convenience.py
29
+ danielutils/classes/Counter.py
91
30
  danielutils/classes/Tree.py
92
31
  danielutils/classes/__init__.py
93
32
  danielutils/classes/convenience.py
@@ -107,6 +46,12 @@ danielutils/conversions/main_conversions.py
107
46
  danielutils/conversions/specialized_conversions/__init__.py
108
47
  danielutils/conversions/specialized_conversions/to_hex.py
109
48
  danielutils/conversions/specialized_conversions/to_int.py
49
+ danielutils/data_structures/Comparer.py
50
+ danielutils/data_structures/Graph.py
51
+ danielutils/data_structures/Heap.py
52
+ danielutils/data_structures/Node.py
53
+ danielutils/data_structures/Queue.py
54
+ danielutils/data_structures/Stack.py
110
55
  danielutils/data_structures/__init__.py
111
56
  danielutils/data_structures/comparer.py
112
57
  danielutils/data_structures/default_dict.py
@@ -116,7 +61,6 @@ danielutils/data_structures/heap.py
116
61
  danielutils/data_structures/node.py
117
62
  danielutils/data_structures/queue.py
118
63
  danielutils/data_structures/stack.py
119
- danielutils/decorators/PartiallyImplemented.py
120
64
  danielutils/decorators/__init__.py
121
65
  danielutils/decorators/atomic.py
122
66
  danielutils/decorators/attach.py
@@ -127,6 +71,7 @@ danielutils/decorators/deprecate.py
127
71
  danielutils/decorators/limit_recursion.py
128
72
  danielutils/decorators/memo.py
129
73
  danielutils/decorators/overload.py
74
+ danielutils/decorators/partially_implemented.py
130
75
  danielutils/decorators/processify.py
131
76
  danielutils/decorators/property.py
132
77
  danielutils/decorators/threadify.py
@@ -148,20 +93,21 @@ danielutils/math/constants.py
148
93
  danielutils/math/functions.py
149
94
  danielutils/math/math_print.py
150
95
  danielutils/math/math_symbols.py
151
- danielutils/metaclasses/AtomicClassMeta.py
152
- danielutils/metaclasses/ImplicitDataDeleterMeta.py
153
- danielutils/metaclasses/InstanceCacheMeta.py
154
96
  danielutils/metaclasses/Interface.py
155
- danielutils/metaclasses/OverloadMeta.py
156
97
  danielutils/metaclasses/__init__.py
157
- danielutils/reflection/Class.py
158
- danielutils/reflection/File.py
159
- danielutils/reflection/Function.py
160
- danielutils/reflection/Module.py
161
- danielutils/reflection/System.py
98
+ danielutils/metaclasses/atomic_class_meta.py
99
+ danielutils/metaclasses/implicit_data_deleter_meta.py
100
+ danielutils/metaclasses/instance_cache_meta.py
101
+ danielutils/metaclasses/interface.py
102
+ danielutils/metaclasses/overload_meta.py
162
103
  danielutils/reflection/__init__.py
104
+ danielutils/reflection/class_reflection.py
105
+ danielutils/reflection/file_reflection.py
106
+ danielutils/reflection/function_reflections.py
163
107
  danielutils/reflection/get_prev_frame.py
164
108
  danielutils/reflection/get_traceback.py
109
+ danielutils/reflection/module_reflections.py
110
+ danielutils/reflection/system_reflections.py
165
111
  danielutils/snippets/__init__.py
166
112
  danielutils/snippets/try_get.py
167
113
  danielutils/system/__init__.py
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"]
3
3
  build-backend = "setuptools.build_meta"
4
4
  [project]
5
5
  name = "danielutils"
6
- version = "0.9.62"
6
+ version = "0.9.64"
7
7
  authors = [
8
8
  { name = "danielnachumdev", email = "danielnachumdev@gmail.com" },
9
9
  ]
@@ -9,7 +9,7 @@ def read_file(path: str) -> "list[str]":
9
9
 
10
10
  README_PATH = 'README.md'
11
11
  DESCRIPTION = 'A python utils library for things I find useful'
12
- VERSION = "0.9.62"
12
+ VERSION = "0.9.64"
13
13
  LONG_DESCRIPTION = '\n'.join(read_file(README_PATH))
14
14
  setup(
15
15
  name="danielutils",
@@ -1,5 +0,0 @@
1
- from .Interface import *
2
- from .AtomicClassMeta import *
3
- from .ImplicitDataDeleterMeta import *
4
- from .InstanceCacheMeta import *
5
- from .OverloadMeta import *
File without changes
File without changes