delay pathod parsing until needed

This allows us to use different languages based on runtime env.
This commit is contained in:
Thomas Kriechbaumer 2015-06-12 13:41:04 +02:00
parent 22811c45dd
commit 30fbf57e4b
4 changed files with 3 additions and 28 deletions

View File

@ -208,17 +208,11 @@ def args_pathod(argv, stdout=sys.stdout, stderr=sys.stderr):
if os.path.isfile(spec):
data = open(spec).read()
spec = data
try:
req = language.parse_pathod(spec)
except language.ParseException as v:
print >> stderr, "Error parsing anchor spec: %s" % v.msg
print >> stderr, v.marked()
sys.exit(1)
try:
arex = re.compile(patt)
except re.error:
return parser.error("Invalid regex in anchor: %s" % patt)
anchors.append((arex, req))
anchors.append((arex, spec))
args.anchors = anchors
return args

View File

@ -23,7 +23,7 @@ class _TestDaemon:
ssloptions = self.ssloptions,
staticdir = tutils.test_data.path("data"),
anchors = [
(re.compile("/anchor/.*"), language.parse_pathod("202"))
(re.compile("/anchor/.*"), "202")
]
)

View File

@ -65,15 +65,6 @@ def test_pathod(perror):
assert perror.called
perror.reset_mock()
s = cStringIO.StringIO()
tutils.raises(
SystemExit,
cmdline.args_pathod,
["pathod", "-a", "foo=."],
s,
s
)
a = cmdline.args_pathod(
[
"pathod",
@ -92,13 +83,3 @@ def test_pathod(perror):
)
assert perror.called
perror.reset_mock()
a = cmdline.args_pathod(
[
"pathod",
"-c",
"?"
]
)
assert perror.called
perror.reset_mock()

View File

@ -27,7 +27,7 @@ class DaemonTests(object):
klass.d = test.Daemon(
staticdir=test_data.path("data"),
anchors=[
(re.compile("/anchor/.*"), language.parse_pathod("202:da"))
(re.compile("/anchor/.*"), "202:da")
],
ssl = klass.ssl,
ssloptions = so,