d8s-python 0.10.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.
@@ -0,0 +1,305 @@
1
+ Metadata-Version: 2.4
2
+ Name: d8s_python
3
+ Version: 0.10.0
4
+ Summary: Democritus functions for working with Python code.
5
+ Project-URL: Source, https://github.com/democritus-project/d8s-python
6
+ Project-URL: Issues, https://github.com/democritus-project/d8s-python/issues
7
+ Author: Floyd Hightower
8
+ License: GNU Lesser General Public License v3
9
+ License-File: COPYING
10
+ License-File: COPYING.LESSER
11
+ Keywords: abstract-syntax-tree,ast,democritus,python,python-ast,python-asts,python-asts-utility,utility
12
+ Classifier: Development Status :: 2 - Pre-Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
15
+ Classifier: Natural Language :: English
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: d8s-algorithms<1.0,>=0.7.0
24
+ Requires-Dist: d8s-file-system<1.0,>=0.10.0
25
+ Requires-Dist: d8s-grammars<1.0,>=0.6.0
26
+ Requires-Dist: d8s-lists<1.0,>=0.8.0
27
+ Requires-Dist: d8s-strings<1.0,>=0.5.0
28
+ Requires-Dist: jinja2<4.0,>=3.1.6
29
+ Requires-Dist: more-itertools<12.0,>=11.1.0
30
+ Description-Content-Type: text/markdown
31
+
32
+ # Democritus Python
33
+
34
+ [![PyPI](https://img.shields.io/pypi/v/d8s-python.svg)](https://pypi.python.org/pypi/d8s-python)
35
+ [![CI](https://github.com/democritus-project/d8s-python/workflows/CI/badge.svg)](https://github.com/democritus-project/d8s-python/actions)
36
+ [![Lint](https://github.com/democritus-project/d8s-python/workflows/Lint/badge.svg)](https://github.com/democritus-project/d8s-python/actions)
37
+ [![codecov](https://codecov.io/gh/democritus-project/d8s-python/branch/main/graph/badge.svg?token=V0WOIXRGMM)](https://codecov.io/gh/democritus-project/d8s-python)
38
+ [![The Democritus Project uses semver version 2.0.0](https://img.shields.io/badge/-semver%20v2.0.0-22bfda)](https://semver.org/spec/v2.0.0.html)
39
+ [![The Democritus Project uses ruff to format and lint code](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
40
+ [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://choosealicense.com/licenses/lgpl-3.0/)
41
+
42
+ Democritus functions<sup>[1]</sup> for working with Python data (code and ASTs).
43
+
44
+ [1] Democritus functions are <i>simple, effective, modular, well-tested, and well-documented</i> Python functions.
45
+
46
+ We use `d8s` (pronounced "dee-eights") as an abbreviation for `democritus` (you can read more about this [here](https://github.com/democritus-project/roadmap#what-is-d8s)).
47
+
48
+ ## Installation
49
+
50
+ ```
51
+ pip install d8s-python
52
+ ```
53
+
54
+ ## Usage
55
+
56
+ You import the library like:
57
+
58
+ ```python
59
+ from d8s_python import *
60
+ ```
61
+
62
+ Once imported, you can use any of the functions listed below.
63
+
64
+ ## Functions
65
+
66
+ - ```python
67
+ def python_functions_signatures(
68
+ code_text: str,
69
+ *,
70
+ ignore_private_functions: bool = False,
71
+ ignore_nested_functions: bool = False,
72
+ keep_function_name: bool = False,
73
+ ) -> List[str]:
74
+ """Return the function signatures for all of the functions in the given code_text."""
75
+ ```
76
+ - ```python
77
+ def python_todos(code_text: str, todo_regex: str = 'TODO:.*') -> List[str]:
78
+ """Return all todos in the given code_text that match the given todo_regex."""
79
+ ```
80
+ - ```python
81
+ def python_make_pythonic(name: str) -> str:
82
+ """Make the name pythonic.
83
+
84
+ (e.g. 'fooBar' => 'foo_bar', 'foo-bar' => 'foo_bar', 'foo bar' => 'foo_bar', 'Foo Bar' => 'foo_bar')."""
85
+ ```
86
+ - ```python
87
+ def python_namespace_has_argument(namespace: argparse.Namespace, argument_name: str) -> bool:
88
+ """."""
89
+ ```
90
+ - ```python
91
+ def python_traceback_prettify(traceback: str) -> str:
92
+ """Return a string with the given traceback pretty-printed."""
93
+ ```
94
+ - ```python
95
+ def python_traceback_pretty_print(traceback: str) -> None:
96
+ """Return a string with the given traceback pretty-printed."""
97
+ ```
98
+ - ```python
99
+ def python_clean(code_text: str) -> str:
100
+ """Clean python code as it is often found in documentation and snippets."""
101
+ ```
102
+ - ```python
103
+ def python_function_blocks(
104
+ code_text: str, *, ignore_private_functions: bool = False, ignore_nested_functions: bool = False
105
+ ) -> List[str]:
106
+ """Find the code (as a string) for every function in the given code_text."""
107
+ ```
108
+ - ```python
109
+ def python_line_count(python_code: str, *, ignore_empty_lines: bool = True) -> int:
110
+ """Return the number of lines in the given function_text."""
111
+ ```
112
+ - ```python
113
+ def python_function_lengths(code_text: str) -> List[int]:
114
+ """Find the lengths of each function in the given code_text."""
115
+ ```
116
+ - ```python
117
+ def python_version() -> str:
118
+ """Return the python version of the current environment."""
119
+ ```
120
+ - ```python
121
+ def python_is_version_2() -> bool:
122
+ """Return whether or not the python version of the current environment is v2.x."""
123
+ ```
124
+ - ```python
125
+ def python_is_version_3() -> bool:
126
+ """Return whether or not the python version of the current environment is v3.x."""
127
+ ```
128
+ - ```python
129
+ def python_files_using_function(function_name: str, search_path: str) -> List[str]:
130
+ """Find where the given function is used in the given search path."""
131
+ ```
132
+ - ```python
133
+ def python_keywords() -> List[str]:
134
+ """Get a list of the python keywords."""
135
+ ```
136
+ - ```python
137
+ def python_object_properties_enumerate(
138
+ python_object: Any, *, run_methods: bool = True, internal_properties: bool = True
139
+ ) -> None:
140
+ """Enumerate and print out the properties of the given object."""
141
+ ```
142
+ - ```python
143
+ def python_copy_deep(python_object: Any) -> Any:
144
+ """Return a deep (complete, recursive) copy of the given python object."""
145
+ ```
146
+ - ```python
147
+ def python_copy_shallow(python_object: Any) -> Any:
148
+ """Return shallow copy of the given python object."""
149
+ ```
150
+ - ```python
151
+ def python_file_names(path: str, *, exclude_tests: bool = False) -> List[str]:
152
+ """Find all python files in the given directory."""
153
+ ```
154
+ - ```python
155
+ def python_fstrings(code_text: str, *, include_braces: bool = False) -> Iterator[str]:
156
+ """Find all of the python formatted string literals in the given text. See https://realpython.com/python-f-strings/ for more details about f-strings."""
157
+ ```
158
+ - ```python
159
+ def python_code_details(code_text: str):
160
+ """Get details about the given code_text. This is a wrapper for `dis.code_info`"""
161
+ ```
162
+ - ```python
163
+ def python_disassemble(code_text: str):
164
+ """Disassemble the python code_text. This is a wrapper for `dis.dis`"""
165
+ ```
166
+ - ```python
167
+ def python_stack_local_data():
168
+ """Get local data in the current python environment."""
169
+ ```
170
+ - ```python
171
+ def python_object_doc_string(python_object: Any) -> Union[str, None]:
172
+ """Get the doc string for the given python object (e.g. module, function, or class)."""
173
+ ```
174
+ - ```python
175
+ def python_object_source_file(python_object: Any) -> str:
176
+ """Get the source file for the given python object (e.g. module, function, or class)."""
177
+ ```
178
+ - ```python
179
+ def python_object_module(python_object: Any) -> str:
180
+ """Get the module for the given python object (e.g. function or class)."""
181
+ ```
182
+ - ```python
183
+ def python_object_source_code(python_object: Any) -> str:
184
+ """Get the source code for the given python object (e.g. module, function, or class)."""
185
+ ```
186
+ - ```python
187
+ def python_object_signature(python_object: Any) -> str:
188
+ """Get the argument signature for the given python object (e.g. module, function, or class)."""
189
+ ```
190
+ - ```python
191
+ def python_sort_type_list_by_name(python_type_list: List[type], **kwargs) -> List[type]:
192
+ """."""
193
+ ```
194
+ - ```python
195
+ def python_type_name(python_type: type) -> str:
196
+ """Return the common name of the given type."""
197
+ ```
198
+ - ```python
199
+ def python_object_type_to_word(python_object: Any) -> str:
200
+ """Convert the given python type to a string."""
201
+ ```
202
+ - ```python
203
+ def python_ast_raise_name(node: ast.Raise) -> Optional[str]:
204
+ """Get the name of the exception raise by the given ast.Raise object."""
205
+ ```
206
+ - ```python
207
+ def python_ast_exception_handler_exceptions_handled(handler: ast.ExceptHandler) -> Optional[Iterable[str]]:
208
+ """Return all of the exceptions handled by the given exception handler."""
209
+ ```
210
+ - ```python
211
+ def python_ast_exception_handler_exceptions_raised(handler: ast.ExceptHandler) -> Optional[Iterable[str]]:
212
+ """Return the exception raised by the given exception handler."""
213
+ ```
214
+ - ```python
215
+ def python_exceptions_handled(code_text: str) -> Iterable[str]:
216
+ """Return a list of all exceptions handled in the given code."""
217
+ ```
218
+ - ```python
219
+ def python_exceptions_raised(code_text: str) -> Iterable[str]:
220
+ """Return a list of all exceptions raised in the given code."""
221
+ ```
222
+ - ```python
223
+ def python_functions_as_import_string(code_text: str, module_name: str) -> str:
224
+ """."""
225
+ ```
226
+ - ```python
227
+ def python_ast_object_line_number(ast_object: object) -> Optional[int]:
228
+ """."""
229
+ ```
230
+ - ```python
231
+ def python_ast_object_line_numbers(ast_object: object) -> Tuple[int, int]:
232
+ """."""
233
+ ```
234
+ - ```python
235
+ def python_ast_objects_of_type(
236
+ code_text_or_ast_object: Union[str, object], ast_type: type, *, recursive_search: bool = True
237
+ ) -> Iterable[object]:
238
+ """Return all of the ast objects of the given ast_type in the code_text_or_ast_object."""
239
+ ```
240
+ - ```python
241
+ def python_ast_objects_not_of_type(code_text_or_ast_object: Union[str, object], ast_type: type) -> Iterable[object]:
242
+ """Return all of the ast objects which are not of the given ast_type in the code_text_or_ast_object."""
243
+ ```
244
+ - ```python
245
+ def python_ast_parse(code_text: str) -> ast.Module:
246
+ """."""
247
+ ```
248
+ - ```python
249
+ def python_ast_function_defs(code_text: str, recursive_search: bool = True) -> Iterable[ast.FunctionDef]:
250
+ """."""
251
+ ```
252
+ - ```python
253
+ def python_function_arguments(function_text: str) -> List[ast.arg]:
254
+ """."""
255
+ ```
256
+ - ```python
257
+ def python_function_argument_names(function_text: str) -> Iterable[str]:
258
+ """."""
259
+ ```
260
+ - ```python
261
+ def python_function_argument_defaults(function_text: str) -> List[str]:
262
+ """."""
263
+ ```
264
+ - ```python
265
+ def python_function_argument_annotations(function_text: str) -> List[str]:
266
+ """."""
267
+ ```
268
+ - ```python
269
+ def python_function_names(
270
+ code_text: str, *, ignore_private_functions: bool = False, ignore_nested_functions: bool = False
271
+ ) -> List[str]:
272
+ """."""
273
+ ```
274
+ - ```python
275
+ def python_function_docstrings(
276
+ code_text: str, *, ignore_private_functions: bool = False, ignore_nested_functions: bool = False
277
+ ) -> List[str]:
278
+ """Get docstrings for all of the functions in the given text."""
279
+ ```
280
+ - ```python
281
+ def python_variable_names(code_text: str) -> List[str]:
282
+ """Get all of the variables names in the code_text."""
283
+ ```
284
+ - ```python
285
+ def python_constants(code_text: str) -> List[str]:
286
+ """Get all constants in the code_text."""
287
+ ```
288
+
289
+ ## Development
290
+
291
+ ๐Ÿ‘‹ &nbsp;If you want to get involved in this project, we have some short, helpful guides below:
292
+
293
+ - [contribute to this project ๐Ÿฅ‡][contributing]
294
+ - [test it ๐Ÿงช][local-dev]
295
+ - [lint it ๐Ÿงน][local-dev]
296
+ - [explore it ๐Ÿ”ญ][local-dev]
297
+
298
+ If you have any questions or there is anything we did not cover, please raise an issue and we'll be happy to help.
299
+
300
+ ## Credits
301
+
302
+ This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and Floyd Hightower's [Python project template](https://github.com/fhightower-templates/python-project-template).
303
+
304
+ [contributing]: https://github.com/democritus-project/.github/blob/main/CONTRIBUTING.md#contributing-a-pr-
305
+ [local-dev]: https://github.com/democritus-project/.github/blob/main/CONTRIBUTING.md#local-development-
@@ -0,0 +1,8 @@
1
+ d8s_python/__init__.py,sha256=fuaZal3ulWjeMkwJ7ijKf5L4ezSxzb43GecGGHJMWGE,152
2
+ d8s_python/ast_data.py,sha256=-B11wsR_x7R9MMSad1z8ZoO0bh8erkgfOkcB05qjn0Q,11706
3
+ d8s_python/python_data.py,sha256=u9IJB_MLuHEKgKQqtLTndov69SpnR8k48B_mAGqBVcs,14561
4
+ d8s_python-0.10.0.dist-info/METADATA,sha256=DpvC6lzXmfsggetx39DeKte1MY2B8lk_ioHMoNHXOvM,12392
5
+ d8s_python-0.10.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
6
+ d8s_python-0.10.0.dist-info/licenses/COPYING,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
7
+ d8s_python-0.10.0.dist-info/licenses/COPYING.LESSER,sha256=z72U6pv-bQgJ_Svr4uCXnMjemsp38aSerhHEdEAOMJ4,7632
8
+ d8s_python-0.10.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any