self.path = os.path.join('stats', 'known_apks.txt')
self.apks = {}
if os.path.isfile(self.path):
- with open(self.path, 'r') as f:
+ with open(self.path, 'r', encoding='utf8') as f:
for line in f:
t = line.rstrip().split(' ')
if len(t) == 2:
line += ' ' + time.strftime('%Y-%m-%d', added)
lst.append(line)
- with open(self.path, 'w') as f:
+ with open(self.path, 'w', encoding='utf8') as f:
for line in sorted(lst, key=natural_key):
f.write(line + '\n')
if value is None:
origkey = key + '_orig'
value = thisconfig[origkey] if origkey in thisconfig else thisconfig[key]
- 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 + '"'
# make sure the file ends with a carraige return
if not re.match('\n$', data):
data += '\n'
- with open('config.py', 'w') as f:
+ with open('config.py', 'w', encoding='utf8') as f:
f.writelines(data)
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)
raise MetaDataException('Cannot write "%s", not an accepted format, use: %s' % (
metadatapath, ', '.join(accepted)))
- with open(metadatapath, 'w') as mf:
+ with open(metadatapath, 'w', encoding='utf8') as mf:
if ext == 'txt':
return write_txt(mf, app)
elif ext == 'yml':
s = io.StringIO()
# TODO: currently reading entire file again, should reuse first
# read in metadata.py
- with open(app.metadatapath, 'r') as f:
+ with open(app.metadatapath, 'r', encoding='utf8') as f:
cur_content = f.read()
metadata.write_txt(s, app)
content = s.getvalue()
catdata = ''
for cat in categories:
catdata += cat + '\n'
- with open(os.path.join(repodir, 'categories.txt'), 'w') as f:
+ with open(os.path.join(repodir, 'categories.txt'), 'w', encoding='utf8') as f:
f.write(catdata)
if 'name' not in apk:
logging.error(apk['id'] + ' does not have a name! Skipping...')
continue
- f = open(os.path.join('metadata', apk['id'] + '.txt'), 'w')
+ f = open(os.path.join('metadata', apk['id'] + '.txt'), 'w', encoding='utf8')
f.write("License:Unknown\n")
f.write("Web Site:\n")
f.write("Source Code:\n")
# Generate latest apps data for widget
if os.path.exists(os.path.join('stats', 'latestapps.txt')):
data = ''
- with open(os.path.join('stats', 'latestapps.txt'), 'r') as f:
+ with open(os.path.join('stats', 'latestapps.txt'), 'r', encoding='utf8') as f:
for line in f:
appid = line.rstrip()
data += appid + "\t"
if app.icon is not None:
data += app.icon + "\t"
data += app.License + "\n"
- with open(os.path.join(repodirs[0], 'latestapps.dat'), 'w') as f:
+ with open(os.path.join(repodirs[0], 'latestapps.dat'), 'w', encoding='utf8') as f:
f.write(data)
if cachechanged: