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

Files changed (91) hide show
  1. winipedia_utils/concurrent/concurrent.py +245 -242
  2. winipedia_utils/concurrent/multiprocessing.py +130 -115
  3. winipedia_utils/concurrent/multithreading.py +93 -93
  4. winipedia_utils/consts.py +23 -23
  5. winipedia_utils/data/__init__.py +1 -1
  6. winipedia_utils/data/dataframe/__init__.py +1 -0
  7. winipedia_utils/data/dataframe/cleaning.py +378 -0
  8. winipedia_utils/data/structures/__init__.py +1 -0
  9. winipedia_utils/data/structures/dicts.py +16 -0
  10. winipedia_utils/django/__init__.py +24 -24
  11. winipedia_utils/django/bulk.py +538 -538
  12. winipedia_utils/django/command.py +334 -334
  13. winipedia_utils/django/database.py +289 -289
  14. winipedia_utils/git/__init__.py +1 -1
  15. winipedia_utils/git/gitignore/__init__.py +1 -1
  16. winipedia_utils/git/gitignore/gitignore.py +136 -136
  17. winipedia_utils/git/pre_commit/__init__.py +1 -1
  18. winipedia_utils/git/pre_commit/config.py +70 -70
  19. winipedia_utils/git/pre_commit/hooks.py +109 -109
  20. winipedia_utils/git/pre_commit/run_hooks.py +49 -49
  21. winipedia_utils/iterating/__init__.py +1 -1
  22. winipedia_utils/iterating/iterate.py +29 -29
  23. winipedia_utils/logging/ansi.py +6 -6
  24. winipedia_utils/logging/config.py +64 -64
  25. winipedia_utils/logging/logger.py +26 -26
  26. winipedia_utils/modules/class_.py +119 -119
  27. winipedia_utils/modules/function.py +101 -103
  28. winipedia_utils/modules/module.py +379 -379
  29. winipedia_utils/modules/package.py +390 -390
  30. winipedia_utils/oop/mixins/meta.py +333 -331
  31. winipedia_utils/oop/mixins/mixin.py +37 -37
  32. winipedia_utils/os/__init__.py +1 -1
  33. winipedia_utils/os/os.py +63 -63
  34. winipedia_utils/projects/__init__.py +1 -1
  35. winipedia_utils/projects/poetry/__init__.py +1 -1
  36. winipedia_utils/projects/poetry/config.py +91 -91
  37. winipedia_utils/projects/poetry/poetry.py +31 -31
  38. winipedia_utils/projects/project.py +48 -48
  39. winipedia_utils/pyside/__init__.py +1 -1
  40. winipedia_utils/pyside/core/__init__.py +1 -1
  41. winipedia_utils/pyside/core/py_qiodevice.py +476 -476
  42. winipedia_utils/pyside/ui/__init__.py +1 -1
  43. winipedia_utils/pyside/ui/base/__init__.py +1 -1
  44. winipedia_utils/pyside/ui/base/base.py +180 -180
  45. winipedia_utils/pyside/ui/pages/__init__.py +1 -1
  46. winipedia_utils/pyside/ui/pages/base/__init__.py +1 -1
  47. winipedia_utils/pyside/ui/pages/base/base.py +92 -92
  48. winipedia_utils/pyside/ui/pages/browser.py +26 -26
  49. winipedia_utils/pyside/ui/pages/player.py +85 -85
  50. winipedia_utils/pyside/ui/widgets/__init__.py +1 -1
  51. winipedia_utils/pyside/ui/widgets/browser.py +243 -243
  52. winipedia_utils/pyside/ui/widgets/clickable_widget.py +57 -57
  53. winipedia_utils/pyside/ui/widgets/media_player.py +430 -430
  54. winipedia_utils/pyside/ui/widgets/notification.py +78 -78
  55. winipedia_utils/pyside/ui/windows/__init__.py +1 -1
  56. winipedia_utils/pyside/ui/windows/base/__init__.py +1 -1
  57. winipedia_utils/pyside/ui/windows/base/base.py +49 -49
  58. winipedia_utils/resources/__init__.py +1 -1
  59. winipedia_utils/resources/svgs/__init__.py +1 -1
  60. winipedia_utils/resources/svgs/download_arrow.svg +2 -2
  61. winipedia_utils/resources/svgs/exit_fullscreen_icon.svg +5 -5
  62. winipedia_utils/resources/svgs/fullscreen_icon.svg +2 -2
  63. winipedia_utils/resources/svgs/menu_icon.svg +3 -3
  64. winipedia_utils/resources/svgs/pause_icon.svg +3 -3
  65. winipedia_utils/resources/svgs/play_icon.svg +16 -16
  66. winipedia_utils/resources/svgs/plus_icon.svg +23 -23
  67. winipedia_utils/resources/svgs/svg.py +15 -15
  68. winipedia_utils/security/__init__.py +1 -1
  69. winipedia_utils/security/cryptography.py +29 -29
  70. winipedia_utils/security/keyring.py +70 -70
  71. winipedia_utils/setup.py +47 -47
  72. winipedia_utils/testing/assertions.py +23 -23
  73. winipedia_utils/testing/convention.py +177 -177
  74. winipedia_utils/testing/create_tests.py +291 -291
  75. winipedia_utils/testing/fixtures.py +28 -28
  76. winipedia_utils/testing/tests/base/fixtures/__init__.py +1 -1
  77. winipedia_utils/testing/tests/base/fixtures/fixture.py +6 -6
  78. winipedia_utils/testing/tests/base/fixtures/scopes/class_.py +33 -33
  79. winipedia_utils/testing/tests/base/fixtures/scopes/function.py +7 -7
  80. winipedia_utils/testing/tests/base/fixtures/scopes/module.py +31 -31
  81. winipedia_utils/testing/tests/base/fixtures/scopes/package.py +7 -7
  82. winipedia_utils/testing/tests/base/fixtures/scopes/session.py +312 -312
  83. winipedia_utils/testing/tests/base/utils/utils.py +82 -82
  84. winipedia_utils/testing/tests/conftest.py +32 -32
  85. winipedia_utils/text/string.py +126 -126
  86. {winipedia_utils-0.1.63.dist-info → winipedia_utils-0.2.0.dist-info}/METADATA +5 -4
  87. winipedia_utils-0.2.0.dist-info/RECORD +103 -0
  88. {winipedia_utils-0.1.63.dist-info → winipedia_utils-0.2.0.dist-info}/WHEEL +1 -1
  89. {winipedia_utils-0.1.63.dist-info → winipedia_utils-0.2.0.dist-info/licenses}/LICENSE +21 -21
  90. winipedia_utils/data/dataframe.py +0 -7
  91. winipedia_utils-0.1.63.dist-info/RECORD +0 -100
