blob: a1b1197cb27d022232c366a11bbb91ba77631aec [file] [log] [blame]
Cole Fauste0fab082022-10-24 18:36:22 -07001#!/usr/bin/env python3
Sasha Levitskiy83561d12016-10-10 22:48:10 -07002#
3# Copyright (C) 2016 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the 'License');
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an 'AS IS' BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
Cole Fauste0fab082022-10-24 18:36:22 -070018import argparse
19import json
20import sys
Sasha Levitskiy83561d12016-10-10 22:48:10 -070021
22def PrintFileNames(path):
23 with open(path) as jf:
24 data = json.load(jf)
25 for line in data:
26 print(line["Name"])
27
28def PrintCanonicalList(path):
29 with open(path) as jf:
30 data = json.load(jf)
31 for line in data:
Cole Fauste0fab082022-10-24 18:36:22 -070032 print(f"{line['Size']:12d} {line['Name']}")
Sasha Levitskiy83561d12016-10-10 22:48:10 -070033
Cole Fauste0fab082022-10-24 18:36:22 -070034def main():
35 parser = argparse.ArgumentParser()
36 parser.add_argument("-n", action="store_true",
37 help="produces list of files only")
38 parser.add_argument("-c", action="store_true",
39 help="produces classic installed-files.txt")
40 parser.add_argument("json_files_list")
41 args = parser.parse_args()
Sasha Levitskiy83561d12016-10-10 22:48:10 -070042
Cole Fauste0fab082022-10-24 18:36:22 -070043 if args.n and args.c:
44 sys.exit("Cannot specify both -n and -c")
45 elif args.n:
46 PrintFileNames(args.json_files_list)
47 elif args.c:
48 PrintCanonicalList(args.json_files_list)
49 else:
50 sys.exit("No conversion option specified")
Sasha Levitskiy83561d12016-10-10 22:48:10 -070051
52if __name__ == '__main__':
Cole Fauste0fab082022-10-24 18:36:22 -070053 main()