oh-my-batch 0.2.5__py3-none-any.whl → 0.3.1__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.
@@ -21,7 +21,7 @@ checkpoint() {
21
21
  fi
22
22
  }
23
23
 
24
- echo -e "${GREEN}Functiion: checkpoint${NC}"
24
+ echo -e "${GREEN}Function: checkpoint${NC}"
25
25
  cat <<EOF
26
26
  Usage:
27
27
  checkpoint <flag_file> <command> [arg1] [arg2] ...
oh_my_batch/combo.py CHANGED
@@ -161,7 +161,7 @@ class ComboMaker:
161
161
  raise ValueError(f"Variable {key} not found")
162
162
  return self
163
163
 
164
- def make_files(self, template: str, dest: str, delimiter='@', mode=None, encoding='utf-8'):
164
+ def make_files(self, file: str, template: str, delimiter='@', mode=None, encoding='utf-8'):
165
165
  """
166
166
  Make files from template against each combo
167
167
  The template file can include variables with delimiter.
@@ -171,8 +171,8 @@ class ComboMaker:
171
171
  For example, if dest is 'output/{i}-{TEMP}.txt',
172
172
  then files are saved as output/0-300K.txt, output/1-400K.txt, ...
173
173
 
174
+ :param file: Path pattern to destination file
174
175
  :param template: Path to template file
175
- :param dest: Path pattern to destination file
176
176
  :param delimiter: Delimiter for variables in template, default is '@', as '$' is popular in shell scripts
177
177
  can be changed to other character, e.g $, $$, ...
178
178
  :param mode: File mode, e.g. 755, 644, ...
@@ -188,12 +188,12 @@ class ComboMaker:
188
188
  with open(template, 'r') as f:
189
189
  template_text = f.read()
190
190
  text = _Template(template_text).safe_substitute(combo)
191
- _dest = dest.format(i=i, **combo)
192
- ensure_dir(_dest)
193
- with open(_dest, 'w', encoding=encoding) as f:
191
+ _file = file.format(i=i, **combo)
192
+ ensure_dir(_file)
193
+ with open(_file, 'w', encoding=encoding) as f:
194
194
  f.write(text)
195
195
  if mode is not None:
196
- os.chmod(_dest, mode_translate(str(mode)))
196
+ os.chmod(_file, mode_translate(str(mode)))
197
197
  return self
198
198
 
199
199
  def print(self, *line: str, file: str = '', mode=None, encoding='utf-8'):
oh_my_batch/util.py CHANGED
@@ -60,7 +60,7 @@ def ensure_dir(path: str):
60
60
  """
61
61
  d = os.path.dirname(path)
62
62
  if d:
63
- os.makedirs(os.path.dirname(d), exist_ok=True)
63
+ os.makedirs(d, exist_ok=True)
64
64
 
65
65
 
66
66
  def mode_translate(mode: str):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oh-my-batch
3
- Version: 0.2.5
3
+ Version: 0.3.1
4
4
  Summary:
5
5
  License: GPL
6
6
  Author: weihong.xu
@@ -47,10 +47,12 @@ To make the best use of `oh-my-batch`, you need to know some shell tips.
47
47
  You can load useful functions from `oh-my-batch` this way:
48
48
 
49
49
  ```bash
50
- omb misc export-shell-func > omb-func.sh && source omb-func.sh && rm omb-func.sh
50
+ eval "$(omb misc export-shell-func)"
51
+ # or
52
+ omb misc export-shell-func > omb-func.sh && source omb-func.sh
51
53
  ```
52
54
 
53
- This will load some functions to your shell script, for example, `checkpoint`.
55
+ This will load extra functions to your shell script, for example, `checkpoint`.
54
56
 
55
57
  ### Generate files from different combinations of parameters
56
58
 
