1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# Copyright 2011 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""View and edit feature rules."""
__metaclass__ = type
__all__ = [
'FeatureInfoView',
]
from collections import namedtuple
from canonical.launchpad.webapp.publisher import LaunchpadView
from lp.services.features.flags import (
flag_info,
undocumented_flags,
value_domain_info,
)
from lp.services.features.scopes import (
HANDLERS,
undocumented_scopes,
)
from lp.services.utils import docstring_dedent
# Named tuples to use when passing flag and scope data to the template.
Flag = namedtuple('Flag', ('name', 'domain', 'description', 'default'))
ValueDomain = namedtuple('ValueDomain', ('name', 'description'))
Scope = namedtuple('Scope', ('regex', 'description'))
class FeatureInfoView(LaunchpadView):
"""Display feature flag documentation and other info."""
page_title = label = 'Feature flag info'
@property
def flag_info(self):
"""A list of flags as named tuples, ready to be rendered."""
return map(Flag._make, flag_info)
@property
def undocumented_flags(self):
"""Flag names referenced during process lifetime but not documented.
"""
return ', '.join(undocumented_flags)
@property
def value_domain_info(self):
"""A list of flags as named tuples, ready to be rendered."""
return map(ValueDomain._make, value_domain_info)
@property
def undocumented_scopes(self):
"""Scope names referenced during process lifetime but not documented.
"""
return ', '.join(undocumented_scopes)
@property
def scope_info(self):
"""A list of scopes as named tuples, ready to be rendered."""
return [
Scope._make((handler.pattern, docstring_dedent(handler.__doc__)))
for handler in HANDLERS]
|