mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 07:31:08 +00:00
Read ~/.devscripts in a more robust way, to ideally pick up multi-line variables (Closes: #725418).
This commit is contained in:
parent
b551877651
commit
5a20308ab1
4
debian/changelog
vendored
4
debian/changelog
vendored
@ -9,6 +9,10 @@ ubuntu-dev-tools (0.206) UNRELEASED; urgency=medium
|
||||
[ Fernando Bravo Hernández ]
|
||||
* Parsing arch parameter to getBinaryPackage() (LP: #2081861)
|
||||
|
||||
[ Simon Quigley ]
|
||||
* Read ~/.devscripts in a more robust way, to ideally pick up multi-line
|
||||
variables (Closes: #725418).
|
||||
|
||||
-- Simon Quigley <tsimonq2@debian.org> Tue, 04 Mar 2025 13:04:30 -0600
|
||||
|
||||
ubuntu-dev-tools (0.205) unstable; urgency=medium
|
||||
|
@ -68,21 +68,19 @@ class UDTConfig:
|
||||
config = {}
|
||||
for filename in ("/etc/devscripts.conf", "~/.devscripts"):
|
||||
try:
|
||||
f = open(os.path.expanduser(filename), "r", encoding="utf-8")
|
||||
with open(os.path.expanduser(filename), "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
except IOError:
|
||||
continue
|
||||
for line in f:
|
||||
parsed = shlex.split(line, comments=True)
|
||||
if len(parsed) > 1:
|
||||
Logger.warning(
|
||||
"Cannot parse variable assignment in %s: %s",
|
||||
getattr(f, "name", "<config>"),
|
||||
line,
|
||||
)
|
||||
if len(parsed) >= 1 and "=" in parsed[0]:
|
||||
key, value = parsed[0].split("=", 1)
|
||||
try:
|
||||
tokens = shlex.split(content, comments=True)
|
||||
except ValueError as e:
|
||||
Logger.error("Error parsing %s: %s", filename, e)
|
||||
continue
|
||||
for token in tokens:
|
||||
if "=" in token:
|
||||
key, value = token.split("=", 1)
|
||||
config[key] = value
|
||||
f.close()
|
||||
return config
|
||||
|
||||
def get_value(self, key, default=None, boolean=False, compat_keys=()):
|
||||
|
Loading…
x
Reference in New Issue
Block a user