pythonqtside 1.1.12__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.
- pythonqtside/Qt.py +14 -0
- pythonqtside/QtCore.py +14 -0
- pythonqtside/QtGui.py +14 -0
- pythonqtside/QtNetwork.py +14 -0
- pythonqtside/QtOpenGL.py +14 -0
- pythonqtside/QtSvg.py +14 -0
- pythonqtside/QtUiTools.py +14 -0
- pythonqtside/QtWidgets.py +14 -0
- pythonqtside/QtXmlPatterns.py +14 -0
- pythonqtside/__init__.py +34 -0
- pythonqtside/_app.py +319 -0
- pythonqtside/_app_cleanup.py +216 -0
- pythonqtside/_app_conversions.py +106 -0
- pythonqtside/_app_dialogs.py +74 -0
- pythonqtside/_app_flags.py +79 -0
- pythonqtside/_app_imports.py +146 -0
- pythonqtside/_app_keywords.py +210 -0
- pythonqtside/_app_native.py +404 -0
- pythonqtside/_app_proxy.py +43 -0
- pythonqtside/_app_source.py +110 -0
- pythonqtside/_differences.json +9808 -0
- pythonqtside/_flags.json +210 -0
- pythonqtside/_implicit_conversions.json +1975 -0
- pythonqtside/_inventory.json +115478 -0
- pythonqtside/_keywords.json +1 -0
- pythonqtside/_out_parameters.json +465 -0
- pythonqtside/_qtwidgets.json +202 -0
- pythonqtside/_routing.py +95 -0
- pythonqtside/compat.py +44 -0
- pythonqtside/tooling/__init__.py +2 -0
- pythonqtside/tooling/conversions.py +433 -0
- pythonqtside/tooling/differences.py +290 -0
- pythonqtside/tooling/flags.py +156 -0
- pythonqtside/tooling/inventory.py +149 -0
- pythonqtside/tooling/join.py +184 -0
- pythonqtside/tooling/keywords.py +259 -0
- pythonqtside/tooling/surface.py +191 -0
- pythonqtside-1.1.12.dist-info/METADATA +468 -0
- pythonqtside-1.1.12.dist-info/RECORD +42 -0
- pythonqtside-1.1.12.dist-info/WHEEL +4 -0
- pythonqtside-1.1.12.dist-info/licenses/LICENSE +201 -0
- pythonqtside-1.1.12.dist-info/licenses/NOTICE +7 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# this_file: src/pythonqtside/_app_source.py
|
|
2
|
+
"""Adapt calls in memory while retaining original filenames and line numbers."""
|
|
3
|
+
|
|
4
|
+
import ast
|
|
5
|
+
import hashlib
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Calls(ast.NodeTransformer):
|
|
9
|
+
"""Prepare the callee; keep its invocation in the original Python frame."""
|
|
10
|
+
|
|
11
|
+
def __init__(self, call_name: str, resolve_name: str) -> None:
|
|
12
|
+
self.call_name = call_name
|
|
13
|
+
self.resolve_name = resolve_name
|
|
14
|
+
self.locations: list[dict[str, int]] = []
|
|
15
|
+
self.super_locations: list[dict[str, int]] = []
|
|
16
|
+
|
|
17
|
+
def visit_Call(self, node: ast.Call) -> ast.Call:
|
|
18
|
+
# Record syntax before visiting children rewrites the inner super call.
|
|
19
|
+
match node.func:
|
|
20
|
+
case ast.Attribute(value=ast.Call(func=ast.Name(id="super"))):
|
|
21
|
+
self.super_locations.append(
|
|
22
|
+
{"line": node.lineno, "column": node.col_offset}
|
|
23
|
+
)
|
|
24
|
+
if isinstance(node.func, ast.Attribute):
|
|
25
|
+
# The callee attribute is adapted below; only its receiver is visited,
|
|
26
|
+
# so visit_Attribute never rewrites a method being called.
|
|
27
|
+
node.func.value = self.visit(node.func.value)
|
|
28
|
+
node.args = [self.visit(arg) for arg in node.args]
|
|
29
|
+
node.keywords = [self.visit(keyword) for keyword in node.keywords]
|
|
30
|
+
else:
|
|
31
|
+
self.generic_visit(node)
|
|
32
|
+
self.locations.append({"line": node.lineno, "column": node.col_offset})
|
|
33
|
+
callee = node.func
|
|
34
|
+
if isinstance(callee, ast.Attribute):
|
|
35
|
+
# Keyword call sites tell the resolver to map PySide2 keyword names.
|
|
36
|
+
keywords = [ast.Constant(True)] if node.keywords else []
|
|
37
|
+
receiver, attribute = callee.value, [ast.Constant(callee.attr)]
|
|
38
|
+
# `owner.signal.connect(cb)`: pass the owner and signal name too, so a
|
|
39
|
+
# callback can reach the signal overload matching its arity.
|
|
40
|
+
if callee.attr in {"connect", "disconnect"} and isinstance(
|
|
41
|
+
receiver, ast.Attribute
|
|
42
|
+
):
|
|
43
|
+
attribute = [
|
|
44
|
+
ast.Constant(receiver.attr),
|
|
45
|
+
ast.Constant(bool(node.keywords)),
|
|
46
|
+
ast.Constant(callee.attr),
|
|
47
|
+
]
|
|
48
|
+
receiver, keywords = receiver.value, []
|
|
49
|
+
callee = ast.copy_location(
|
|
50
|
+
ast.Call(
|
|
51
|
+
func=ast.Name(id=self.resolve_name, ctx=ast.Load()),
|
|
52
|
+
args=[receiver, *attribute, *keywords],
|
|
53
|
+
keywords=[],
|
|
54
|
+
),
|
|
55
|
+
callee,
|
|
56
|
+
)
|
|
57
|
+
node.func = ast.copy_location(
|
|
58
|
+
ast.Call(
|
|
59
|
+
func=ast.Name(id=self.call_name, ctx=ast.Load()),
|
|
60
|
+
# A keyword call site also maps keywords of a captured native method.
|
|
61
|
+
args=[callee, *([ast.Constant(True)] if node.keywords else [])],
|
|
62
|
+
keywords=[],
|
|
63
|
+
),
|
|
64
|
+
node.func,
|
|
65
|
+
)
|
|
66
|
+
return node
|
|
67
|
+
|
|
68
|
+
def visit_Attribute(self, node: ast.Attribute) -> ast.AST:
|
|
69
|
+
"""``base = super().name`` (a load, not a call): resolve it like a super
|
|
70
|
+
call, so a native base method PythonQt's super() misses is still found and
|
|
71
|
+
a later keyword call is mapped."""
|
|
72
|
+
match node: # checked before visiting rewrites the inner super() call
|
|
73
|
+
case ast.Attribute(
|
|
74
|
+
value=ast.Call(func=ast.Name(id="super")), ctx=ast.Load()
|
|
75
|
+
):
|
|
76
|
+
super_load = True
|
|
77
|
+
case _:
|
|
78
|
+
super_load = False
|
|
79
|
+
self.generic_visit(node)
|
|
80
|
+
if super_load:
|
|
81
|
+
self.super_locations.append(
|
|
82
|
+
{"line": node.lineno, "column": node.col_offset}
|
|
83
|
+
)
|
|
84
|
+
return ast.copy_location(
|
|
85
|
+
ast.Call(
|
|
86
|
+
func=ast.Name(id=self.resolve_name, ctx=ast.Load()),
|
|
87
|
+
args=[node.value, ast.Constant(node.attr), ast.Constant(True)],
|
|
88
|
+
keywords=[],
|
|
89
|
+
),
|
|
90
|
+
node,
|
|
91
|
+
)
|
|
92
|
+
return node
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def adapt_source(
|
|
96
|
+
source: str, filename: str, *, call_name: str, resolve_name: str
|
|
97
|
+
) -> tuple[ast.Module, dict]:
|
|
98
|
+
"""Produce a compilable AST and original-source provenance without I/O."""
|
|
99
|
+
tree = ast.parse(source, filename=filename)
|
|
100
|
+
transformer = Calls(call_name, resolve_name)
|
|
101
|
+
tree = ast.fix_missing_locations(transformer.visit(tree))
|
|
102
|
+
return tree, {
|
|
103
|
+
"original_source": source,
|
|
104
|
+
"source_sha256": hashlib.sha256(source.encode()).hexdigest(),
|
|
105
|
+
"call_sites": len(transformer.locations),
|
|
106
|
+
"locations": transformer.locations,
|
|
107
|
+
# These are rewritten source sites, not counts of runtime fallback use.
|
|
108
|
+
"super_call_sites": len(transformer.super_locations),
|
|
109
|
+
"super_locations": transformer.super_locations,
|
|
110
|
+
}
|