Skip to content

Commit 2311c90

Browse files
Python interface: various PR bugs caught by Copilot
1 parent 8fa1a79 commit 2311c90

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

sbnalg/gallery/python/LArSoftUtils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def serviceClassToConfigKeys(serviceClassName: str) -> list[str]:
226226
candidates = []
227227

228228
# remove namespaces (namespaces are not part of any candidate)
229-
try: serviceClassName = serviceClassName[:serviceClassName.index('::')]
229+
try: serviceClassName = serviceClassName[:serviceClassName.rindex('::')]
230230
except ValueError: pass # no namespace
231231

232232
if not serviceClassName: return [] # ?!
@@ -284,10 +284,10 @@ def readServiceConfig(getConfig, configKey, returnConfigKey = True):
284284
= tuple(base + suffix for base in serviceClassToConfigKeys(configKey))
285285

286286
Logger.debug("Configuration from candidates: '%s'", "', '".join(configKeys))
287-
for configKey in configKeys:
288-
try: config = getConfig(configKey)
287+
for candidateKey in configKeys:
288+
try: config = getConfig(candidateKey)
289289
except Exception: continue
290-
return (config, configKey) if returnConfigKey else config
290+
return (config, candidateKey) if returnConfigKey else config
291291
raise RuntimeError(f"No configuration for service key '{configKey}'")
292292
# readServiceConfig()
293293

@@ -701,6 +701,8 @@ def fullConfig(self): return self.serviceTable is None
701701
def isValid(self): return self.configPath is not None
702702
def hasExtraConfig(self): return bool(self.extraConfig)
703703
def needsCustom(self): return not self.fullConfig() or self.hasExtraConfig()
704+
def serviceTableName(self):
705+
return 'services' if self.fullConfig() else self.serviceTable
704706

705707
def addExtraConfig(self, extra): self.extraConfig += "\n" + extra
706708

@@ -811,7 +813,7 @@ def loadConfiguration(self):
811813
'\n# ==============================='
812814
.format(
813815
configPath=configurationInfo.configPath,
814-
serviceTable=configurationInfo.serviceTable,
816+
serviceTable=configurationInfo.serviceTableName(),
815817
extraConfig=configurationInfo.extraConfig,
816818
)
817819
)

sbnalg/gallery/python/cppUtils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,10 @@ def loadMany(self, *pathSpecs, extraPaths = [], force = False, loadAll = False):
148148
`{ relPath: 'larcorealg_Geometry', extraPaths: [] }`.
149149
If a path specification is not a dictionary, it is assumed to be a `relPath`
150150
and it is equivalent to having `{ relPath: pathSpec }`.
151-
If an argument `extraPath` or `force` is specified in the path
152-
specification, a value is used from the `extraPath` and `force` arguments
153-
of this function.
151+
If `extraPaths` or `force` are not specified in a path specification,
152+
they default to the `extraPaths` and `force` arguments of this function;
153+
if they are specified in the path specification, their values override
154+
the defaults from this function.
154155
155156
If `loadAll` is set, all loads are attempted; the return value is a pair:
156157
whether an exception was thrown, and a list of all return values or

0 commit comments

Comments
 (0)