From 32178f5e32c28fcfe19ba4e219a408c71cfab4cb Mon Sep 17 00:00:00 2001 From: Michael Sekania Date: Thu, 17 Aug 2023 19:41:47 +0200 Subject: [PATCH 1/2] Fix/Improve class With --- slurm.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/slurm.py b/slurm.py index a916693..68ca371 100755 --- a/slurm.py +++ b/slurm.py @@ -229,21 +229,19 @@ def sets(self, sacctmgr): class With(Parser): """Parameters dependent on a With* argument, only supplied if the given key parameter is""" - def __init__(self, w, k, *l): + def __init__(self, w, *l): self.args = w - self.key = k + self.optlen = len(l) self.sub = List(*l) def parse(self, sacctmgr): - self.key.format(sacctmgr) - self.key.parse(sacctmgr) - if self.key.val is not None: + if self.optlen > 0: sacctmgr.args.append(self.args) self.sub.format(sacctmgr) self.sub.parse(sacctmgr) def sets(self, sacctmgr): - if self.key.val is not None: + if self.optlen > 0: self.sub.sets(sacctmgr) class Opt(Param): From 4b99ad61b09e4afd78ba43aebd40efd8e5c9b8cd Mon Sep 17 00:00:00 2001 From: Michael Sekania Date: Wed, 24 Jul 2024 11:48:33 +0200 Subject: [PATCH 2/2] Update slurm.py, do not add With key in format if key is not set --- slurm.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/slurm.py b/slurm.py index 68ca371..3e18a40 100755 --- a/slurm.py +++ b/slurm.py @@ -229,19 +229,21 @@ def sets(self, sacctmgr): class With(Parser): """Parameters dependent on a With* argument, only supplied if the given key parameter is""" - def __init__(self, w, *l): + def __init__(self, w, k, *l): self.args = w - self.optlen = len(l) + self.key = k self.sub = List(*l) def parse(self, sacctmgr): - if self.optlen > 0: + self.key.parse(sacctmgr) + if self.key.val is not None: + self.key.format(sacctmgr) sacctmgr.args.append(self.args) self.sub.format(sacctmgr) self.sub.parse(sacctmgr) def sets(self, sacctmgr): - if self.optlen > 0: + if self.key.val is not None: self.sub.sets(sacctmgr) class Opt(Param):