mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 06:50:29 +03:00
rename metadata.write_metadata() to match metadata.parse_*_metadata()
This changes the function name to include the format of the metadata file, and also changes the order of the args to match the parse_*_metadata() functions.
This commit is contained in:
parent
3b20153cd7
commit
994488ad47
4 changed files with 18 additions and 14 deletions
|
|
@ -492,8 +492,7 @@ def checkupdates_app(app, first=True):
|
|||
|
||||
if commitmsg:
|
||||
metadatapath = os.path.join('metadata', app.id + '.txt')
|
||||
with open(metadatapath, 'w') as f:
|
||||
metadata.write_metadata('txt', f, app)
|
||||
metadata.write_metadata(metadatapath, app)
|
||||
if options.commit:
|
||||
logging.info("Commiting update for " + metadatapath)
|
||||
gitcmd = ["git", "commit", "-m", commitmsg]
|
||||
|
|
|
|||
|
|
@ -243,8 +243,7 @@ def main():
|
|||
f.write(app.RepoType + ' ' + app.Repo)
|
||||
|
||||
metadatapath = os.path.join('metadata', package + '.txt')
|
||||
with open(metadatapath, 'w') as f:
|
||||
metadata.write_metadata('txt', f, app)
|
||||
metadata.write_metadata(metadatapath, app)
|
||||
logging.info("Wrote " + metadatapath)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1270,7 +1270,7 @@ def write_plaintext_metadata(mf, app, w_comment, w_field, w_build):
|
|||
#
|
||||
# 'mf' - Writer interface (file, StringIO, ...)
|
||||
# 'app' - The app data
|
||||
def write_txt_metadata(mf, app):
|
||||
def write_txt(mf, app):
|
||||
|
||||
def w_comment(line):
|
||||
mf.write("# %s\n" % line)
|
||||
|
|
@ -1313,7 +1313,7 @@ def write_txt_metadata(mf, app):
|
|||
write_plaintext_metadata(mf, app, w_comment, w_field, w_build)
|
||||
|
||||
|
||||
def write_yaml_metadata(mf, app):
|
||||
def write_yaml(mf, app):
|
||||
|
||||
def w_comment(line):
|
||||
mf.write("# %s\n" % line)
|
||||
|
|
@ -1377,9 +1377,16 @@ def write_yaml_metadata(mf, app):
|
|||
write_plaintext_metadata(mf, app, w_comment, w_field, w_build)
|
||||
|
||||
|
||||
def write_metadata(fmt, mf, app):
|
||||
if fmt == 'txt':
|
||||
return write_txt_metadata(mf, app)
|
||||
if fmt == 'yaml':
|
||||
return write_yaml_metadata(mf, app)
|
||||
raise MetaDataException("Unknown metadata format given")
|
||||
def write_metadata(metadatapath, app):
|
||||
_, ext = fdroidserver.common.get_extension(metadatapath)
|
||||
accepted = fdroidserver.common.config['accepted_formats']
|
||||
if ext not in accepted:
|
||||
raise MetaDataException('Cannot write "%s", not an accepted format, use: %s' % (
|
||||
metadatapath, ', '.join(accepted)))
|
||||
|
||||
with open(metadatapath, 'w') as mf:
|
||||
if ext == 'txt':
|
||||
return write_txt(mf, app)
|
||||
elif ext == 'yaml':
|
||||
return write_yaml(mf, app)
|
||||
raise MetaDataException('Unknown metadata format: %s' % metadatapath)
|
||||
|
|
|
|||
|
|
@ -84,8 +84,7 @@ def main():
|
|||
print(app.metadatapath)
|
||||
continue
|
||||
|
||||
with open(base + '.' + to_ext, 'w') as f:
|
||||
metadata.write_metadata(to_ext, f, app)
|
||||
metadata.write_metadata(base + '.' + to_ext, app)
|
||||
|
||||
if ext != to_ext:
|
||||
os.remove(app.metadatapath)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue