runem 0.1.2__py3-none-any.whl → 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
runem/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.3.0
runem/job.py CHANGED
@@ -11,6 +11,12 @@ class NoJobName(ValueError):
11
11
  pass
12
12
 
13
13
 
14
+ class BadWhenConfigLocation(ValueError):
15
+ """The job-config does not contain a label and can't be coerced to crate one."""
16
+
17
+ pass
18
+
19
+
14
20
  class Job:
15
21
  """A class with utility functions for jobs.
16
22
 
@@ -27,6 +33,16 @@ class Job:
27
33
 
28
34
  TODO: make a non-static member function
29
35
  """
36
+ if "tags" in job:
37
+ raise BadWhenConfigLocation(
38
+ "'tags' should be listed inside the 'when' config for jobs"
39
+ )
40
+
41
+ if "phase" in job:
42
+ raise BadWhenConfigLocation(
43
+ "'phase' should be listed inside the 'when' config for jobs"
44
+ )
45
+
30
46
  if "when" not in job or "tags" not in job["when"]:
31
47
  # handle the special case where we have No tags
32
48
  return None
@@ -1,18 +1,24 @@
1
1
  import shlex
2
2
  import typing
3
3
 
4
+ from typing_extensions import Unpack
5
+
6
+ from runem.config_metadata import ConfigMetadata
4
7
  from runem.run_command import run_command
8
+ from runem.types.common import FilePathList
9
+ from runem.types.options import OptionsWritable
5
10
  from runem.types.runem_config import JobConfig
11
+ from runem.types.types_jobs import AllKwargs
6
12
 
7
13
 
8
14
  def validate_simple_command(command_string: str) -> typing.List[str]:
9
- # use shlex to handle parsing of the command string, a non-trivial problem.
15
+ """Use shlex to handle parsing of the command string, a non-trivial problem."""
10
16
  split_command: typing.List[str] = shlex.split(command_string)
11
17
  return split_command
12
18
 
13
19
 
14
20
  def job_runner_simple_command(
15
- **kwargs: typing.Any,
21
+ **kwargs: Unpack[AllKwargs],
16
22
  ) -> None:
17
23
  """Parses the command and tries to run it via the system.
18
24
 
@@ -22,11 +28,37 @@ def job_runner_simple_command(
22
28
  job_config: JobConfig = kwargs["job"]
23
29
  command_string: str = job_config["command"]
24
30
 
31
+ command_string_files: str = command_string
32
+ if "{file_list}" in command_string:
33
+ file_list: FilePathList = kwargs["file_list"]
34
+ file_list_with_quotes: typing.List[str] = [
35
+ f'"{str(file_path)}"' for file_path in file_list
36
+ ]
37
+ command_string_files = command_string.replace(
38
+ "{file_list}", " ".join(file_list_with_quotes)
39
+ )
40
+
41
+ config_metadata: ConfigMetadata = kwargs["config_metadata"]
42
+ options: OptionsWritable = config_metadata.options
43
+ command_string_options: str = command_string_files
44
+ for name, value in options.items():
45
+ # For now, just pass `--option-name`, `--check` or similar to the
46
+ # command line. At some point we will want this to be cleverer, but
47
+ # this will do for now.
48
+ option_search = f"{{{name}}}"
49
+ if option_search in command_string_files:
50
+ replacement = ""
51
+ if value:
52
+ replacement = f"--{name}"
53
+ command_string_options = command_string_options.replace(
54
+ option_search, replacement
55
+ )
56
+
25
57
  # use shlex to handle parsing of the command string, a non-trivial problem.
26
- result = validate_simple_command(command_string)
58
+ cmd = validate_simple_command(command_string_options)
27
59
 
28
60
  # preserve quotes for consistent handling of strings and avoid the "word
29
61
  # splitting" problem for unix-like shells.
30
- result_with_quotes = [f'"{token}"' if " " in token else token for token in result]
62
+ cmd_with_quotes = [f'"{token}"' if " " in token else token for token in cmd]
31
63
 
32
- run_command(cmd=result_with_quotes, **kwargs)
64
+ run_command(cmd=cmd_with_quotes, **kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: runem
3
- Version: 0.1.2
3
+ Version: 0.3.0
4
4
  Summary: Awesome runem created by lursight
5
5
  Home-page: https://github.com/lursight/runem/
6
6
  Author: lursight
@@ -9,7 +9,7 @@ License-File: LICENSE
9
9
  Requires-Dist: packaging
10
10
  Requires-Dist: PyYAML
11
11
  Requires-Dist: rich
12
- Requires-Dist: typing-extensions
12
+ Requires-Dist: typing_extensions
13
13
  Provides-Extra: tests
14
14
  Requires-Dist: black==24.10.0; extra == "tests"
15
15
  Requires-Dist: coverage==7.5; extra == "tests"
@@ -1,4 +1,4 @@
1
- runem/VERSION,sha256=KXtQ8IOG01Ifj9ry94642dCs30UtLmFZaQX7o3IIx5I,6
1
+ runem/VERSION,sha256=2RXMldbKj0euKXcT7UbU5cXZnd0p_Dxh4mO98wXytbA,6
2
2
  runem/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  runem/__main__.py,sha256=dsOiVZegpfK9JOs5n7UmbX5iwwbj7iFkEbLoVeEgAn4,136
4
4
  runem/base.py,sha256=EZfR7FIlwEdU9Vfe47Wk2DOO8GQqpKxxLNKp6YHueZ4,316
@@ -11,10 +11,10 @@ runem/config_parse.py,sha256=sXPMA8HSUcaJoq0dUfphK181waZqnIrq20mpYOQ_XCo,13498
11
11
  runem/files.py,sha256=59boeFvUANYOS-PllIjeKIht6lNINZ43WxahDg90oAc,4392
12
12
  runem/hook_manager.py,sha256=H0TL3HCqU2mgKm_-dgCD7TsK5T1bLT4g7x6kpytMPhU,4350
13
13
  runem/informative_dict.py,sha256=U7p9z78UwOT4TAfng1iDXCEyeYz6C-XZlx9Z1pWNVrI,1548
14
- runem/job.py,sha256=LmNXDHxDxAwyJxAAdPHIv_0bwZy2btyTPHPGO_N7euI,2986
14
+ runem/job.py,sha256=NOdRQnGePPyYdmIR_6JKVFzp9nbgNGetpE13bHEHaf4,3442
15
15
  runem/job_execute.py,sha256=BPkeTpeTGJs3QWa0-07DZvF1f0uKO79e4yMsTxq1UHk,4656
16
16
  runem/job_filter.py,sha256=7vgG4YWJ9gyGBFjV7QbSojG5ofYoszAmxXx9HnMLkHo,5384
17
- runem/job_runner_simple_command.py,sha256=OIfj7CrPy0fPszhubUsTzORMlMC62OiNSvH5DysYL-4,1104
17
+ runem/job_runner_simple_command.py,sha256=iP5an6yixW8o4C0ZBtu6csb-oVK3Q62ZZgtHBmxlXaU,2428
18
18
  runem/job_wrapper.py,sha256=q5GtopZ5vhSJ581rwU4-lF9KnbL3ZYgOC8fqaCnXD_g,983
19
19
  runem/job_wrapper_python.py,sha256=rx7J_N-JXs8GgMq7Sla7B9s_ZAfofKUhEnzgMcq_bts,4303
20
20
  runem/log.py,sha256=dIrocigvIJs1ZGkAzTogXkAK-0ZW3q5FkjpDgLdeW-E,630
@@ -34,9 +34,9 @@ runem/types/runem_config.py,sha256=qG_bghm5Nr-ZTbaZbf1v8Fx447V-hgEvvRy5NZ3t-Io,5
34
34
  runem/types/types_jobs.py,sha256=wqiiBmRIJDbGlKcfOqewHGKx350w0p4_7pysMm7xGmo,4906
35
35
  tests/test_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
36
  tests/test_types/test_public_api.py,sha256=QHiwt7CetQur65JSbFRnOzQxhCJkX5MVLymHHVd_6yc,160
37
- runem-0.1.2.dist-info/LICENSE,sha256=awOCsWJ58m_2kBQwBUGWejVqZm6wuRtCL2hi9rfa0X4,1211
38
- runem-0.1.2.dist-info/METADATA,sha256=UQCyI88PE3lJWibR7VmDFyIGi9xPpnykhp8QKmn9E-U,5842
39
- runem-0.1.2.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
40
- runem-0.1.2.dist-info/entry_points.txt,sha256=nu0g_vBeuPihYtimbtlNusxWovylMppvJ8UxdJlJfvM,46
41
- runem-0.1.2.dist-info/top_level.txt,sha256=Zu65aVeDPh8WbChU4Mi7-Md4S3XJDPuqdQjEE3DSQno,12
42
- runem-0.1.2.dist-info/RECORD,,
37
+ runem-0.3.0.dist-info/LICENSE,sha256=awOCsWJ58m_2kBQwBUGWejVqZm6wuRtCL2hi9rfa0X4,1211
38
+ runem-0.3.0.dist-info/METADATA,sha256=60xJCeO4__eyLluCyFosw1UTsIbs1dyQFruOJ6iNM7I,5842
39
+ runem-0.3.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
40
+ runem-0.3.0.dist-info/entry_points.txt,sha256=nu0g_vBeuPihYtimbtlNusxWovylMppvJ8UxdJlJfvM,46
41
+ runem-0.3.0.dist-info/top_level.txt,sha256=Zu65aVeDPh8WbChU4Mi7-Md4S3XJDPuqdQjEE3DSQno,12
42
+ runem-0.3.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.5.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
File without changes