1 |
commit: 2a921c0056de70e4a05169cc7d599b809ede3dd6 |
2 |
Author: André Erdmann <dywi <AT> mailerd <DOT> de> |
3 |
AuthorDate: Tue Aug 27 15:29:26 2013 +0000 |
4 |
Commit: André Erdmann <dywi <AT> mailerd <DOT> de> |
5 |
CommitDate: Tue Aug 27 15:29:26 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=2a921c00 |
7 |
|
8 |
roverlay/status.py: some comments |
9 |
|
10 |
--- |
11 |
roverlay/status.py | 46 ++++++++++++++++++++++++++++++++++++++++++---- |
12 |
1 file changed, 42 insertions(+), 4 deletions(-) |
13 |
|
14 |
diff --git a/roverlay/status.py b/roverlay/status.py |
15 |
index 59c8cb6..595e8fb 100644 |
16 |
--- a/roverlay/status.py |
17 |
+++ b/roverlay/status.py |
18 |
@@ -5,7 +5,6 @@ |
19 |
# either version 2 of the License, or (at your option) any later version. |
20 |
|
21 |
# --- TODO/FIXME --- |
22 |
-# * what happens if the database has UNKNOWNS? |
23 |
# * RRA creation doesn't seem to be correct |
24 |
# |
25 |
|
26 |
@@ -46,6 +45,28 @@ class DBStats ( roverlay.stats.rating.RoverlayNumStatsRating ): |
27 |
# --- end of __init__ (...) --- |
28 |
|
29 |
def make_suggestions ( self, pure_text=False ): |
30 |
+ """Creates a list of 2-tuples ( <topic>, list<details> ) with |
31 |
+ suggestions and stores it as self.suggestions. |
32 |
+ |
33 |
+ List example: |
34 |
+ [ |
35 |
+ ( |
36 |
+ "normal/expected failure rate", |
37 |
+ [ |
38 |
+ "write dependency rules", |
39 |
+ "configure package ignore rules", |
40 |
+ ] |
41 |
+ ), |
42 |
+ ( |
43 |
+ ... |
44 |
+ ), |
45 |
+ ] |
46 |
+ |
47 |
+ arguments: |
48 |
+ * pure_text -- disable html tags |
49 |
+ |
50 |
+ Returns: True if any suggestions available, else False. |
51 |
+ """ |
52 |
self.suggestions = list ( self.get_suggestions ( pure_text=pure_text ) ) |
53 |
return bool ( self.suggestions ) |
54 |
# --- end of __init__ (...) --- |
55 |
@@ -53,9 +74,8 @@ class DBStats ( roverlay.stats.rating.RoverlayNumStatsRating ): |
56 |
# --- end of DBStats --- |
57 |
|
58 |
|
59 |
- |
60 |
- |
61 |
class ReferenceableDict ( dict ): |
62 |
+ |
63 |
def ref ( self ): |
64 |
return weakref.ref ( self ) |
65 |
# --- end of ref (...) --- |
66 |
@@ -178,6 +198,9 @@ class StatusRuntimeEnvironment ( roverlay.runtime.RuntimeEnvironmentBase ): |
67 |
|
68 |
|
69 |
def do_setup_mako ( self ): |
70 |
+ |
71 |
+ |
72 |
+ # set up template_dirs / default_template |
73 |
template_dirs = [] |
74 |
self.default_template = 'status' |
75 |
|
76 |
@@ -211,7 +234,7 @@ class StatusRuntimeEnvironment ( roverlay.runtime.RuntimeEnvironmentBase ): |
77 |
raise Exception ( "no template directories found!" ) |
78 |
|
79 |
|
80 |
- |
81 |
+ # get module root (for caching) |
82 |
if 'module_root' in self.options: |
83 |
module_dir = self.options ['module_root'] |
84 |
else: |
85 |
@@ -230,6 +253,7 @@ class StatusRuntimeEnvironment ( roverlay.runtime.RuntimeEnvironmentBase ): |
86 |
# 'python_' + hex ( sys.hexversion>>16 ) |
87 |
|
88 |
|
89 |
+ # create lookup object |
90 |
self._mako_lookup = mako.lookup.TemplateLookup ( |
91 |
directories=template_dirs, module_directory=module_dir, |
92 |
output_encoding=self.TEMPLATE_ENCODING, |
93 |
@@ -316,6 +340,20 @@ class StatusRuntimeEnvironment ( roverlay.runtime.RuntimeEnvironmentBase ): |
94 |
file_extensions=[ '', ], |
95 |
add_mode_ext=True |
96 |
): |
97 |
+ """Tries to find a template. |
98 |
+ |
99 |
+ arguments: |
100 |
+ * template_name -- name of the template |
101 |
+ * file_extensions -- an iterable containing possible file extensions, |
102 |
+ in order |
103 |
+ * add_mode_ext -- whether to try script_mode-specific file extension |
104 |
+ first (Defaults to True). |
105 |
+ |
106 |
+ Returns: a Template object |
107 |
+ |
108 |
+ Raises: |
109 |
+ * Passes mako.exceptions.TopLevelLookupException if template not found |
110 |
+ """ |
111 |
my_template = None |
112 |
|
113 |
if add_mode_ext: |