예제 #1
0
    def dump(self, keys=None, sparse=False, pnative=False, prefix='',
             none_str=''):
        """Override parse.config.dump().

        To restore the list-nature of theme state items.
        """
        cfg = deepcopy(self.get([], sparse))
        try:
            for theme in cfg['themes'].values():
                for state in theme:
                    clist = []
                    for attr, val in theme[state].items():
                        clist.append('%s=%s' % (attr, val))
                    theme[state] = clist
        except (KeyError, AttributeError):
            pass

        parents = []
        for key in keys:
            try:
                cfg = cfg[key]
            except KeyError:
                raise ItemNotFoundError(itemstr(parents, key))
            else:
                parents.append(key)

        if pnative:
            print(cfg)
        else:
            printcfg(cfg, prefix=prefix, level=len(keys))
예제 #2
0
파일: config.py 프로젝트: zhengge2017/cylc
 def dump(self, keys=[], sparse=False, pnative=False, prefix='',
          none_str=''):
     cfg = self.get(keys, sparse)
     if pnative:
         print cfg
     else:
         printcfg(cfg, prefix=prefix, level=len(keys), none_str=none_str)
예제 #3
0
파일: gcylc.py 프로젝트: zhengge2017/cylc
    def dump(self, keys=[], sparse=False, pnative=False, prefix='',
             none_str=''):
        # override parse.config.dump() to restore the list-nature of
        # theme state items
        cfg = deepcopy(self.get([], sparse))
        try:
            for theme in cfg['themes'].values():
                for state in theme.keys():
                    clist = []
                    for attr, val in theme[state].items():
                        clist.append(attr + '=' + val)
                    theme[state] = clist
        except:
            pass

        parents = []
        for key in keys:
            try:
                cfg = cfg[key]
            except KeyError:
                raise ItemNotFoundError(itemstr(parents, key))
            else:
                parents.append(key)

        if pnative:
            print cfg
        else:
            printcfg(cfg, prefix=prefix, level=len(keys))
예제 #4
0
파일: gcylc.py 프로젝트: arjclark/cylc
    def dump(self, keys, sparse=False, pnative=False, prefix='',
             none_str=''):
        """Override parse.config.dump().

        To restore the list-nature of theme state items.
        """
        cfg = deepcopy(self.get([], sparse))
        try:
            for theme in cfg['themes'].values():
                for state in theme:
                    clist = []
                    for attr, val in theme[state].items():
                        clist.append('%s=%s' % (attr, val))
                    theme[state] = clist
        except (KeyError, AttributeError):
            pass

        parents = []
        for key in keys:
            try:
                cfg = cfg[key]
            except KeyError:
                raise ItemNotFoundError(itemstr(parents, key))
            else:
                parents.append(key)

        if pnative:
            print cfg
        else:
            printcfg(cfg, prefix=prefix, level=len(keys))
예제 #5
0
 def dump(self, keys=[], sparse=False, pnative=False, prefix='',
          none_str=''):
     cfg = self.get(keys, sparse)
     if pnative:
         print cfg
     else:
         printcfg(cfg, prefix=prefix, level=len(keys), none_str=none_str)
예제 #6
0
def print_cfg():
    printcfg(get_cfg())
예제 #7
0
파일: gcylc.py 프로젝트: clarkrowley/cylc
        except:
            pass

        parents = []
        for key in keys:
            try:
                cfg = cfg[key]
            except KeyError, x:
                raise ItemNotFoundError(itemstr(parents, key))
            else:
                parents.append(key)

        if pnative:
            print cfg
        else:
            printcfg(cfg, prefix=prefix, level=len(keys))


# load on import if not already loaded
gcfg = None
if not gcfg:
    gcfg = gconfig(SPEC, upg)
    try:
        gcfg.loadcfg(SITE_FILE, "site config")
    except ParsecError as exc:
        sys.stderr.write("WARNING: ignoring bad site GUI config %s:\n"
                         "%s\n" % (SITE_FILE, str(exc)))

    if os.access(USER_FILE, os.F_OK | os.R_OK):
        try:
            gcfg.loadcfg(USER_FILE, "user config")
예제 #8
0
파일: upgrade.py 프로젝트: dpmatthews/cylc
            'cde': 'foo',
        },
        'hostnames': {
            'host 1': {
                'work dir': '/a/b/c',
                'running dir': '/a/b/c/d'
            },
            'host 2': {
                'work dir': '/x/b/c',
                'running dir': '/x/b/c/d'
            },
        }
    }
    x2 = converter(lambda x: 2 * x, 'value x 2')

    printcfg(cfg)
    sys.stdout.write('\n')

    upg = upgrader(cfg, 'test file')
    # successive upgrades are incremental - at least until I think of a
    # good way to remember what items have already been translated...
    upg.deprecate('1.3', ['item one'], ['item ONE'], x2)
    upg.deprecate('1.3', ['section A'], ['Heading A'])
    # NOTE change to new item keys here!
    upg.deprecate('1.3', ['Heading A', 'cde'], ['Heading A', 'CDE'])
    upg.deprecate('1.4', ['Heading A', 'abc'], cvtr=x2, silent=True)
    upg.deprecate(
        '1.4.1', ['item two'], ['Heading A', 'item two'], silent=True)
    upg.deprecate('1.5', ['hostnames'], ['hosts'])
    upg.deprecate(
        '1.5',
예제 #9
0
            'cde': 'foo',
        },
        'hostnames': {
            'host 1': {
                'work dir': '/a/b/c',
                'running dir': '/a/b/c/d'
            },
            'host 2': {
                'work dir': '/x/b/c',
                'running dir': '/x/b/c/d'
            },
        }
    }
    x2 = converter(lambda x: 2 * x, 'value x 2')

    printcfg(cfg)
    sys.stdout.write('\n')

    upg = upgrader(cfg, 'test file')
    # successive upgrades are incremental - at least until I think of a
    # good way to remember what items have already been translated...
    upg.deprecate('1.3', ['item one'], ['item ONE'], x2)
    upg.deprecate('1.3', ['section A'], ['Heading A'])
    # NOTE change to new item keys here!
    upg.deprecate('1.3', ['Heading A', 'cde'], ['Heading A', 'CDE'])
    upg.deprecate('1.4', ['Heading A', 'abc'], cvtr=x2, silent=True)
    upg.deprecate('1.4.1', ['item two'], ['Heading A', 'item two'],
                  silent=True)
    upg.deprecate('1.5', ['hostnames'], ['hosts'])
    upg.deprecate('1.5', ['hosts', '__MANY__', 'running dir'],
                  ['hosts', '__MANY__', 'run dir'])
예제 #10
0
파일: gcylc.py 프로젝트: kaday/cylc
        except:
            pass

        parents = []
        for key in keys:
            try:
                cfg = cfg[key]
            except KeyError, x:
                raise ItemNotFoundError(itemstr(parents, key))
            else:
                parents.append(key)

        if pnative:
            print cfg
        else:
            printcfg(cfg, prefix=prefix, level=len(keys))


# load on import if not already loaded
gcfg = None
if not gcfg:
    gcfg = gconfig(SPEC, upg)
    try:
        gcfg.loadcfg(SITE_FILE, "site config")
    except ParsecError as exc:
        sys.stderr.write("WARNING: ignoring bad site GUI config %s:\n" "%s\n" % (SITE_FILE, str(exc)))

    if os.access(USER_FILE, os.F_OK | os.R_OK):
        try:
            gcfg.loadcfg(USER_FILE, "user config")
        except ParsecError as exc:
예제 #11
0
def print_cfg():
    printcfg(get_cfg())