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))
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)
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))
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))
def print_cfg(): printcfg(get_cfg())
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")
'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',
'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'])
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: