public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/hardened-refpolicy:master commit in: support/, policy/flask/, doc/templates/
@ 2012-05-01 12:25 Sven Vermeulen
  0 siblings, 0 replies; only message in thread
From: Sven Vermeulen @ 2012-05-01 12:25 UTC (permalink / raw
  To: gentoo-commits

commit:     9e70333ad297407c69d7369134a75b5af6bada7b
Author:     Sven Vermeulen <sven.vermeulen <AT> siphos <DOT> be>
AuthorDate: Tue May  1 12:24:52 2012 +0000
Commit:     Sven Vermeulen <sven.vermeulen <AT> siphos <DOT> be>
CommitDate: Tue May  1 12:24:52 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-refpolicy.git;a=commit;h=9e70333a

Who uses html pages to embed python code in... oh right, we do

---
 doc/templates/bool_list.html |    2 +-
 doc/templates/interface.html |    4 +-
 doc/templates/template.html  |    4 +-
 doc/templates/tun_list.html  |    2 +-
 policy/flask/flask.py        |    4 +-
 support/genhomedircon        |    8 +++---
 support/pyplate.py           |    4 +-
 support/sedoctool.py         |   61 +++++++++++++++++++++--------------------
 8 files changed, 45 insertions(+), 44 deletions(-)

diff --git a/doc/templates/bool_list.html b/doc/templates/bool_list.html
index 2d852da..3a2f526 100644
--- a/doc/templates/bool_list.html
+++ b/doc/templates/bool_list.html
@@ -2,7 +2,7 @@
 
 [[for bool in booleans]]
 <div id="interfacesmall">
-[[if bool.has_key('mod_layer')]]
+[[if 'mod_layer' in bool]]
 Module: <a href='[[bool['mod_layer']+ "_" + bool['mod_name'] + ".html#link_" + bool['bool_name']]]'>
 [[bool['mod_name']]]</a><p/>
 Layer: <a href='[[bool['mod_layer']]].html'>

diff --git a/doc/templates/interface.html b/doc/templates/interface.html
index 90eb436..0409361 100644
--- a/doc/templates/interface.html
+++ b/doc/templates/interface.html
@@ -1,10 +1,10 @@
 [[for int in interfaces]]
 <a name="link_[[int['interface_name']]]"></a>
 <div id="interface">
-[[if int.has_key("mod_layer")]]
+[[if "mod_layer" in int]]
 	Layer: [[mod_layer]]<br>
 [[end]]
-[[if int.has_key("mod_name")]]
+[[if "mod_name" in int]]
 	Module: [[mod_name]]<br>
 [[end]]
 <div id="codeblock">

diff --git a/doc/templates/template.html b/doc/templates/template.html
index 251d227..03dd1d5 100644
--- a/doc/templates/template.html
+++ b/doc/templates/template.html
@@ -1,10 +1,10 @@
 [[for temp in templates]]
 <a name="link_[[temp['template_name']]]"></a>
 <div id="template">
-[[if temp.has_key("mod_layer")]]
+[[if "mod_layer" in temp]]
 	Layer: [[mod_layer]]<br>
 [[end]]
-[[if temp.has_key("mod_name")]]
+[[if "mod_name" in temp]]
 	Module: [[mod_name]]<br>
 [[end]]
 <div id="codeblock">

diff --git a/doc/templates/tun_list.html b/doc/templates/tun_list.html
index 278f284..4daf8b4 100644
--- a/doc/templates/tun_list.html
+++ b/doc/templates/tun_list.html
@@ -2,7 +2,7 @@
 
 [[for tun in tunables]]
 <div id="interfacesmall">
-[[if tun.has_key('mod_layer')]]
+[[if 'mod_layer' in tun]]
 Module: <a href='[[tun['mod_layer']+ "_" + tun['mod_name'] + ".html#link_" + tun['tun_name']]]'>
 [[tun['mod_name']]]</a><p/>
 Layer: <a href='[[tun['mod_layer']]].html'>

diff --git a/policy/flask/flask.py b/policy/flask/flask.py
index 8b4be50..ca566d8 100644
--- a/policy/flask/flask.py
+++ b/policy/flask/flask.py
@@ -313,7 +313,7 @@ class Flask:
 		results = []
 		results.append(self.autogen)
 		for c in self.vectors:
-			if self.inherits.has_key(c):
+			if c in self.inherits:
 				i = self.inherits[c]
 				count = len(self.common[i])
 				if not (mode == self.KERNEL and self.userspace[c]):
@@ -355,7 +355,7 @@ class Flask:
 			count = 0
 
 			ps = []
-			if self.inherits.has_key(c):
+			if c in self.inherits:
 				ps += self.common[self.inherits[c]]
 			ps += self.vector[c]
 			for p in ps: 

diff --git a/support/genhomedircon b/support/genhomedircon
index 01ef91d..33dbcc1 100644
--- a/support/genhomedircon
+++ b/support/genhomedircon
@@ -82,7 +82,7 @@ def getPrefixes():
 				u[5] != "/" and \
 				string.count(u[5], "/") > 1:
 			prefix = u[5][:string.rfind(u[5], "/")]
-			if not prefixes.has_key(prefix):
+			if not prefix in prefixes:
 				prefixes[prefix] = ""
 	return prefixes
  
@@ -133,7 +133,7 @@ def oldgenhomedircon(filecontextdir, filecontext):
                 homedir = rc[1].split("=")[1]
                 homedir = homedir.split("#")[0]
                 homedir = homedir.strip()
-                if not prefixes.has_key(homedir):
+                if not homedir in prefixes:
                         prefixes[homedir] = ""
         else:
                 #rc[0] == 256 means the file was there, we read it, but the grep didn't match
@@ -149,7 +149,7 @@ def oldgenhomedircon(filecontextdir, filecontext):
                 homedir = homedir.split("#")[0]
                 homedir = homedir.strip()
                 homedir = re.sub(r"[^/a-zA-Z0-9].*$", "", homedir)
-                if not prefixes.has_key(homedir):
+                if not homedir in prefixes:
                         prefixes[homedir] = ""
 
         #the idea is that we need to find all of the home_root_t directories we do this by just accepting
@@ -187,7 +187,7 @@ def oldgenhomedircon(filecontextdir, filecontext):
                         if re.search(regex, potential, 0):
                                 addme = 0
                 if addme == 1:
-                        if not prefixes.has_key(potential):
+                        if not potential in prefixes:
                                 prefixes[potential] = ""
 
 

diff --git a/support/pyplate.py b/support/pyplate.py
index 22385e9..c13cd88 100644
--- a/support/pyplate.py
+++ b/support/pyplate.py
@@ -185,7 +185,7 @@ class ForTemplateNode(TemplateNode):
   def execute(self, stream, data):
     remember_vars = {}
     for var in self.vars:
-      if data.has_key(var):
+      if var in data:
         remember_vars[var] = data[var]
     for list in eval(self.expression, globals(), data):
       if is_sequence(list):
@@ -264,7 +264,7 @@ class FunctionTemplateNode(TemplateNode):
   def call(self, args, stream, data):
     remember_vars = {}
     for index, var in enumerate(self.vars):
-      if data.has_key(var):
+      if var in data:
         remember_vars[var] = data[var]
       data[var] = args[index]
     TemplateNode.execute(self, stream, data)

diff --git a/support/sedoctool.py b/support/sedoctool.py
index a363e72..afcdee4 100644
--- a/support/sedoctool.py
+++ b/support/sedoctool.py
@@ -209,39 +209,40 @@ def get_conf(conf):
 
 	return namevalue_list
 
-def first_cmp(a, b):
+def first_cmp_func(a):
 	"""
-	Compares the two first elements of a list instead of the entire list.
+	Return the first element to sort/compare on.
 	"""
 
-	return cmp(a[0], b[0])
+	return a[0]
 
-def int_cmp(a, b):
+def int_cmp_func(a):
 	"""
-	Compares two interfaces.
+	Return the interface name to sort/compare on.
 	"""
 
-	return cmp(a["interface_name"], b["interface_name"])
+	return a["interface_name"]
 		
-def temp_cmp(a, b):
+def temp_cmp_func(a):
 	"""
-	Compares two templates.
+	Return the template name to sort/compare on.
 	"""
 
-	return cmp(a["template_name"], b["template_name"])
+	return a["template_name"]
 
-def tun_cmp(a, b):
+def tun_cmp_func(a):
 	"""
-	Compares two tunables.
+	Return the tunable name to sort/compare on.
 	"""
 
-	return cmp(a["tun_name"], b["tun_name"])
-def bool_cmp(a, b):
+	return a["tun_name"]
+
+def bool_cmp_func(a):
 	"""
-	Compares two booleans.
+	Return the boolean name to sort/compare on.
 	"""
 
-	return cmp(a["bool_name"], b["bool_name"])
+	return a["bool_name"]
 
 def gen_doc_menu(mod_layer, module_list):
 	"""
@@ -249,18 +250,18 @@ def gen_doc_menu(mod_layer, module_list):
 	"""
 
 	menu = []
-	for layer, value in module_list.iteritems():
+	for layer, value in module_list.items():
 		cur_menu = (layer, [])
 		menu.append(cur_menu)
 		if layer != mod_layer and mod_layer != None:
 			continue
 		#we are in our layer so fill in the other modules or we want them all
-		for mod, desc in value.iteritems():
+		for mod, desc in value.items():
 			cur_menu[1].append((mod, desc))
 
-	menu.sort(first_cmp)
+	menu.sort(key=first_cmp_func)
 	for x in menu:
-		x[1].sort(first_cmp)
+		x[1].sort(key=first_cmp_func)
 	return menu
 
 def format_html_desc(node):
@@ -379,7 +380,7 @@ def gen_docs(doc, working_dir, templatedir):
 
 #generate index pages
 	main_content_buf = ''
-	for mod_layer,modules in module_list.iteritems():
+	for mod_layer,modules in module_list.items():
 		menu = gen_doc_menu(mod_layer, module_list)
 
 		layer_summary = None
@@ -485,7 +486,7 @@ def gen_docs(doc, working_dir, templatedir):
 					   "interface_parameters" : interface_parameters,
 					   "mod_name": mod_name,
 					   "mod_layer" : mod_layer })
