mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
59deefe6ab
Summary: Eden should load its configuration from toml files. This change includes: - ConfigParser is the class that parses and provides access to the configuration. We load the configuration from toml files and pass to ConfigParser in order to preserve existing behavior. - The toml configuration format differs from the Config format. Thus, we use toml.load() and toml.dump() to load/save toml format configuration. - Tests - configuration is properly loaded from a group of config files - toml configuration (if present) takes precedence - missing configuration files (/home/user/.edenrc) are ignored - invalid configuration files are fatal - update of configuration works (adding repo) - toml parsing handles over-rides of properties in the same way as cfg files Deployment Strategy: - This code determines whether to use toml configuration based on the presence of atleast 1 '.toml' file in the etc-eden-dir/config.d. Reviewed By: chadaustin Differential Revision: D9023232 fbshipit-source-id: 6734a9d91eca92b05872a758c764546451dd2d51
23 lines
850 B
Python
23 lines
850 B
Python
#!/usr/bin/env python3
|
|
#
|
|
# Copyright (c) 2016-present, Facebook, Inc.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the BSD-style license found in the
|
|
# LICENSE file in the root directory of this source tree. An additional grant
|
|
# of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
import collections
|
|
import configparser
|
|
|
|
|
|
# Convert the passed ConfigParser to a raw dictionary (without interpolation)
|
|
# Useful for updating configuration files in different formats.
|
|
def config_to_raw_dict(config: configparser.ConfigParser) -> collections.OrderedDict:
|
|
rslt = collections.OrderedDict() # type: collections.OrderedDict
|
|
for section in config.sections():
|
|
rslt[section] = collections.OrderedDict()
|
|
for k, v in config.items(section, raw=True):
|
|
rslt[section][k] = v
|
|
return rslt
|