aboutsummaryrefslogtreecommitdiffstats
path: root/bsie/apps/info.py
diff options
context:
space:
mode:
Diffstat (limited to 'bsie/apps/info.py')
-rw-r--r--bsie/apps/info.py49
1 files changed, 14 insertions, 35 deletions
diff --git a/bsie/apps/info.py b/bsie/apps/info.py
index eaf1f71..e27b70b 100644
--- a/bsie/apps/info.py
+++ b/bsie/apps/info.py
@@ -1,18 +1,15 @@
-"""
-Part of the bsie module.
-A copy of the license is provided with the project.
-Author: Matthias Baumgartner, 2022
-"""
-# imports
+# standard imports
import argparse
+import os
import sys
import typing
# bsie imports
-from bsie.base import errors
-from bsie.tools import builder
-from bsie.utils import bsfs
+from bsie.utils import bsfs, errors
+
+# inner-module imports
+from . import _loader
# exports
__all__: typing.Sequence[str] = (
@@ -25,42 +22,24 @@ __all__: typing.Sequence[str] = (
def main(argv):
"""Show information from BSIE."""
parser = argparse.ArgumentParser(description=main.__doc__, prog='info')
- parser.add_argument('what', choices=('predicates', ),
+ parser.add_argument('--config', type=str,
+ default=os.path.join(os.path.dirname(__file__), _loader.DEFAULT_CONFIG_FILE),
+ help='Path to the config file.')
+ parser.add_argument('what', choices=('predicates', 'schema'),
help='Select what information to show.')
args = parser.parse_args(argv)
- # FIXME: Read reader/extractor configs from a config file
- # reader builder
- rbuild = builder.ReaderBuilder({})
- # extractor builder
- ebuild = builder.ExtractorBuilder([
- {'bsie.extractor.generic.path.Path': {}},
- {'bsie.extractor.generic.stat.Stat': {}},
- {'bsie.extractor.generic.constant.Constant': dict(
- tuples=[('http://bsfs.ai/schema/Entity#author', 'Me, myself, and I')],
- schema='''
- bse:author rdfs:subClassOf bsfs:Predicate ;
- rdfs:domain bsfs:Entity ;
- rdfs:range xsd:string ;
- bsfs:unique "true"^^xsd:boolean .
- ''',
- )},
- ])
- # pipeline builder
- pbuild = builder.PipelineBuilder(
- bsfs.Namespace('http://example.com/me/'), # not actually used
- rbuild,
- ebuild,
- )
-
# build pipeline
- pipeline = pbuild.build()
+ pipeline = _loader.load_pipeline(args.config)
# show info
if args.what == 'predicates':
# show predicates
for pred in pipeline.schema.predicates():
print(pred.uri)
+ elif args.what == 'schema':
+ # show schema
+ print(bsfs.schema.to_string(pipeline.schema))
else:
# args.what is already checked by argparse
raise errors.UnreachableError()