mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-09-17 10:40:12 +02:00
Make write_metadata take a writer
This will let rewritemeta report format issues without writing to disk.
This commit is contained in:
parent
d88914b466
commit
911994fc99
@ -505,7 +505,8 @@ def checkupdates_app(app, first=True):
|
|||||||
|
|
||||||
if commitmsg:
|
if commitmsg:
|
||||||
metadatapath = os.path.join('metadata', app['id'] + '.txt')
|
metadatapath = os.path.join('metadata', app['id'] + '.txt')
|
||||||
metadata.write_metadata(metadatapath, app)
|
with open(metadatapath, 'w') as f:
|
||||||
|
metadata.write_metadata(f, app)
|
||||||
if options.commit:
|
if options.commit:
|
||||||
logging.info("Commiting update for " + metadatapath)
|
logging.info("Commiting update for " + metadatapath)
|
||||||
gitcmd = ["git", "commit", "-m", commitmsg]
|
gitcmd = ["git", "commit", "-m", commitmsg]
|
||||||
|
@ -248,7 +248,8 @@ def main():
|
|||||||
f.write(app['Repo Type'] + ' ' + app['Repo'])
|
f.write(app['Repo Type'] + ' ' + app['Repo'])
|
||||||
|
|
||||||
metadatapath = os.path.join('metadata', package + '.txt')
|
metadatapath = os.path.join('metadata', package + '.txt')
|
||||||
metadata.write_metadata(metadatapath, app)
|
with open(metadatapath, 'w') as f:
|
||||||
|
metadata.write_metadata(f, app)
|
||||||
logging.info("Wrote " + metadatapath)
|
logging.info("Wrote " + metadatapath)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1040,9 +1040,9 @@ def parse_txt_metadata(apps, metadatapath):
|
|||||||
|
|
||||||
# Write a metadata file.
|
# Write a metadata file.
|
||||||
#
|
#
|
||||||
# 'dest' - The path to the output file
|
# 'mf' - Writer interface (file, StringIO, ...)
|
||||||
# 'app' - The app data
|
# 'app' - The app data
|
||||||
def write_metadata(dest, app):
|
def write_metadata(mf, app):
|
||||||
|
|
||||||
def writecomments(key):
|
def writecomments(key):
|
||||||
written = 0
|
written = 0
|
||||||
@ -1073,7 +1073,6 @@ def write_metadata(dest, app):
|
|||||||
if value:
|
if value:
|
||||||
writefield(field, value)
|
writefield(field, value)
|
||||||
|
|
||||||
mf = open(dest, 'w')
|
|
||||||
writefield_nonempty('Disabled')
|
writefield_nonempty('Disabled')
|
||||||
if app['AntiFeatures']:
|
if app['AntiFeatures']:
|
||||||
writefield('AntiFeatures')
|
writefield('AntiFeatures')
|
||||||
@ -1161,4 +1160,3 @@ def write_metadata(dest, app):
|
|||||||
writefield('No Source Since')
|
writefield('No Source Since')
|
||||||
mf.write('\n')
|
mf.write('\n')
|
||||||
writecomments(None)
|
writecomments(None)
|
||||||
mf.close()
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
import logging
|
import logging
|
||||||
import common
|
import common
|
||||||
@ -46,13 +45,14 @@ def main():
|
|||||||
|
|
||||||
for appid, app in apps.iteritems():
|
for appid, app in apps.iteritems():
|
||||||
metadatapath = app['metadatapath']
|
metadatapath = app['metadatapath']
|
||||||
ext = os.path.splitext(metadatapath)[1][1:]
|
ext = common.get_extension(metadatapath)
|
||||||
if ext == 'txt':
|
if ext not in ['txt']:
|
||||||
logging.debug("Rewriting " + metadatapath)
|
|
||||||
metadata.write_metadata(metadatapath, app)
|
|
||||||
else:
|
|
||||||
logging.info("Ignoring %s file at '%s'"
|
logging.info("Ignoring %s file at '%s'"
|
||||||
% (ext.upper(), metadatapath))
|
% (ext.upper(), metadatapath))
|
||||||
|
continue
|
||||||
|
logging.debug("Rewriting " + metadatapath)
|
||||||
|
with open(metadatapath, 'w') as f:
|
||||||
|
metadata.write_metadata(f, app)
|
||||||
|
|
||||||
logging.debug("Finished.")
|
logging.debug("Finished.")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user