polyglot-piranha 0.3.0__cp39-cp39-manylinux_2_34_x86_64.whl → 0.3.32__cp39-cp39-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.
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2022 Uber Technologies, Inc.
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,11 @@
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 __future__ import annotations
13
+ from typing import List, Optional, Literal
14
+
15
+ # Languages that Piranha supports (see ./src/models/language.rs)
16
+ PiranhaLanguage = Literal["java", "kt", "kotlin", "go", "python", "swift", "typescript", "tsx", "thrift", "strings", "scm", "scala", "ruby", "yaml", "yml"]
13
17
 
14
18
 
15
19
  def execute_piranha(piranha_argument: PiranhaArguments) -> list[PiranhaOutputSummary]:
@@ -32,42 +36,51 @@ class PiranhaArguments:
32
36
 
33
37
  def __init__(
34
38
  self,
35
- language: str,
36
- substitutions: dict,
37
- path_to_configurations: Optional[str],
38
- rule_graph: Optional[RuleGraph]= None,
39
- path_to_codebase: Optional[str] = None,
39
+ language: PiranhaLanguage,
40
+ paths_to_codebase: Optional[List[str]] = None,
41
+ include: Optional[List[str]] = None,
42
+ exclude: Optional[List[str]] = None,
43
+ substitutions: Optional[dict[str, str]] = None,
44
+ path_to_configurations: Optional[str] = None,
45
+ rule_graph: Optional[RuleGraph] = None,
40
46
  code_snippet: Optional[str] = None,
41
47
  dry_run: Optional[bool] = None,
42
48
  cleanup_comments: Optional[bool] = None,
43
49
  cleanup_comments_buffer: Optional[int] = None,
44
50
  number_of_ancestors_in_parent_scope: Optional[int] = None,
45
- delete_file_if_empty : Optional[bool] = None,
46
- delete_consecutive_new_lines : Optional[bool] = None,
47
- path_to_output: Optional[str] = None
48
-
51
+ delete_consecutive_new_lines: Optional[bool] = None,
52
+ global_tag_prefix: Optional[str] = "GLOBAL_TAG",
53
+ delete_file_if_empty: Optional[bool] = None,
54
+ path_to_output: Optional[str] = None,
55
+ allow_dirty_ast: Optional[bool] = None,
56
+ should_validate: Optional[bool] = None,
57
+ experiment_dyn: Optional[bool] = None,
58
+ path_to_custom_builtin_rules: Optional[str] = None,
49
59
  ):
50
60
  """
51
61
  Constructs `PiranhaArguments`
52
62
 
53
63
  Parameters
54
64
  ------------
55
- language: str
65
+ language: PiranhaLanguage
56
66
  the target language
57
- substitutions: dict
58
- Substitutions to instantiate the initial set of rules
67
+ paths_to_codebase: List[str]
68
+ Paths to source code folder or file
59
69
  keyword arguments: _
60
- path_to_configurations (str) : Directory containing the configuration files - `piranha_arguments.toml`, `rules.toml`, and `edges.toml`
61
- rule_graph (RuleGraph) : The rule graph constructed via RuleGraph DSL
62
- path_to_codebase (str) : Path to source code folder or file
63
- code_snippet (str) : The input code snippet to transform
64
- dry_run (bool) : Disables in-place rewriting of code
65
- cleanup_comments (bool) : Enables deletion of associated comments
70
+ substitutions (dict): Substitutions to instantiate the initial set of rules
71
+ path_to_configurations (str): Directory containing the configuration files - `piranha_arguments.toml`, `rules.toml`, and `edges.toml`
72
+ rule_graph (RuleGraph): The rule graph constructed via RuleGraph DSL
73
+ code_snippet (str): The input code snippet to transform
74
+ dry_run (bool): Disables in-place rewriting of code
75
+ cleanup_comments (bool): Enables deletion of associated comments
66
76
  cleanup_comments_buffer (int): The number of lines to consider for cleaning up the comments
67
77
  number_of_ancestors_in_parent_scope (int): The number of ancestors considered when PARENT rules
78
+ delete_consecutive_new_lines (bool): Replaces consecutive \ns with a \n
79
+ global_tag_prefix (str): the prefix for global tags
68
80
  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
81
  path_to_output (str): Path to the output json file
82
+ allow_dirty_ast (bool): Allows syntax errors in the input source code
83
+ path_to_custom_builtin_rules (str): If provided, the default built-in rules will be ignored
71
84
  """
