Commit 32bde98f authored by Roland Denis's avatar Roland Denis
Browse files

Moving global counter as class attribute

parent eb7a6bde
......@@ -39,8 +39,6 @@ def jinja2_format_storage(value, power=0, units=['o', 'Kio', 'Mio', 'Gio', 'Tio'
# Extend default translator
class myHTMLTranslator(PelicanHTMLTranslator):
global num_meso
num_meso = 0
def __init__(self, *args, **kwargs):
......@@ -59,6 +57,8 @@ class myHTMLTranslator(PelicanHTMLTranslator):
self.storage_template = env.get_template('storage.tpl')
self.storage_list_template = env.get_template('storage_list.tpl')
self.num_meso = 0
super().__init__(*args, *kwargs)
def visit_region(self, node):
......@@ -78,52 +78,51 @@ class myHTMLTranslator(PelicanHTMLTranslator):
#super().depart_section(node)
def visit_meso(self, node):
global num_meso
num_meso=num_meso+1
self.body.extend(self.meso_template.render(meso=node, num=num_meso, header=True).splitlines(True))
self.num_meso += 1
self.body.extend(self.meso_template.render(meso=node, num=self.num_meso, header=True).splitlines(True))
def depart_meso(self, node):
self.body.extend(self.meso_template.render(meso=node, footer=True).splitlines(True))
def visit_cluster_list(self, node):
self.body.extend(self.cluster_list_template.render(num=num_meso, header=True).splitlines(True))
self.body.extend(self.cluster_list_template.render(num=self.num_meso, header=True).splitlines(True))
def depart_cluster_list(self, node):
self.body.extend(self.cluster_list_template.render(num=num_meso, footer=True).splitlines(True))
self.body.extend(self.cluster_list_template.render(num=self.num_meso, footer=True).splitlines(True))
def visit_cluster(self, node):
self.body.extend(self.cluster_template.render(cluster=node, num=num_meso, header=True).splitlines(True))
self.body.extend(self.cluster_template.render(cluster=node, num=self.num_meso, header=True).splitlines(True))
def depart_cluster(self, node):
self.body.extend(self.cluster_template.render(cluster=node, num=num_meso, footer=True).splitlines(True))
self.body.extend(self.cluster_template.render(cluster=node, num=self.num_meso, footer=True).splitlines(True))
def visit_cluster_storage_list(self, node):
pass
#self.body.extend(self.storage_list_template.render(num=num_meso, header=True).splitlines(True))
#self.body.extend(self.storage_list_template.render(num=self.num_meso, header=True).splitlines(True))
def depart_cluster_storage_list(self, node):
pass
#self.body.extend(self.storage_list_template.render(num=num_meso, footer=True).splitlines(True))
#self.body.extend(self.storage_list_template.render(num=self.num_meso, footer=True).splitlines(True))
def visit_cluster_storage(self, node):
pass
#self.body.extend(self.storage_template.render(storage=node, num=num_meso, header=True).splitlines(True))
#self.body.extend(self.storage_template.render(storage=node, num=self.num_meso, header=True).splitlines(True))
def depart_cluster_storage(self, node):
pass
#self.body.extend(self.storage_template.render(storage=node, num=num_meso, footer=True).splitlines(True))
#self.body.extend(self.storage_template.render(storage=node, num=self.num_meso, footer=True).splitlines(True))
def visit_storage_list(self, node):
self.body.extend(self.storage_list_template.render(num=num_meso, header=True).splitlines(True))
self.body.extend(self.storage_list_template.render(num=self.num_meso, header=True).splitlines(True))
def depart_storage_list(self, node):
self.body.extend(self.storage_list_template.render(num=num_meso, footer=True).splitlines(True))
self.body.extend(self.storage_list_template.render(num=self.num_meso, footer=True).splitlines(True))
def visit_storage(self, node):
self.body.extend(self.storage_template.render(storage=node, num=num_meso, header=True).splitlines(True))
self.body.extend(self.storage_template.render(storage=node, num=self.num_meso, header=True).splitlines(True))
def depart_storage(self, node):
self.body.extend(self.storage_template.render(storage=node, num=num_meso, footer=True).splitlines(True))
self.body.extend(self.storage_template.render(storage=node, num=self.num_meso, footer=True).splitlines(True))
def visit_node_type_list(self, node):
pass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment