Skip to content

Commit a85af77

Browse files
🍀 refactor - inline if elses.
Issue: #10
1 parent 06ebd4c commit a85af77

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

1build

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ class Project:
2020
if cmd.name == command_name:
2121
return cmd
2222
else:
23-
raise ValueError("No command '" + command_name + "' found in config file " + __build_file_name__() + "\n\n" +
24-
__help_message__(self)
25-
)
23+
raise ValueError(
24+
"No command '" + command_name + "' found in config file " + __build_file_name__() + "\n\n" +
25+
__help_message__(self)
26+
)
2627

2728
def __has_command__(self, command_name):
2829
for cmd in self.commands:
@@ -47,17 +48,12 @@ class Command:
4748

4849

4950
def run(build_file_name, arguments):
50-
"""
51-
:param build_file_name: parametrize build file name & update the global BUILD_FILE_NAME variable with this value
52-
:param arguments: command line arguments will be passed here
53-
"""
5451
global BUILD_FILE_NAME
5552
BUILD_FILE_NAME = build_file_name
56-
5753
try:
5854
project = __parse_project_config__()
5955
command_name = command_to_run(arguments)
60-
if command_name.lower() == "help":
56+
if command_name == "help":
6157
print(__help_message__(project))
6258
else:
6359
command = project.get_command(command_name)
@@ -68,10 +64,7 @@ def run(build_file_name, arguments):
6864

6965
def execute(command, before=None, after=None):
7066
cmd = command.cmd
71-
72-
print(dash)
73-
print("Name: " + command.name)
74-
print("Command: " + command.cmd)
67+
print(dash + "\nName: " + command.name + "\nCommand: " + command.cmd)
7568
if before:
7669
print("Before: " + before)
7770
cmd = before + " && " + cmd
@@ -119,10 +112,7 @@ def __build_file_name__(): return "'" + BUILD_FILE_NAME + "'"
119112

120113

121114
def command_to_run(arguments):
122-
if len(arguments) is 1:
123-
return "help"
124-
else:
125-
return arguments[1]
115+
return "help" if len(arguments) == 1 else arguments[1]
126116

127117

128118
def sample_yaml_file():

0 commit comments

Comments
 (0)