Skip to content

Commit

Permalink
Remove not used code (#58)
Browse files Browse the repository at this point in the history
* remove not needed code

* remove not needed code

* linting
  • Loading branch information
reschandreas authored Jan 6, 2024
1 parent 18d24f4 commit b70f4c8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 6 additions & 2 deletions cli/generators/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ class CliGenerator(BaseGenerator):

template: Optional[Template] = None

actions: List[ScriptAction] = []

def __init__(
self, windfile: WindFile, input_settings: InputSettings, output_settings: OutputSettings, metadata: PassMetadata
):
input_settings.target = Target.cli
self.functions = []
self.actions = []
super().__init__(windfile, input_settings, output_settings, metadata)

def handle_step(self, name: str, step: ScriptAction, call: bool) -> None:
Expand Down Expand Up @@ -74,6 +77,7 @@ def handle_step(self, name: str, step: ScriptAction, call: bool) -> None:
self.before_results[step.name] = [result for result in step.results if result.before]
if self.windfile.metadata.moveResultsTo:
self.after_results[step.name] = [result for result in step.results if result.before]
self.actions.append(step)
return None

def check(self, content: str) -> bool:
Expand Down Expand Up @@ -185,8 +189,8 @@ def generate_using_jinja2(self) -> str:
"needs_subshells": self.needs_subshells,
"has_always_actions": self.has_always_actions(),
"functions": self.functions,
"steps": [action.root for action in self.windfile.actions],
"always_steps": [action.root for action in self.windfile.actions if action.root.runAlways],
"steps": self.actions,
"always_steps": [action for action in self.actions if action.runAlways],
"metadata": self.windfile.metadata,
"before_results": self.before_results,
"after_results": self.after_results,
Expand Down
12 changes: 9 additions & 3 deletions cli/generators/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import jenkins # type: ignore
from jinja2 import Environment, FileSystemLoader, Template

from classes.generated.definitions import Target
from classes.generated.definitions import Target, Action
from classes.generated.windfile import WindFile
from classes.input_settings import InputSettings
from classes.output_settings import OutputSettings
Expand Down Expand Up @@ -115,14 +115,20 @@ def generate_using_jinja2(self) -> str:
env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), "..", "templates")))
self.template = env.get_template("Jenkinsfile.j2")

actions: List[Action] = []
for action in self.windfile.actions:
if action.root.platform and action.root.platform != Target.jenkins:
continue
actions.append(action)

data: dict[str, typing.Any] = {
"docker": self.windfile.metadata.docker,
"environment": self.windfile.environment.root.root if self.windfile.environment else None,
"needs_lifecycle_parameter": self.needs_lifecycle_parameter,
"repositories": self.windfile.repositories if self.windfile.repositories else None,
"has_always_actions": self.has_always_actions(),
"steps": [action.root for action in self.windfile.actions if not action.root.runAlways],
"always_steps": [action.root for action in self.windfile.actions if action.root.runAlways],
"steps": [action.root for action in actions if not action.root.runAlways],
"always_steps": [action.root for action in actions if action.root.runAlways],
"metadata": self.windfile.metadata,
"before_results": self.before_results,
"after_results": self.after_results,
Expand Down
2 changes: 1 addition & 1 deletion cli/test/test_env_replacement.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def generate_and_check_if_repository_variables_are_set(
if index > 0:
var_name += f"_{index}"
self.assertIn(f"{var_name} = '{repo.url}'", result)
self.assertIn("url: '${" + var_name + "}'", result)
self.assertIn('url: "${' + var_name + '}"', result)
index += 1
elif isinstance(gen, CliGenerator):
for repo in windfile.repositories.values():
Expand Down

0 comments on commit b70f4c8

Please sign in to comment.