@@ -87,33 +87,36 @@ def __init__(self, options, filename=None):
8787
8888 self .parsed = self .read (files )
8989
90- # for proper $CFGDIR selection, take last parsed configfile only
91- cfg_dirname = os .path .dirname (files [- 1 ])
90+ if self .parsed :
91+ # for proper $CFGDIR selection, take last parsed configfile only
92+ cfg_dirname = os .path .dirname (self .parsed [- 1 ])
9293
93- # parse Main.confdir
94- try :
95- # keep track of loaded confdirs
96- loaded_confdirs = set ()
97-
98- confdirstr = self .get (self .MAIN_SECTION , "confdir" )
99- for confdir in shlex .split (confdirstr ):
100- # substitute $CFGDIR, set to the highest priority clustershell
101- # configuration directory that has been found
102- confdir = Template (confdir ).safe_substitute (CFGDIR = cfg_dirname )
103- confdir = os .path .normpath (confdir )
104- if confdir in loaded_confdirs :
105- continue # load each confdir only once
106- loaded_confdirs .add (confdir )
107- if not os .path .isdir (confdir ):
108- if not os .path .exists (confdir ):
109- continue
110- msg = "Defined confdir %s is not a directory" % confdir
111- raise ClushConfigError (msg = msg )
112- # add config declared in clush.conf.d file parts
113- for cfgfn in sorted (glob .glob ('%s/*.conf' % confdir )):
114- self .parsed += self .read (cfgfn ) # ignore files that cannot be read
115- except (NoSectionError , NoOptionError ):
116- pass
94+ # parse Main.confdir
95+ try :
96+ # keep track of loaded confdirs
97+ loaded_confdirs = set ()
98+
99+ confdirstr = self .get (self .MAIN_SECTION , "confdir" )
100+ for confdir in shlex .split (confdirstr ):
101+ # substitute $CFGDIR, set to the highest priority
102+ # configuration directory that has been found
103+ confdir = Template (confdir ).safe_substitute (
104+ CFGDIR = cfg_dirname )
105+ confdir = os .path .normpath (confdir )
106+ if confdir in loaded_confdirs :
107+ continue # load each confdir only once
108+ loaded_confdirs .add (confdir )
109+ if not os .path .isdir (confdir ):
110+ if not os .path .exists (confdir ):
111+ continue
112+ msg = "Defined confdir %s is not a directory" % confdir
113+ raise ClushConfigError (msg = msg )
114+ # add config declared in clush.conf.d file parts
115+ for cfgfn in sorted (glob .glob ('%s/*.conf' % confdir )):
116+ # ignore files that cannot be read
117+ self .parsed += self .read (cfgfn )
118+ except (NoSectionError , NoOptionError ):
119+ pass
117120
118121 # Apply command line overrides
119122 if options .quiet :
0 commit comments