qvm-template: Make pylint happy by changing "license" to "licence".

This commit is contained in:
WillyPillow 2020-07-29 19:58:19 +08:00
parent f960ed4726
commit ef59a658f4

View File

@ -316,7 +316,7 @@ def qrexec_repoquery(args, app, spec='*', refresh=False):
name_re = re.compile(r'^[A-Za-z0-9._+\-]*$') name_re = re.compile(r'^[A-Za-z0-9._+\-]*$')
evr_re = re.compile(r'^[A-Za-z0-9._+~]*$') evr_re = re.compile(r'^[A-Za-z0-9._+~]*$')
date_re = re.compile(r'^\d+-\d+-\d+ \d+:\d+$') date_re = re.compile(r'^\d+-\d+-\d+ \d+:\d+$')
license_re = re.compile(r'^[A-Za-z0-9._+\-()]*$') licence_re = re.compile(r'^[A-Za-z0-9._+\-()]*$')
result = [] result = []
for line in stdout.split('|\n'): for line in stdout.split('|\n'):
# Note that there's an empty entry at the end as .strip() is not used. # Note that there's an empty entry at the end as .strip() is not used.
@ -327,7 +327,7 @@ def qrexec_repoquery(args, app, spec='*', refresh=False):
try: try:
# If there is an incorrect number of entries, raise an error # If there is an incorrect number of entries, raise an error
name, epoch, version, release, reponame, dlsize, \ name, epoch, version, release, reponame, dlsize, \
buildtime, license, url, summary, description = entry buildtime, licence, url, summary, description = entry
# Ignore packages that are not templates # Ignore packages that are not templates
if not name.startswith(PACKAGE_NAME_PREFIX): if not name.startswith(PACKAGE_NAME_PREFIX):
@ -348,14 +348,14 @@ def qrexec_repoquery(args, app, spec='*', refresh=False):
raise ValueError raise ValueError
buildtime = datetime.datetime.strptime(buildtime, '%Y-%m-%d %H:%M') buildtime = datetime.datetime.strptime(buildtime, '%Y-%m-%d %H:%M')
# XXX: Perhaps whitelist licenses directly? # XXX: Perhaps whitelist licenses directly?
if not re.fullmatch(license_re, license): if not re.fullmatch(licence_re, licence):
raise ValueError raise ValueError
# Check name actually matches spec # Check name actually matches spec
if not is_match_spec(name, epoch, version, release, spec): if not is_match_spec(name, epoch, version, release, spec):
continue continue
result.append((name, epoch, version, release, reponame, dlsize, result.append((name, epoch, version, release, reponame, dlsize,
buildtime, license, url, summary, description)) buildtime, licence, url, summary, description))
except (TypeError, ValueError): except (TypeError, ValueError):
raise ConnectionError(("qrexec call 'qubes.TemplateSearch' failed:" raise ConnectionError(("qrexec call 'qubes.TemplateSearch' failed:"
" unexpected data format.")) " unexpected data format."))
@ -414,13 +414,13 @@ def list_templates(args, app, operation):
_ = install_time # unused _ = install_time # unused
#pylint: disable=unused-variable #pylint: disable=unused-variable
name, epoch, version, release, reponame, dlsize, \ name, epoch, version, release, reponame, dlsize, \
buildtime, license, url, summary, description = data buildtime, licence, url, summary, description = data
version_str = build_version_str((epoch, version, release)) version_str = build_version_str((epoch, version, release))
tpl_list.append((status, name, version_str, reponame)) tpl_list.append((status, name, version_str, reponame))
def append_info(data, status, install_time=None): def append_info(data, status, install_time=None):
name, epoch, version, release, reponame, dlsize, \ name, epoch, version, release, reponame, dlsize, \
buildtime, license, url, summary, description = data buildtime, licence, url, summary, description = data
tpl_list.append((status, 'Name', ':', name)) tpl_list.append((status, 'Name', ':', name))
tpl_list.append((status, 'Epoch', ':', epoch)) tpl_list.append((status, 'Epoch', ':', epoch))
tpl_list.append((status, 'Version', ':', version)) tpl_list.append((status, 'Version', ':', version))
@ -432,7 +432,7 @@ def list_templates(args, app, operation):
if install_time: if install_time:
tpl_list.append((status, 'Install time', ':', str(install_time))) tpl_list.append((status, 'Install time', ':', str(install_time)))
tpl_list.append((status, 'URL', ':', url)) tpl_list.append((status, 'URL', ':', url))
tpl_list.append((status, 'License', ':', license)) tpl_list.append((status, 'License', ':', licence))
tpl_list.append((status, 'Summary', ':', summary)) tpl_list.append((status, 'Summary', ':', summary))
# Only show "Description" for the first line # Only show "Description" for the first line
title = 'Description' title = 'Description'
@ -499,7 +499,7 @@ def list_templates(args, app, operation):
remote = set() remote = set()
#pylint: disable=unused-variable #pylint: disable=unused-variable
for name, epoch, version, release, reponame, dlsize, \ for name, epoch, version, release, reponame, dlsize, \
buildtime, license, url, summary, description in query_res: buildtime, licence, url, summary, description in query_res:
remote.add(name) remote.add(name)
for vm in app.domains: for vm in app.domains:
if 'template-name' in vm.features and \ if 'template-name' in vm.features and \
@ -516,7 +516,7 @@ def list_templates(args, app, operation):
vm.features['template-release']) vm.features['template-release'])
for data in query_res: for data in query_res:
name, epoch, version, release, reponame, dlsize, \ name, epoch, version, release, reponame, dlsize, \
buildtime, license, url, summary, description = data buildtime, licence, url, summary, description = data
if name in local: if name in local:
if rpm.labelCompare(local[name], (epoch, version, release)) < 0: if rpm.labelCompare(local[name], (epoch, version, release)) < 0:
append(data, TemplateState.UPGRADABLE) append(data, TemplateState.UPGRADABLE)
@ -573,7 +573,7 @@ def search(args, app):
for keyword in args.templates: for keyword in args.templates:
#pylint: disable=unused-variable #pylint: disable=unused-variable
for idx, (name, epoch, version, release, reponame, dlsize, \ for idx, (name, epoch, version, release, reponame, dlsize, \
buildtime, license, url, summary, description) \ buildtime, licence, url, summary, description) \
in enumerate(query_res): in enumerate(query_res):
needles = [(name, WEIGHT_NAME), (summary, WEIGHT_SUMMARY)] needles = [(name, WEIGHT_NAME), (summary, WEIGHT_SUMMARY)]
if args.all: if args.all:
@ -606,7 +606,7 @@ def search(args, app):
def gen_header(idx, needles): def gen_header(idx, needles):
#pylint: disable=unused-variable #pylint: disable=unused-variable
name, epoch, version, release, reponame, dlsize, \ name, epoch, version, release, reponame, dlsize, \
buildtime, license, url, summary, description = query_res[idx] buildtime, licence, url, summary, description = query_res[idx]
fields = [] fields = []
weight_types = set(x[0] for x in needles) weight_types = set(x[0] for x in needles)
for weight, field in WEIGHT_TO_FIELD: for weight, field in WEIGHT_TO_FIELD:
@ -626,7 +626,7 @@ def search(args, app):
# XXX: The style is different from that of DNF # XXX: The style is different from that of DNF
print('===', cur_header, '===') print('===', cur_header, '===')
name, epoch, version, release, reponame, dlsize, \ name, epoch, version, release, reponame, dlsize, \
buildtime, license, url, summary, description = query_res[idx] buildtime, licence, url, summary, description = query_res[idx]
print(name, ':', summary) print(name, ':', summary)
def get_dl_list(args, app, version_selector=VersionSelector.LATEST): def get_dl_list(args, app, version_selector=VersionSelector.LATEST):
@ -645,7 +645,7 @@ def get_dl_list(args, app, version_selector=VersionSelector.LATEST):
# We only select one package for each distinct package name # We only select one package for each distinct package name
#pylint: disable=unused-variable #pylint: disable=unused-variable
for name, epoch, version, release, reponame, dlsize, \ for name, epoch, version, release, reponame, dlsize, \
buildtime, license, url, summary, description in query_res: buildtime, licence, url, summary, description in query_res:
ver = (epoch, version, release) ver = (epoch, version, release)
if version_selector == VersionSelector.LATEST: if version_selector == VersionSelector.LATEST:
if name not in candid \ if name not in candid \