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.
Files changed (42) hide show
  1. pythonqtside/Qt.py +14 -0
  2. pythonqtside/QtCore.py +14 -0
  3. pythonqtside/QtGui.py +14 -0
  4. pythonqtside/QtNetwork.py +14 -0
  5. pythonqtside/QtOpenGL.py +14 -0
  6. pythonqtside/QtSvg.py +14 -0
  7. pythonqtside/QtUiTools.py +14 -0
  8. pythonqtside/QtWidgets.py +14 -0
  9. pythonqtside/QtXmlPatterns.py +14 -0
  10. pythonqtside/__init__.py +34 -0
  11. pythonqtside/_app.py +319 -0
  12. pythonqtside/_app_cleanup.py +216 -0
  13. pythonqtside/_app_conversions.py +106 -0
  14. pythonqtside/_app_dialogs.py +74 -0
  15. pythonqtside/_app_flags.py +79 -0
  16. pythonqtside/_app_imports.py +146 -0
  17. pythonqtside/_app_keywords.py +210 -0
  18. pythonqtside/_app_native.py +404 -0
  19. pythonqtside/_app_proxy.py +43 -0
  20. pythonqtside/_app_source.py +110 -0
  21. pythonqtside/_differences.json +9808 -0
  22. pythonqtside/_flags.json +210 -0
  23. pythonqtside/_implicit_conversions.json +1975 -0
  24. pythonqtside/_inventory.json +115478 -0
  25. pythonqtside/_keywords.json +1 -0
  26. pythonqtside/_out_parameters.json +465 -0
  27. pythonqtside/_qtwidgets.json +202 -0
  28. pythonqtside/_routing.py +95 -0
  29. pythonqtside/compat.py +44 -0
  30. pythonqtside/tooling/__init__.py +2 -0
  31. pythonqtside/tooling/conversions.py +433 -0
  32. pythonqtside/tooling/differences.py +290 -0
  33. pythonqtside/tooling/flags.py +156 -0
  34. pythonqtside/tooling/inventory.py +149 -0
  35. pythonqtside/tooling/join.py +184 -0
  36. pythonqtside/tooling/keywords.py +259 -0
  37. pythonqtside/tooling/surface.py +191 -0
  38. pythonqtside-1.1.12.dist-info/METADATA +468 -0
  39. pythonqtside-1.1.12.dist-info/RECORD +42 -0
  40. pythonqtside-1.1.12.dist-info/WHEEL +4 -0
  41. pythonqtside-1.1.12.dist-info/licenses/LICENSE +201 -0
  42. 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
+ }