72
85
  ...
73
86
 
@@ -77,17 +90,20 @@ class PiranhaOutputSummary:
77
90
 
78
91
  Attributes
79
92
  ----------
80
- path : path to the file
81
- content : content of the file after all the rewrites
82
- matches : All the occurrences of "match-only" rules
93
+ path: path to the file
94
+ content: content of the file after all the rewrites
95
+ matches: All the occurrences of "match-only" rules
83
96
  rewrites: All the applied edits
84
97
  """
85
98
 
86
99
  path: str
87
100
  "path to the file"
88
101
 
102
+ original_content: str
103
+ "Original content of the file before any rewrites"
104
+
89
105
  content: str
90
- "content of the file after all the rewrites"
106
+ "Final content of the file after all the rewrites"
91
107
 
92
108
  matches: list[tuple[str, Match]]
93
109
  'All the occurrences of "match-only" rules'
@@ -101,9 +117,9 @@ class Edit:
101
117
 
102
118
  Attributes
103
119
  ----------
104
- p_match : The match representing the target site of the edit
105
- replacement_string : The string to replace the substring encompassed by the match
106
- matched_rule : The rule used for creating this match-replace
120
+ p_match: The match representing the target site of the edit
121
+ replacement_string: The string to replace the substring encompassed by the match
122
+ matched_rule: The rule used for creating this match-replace
107
123
  """
108
124
 
109
125
  p_match: Match
@@ -121,9 +137,9 @@ class Match:
121
137
 
122
138
  Attributes
123
139
  ----------
124
- matched_sting : Code snippet that matched
125
- range : Range of the entire AST node captured by the match
126
- matches : The mapping between tags and string representation of the AST captured
140
+ matched_sting: Code snippet that matched
141
+ range: Range of the entire AST node captured by the match
142
+ matches: The mapping between tags and string representation of the AST captured
127
143
  """
128
144
 
129
145
  matched_string: str
@@ -132,7 +148,7 @@ class Match:
132
148
  range: Range
133
149
  "Range of the entire AST node captured by the match"
134
150
 
135
- matches: dict
151
+ matches: dict[str, str]
136
152
  "The mapping between tags and string representation of the AST captured"
137
153
  ""
138
154
 
@@ -150,59 +166,81 @@ class Point:
150
166
  row: int
151
167
  column: int
152
168
 
153
- class Constraint:
154
- """ A class to capture Constraints of a Piranha Rule
155
- """
156
- matcher: TSQuery
157
- "Scope in which the constraint query has to be applied"
158
- queries: list[TSQuery]
159
- "The Tree-sitter queries that need to be applied in the `matcher` scope"
160
-
169
+ class Filter:
170
+ """A class to capture filters of a Piranha Rule"""
171
+
172
+ enclosing_node: TSQuery
173
+ "AST patterns that some ancestor node of the primary match should comply"
174
+ not_contains: list[TSQuery]
175
+ "AST patterns that SHOULD NOT match any subtree of node matching `enclosing_node` pattern"
176
+ contains: TSQuery
177
+ "AST pattern that SHOULD match subtrees of `enclosing_node`. " "Number of matches should be within the range of `at_least` and `at_most`."
178
+ at_least: int
179
+ "The minimum number of times the contains query should match in the enclosing node"
180
+ at_most: int
181
+ "The maximum number of times the contains query should match in the enclosing node"
182
+ child_count: int
183
+ "Number of named children under the primary matched node"
184
+ sibling_count: int
185
+ "Number of named siblings of the primary matched node"
161
186
  def __init__(
162
187
  self,
163
- matcher: str,
164
- queries: list[str] = []
188
+ enclosing_node: Optional[str] = None,
189
+ not_enclosing_node: Optional[str] = None,
190
+ not_contains: list[str] = [],
191
+ contains: Optional[str] = None,
192
+ at_least: int = 1,
193
+ at_most: int = 4294967295, # u32::MAX
194
+ child_count: int = 4294967295, # u32::MAX
195
+ sibling_count: int = 4294967295, # u32::MAX
165
196
  ):
166
197
  """
