def loadcfg(self, rcfile, title=""): """Parse a config file, upgrade or deprecate items if necessary, validate it against the spec, and if this is not the first load, combine/override with the existing loaded config.""" sparse = parse(rcfile, self.output_fname, self.tvars) if self.upgrader is not None: self.upgrader(sparse, title) self.validate(sparse) if not self.sparse: self.sparse = sparse else: # Already loaded, override with new items. replicate(self.sparse, sparse)
try: self.validate( sparse ) except Exception, x: if strict: raise if cylc.flags.verbose: print >> sys.stderr, x print >> sys.stderr, "WARNING: " + title + " validation failed" else: if not self.sparse: self.sparse = sparse else: # already loaded, this must be an override replicate( self.sparse, sparse ) def validate( self, sparse ): "Validate sparse config against the file spec." validate( sparse, self.spec ) check_compulsory( sparse, self.spec ) def expand( self ): "Flesh out undefined items with defaults, if any, from the spec." if not self.dense: self.dense = expand( self.sparse, self.spec ) def get( self, keys=[], sparse=False ): """ Retrieve items or sections, sparse or dense, by list of keys: [sec1,sec2,item] =>