|
35 | 35 | USER_OUTPUT_DIR, |
36 | 36 | MissingFile, |
37 | 37 | NonZeroExit, |
| 38 | + render_command, |
38 | 39 | run_command, |
39 | 40 | ) |
40 | 41 |
|
@@ -96,39 +97,6 @@ def __init__(self) -> None: |
96 | 97 | self.status = self.requirements.get_status() |
97 | 98 | self.missing = self.requirements.get_missing() |
98 | 99 |
|
99 | | - def render_command(self, command: list[str], map: dict[str, str]) -> list[str]: |
100 | | - """Render a command template by replacing placeholders with values. |
101 | | -
|
102 | | - Args: |
103 | | - command: The command template as a list of strings. |
104 | | - map: A dictionary of placeholders to their replacement values. |
105 | | -
|
106 | | - Returns: |
107 | | - The rendered command as a list of strings. |
108 | | -
|
109 | | - """ |
110 | | - _command = command.copy() |
111 | | - for pattern, value in map.items(): |
112 | | - for i, arg in enumerate(_command): |
113 | | - # Check if optional argument can be used |
114 | | - if isinstance(arg, tuple): |
115 | | - default_arg, optional_arg = arg |
116 | | - if pattern in optional_arg: |
117 | | - _command[i] = arg.replace(pattern, value) |
118 | | - else: |
119 | | - _command[i] = default_arg |
120 | | - else: |
121 | | - if pattern in arg: |
122 | | - _command[i] = arg.replace(pattern, value) |
123 | | - |
124 | | - # Remove not rendered part of the command: |
125 | | - __command = [] |
126 | | - for part in _command: |
127 | | - if not ("{" in part and "}" in part): |
128 | | - __command.append(part) |
129 | | - |
130 | | - return __command |
131 | | - |
132 | 100 | def run_analysis( |
133 | 101 | self, lang: str, project_dir: Path, output_dir: Path, **kwargs: Any |
134 | 102 | ) -> None: |
@@ -165,7 +133,7 @@ def run_analysis( |
165 | 133 | command_output = "" |
166 | 134 | start = time.time() |
167 | 135 | for command in self.commands: |
168 | | - rendered_command = self.render_command(command, render_variables) |
| 136 | + rendered_command = render_command(command, render_variables) |
169 | 137 | retcode, out = run_command(rendered_command, project_dir, self.environ) |
170 | 138 | command_output += out |
171 | 139 | if retcode not in self.valid_codes: |
|
0 commit comments