summaryrefslogtreecommitdiff
path: root/scripts/hiddenapi/merge_csv.py
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2021-02-12 11:46:42 +0000
committer Paul Duffin <paulduffin@google.com> 2021-02-16 13:28:26 +0000
commit031d8693b3dae7edaca2e5fef3d017ac2e67424d (patch)
tree496cc3cd5c3166c0b4c048fe7e66e5833e46a93a /scripts/hiddenapi/merge_csv.py
parent7ad17bdad5b613d483d4f77d3c7637c407904211 (diff)
Allow explicitly specified additional annotations for hiddenapi
Adds the hiddenapi_additional_annotations to allow a library to list the libraries that provided additional hiddenapi related annotations for a library. Modifies merge_csv.py so it can process multiple zip files at the same time and uses that to merge the embedded .uau files from a module and those it depends upon. Bug: 180102243 Test: m droid Verified that hiddenapi files (both aggregated ones and for the individual modules) are not affected by this change. Change-Id: I796520021c7357398a9e2a09f1029e4a578b05b3
Diffstat (limited to 'scripts/hiddenapi/merge_csv.py')
-rwxr-xr-xscripts/hiddenapi/merge_csv.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/scripts/hiddenapi/merge_csv.py b/scripts/hiddenapi/merge_csv.py
index 6a5b0e134..5ad61b2f6 100755
--- a/scripts/hiddenapi/merge_csv.py
+++ b/scripts/hiddenapi/merge_csv.py
@@ -26,7 +26,8 @@ from zipfile import ZipFile
args_parser = argparse.ArgumentParser(description='Merge given CSV files into a single one.')
args_parser.add_argument('--header', help='Comma separated field names; '
'if missing determines the header from input files.')
-args_parser.add_argument('--zip_input', help='ZIP archive with all CSV files to merge.')
+args_parser.add_argument('--zip_input', help='Treat files as ZIP archives containing CSV files to merge.',
+ action="store_true")
args_parser.add_argument('--output', help='Output file for merged CSV.',
default='-', type=argparse.FileType('w'))
args_parser.add_argument('files', nargs=argparse.REMAINDER)
@@ -36,20 +37,16 @@ args = args_parser.parse_args()
def dict_reader(input):
return csv.DictReader(input, delimiter=',', quotechar='|')
-
-if args.zip_input and len(args.files) > 0:
- raise ValueError('Expecting either a single ZIP with CSV files'
- ' or a list of CSV files as input; not both.')
-
csv_readers = []
-if len(args.files) > 0:
+if not(args.zip_input):
for file in args.files:
csv_readers.append(dict_reader(open(file, 'r')))
-elif args.zip_input:
- with ZipFile(args.zip_input) as zip:
- for entry in zip.namelist():
- if entry.endswith('.uau'):
- csv_readers.append(dict_reader(io.TextIOWrapper(zip.open(entry, 'r'))))
+else:
+ for file in args.files:
+ with ZipFile(file) as zip:
+ for entry in zip.namelist():
+ if entry.endswith('.uau'):
+ csv_readers.append(dict_reader(io.TextIOWrapper(zip.open(entry, 'r'))))
headers = set()
if args.header: