Bug 1258916 part 8 - Change most uses of 'fn' to 'srcname' to make it clearer. rs=dbaron
authorXidorn Quan <me@upsuper.org>
Fri, 11 Nov 2016 21:35:38 +1100
changeset 352187 498f5669f48db0d57c6edb53f1d5ef3eb507833b
parent 352186 f33bcb35609a9c0a5a2173951f99e4ddcff9a536
child 352188 a1fe2f1909d445a027fa8210a3970384877cf40a
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1258916
milestone52.0a1
Bug 1258916 part 8 - Change most uses of 'fn' to 'srcname' to make it clearer. rs=dbaron MozReview-Commit-ID: HxHRj2He6cw
layout/reftests/w3c-css/import-tests.py
--- a/layout/reftests/w3c-css/import-tests.py
+++ b/layout/reftests/w3c-css/import-tests.py
@@ -140,92 +140,92 @@ def copy_support_files(test, dirname):
     global gSrcPath
     if dirname in support_dirs_mapped:
         return
     support_dirs_mapped.add(dirname)
     support_dir = os.path.join(dirname, "support")
     if not os.path.exists(support_dir):
         return
     for dirpath, dirnames, filenames in os.walk(support_dir):
-        for fn in filenames:
-            if fn == "LOCK":
+        for srcname in filenames:
+            if srcname == "LOCK":
                 continue
-            full_fn = os.path.join(dirpath, fn)
-            destname = to_unix_path_sep(os.path.relpath(full_fn, gSrcPath))
-            copy_file(test, full_fn, destname, True)
+            full_srcname = os.path.join(dirpath, srcname)
+            destname = to_unix_path_sep(os.path.relpath(full_srcname, gSrcPath))
+            copy_file(test, full_srcname, destname, True)
 
-def map_file(fn):
+def map_file(srcname):
     global gSrcPath
-    fn = to_unix_path_sep(os.path.normpath(fn))
-    if fn in filemap:
-        return filemap[fn]
-    destname = to_unix_path_sep(os.path.relpath(fn, gSrcPath))
+    srcname = to_unix_path_sep(os.path.normpath(srcname))
+    if srcname in filemap:
+        return filemap[srcname]
+    destname = to_unix_path_sep(os.path.relpath(srcname, gSrcPath))
     destdir = os.path.dirname(destname)
-    filemap[fn] = destname
-    load_flags_for(fn, destname)
-    copy_file(destname, fn, destname, False)
-    copy_support_files(destname, os.path.dirname(fn))
+    filemap[srcname] = destname
+    load_flags_for(srcname, destname)
+    copy_file(destname, srcname, destname, False)
+    copy_support_files(destname, os.path.dirname(srcname))
     return destname
 
-def load_flags_for(fn, destname):
+def load_flags_for(srcname, destname):
     global gTestFlags
     gTestFlags[destname] = []
 
-    if not (is_html(fn) or is_xml(fn)):
+    if not (is_html(srcname) or is_xml(srcname)):
         return
-    document = get_document_for(fn)
+    document = get_document_for(srcname)
     for meta in document.getElementsByTagName("meta"):
         name = meta.getAttribute("name")
         if name == "flags":
             gTestFlags[destname] = meta.getAttribute("content").split()
 
 def is_html(fn):
     return fn.endswith(".htm") or fn.endswith(".html")
 
 def is_xml(fn):
     return fn.endswith(".xht") or fn.endswith(".xml") or fn.endswith(".xhtml") or fn.endswith(".svg")
 
-def get_document_for(fn):
+def get_document_for(srcname):
     document = None # an xml.dom.minidom document
-    if is_html(fn):
+    if is_html(srcname):
         # An HTML file
-        f = open(fn, "rb")
+        f = open(srcname, "rb")
         parser = html5lib.HTMLParser(tree=html5lib.treebuilders.getTreeBuilder("dom"))
         document = parser.parse(f)
         f.close()
     else:
         # An XML file
-        document = xml.dom.minidom.parse(fn)
+        document = xml.dom.minidom.parse(srcname)
     return document
 
-def add_test_items(fn):
-    if not (is_html(fn) or is_xml(fn)):
-        map_file(fn)
+def add_test_items(srcname):
+    if not (is_html(srcname) or is_xml(srcname)):
+        map_file(srcname)
         return None
-    document = get_document_for(fn)
+    document = get_document_for(srcname)
     refs = []
     notrefs = []
     for link in document.getElementsByTagName("link"):
         rel = link.getAttribute("rel")
         if rel == "match":
             arr = refs
         elif rel == "mismatch":
             arr = notrefs
         else:
             continue
         if str(link.getAttribute("href")) != "":
-            arr.append(os.path.join(os.path.dirname(fn), str(link.getAttribute("href"))))
+            arr.append(os.path.join(os.path.dirname(srcname), str(link.getAttribute("href"))))
         else:
-            gLog.write("Warning: href attribute found empty in " + fn + "\n")
+            gLog.write("Warning: href attribute found empty in " + srcname + "\n")
     if len(refs) > 1:
         raise StandardError("Need to add code to specify which reference we want to match.")
     for ref in refs:
-        tests.append(["==", map_file(fn), map_file(ref)])
+        tests.append(["==", map_file(srcname), map_file(ref)])
     for notref in notrefs:
-        tests.append(["!=", map_file(fn), map_file(notref)])
+        tests.append(["!=", map_file(srcname), map_file(notref)])
     # Add chained references too
     for ref in refs:
         add_test_items(ref)
     for notref in notrefs:
         add_test_items(notref)
 
 AHEM_FONT_PATH = os.path.normpath(
     os.path.join(os.path.dirname(__file__), "../fonts/Ahem.ttf"))