winipedia-utils 0.2.0__py3-none-any.whl → 0.2.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 winipedia-utils might be problematic. Click here for more details.

Files changed (90) hide show
  1. winipedia_utils/concurrent/concurrent.py +245 -245
  2. winipedia_utils/concurrent/multiprocessing.py +130 -130
  3. winipedia_utils/concurrent/multithreading.py +93 -93
  4. winipedia_utils/consts.py +21 -23
  5. winipedia_utils/data/__init__.py +1 -1
  6. winipedia_utils/data/dataframe/__init__.py +1 -1
  7. winipedia_utils/data/dataframe/cleaning.py +378 -378
  8. winipedia_utils/data/structures/__init__.py +1 -1
  9. winipedia_utils/data/structures/dicts.py +16 -16
  10. winipedia_utils/git/__init__.py +1 -1
  11. winipedia_utils/git/gitignore/__init__.py +1 -1
  12. winipedia_utils/git/gitignore/gitignore.py +136 -136
  13. winipedia_utils/git/pre_commit/__init__.py +1 -1
  14. winipedia_utils/git/pre_commit/config.py +70 -70
  15. winipedia_utils/git/pre_commit/hooks.py +109 -109
  16. winipedia_utils/git/pre_commit/run_hooks.py +49 -49
  17. winipedia_utils/iterating/__init__.py +1 -1
  18. winipedia_utils/iterating/iterate.py +29 -29
  19. winipedia_utils/logging/ansi.py +6 -6
  20. winipedia_utils/logging/config.py +64 -64
  21. winipedia_utils/logging/logger.py +26 -26
  22. winipedia_utils/modules/class_.py +119 -119
  23. winipedia_utils/modules/function.py +101 -101
  24. winipedia_utils/modules/module.py +379 -379
  25. winipedia_utils/modules/package.py +390 -390
  26. winipedia_utils/oop/mixins/meta.py +333 -333
  27. winipedia_utils/oop/mixins/mixin.py +37 -37
  28. winipedia_utils/os/__init__.py +1 -1
  29. winipedia_utils/os/os.py +63 -63
  30. winipedia_utils/projects/__init__.py +1 -1
  31. winipedia_utils/projects/poetry/__init__.py +1 -1
  32. winipedia_utils/projects/poetry/config.py +91 -91
  33. winipedia_utils/projects/poetry/poetry.py +31 -31
  34. winipedia_utils/projects/project.py +48 -48
  35. winipedia_utils/resources/__init__.py +1 -1
  36. winipedia_utils/resources/svgs/__init__.py +1 -1
  37. winipedia_utils/resources/svgs/download_arrow.svg +2 -2
  38. winipedia_utils/resources/svgs/exit_fullscreen_icon.svg +5 -5
  39. winipedia_utils/resources/svgs/fullscreen_icon.svg +2 -2
  40. winipedia_utils/resources/svgs/menu_icon.svg +3 -3
  41. winipedia_utils/resources/svgs/pause_icon.svg +3 -3
  42. winipedia_utils/resources/svgs/play_icon.svg +16 -16
  43. winipedia_utils/resources/svgs/plus_icon.svg +23 -23
  44. winipedia_utils/resources/svgs/svg.py +15 -15
  45. winipedia_utils/security/__init__.py +1 -1
  46. winipedia_utils/security/cryptography.py +29 -29
  47. winipedia_utils/security/keyring.py +70 -70
  48. winipedia_utils/setup.py +47 -47
  49. winipedia_utils/testing/assertions.py +23 -23
  50. winipedia_utils/testing/convention.py +177 -177
  51. winipedia_utils/testing/create_tests.py +291 -291
  52. winipedia_utils/testing/fixtures.py +28 -28
  53. winipedia_utils/testing/tests/base/fixtures/__init__.py +1 -1
  54. winipedia_utils/testing/tests/base/fixtures/fixture.py +6 -6
  55. winipedia_utils/testing/tests/base/fixtures/scopes/class_.py +33 -33
  56. winipedia_utils/testing/tests/base/fixtures/scopes/function.py +7 -7
  57. winipedia_utils/testing/tests/base/fixtures/scopes/module.py +31 -31
  58. winipedia_utils/testing/tests/base/fixtures/scopes/package.py +7 -7
  59. winipedia_utils/testing/tests/base/fixtures/scopes/session.py +312 -312
  60. winipedia_utils/testing/tests/base/utils/utils.py +82 -82
  61. winipedia_utils/testing/tests/conftest.py +32 -32
  62. winipedia_utils/text/string.py +126 -126
  63. {winipedia_utils-0.2.0.dist-info → winipedia_utils-0.2.1.dist-info}/METADATA +1 -4
  64. winipedia_utils-0.2.1.dist-info/RECORD +80 -0
  65. {winipedia_utils-0.2.0.dist-info → winipedia_utils-0.2.1.dist-info}/licenses/LICENSE +21 -21
  66. winipedia_utils/django/__init__.py +0 -24
  67. winipedia_utils/django/bulk.py +0 -538
  68. winipedia_utils/django/command.py +0 -334
  69. winipedia_utils/django/database.py +0 -289
  70. winipedia_utils/pyside/__init__.py +0 -1
  71. winipedia_utils/pyside/core/__init__.py +0 -1
  72. winipedia_utils/pyside/core/py_qiodevice.py +0 -476
  73. winipedia_utils/pyside/ui/__init__.py +0 -1
  74. winipedia_utils/pyside/ui/base/__init__.py +0 -1
  75. winipedia_utils/pyside/ui/base/base.py +0 -180
  76. winipedia_utils/pyside/ui/pages/__init__.py +0 -1
  77. winipedia_utils/pyside/ui/pages/base/__init__.py +0 -1
  78. winipedia_utils/pyside/ui/pages/base/base.py +0 -92
  79. winipedia_utils/pyside/ui/pages/browser.py +0 -26
  80. winipedia_utils/pyside/ui/pages/player.py +0 -85
  81. winipedia_utils/pyside/ui/widgets/__init__.py +0 -1
  82. winipedia_utils/pyside/ui/widgets/browser.py +0 -243
  83. winipedia_utils/pyside/ui/widgets/clickable_widget.py +0 -57
  84. winipedia_utils/pyside/ui/widgets/media_player.py +0 -430
  85. winipedia_utils/pyside/ui/widgets/notification.py +0 -78
  86. winipedia_utils/pyside/ui/windows/__init__.py +0 -1
  87. winipedia_utils/pyside/ui/windows/base/__init__.py +0 -1
  88. winipedia_utils/pyside/ui/windows/base/base.py +0 -49
  89. winipedia_utils-0.2.0.dist-info/RECORD +0 -103
  90. {winipedia_utils-0.2.0.dist-info → winipedia_utils-0.2.1.dist-info}/WHEEL +0 -0
