Ejemplo n.º 1
0
def get_expand_nonrt( fpath, template_vars, template_vars_file,
        do_expand=False, verbose=False, is_reload=False,
        write_processed_file=True):
    global cfg
    if is_reload or not cfg:
        cfg = parse( fpath, verbose,
                write_processed_file=write_processed_file,
                template_vars=template_vars,
                template_vars_file=template_vars_file )

        u = upgrader( cfg, SPEC, 'suite definition', verbose )
        u.deprecate( '5.2.0', ['cylc','event handler execution'], ['cylc','event handler submission'] )
        u.upgrade()

        validate( cfg, SPEC )

        # load defaults for everything except [runtime]
        # (keep runtime sparse for efficient inheritance)
        for key,val in SPEC.items():
            if isinstance(val,dict):
                if key != 'runtime':
                    # all main sections except for runtime
                    if key not in cfg:
                        cfg[key] = {} # TODO - ordered dict?
                    cfg[key] = expand( cfg[key], SPEC[key] )
            else:
                # top level (no section) items
                if key not in cfg:
                    cfg[key] = val.args['default']

    return cfg
Ejemplo n.º 2
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)"
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
def get_expand_nonrt(fpath,
                     template_vars,
                     template_vars_file,
                     do_expand=False,
                     verbose=False,
                     is_reload=False,
                     write_processed_file=True):
    global cfg
    if is_reload or not cfg:
        cfg = parse(fpath,
                    verbose,
                    write_processed_file=write_processed_file,
                    template_vars=template_vars,
                    template_vars_file=template_vars_file)

        u = upgrader(cfg, SPEC, 'suite definition', verbose)
        u.deprecate('5.2.0', ['cylc', 'event handler execution'],
                    ['cylc', 'event handler submission'])
        u.upgrade()

        validate(cfg, SPEC)

        # load defaults for everything except [runtime]
        # (keep runtime sparse for efficient inheritance)
        for key, val in SPEC.items():
            if isinstance(val, dict):
                if key != 'runtime':
                    # all main sections except for runtime
                    if key not in cfg:
                        cfg[key] = {}  # TODO - ordered dict?
                    cfg[key] = expand(cfg[key], SPEC[key])
            else:
                # top level (no section) items
                if key not in cfg:
                    cfg[key] = val.args['default']

    return cfg