167
- Constructs `Constraint`
198
+ Constructs `Filter`
168
199
 
169
200
  Parameters
170
201
  ------------
171
- matcher: str
172
- Scope in which the constraint query has to be applied
173
- queries: list[str]
174
- The Tree-sitter queries that need to be applied in the `matcher` scope
202
+ enclosing_node: str
203
+ AST patterns that some ancestor node of the primary match should comply
204
+ not_contains: list[str]
205
+ AST patterns that should not match any subtree of node matching `enclosing_node` pattern
175
206
  """
176
207
  ...
177
208
 
178
209
  class Rule:
179
- """ A class to capture Piranha Rule
180
- """
210
+ """A class to capture Piranha Rule"""
211
+
181
212
  name: str
182
213
  "Name of the rule"
183
214
  query: TSQuery
184
215
  "Tree-sitter query as string"
185
216
  replace_node: str
186
217
  "The tag corresponding to the node to be replaced"
218
+ replace_node_idx: str
219
+ "The i'th child of node corresponding to the replace_node tag will be replaced"
187
220
  replace: str
188
221
  "Replacement pattern"
189
222
  groups: set[str]
190
223
  "Group(s) to which the rule belongs"
191
224
  holes: set[str]
192
225
  "Holes that need to be filled, in order to instantiate a rule"
193
- constraints: set[Constraint]
194
- "Additional constraints for matching the rule"
226
+ filters: set[Filter]
227
+ "Filters to test before applying a rule"
228
+ is_seed_rule: bool
229
+ "Marks a rule as a seed rule"
230
+ keep_comment_regexes: set[str]
231
+ "Make comment deleting optional"
195
232
 
196
233
  def __init__(
197
234
  self,
198
235
  name: str,
199
- query: str,
236
+ query: Optional[str] = None,
200
237
  replace_node: Optional[str] = None,
201
238
  replace: Optional[str] = None,
202
239
  groups: set[str] = set(),
203
240
  holes: set[str] = set(),
204
- constraints: set[Constraint] = set(),
241
+ filters: set[Filter] = set(),
205
242
  is_seed_rule: bool = True,
243
+ keep_comment_regexes: Optional[set[str]] = None,
206
244
  ):
207
245
  """
208
246
  Constructs `Rule`
@@ -221,8 +259,10 @@ class Rule:
221
259
  Group(s) to which the rule belongs
222
260
  holes: set[str]
223
261
  Holes that need to be filled, in order to instantiate a rule
