From 3383ad8955b03ac9c48f6b25a505c83a9fd19d38 Mon Sep 17 00:00:00 2001
From: "(no author)" <(no author)@8a9318a1-56ba-4d59-b755-99d26321be01>
Date: Thu, 10 Sep 2009 16:37:47 +0000
Subject: [PATCH] moved variable reports and images into subdirectories using
 their display names so that virtual data sets using the same variable do not
 stomp each other's image names

git-svn-id: https://svn.ssec.wisc.edu/repos/glance/trunk@79 8a9318a1-56ba-4d59-b755-99d26321be01
---
 pyglance/glance/compare.py         | 18 ++++++++++++++++--
 pyglance/glance/mainreport.txt     | 13 +++++++------
 pyglance/glance/variablereport.txt |  2 +-
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/pyglance/glance/compare.py b/pyglance/glance/compare.py
index d38ca23..a772d7e 100644
--- a/pyglance/glance/compare.py
+++ b/pyglance/glance/compare.py
@@ -20,6 +20,8 @@ import glance.delta as delta
 import glance.plot as plot
 import glance.report as report
 
+from urllib import quote
+
 LOG = logging.getLogger(__name__)
 
 # these are the built in defaults for the settings
@@ -921,6 +923,17 @@ python -m glance
                 displayName = varRunInfo['display_name']
             explanationName = technicalName
             
+            # check to see if there is a directory to put information about this variable in,
+            # if not then create it
+            variableDir = outputPath + "/" + displayName
+            varRunInfo['variable_dir'] = variableDir
+            varRunInfo['variable_report_path_escaped'] = quote(displayName + "/" + technicalName + '.html')
+            LOG.debug ("Directory selected for variable information: " + varRunInfo['variable_report_path_escaped'])
+            if not (os.path.isdir(variableDir)) :
+                LOG.debug("Variable directory (" + variableDir + ") does not exist.")
+                LOG.debug("Creating variable directory.")
+                os.makedirs(variableDir)
+            
             # if B has an alternate variable name, figure that out
             b_variable = technicalName
             if 'alternate_name_in_B' in varRunInfo :
@@ -1022,7 +1035,7 @@ python -m glance
                                                          variableAnalysisInfo[varKey]['run_info'], runInfo,
                                                          variableAnalysisInfo[varKey]['var_stats'],
                                                          spatialInfo,
-                                                         outputPath,
+                                                         variableAnalysisInfo[varKey]['run_info']['variable_dir'],
                                                          variableAnalysisInfo[varKey]['run_info']['variable_name'] + ".html")
             
             print ('generating summary report')
@@ -1057,7 +1070,8 @@ python -m glance
                                                          latitudeCommon, longitudeCommon,
                                                          spaciallyInvalidMaskA,
                                                          spaciallyInvalidMaskB,
-                                                         outputPath, True,
+                                                         variableAnalysisInfo[varKey]['run_info']['variable_dir'],
+                                                         True,
                                                          doFork=runInfo['doFork']) 
                     print("\tfinished creating figures for: " + variableAnalysisInfo[varKey]['exp_name'])
         
diff --git a/pyglance/glance/mainreport.txt b/pyglance/glance/mainreport.txt
index e184997..55a8572 100644
--- a/pyglance/glance/mainreport.txt
+++ b/pyglance/glance/mainreport.txt
@@ -155,15 +155,16 @@ Copyright (c) 2009 University of Wisconsin SSEC. All rights reserved.
                         <%
                             # get some information about the variable, for convenience
                             tempVariableInfo = variables[variableKey]
+                            tempVarRunInfo   = tempVariableInfo['variable_run_info']
                             
-                            technicalName  = tempVariableInfo['variable_run_info']['variable_name']
+                            technicalName  = tempVarRunInfo['variable_name']
                             varDisplayName = technicalName
-                            if 'display_name' in tempVariableInfo['variable_run_info'] :
-                                varDisplayName = tempVariableInfo['variable_run_info']['display_name']
+                            if 'display_name' in tempVarRunInfo :
+                                varDisplayName = tempVarRunInfo['display_name']
                             
                             passPercent          = tempVariableInfo['pass_epsilon_percent']
                             finiteSimilarPercent = tempVariableInfo['finite_similar_percent']
-                            didPass = tempVariableInfo['variable_run_info']['did_pass']
+                            didPass              = tempVarRunInfo['did_pass']
                         %>
                         <tr>
                             <td>
@@ -176,8 +177,8 @@ Copyright (c) 2009 University of Wisconsin SSEC. All rights reserved.
                                 % endif
                             </td>
                             <td>
-                                Variable: <a href="${technicalName | u}.html">${varDisplayName}</a> <br>
-                                Epsilon used: ${tempVariableInfo['variable_run_info']['epsilon']} <br>
+                                Variable: <a href="${tempVarRunInfo['variable_report_path_escaped']}">${varDisplayName}</a> <br>
+                                Epsilon used: ${tempVarRunInfo['epsilon']} <br>
                                 Finite values within one epsilon of difference:
                                 ${report.make_formatted_display_string(passPercent, '%.6g')}%<br>
                                 Data that matched in finite-ness between the files:
diff --git a/pyglance/glance/variablereport.txt b/pyglance/glance/variablereport.txt
index 50ed426..825c916 100644
--- a/pyglance/glance/variablereport.txt
+++ b/pyglance/glance/variablereport.txt
@@ -171,7 +171,7 @@ Copyright (c) 2009 University of Wisconsin SSEC. All rights reserved.
             </dt>
             <dd>
                 % for statName, statValue in sorted(list(dataSet.items())) :
-                    ${statName}<a href="./doc.html">*</a>: ${report.make_formatted_display_string(statValue)} <br>
+                    ${statName}<a href="../doc.html">*</a>: ${report.make_formatted_display_string(statValue)} <br>
                 % endfor
                 <br>
             <dd>
-- 
GitLab