Skip to content

Commit

Permalink
qvm-template: minor improvements
Browse files Browse the repository at this point in the history
- rename parser_gen to get_parser - for consistency with other tools
- clarify 'storage pool'
- move '-' to the end in regex characters list

QubesOS/qubes-issues#2534
  • Loading branch information
marmarek committed Feb 6, 2021
1 parent 8aede94 commit 9401249
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions qubesadmin/tools/qvm_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def qubes_release() -> str:
# Return default value instead of throwing so that it works on CI
return '4.1'

def parser_gen() -> argparse.ArgumentParser:
def get_parser() -> argparse.ArgumentParser:
"""Generate argument parser for the application."""
formatter = argparse.ArgumentDefaultsHelpFormatter
parser_main = argparse.ArgumentParser(description='Qubes Template Manager',
Expand Down Expand Up @@ -128,7 +128,7 @@ def parser_add_command(cmd, help_str):
parser_install = parser_add_command('install',
help_str='Install template packages.')
parser_install.add_argument('--pool',
help='Specify pool to store created VMs in.')
help='Specify storage pool to store created templates in.')
parser_reinstall = parser_add_command('reinstall',
help_str='Reinstall template packages.')
parser_downgrade = parser_add_command('downgrade',
Expand Down Expand Up @@ -212,7 +212,7 @@ def parser_add_command(cmd, help_str):

return parser_main

parser = parser_gen()
parser = get_parser()

class TemplateState(enum.Enum):
"""Enum representing the state of a template."""
Expand Down Expand Up @@ -467,10 +467,10 @@ def qrexec_repoquery(
for line in stderr.decode('ASCII').rstrip().split('\n'):
print('[Qrexec] %s' % line, file=sys.stderr)
raise ConnectionError("qrexec call 'qubes.TemplateSearch' failed.")
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._+~]*$')
date_re = re.compile(r'^\d+-\d+-\d+ \d+:\d+$')
licence_re = re.compile(r'^[A-Za-z0-9._+\-()]*$')
licence_re = re.compile(r'^[A-Za-z0-9._+()-]*$')
result = []
# FIXME: This breaks when \n is the first character of the description
for line in stdout.split('|\n'):
Expand Down

0 comments on commit 9401249

Please sign in to comment.