示例#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
文件: gcylc.py 项目: clarkrowley/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, x:
                raise ItemNotFoundError(itemstr(parents, key))
            else:
                parents.append(key)
示例#3
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))
示例#4
0
文件: gcylc.py 项目: kaday/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, x:
                raise ItemNotFoundError(itemstr(parents, key))
            else:
                parents.append(key)