Bug 1258916 part 8 - Change most uses of 'fn' to 'srcname' to make it clearer. rs=dbaron

MozReview-Commit-ID: HxHRj2He6cw

--HG--
extra : source : 4c340c7a64ac30b4b07c312729e0b6c8db8da7df
This commit is contained in:
Xidorn Quan 2016-11-11 21:35:38 +11:00
Родитель 0be8f38737
Коммит 7d3b1f4fdb
1 изменённых файлов: 29 добавлений и 29 удалений

Просмотреть файл

@ -145,33 +145,33 @@ def copy_support_files(test, dirname):
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":
@ -183,24 +183,24 @@ def is_html(fn):
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"):
@ -212,15 +212,15 @@ def add_test_items(fn):
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)