-		interfaces.sort(int_cmp)	
+		interfaces.sort(key=int_cmp_func)	
 		interface_tpl = pyplate.Template(intdata)
 		interface_buf = interface_tpl.execute_string({"interfaces" : interfaces})
 	
@@ -532,7 +533,7 @@ def gen_docs(doc, working_dir, templatedir):
 					   "mod_name": mod_name,
 					   "mod_layer" : mod_layer })
 
-		templates.sort(temp_cmp)	
+		templates.sort(key=temp_cmp_func)	
 		template_tpl = pyplate.Template(templatedata)
 		template_buf = template_tpl.execute_string({"templates" : templates})
 
@@ -556,7 +557,7 @@ def gen_docs(doc, working_dir, templatedir):
 					   "def_val" : boolean_dftval,
 					   "mod_name": mod_name,
 					   "mod_layer" : mod_layer })
-		booleans.sort(bool_cmp)
+		booleans.sort(key=bool_cmp_func)
 		boolean_tpl = pyplate.Template(booldata)
 		boolean_buf = boolean_tpl.execute_string({"booleans" : booleans})
 
@@ -580,7 +581,7 @@ def gen_docs(doc, working_dir, templatedir):
 					   "def_val" : tunable_dftval,
 					   "mod_name": mod_name,
 					   "mod_layer" : mod_layer })
