mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 14:41:31 +02:00
cros_extract_deps -j writes JSON, sorted by package name.
Rationale: Consumers of this output should not have to eval() python code in order to use the output. Also potentially useful for dumping out of buildbot for consumption by other web-based tools. Review URL: http://codereview.chromium.org/3148022
This commit is contained in:
parent
12f14ce889
commit
88a33da077
@ -5,8 +5,8 @@
|
||||
|
||||
"""Extract dependency tree out of emerge and make it accessible and useful."""
|
||||
|
||||
import json
|
||||
import optparse
|
||||
import pprint
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
@ -23,6 +23,14 @@ class ParseException(Exception):
|
||||
return self.reason
|
||||
|
||||
|
||||
class SetEncoder(json.JSONEncoder):
|
||||
"""Custom json encoder class, doesn't hate set types."""
|
||||
def default(self, o):
|
||||
if isinstance(o, set):
|
||||
return list(o)
|
||||
return json.JSONEncoder.default(self, o)
|
||||
|
||||
|
||||
def GetDepLinesFromPortage(options, packages):
|
||||
"""Get dependency lines out of emerge.
|
||||
|
||||
@ -179,7 +187,7 @@ def main():
|
||||
|
||||
lines = GetDepLinesFromPortage(options, packages)
|
||||
deps_map = ParseDepLines(lines)
|
||||
output = pprint.pformat(deps_map)
|
||||
output = json.dumps(deps_map, sort_keys=True, indent=2, cls=SetEncoder)
|
||||
if options.output:
|
||||
output_file = open(options.output, 'w')
|
||||
output_file.write(output)
|
||||
|
Loading…
x
Reference in New Issue
Block a user