winipedia_utils/setup.py CHANGED
@@ -1,47 +1,47 @@
1
- """A script that can be called after you installed the package.
2
-
3
- This script calls create tests, creates the pre-commit config, and
4
- creates the pyproject.toml file and some other things to set up a project.
5
- This package assumes you are using poetry and pre-commit.
6
- This script is intended to be called once at the beginning of a project.
7
- """
8
-
9
- from winipedia_utils.git.gitignore.gitignore import _add_package_patterns_to_gitignore
10
- from winipedia_utils.git.pre_commit.config import (
11
- _add_package_hook_to_pre_commit_config,
12
- _pre_commit_install,
13
- )
14
- from winipedia_utils.git.pre_commit.run_hooks import _run_all_hooks
15
- from winipedia_utils.logging.logger import get_logger
16
- from winipedia_utils.projects.poetry.config import (
17
- _add_configurations_to_pyproject_toml,
18
- )
19
- from winipedia_utils.projects.poetry.poetry import (
20
- _install_dev_dependencies,
21
- )
22
- from winipedia_utils.projects.project import _create_project_root
23
-
24
- logger = get_logger(__name__)
25
-
26
-
27
- def _setup() -> None:
28
- """Set up the project."""
29
- # install winipedia_utils dev dependencies as dev
30
- _install_dev_dependencies()
31
- # create pre-commit config
32
- _add_package_hook_to_pre_commit_config()
33
- # install pre-commit
34
- _pre_commit_install()
35
- # add patterns to .gitignore
36
- _add_package_patterns_to_gitignore()
37
- # add tool.* configurations to pyproject.toml
38
- _add_configurations_to_pyproject_toml()
39
- # create the project root
40
- _create_project_root()
41
- # run pre-commit once, create tests is included here
42
- _run_all_hooks()
43
- logger.info("Setup complete!")
44
-
45
-
46
- if __name__ == "__main__":
47
- _setup()
1
+ """A script that can be called after you installed the package.
2
+
3
+ This script calls create tests, creates the pre-commit config, and
4
+ creates the pyproject.toml file and some other things to set up a project.
5
+ This package assumes you are using poetry and pre-commit.
6
+ This script is intended to be called once at the beginning of a project.
7
+ """
8
+
9
+ from winipedia_utils.git.gitignore.gitignore import _add_package_patterns_to_gitignore
10
+ from winipedia_utils.git.pre_commit.config import (
11
+ _add_package_hook_to_pre_commit_config,
12
+ _pre_commit_install,
13
+ )
14
+ from winipedia_utils.git.pre_commit.run_hooks import _run_all_hooks
15
+ from winipedia_utils.logging.logger import get_logger
16
+ from winipedia_utils.projects.poetry.config import (
17
+ _add_configurations_to_pyproject_toml,
18
+ )
19
+ from winipedia_utils.projects.poetry.poetry import (
20
+ _install_dev_dependencies,
21
+ )
22
+ from winipedia_utils.projects.project import _create_project_root
23
+
24
+ logger = get_logger(__name__)
25
+
26
+
27
+ def _setup() -> None:
28
+ """Set up the project."""
29
+ # install winipedia_utils dev dependencies as dev
30
+ _install_dev_dependencies()
31
+ # create pre-commit config
32
+ _add_package_hook_to_pre_commit_config()
33
+ # install pre-commit
34
+ _pre_commit_install()
35
+ # add patterns to .gitignore
36
+ _add_package_patterns_to_gitignore()
37
+ # add tool.* configurations to pyproject.toml
38
+ _add_configurations_to_pyproject_toml()
39
+ # create the project root
40
+ _create_project_root()
41
+ # run pre-commit once, create tests is included here
42
+ _run_all_hooks()
43
+ logger.info("Setup complete!")
44
+
45
+
46
+ if __name__ == "__main__":
47
+ _setup()
@@ -1,23 +1,23 @@
1
- """Testing assertion utilities for enhanced test validation.
2
-
3
- This module provides custom assertion functions that extend Python's built-in
4
- assert statement with additional features like improved error messages and
5
- specialized validation logic for common testing scenarios.
6
- """
7
-
8
-
9
- def assert_with_msg(expr: bool, msg: str) -> None: # noqa: FBT001
10
- """Assert that an expression is true with a custom error message.
11
-
12
- A thin wrapper around Python's built-in assert statement that makes it
13
- easier to provide meaningful error messages when assertions fail.
14
-
15
- Args:
16
- expr: The expression to evaluate for truthiness
17
- msg: The error message to display if the assertion fails
18
-
19
- Raises:
20
- AssertionError: If the expression evaluates to False
21
-
22
- """
23
- assert expr, msg # noqa: S101 # nosec: B101
1
+ """Testing assertion utilities for enhanced test validation.
2
+
3
+ This module provides custom assertion functions that extend Python's built-in
4
+ assert statement with additional features like improved error messages and
5
+ specialized validation logic for common testing scenarios.
6
+ """
7
+
8
+
9
+ def assert_with_msg(expr: bool, msg: str) -> None: # noqa: FBT001
10
+ """Assert that an expression is true with a custom error message.
11
+
12
+ A thin wrapper around Python's built-in assert statement that makes it
13
+ easier to provide meaningful error messages when assertions fail.
14
+
15
+ Args:
16
+ expr: The expression to evaluate for truthiness
17
+ msg: The error message to display if the assertion fails
18
+
19
+ Raises:
20
+ AssertionError: If the expression evaluates to False
21
+
22
+ """
23
+ assert expr, msg # noqa: S101 # nosec: B101
@@ -1,177 +1,177 @@
1
- """Testing conventions and utilities.
2
-
3
- This module provides functions and constants for managing test naming conventions,
4
- mapping between test objects and their corresponding implementation objects,
5
- and utilities for test discovery and validation.
6
-
7
- Returns:
8
- Various utility functions and constants for testing conventions.
9
-
10
- """
11
-
12
- from collections.abc import Callable, Iterable
13
- from types import ModuleType
14
- from typing import Any
15
-
16
- from winipedia_utils.modules.module import (
17
- get_isolated_obj_name,
18
- import_obj_from_importpath,
19
- make_obj_importpath,
20
- )
21
-
22
- TEST_FUNCTION_PREFIX = "test_"
23
-
24
- TEST_CLASS_PREFIX = "Test"
25
-
26
- TEST_MODULE_PREFIX = TEST_FUNCTION_PREFIX
27
-
28
- TEST_PREFIXES = [TEST_FUNCTION_PREFIX, TEST_CLASS_PREFIX, TEST_MODULE_PREFIX]
29
-
30
- TESTS_PACKAGE_NAME = "tests"
31
-
32
-
33
- def get_right_test_prefix(obj: Callable[..., Any] | type | ModuleType) -> str:
34
- """Get the appropriate test prefix for an object based on its type.
35
-
36
- Args:
37
- obj: The object to get the test prefix for (function, class, or module)
38
-
39
- Returns:
40
- The appropriate test prefix string for the given object type
41
-
42
- """
43
- if isinstance(obj, ModuleType):
44
- return TEST_MODULE_PREFIX
45
- if isinstance(obj, type):
46
- return TEST_CLASS_PREFIX
47
- return TEST_FUNCTION_PREFIX
48
-
49
-
50
- def make_test_obj_name(obj: Callable[..., Any] | type | ModuleType) -> str:
51
- """Create a test name for an object by adding the appropriate prefix.
52
-
53
- Args:
54
- obj: The object to create a test name for
55
-
56
- Returns:
57
- The test name with the appropriate prefix
58
-
59
- """
60
- prefix = get_right_test_prefix(obj)
61
- name = get_isolated_obj_name(obj)
62
- return prefix + name
63
-
64
-
65
- def reverse_make_test_obj_name(test_name: str) -> str:
66
- """Extract the original object name from a test name by removing the prefix.
67
-
68
- Args:
69
- test_name: The test name to extract the original name from
70
-
71
- Returns:
72
- The original object name without the test prefix
73
-
74
- Raises:
75
- ValueError: If the test name doesn't start with any of the expected prefixes
76
-
77
- """
78
- for prefix in TEST_PREFIXES:
79
- if test_name.startswith(prefix):
80
- return test_name.removeprefix(prefix)
81
- msg = f"{test_name=} is expected to start with one of {TEST_PREFIXES=}"
82
- raise ValueError(msg)
83
-
84
-
85
- def make_test_obj_importpath_from_obj(
86
- obj: Callable[..., Any] | type | ModuleType,
87
- ) -> str:
88
- """Create an import path for a test object based on the original object.
89
-
90
- Args:
91
- obj: The original object to create a test import path for
92
-
93
- Returns:
94
- The import path for the corresponding test object
95
-
96
- """
97
- parts = make_obj_importpath(obj).split(".")
98
- test_name = make_test_obj_name(obj)
99
- test_parts = [
100
- (TEST_MODULE_PREFIX if part[0].islower() else TEST_CLASS_PREFIX) + part
101
- for part in parts
102
- ]
103
- test_parts[-1] = test_name
104
- test_parts.insert(0, TESTS_PACKAGE_NAME)
105
- return ".".join(test_parts)
106
-
107
-
108
- def make_obj_importpath_from_test_obj(
109
- test_obj: Callable[..., Any] | type | ModuleType,
110
- ) -> str:
111
- """Create an import path for an original object based on its test object.
112
-
113
- Args:
114
- test_obj: The test object to create an original import path for
115
-
116
- Returns:
117
- The import path for the corresponding original object
118
-
119
- """
120
- test_parts = make_obj_importpath(test_obj).split(".")
121
- test_parts = test_parts[1:]
122
- parts = [reverse_make_test_obj_name(part) for part in test_parts]
123
- return ".".join(parts)
124
-
125
-
126
- def get_test_obj_from_obj(
127
- obj: Callable[..., Any] | type | ModuleType,
128
- ) -> Callable[..., Any] | type | ModuleType:
129
- """Get the test object corresponding to an original object.
130
-
131
- Args:
132
- obj: The original object to get the test object for
133
-
134
- Returns:
135
- The corresponding test object
136
-
137
- """
138
- test_obj_path = make_test_obj_importpath_from_obj(obj)
139
- return import_obj_from_importpath(test_obj_path)
140
-
141
-
142
- def get_obj_from_test_obj(
143
- test_obj: Callable[..., Any] | type | ModuleType,
144
- ) -> Callable[..., Any] | type | ModuleType:
145
- """Get the original object corresponding to a test object.
146
-
147
- Args:
148
- test_obj: The test object to get the original object for
149
-
150
- Returns:
151
- The corresponding original object
152
-
153
- """
154
- obj_importpath = make_obj_importpath_from_test_obj(test_obj)
155
- return import_obj_from_importpath(obj_importpath)
156
-
157
-
158
- def make_untested_summary_error_msg(
159
- untested_objs: Iterable[str],
160
- ) -> str:
161
- """Create an error message summarizing untested objects.
162
-
163
- Args:
164
- untested_objs: Collection of import paths for untested objects
165
-
166
- Returns:
167
- A formatted error message listing all untested objects
168
-
169
- """
170
- msg = """
171
- Found untested objects:
172
- """
173
- for untested in untested_objs:
174
- msg += f"""
175
- - {untested}
176
- """
177
- return msg
1
+ """Testing conventions and utilities.
2
+
3
+ This module provides functions and constants for managing test naming conventions,
4
+ mapping between test objects and their corresponding implementation objects,
5
+ and utilities for test discovery and validation.
6
+
7
+ Returns:
8
+ Various utility functions and constants for testing conventions.
9
+
10
+ """
11
+
12
+ from collections.abc import Callable, Iterable
13
+ from types import ModuleType
14
+ from typing import Any
15
+
16
+ from winipedia_utils.modules.module import (
17
+ get_isolated_obj_name,
18
+ import_obj_from_importpath,
19
+ make_obj_importpath,
20
+ )
21
+
22
+ TEST_FUNCTION_PREFIX = "test_"
23
+
24
+ TEST_CLASS_PREFIX = "Test"
25
+
26
+ TEST_MODULE_PREFIX = TEST_FUNCTION_PREFIX
27
+
28
+ TEST_PREFIXES = [TEST_FUNCTION_PREFIX, TEST_CLASS_PREFIX, TEST_MODULE_PREFIX]
29
+
30
+ TESTS_PACKAGE_NAME = "tests"
31
+
32
+
33
+ def get_right_test_prefix(obj: Callable[..., Any] | type | ModuleType) -> str:
34
+ """Get the appropriate test prefix for an object based on its type.
35
+
36
+ Args:
37
+ obj: The object to get the test prefix for (function, class, or module)
38
+
39
+ Returns:
40
+ The appropriate test prefix string for the given object type
41
+
42
+ """
43
+ if isinstance(obj, ModuleType):
44
+ return TEST_MODULE_PREFIX
45
+ if isinstance(obj, type):
46
+ return TEST_CLASS_PREFIX
47
+ return TEST_FUNCTION_PREFIX
48
+
49
+
50
+ def make_test_obj_name(obj: Callable[..., Any] | type | ModuleType) -> str:
51
+ """Create a test name for an object by adding the appropriate prefix.
52
+
53
+ Args:
54
+ obj: The object to create a test name for
55
+
56
+ Returns:
57
+ The test name with the appropriate prefix
58
+
59
+ """
60
+ prefix = get_right_test_prefix(obj)
61
+ name = get_isolated_obj_name(obj)
62
+ return prefix + name
63
+
64
+
65
+ def reverse_make_test_obj_name(test_name: str) -> str:
66
+ """Extract the original object name from a test name by removing the prefix.
67
+
68
+ Args:
69
+ test_name: The test name to extract the original name from
70
+
71
+ Returns:
72
+ The original object name without the test prefix
73
+
74
+ Raises:
75
+ ValueError: If the test name doesn't start with any of the expected prefixes
76
+
77
+ """
78
+ for prefix in TEST_PREFIXES:
79
+ if test_name.startswith(prefix):
80
+ return test_name.removeprefix(prefix)
81
+ msg = f"{test_name=} is expected to start with one of {TEST_PREFIXES=}"
82
+ raise ValueError(msg)
83
+
84
+
85
+ def make_test_obj_importpath_from_obj(
86
+ obj: Callable[..., Any] | type | ModuleType,
87
+ ) -> str:
88
+ """Create an import path for a test object based on the original object.
89
+
90
+ Args:
91
+ obj: The original object to create a test import path for
92
+
93
+ Returns:
94
+ The import path for the corresponding test object
95
+
96
+ """
97
+ parts = make_obj_importpath(obj).split(".")
98
+ test_name = make_test_obj_name(obj)
99
+ test_parts = [
100
+ (TEST_MODULE_PREFIX if part[0].islower() else TEST_CLASS_PREFIX) + part
101
+ for part in parts
102
+ ]
103
+ test_parts[-1] = test_name
104
+ test_parts.insert(0, TESTS_PACKAGE_NAME)
105
+ return ".".join(test_parts)
106
+
107
+
108
+ def make_obj_importpath_from_test_obj(
109
+ test_obj: Callable[..., Any] | type | ModuleType,
110
+ ) -> str:
111
+ """Create an import path for an original object based on its test object.
112
+
113
+ Args:
114
+ test_obj: The test object to create an original import path for
115
+
116
+ Returns:
117
+ The import path for the corresponding original object
118
+
119
+ """
120
+ test_parts = make_obj_importpath(test_obj).split(".")
121
+ test_parts = test_parts[1:]
122
+ parts = [reverse_make_test_obj_name(part) for part in test_parts]
123
+ return ".".join(parts)
124
+
125
+
126
+ def get_test_obj_from_obj(
127
+ obj: Callable[..., Any] | type | ModuleType,
128
+ ) -> Callable[..., Any] | type | ModuleType:
129
+ """Get the test object corresponding to an original object.
130
+
131
+ Args:
132
+ obj: The original object to get the test object for
133
+
134
+ Returns:
135
+ The corresponding test object
136
+
137
+ """
138
+ test_obj_path = make_test_obj_importpath_from_obj(obj)
139
+ return import_obj_from_importpath(test_obj_path)
140
+
141
+
142
+ def get_obj_from_test_obj(
143
+ test_obj: Callable[..., Any] | type | ModuleType,
144
+ ) -> Callable[..., Any] | type | ModuleType:
145
+ """Get the original object corresponding to a test object.
146
+
147
+ Args:
148
+ test_obj: The test object to get the original object for
149
+
150
+ Returns:
151
+ The corresponding original object
152
+
153
+ """
154
+ obj_importpath = make_obj_importpath_from_test_obj(test_obj)
155
+ return import_obj_from_importpath(obj_importpath)
156
+
157
+
158
+ def make_untested_summary_error_msg(
159
+ untested_objs: Iterable[str],
160
+ ) -> str:
161
+ """Create an error message summarizing untested objects.
162
+
163
+ Args:
164
+ untested_objs: Collection of import paths for untested objects
165
+
166
+ Returns:
167
+ A formatted error message listing all untested objects
168
+
169
+ """
170
+ msg = """
171
+ Found untested objects:
172
+ """
173
+ for untested in untested_objs:
174
+ msg += f"""
175
+ - {untested}
176
+ """
177
+ return msg