Skip to content

Commit

Permalink
improve build version menu
Browse files Browse the repository at this point in the history
* adds template type context to build version menu
* move conditions in convenience function get_template_type()
* updates `dist` files
  • Loading branch information
itoffshore committed Oct 14, 2023
1 parent b753733 commit 78efba9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
Binary file removed dist/distrobuilder_menu-0.1.3.tar.gz
Binary file not shown.
Binary file not shown.
Binary file added dist/distrobuilder_menu-0.1.4.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build-backend = "hatchling.build"

[project]
name = "distrobuilder_menu"
version = "0.1.3"
version = "0.1.4"
authors = [
{ name="Stuart Cardall", email="developer@it-offshore.co.uk" },
]
Expand Down
8 changes: 3 additions & 5 deletions src/distrobuilder_menu/menus/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def menu_versions(template, version_list, template_path):
# get_menu_context() is for directory type menus
# there is only one instance of this file type menu so construct title / question
title = f"Build {container_type} Variant"
question = f"Choose {container_type} variant to build from template: {template}"
template_type = helpers.get_template_type(template_path)
question = f"Build {container_type} variant from {template_type} template: {template}"

# generate menu (see menus.py)
# get_choice() returns a list index here
Expand Down Expand Up @@ -393,10 +394,7 @@ def generate_custom_template():
return

# show context
if USER_CONFIG.subdir_images in src_template:
src_type = 'standard'
else:
src_type = 'custom'
src_type = helpers.get_template_type(src_template)
print(f"\nOverriding {src_type} SOURCE template: {os_name}")

# choose OVERRIDE file / menu
Expand Down
15 changes: 15 additions & 0 deletions src/distrobuilder_menu/menus/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,21 @@ def get_menu_context(template_dir, pre_str, action):
return menu_context


def get_template_type(template):
""" Convenience function for template types
Args:
template (path): path to the template
Returns: 'standard' || 'custom'
"""
if USER_CONFIG.subdir_images in template:
template_type = 'standard'
else:
template_type = 'custom'
return template_type


def select_file_paths():
""" Used by create_custom_override() to add the file paths to include
in the override file used to generate a custom template
Expand Down

0 comments on commit 78efba9

Please sign in to comment.