aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-06-29 10:42:15 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-06-29 10:42:15 +1200
commit1b42f5ab1f3e22c760d155c7e3dea283032a517e (patch)
tree0467cad0758989ebd35e02d91df54e7b9e7fc7b0 /libpathod
parent4040df664ba1d05acf29293141ca650c69a8788b (diff)
downloadmitmproxy-1b42f5ab1f3e22c760d155c7e3dea283032a517e.tar.gz
mitmproxy-1b42f5ab1f3e22c760d155c7e3dea283032a517e.tar.bz2
mitmproxy-1b42f5ab1f3e22c760d155c7e3dea283032a517e.zip
Allow naked literals for path specification.
Diffstat (limited to 'libpathod')
-rw-r--r--libpathod/rparse.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/libpathod/rparse.py b/libpathod/rparse.py
index 6306f746..e08da49f 100644
--- a/libpathod/rparse.py
+++ b/libpathod/rparse.py
@@ -155,20 +155,29 @@ class FileGenerator:
return self.map.__getslice__(a, b)
-class ValueLiteral:
+class _Value:
def __init__(self, val):
self.val = val
def get_generator(self, settings):
return LiteralGenerator(self.val)
+ def __str__(self):
+ return self.val
+
+
+class ValueLiteral(_Value):
@classmethod
def expr(klass):
e = v_literal.copy()
return e.setParseAction(lambda x: klass(*x))
- def __str__(self):
- return self.val
+
+class ValueNakedLiteral(_Value):
+ @classmethod
+ def expr(klass):
+ e = v_naked_literal.copy()
+ return e.setParseAction(lambda x: klass(*x))
class ValueGenerate:
@@ -238,6 +247,16 @@ Value = pp.MatchFirst(
)
+NakedValue = pp.MatchFirst(
+ [
+ ValueGenerate.expr(),
+ ValueFile.expr(),
+ ValueLiteral.expr(),
+ ValueNakedLiteral.expr(),
+ ]
+)
+
+
class ShortcutContentType:
def __init__(self, value):
self.value = value
@@ -302,7 +321,7 @@ class Path:
@classmethod
def expr(klass):
- e = v_naked_literal.copy()
+ e = NakedValue.copy()
return e.setParseAction(lambda x: klass(*x))