polyglot-piranha 0.3.2__cp38-cp38-manylinux_2_34_x86_64.whl → 0.3.4__cp38-cp38-manylinux_2_34_x86_64.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.
- polyglot_piranha/__init__.pyi +54 -42
- polyglot_piranha/polyglot_piranha.cpython-38-x86_64-linux-gnu.so +0 -0
- {polyglot_piranha-0.3.2.dist-info → polyglot_piranha-0.3.4.dist-info}/METADATA +2 -2
- polyglot_piranha-0.3.4.dist-info/RECORD +10 -0
- {polyglot_piranha-0.3.2.dist-info → polyglot_piranha-0.3.4.dist-info}/WHEEL +1 -1
- polyglot_piranha-0.3.2.dist-info/RECORD +0 -10
- {polyglot_piranha-0.3.2.dist-info → polyglot_piranha-0.3.4.dist-info}/license_files/LICENSE +0 -0
- {polyglot_piranha-0.3.2.dist-info → polyglot_piranha-0.3.4.dist-info}/license_files/NOTICE +0 -0
polyglot_piranha/__init__.pyi
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
# express or implied. See the License for the specific language governing permissions and
|
10
10
|
# limitations under the License.
|
11
11
|
|
12
|
-
from typing import Optional
|
12
|
+
from typing import List, Optional
|
13
13
|
|
14
14
|
|
15
15
|
def execute_piranha(piranha_argument: PiranhaArguments) -> list[PiranhaOutputSummary]:
|
@@ -33,20 +33,22 @@ class PiranhaArguments:
|
|
33
33
|
def __init__(
|
34
34
|
self,
|
35
35
|
language: str,
|
36
|
+
path_to_codebase: Optional[str] = None,
|
37
|
+
include: Optional[List[str]] = None,
|
38
|
+
exclude: Optional[List[str]] = None,
|
36
39
|
substitutions: Optional[dict] = None,
|
37
40
|
path_to_configurations: Optional[str] = None,
|
38
41
|
rule_graph: Optional[RuleGraph]= None,
|
39
|
-
path_to_codebase: Optional[str] = None,
|
40
42
|
code_snippet: Optional[str] = None,
|
41
43
|
dry_run: Optional[bool] = None,
|
42
44
|
cleanup_comments: Optional[bool] = None,
|
43
45
|
cleanup_comments_buffer: Optional[int] = None,
|
44
46
|
number_of_ancestors_in_parent_scope: Optional[int] = None,
|
45
|
-
delete_consecutive_new_lines
|
47
|
+
delete_consecutive_new_lines: Optional[bool] = None,
|
46
48
|
global_tag_prefix: Optional[str] = 'GLOBAL_TAG',
|
47
|
-
delete_file_if_empty
|
49
|
+
delete_file_if_empty: Optional[bool] = None,
|
48
50
|
path_to_output: Optional[str] = None,
|
49
|
-
allow_dirty_ast
|
51
|
+
allow_dirty_ast: Optional[bool] = None
|
50
52
|
):
|
51
53
|
"""
|
52
54
|
Constructs `PiranhaArguments`
|
@@ -55,21 +57,22 @@ class PiranhaArguments:
|
|
55
57
|
------------
|
56
58
|
language: str
|
57
59
|
the target language
|
60
|
+
path_to_codebase: str
|
61
|
+
Path to source code folder or file
|
58
62
|
keyword arguments: _
|
59
|
-
substitutions (dict)
|
60
|
-
path_to_configurations (str)
|
61
|
-
rule_graph (RuleGraph)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
cleanup_comments (bool) : Enables deletion of associated comments
|
63
|
+
substitutions (dict): Substitutions to instantiate the initial set of rules
|
64
|
+
path_to_configurations (str): Directory containing the configuration files - `piranha_arguments.toml`, `rules.toml`, and `edges.toml`
|
65
|
+
rule_graph (RuleGraph): The rule graph constructed via RuleGraph DSL
|
66
|
+
code_snippet (str): The input code snippet to transform
|
67
|
+
dry_run (bool): Disables in-place rewriting of code
|
68
|
+
cleanup_comments (bool): Enables deletion of associated comments
|
66
69
|
cleanup_comments_buffer (int): The number of lines to consider for cleaning up the comments
|
67
70
|
number_of_ancestors_in_parent_scope (int): The number of ancestors considered when PARENT rules
|
68
|
-
delete_consecutive_new_lines (bool)
|
71
|
+
delete_consecutive_new_lines (bool): Replaces consecutive \ns with a \n
|
69
72
|
global_tag_prefix (str): the prefix for global tags
|
70
73
|
delete_file_if_empty (bool): User option that determines whether an empty file will be deleted
|
71
74
|
path_to_output (str): Path to the output json file
|
72
|
-
allow_dirty_ast (bool)
|
75
|
+
allow_dirty_ast (bool): Allows syntax errors in the input source code
|
73
76
|
"""
|
74
77
|
...
|
75
78
|
|
@@ -79,9 +82,9 @@ class PiranhaOutputSummary:
|
|
79
82
|
|
80
83
|
Attributes
|
81
84
|
----------
|
82
|
-
path
|
83
|
-
content
|
84
|
-
matches
|
85
|
+
path: path to the file
|
86
|
+
content: content of the file after all the rewrites
|
87
|
+
matches: All the occurrences of "match-only" rules
|
85
88
|
rewrites: All the applied edits
|
86
89
|
"""
|
87
90
|
|
@@ -106,9 +109,9 @@ class Edit:
|
|
106
109
|
|
107
110
|
Attributes
|
108
111
|
----------
|
109
|
-
p_match
|
110
|
-
replacement_string
|
111
|
-
matched_rule
|
112
|
+
p_match: The match representing the target site of the edit
|
113
|
+
replacement_string: The string to replace the substring encompassed by the match
|
114
|
+
matched_rule: The rule used for creating this match-replace
|
112
115
|
"""
|
113
116
|
|
114
117
|
p_match: Match
|
@@ -126,9 +129,9 @@ class Match:
|
|
126
129
|
|
127
130
|
Attributes
|
128
131
|
----------
|
129
|
-
matched_sting
|
130
|
-
range
|
131
|
-
matches
|
132
|
+
matched_sting: Code snippet that matched
|
133
|
+
range: Range of the entire AST node captured by the match
|
134
|
+
matches: The mapping between tags and string representation of the AST captured
|
132
135
|
"""
|
133
136
|
|
134
137
|
matched_string: str
|
@@ -155,28 +158,37 @@ class Point:
|
|
155
158
|
row: int
|
156
159
|
column: int
|
157
160
|
|
158
|
-
class
|
159
|
-
""" A class to capture
|
161
|
+
class Filter:
|
162
|
+
""" A class to capture filters of a Piranha Rule
|
160
163
|
"""
|
161
|
-
|
162
|
-
"
|
163
|
-
|
164
|
-
"
|
165
|
-
|
164
|
+
enclosing_node: TSQuery
|
165
|
+
"AST patterns that some ancestor node of the primary match should comply"
|
166
|
+
not_contains: list[TSQuery]
|
167
|
+
"AST patterns that SHOULD NOT match any subtree of node matching `enclosing_node` pattern"
|
168
|
+
contains: TSQuery
|
169
|
+
"AST pattern that SHOULD match subtrees of `enclosing_node`. " \
|
170
|
+
"Number of matches should be within the range of `at_least` and `at_most`."
|
171
|
+
at_least: int
|
172
|
+
"The minimum number of times the contains query should match in the enclosing node"
|
173
|
+
at_most: int
|
174
|
+
"The maximum number of times the contains query should match in the enclosing node"
|
166
175
|
def __init__(
|
167
176
|
self,
|
168
|
-
|
169
|
-
|
177
|
+
enclosing_node: str = '',
|
178
|
+
not_contains: list[str] = [],
|
179
|
+
contains: str = '',
|
180
|
+
at_least: int = 1,
|
181
|
+
at_most: int = 4294967295 # u32::MAX
|
170
182
|
):
|
171
183
|
"""
|
172
|
-
Constructs `
|
184
|
+
Constructs `Filter`
|
173
185
|
|
174
186
|
Parameters
|
175
187
|
------------
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
188
|
+
enclosing_node: str
|
189
|
+
AST patterns that some ancestor node of the primary match should comply
|
190
|
+
not_contains: list[str]
|
191
|
+
AST patterns that should not match any subtree of node matching `enclosing_node` pattern
|
180
192
|
"""
|
181
193
|
...
|
182
194
|
|
@@ -195,8 +207,8 @@ class Rule:
|
|
195
207
|
"Group(s) to which the rule belongs"
|
196
208
|
holes: set[str]
|
197
209
|
"Holes that need to be filled, in order to instantiate a rule"
|
198
|
-
|
199
|
-
"
|
210
|
+
filters: set[Filter]
|
211
|
+
"Filters to test before applying a rule"
|
200
212
|
|
201
213
|
def __init__(
|
202
214
|
self,
|
@@ -206,7 +218,7 @@ class Rule:
|
|
206
218
|
replace: Optional[str] = None,
|
207
219
|
groups: set[str] = set(),
|
208
220
|
holes: set[str] = set(),
|
209
|
-
|
221
|
+
filters: set[Filter] = set(),
|
210
222
|
is_seed_rule: bool = True,
|
211
223
|
):
|
212
224
|
"""
|
@@ -226,8 +238,8 @@ class Rule:
|
|
226
238
|
Group(s) to which the rule belongs
|
227
239
|
holes: set[str]
|
228
240
|
Holes that need to be filled, in order to instantiate a rule
|
229
|
-
|
230
|
-
|
241
|
+
filters: set[Filter]
|
242
|
+
Filters to test before applying a rule
|
231
243
|
"""
|
232
244
|
...
|
233
245
|
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: polyglot_piranha
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.4
|
4
4
|
License-File: LICENSE
|
5
5
|
License-File: LICENSE
|
6
6
|
License-File: NOTICE
|
@@ -10,9 +10,9 @@ Author: Uber Technologies Inc.
|
|
10
10
|
Author-email: Ameya Ketkar <ketkara@uber.com>, Lazaro Clapp <lazaro@uber.com>
|
11
11
|
Requires-Python: >=3.7
|
12
12
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
13
|
-
Project-URL: repository, https://github.com/uber/piranha
|
14
13
|
Project-URL: homepage, https://github.com/uber/piranha
|
15
14
|
Project-URL: documentation, https://github.com/uber/piranha
|
15
|
+
Project-URL: repository, https://github.com/uber/piranha
|
16
16
|
|
17
17
|
# Piranha
|
18
18
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
polyglot_piranha-0.3.4.dist-info/METADATA,sha256=0ibaLIqcy7Fg1mUV_0ZWFWjxyo7RlwQlizMsNYbVuWQ,3797
|
2
|
+
polyglot_piranha-0.3.4.dist-info/WHEEL,sha256=K7DQ9RCm11tsJ0DJdvmWY0f4XhkpQWD3FWjOaNUCKcs,106
|
3
|
+
polyglot_piranha-0.3.4.dist-info/license_files/LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
|
4
|
+
polyglot_piranha-0.3.4.dist-info/license_files/LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
|
5
|
+
polyglot_piranha-0.3.4.dist-info/license_files/NOTICE,sha256=9bEJKCdL0MABjEknpMHXbYBZSkGVGRXYcSxSXS293X0,147
|
6
|
+
polyglot_piranha/__init__.py,sha256=pghVgChf0-NgAG_zd7CzKtvFuBDxg5Wh-GcHx2PoTzg,147
|
7
|
+
polyglot_piranha/__init__.pyi,sha256=sDMJC2xnL0QPNkBARAljzgwu7D-hbccyC-79r9p0djw,9476
|
8
|
+
polyglot_piranha/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
+
polyglot_piranha/polyglot_piranha.cpython-38-x86_64-linux-gnu.so,sha256=C4ew_I0ev7teG6Lcozl-XpIp1ZkxYKmiy61Ja8SFwgw,88282168
|
10
|
+
polyglot_piranha-0.3.4.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
polyglot_piranha-0.3.2.dist-info/METADATA,sha256=E12qkch7UKdhsVFxe6UYwQGEKJZT-O2ES_2U_Cc-17k,3797
|
2
|
-
polyglot_piranha-0.3.2.dist-info/WHEEL,sha256=d-aPevxyEa_9vw-z4aWRQWRSKHVEM0xQZ-sv4FQt1ZE,108
|
3
|
-
polyglot_piranha-0.3.2.dist-info/license_files/LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
|
4
|
-
polyglot_piranha-0.3.2.dist-info/license_files/LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
|
5
|
-
polyglot_piranha-0.3.2.dist-info/license_files/NOTICE,sha256=9bEJKCdL0MABjEknpMHXbYBZSkGVGRXYcSxSXS293X0,147
|
6
|
-
polyglot_piranha/__init__.py,sha256=pghVgChf0-NgAG_zd7CzKtvFuBDxg5Wh-GcHx2PoTzg,147
|
7
|
-
polyglot_piranha/__init__.pyi,sha256=286ZkzHJTGYUMqn6ZxHcvEzn_u1DkYLfMaFwzrSyH0M,8845
|
8
|
-
polyglot_piranha/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
-
polyglot_piranha/polyglot_piranha.cpython-38-x86_64-linux-gnu.so,sha256=YJ0Zf0N5GcUaa1mU9pc8h1b1K0W_v1SpaVicBHV0-PY,84310040
|
10
|
-
polyglot_piranha-0.3.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|