[Python-checkins] distutils2: Better handling of multi lines fields of the setup.cfg.
tarek.ziade
python-checkins at python.org
Sat Jan 29 14:21:48 CET 2011
tarek.ziade pushed a342826d7308 to distutils2:
http://hg.python.org/distutils2/rev/a342826d7308
changeset: 907:a342826d7308
parent: 896:272155a17d56
user: Julien Miotte <miotte.julien at gmail.com>
date: Fri Jan 28 12:15:54 2011 +0100
summary:
Better handling of multi lines fields of the setup.cfg.
Now single line values can be written on the same line as the field name.
For instance, the line:
project_url = spam,http://spam.spam
Was causing python -m distutils.run sdist with this error:
ValueError: need more than 1 value to unpack
Now, every field that should be of multiple use is handled as a list.
files:
distutils2/config.py
distutils2/metadata.py
diff --git a/distutils2/config.py b/distutils2/config.py
--- a/distutils2/config.py
+++ b/distutils2/config.py
@@ -76,10 +76,9 @@
return value
def _multiline(self, value):
- if '\n' in value:
- value = [v for v in
- [v.strip() for v in value.split('\n')]
- if v != '']
+ value = [v for v in
+ [v.strip() for v in value.split('\n')]
+ if v != '']
return value
def _read_setup_cfg(self, parser):
@@ -100,7 +99,9 @@
if 'metadata' in content:
for key, value in content['metadata'].iteritems():
key = key.replace('_', '-')
- value = self._multiline(value)
+ if metadata.is_multi_field(key):
+ value = self._multiline(value)
+
if key == 'project-url':
value = [(label.strip(), url.strip())
for label, url in
diff --git a/distutils2/metadata.py b/distutils2/metadata.py
--- a/distutils2/metadata.py
+++ b/distutils2/metadata.py
@@ -298,6 +298,10 @@
name = self._convert_name(name)
return name in _ALL_FIELDS
+ def is_multi_field(self, name):
+ name = self._convert_name(name)
+ return name in _LISTFIELDS
+
def read(self, filepath):
self.read_file(open(filepath))
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list