diff options
author | Gunnar Aastrand Grimnes <gromgull@gmail.com> | 2015-11-27 12:02:15 +0100 |
---|---|---|
committer | Gunnar Aastrand Grimnes <gromgull@gmail.com> | 2015-11-28 07:28:24 +0100 |
commit | a4f0ee142d17686d16fc50e832b1360e374fb79a (patch) | |
tree | f0c3ff6ea5e3225fe411fb50ff4531592d79c724 | |
parent | fa4172cc51a39b698ab7cb81240243ed6d62db1c (diff) | |
download | rdflib-path-n3-method.tar.gz |
added .n3 methods for path objectspath-n3-method
-rw-r--r-- | rdflib/paths.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/rdflib/paths.py b/rdflib/paths.py index 1862c98c..02a2ce7f 100644 --- a/rdflib/paths.py +++ b/rdflib/paths.py @@ -217,6 +217,9 @@ class InvPath(Path): def __repr__(self): return "Path(~%s)" % (self.arg,) + def n3(self): + return '^%s'%self.arg.n3() + class SequencePath(Path): def __init__(self, *args): @@ -258,6 +261,9 @@ class SequencePath(Path): def __repr__(self): return "Path(%s)" % " / ".join(str(x) for x in self.args) + def n3(self): + return '/'.join(a.n3() for a in self.args) + class AlternativePath(Path): def __init__(self, *args): @@ -276,6 +282,10 @@ class AlternativePath(Path): def __repr__(self): return "Path(%s)" % " | ".join(str(x) for x in self.args) + def n3(self): + return '|'.join(a.n3() for a in self.args) + + class MulPath(Path): def __init__(self, path, mod): @@ -375,6 +385,10 @@ class MulPath(Path): def __repr__(self): return "Path(%s%s)" % (self.path, self.mod) + def n3(self): + return '%s%s'%(self.path, self.mod) + + class NegatedPath(Path): def __init__(self, arg): @@ -404,6 +418,9 @@ class NegatedPath(Path): def __repr__(self): return "Path(! %s)" % ",".join(str(x) for x in self.args) + def n3(self): + return '!(%s)'%('|'.join(self.args)) + class PathList(list): pass |