do not delete yml metadata when raumel not installed

This commit is contained in:
Michael Pöhn 2019-07-29 17:39:51 +02:00
parent 0885303672
commit 8e5232076f
2 changed files with 14 additions and 9 deletions

View file

@ -27,6 +27,7 @@ import logging
import textwrap
import io
import yaml
import importlib
from collections import OrderedDict
import fdroidserver.common
@ -1584,11 +1585,15 @@ def write_metadata(metadatapath, app):
warn_or_exception(_('Cannot write "{path}", not an accepted format, use: {formats}')
.format(path=metadatapath, formats=', '.join(accepted)))
with open(metadatapath, 'w') as mf:
if ext == 'txt':
if ext == 'txt':
with open(metadatapath, 'w') as mf:
return write_txt(mf, app)
elif ext == 'yml':
return write_yaml(mf, app)
elif ext == 'yml':
if importlib.util.find_spec('ruamel.yaml'):
with open(metadatapath, 'w') as mf:
return write_yaml(mf, app)
else:
raise FDroidException('ruamel.yaml not installed, can not write metadata.')
warn_or_exception(_('Unknown metadata format: %s') % metadatapath)