oh-my-batch 0.5.7__py3-none-any.whl → 0.6.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.
oh_my_batch/batch.py CHANGED
@@ -1,3 +1,4 @@
1
+ from typing import Optional
1
2
  import shlex
2
3
  import os
3
4
 
@@ -25,6 +26,24 @@ class BatchMaker:
25
26
  self._work_dirs.extend(paths)
26
27
  return self
27
28
 
29
+ def filter(self, expr: str):
30
+ """
31
+ Filter working directories with a Python expression
32
+
33
+ :param expr: Python expression, the variable `{workdir}, {work_dir} or {w}` is the directory path,
34
+ `{index} or {i}` is the index of the directory
35
+
36
+ Example: if expr is 'os.path.exits("{workdir}/input.json")',
37
+ then only the directories containing 'input.json' will be kept.
38
+ """
39
+ filtered = []
40
+ for i, workdir in enumerate(self._work_dirs):
41
+ expr_eval = expr.format(workdir=workdir, work_dir=workdir, w=workdir, index=i, i=i)
42
+ if eval(expr_eval):
43
+ filtered.append(workdir)
44
+ self._work_dirs = filtered
45
+ return self
46
+
28
47
  def add_header_files(self, *file: str, encoding='utf-8'):
29
48
  """
30
49
  Add script header from files
@@ -130,4 +149,4 @@ def load_files(*file, encoding='utf-8', raise_invalid=False):
130
149
  for file in expand_globs(file, raise_invalid=raise_invalid):
131
150
  with open(file, 'r', encoding=encoding) as f:
132
151
  result.append(f.read())
133
- return result
152
+ return result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oh-my-batch
3
- Version: 0.5.7
3
+ Version: 0.6.1
4
4
  Summary:
5
5
  License: GPL
6
6
  Author: weihong.xu
@@ -2,14 +2,14 @@ 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
4
  oh_my_batch/assets/functions.sh,sha256=LaiavZBu84D7C1r-dWhf91vPTuHXCMV1DQZUIPVQnjE,1001
5
- oh_my_batch/batch.py,sha256=i3q1zY2li-YyN_99zjlpNJlZqqF5PSO3hwW1e0_N2VE,3958
5
+ oh_my_batch/batch.py,sha256=nQUrKULULYUPtkibrU4SJlJQM9D63TsC1VajHcxZulQ,4723
6
6
  oh_my_batch/cli.py,sha256=Jyz8q2pUYke3mfJS6F_G9S9hApddgXxQw1BsN6Kfkjc,553
7
7
  oh_my_batch/combo.py,sha256=Twtzbv3hQUCNzwLjtbhmXJ_De5YNlL1mSzK-Zqejh7Y,11423
8
8
  oh_my_batch/job.py,sha256=fFoyLd0rKilV979ovEf0Y3iXgpyyDmHIfkMSZBaAX4Q,7446
9
9
  oh_my_batch/misc.py,sha256=G_iOovRCrShBJJCc82QLN0CvMqW4adOefEoY1GedEiw,452
10
10
  oh_my_batch/util.py,sha256=5ve2QcviuF0UHFLrsXmjMTj0ogXJ4g05q1y-yWCFuOk,2409
11
- oh_my_batch-0.5.7.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
12
- oh_my_batch-0.5.7.dist-info/METADATA,sha256=EPKPEteFvfkUMC70IhiDoyBaTCwBX2_zBwRdauJ1CF8,5468
13
- oh_my_batch-0.5.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
14
- oh_my_batch-0.5.7.dist-info/entry_points.txt,sha256=ZY2GutSoNjjSyJ4qO2pTeseKUFgoTYdvmgkuZZkwi68,77
15
- oh_my_batch-0.5.7.dist-info/RECORD,,
11
+ oh_my_batch-0.6.1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
12
+ oh_my_batch-0.6.1.dist-info/METADATA,sha256=ETV1q0arbSp8Xj-PFTKGj3rO6bbus8nX-XrtKQH1elI,5468
13
+ oh_my_batch-0.6.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
14
+ oh_my_batch-0.6.1.dist-info/entry_points.txt,sha256=ZY2GutSoNjjSyJ4qO2pTeseKUFgoTYdvmgkuZZkwi68,77
15
+ oh_my_batch-0.6.1.dist-info/RECORD,,