mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-09 16:01:28 +00:00
Revert r863, let's use environment variables again
This commit is contained in:
parent
3764bd12af
commit
d80f54dfa5
@ -88,7 +88,7 @@ removed once the script finishes running.
|
|||||||
\fBbackportpackage\fR is only recommended for testing backports in a
|
\fBbackportpackage\fR is only recommended for testing backports in a
|
||||||
PPA, not uploading backports to the Ubuntu archive.
|
PPA, not uploading backports to the Ubuntu archive.
|
||||||
.SH CONFIGURATION VARIABLES
|
.SH CONFIGURATION VARIABLES
|
||||||
The following variables can be set in the
|
The following variables can be set in the environment or in
|
||||||
.BR ubuntu\-dev\-tools (5)
|
.BR ubuntu\-dev\-tools (5)
|
||||||
configuration files:
|
configuration files:
|
||||||
.TP
|
.TP
|
||||||
|
@ -35,7 +35,11 @@ them by using \fB\-\-no\-conf\fR as the \fIfirst\fR command\-line
|
|||||||
option.
|
option.
|
||||||
|
|
||||||
.SH ENVIRONMENT
|
.SH ENVIRONMENT
|
||||||
Several scripts use the following environment variables:
|
All \fBubuntu\-dev\-tools\fR configuration variables can be set (and
|
||||||
|
overridden) by setting them in the environment (unlike
|
||||||
|
\fBdevscripts\fR).
|
||||||
|
|
||||||
|
In addition, several scripts use the following environment variables:
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B UBUMAIL
|
.B UBUMAIL
|
||||||
|
@ -37,8 +37,6 @@ def get_devscripts_config():
|
|||||||
dictionary
|
dictionary
|
||||||
"""
|
"""
|
||||||
config = {}
|
config = {}
|
||||||
if len(sys.argv) > 1 and sys.argv[1] in ('--no-conf', '--noconf'):
|
|
||||||
return config
|
|
||||||
var_re = re.compile(r'^\s*([A-Z_]+?)=(.+)$')
|
var_re = re.compile(r'^\s*([A-Z_]+?)=(.+)$')
|
||||||
for fn in ('/etc/devscripts.conf', '~/.devscripts'):
|
for fn in ('/etc/devscripts.conf', '~/.devscripts'):
|
||||||
f = open(os.path.expanduser(fn), 'r')
|
f = open(os.path.expanduser(fn), 'r')
|
||||||
@ -49,32 +47,33 @@ def get_devscripts_config():
|
|||||||
f.close()
|
f.close()
|
||||||
return config
|
return config
|
||||||
|
|
||||||
def get_value(key, default=None, prefix=None, compat_vars=[]):
|
def get_value(key, default=None, prefix=None, compat_keys=[]):
|
||||||
"""Retrieve a value from a configuration file.
|
"""Retrieve a value from the environment or configuration files.
|
||||||
keys are prefixed with the script name + _, or prefix.
|
keys are prefixed with the script name + _, or prefix.
|
||||||
Historical *environment variable* names can be supplied via compat_keys, no
|
|
||||||
prefix is applied to them.
|
Store Priority: Environment variables, user config file, system config file
|
||||||
|
Variable Priority: PREFIX_KEY, UBUNTUTOOLS_KEY, compat_keys
|
||||||
|
|
||||||
|
Historical variable names can be supplied via compat_keys, no prefix is
|
||||||
|
applied to them.
|
||||||
"""
|
"""
|
||||||
|
if default is None and key in defaults:
|
||||||
|
default = defaults[key]
|
||||||
|
if len(sys.argv) > 1 and sys.argv[1] in ('--no-conf', '--noconf'):
|
||||||
|
return default
|
||||||
|
|
||||||
if prefix is None:
|
if prefix is None:
|
||||||
prefix = os.path.basename(sys.argv[0]).upper().replace('-', '_') + '_'
|
prefix = os.path.basename(sys.argv[0]).upper().replace('-', '_') + '_'
|
||||||
|
|
||||||
config = get_devscripts_config()
|
keys = [prefix + key, 'UBUNTUTOOLS_' + key] + compat_keys
|
||||||
for k in (prefix + key, 'UBUNTUTOOLS_' + key):
|
|
||||||
if k in config:
|
|
||||||
value = config[k]
|
|
||||||
if value in ('yes', 'no'):
|
|
||||||
value = value == 'yes'
|
|
||||||
return value
|
|
||||||
|
|
||||||
for k in compat_vars:
|
for store in (os.environ, get_devscripts_config()):
|
||||||
if k in os.environ:
|
for k in keys:
|
||||||
value = os.environ[k]
|
if k in store:
|
||||||
if value in ('yes', 'no'):
|
value = store[k]
|
||||||
value = value == 'yes'
|
if value in ('yes', 'no'):
|
||||||
return value
|
value = value == 'yes'
|
||||||
|
return value
|
||||||
if key in defaults:
|
|
||||||
return defaults[key]
|
|
||||||
return default
|
return default
|
||||||
|
|
||||||
def ubu_email(name=None, email=None, export=True):
|
def ubu_email(name=None, email=None, export=True):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user