summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2021-03-15 18:23:40 +0000
committerStephen Finucane <sfinucan@redhat.com>2021-04-22 10:00:38 +0100
commit16a8553e9f7630951b5a21b74a1d39063ccb9689 (patch)
treeed1ffda0d1ef87f8e693a73e7dc766d6737350c1
parent7a13063daa37d0ee39be689c4560408f08890eb6 (diff)
downloadpbr-16a8553e9f7630951b5a21b74a1d39063ccb9689.tar.gz
Don't pass empty 'long_description'
Correct a small logic error that would result in us passing an empty 'long_description' value to 'setup' if 'description_file' pointed to a file that was empty. Fixing this also makes it a little more obvious that we are only setting values that are present in 'setup.cfg', since that wasn't totally clear before. A small, unrelated typo is addressed. Change-Id: Ib32b5fb5da84215376c8e372470b2ff08eb47908 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
-rw-r--r--pbr/util.py32
1 files changed, 15 insertions, 17 deletions
diff --git a/pbr/util.py b/pbr/util.py
index d821183..44b6a6e 100644
--- a/pbr/util.py
+++ b/pbr/util.py
@@ -321,28 +321,26 @@ def setup_cfg_to_setup_kwargs(config, script_args=()):
section, option = alias
elif len(alias) == 1:
- # The distutils field name is the same thant distutils2's.
+ # The distutils field name is the same as distutils2's.
section = alias[0]
option = arg
in_cfg_value = has_get_option(config, section, option)
+ if not in_cfg_value and arg == "long_description":
+ in_cfg_value = has_get_option(config, section, "description_file")
+ if in_cfg_value:
+ in_cfg_value = split_multiline(in_cfg_value)
+ value = ''
+ for filename in in_cfg_value:
+ description_file = io.open(filename, encoding='utf-8')
+ try:
+ value += description_file.read().strip() + '\n\n'
+ finally:
+ description_file.close()
+ in_cfg_value = value
+
if not in_cfg_value:
- # There is no such option in the setup.cfg
- if arg == "long_description":
- in_cfg_value = has_get_option(config, section,
- "description_file")
- if in_cfg_value:
- in_cfg_value = split_multiline(in_cfg_value)
- value = ''
- for filename in in_cfg_value:
- description_file = io.open(filename, encoding='utf-8')
- try:
- value += description_file.read().strip() + '\n\n'
- finally:
- description_file.close()
- in_cfg_value = value
- else:
- continue
+ continue
if arg in CSV_FIELDS:
in_cfg_value = split_csv(in_cfg_value)