@@ -1,119 +1,119 @@
1
- """Class utilities for introspection and manipulation.
2
-
3
- This module provides utility functions for working with Python classes,
4
- including extracting methods from classes and finding classes within modules.
5
- These utilities are particularly useful for reflection, testing,
6
- and dynamic code generation.
7
- """
8
-
9
- import inspect
10
- from collections.abc import Callable
11
- from importlib import import_module
12
- from types import ModuleType
13
- from typing import Any
14
-
15
- from winipedia_utils.modules.function import is_func
16
-
17
-
18
- def get_all_methods_from_cls(
19
- class_: type, *, exclude_parent_methods: bool = False
20
- ) -> list[Callable[..., Any]]:
21
- """Get all methods from a class.
22
-
23
- Retrieves all methods (functions or methods) from a class. Can optionally
24
- exclude methods inherited from parent classes.
25
-
26
- Args:
27
- class_: The class to extract methods from
28
- exclude_parent_methods: If True, only include methods defined in this class,
29
- excluding those inherited from parent classes
30
- Returns:
31
- A list of callable methods from the class
32
-
33
- """
34
- from winipedia_utils.modules.module import get_def_line, get_module_of_obj
35
-
36
- methods = [
37
- (method, name) for name, method in inspect.getmembers(class_) if is_func(method)
38
- ]
39
-
40
- if exclude_parent_methods:
41
- methods = [
42
- (method, name)
43
- for method, name in methods
44
- if get_module_of_obj(method).__name__ == class_.__module__
45
- and name in class_.__dict__
46
- ]
47
-
48
- only_methods = [method for method, _name in methods]
49
- # sort by definition order
50
- return sorted(only_methods, key=get_def_line)
51
-
52
-
53
- def get_all_cls_from_module(module: ModuleType | str) -> list[type]:
54
- """Get all classes defined in a module.
55
-
56
- Retrieves all class objects that are defined directly in the specified module,
57
- excluding imported classes.
58
-
59
- Args:
60
- module: The module to extract classes from
61
-
62
- Returns:
63
- A list of class types defined in the module
64
-
65
- """
66
- from winipedia_utils.modules.module import get_def_line, get_module_of_obj
67
-
68
- if isinstance(module, str):
69
- module = import_module(module)
70
-
71
- # necessary for bindings packages like AESGCM from cryptography._rust backend
72
- default = ModuleType("default")
73
- classes = [
74
- obj
75
- for _, obj in inspect.getmembers(module, inspect.isclass)
76
- if get_module_of_obj(obj, default).__name__ == module.__name__
77
- ]
78
- # sort by definition order
79
- return sorted(classes, key=get_def_line)
80
-
81
-
82
- def get_all_subclasses(cls: type) -> list[type]:
83
- """Get all subclasses of a class.
84
-
85
- Retrieves all classes that are subclasses of the specified class.
86
- Also returns subclasses of subclasses (recursive).
87
-
88
- Args:
89
- cls: The class to find subclasses of
90
-
91
- Returns:
92
- A list of subclasses of the given class
93
-
94
- """
95
- subclasses_set = set(cls.__subclasses__())
96
- for subclass in cls.__subclasses__():
97
- subclasses_set.update(get_all_subclasses(subclass))
98
- return list(subclasses_set)
99
-
100
-
101
- def get_all_nonabstract_subclasses(cls: type) -> list[type]:
102
- """Get all non-abstract subclasses of a class.
103
-
104
- Retrieves all classes that are subclasses of the specified class,
105
- excluding abstract classes. Also returns subclasses of subclasses
106
- (recursive).
107
-
108
- Args:
109
- cls: The class to find subclasses of
110
-
111
- Returns:
112
- A list of non-abstract subclasses of the given class
113
-
114
- """
115
- return [
116
- subclass
117
- for subclass in get_all_subclasses(cls)
118
- if not inspect.isabstract(subclass)
119
- ]
1
+ """Class utilities for introspection and manipulation.
2
+
3
+ This module provides utility functions for working with Python classes,
4
+ including extracting methods from classes and finding classes within modules.
5
+ These utilities are particularly useful for reflection, testing,
6
+ and dynamic code generation.
7
+ """
8
+
9
+ import inspect
10
+ from collections.abc import Callable
11
+ from importlib import import_module
12
+ from types import ModuleType
13
+ from typing import Any
14
+
15
+ from winipedia_utils.modules.function import is_func
16
+
17
+
18
+ def get_all_methods_from_cls(
19
+ class_: type, *, exclude_parent_methods: bool = False
20
+ ) -> list[Callable[..., Any]]:
21
+ """Get all methods from a class.
22
+
23
+ Retrieves all methods (functions or methods) from a class. Can optionally
24
+ exclude methods inherited from parent classes.
25
+
26
+ Args:
27
+ class_: The class to extract methods from
28
+ exclude_parent_methods: If True, only include methods defined in this class,
29
+ excluding those inherited from parent classes
30
+ Returns:
31
+ A list of callable methods from the class
32
+
33
+ """
34
+ from winipedia_utils.modules.module import get_def_line, get_module_of_obj
35
+
36
+ methods = [
37
+ (method, name) for name, method in inspect.getmembers(class_) if is_func(method)
38
+ ]
39
+
40
+ if exclude_parent_methods:
41
+ methods = [
42
+ (method, name)
43
+ for method, name in methods
44
+ if get_module_of_obj(method).__name__ == class_.__module__
45
+ and name in class_.__dict__
46
+ ]
47
+
48
+ only_methods = [method for method, _name in methods]
49
+ # sort by definition order
50
+ return sorted(only_methods, key=get_def_line)
51
+
52
+
53
+ def get_all_cls_from_module(module: ModuleType | str) -> list[type]:
54
+ """Get all classes defined in a module.
55
+
56
+ Retrieves all class objects that are defined directly in the specified module,
57
+ excluding imported classes.
58
+
59
+ Args:
60
+ module: The module to extract classes from
61
+
62
+ Returns:
63
+ A list of class types defined in the module
64
+
65
+ """
66
+ from winipedia_utils.modules.module import get_def_line, get_module_of_obj
67
+
68
+ if isinstance(module, str):
69
+ module = import_module(module)
70
+
71
+ # necessary for bindings packages like AESGCM from cryptography._rust backend
72
+ default = ModuleType("default")
73
+ classes = [
74
+ obj
75
+ for _, obj in inspect.getmembers(module, inspect.isclass)
76
+ if get_module_of_obj(obj, default).__name__ == module.__name__
77
+ ]
78
+ # sort by definition order
79
+ return sorted(classes, key=get_def_line)
80
+
81
+
82
+ def get_all_subclasses(cls: type) -> list[type]:
83
+ """Get all subclasses of a class.
84
+
85
+ Retrieves all classes that are subclasses of the specified class.
86
+ Also returns subclasses of subclasses (recursive).
87
+
88
+ Args:
89
+ cls: The class to find subclasses of
90
+
91
+ Returns:
92
+ A list of subclasses of the given class
93
+
94
+ """
95
+ subclasses_set = set(cls.__subclasses__())
96
+ for subclass in cls.__subclasses__():
97
+ subclasses_set.update(get_all_subclasses(subclass))
98
+ return list(subclasses_set)
99
+
100
+
101
+ def get_all_nonabstract_subclasses(cls: type) -> list[type]:
102
+ """Get all non-abstract subclasses of a class.
103
+
104
+ Retrieves all classes that are subclasses of the specified class,
105
+ excluding abstract classes. Also returns subclasses of subclasses
106
+ (recursive).
107
+
108
+ Args:
109
+ cls: The class to find subclasses of
110
+
111
+ Returns:
112
+ A list of non-abstract subclasses of the given class
113
+
114
+ """
115
+ return [
116
+ subclass
117
+ for subclass in get_all_subclasses(cls)
118
+ if not inspect.isabstract(subclass)
119
+ ]
@@ -1,101 +1,101 @@
1
- """Function utilities for introspection and manipulation.
2
-
3
- This module provides utility functions for working with Python functions,
4
- including extracting functions from modules and manipulating function objects.
5
- These utilities are particularly useful for reflection, testing, and
6
- dynamic code generation.
7
- """
8
-
9
- import inspect
10
- from collections.abc import Callable
11
- from importlib import import_module
12
- from types import ModuleType
13
- from typing import Any
14
-
15
-
16
- def is_func_or_method(obj: Any) -> bool:
17
- """Return True if *obj* is a function or method.
18
-
19
- This function checks if the given object is a function or method,
20
- including those defined in a class body.
21
-
22
- Args:
23
- obj: The object to check
24
-
25
- Returns:
26
- bool: True if the object is a function or method, False otherwise
27
-
28
- """
29
- return inspect.isfunction(obj) or inspect.ismethod(obj)
30
-
31
-
32
- def is_func(obj: Any) -> bool:
33
- """Return True if *obj* is a 'method-like' attribute as it appears in a class body.
34
-
35
- Accepts:
36
-
37
-
38
- • plain functions (instance methods)
39
- • staticmethod / classmethod descriptors
40
- • property descriptors (getter counts as method)
41
- • decorated functions that keep a __wrapped__ chain
42
-
43
- Returns:
44
- bool: True if the object is a method-like attribute, False otherwise
45
-
46
- """
47
- # plain function
48
-
49
- if is_func_or_method(obj):
50
- return True
51
-
52
- if isinstance(obj, (staticmethod, classmethod, property)):
53
- return True
54
-
55
- unwrapped = inspect.unwrap(obj)
56
-
57
- return is_func_or_method(unwrapped)
58
-
59
-
60
- def get_all_functions_from_module(module: ModuleType | str) -> list[Callable[..., Any]]:
61
- """Get all functions defined in a module.
62
-
63
- Retrieves all function objects that are defined directly in the specified module,
64
- excluding imported functions.
65
- The functions are sorted by their line number in the module.
66
-
67
- Args:
68
- module: The module to extract functions from
69
-
70
- Returns:
71
- A list of callable functions defined in the module
72
-
73
- """
74
- from winipedia_utils.modules.module import get_def_line, get_module_of_obj
75
-
76
- if isinstance(module, str):
77
- module = import_module(module)
78
- funcs = [
79
- func
80
- for _name, func in inspect.getmembers(module, is_func)
81
- if get_module_of_obj(func).__name__ == module.__name__
82
- ]
83
- # sort by definition order
84
- return sorted(funcs, key=get_def_line)
85
-
86
-
87
- def unwrap_method(method: Any) -> Callable[..., Any] | Any:
88
- """Unwrap a method to its underlying function.
89
-
90
- Args:
91
- method: The method to unwrap
92
-
93
- Returns:
94
- The underlying function of the method
95
-
96
- """
97
- if isinstance(method, (staticmethod, classmethod)):
98
- method = method.__func__
99
- if isinstance(method, property):
100
- method = method.fget
101
- return inspect.unwrap(method)
1
+ """Function utilities for introspection and manipulation.
2
+
3
+ This module provides utility functions for working with Python functions,
4
+ including extracting functions from modules and manipulating function objects.
5
+ These utilities are particularly useful for reflection, testing, and
6
+ dynamic code generation.
7
+ """
8
+
9
+ import inspect
10
+ from collections.abc import Callable
11
+ from importlib import import_module
12
+ from types import ModuleType
13
+ from typing import Any
14
+
15
+
16
+ def is_func_or_method(obj: Any) -> bool:
17
+ """Return True if *obj* is a function or method.
18
+
19
+ This function checks if the given object is a function or method,
20
+ including those defined in a class body.
21
+
22
+ Args:
23
+ obj: The object to check
24
+
25
+ Returns:
26
+ bool: True if the object is a function or method, False otherwise
27
+
28
+ """
29
+ return inspect.isfunction(obj) or inspect.ismethod(obj)
30
+
31
+
32
+ def is_func(obj: Any) -> bool:
33
+ """Return True if *obj* is a 'method-like' attribute as it appears in a class body.
34
+
35
+ Accepts:
36
+
37
+
38
+ • plain functions (instance methods)
39
+ • staticmethod / classmethod descriptors
40
+ • property descriptors (getter counts as method)
41
+ • decorated functions that keep a __wrapped__ chain
42
+
43
+ Returns:
44
+ bool: True if the object is a method-like attribute, False otherwise
45
+
46
+ """
47
+ # plain function
48
+
49
+ if is_func_or_method(obj):
50
+ return True
51
+
52
+ if isinstance(obj, (staticmethod, classmethod, property)):
53
+ return True
54
+
55
+ unwrapped = inspect.unwrap(obj)
56
+
57
+ return is_func_or_method(unwrapped)
58
+
59
+
60
+ def get_all_functions_from_module(module: ModuleType | str) -> list[Callable[..., Any]]:
61
+ """Get all functions defined in a module.
62
+
63
+ Retrieves all function objects that are defined directly in the specified module,
64
+ excluding imported functions.
65
+ The functions are sorted by their line number in the module.
66
+
67
+ Args:
68
+ module: The module to extract functions from
69
+
70
+ Returns:
71
+ A list of callable functions defined in the module
72
+
73
+ """
74
+ from winipedia_utils.modules.module import get_def_line, get_module_of_obj
75
+
76
+ if isinstance(module, str):
77
+ module = import_module(module)
78
+ funcs = [
79
+ func
80
+ for _name, func in inspect.getmembers(module, is_func)
81
+ if get_module_of_obj(func).__name__ == module.__name__
82
+ ]
83
+ # sort by definition order
84
+ return sorted(funcs, key=get_def_line)
85
+
86
+
87
+ def unwrap_method(method: Any) -> Callable[..., Any] | Any:
88
+ """Unwrap a method to its underlying function.
89
+
90
+ Args:
91
+ method: The method to unwrap
92
+
93
+ Returns:
94
+ The underlying function of the method
95
+
96
+ """
97
+ if isinstance(method, (staticmethod, classmethod)):
98
+ method = method.__func__
99
+ if isinstance(method, property):
100
+ method = method.fget
101
+ return inspect.unwrap(method)