Bug 1479484 - Part 1: Add make_dafsa.py to the virtualenv's python path, r=froydnj

Summary:
The plan is to also expose perfecthash.py from this module on the python path.
This also allows us to stop using explicit module loading to load make_dafsa.py.

make_dafsa.py was moved into tools/ to avoid any extra python files from
accidentally ending up on the python path.

Reviewers: froydnj!

Tags: #secure-revision

Bug #: 1479484

Differential Revision: https://phabricator.services.mozilla.com/D2614


--HG--
rename : xpcom/ds/make_dafsa.py => xpcom/ds/tools/make_dafsa.py
This commit is contained in:
Nika Layzell 2018-07-31 18:20:18 -04:00
parent ad3026deb1
commit 7a9f60fafb
5 changed files with 5 additions and 11 deletions

View File

@ -65,6 +65,7 @@ mozilla.pth:testing/web-platform/tests/tools/wptserve
mozilla.pth:testing/web-platform/tests/tools/six
mozilla.pth:testing/xpcshell
mozilla.pth:third_party/python/mock-1.0.0
mozilla.pth:xpcom/ds/tools
mozilla.pth:xpcom/typelib/xpt/tools
mozilla.pth:tools/docs
mozilla.pth:third_party/python/cbor2

View File

@ -8,6 +8,7 @@ import imp
import os
import re
import sys
from make_dafsa import words_to_cxx
"""
Processes a file containing effective TLD data. See the following URL for a
@ -104,14 +105,6 @@ def main(output, effective_tld_filename):
eTLD file is then printed to output.
"""
# Find and load the `make_dafsa.py` script under xpcom/ds.
tld_dir = os.path.dirname(effective_tld_filename)
make_dafsa_py = os.path.join(tld_dir, '../../xpcom/ds/make_dafsa.py')
sys.path.append(os.path.dirname(make_dafsa_py))
with open(make_dafsa_py, 'r') as fh:
make_dafsa = imp.load_module('script', fh, make_dafsa_py,
('.py', 'r', imp.PY_SOURCE))
def typeEnum(etld):
"""
Maps the flags to the DAFSA's enum types.
@ -130,7 +123,7 @@ def main(output, effective_tld_filename):
for etld in getEffectiveTLDs(effective_tld_filename):
yield "%s%d" % (etld.domain(), typeEnum(etld))
output.write(make_dafsa.words_to_cxx(dafsa_words()))
output.write(words_to_cxx(dafsa_words()))
if __name__ == '__main__':
main(sys.stdout, sys.argv[1])

View File

@ -185,7 +185,7 @@ GENERATED_FILES = [
'nsSTSPreloadList.h',
]
dafsa_data = GENERATED_FILES['nsSTSPreloadList.h']
dafsa_data.script = '../../../xpcom/ds/make_dafsa.py'
dafsa_data.script = '../../../xpcom/ds/tools/make_dafsa.py'
dafsa_data.inputs = ['nsSTSPreloadList.inc']
if CONFIG['NSS_DISABLE_DBM']:

View File

@ -105,7 +105,7 @@ GENERATED_FILES = [
'dafsa_test_1.inc',
]
dafsa_data = GENERATED_FILES['dafsa_test_1.inc']
dafsa_data.script = '../../ds/make_dafsa.py'
dafsa_data.script = '../../ds/tools/make_dafsa.py'
dafsa_data.inputs = ['dafsa_test_1.dat']
TEST_HARNESS_FILES.gtest += [