##// END OF EJS Templates
configitems: extract the logic to build a registrar on any configtable...
marmoute -
r33126:c2ca511c default
parent child Browse files
Show More
@@ -7,6 +7,8 b''
7 7
8 8 from __future__ import absolute_import
9 9
10 import functools
11
10 12 from . import (
11 13 error,
12 14 )
@@ -26,9 +28,9 b' class configitem(object):'
26 28
27 29 coreitems = {}
28 30
29 def coreconfigitem(*args, **kwargs):
31 def _register(configtable, *args, **kwargs):
30 32 item = configitem(*args, **kwargs)
31 section = coreitems.setdefault(item.section, {})
33 section = configtable.setdefault(item.section, {})
32 34 if item.name in section:
33 35 msg = "duplicated config item registration for '%s.%s'"
34 36 raise error.ProgrammingError(msg % (item.section, item.name))
@@ -36,6 +38,11 b' def coreconfigitem(*args, **kwargs):'
36 38
37 39 # Registering actual config items
38 40
41 def getitemregister(configtable):
42 return functools.partial(_register, configtable)
43
44 coreconfigitem = getitemregister(coreitems)
45
39 46 coreconfigitem('patch', 'fuzz',
40 47 default=2,
41 48 )
General Comments 0
You need to be logged in to leave comments. Login now