[reprotest] 01/03: Add a --config-file option and fix the loading of configs
Ximin Luo
infinity0 at debian.org
Tue Jan 24 20:26:44 UTC 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository reprotest.
commit 15f243fc95f58614e99e4b9b04d6de1d2e2eb99e
Author: Ximin Luo <infinity0 at debian.org>
Date: Tue Jan 24 17:05:08 2017 +0100
Add a --config-file option and fix the loading of configs
---
README.md | 6 ++++--
TODO | 2 +-
debian/changelog | 1 +
reprotest/__init__.py | 10 ++++++----
4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index d85a592..96962cc 100644
--- a/README.md
+++ b/README.md
@@ -110,8 +110,10 @@ except there's no `dont_vary` option, and there are `build_command` and
file, reprotest can be run without passing those as command-line arguments.
Command-line arguments always override config file options.
-Reprotest searches the working directory for `.reprotestrc`; other locations
-will be supported in the future. A sample config file is below.
+Reprotest by default loads `./.reprotestrc`, or you can tell it to load another
+file with the `--config-file` command line option.
+
+A sample config file is below.
[basics]
build_command = setup.py sdist
diff --git a/TODO b/TODO
index 7cd2d21..27b1b55 100644
--- a/TODO
+++ b/TODO
@@ -1,2 +1,2 @@
-- reprotest man page, reprotest -c config argument
+- reprotest man page
- make mock_build capture more stuff and test it in tests.py:test_variations
diff --git a/debian/changelog b/debian/changelog
index d2db331..08cae0f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,7 @@ reprotest (0.6) UNRELEASED; urgency=medium
* Rename some variations:
path -> exec_path, to distinguish it from build_path
faketime -> time, since users care about interface not implementation
+ * Add a --config-file option and fix the loading of configs.
-- Ximin Luo <infinity0 at debian.org> Sat, 07 Jan 2017 17:15:42 +0100
diff --git a/reprotest/__init__.py b/reprotest/__init__.py
index 0918aa5..23022a0 100644
--- a/reprotest/__init__.py
+++ b/reprotest/__init__.py
@@ -524,6 +524,9 @@ COMMAND_LINE_OPTIONS = types.MappingProxyType(collections.OrderedDict([
('--verbosity', types.MappingProxyType({
'type': int, 'default': 0,
'help': 'An integer. Control which messages are displayed.'})),
+ ('--config-file', types.MappingProxyType({
+ 'type': str, 'default': '.reprotestrc',
+ 'help': 'File to load configuration from. (Default: %(default)s)'})),
('--source-root', types.MappingProxyType({
'dest': 'source_root', 'type': pathlib.Path,
'help': 'Root of the source tree, if not the '
@@ -590,10 +593,10 @@ for option in COMMAND_LINE_OPTIONS.keys():
CONFIG_OPTIONS.append(option.strip('-'))
CONFIG_OPTIONS = tuple(CONFIG_OPTIONS)
-def config():
+def config(filename):
# Config file.
config = configparser.ConfigParser()
- config.read('.reprotestrc')
+ config.read(filename)
options = collections.OrderedDict()
if 'basics' in config:
for option in CONFIG_OPTIONS:
@@ -636,11 +639,10 @@ def command_line(*argv):
def main():
- config_options = config()
-
# Argparse exits with status code 2 if something goes wrong, which
# is already the right status exit code for reprotest.
command_line_options = command_line(*sys.argv[1:])
+ config_options = config(command_line_options.get('config_file'))
# Command-line arguments override config file settings.
build_command = command_line_options.get(
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/reprotest.git
More information about the Reproducible-commits
mailing list