mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
extension simplifications
This commit is contained in:
parent
aa3ca80ae6
commit
48645072ee
3 changed files with 10 additions and 10 deletions
|
@ -376,7 +376,8 @@ def get_extension(filename):
|
||||||
|
|
||||||
|
|
||||||
def has_extension(filename, ext):
|
def has_extension(filename, ext):
|
||||||
return ext == get_extension(filename)
|
_, f_ext = get_extension(filename)
|
||||||
|
return ext == f_ext
|
||||||
|
|
||||||
|
|
||||||
apk_regex = None
|
apk_regex = None
|
||||||
|
|
|
@ -599,7 +599,7 @@ def get_default_app_info_list(apps, metadatapath=None):
|
||||||
if metadatapath is None:
|
if metadatapath is None:
|
||||||
appid = None
|
appid = None
|
||||||
else:
|
else:
|
||||||
appid = os.path.splitext(os.path.basename(metadatapath))[0]
|
appid, _ = common.get_extension(os.path.basename(metadatapath))
|
||||||
if appid in apps:
|
if appid in apps:
|
||||||
logging.critical("'%s' is a duplicate! '%s' is already provided by '%s'"
|
logging.critical("'%s' is a duplicate! '%s' is already provided by '%s'"
|
||||||
% (metadatapath, appid, apps[appid]['metadatapath']))
|
% (metadatapath, appid, apps[appid]['metadatapath']))
|
||||||
|
@ -751,22 +751,21 @@ def _decode_dict(data):
|
||||||
|
|
||||||
|
|
||||||
def parse_metadata(apps, metadatapath):
|
def parse_metadata(apps, metadatapath):
|
||||||
root, ext = os.path.splitext(metadatapath)
|
_, ext = common.get_extension(metadatapath)
|
||||||
metadataformat = ext[1:]
|
|
||||||
accepted = common.config['accepted_formats']
|
accepted = common.config['accepted_formats']
|
||||||
if metadataformat not in accepted:
|
if ext not in accepted:
|
||||||
logging.critical('"' + metadatapath
|
logging.critical('"' + metadatapath
|
||||||
+ '" is not in an accepted format, '
|
+ '" is not in an accepted format, '
|
||||||
+ 'convert to: ' + ', '.join(accepted))
|
+ 'convert to: ' + ', '.join(accepted))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if metadataformat == 'txt':
|
if ext == 'txt':
|
||||||
return parse_txt_metadata(apps, metadatapath)
|
return parse_txt_metadata(apps, metadatapath)
|
||||||
if metadataformat == 'json':
|
if ext == 'json':
|
||||||
return parse_json_metadata(apps, metadatapath)
|
return parse_json_metadata(apps, metadatapath)
|
||||||
if metadataformat == 'xml':
|
if ext == 'xml':
|
||||||
return parse_xml_metadata(apps, metadatapath)
|
return parse_xml_metadata(apps, metadatapath)
|
||||||
if metadataformat == 'yaml':
|
if ext == 'yaml':
|
||||||
return parse_yaml_metadata(apps, metadatapath)
|
return parse_yaml_metadata(apps, metadatapath)
|
||||||
|
|
||||||
logging.critical('Unknown metadata format: ' + metadatapath)
|
logging.critical('Unknown metadata format: ' + metadatapath)
|
||||||
|
|
|
@ -147,7 +147,7 @@ def scan_source(build_dir, root_dir, thisbuild):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
fd = fp[len(build_dir) + 1:]
|
fd = fp[len(build_dir) + 1:]
|
||||||
ext = common.get_extension(fd)
|
_, ext = common.get_extension(fd)
|
||||||
|
|
||||||
if ext == 'so':
|
if ext == 'so':
|
||||||
count += handleproblem('shared library', fd, fp)
|
count += handleproblem('shared library', fd, fp)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue