chiark
/
gitweb
/
~ianmdlvl
/
fdroidserver.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ff48c6b
)
common.write_to_config(): if key doesn't exist in config.py, append it
author
Hans-Christoph Steiner
<hans@eds.org>
Tue, 21 Apr 2015 02:27:31 +0000
(22:27 -0400)
committer
Hans-Christoph Steiner
<hans@eds.org>
Fri, 8 May 2015 20:13:15 +0000
(16:13 -0400)
This lets `fdroid update --create-key` add key/value pairs to config.py
fdroidserver/common.py
patch
|
blob
|
history
diff --git
a/fdroidserver/common.py
b/fdroidserver/common.py
index 8ed8193b1fdb54b76ffdf6ee4752d7f37b3f2d11..f44e80a2f564987b43625d6f794485c73cd692bb 100644
(file)
--- a/
fdroidserver/common.py
+++ b/
fdroidserver/common.py
@@
-2067,5
+2067,11
@@
def write_to_config(thisconfig, key, value=None):
pattern = '\n[\s#]*' + key + '\s*=\s*"[^"]*"'
repl = '\n' + key + ' = "' + value + '"'
data = re.sub(pattern, repl, data)
+ # if this key is not in the file, append it
+ if not re.match('\s*' + key + '\s*=\s*"', data):
+ data += repl
+ # make sure the file ends with a carraige return
+ if not re.match('\n$', data):
+ data += '\n'
with open('config.py', 'w') as f:
f.writelines(data)