From 50dee2e79af196e412fe7ee35f641b189d94eefe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20No=C3=ABl?= Date: Sun, 29 Jul 2018 01:42:55 +0100 Subject: Do not use rapper --- configure.ac | 6 ------ data/ontology2code | 25 +++++++++---------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index 9ec5f52c..f8b9b320 100644 --- a/configure.ac +++ b/configure.ac @@ -248,12 +248,6 @@ fi # Ontology parsing dependencies ################################################# -# check for rapper -AC_CHECK_PROG(HAVE_RAPPER, rapper, yes, no) -if test "x$HAVE_RAPPER" = "xno"; then - AC_MSG_ERROR("You need the tool `rapper' from the `raptor-utils' package in order to compile Zeitgeist") -fi - # check for python-rdflib AC_MSG_CHECKING([for python-rdflib]) echo "import rdflib" | $PYTHON - 2>/dev/null diff --git a/data/ontology2code b/data/ontology2code index b8efbfdc..acaf330c 100755 --- a/data/ontology2code +++ b/data/ontology2code @@ -192,24 +192,21 @@ class OntologyParser: symbols = None def __init__(self, directory): - rdfxml = self._load_rdfxml_from_trig_directory(directory) - self.symbols = self._parse(rdfxml) - - @staticmethod - def _load_rdfxml_from_trig_directory(directory): if not os.path.isdir(directory): raise SystemExit, 'Directory doesn\'t exist: %s' % directory - files = ' '.join(glob.glob(os.path.join(directory, '*.trig'))) - return commands.getoutput( - "cat %s | rapper -i trig -o rdfxml -I ZeitgeistNamespace - " \ - "2>/dev/null" % files) + files = glob.glob(os.path.join(directory, '*.trig')) + self.symbols = SymbolCollection() + for file in files: + self._parse(file) - def _parse(self, rdfxml_stream): + self.symbols.post_process() + + def _parse(self, file): """ Parse an RDFXML stream into a SymbolCollection. """ ontology = rdflib.ConjunctiveGraph() - ontology.parse(StringInputSource(rdfxml_stream)) + ontology.parse(file, format="trig") def _get_all_classes(*super_classes): for cls in super_classes: @@ -222,7 +219,6 @@ class OntologyParser: symbol_classes = set(_get_all_classes(*parent_classes)) all_symbols = symbol_classes.union(parent_classes) - symbols = SymbolCollection() for symbol in sorted(all_symbols): # URI uri = str(symbol) @@ -243,10 +239,7 @@ class OntologyParser: assert parents # And we have a new Symbol! - symbols.register(uri, parents, display_name, doc) - - symbols.post_process() - return symbols + self.symbols.register(uri, parents, display_name, doc) class GenericSerializer: -- cgit v1.2.1