@@ -83,8 +85,8 @@ omb combo \
83
85
  add_files DATA_FILE tmp/*.data - \
84
86
  add_var TEMP 300 400 500 - \
85
87
  add_randint RANDOM -n 3 -a 1 -b 1000 --broadcast - \
86
- make_files tmp/in.lmp.tmp tmp/tasks/{i}-T-{TEMP}/in.lmp - \
87
- make_files tmp/run.sh.tmp tmp/tasks/{i}-T-{TEMP}/run.sh --mode 755 - \
88
+ make_files tmp/tasks/{i}-T-{TEMP}/in.lmp --template tmp/in.lmp.tmp - \
89
+ make_files tmp/tasks/{i}-T-{TEMP}/run.sh --template tmp/run.sh.tmp --mode 755 - \
88
90
  done
89
91
  ```
90
92
 
@@ -1,15 +1,15 @@
1
1
  oh_my_batch/__init__.py,sha256=BsRNxZbqDWfaIZJGxzIDqCubRWztMGFDceW08TECuFs,98
2
2
  oh_my_batch/__main__.py,sha256=sWyFZMwWNvhkanwZSJRGfBBDoIevhC028dTSB67i6yI,61
3
3
  oh_my_batch/assets/__init__.py,sha256=Exub46UbQaz2V2eXpQeiVfnThQpXaNeuyjlGY6gBSZc,130
4
- oh_my_batch/assets/functions.sh,sha256=dvPGpOKz4CyUSlE5IAewQc8HUrQJuaZ0j-WZIuxB3Tg,1002
4
+ oh_my_batch/assets/functions.sh,sha256=LaiavZBu84D7C1r-dWhf91vPTuHXCMV1DQZUIPVQnjE,1001
5
5
  oh_my_batch/batch.py,sha256=6qnaXEVyA493heGzzbCrdZXCcnYk8zgl7WP0rmo7KlU,3690
6
6
  oh_my_batch/cli.py,sha256=Jyz8q2pUYke3mfJS6F_G9S9hApddgXxQw1BsN6Kfkjc,553
7
- oh_my_batch/combo.py,sha256=-qgqT7XSvEeyefMPD3-HuX-aozefjSKhbZbPm1pm_18,9324
7
+ oh_my_batch/combo.py,sha256=U3vdHcqe2TEqMVMH7kVW-AlIYFzle839E9BzMNVtj6Y,9324
8
8
  oh_my_batch/job.py,sha256=Uk0E-WxnexBu9wuUV3uc1aAwVF_5rWdNdLEOB8Y9B-U,6252
9
9
  oh_my_batch/misc.py,sha256=G_iOovRCrShBJJCc82QLN0CvMqW4adOefEoY1GedEiw,452
10
- oh_my_batch/util.py,sha256=K-XAndE5dgpxBrohAlUhVpeJGT7Q9vUG9ghHc9L0HaU,2426
11
- oh_my_batch-0.2.5.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
12
- oh_my_batch-0.2.5.dist-info/METADATA,sha256=KxRayqgrzOIz_ng2VHElCtjowYOPlfvaOKzEBoeID5w,5445
13
- oh_my_batch-0.2.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
14
- oh_my_batch-0.2.5.dist-info/entry_points.txt,sha256=ZY2GutSoNjjSyJ4qO2pTeseKUFgoTYdvmgkuZZkwi68,77
15
- oh_my_batch-0.2.5.dist-info/RECORD,,
10
+ oh_my_batch/util.py,sha256=5ve2QcviuF0UHFLrsXmjMTj0ogXJ4g05q1y-yWCFuOk,2409
11
+ oh_my_batch-0.3.1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
12
+ oh_my_batch-0.3.1.dist-info/METADATA,sha256=vCTUrC_RUrC7162mntphFlwIt3JAYvdxjC3EFQZFqi8,5492
13
+ oh_my_batch-0.3.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
14
+ oh_my_batch-0.3.1.dist-info/entry_points.txt,sha256=ZY2GutSoNjjSyJ4qO2pTeseKUFgoTYdvmgkuZZkwi68,77
15
+ oh_my_batch-0.3.1.dist-info/RECORD,,