mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 06:50:29 +03:00
Simplify some file logic with "with"
This commit is contained in:
parent
2894786ec9
commit
6fe8d96e85
4 changed files with 48 additions and 63 deletions
|
|
@ -200,22 +200,21 @@ def main():
|
|||
count)
|
||||
alldownloads += count
|
||||
lst.append("ALL " + str(alldownloads))
|
||||
f = open('stats/total_downloads_app.txt', 'w')
|
||||
f.write('# Total downloads by application, since October 2011\n')
|
||||
for line in sorted(lst):
|
||||
f.write(line + '\n')
|
||||
f.close()
|
||||
with open('stats/total_downloads_app.txt', 'w') as f:
|
||||
f.write('# Total downloads by application, since October 2011\n')
|
||||
for line in sorted(lst):
|
||||
f.write(line + '\n')
|
||||
|
||||
f = open('stats/total_downloads_app_version.txt', 'w')
|
||||
f.write('# Total downloads by application and version, '
|
||||
'since October 2011\n')
|
||||
lst = []
|
||||
for appver in appsvercount:
|
||||
count = appsvercount[appver]
|
||||
lst.append(appver + " " + str(count))
|
||||
for line in sorted(lst):
|
||||
f.write(line + "\n")
|
||||
f.close()
|
||||
|
||||
with open('stats/total_downloads_app_version.txt', 'w') as f:
|
||||
f.write('# Total downloads by application and version, '
|
||||
'since October 2011\n')
|
||||
for line in sorted(lst):
|
||||
f.write(line + "\n")
|
||||
|
||||
# Calculate and write stats for repo types...
|
||||
logging.info("Processing repo types...")
|
||||
|
|
@ -225,10 +224,9 @@ def main():
|
|||
if rtype == 'srclib':
|
||||
rtype = common.getsrclibvcs(app['Repo'])
|
||||
repotypes[rtype] += 1
|
||||
f = open('stats/repotypes.txt', 'w')
|
||||
for rtype, count in repotypes.most_common():
|
||||
f.write(rtype + ' ' + str(count) + '\n')
|
||||
f.close()
|
||||
with open('stats/repotypes.txt', 'w') as f:
|
||||
for rtype, count in repotypes.most_common():
|
||||
f.write(rtype + ' ' + str(count) + '\n')
|
||||
|
||||
# Calculate and write stats for update check modes...
|
||||
logging.info("Processing update check modes...")
|
||||
|
|
@ -240,20 +238,18 @@ def main():
|
|||
if checkmode.startswith('Tags '):
|
||||
checkmode = checkmode[:4]
|
||||
ucms[checkmode] += 1
|
||||
f = open('stats/update_check_modes.txt', 'w')
|
||||
for checkmode, count in ucms.most_common():
|
||||
f.write(checkmode + ' ' + str(count) + '\n')
|
||||
f.close()
|
||||
with open('stats/update_check_modes.txt', 'w') as f:
|
||||
for checkmode, count in ucms.most_common():
|
||||
f.write(checkmode + ' ' + str(count) + '\n')
|
||||
|
||||
logging.info("Processing categories...")
|
||||
ctgs = Counter()
|
||||
for app in metaapps:
|
||||
for category in app['Categories']:
|
||||
ctgs[category] += 1
|
||||
f = open('stats/categories.txt', 'w')
|
||||
for category, count in ctgs.most_common():
|
||||
f.write(category + ' ' + str(count) + '\n')
|
||||
f.close()
|
||||
with open('stats/categories.txt', 'w') as f:
|
||||
for category, count in ctgs.most_common():
|
||||
f.write(category + ' ' + str(count) + '\n')
|
||||
|
||||
logging.info("Processing antifeatures...")
|
||||
afs = Counter()
|
||||
|
|
@ -263,10 +259,9 @@ def main():
|
|||
antifeatures = [a.strip() for a in app['AntiFeatures'].split(',')]
|
||||
for antifeature in antifeatures:
|
||||
afs[antifeature] += 1
|
||||
f = open('stats/antifeatures.txt', 'w')
|
||||
for antifeature, count in afs.most_common():
|
||||
f.write(antifeature + ' ' + str(count) + '\n')
|
||||
f.close()
|
||||
with open('stats/antifeatures.txt', 'w') as f:
|
||||
for antifeature, count in afs.most_common():
|
||||
f.write(antifeature + ' ' + str(count) + '\n')
|
||||
|
||||
# Calculate and write stats for licenses...
|
||||
logging.info("Processing licenses...")
|
||||
|
|
@ -274,26 +269,23 @@ def main():
|
|||
for app in metaapps:
|
||||
license = app['License']
|
||||
licenses[license] += 1
|
||||
f = open('stats/licenses.txt', 'w')
|
||||
for license, count in licenses.most_common():
|
||||
f.write(license + ' ' + str(count) + '\n')
|
||||
f.close()
|
||||
with open('stats/licenses.txt', 'w') as f:
|
||||
for license, count in licenses.most_common():
|
||||
f.write(license + ' ' + str(count) + '\n')
|
||||
|
||||
# Write list of disabled apps...
|
||||
logging.info("Processing disabled apps...")
|
||||
disabled = [a['id'] for a in allmetaapps if a['Disabled']]
|
||||
f = open('stats/disabled_apps.txt', 'w')
|
||||
for appid in sorted(disabled):
|
||||
f.write(appid + '\n')
|
||||
f.close()
|
||||
with open('stats/disabled_apps.txt', 'w') as f:
|
||||
for appid in sorted(disabled):
|
||||
f.write(appid + '\n')
|
||||
|
||||
# Write list of latest apps added to the repo...
|
||||
logging.info("Processing latest apps...")
|
||||
latest = knownapks.getlatest(10)
|
||||
f = open('stats/latestapps.txt', 'w')
|
||||
for appid in latest:
|
||||
f.write(appid + '\n')
|
||||
f.close()
|
||||
with open('stats/latestapps.txt', 'w') as f:
|
||||
for appid in latest:
|
||||
f.write(appid + '\n')
|
||||
|
||||
if unknownapks:
|
||||
logging.info('\nUnknown apks:')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue