Example #1
0
def get_cfg( cfile=TEST_FILE, verbose=False, template_vars=[], template_vars_file=None ):
    global cfg
    if not cfg:
        cfg = parse( cfile, verbose=verbose,
                template_vars=template_vars,
                template_vars_file=template_vars_file )
        validate( cfg, SPEC )
        cfg = expand( cfg, SPEC )
    return cfg
Example #2
0
def get_cfg(cfile=TEST_FILE,
            verbose=False,
            template_vars=[],
            template_vars_file=None):
    global cfg
    if not cfg:
        cfg = parse(cfile,
                    verbose=verbose,
                    template_vars=template_vars,
                    template_vars_file=template_vars_file)
        validate(cfg, SPEC)
        cfg = expand(cfg, SPEC)
    return cfg
Example #3
0
def load_single( FILE, SPEC, descr, upgrader=None, do_expand=False, verbose=True, strict=False ):
    """
    Parse, upgrade, validate, combine, and expand a single parsec config file.
    If FILE fails to parse or validate just fall back on spec defaults.
    """
    cfg = OrderedDict()
    try:
        cfg = parse( FILE )
    except FileNotFoundError, x:
        if strict:
            raise
        # not an error - may be relying on defaults
        pass
Example #4
0
 def loadcfg( self, rcfile, title="", strict=False, silent=False ):
     """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."""
     try:
         sparse = parse( rcfile, write_proc=self.write_proc,
             template_vars=self.tvars, template_vars_file=self.tvars_file )
     except Exception, x:
         if strict:
             raise
         if not silent or cylc.flags.verbose:
             # no user.rc file, for instance, is not really an error.
             print >> sys.stderr, x
             print >> sys.stderr, "WARNING: " + title + " parsing failed (continuing)"
Example #5
0
 def loadcfg(self, rcfile, title="", strict=False, silent=False):
     """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."""
     try:
         sparse = parse(rcfile,
                        write_proc=self.write_proc,
                        template_vars=self.tvars,
                        template_vars_file=self.tvars_file)
     except Exception, x:
         if strict:
             raise
         if not silent or cylc.flags.verbose:
             # no global.rc file, for instance, is not really an error.
             print >> sys.stderr, x
             print >> sys.stderr, "WARNING: " + title + " parsing failed (continuing)"
Example #6
0
def load_single(FILE,
                SPEC,
                descr,
                upgrader=None,
                do_expand=False,
                verbose=True,
                strict=False):
    """
    Parse, upgrade, validate, combine, and expand a single parsec config file.
    If FILE fails to parse or validate just fall back on spec defaults.
    """
    cfg = OrderedDict()
    try:
        cfg = parse(FILE)
    except FileNotFoundError, x:
        if strict:
            raise
        # not an error - may be relying on defaults
        pass