oh-my-batch 0.4.2__tar.gz → 0.4.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oh-my-batch
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary:
5
5
  License: GPL
6
6
  Author: weihong.xu
@@ -33,7 +33,7 @@ class ComboMaker:
33
33
  self.add_var(key, *args)
34
34
  return self
35
35
 
36
- def add_randint(self, key: str, n: int, a: int, b: int, seed=None):
36
+ def add_randint(self, key: str, n: int, a: int, b: int, uniq=False, seed=None):
37
37
  """
38
38
  Add a variable with random integer values
39
39
 
@@ -41,11 +41,17 @@ class ComboMaker:
41
41
  :param n: Number of values
42
42
  :param a: Lower bound
43
43
  :param b: Upper bound
44
+ :param uniq: If True, values are unique, default is False
44
45
  :param seed: Seed for random number generator
45
46
  """
46
47
  if seed is not None:
47
48
  random.seed(seed)
48
- args = [random.randint(a, b) for _ in range(n)]
49
+ if uniq:
50
+ if b - a + 1 < n:
51
+ raise ValueError("Not enough unique values")
52
+ args = random.sample(range(a, b + 1), n)
53
+ else:
54
+ args = [random.randint(a, b) for _ in range(n)]
49
55
  self.add_var(key, *args)
50
56
  return self
51
57
 
@@ -221,7 +227,7 @@ class ComboMaker:
221
227
 
222
228
  For example,
223
229
 
224
- run_cmd "cp {DATA_FIEL} ./path/to/workdir/{i}/data.txt"
230
+ run_cmd "cp {DATA_FILE} ./path/to/workdir/{i}/data.txt"
225
231
 
226
232
  will copy each file in DATA_FILE to ./path/to/workdir/{i}/data.txt
227
233
 
@@ -237,6 +243,20 @@ class ComboMaker:
237
243
  raise RuntimeError(f"Failed to run command: {_cmd}")
238
244
  return self
239
245
 
246
+ def show_combos(self):
247
+ combos = self._make_combos()
248
+ if not combos:
249
+ print("No combos")
250
+ keys = combos[0].keys()
251
+
252
+ for i, combo in enumerate(combos):
253
+ print(f"> Combo {i}:")
254
+ for k in keys:
255
+ v = str(combo[k])
256
+ if '\n' in v:
257
+ v = f"\n{v}"
258
+ print(f"@{k}: {v}")
259
+
240
260
  def done(self):
241
261
  """
242
262
  End of command chain
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "oh-my-batch"
3
- version = "0.4.2"
3
+ version = "0.4.4"
4
4
  description = ""
5
5
  authors = ["weihong.xu <xuweihong.cn@gmail.com>"]
6
6
  license = "GPL"
File without changes
File without changes