1 |
commit: 9e70333ad297407c69d7369134a75b5af6bada7b |
2 |
Author: Sven Vermeulen <sven.vermeulen <AT> siphos <DOT> be> |
3 |
AuthorDate: Tue May 1 12:24:52 2012 +0000 |
4 |
Commit: Sven Vermeulen <sven.vermeulen <AT> siphos <DOT> be> |
5 |
CommitDate: Tue May 1 12:24:52 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-refpolicy.git;a=commit;h=9e70333a |
7 |
|
8 |
Who uses html pages to embed python code in... oh right, we do |
9 |
|
10 |
--- |
11 |
doc/templates/bool_list.html | 2 +- |
12 |
doc/templates/interface.html | 4 +- |
13 |
doc/templates/template.html | 4 +- |
14 |
doc/templates/tun_list.html | 2 +- |
15 |
policy/flask/flask.py | 4 +- |
16 |
support/genhomedircon | 8 +++--- |
17 |
support/pyplate.py | 4 +- |
18 |
support/sedoctool.py | 61 +++++++++++++++++++++-------------------- |
19 |
8 files changed, 45 insertions(+), 44 deletions(-) |
20 |
|
21 |
diff --git a/doc/templates/bool_list.html b/doc/templates/bool_list.html |
22 |
index 2d852da..3a2f526 100644 |
23 |
--- a/doc/templates/bool_list.html |
24 |
+++ b/doc/templates/bool_list.html |
25 |
@@ -2,7 +2,7 @@ |
26 |
|
27 |
[[for bool in booleans]] |
28 |
<div id="interfacesmall"> |
29 |
-[[if bool.has_key('mod_layer')]] |
30 |
+[[if 'mod_layer' in bool]] |
31 |
Module: <a href='[[bool['mod_layer']+ "_" + bool['mod_name'] + ".html#link_" + bool['bool_name']]]'> |
32 |
[[bool['mod_name']]]</a><p/> |
33 |
Layer: <a href='[[bool['mod_layer']]].html'> |
34 |
|
35 |
diff --git a/doc/templates/interface.html b/doc/templates/interface.html |
36 |
index 90eb436..0409361 100644 |
37 |
--- a/doc/templates/interface.html |
38 |
+++ b/doc/templates/interface.html |
39 |
@@ -1,10 +1,10 @@ |
40 |
[[for int in interfaces]] |
41 |
<a name="link_[[int['interface_name']]]"></a> |
42 |
<div id="interface"> |
43 |
-[[if int.has_key("mod_layer")]] |
44 |
+[[if "mod_layer" in int]] |
45 |
Layer: [[mod_layer]]<br> |
46 |
[[end]] |
47 |
-[[if int.has_key("mod_name")]] |
48 |
+[[if "mod_name" in int]] |
49 |
Module: [[mod_name]]<br> |
50 |
[[end]] |
51 |
<div id="codeblock"> |
52 |
|
53 |
diff --git a/doc/templates/template.html b/doc/templates/template.html |
54 |
index 251d227..03dd1d5 100644 |
55 |
--- a/doc/templates/template.html |
56 |
+++ b/doc/templates/template.html |
57 |
@@ -1,10 +1,10 @@ |
58 |
[[for temp in templates]] |
59 |
<a name="link_[[temp['template_name']]]"></a> |
60 |
<div id="template"> |
61 |
-[[if temp.has_key("mod_layer")]] |
62 |
+[[if "mod_layer" in temp]] |
63 |
Layer: [[mod_layer]]<br> |
64 |
[[end]] |
65 |
-[[if temp.has_key("mod_name")]] |
66 |
+[[if "mod_name" in temp]] |
67 |
Module: [[mod_name]]<br> |
68 |
[[end]] |
69 |
<div id="codeblock"> |
70 |
|
71 |
diff --git a/doc/templates/tun_list.html b/doc/templates/tun_list.html |
72 |
index 278f284..4daf8b4 100644 |
73 |
--- a/doc/templates/tun_list.html |
74 |
+++ b/doc/templates/tun_list.html |
75 |
@@ -2,7 +2,7 @@ |
76 |
|
77 |
[[for tun in tunables]] |
78 |
<div id="interfacesmall"> |
79 |
-[[if tun.has_key('mod_layer')]] |
80 |
+[[if 'mod_layer' in tun]] |
81 |
Module: <a href='[[tun['mod_layer']+ "_" + tun['mod_name'] + ".html#link_" + tun['tun_name']]]'> |
82 |
[[tun['mod_name']]]</a><p/> |
83 |
Layer: <a href='[[tun['mod_layer']]].html'> |
84 |
|
85 |
diff --git a/policy/flask/flask.py b/policy/flask/flask.py |
86 |
index 8b4be50..ca566d8 100644 |
87 |
--- a/policy/flask/flask.py |
88 |
+++ b/policy/flask/flask.py |
89 |
@@ -313,7 +313,7 @@ class Flask: |
90 |
results = [] |
91 |
results.append(self.autogen) |
92 |
for c in self.vectors: |
93 |
- if self.inherits.has_key(c): |
94 |
+ if c in self.inherits: |
95 |
i = self.inherits[c] |
96 |
count = len(self.common[i]) |
97 |
if not (mode == self.KERNEL and self.userspace[c]): |
98 |
@@ -355,7 +355,7 @@ class Flask: |
99 |
count = 0 |
100 |
|
101 |
ps = [] |
102 |
- if self.inherits.has_key(c): |
103 |
+ if c in self.inherits: |
104 |
ps += self.common[self.inherits[c]] |
105 |
ps += self.vector[c] |
106 |
for p in ps: |
107 |
|
108 |
diff --git a/support/genhomedircon b/support/genhomedircon |
109 |
index 01ef91d..33dbcc1 100644 |
110 |
--- a/support/genhomedircon |
111 |
+++ b/support/genhomedircon |
112 |
@@ -82,7 +82,7 @@ def getPrefixes(): |
113 |
u[5] != "/" and \ |
114 |
string.count(u[5], "/") > 1: |
115 |
prefix = u[5][:string.rfind(u[5], "/")] |
116 |
- if not prefixes.has_key(prefix): |
117 |
+ if not prefix in prefixes: |
118 |
prefixes[prefix] = "" |
119 |
return prefixes |
120 |
|
121 |
@@ -133,7 +133,7 @@ def oldgenhomedircon(filecontextdir, filecontext): |
122 |
homedir = rc[1].split("=")[1] |
123 |
homedir = homedir.split("#")[0] |
124 |
homedir = homedir.strip() |
125 |
- if not prefixes.has_key(homedir): |
126 |
+ if not homedir in prefixes: |
127 |
prefixes[homedir] = "" |
128 |
else: |
129 |
#rc[0] == 256 means the file was there, we read it, but the grep didn't match |
130 |
@@ -149,7 +149,7 @@ def oldgenhomedircon(filecontextdir, filecontext): |
131 |
homedir = homedir.split("#")[0] |
132 |
homedir = homedir.strip() |
133 |
homedir = re.sub(r"[^/a-zA-Z0-9].*$", "", homedir) |
134 |
- if not prefixes.has_key(homedir): |
135 |
+ if not homedir in prefixes: |
136 |
prefixes[homedir] = "" |
137 |
|
138 |
#the idea is that we need to find all of the home_root_t directories we do this by just accepting |
139 |
@@ -187,7 +187,7 @@ def oldgenhomedircon(filecontextdir, filecontext): |
140 |
if re.search(regex, potential, 0): |
141 |
addme = 0 |
142 |
if addme == 1: |
143 |
- if not prefixes.has_key(potential): |
144 |
+ if not potential in prefixes: |
145 |
prefixes[potential] = "" |
146 |
|
147 |
|
148 |
|
149 |
diff --git a/support/pyplate.py b/support/pyplate.py |
150 |
index 22385e9..c13cd88 100644 |
151 |
--- a/support/pyplate.py |
152 |
+++ b/support/pyplate.py |
153 |
@@ -185,7 +185,7 @@ class ForTemplateNode(TemplateNode): |
154 |
def execute(self, stream, data): |
155 |
remember_vars = {} |
156 |
for var in self.vars: |
157 |
- if data.has_key(var): |
158 |
+ if var in data: |
159 |
remember_vars[var] = data[var] |
160 |
for list in eval(self.expression, globals(), data): |
161 |
if is_sequence(list): |
162 |
@@ -264,7 +264,7 @@ class FunctionTemplateNode(TemplateNode): |
163 |
def call(self, args, stream, data): |
164 |
remember_vars = {} |
165 |
for index, var in enumerate(self.vars): |
166 |
- if data.has_key(var): |
167 |
+ if var in data: |
168 |
remember_vars[var] = data[var] |
169 |
data[var] = args[index] |
170 |
TemplateNode.execute(self, stream, data) |
171 |
|
172 |
diff --git a/support/sedoctool.py b/support/sedoctool.py |
173 |
index a363e72..afcdee4 100644 |
174 |
--- a/support/sedoctool.py |
175 |
+++ b/support/sedoctool.py |
176 |
@@ -209,39 +209,40 @@ def get_conf(conf): |
177 |
|
178 |
return namevalue_list |
179 |
|
180 |
-def first_cmp(a, b): |
181 |
+def first_cmp_func(a): |
182 |
""" |
183 |
- Compares the two first elements of a list instead of the entire list. |
184 |
+ Return the first element to sort/compare on. |
185 |
""" |
186 |
|
187 |
- return cmp(a[0], b[0]) |
188 |
+ return a[0] |
189 |
|
190 |
-def int_cmp(a, b): |
191 |
+def int_cmp_func(a): |
192 |
""" |
193 |
- Compares two interfaces. |
194 |
+ Return the interface name to sort/compare on. |
195 |
""" |
196 |
|
197 |
- return cmp(a["interface_name"], b["interface_name"]) |
198 |
+ return a["interface_name"] |
199 |
|
200 |
-def temp_cmp(a, b): |
201 |
+def temp_cmp_func(a): |
202 |
""" |
203 |
- Compares two templates. |
204 |
+ Return the template name to sort/compare on. |
205 |
""" |
206 |
|
207 |
- return cmp(a["template_name"], b["template_name"]) |
208 |
+ return a["template_name"] |
209 |
|
210 |
-def tun_cmp(a, b): |
211 |
+def tun_cmp_func(a): |
212 |
""" |
213 |
- Compares two tunables. |
214 |
+ Return the tunable name to sort/compare on. |
215 |
""" |
216 |
|
217 |
- return cmp(a["tun_name"], b["tun_name"]) |
218 |
-def bool_cmp(a, b): |
219 |
+ return a["tun_name"] |
220 |
+ |
221 |
+def bool_cmp_func(a): |
222 |
""" |
223 |
- Compares two booleans. |
224 |
+ Return the boolean name to sort/compare on. |
225 |
""" |
226 |
|
227 |
- return cmp(a["bool_name"], b["bool_name"]) |
228 |
+ return a["bool_name"] |
229 |
|
230 |
def gen_doc_menu(mod_layer, module_list): |
231 |
""" |
232 |
@@ -249,18 +250,18 @@ def gen_doc_menu(mod_layer, module_list): |
233 |
""" |
234 |
|
235 |
menu = [] |
236 |
- for layer, value in module_list.iteritems(): |
237 |
+ for layer, value in module_list.items(): |
238 |
cur_menu = (layer, []) |
239 |
menu.append(cur_menu) |
240 |
if layer != mod_layer and mod_layer != None: |
241 |
continue |
242 |
#we are in our layer so fill in the other modules or we want them all |
243 |
- for mod, desc in value.iteritems(): |
244 |
+ for mod, desc in value.items(): |
245 |
cur_menu[1].append((mod, desc)) |
246 |
|
247 |
- menu.sort(first_cmp) |
248 |
+ menu.sort(key=first_cmp_func) |
249 |
for x in menu: |
250 |
- x[1].sort(first_cmp) |
251 |
+ x[1].sort(key=first_cmp_func) |
252 |
return menu |
253 |
|
254 |
def format_html_desc(node): |
255 |
@@ -379,7 +380,7 @@ def gen_docs(doc, working_dir, templatedir): |
256 |
|
257 |
#generate index pages |
258 |
main_content_buf = '' |
259 |
- for mod_layer,modules in module_list.iteritems(): |
260 |
+ for mod_layer,modules in module_list.items(): |
261 |
menu = gen_doc_menu(mod_layer, module_list) |
262 |
|
263 |
layer_summary = None |
264 |
@@ -485,7 +486,7 @@ def gen_docs(doc, working_dir, templatedir): |
265 |
"interface_parameters" : interface_parameters, |
266 |
"mod_name": mod_name, |
267 |
"mod_layer" : mod_layer }) |
268 |
- interfaces.sort(int_cmp) |
269 |
+ interfaces.sort(key=int_cmp_func) |
270 |
interface_tpl = pyplate.Template(intdata) |
271 |
interface_buf = interface_tpl.execute_string({"interfaces" : interfaces}) |
272 |
|
273 |
@@ -532,7 +533,7 @@ def gen_docs(doc, working_dir, templatedir): |
274 |
"mod_name": mod_name, |
275 |
"mod_layer" : mod_layer }) |
276 |
|
277 |
- templates.sort(temp_cmp) |
278 |
+ templates.sort(key=temp_cmp_func) |
279 |
template_tpl = pyplate.Template(templatedata) |
280 |
template_buf = template_tpl.execute_string({"templates" : templates}) |
281 |
|
282 |
@@ -556,7 +557,7 @@ def gen_docs(doc, working_dir, templatedir): |
283 |
"def_val" : boolean_dftval, |
284 |
"mod_name": mod_name, |
285 |
"mod_layer" : mod_layer }) |
286 |
- booleans.sort(bool_cmp) |
287 |
+ booleans.sort(key=bool_cmp_func) |
288 |
boolean_tpl = pyplate.Template(booldata) |
289 |
boolean_buf = boolean_tpl.execute_string({"booleans" : booleans}) |
290 |
|
291 |
@@ -580,7 +581,7 @@ def gen_docs(doc, working_dir, templatedir): |
292 |
"def_val" : tunable_dftval, |
293 |
"mod_name": mod_name, |
294 |
"mod_layer" : mod_layer }) |
295 |
- tunables.sort(tun_cmp) |
296 |
+ tunables.sort(key=tun_cmp_func) |
297 |
tunable_tpl = pyplate.Template(tundata) |
298 |
tunable_buf = tunable_tpl.execute_string({"tunables" : tunables}) |
299 |
|
300 |
@@ -639,7 +640,7 @@ def gen_docs(doc, working_dir, templatedir): |
301 |
menu_buf = menu_tpl.execute_string(menu_args) |
302 |
|
303 |
#build the interface index |
304 |
- all_interfaces.sort(int_cmp) |
305 |
+ all_interfaces.sort(key=int_cmp_func) |
306 |
interface_tpl = pyplate.Template(intlistdata) |
307 |
interface_buf = interface_tpl.execute_string({"interfaces" : all_interfaces}) |
308 |
int_file = "interfaces.html" |
309 |
@@ -654,7 +655,7 @@ def gen_docs(doc, working_dir, templatedir): |
310 |
|
311 |
|
312 |
#build the template index |
313 |
- all_templates.sort(temp_cmp) |
314 |
+ all_templates.sort(key=temp_cmp_func) |
315 |
template_tpl = pyplate.Template(templistdata) |
316 |
template_buf = template_tpl.execute_string({"templates" : all_templates}) |
317 |
temp_file = "templates.html" |
318 |
@@ -679,7 +680,7 @@ def gen_docs(doc, working_dir, templatedir): |
319 |
global_tun.append( { "tun_name" : tunable_name, |
320 |
"def_val" : default_value, |
321 |
"desc" : description } ) |
322 |
- global_tun.sort(tun_cmp) |
323 |
+ global_tun.sort(key=tun_cmp_func) |
324 |
global_tun_tpl = pyplate.Template(gtunlistdata) |
325 |
global_tun_buf = global_tun_tpl.execute_string({"tunables" : global_tun}) |
326 |
global_tun_file = "global_tunables.html" |
327 |
@@ -694,7 +695,7 @@ def gen_docs(doc, working_dir, templatedir): |
328 |
|
329 |
#build the tunable index |
330 |
all_tunables = all_tunables + global_tun |
331 |
- all_tunables.sort(tun_cmp) |
332 |
+ all_tunables.sort(key=tun_cmp_func) |
333 |
tunable_tpl = pyplate.Template(tunlistdata) |
334 |
tunable_buf = tunable_tpl.execute_string({"tunables" : all_tunables}) |
335 |
temp_file = "tunables.html" |
336 |
@@ -718,7 +719,7 @@ def gen_docs(doc, working_dir, templatedir): |
337 |
global_bool.append( { "bool_name" : bool_name, |
338 |
"def_val" : default_value, |
339 |
"desc" : description } ) |
340 |
- global_bool.sort(bool_cmp) |
341 |
+ global_bool.sort(key=bool_cmp_func) |
342 |
global_bool_tpl = pyplate.Template(gboollistdata) |
343 |
global_bool_buf = global_bool_tpl.execute_string({"booleans" : global_bool}) |
344 |
global_bool_file = "global_booleans.html" |
345 |
@@ -733,7 +734,7 @@ def gen_docs(doc, working_dir, templatedir): |
346 |
|
347 |
#build the boolean index |
348 |
all_booleans = all_booleans + global_bool |
349 |
- all_booleans.sort(bool_cmp) |
350 |
+ all_booleans.sort(key=bool_cmp_func) |
351 |
boolean_tpl = pyplate.Template(boollistdata) |
352 |
boolean_buf = boolean_tpl.execute_string({"booleans" : all_booleans}) |
353 |
temp_file = "booleans.html" |