diff options
| author | 2021-09-01 14:27:13 +0000 | |
|---|---|---|
| committer | 2021-09-01 14:27:13 +0000 | |
| commit | 0364846a73718eee7fbad2f67bb0ed784c79b548 (patch) | |
| tree | 67d1fd0965983aaf0f7648e64766af34dfcb78d4 /scripts/hiddenapi/signature_patterns.py | |
| parent | deee92ca0cb3bff7598922283e00f41cd61e82ae (diff) | |
| parent | 2c2219b60e2a25f03b75176a4f27b1ff4a86ebca (diff) | |
Merge "Apply pylint to remaining scripts in hiddenapi"
Diffstat (limited to 'scripts/hiddenapi/signature_patterns.py')
| -rwxr-xr-x | scripts/hiddenapi/signature_patterns.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/scripts/hiddenapi/signature_patterns.py b/scripts/hiddenapi/signature_patterns.py index a7c5bb4f3..0acb2a004 100755 --- a/scripts/hiddenapi/signature_patterns.py +++ b/scripts/hiddenapi/signature_patterns.py @@ -13,22 +13,26 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" -Generate a set of signature patterns from the modular flags generated by a +"""Generate a set of signature patterns from the modular flags generated by a bootclasspath_fragment that can be used to select a subset of monolithic flags against which the modular flags can be compared. """ import argparse import csv +import sys + +def dict_reader(csvfile): + return csv.DictReader( + csvfile, delimiter=',', quotechar='|', fieldnames=['signature'] + ) -def dict_reader(input): - return csv.DictReader(input, delimiter=',', quotechar='|', fieldnames=['signature']) def produce_patterns_from_file(file): with open(file, 'r') as f: return produce_patterns_from_stream(f) + def produce_patterns_from_stream(stream): # Read in all the signatures into a list and remove member names. patterns = set() @@ -38,18 +42,26 @@ def produce_patterns_from_stream(stream): # Remove the class specific member signature pieces = text.split(";->") qualifiedClassName = pieces[0] - # Remove inner class names as they cannot be separated from the containing outer class. + # Remove inner class names as they cannot be separated + # from the containing outer class. pieces = qualifiedClassName.split("$", maxsplit=1) pattern = pieces[0] patterns.add(pattern) - patterns = list(patterns) + patterns = list(patterns) #pylint: disable=redefined-variable-type patterns.sort() return patterns + def main(args): - args_parser = argparse.ArgumentParser(description='Generate a set of signature patterns that select a subset of monolithic hidden API files.') - args_parser.add_argument('--flags', help='The stub flags file which contains an entry for every dex member') + args_parser = argparse.ArgumentParser( + description='Generate a set of signature patterns ' + 'that select a subset of monolithic hidden API files.' + ) + args_parser.add_argument( + '--flags', + help='The stub flags file which contains an entry for every dex member', + ) args_parser.add_argument('--output', help='Generated signature prefixes') args = args_parser.parse_args(args) @@ -62,5 +74,6 @@ def main(args): outputFile.write(pattern) outputFile.write("\n") + if __name__ == "__main__": main(sys.argv[1:]) |