Show More
@@ -1,50 +1,57 b'' | |||
|
1 | 1 | # configitems.py - centralized declaration of configuration option |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | import functools | |
|
11 | ||
|
10 | 12 | from . import ( |
|
11 | 13 | error, |
|
12 | 14 | ) |
|
13 | 15 | |
|
14 | 16 | class configitem(object): |
|
15 | 17 | """represent a known config item |
|
16 | 18 | |
|
17 | 19 | :section: the official config section where to find this item, |
|
18 | 20 | :name: the official name within the section, |
|
19 | 21 | :default: default value for this item, |
|
20 | 22 | """ |
|
21 | 23 | |
|
22 | 24 | def __init__(self, section, name, default=None): |
|
23 | 25 | self.section = section |
|
24 | 26 | self.name = name |
|
25 | 27 | self.default = default |
|
26 | 28 | |
|
27 | 29 | coreitems = {} |
|
28 | 30 | |
|
29 |
def |
|
|
31 | def _register(configtable, *args, **kwargs): | |
|
30 | 32 | item = configitem(*args, **kwargs) |
|
31 |
section = co |
|
|
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)) |
|
35 | 37 | section[item.name] = item |
|
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 | ) |
|
42 | 49 | coreconfigitem('ui', 'clonebundleprefers', |
|
43 | 50 | default=[], |
|
44 | 51 | ) |
|
45 | 52 | coreconfigitem('ui', 'interactive', |
|
46 | 53 | default=None, |
|
47 | 54 | ) |
|
48 | 55 | coreconfigitem('ui', 'quiet', |
|
49 | 56 | default=False, |
|
50 | 57 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now