read/write F-Droid files always as UTF-8

This makes UTF-8 the sole supported encoding for F-Droid's files. This is
mostly codifying the already existing practice for config.py and index.xml.
The other files where always just ASCII before.

* config.py
* metadata/*.txt
* known_apks.txt
* categories.txt
* latestapps.txt
* latestapps.dat
* index.xml

Note: this does not change the read/write encoding of stats files.  That is
still ASCII.
This commit is contained in:
Hans-Christoph Steiner 2016-06-07 13:35:13 +02:00
parent 444e8ad982
commit afd528731a
5 changed files with 12 additions and 12 deletions

View file

@ -35,12 +35,12 @@ options = None
def disable_in_config(key, value):
'''write a key/value to the local config.py, then comment it out'''
with open('config.py', 'r') as f:
with open('config.py', 'r', encoding='utf8') as f:
data = f.read()
pattern = '\n[\s#]*' + key + '\s*=\s*"[^"]*"'
repl = '\n#' + key + ' = "' + value + '"'
data = re.sub(pattern, repl, data)
with open('config.py', 'w') as f:
with open('config.py', 'w', encoding='utf8') as f:
f.writelines(data)