delay pathod parsing until needed
This allows us to use different languages based on runtime env.
This commit is contained in:
parent
22811c45dd
commit
30fbf57e4b
|
@ -208,17 +208,11 @@ def args_pathod(argv, stdout=sys.stdout, stderr=sys.stderr):
|
||||||
if os.path.isfile(spec):
|
if os.path.isfile(spec):
|
||||||
data = open(spec).read()
|
data = open(spec).read()
|
||||||
spec = data
|
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:
|
try:
|
||||||
arex = re.compile(patt)
|
arex = re.compile(patt)
|
||||||
except re.error:
|
except re.error:
|
||||||
return parser.error("Invalid regex in anchor: %s" % patt)
|
return parser.error("Invalid regex in anchor: %s" % patt)
|
||||||
anchors.append((arex, req))
|
anchors.append((arex, spec))
|
||||||
args.anchors = anchors
|
args.anchors = anchors
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class _TestDaemon:
|
||||||
ssloptions = self.ssloptions,
|
ssloptions = self.ssloptions,
|
||||||
staticdir = tutils.test_data.path("data"),
|
staticdir = tutils.test_data.path("data"),
|
||||||
anchors = [
|
anchors = [
|
||||||
(re.compile("/anchor/.*"), language.parse_pathod("202"))
|
(re.compile("/anchor/.*"), "202")
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -65,15 +65,6 @@ def test_pathod(perror):
|
||||||
assert perror.called
|
assert perror.called
|
||||||
perror.reset_mock()
|
perror.reset_mock()
|
||||||
|
|
||||||
s = cStringIO.StringIO()
|
|
||||||
tutils.raises(
|
|
||||||
SystemExit,
|
|
||||||
cmdline.args_pathod,
|
|
||||||
["pathod", "-a", "foo=."],
|
|
||||||
s,
|
|
||||||
s
|
|
||||||
)
|
|
||||||
|
|
||||||
a = cmdline.args_pathod(
|
a = cmdline.args_pathod(
|
||||||
[
|
[
|
||||||
"pathod",
|
"pathod",
|
||||||
|
@ -92,13 +83,3 @@ def test_pathod(perror):
|
||||||
)
|
)
|
||||||
assert perror.called
|
assert perror.called
|
||||||
perror.reset_mock()
|
perror.reset_mock()
|
||||||
|
|
||||||
a = cmdline.args_pathod(
|
|
||||||
[
|
|
||||||
"pathod",
|
|
||||||
"-c",
|
|
||||||
"?"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
assert perror.called
|
|
||||||
perror.reset_mock()
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class DaemonTests(object):
|
||||||
klass.d = test.Daemon(
|
klass.d = test.Daemon(
|
||||||
staticdir=test_data.path("data"),
|
staticdir=test_data.path("data"),
|
||||||
anchors=[
|
anchors=[
|
||||||
(re.compile("/anchor/.*"), language.parse_pathod("202:da"))
|
(re.compile("/anchor/.*"), "202:da")
|
||||||
],
|
],
|
||||||
ssl = klass.ssl,
|
ssl = klass.ssl,
|
||||||
ssloptions = so,
|
ssloptions = so,
|
||||||
|
|
Loading…
Reference in New Issue