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:
|
||||
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:
|
||||
logging.info("Commiting update for " + metadatapath)
|
||||
gitcmd = ["git", "commit", "-m", commitmsg]
|
||||
|
@ -248,7 +248,8 @@ def main():
|
||||
f.write(app['Repo Type'] + ' ' + app['Repo'])
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
@ -1040,9 +1040,9 @@ def parse_txt_metadata(apps, metadatapath):
|
||||
|
||||
# Write a metadata file.
|
||||
#
|
||||
# 'dest' - The path to the output file
|
||||
# 'mf' - Writer interface (file, StringIO, ...)
|
||||
# 'app' - The app data
|
||||
def write_metadata(dest, app):
|
||||
def write_metadata(mf, app):
|
||||
|
||||
def writecomments(key):
|
||||
written = 0
|
||||
@ -1073,7 +1073,6 @@ def write_metadata(dest, app):
|
||||
if value:
|
||||
writefield(field, value)
|
||||
|
||||
mf = open(dest, 'w')
|
||||
writefield_nonempty('Disabled')
|
||||
if app['AntiFeatures']:
|
||||
writefield('AntiFeatures')
|
||||
@ -1161,4 +1160,3 @@ def write_metadata(dest, app):
|
||||
writefield('No Source Since')
|
||||
mf.write('\n')
|
||||
writecomments(None)
|
||||
mf.close()
|
||||
|
@ -18,7 +18,6 @@
|
||||
# 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/>.
|
||||
|
||||
import os
|
||||
from argparse import ArgumentParser
|
||||
import logging
|
||||
import common
|
||||
@ -46,13 +45,14 @@ def main():
|
||||
|
||||
for appid, app in apps.iteritems():
|
||||
metadatapath = app['metadatapath']
|
||||
ext = os.path.splitext(metadatapath)[1][1:]
|
||||
if ext == 'txt':
|
||||
logging.debug("Rewriting " + metadatapath)
|
||||
metadata.write_metadata(metadatapath, app)
|
||||
else:
|
||||
ext = common.get_extension(metadatapath)
|
||||
if ext not in ['txt']:
|
||||
logging.info("Ignoring %s file at '%s'"
|
||||
% (ext.upper(), metadatapath))
|
||||
continue
|
||||
logging.debug("Rewriting " + metadatapath)
|
||||
with open(metadatapath, 'w') as f:
|
||||
metadata.write_metadata(f, app)
|
||||
|
||||
logging.debug("Finished.")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user