Skip to content

Commit

Permalink
tested the default function and cleared errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoEg committed Jun 16, 2024
1 parent baa47f2 commit 2dfc7bb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
34 changes: 17 additions & 17 deletions installation_instruction/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@
License: {__license__}
Repository: {__repository__}"""

def _get_system(option_types):

system = platform.system()
system_names = {
'Linux': 'lin',
'Darwin': 'mac',
'Windows': 'win',
}

sub_default = system_names.get(system,None)
for type in option_types:
default_type = type.lower()
if sub_default in default_type:
return type

return None

class ConfigReadCommand(click.MultiCommand):
"""
Expand All @@ -43,22 +59,6 @@ def __init__(self, *args, **kwargs):
options_metavar="",
)

def _get_system(self, option_types):
system = platform.system().lower()
system_names = {
'linux': 'lin',
'linux2': 'lin',
'darwin': 'mac',
'win32': 'win',
}
if system in system_names.keys:
system = system_names.get(system)
for type in option_types:
if system in type.lower():
return type

return None


def get_command(self, ctx, config_file: str) -> click.Command|None:
if not isfile(config_file):
Expand All @@ -74,7 +74,7 @@ def get_command(self, ctx, config_file: str) -> click.Command|None:

for option in options:
if '__os__' in option.name:
system_default = self._get_system(option.type.choices)
system_default = _get_system(option.type.choices)
if system_default:
option.default = system_default

Expand Down
7 changes: 7 additions & 0 deletions tests/data/test_install/install.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ properties:
error_template:
type: boolean
default: false
__os__:
description: The operating system in which the package is installed.
enum:
- Windows
- macOS
- Linux
default: macOS
required:
- error_install
- error_template
Expand Down

0 comments on commit 2dfc7bb

Please sign in to comment.