astToolkit 0.3.3__tar.gz → 0.3.4__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.
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/PKG-INFO +1 -1
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/__init__.py +2 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_astTypes.py +7 -1
- asttoolkit-0.3.4/astToolkit/_dumpFunctionDef.py +76 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_toolBe.py +0 -1
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_toolkitAST.py +6 -11
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_types.py +1 -2
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit.egg-info/PKG-INFO +1 -1
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit.egg-info/SOURCES.txt +1 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/pyproject.toml +1 -1
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/LICENSE +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/README.md +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_joinClassmethod.py +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_theSSOT.py +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_toolClassIsAndAttribute.py +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_toolDOT.py +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_toolGrab.py +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_toolIfThis.py +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_toolMake.py +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_toolThen.py +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_toolkitContainers.py +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/_toolkitNodeVisitor.py +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/py.typed +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit/transformationTools.py +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit.egg-info/dependency_links.txt +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit.egg-info/requires.txt +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/astToolkit.egg-info/top_level.txt +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/setup.cfg +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/tests/conftest.py +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/tests/test_basic.py +0 -0
- {asttoolkit-0.3.3 → asttoolkit-0.3.4}/tests/test_joinClassmethod.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astToolkit
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: A powerfully composable, type-safe toolkit for Python abstract syntax tree (AST) manipulation, analysis, transformation, and code generation with a layered architecture designed for building sophisticated code processing assembly-lines.
|
|
5
5
|
Author-email: Hunter Hogan <HunterHogan@pm.me>
|
|
6
6
|
License: CC-BY-NC-4.0
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""This file is generated automatically, so changes to this file will be lost."""
|
|
2
|
-
from typing import Any, TypeAlias as typing_TypeAlias, TypeVar as typing_TypeVar
|
|
2
|
+
from typing import Any, TypeAlias as typing_TypeAlias, TypedDict, TypeVar as typing_TypeVar
|
|
3
3
|
import ast
|
|
4
4
|
import sys
|
|
5
5
|
intORstr: typing_TypeAlias = Any
|
|
@@ -8,6 +8,12 @@ intORtype_params: typing_TypeAlias = Any
|
|
|
8
8
|
木 = typing_TypeVar('木', bound=ast.AST, covariant=True)
|
|
9
9
|
个 = typing_TypeVar('个', covariant=True)
|
|
10
10
|
个return = typing_TypeVar('个return', covariant=True)
|
|
11
|
+
|
|
12
|
+
class ast_attributes(TypedDict, total=False):
|
|
13
|
+
lineno: int
|
|
14
|
+
col_offset: int
|
|
15
|
+
end_lineno: int | None
|
|
16
|
+
end_col_offset: int | None
|
|
11
17
|
hasDOTannotation_expr: typing_TypeAlias = ast.AnnAssign
|
|
12
18
|
hasDOTannotation_exprOrNone: typing_TypeAlias = ast.arg
|
|
13
19
|
hasDOTannotation: typing_TypeAlias = hasDOTannotation_expr | hasDOTannotation_exprOrNone
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from _ast import *
|
|
2
|
+
|
|
3
|
+
def dump(node, annotate_fields=True, include_attributes=False, *, indent=None, show_empty=False):
|
|
4
|
+
"""
|
|
5
|
+
Return a formatted dump of the tree in node. This is mainly useful for
|
|
6
|
+
debugging purposes. If annotate_fields is true (by default),
|
|
7
|
+
the returned string will show the names and the values for fields.
|
|
8
|
+
If annotate_fields is false, the result string will be more compact by
|
|
9
|
+
omitting unambiguous field names. Attributes such as line
|
|
10
|
+
numbers and column offsets are not dumped by default. If this is wanted,
|
|
11
|
+
include_attributes can be set to true. If indent is a non-negative
|
|
12
|
+
integer or string, then the tree will be pretty-printed with that indent
|
|
13
|
+
level. None (the default) selects the single line representation.
|
|
14
|
+
If show_empty is False, then empty lists and fields that are None
|
|
15
|
+
will be omitted from the output for better readability.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def _format(node, level=0):
|
|
19
|
+
if indent is not None:
|
|
20
|
+
level += 1
|
|
21
|
+
prefix = '\n' + indent * level
|
|
22
|
+
sep = ',\n' + indent * level
|
|
23
|
+
else:
|
|
24
|
+
prefix = ''
|
|
25
|
+
sep = ', '
|
|
26
|
+
if isinstance(node, AST):
|
|
27
|
+
cls = type(node)
|
|
28
|
+
args = []
|
|
29
|
+
args_buffer = []
|
|
30
|
+
allsimple = True
|
|
31
|
+
keywords = annotate_fields
|
|
32
|
+
for name in node._fields:
|
|
33
|
+
try:
|
|
34
|
+
value = getattr(node, name)
|
|
35
|
+
except AttributeError:
|
|
36
|
+
keywords = True
|
|
37
|
+
continue
|
|
38
|
+
if value is None and getattr(cls, name, ...) is None:
|
|
39
|
+
keywords = True
|
|
40
|
+
continue
|
|
41
|
+
if not show_empty and (value is None or value == []) and (not isinstance(node, (Constant, MatchSingleton))):
|
|
42
|
+
args_buffer.append(repr(value))
|
|
43
|
+
continue
|
|
44
|
+
elif not keywords:
|
|
45
|
+
args.extend(args_buffer)
|
|
46
|
+
args_buffer = []
|
|
47
|
+
value, simple = _format(value, level)
|
|
48
|
+
allsimple = allsimple and simple
|
|
49
|
+
if keywords:
|
|
50
|
+
args.append('%s=%s' % (name, value))
|
|
51
|
+
else:
|
|
52
|
+
args.append(value)
|
|
53
|
+
if include_attributes and node._attributes:
|
|
54
|
+
for name in node._attributes:
|
|
55
|
+
try:
|
|
56
|
+
value = getattr(node, name)
|
|
57
|
+
except AttributeError:
|
|
58
|
+
continue
|
|
59
|
+
if value is None and getattr(cls, name, ...) is None:
|
|
60
|
+
continue
|
|
61
|
+
value, simple = _format(value, level)
|
|
62
|
+
allsimple = allsimple and simple
|
|
63
|
+
args.append('%s=%s' % (name, value))
|
|
64
|
+
if allsimple and len(args) <= 3:
|
|
65
|
+
return ('%s(%s)' % ('ast.' + node.__class__.__name__, ', '.join(args)), not args)
|
|
66
|
+
return ('%s(%s%s)' % ('ast.' + node.__class__.__name__, prefix, sep.join(args)), False)
|
|
67
|
+
elif isinstance(node, list):
|
|
68
|
+
if not node:
|
|
69
|
+
return ('[]', True)
|
|
70
|
+
return ('[%s%s]' % (prefix, sep.join((_format(x, level)[0] for x in node))), False)
|
|
71
|
+
return (repr(node), True)
|
|
72
|
+
if not isinstance(node, AST):
|
|
73
|
+
raise TypeError('expected AST, got %r' % node.__class__.__name__)
|
|
74
|
+
if indent is not None and (not isinstance(indent, str)):
|
|
75
|
+
indent = ' ' * indent
|
|
76
|
+
return _format(node)[0]
|
|
@@ -22,9 +22,6 @@ def astModuleToIngredientsFunction(astModule: ast.AST, identifierFunctionDef: st
|
|
|
22
22
|
Returns:
|
|
23
23
|
ingredientsFunction: `IngredientsFunction` object containing the `ast.FunctionDef` and _all_ imports from the
|
|
24
24
|
source module.
|
|
25
|
-
|
|
26
|
-
Raises:
|
|
27
|
-
FREAKOUT: If the function definition is not found.
|
|
28
25
|
"""
|
|
29
26
|
astFunctionDef = raiseIfNone(extractFunctionDef(astModule, identifierFunctionDef))
|
|
30
27
|
return IngredientsFunction(astFunctionDef, LedgerOfImports(astModule))
|
|
@@ -74,10 +71,9 @@ def parseLogicalPath2astModule(logicalPathModule: str_nameDOTname, packageIdenti
|
|
|
74
71
|
The logical path to the module using dot notation (e.g., 'package.module').
|
|
75
72
|
packageIdentifierIfRelative : None
|
|
76
73
|
The package identifier to use if the module path is relative, defaults to None.
|
|
77
|
-
mode :
|
|
78
|
-
The mode parameter for `ast.parse`. Default is `
|
|
79
|
-
|
|
80
|
-
`ast.parse` documentation for some details and much confusion.
|
|
74
|
+
mode : 'exec'
|
|
75
|
+
The mode parameter for `ast.parse`. Default is `'exec'`. Options are `'exec'`, `'eval'`, `'func_type'`, `'single'`. See
|
|
76
|
+
`ast.parse` documentation.
|
|
81
77
|
|
|
82
78
|
Returns
|
|
83
79
|
-------
|
|
@@ -99,10 +95,9 @@ def parsePathFilename2astModule(pathFilename: PathLike[Any] | PurePath, mode: Li
|
|
|
99
95
|
----------
|
|
100
96
|
pathFilename
|
|
101
97
|
The path to the file to be parsed. Can be a string path, PathLike object, or PurePath object.
|
|
102
|
-
mode :
|
|
103
|
-
The mode parameter for `ast.parse`. Default is `
|
|
104
|
-
|
|
105
|
-
`ast.parse` documentation for some details and much confusion.
|
|
98
|
+
mode : 'exec'
|
|
99
|
+
The mode parameter for `ast.parse`. Default is `'exec'`. Options are `'exec'`, `'eval'`, `'func_type'`, `'single'`. See
|
|
100
|
+
`ast.parse` documentation.
|
|
106
101
|
|
|
107
102
|
Returns
|
|
108
103
|
-------
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import TypeAlias as typing_TypeAlias
|
|
2
2
|
import ast
|
|
3
|
-
import sys
|
|
4
3
|
|
|
5
4
|
# Type hints through TypeAlias or type "hints" through the identifier name.
|
|
6
5
|
str_nameDOTname: typing_TypeAlias = str
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astToolkit
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: A powerfully composable, type-safe toolkit for Python abstract syntax tree (AST) manipulation, analysis, transformation, and code generation with a layered architecture designed for building sophisticated code processing assembly-lines.
|
|
5
5
|
Author-email: Hunter Hogan <HunterHogan@pm.me>
|
|
6
6
|
License: CC-BY-NC-4.0
|
|
@@ -36,7 +36,7 @@ optional-dependencies = { testing = [
|
|
|
36
36
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
37
37
|
requires-python = ">=3.12"
|
|
38
38
|
urls = { Donate = "https://www.patreon.com/integrated", Homepage = "https://github.com/hunterhogan/astToolkit", Issues = "https://github.com/hunterhogan/astToolkit/issues", Repository = "https://github.com/hunterhogan/astToolkit.git" }
|
|
39
|
-
version = "0.3.
|
|
39
|
+
version = "0.3.4"
|
|
40
40
|
|
|
41
41
|
[tool.coverage]
|
|
42
42
|
report = { exclude_lines = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|