Mercurial > hg-stable
view mercurial/configitems.py @ 33004:2529e2ae9f4c
configitems: register 'ui.quiet' as first example
We now have a user and this works fine.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 17 Jun 2017 12:33:59 +0200 |
parents | 6d983e8af49c |
children | 1d5d7e2b7ab5 |
line wrap: on
line source
# configitems.py - centralized declaration of configuration option # # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net> # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. from __future__ import absolute_import from . import ( error, ) class configitem(object): """represent a known config item :section: the official config section where to find this item, :name: the official name within the section, :default: default value for this item, """ def __init__(self, section, name, default=None): self.section = section self.name = name self.default = default coreitems = {} def coreconfigitem(*args, **kwargs): item = configitem(*args, **kwargs) section = coreitems.setdefault(item.section, {}) if item.name in section: msg = "duplicated config item registration for '%s.%s'" raise error.ProgrammingError(msg % (item.section, item.name)) section[item.name] = item # Registering actual config items coreconfigitem('ui', 'quiet', default=False, )