Mercurial > repos > richard-burhans > segalign
comparison package_output.py @ 4:36cafb694dd2 draft
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit b8aa943b38b865defab8a27e4404bb8a2131f919
| author | richard-burhans |
|---|---|
| date | Tue, 23 Apr 2024 22:39:23 +0000 |
| parents | 5c72425b7f1b |
| children | 08e987868f0f |
comparison
equal
deleted
inserted
replaced
| 3:6f46cebc9ed8 | 4:36cafb694dd2 |
|---|---|
| 31 if self.tarfile is None: | 31 if self.tarfile is None: |
| 32 self.tarfile = tarfile.open( | 32 self.tarfile = tarfile.open( |
| 33 name=self.pathname, | 33 name=self.pathname, |
| 34 mode="w:gz", | 34 mode="w:gz", |
| 35 format=tarfile.GNU_FORMAT, | 35 format=tarfile.GNU_FORMAT, |
| 36 compresslevel=1, | 36 compresslevel=6, |
| 37 ) | 37 ) |
| 38 | 38 |
| 39 def add_config(self, pathname: str) -> None: | 39 def add_config(self, pathname: str) -> None: |
| 40 if self.tarfile is None: | 40 if self.tarfile is None: |
| 41 self._initialize() | 41 self._initialize() |
| 150 | 150 |
| 151 self.package_file.add_config("commands.json") | 151 self.package_file.add_config("commands.json") |
| 152 | 152 |
| 153 def _parse_line(self, line: str) -> typing.Dict[str, typing.Any]: | 153 def _parse_line(self, line: str) -> typing.Dict[str, typing.Any]: |
| 154 # resolve shell redirects | 154 # resolve shell redirects |
| 155 trees: typing.List[typing.Any] = bashlex.parse(line, strictmode=False) # type: ignore[attr-defined] | 155 trees: typing.List[typing.Any] = bashlex.parse(line, strictmode=False) |
| 156 positions: typing.List[typing.Tuple[int, int]] = [] | 156 positions: typing.List[typing.Tuple[int, int]] = [] |
| 157 | 157 |
| 158 for tree in trees: | 158 for tree in trees: |
| 159 visitor = nodevisitor(positions) | 159 visitor = nodevisitor(positions) |
| 160 visitor.visit(tree) | 160 visitor.visit(tree) |
| 174 command_dict["stderr"] = visitor.stderr | 174 command_dict["stderr"] = visitor.stderr |
| 175 | 175 |
| 176 return command_dict | 176 return command_dict |
| 177 | 177 |
| 178 def _parse_processed_line(self, line: str) -> typing.Dict[str, typing.Any]: | 178 def _parse_processed_line(self, line: str) -> typing.Dict[str, typing.Any]: |
| 179 argv: typing.List[str] = list(bashlex.split(line)) # type: ignore[attr-defined] | 179 argv: typing.List[str] = list(bashlex.split(line)) |
| 180 self.executable = argv.pop(0) | 180 self.executable = argv.pop(0) |
| 181 | 181 |
| 182 parser: argparse.ArgumentParser = argparse.ArgumentParser(add_help=False) | 182 parser: argparse.ArgumentParser = argparse.ArgumentParser(add_help=False) |
| 183 if "arguments" in self.config: | 183 if "arguments" in self.config: |
| 184 arguments_section = self.config["arguments"] | 184 arguments_section = self.config["arguments"] |
| 234 command_dict["args"].append(f"--query={value}") | 234 command_dict["args"].append(f"--query={value}") |
| 235 | 235 |
| 236 return command_dict | 236 return command_dict |
| 237 | 237 |
| 238 | 238 |
| 239 class nodevisitor(bashlex.ast.nodevisitor): # type: ignore[name-defined,misc] | 239 class nodevisitor(bashlex.ast.nodevisitor): # type: ignore[misc] |
| 240 def __init__(self, positions: typing.List[typing.Tuple[int, int]]) -> None: | 240 def __init__(self, positions: typing.List[typing.Tuple[int, int]]) -> None: |
| 241 self.positions = positions | 241 self.positions = positions |
| 242 self.stdin = None | 242 self.stdin = None |
| 243 self.stdout = None | 243 self.stdout = None |
| 244 self.stderr = None | 244 self.stderr = None |
| 245 | 245 |
| 246 def visitredirect( | 246 def visitredirect( |
| 247 self, | 247 self, |
| 248 n: bashlex.ast.node, # type: ignore[name-defined] | 248 n: bashlex.ast.node, |
| 249 n_input: int, | 249 n_input: int, |
| 250 n_type: str, | 250 n_type: str, |
| 251 output: typing.Any, | 251 output: typing.Any, |
| 252 heredoc: typing.Any, | 252 heredoc: typing.Any, |
| 253 ) -> None: | 253 ) -> None: |
| 254 if isinstance(n_input, int) and 0 <= n_input <= 2: | 254 if isinstance(n_input, int) and 0 <= n_input <= 2: |
| 255 if isinstance(output, bashlex.ast.node) and output.kind == "word": # type: ignore[attr-defined] | 255 if isinstance(output, bashlex.ast.node) and output.kind == "word": |
| 256 self.positions.append(n.pos) | 256 self.positions.append(n.pos) |
| 257 if n_input == 0: | 257 if n_input == 0: |
| 258 self.stdin = output.word | 258 self.stdin = output.word |
| 259 elif n_input == 1: | 259 elif n_input == 1: |
| 260 self.stdout = output.word | 260 self.stdout = output.word |
| 263 else: | 263 else: |
| 264 sys.exit(f"oops 1: {type(n_input)}") | 264 sys.exit(f"oops 1: {type(n_input)}") |
| 265 else: | 265 else: |
| 266 sys.exit(f"oops 2: {type(n_input)}") | 266 sys.exit(f"oops 2: {type(n_input)}") |
| 267 | 267 |
| 268 def visitheredoc(self, n: bashlex.ast.node, value: typing.Any) -> None: # type: ignore[name-defined] | 268 def visitheredoc(self, n: bashlex.ast.node, value: typing.Any) -> None: |
| 269 pass | 269 pass |
| 270 | 270 |
| 271 | 271 |
| 272 def main() -> None: | 272 def main() -> None: |
| 273 our_dirname: str = os.path.dirname(os.path.realpath(__file__)) | 273 our_dirname: str = os.path.dirname(os.path.realpath(__file__)) |