224
- constraints: set[Constraint]
225
- Additional constraints for matching the rule
262
+ filters: set[Filter]
263
+ Filters to test before applying a rule
264
+ is_seed_rule: bool
265
+ Marks a rule as a seed rule
226
266
  """
227
267
  ...
228
268
 
@@ -259,7 +299,7 @@ class RuleGraph:
259
299
  "The rules in the graph"
260
300
  edges: list[OutgoingEdges]
261
301
  "The edges in the graph"
262
- graph: dict
302
+ graph: dict[str, list[tuple[str, str]]]
263
303
  "The graph itself (as an adjacency list)"
264
304
 
265
305
  def __init__(
@@ -282,6 +322,5 @@ class RuleGraph:
282
322
  class TSQuery:
283
323
  "Captures a Tree sitter query"
284
324
  def query(self):
285
- """The query
286
- """
325
+ """The query"""
287
326
  ...
@@ -0,0 +1,125 @@
1
+ Metadata-Version: 2.4
2
+ Name: polyglot_piranha
3
+ Version: 0.3.32
4
+ License-File: LICENSE
5
+ License-File: NOTICE
6
+ Summary: Polyglot Piranha is a library for performing structural find and replace with deep cleanup.
7
+ Keywords: refactoring,code update,structural find-replace,structural search and replace,structural search
8
+ Author: Uber Technologies Inc.
9
+ License: Apache-2.0
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
12
+ Project-URL: homepage, https://github.com/uber/piranha
13
+ Project-URL: documentation, https://github.com/uber/piranha
14
+ Project-URL: repository, https://github.com/uber/piranha
15
+
16
+ # PolyglotPiranha
17
+
18
+ PolyglotPiranha is a lightweight code transformation toolset for automating large scale changes. At Uber, it is mostly used to clean up stale feature flags.
19
+
20
+ We only support languages that are used at Uber. We likely won't be able to add new languages in this repo. There are a number of forks (see https://github.com/uber/piranha/forks for a full list) that may provide additional features.
21
+
22
+
23
+ ## Installation
24
+
25
+ To install Polyglot Piranha, you can use it as a Python library or as a command-line tool.
26
+
27
+ ### Python API
28
+
29
+ To install the Python API, run the following command:
30
+
31
+ ```bash
32
+ pip install polyglot-piranha
33
+ ```
34
+
35
+ ### Command-line Interface
36
+
37
+ To install the command-line interface, follow these steps:
38
+
39
+ 1. Install [Rust](https://www.rust-lang.org/tools/install)
40
+ 2. Clone the repository: `git clone https://github.com/uber/piranha.git`
41
+ 3. Navigate to the cloned directory: `cd piranha`
42
+ 4. Build the project: `cargo build --release` (or `cargo build --release --no-default-features` for macOS)
43
+ 5. The binary will be generated under `target/release`
44
+
45
+ ## Example Usage
46
+
47
+ ```python
48
+ from polyglot_piranha import execute_piranha, PiranhaArguments, Rule, RuleGraph, OutgoingEdges
49
+
50
+ # Original code snippet
51
+ code = """
52
+ if (obj.isLocEnabled() || x > 0) {
53
+ // do something
54
+ } else {
55
+ // do something else!
56
+ }
57
+ """
58
+
59
+ # Define the rule to replace the method call
60
+ r1 = Rule(
61
+ name="replace_method",
62
+ query="cs :[x].isLocEnabled()", # cs indicates we are using concrete syntax
63
+ replace_node="*",
64
+ replace="true",
65
+ is_seed_rule=True
66
+ )
67
+
68
+ # Define the edges for the rule graph.
69
+ # In this case, boolean_literal_cleanup is already defined for java [see src/cleanup_rules]
70
+ edge = OutgoingEdges("replace_method", to=["boolean_literal_cleanup"], scope="parent")
71
+
72
+ # Create Piranha arguments
73
+ piranha_arguments = PiranhaArguments(
74
+ code_snippet=code,
75
+ language="java",
76
+ rule_graph=RuleGraph(rules=[r1], edges=[edge])
77
+ )
78
+
79
+ # Execute Piranha and print the transformed code
80
+ piranha_summary = execute_piranha(piranha_arguments)
81
+ print(piranha_summary[0].content)
82
+ ```
83
+
84
+
85
+ ## Documentation
86
+
87
+ For more examples and explanations of the toolset, please check our demos and extended [POLYGLOT_README.md](POLYGLOT_README.md) file.
88
+
89
+
90
+ ## Feature Flags
91
+
92
+
93
+ Feature flags are commonly used to enable gradual rollout or experiment with new features. In a few cases, even after the purpose of the flag is accomplished, the code pertaining to the feature flag is not removed. We refer to such flags as stale flags. The presence of code pertaining to stale flags can have the following drawbacks:
94
+ - Unnecessary code clutter increases the overall complexity w.r.t maintenance resulting in reduced developer productivity
95
+ - The flags can interfere with other experimental flags (e.g., due to nesting under a flag that is always false)
96
+ - Presence of unused code in the source as well as the binary
97
+ - Stale flags can also cause bugs
98
+
99
+ PolyglotPiranha is a tool that can automatically refactor code related to stale flags. At a higher level, the input to the tool is the name of the flag and the expected behavior, after specifying a list of APIs related to flags in a properties file. Piranha will use these inputs to automatically refactor the code according to the expected behavior.
100
+
101
+ PolyglotPiranha (as of May 2022) is a common refactoring tool to support multiple languages and feature flag APIs.
102
+ For legacy language-specific implementations please check following [tag](https://github.com/uber/piranha/releases/tag/last-version-having-legacy-piranha).
103
+
104
+
105
+
106
+ A few additional links on Piranha:
107
+
108
+ - Research paper published at [PLDI 2024](https://dl.acm.org/doi/10.1145/3656429) on PolyglotPiranha.
109
+ - A technical [report](report.pdf) detailing our experiences with using Piranha at Uber.
110
+ - A [blogpost](https://eng.uber.com/piranha/) presenting more information on Piranha.
111
+ - 6 minute [video](https://www.youtube.com/watch?v=V5XirDs6LX8&feature=emb_logo) overview of Piranha.
112
+
113
+ ## Support
114
+
115
+ If you have any questions on how to use Piranha or find any bugs, please [open a GitHub issue](https://github.com/uber/piranha/issues).
116
+
117
+ ## License
118
+ Piranha is licensed under the Apache 2.0 license. See the LICENSE file for more information.
119
+
120
+ ## Note
121
+
122
+ This is not an official Uber product, and provided as is.
123
+
124
+
125
+
@@ -0,0 +1,11 @@
1
+ LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
2
+ NOTICE,sha256=9bEJKCdL0MABjEknpMHXbYBZSkGVGRXYcSxSXS293X0,147
3
+ polyglot_piranha-0.3.32.dist-info/METADATA,sha256=NM_XLFAlvhPY4vcl-sH0iBRtBV0aANBkRDiSZPiutMM,4918
4
+ polyglot_piranha-0.3.32.dist-info/WHEEL,sha256=JoLn8ljEzluFt4D23qWjuDJ3Cig5u64Faxv3FqFOY9c,106
5
+ polyglot_piranha-0.3.32.dist-info/licenses/LICENSE,sha256=7qqytxojDvLpt8CphcCVvEQilegiJ0x_oDkwHJU-1z4,11359
6
+ polyglot_piranha-0.3.32.dist-info/licenses/NOTICE,sha256=9bEJKCdL0MABjEknpMHXbYBZSkGVGRXYcSxSXS293X0,147
7
+ polyglot_piranha/__init__.py,sha256=pghVgChf0-NgAG_zd7CzKtvFuBDxg5Wh-GcHx2PoTzg,147
8
+ polyglot_piranha/__init__.pyi,sha256=Aef4ZhgaF9WkC5tmBDCLSPmO2_qZUa_hIFf42fpDrD8,10802
9
+ polyglot_piranha/polyglot_piranha.cpython-39-x86_64-linux-gnu.so,sha256=Z0-X0f0Uj3YIo0Sp-HlPHBxkrt11SfRQ54kWsEVZ1C0,78720072
10
+ polyglot_piranha/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ polyglot_piranha-0.3.32.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: maturin (0.14.14)
2
+ Generator: maturin (1.8.6)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp39-cp39-manylinux_2_34_x86_64
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner].
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ [Piranha]
2
+ Copyright (c) 2018 Uber Technologies, Inc.
3
+
4
+ This product includes software developed at
5
+ Uber Technologies, Inc. (http://www.uber.com/).
@@ -1,57 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: polyglot_piranha
3
- Version: 0.3.0
4
- License-File: LICENSE
5
- License-File: LICENSE
6
- License-File: NOTICE
7
- Summary: Polyglot Piranha is a library for performing structural find and replace with deep cleanup.
8
- Keywords: refactoring,code update,structural find-replace,structural search and replace,structural search
9
- Author: Uber Technologies Inc.
10
- Author-email: Ameya Ketkar <ketkara@uber.com>, Lazaro Clapp <lazaro@uber.com>
11
- Requires-Python: >=3.7
12
- Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
13
- Project-URL: documentation, https://github.com/uber/piranha
14
- Project-URL: repository, https://github.com/uber/piranha
15
- Project-URL: homepage, https://github.com/uber/piranha
16
-
17
- # Piranha
18
-
19
- [![Join the chat at https://gitter.im/uber/piranha](https://badges.gitter.im/uber/piranha.svg)](https://gitter.im/uber/piranha?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
20
-
21
- Feature flags are commonly used to enable gradual rollout or experiment with new features. In a few cases, even after the purpose of the flag is accomplished, the code pertaining to the feature flag is not removed. We refer to such flags as stale flags. The presence of code pertaining to stale flags can have the following drawbacks:
22
- - Unnecessary code clutter increases the overall complexity w.r.t maintenance resulting in reduced developer productivity
23
- - The flags can interfere with other experimental flags (e.g., due to nesting under a flag that is always false)
24
- - Presence of unused code in the source as well as the binary
25
- - Stale flags can also cause bugs
26
-
27
- Piranha is a tool to automatically refactor code related to stale flags. At a higher level, the input to the tool is the name of the flag and the expected behavior, after specifying a list of APIs related to flags in a properties file. Piranha will use these inputs to automatically refactor the code according to the expected behavior.
28
-
29
- This repository contains four independent versions of Piranha, one for each of the four supported languages: Java, JavaScript, Objective-C and Swift. **It also contains a redesigned variant of Piranha (as of May 2022) that is a common refactoring tool to support multiple languages and feature flag APIs. If interested in this polyglot variant, goto [Polyglot Piranha](POLYGLOT_README.md)**.
30
-
31
- To use/build each version, look under the corresponding [lang]/ directory and follow instructions in the corresponding [lang]/README.md file. Make sure to cd into that directory to build any related code following the instructions in the README.
32
-
33
- - [PiranhaJava](legacy/java/README.md)
34
- - [PiranhaJS](legacy/javascript/README.md)
35
- - [PiranhaObjC](legacy/objc/README.md)
36
- - [PiranhaSwift](legacy/swift/README.md)
37
-
38
- A few additional links on Piranha:
39
-
40
- - A technical [report](report.pdf) detailing our experiences with using Piranha at Uber.
41
- - A [blogpost](https://eng.uber.com/piranha/) presenting more information on Piranha.
42
- - 6 minute [video](https://www.youtube.com/watch?v=V5XirDs6LX8&feature=emb_logo) overview of Piranha.
43
-
44
- ## Support
45
-
46
- If you have any questions on how to use Piranha, please feel free to reach out to us on the [gitter channel](https://gitter.im/uber/piranha?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge). For bugs and enhancement requests, [open a GitHub issue](https://github.com/uber/piranha/issues).
47
-
48
- ## Contributors
49
-
50
- We'd love for you to contribute to Piranha! Please note that once
51
- you create a pull request, you will be asked to sign our [Uber Contributor License Agreement](https://cla-assistant.io/uber/piranha).
52
-
53
- We are also looking for contributions to extend Piranha to other languages (C++, C#, Kotlin).
54
-
55
- ## License
56
- Piranha is licensed under the Apache 2.0 license. See the LICENSE file for more information.
57
-
@@ -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=5Ok_1jEcOIKgUZQFsmkOXgkMD5n-Re6DZJd8K7Y7DR8,108
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-39-x86_64-linux-gnu.so,sha256=0jmeh83WDCfrXy5XojO-eTk7AlYvGg7JTWOztOIovhY,74537944
10
- polyglot_piranha-0.3.0.dist-info/RECORD,,