From ab5b4c0f1621f49ea132976e7abe6ba668180428 Mon Sep 17 00:00:00 2001
From: Luis Araujo <luis.araujo@collabora.co.uk>
Date: Fri, 9 Nov 2018 01:44:48 +0800
Subject: [PATCH] Rename some functions with more accurate names

Signed-off-by: Luis Araujo <luis.araujo@collabora.co.uk>
---
 renderer/make_page.py | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/renderer/make_page.py b/renderer/make_page.py
index 96f74d4..1b20e18 100755
--- a/renderer/make_page.py
+++ b/renderer/make_page.py
@@ -9,8 +9,8 @@ from jinja2 import Environment, FileSystemLoader
 
 TEMPLATE_DIR="."
 
-# This command makes sure the following formatting applies for the respective
-# sections:
+# This command parse lists to make sure the following formatting
+# applies for the respective sections:
 #
 # pre-conditions:
 #  - Start line with '#' or '$' for commands, everything else is a comment.
@@ -21,14 +21,12 @@ TEMPLATE_DIR="."
 # run: steps:
 #  - Star '#' for comments , everything else is a command.
 #
-def comments_commands(lines, run=False):
+def parse_list(lines, run=False):
     processed_lines = []
     for line in lines:        
         p, c = '', ''
         sline = line.strip()
-
         if not sline:
-            processed_lines.append((p, c))
             continue
 
         if run:
@@ -48,7 +46,7 @@ def comments_commands(lines, run=False):
 
     return processed_lines
 
-def parse_format(testcase_data):
+def get_template_values(testcase_data):
     template_values = {}
 
     # Mandatory fields
@@ -62,7 +60,7 @@ def parse_format(testcase_data):
         value = metadata.get(mv)
         if value:
             if mv == 'expected':
-                template_values.update({ mv : comments_commands(value) })
+                template_values.update({ mv : parse_list(value) })
             else:
                 template_values.update({ mv.replace('-', '_') : value })
         else:
@@ -78,15 +76,13 @@ def parse_format(testcase_data):
         if not steps:
             print("Error: missing mandatory field steps for run")
             sys.exit(1)
-        template_values.update({ 'run_steps' :
-                                 comments_commands(steps, run=True) })
+        template_values.update({ 'run_steps' : parse_list(steps, run=True) })
 
     # No mandatory fields
     for nm in ['notes', 'format', 'maintainer', 'resources', 'pre-conditions']:
         value = metadata.get(nm)
         if value:
-            template_values.update({ nm.replace('-', '_') :
-                                     comments_commands(value)
+            template_values.update({ nm.replace('-', '_') : parse_list(value)
                                      if nm in ['notes', 'pre-conditions']
                                      else value })
 
@@ -102,18 +98,17 @@ def parse_format(testcase_data):
 
 
 if '__main__' == __name__:
-
     testcase_file = sys.argv[1]
 
     try:
         with open(testcase_file) as testcase:
-            testcase_data = yaml.safe_load(testcase)
+            tc_data = yaml.safe_load(testcase)
     except yaml.scanner.ScannerError as e:
         print("yaml format error:", e)
         sys.exit(1)
 
     env = Environment(loader=FileSystemLoader([TEMPLATE_DIR]))
     # Get template from environment and render it.
-    data = env.get_template('index.html').render(parse_format(testcase_data))
+    data = env.get_template('index.html').render(get_template_values(tc_data))
 
     print(data)
-- 
GitLab