blob: d094e6e2da430cb0dca2e1723af9c8846f4b163f [file] [log] [blame]
# -*- coding: utf-8 -*-
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Script for dumping build config contents."""
from __future__ import print_function
import sys
from chromite.config import chromeos_config
from chromite.lib import constants
from chromite.lib import commandline
from chromite.lib import pformat
assert sys.version_info >= (3, 6), 'This module requires Python 3.6+'
def GetParser():
"""Creates the argparse parser."""
parser = commandline.ArgumentParser(description=__doc__)
parser.add_argument('-f', '--full', action='store_true', default=False,
help='Dump fully expanded configs.')
parser.add_argument('-c', '--csv', action='store_true', default=False,
help='Dump fully expanded configs as CSV.')
parser.add_argument('-u', '--update_config', action='store_true',
default=False, help='Update the site config json dump.')
parser.add_argument('-b', '--builder', type=str, default=None,
help='Single config to dump.')
return parser
def main(argv):
parser = GetParser()
options = parser.parse_args(argv)
site_config = chromeos_config.GetConfig()
filehandle = sys.stdout
if options.update_config:
filehandle = open(constants.CHROMEOS_CONFIG_FILE, 'w')
if options.builder:
if options.builder not in site_config:
raise Exception('%s: Not a valid build config.' % options.builder)
pformat.json(site_config[options.builder], fp=filehandle)
elif options.full:
elif options.csv:
if options.update_config: