polyglot-piranha 0.3.0__cp38-cp38-macosx_10_16_x86_64.whl → 0.3.4__cp38-cp38-macosx_10_16_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 +64 -47
- polyglot_piranha/polyglot_piranha.cpython-38-darwin.so +0 -0
- {polyglot_piranha-0.3.0.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.0.dist-info → polyglot_piranha-0.3.4.dist-info}/WHEEL +1 -1
- polyglot_piranha-0.3.0.dist-info/RECORD +0 -10
- {polyglot_piranha-0.3.0.dist-info → polyglot_piranha-0.3.4.dist-info}/license_files/LICENSE +0 -0
- {polyglot_piranha-0.3.0.dist-info → polyglot_piranha-0.3.4.dist-info}/license_files/NOTICE +0 -0
polyglot_piranha/__init__.pyi
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2023 Uber Technologies, Inc.
|
2
2
|
#
|
3
3
|
# <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
4
4
|
# except in compliance with the License. You may obtain a copy of the License at
|
@@ -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,19 +33,22 @@ class PiranhaArguments:
|
|
33
33
|
def __init__(
|
34
34
|
self,
|
35
35
|
language: str,
|
36
|
-
substitutions: dict,
|
37
|
-
path_to_configurations: Optional[str],
|
38
|
-
rule_graph: Optional[RuleGraph]= None,
|
39
36
|
path_to_codebase: Optional[str] = None,
|
37
|
+
include: Optional[List[str]] = None,
|
38
|
+
exclude: Optional[List[str]] = None,
|
39
|
+
substitutions: Optional[dict] = None,
|
40
|
+
path_to_configurations: Optional[str] = None,
|
41
|
+
rule_graph: Optional[RuleGraph]= 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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
delete_consecutive_new_lines: Optional[bool] = None,
|
48
|
+
global_tag_prefix: Optional[str] = 'GLOBAL_TAG',
|
49
|
+
delete_file_if_empty: Optional[bool] = None,
|
50
|
+
path_to_output: Optional[str] = None,
|
51
|
+
allow_dirty_ast: Optional[bool] = None
|
49
52
|
):
|
50
53
|
"""
|
51
54
|
Constructs `PiranhaArguments`
|
@@ -54,20 +57,22 @@ class PiranhaArguments:
|
|
54
57
|
------------
|
55
58
|
language: str
|
56
59
|
the target language
|
57
|
-
|
58
|
-
|
60
|
+
path_to_codebase: str
|
61
|
+
Path to source code folder or file
|
59
62
|
keyword arguments: _
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
code_snippet (str)
|
64
|
-
dry_run (bool)
|
65
|
-
cleanup_comments (bool)
|
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
|
71
|
+
delete_consecutive_new_lines (bool): Replaces consecutive \ns with a \n
|
72
|
+
global_tag_prefix (str): the prefix for global tags
|
68
73
|
delete_file_if_empty (bool): User option that determines whether an empty file will be deleted
|
69
|
-
delete_consecutive_new_lines (bool) : Replaces consecutive \ns with a \n
|
70
74
|
path_to_output (str): Path to the output json file
|
75
|
+
allow_dirty_ast (bool): Allows syntax errors in the input source code
|
71
76
|
"""
|
72
77
|
...
|
73
78
|
|
@@ -77,17 +82,20 @@ class PiranhaOutputSummary:
|
|
77
82
|
|
78
83
|
Attributes
|
79
84
|
----------
|
80
|
-
path
|
81
|
-
content
|
82
|
-
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
|
83
88
|
rewrites: All the applied edits
|
84
89
|
"""
|
85
90
|
|
86
91
|
path: str
|
87
92
|
"path to the file"
|
88
93
|
|
94
|
+
original_content: str
|
95
|
+
"Original content of the file before any rewrites"
|
96
|
+
|
89
97
|
content: str
|
90
|
-
"content of the file after all the rewrites"
|
98
|
+
"Final content of the file after all the rewrites"
|
91
99
|
|
92
100
|
matches: list[tuple[str, Match]]
|
93
101
|
'All the occurrences of "match-only" rules'
|
@@ -101,9 +109,9 @@ class Edit:
|
|
101
109
|
|
102
110
|
Attributes
|
103
111
|
----------
|
104
|
-
p_match
|
105
|
-
replacement_string
|
106
|
-
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
|
107
115
|
"""
|
108
116
|
|
109
117
|
p_match: Match
|
@@ -121,9 +129,9 @@ class Match:
|
|
121
129
|
|
122
130
|
Attributes
|
123
131
|
----------
|
124
|
-
matched_sting
|
125
|
-
range
|
126
|
-
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
|
127
135
|
"""
|
128
136
|
|
129
137
|
matched_string: str
|
@@ -150,28 +158,37 @@ class Point:
|
|
150
158
|
row: int
|
151
159
|
column: int
|
152
160
|
|
153
|
-
class
|
154
|
-
""" A class to capture
|
161
|
+
class Filter:
|
162
|
+
""" A class to capture filters of a Piranha Rule
|
155
163
|
"""
|
156
|
-
|
157
|
-
"
|
158
|
-
|
159
|
-
"
|
160
|
-
|
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"
|
161
175
|
def __init__(
|
162
176
|
self,
|
163
|
-
|
164
|
-
|
177
|
+
enclosing_node: str = '',
|
178
|
+
not_contains: list[str] = [],
|
179
|
+
contains: str = '',
|
180
|
+
at_least: int = 1,
|
181
|
+
at_most: int = 4294967295 # u32::MAX
|
165
182
|
):
|
166
183
|
"""
|
167
|
-
Constructs `
|
184
|
+
Constructs `Filter`
|
168
185
|
|
169
186
|
Parameters
|
170
187
|
------------
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
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
|
175
192
|
"""
|
176
193
|
...
|
177
194
|
|
@@ -190,8 +207,8 @@ class Rule:
|
|
190
207
|
"Group(s) to which the rule belongs"
|
191
208
|
holes: set[str]
|
192
209
|
"Holes that need to be filled, in order to instantiate a rule"
|
193
|
-
|
194
|
-
"
|
210
|
+
filters: set[Filter]
|
211
|
+
"Filters to test before applying a rule"
|
195
212
|
|
196
213
|
def __init__(
|
197
214
|
self,
|
@@ -201,7 +218,7 @@ class Rule:
|
|
201
218
|
replace: Optional[str] = None,
|
202
219
|
groups: set[str] = set(),
|
203
220
|
holes: set[str] = set(),
|
204
|
-
|
221
|
+
filters: set[Filter] = set(),
|
205
222
|
is_seed_rule: bool = True,
|
206
223
|
):
|
207
224
|
"""
|
@@ -221,8 +238,8 @@ class Rule:
|
|
221
238
|
Group(s) to which the rule belongs
|
222
239
|
holes: set[str]
|
223
240
|
Holes that need to be filled, in order to instantiate a rule
|
224
|
-
|
225
|
-
|
241
|
+
filters: set[Filter]
|
242
|
+
Filters to test before applying a rule
|
226
243
|
"""
|
227
244
|
...
|
228
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: homepage, https://github.com/uber/piranha
|
13
14
|
Project-URL: documentation, https://github.com/uber/piranha
|
14
15
|
Project-URL: repository, https://github.com/uber/piranha
|
15
|
-
Project-URL: homepage, 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=nqll5ynhXCwomcBqYs3lJrWlr8aFscLjrHGA10xvryk,104
|
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-darwin.so,sha256=g3_ubd4UZmfKn-KhCHag4BEj2_bLifMXzQUF7eHnPSA,13625120
|
10
|
+
polyglot_piranha-0.3.4.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
polyglot_piranha-0.3.0.dist-info/METADATA,sha256=uXFsx2SMxlQRLRkUfABg3gRfDWdyeg5etrZ_3nr8Tuo,3797
|
2
|
-
polyglot_piranha-0.3.0.dist-info/WHEEL,sha256=R9as0yyHDf-HADVClq720BdoCu3SSus4Pahnk2I6QnQ,106
|
3
|
-
polyglot_piranha-0.3.0.dist-info/license_files/LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
|
4
|
-
polyglot_piranha-0.3.0.dist-info/license_files/LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
|
5
|
-
polyglot_piranha-0.3.0.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=76ufpcBsLCDOjAJucqyrFsBp8zPRVnpAnyfFQou7Srg,8480
|
8
|
-
polyglot_piranha/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
-
polyglot_piranha/polyglot_piranha.cpython-38-darwin.so,sha256=fokYp5cEqWVAgT5Wp6ZICt5GjTAgFLUFJnGz5J3cDjk,13094992
|
10
|
-
polyglot_piranha-0.3.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|