-		tunables.sort(tun_cmp)
+		tunables.sort(key=tun_cmp_func)
 		tunable_tpl = pyplate.Template(tundata)
 		tunable_buf = tunable_tpl.execute_string({"tunables" : tunables})
 	
@@ -639,7 +640,7 @@ def gen_docs(doc, working_dir, templatedir):
 	menu_buf = menu_tpl.execute_string(menu_args)
 	
 	#build the interface index
-	all_interfaces.sort(int_cmp)
+	all_interfaces.sort(key=int_cmp_func)
 	interface_tpl = pyplate.Template(intlistdata)
 	interface_buf = interface_tpl.execute_string({"interfaces" : all_interfaces})
 	int_file = "interfaces.html"
@@ -654,7 +655,7 @@ def gen_docs(doc, working_dir, templatedir):
 
 
 	#build the template index
-	all_templates.sort(temp_cmp)
+	all_templates.sort(key=temp_cmp_func)
 	template_tpl = pyplate.Template(templistdata)
 	template_buf = template_tpl.execute_string({"templates" : all_templates})
 	temp_file = "templates.html"
@@ -679,7 +680,7 @@ def gen_docs(doc, working_dir, templatedir):
 			global_tun.append( { "tun_name" : tunable_name,
 						"def_val" : default_value,
 						"desc" : description } )
-	global_tun.sort(tun_cmp)
+	global_tun.sort(key=tun_cmp_func)
 	global_tun_tpl = pyplate.Template(gtunlistdata)
 	global_tun_buf = global_tun_tpl.execute_string({"tunables" : global_tun})
 	global_tun_file = "global_tunables.html"
@@ -694,7 +695,7 @@ def gen_docs(doc, working_dir, templatedir):
 
 	#build the tunable index
 	all_tunables = all_tunables + global_tun
-	all_tunables.sort(tun_cmp)
+	all_tunables.sort(key=tun_cmp_func)
 	tunable_tpl = pyplate.Template(tunlistdata)
 	tunable_buf = tunable_tpl.execute_string({"tunables" : all_tunables})
 	temp_file = "tunables.html"
@@ -718,7 +719,7 @@ def gen_docs(doc, working_dir, templatedir):
 			global_bool.append( { "bool_name" : bool_name,
 						"def_val" : default_value,
 						"desc" : description } )
-	global_bool.sort(bool_cmp)
+	global_bool.sort(key=bool_cmp_func)
 	global_bool_tpl = pyplate.Template(gboollistdata)
 	global_bool_buf = global_bool_tpl.execute_string({"booleans" : global_bool})
 	global_bool_file = "global_booleans.html"
@@ -733,7 +734,7 @@ def gen_docs(doc, working_dir, templatedir):
 	
 	#build the boolean index
 	all_booleans = all_booleans + global_bool
-	all_booleans.sort(bool_cmp)
+	all_booleans.sort(key=bool_cmp_func)
 	boolean_tpl = pyplate.Template(boollistdata)
 	boolean_buf = boolean_tpl.execute_string({"booleans" : all_booleans})
 	temp_file = "booleans.html"



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-05-01 12:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-01 12:25 [gentoo-commits] proj/hardened-refpolicy:master commit in: support/, policy/flask/, doc/templates/ Sven Vermeulen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox