mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-16 01:21:07 +00:00
- Support this in many u-d-t scripts, and update manpages.
- Deprecate old configuration environment variables.
This commit is contained in:
parent
86facf23c2
commit
c43e9775e0
4
debian/changelog
vendored
4
debian/changelog
vendored
@ -11,6 +11,8 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low
|
|||||||
* Support reading configuration variables from devscripts configuration
|
* Support reading configuration variables from devscripts configuration
|
||||||
files. (LP: #681693)
|
files. (LP: #681693)
|
||||||
- Added ubuntu-dev-tools.5
|
- Added ubuntu-dev-tools.5
|
||||||
|
- Support this in many u-d-t scripts, and update manpages.
|
||||||
|
- Deprecate old configuration environment variables.
|
||||||
* Support the combined "Name <email>" format in UBUMAIL, DEBFULLNAME, and
|
* Support the combined "Name <email>" format in UBUMAIL, DEBFULLNAME, and
|
||||||
DEBEMAIL. (LP: #665202)
|
DEBEMAIL. (LP: #665202)
|
||||||
* Add the beginnings of a test suite. (LP: #690386)
|
* Add the beginnings of a test suite. (LP: #690386)
|
||||||
@ -22,7 +24,7 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low
|
|||||||
* ubuntutools/lp/lpapicache.py: Allow easier selection of 'staging' as LP
|
* ubuntutools/lp/lpapicache.py: Allow easier selection of 'staging' as LP
|
||||||
instance to use (lp: #693060).
|
instance to use (lp: #693060).
|
||||||
|
|
||||||
-- Michael Bienia <geser@ubuntu.com> Tue, 21 Dec 2010 19:14:57 +0100
|
-- Stefano Rivera <stefanor@ubuntu.com> Wed, 22 Dec 2010 00:06:29 +0200
|
||||||
|
|
||||||
ubuntu-dev-tools (0.108) experimental; urgency=low
|
ubuntu-dev-tools (0.108) experimental; urgency=low
|
||||||
|
|
||||||
|
@ -21,8 +21,7 @@ import pwd
|
|||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
import socket
|
import socket
|
||||||
import StringIO
|
from sys import argv, stderr
|
||||||
import sys
|
|
||||||
|
|
||||||
class UDTConfig(object):
|
class UDTConfig(object):
|
||||||
"""Ubuntu Dev Tools configuration file (devscripts config file) and
|
"""Ubuntu Dev Tools configuration file (devscripts config file) and
|
||||||
@ -43,7 +42,7 @@ class UDTConfig(object):
|
|||||||
def __init__(self, no_conf=False, prefix=None):
|
def __init__(self, no_conf=False, prefix=None):
|
||||||
self.no_conf = no_conf
|
self.no_conf = no_conf
|
||||||
if prefix is None:
|
if prefix is None:
|
||||||
prefix = os.path.basename(sys.argv[0]).upper().replace('-', '_')
|
prefix = os.path.basename(argv[0]).upper().replace('-', '_')
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
if not no_conf:
|
if not no_conf:
|
||||||
self.config = self.parse_devscripts_config()
|
self.config = self.parse_devscripts_config()
|
||||||
@ -60,10 +59,10 @@ class UDTConfig(object):
|
|||||||
continue
|
continue
|
||||||
for line in f:
|
for line in f:
|
||||||
parsed = shlex.split(line, comments=True)
|
parsed = shlex.split(line, comments=True)
|
||||||
if len(parsed) > 1 and not isinstance(f, StringIO.StringIO):
|
if len(parsed) > 1:
|
||||||
print >> sys.stderr, (
|
print >> stderr, (
|
||||||
"W: Cannot parse variable assignment in %s: %s"
|
"W: Cannot parse variable assignment in %s: %s"
|
||||||
% (f.name, line))
|
% (getattr(f, 'name', '<config>'), line))
|
||||||
if len(parsed) >= 1 and '=' in parsed[0]:
|
if len(parsed) >= 1 and '=' in parsed[0]:
|
||||||
key, value = parsed[0].split('=', 1)
|
key, value = parsed[0].split('=', 1)
|
||||||
config[key] = value
|
config[key] = value
|
||||||
@ -98,6 +97,10 @@ class UDTConfig(object):
|
|||||||
value = value == 'yes'
|
value = value == 'yes'
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
if k in compat_keys:
|
||||||
|
print >> stderr, (
|
||||||
|
'W: Deprecated configuration variable: %s. '
|
||||||
|
'Replaced by %s.') % (k, key)
|
||||||
return value
|
return value
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
from sys import stderr
|
||||||
|
|
||||||
import ubuntutools.config
|
import ubuntutools.config
|
||||||
from ubuntutools.config import UDTConfig, ubu_email
|
from ubuntutools.config import UDTConfig, ubu_email
|
||||||
@ -42,10 +43,13 @@ def fake_open(filename, mode='r'):
|
|||||||
class ConfigTestCase(unittest.TestCase):
|
class ConfigTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
ubuntutools.config.open = fake_open
|
ubuntutools.config.open = fake_open
|
||||||
|
ubuntutools.config.stderr = StringIO()
|
||||||
self.cleanEnvironment()
|
self.cleanEnvironment()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
del ubuntutools.config.open
|
del ubuntutools.config.open
|
||||||
|
self.assertEqual(ubuntutools.config.stderr.getvalue(), '')
|
||||||
|
ubuntutools.config.stderr = stderr
|
||||||
self.cleanEnvironment()
|
self.cleanEnvironment()
|
||||||
|
|
||||||
def cleanEnvironment(self):
|
def cleanEnvironment(self):
|
||||||
@ -82,6 +86,10 @@ REPEAT=yes
|
|||||||
'INHERIT': 'user',
|
'INHERIT': 'user',
|
||||||
'REPEAT': 'yes',
|
'REPEAT': 'yes',
|
||||||
})
|
})
|
||||||
|
errs = ubuntutools.config.stderr.getvalue().strip()
|
||||||
|
ubuntutools.config.stderr = StringIO()
|
||||||
|
self.assertEqual(len(errs.splitlines()), 1)
|
||||||
|
self.assertRegexpMatches(errs, r'Cannot parse.*\bCOMMAND_EXECUTION=a')
|
||||||
|
|
||||||
def get_value(self, *args, **kwargs):
|
def get_value(self, *args, **kwargs):
|
||||||
config = UDTConfig(prefix='TEST')
|
config = UDTConfig(prefix='TEST')
|
||||||
@ -117,6 +125,10 @@ REPEAT=yes
|
|||||||
config_files['user'] = 'COMPATFOOBAR=bar'
|
config_files['user'] = 'COMPATFOOBAR=bar'
|
||||||
self.assertEqual(self.get_value('QUX', compat_keys=['COMPATFOOBAR']),
|
self.assertEqual(self.get_value('QUX', compat_keys=['COMPATFOOBAR']),
|
||||||
'bar')
|
'bar')
|
||||||
|
errs = ubuntutools.config.stderr.getvalue().strip()
|
||||||
|
ubuntutools.config.stderr = StringIO()
|
||||||
|
self.assertEqual(len(errs.splitlines()), 1)
|
||||||
|
self.assertRegexpMatches(errs, r'Deprecated.*\bCOMPATFOOBAR\b.*\bQUX\b')
|
||||||
|
|
||||||
def test_boolean(self):
|
def test_boolean(self):
|
||||||
config_files['user'] = "TEST_BOOLEAN=yes"
|
config_files['user'] = "TEST_BOOLEAN=yes"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user