Commits

Geoffrey Sneddon committed 620f85e

There is no need for a generator class: move the one method to make it a function.

Comments (0)

Files changed (3)

 				expected = open(file_name[:-9] + ".html", "r")
 				
 				# Run the spec-gen
-				gen = generator.generator()
-				gen.process(tree, set(["sub", "xref", "toc"]))
+				generator.process(tree)
 				
 				# Get the output
 				walker = treewalkers.getTreeWalker("lxml")
 			# Close the input file
 			input.close()
 			
-			# Create the generator
-			gen = generator.generator()
-			
 			# Remove the option we pass as an argument
 			processes = opts.processes
 			del opts.processes
 			
 			# Run the generator, and profile, or not, as the case may be
 			if kwargs["profile"]:
-				cProfile.runctx("gen.process(tree, processes, **kwargs)", {}, {"gen": gen, "tree": tree, "processes": processes, "kwargs": kwargs})
+				cProfile.runctx("gen.process(tree, processes, **kwargs)", {}, {"gen": generator, "tree": tree, "processes": processes, "kwargs": kwargs})
 			else:
-				gen.process(tree, processes, **kwargs)
+				generator.process(tree, processes, **kwargs)
 			
 			# Serialize to XML
 			#if opts.xml:
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 # THE SOFTWARE.
 
-class generator(object):
-	""" This oversees all the actual work done """
+def process(tree, processes=set(["sub", "toc", "xref"]), **kwargs):
+	""" Process the given tree. """
 	
-	def process(self, tree, processes=set(["sub", "toc", "xref"]), **kwargs):
-		""" Process the given tree. """
+	# Find number of passes to do
+	for process in processes:
+		try:
+			process_module = getattr(__import__('processes', globals(), locals(), [process], -1), process)
+		except ImportError:
+			process_module = __import__(process, globals(), locals(), [], -1)
 		
-		# Find number of passes to do
-		for process in processes:
-			try:
-				process_module = getattr(__import__('processes', globals(), locals(), [process], -1), process)
-			except ImportError:
-				process_module = __import__(process, globals(), locals(), [], -1)
-			
-			getattr(process_module, process)(tree, **kwargs)
+		getattr(process_module, process)(tree, **kwargs)