Skip to content

Commit abfedd7

Browse files
committed
style: minor style fixes
1 parent 5910837 commit abfedd7

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

src/DIRAC/ConfigurationSystem/Client/LocalConfiguration.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,8 @@ def __parseCommandLine(self):
412412

413413
groupArgs = []
414414
step = 0
415-
for i in range(len(self.commandArgumentList)):
416-
argMarking, description, mandatory, values, default = self.commandArgumentList[i]
415+
for i, commandArgument in enumerate(self.commandArgumentList):
416+
argMarking, description, mandatory, values, default = commandArgument
417417

418418
# Check whether the required arguments are given in the command line
419419
if len(self.commandArgList) <= (i + step):
@@ -433,7 +433,7 @@ def __parseCommandLine(self):
433433
if values and cArg not in values:
434434
gLogger.fatal(
435435
"Error when parsing command line arguments: "
436-
'"%s" does not match the allowed values for %s' % (cArg, argMarking)
436+
f'"{cArg}" does not match the allowed values for {argMarking}'
437437
)
438438
self.showHelp(exitCode=1)
439439

@@ -444,30 +444,39 @@ def __parseCommandLine(self):
444444
def __loadCFGFiles(self):
445445
"""
446446
Loads possibly several cfg files, in order:
447-
1. ~/.dirac.cfg
448-
2. cfg files pointed by DIRACSYSCONFIG env variable (comma-separated)
447+
1. cfg files pointed by DIRACSYSCONFIG env variable (comma-separated)
448+
2. ~/.dirac.cfg
449449
3. cfg files specified in addCFGFile calls
450450
4. cfg files that come from the command line
451451
"""
452452
errorsList = []
453+
454+
# 1. $DIRACSYSCONFIG
453455
if "DIRACSYSCONFIG" in os.environ:
454456
diracSysConfigFiles = os.environ["DIRACSYSCONFIG"].replace(" ", "").split(",")
455457
for diracSysConfigFile in reversed(diracSysConfigFiles):
456458
gLogger.debug(f"Loading file from DIRACSYSCONFIG {diracSysConfigFile}")
457459
gConfigurationData.loadFile(diracSysConfigFile)
460+
461+
# 2. ~/.dirac.cfg
458462
gConfigurationData.loadFile(os.path.expanduser("~/.dirac.cfg"))
463+
464+
# 3. cfg files specified in addCFGFile calls
459465
for fileName in self.additionalCFGFiles:
460466
gLogger.debug(f"Loading file {fileName}")
461467
retVal = gConfigurationData.loadFile(fileName)
462468
if not retVal["OK"]:
463469
gLogger.debug(f"Could not load file {fileName}: {retVal['Message']}")
464470
errorsList.append(retVal["Message"])
471+
472+
# 4. cfg files that come from the command line
465473
for fileName in self.cliAdditionalCFGFiles:
466474
gLogger.debug(f"Loading file {fileName}")
467475
retVal = gConfigurationData.loadFile(fileName)
468476
if not retVal["OK"]:
469477
gLogger.debug(f"Could not load file {fileName}: {retVal['Message']}")
470478
errorsList.append(retVal["Message"])
479+
471480
return errorsList
472481

473482
def __addUserDataToConfiguration(self):

src/DIRAC/ConfigurationSystem/private/ConfigurationData.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
import _thread
88
import time
99
import datetime
10-
import DIRAC
1110

1211
from diraccfg import CFG
12+
13+
import DIRAC
1314
from DIRAC.Core.Utilities.File import mkDir
1415
from DIRAC.Core.Utilities import List
1516
from DIRAC.Core.Utilities.ReturnValues import S_OK, S_ERROR
@@ -251,15 +252,13 @@ def getAutoPublish(self):
251252
value = self.extractOptionFromCFG(f"{self.configurationPath}/AutoPublish", self.localCFG)
252253
if value and value.lower() in ("no", "false", "n"):
253254
return False
254-
else:
255-
return True
255+
return True
256256

257257
def getAutoSlaveSync(self):
258258
value = self.extractOptionFromCFG(f"{self.configurationPath}/AutoSlaveSync", self.localCFG)
259259
if value and value.lower() in ("no", "false", "n"):
260260
return False
261-
else:
262-
return True
261+
return True
263262

264263
def getServers(self):
265264
return list(self.remoteServerList)
@@ -290,8 +289,7 @@ def isMaster(self):
290289
value = self.extractOptionFromCFG(f"{self.configurationPath}/Master", self.localCFG)
291290
if value and value.lower() in ("yes", "true", "y"):
292291
return True
293-
else:
294-
return False
292+
return False
295293

296294
def getServicesPath(self):
297295
return "/Services"

0 commit comments

Comments
 (0)