aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2023-01-16 21:36:50 +0100
committerMatthias Baumgartner <dev@igsor.net>2023-01-16 21:36:50 +0100
commit58aaa864f9747d27c065739256d4c6635ca9b751 (patch)
tree9888ae0bd2345816d1ab479dd34b4c6b902c158a
parent4f868bcb3be2658960eace3222563cc9a819366a (diff)
downloadbsie-58aaa864f9747d27c065739256d4c6635ca9b751.tar.gz
bsie-58aaa864f9747d27c065739256d4c6635ca9b751.tar.bz2
bsie-58aaa864f9747d27c065739256d4c6635ca9b751.zip
minor fixes
-rw-r--r--bsie/extractor/image/colors_spatial.py3
-rw-r--r--bsie/lib/pipeline.py3
-rw-r--r--test/apps/test_index.py6
-rw-r--r--test/extractor/image/test_colors_spatial.py9
4 files changed, 16 insertions, 5 deletions
diff --git a/bsie/extractor/image/colors_spatial.py b/bsie/extractor/image/colors_spatial.py
index 38f1db4..ce5b9f2 100644
--- a/bsie/extractor/image/colors_spatial.py
+++ b/bsie/extractor/image/colors_spatial.py
@@ -71,7 +71,8 @@ class ColorsSpatial(base.Extractor):
<{FEATURE_NAME}> rdfs:subClassOf bsfs:Feature ;
# annotations
rdfs:label "Spatially dominant colors"^^xsd:string ;
- schema:description "Domiant colors of subregions in an image."^^xsd:string .
+ schema:description "Domiant colors of subregions in an image."^^xsd:string ;
+ bsfs:dtype xsd:integer .
<{instance_name}> rdfs:subClassOf <{FEATURE_NAME}> ;
bsfs:dimension "{dimension}"^^xsd:integer ;
diff --git a/bsie/lib/pipeline.py b/bsie/lib/pipeline.py
index 02119bc..44685ba 100644
--- a/bsie/lib/pipeline.py
+++ b/bsie/lib/pipeline.py
@@ -125,7 +125,6 @@ class Pipeline():
try:
# get content
content = rdr(path) if rdr is not None else None
-
#logger.info('extracted %s from %s', rdr, path)
# apply extractors on this content
@@ -139,7 +138,7 @@ class Pipeline():
# critical extractor failure.
logger.error('%s failed to extract triples from content: %s', ext, err)
- except errors.UnsupportedFileFormatError as err:
+ except errors.UnsupportedFileFormatError:
# failed to read the file format. skip.
#logger.warning('%s could not process the file format of %s', rdr, err)
pass
diff --git a/test/apps/test_index.py b/test/apps/test_index.py
index c3960b8..7f5be8e 100644
--- a/test/apps/test_index.py
+++ b/test/apps/test_index.py
@@ -23,6 +23,12 @@ from bsie.apps.index import main
## code ##
class TestIndex(unittest.TestCase):
+ def test_main_invalid(self):
+ outbuf = io.StringIO()
+ with contextlib.redirect_stdout(outbuf):
+ bsfs = main([os.path.join(os.path.dirname(__file__), 'inexistent-file.t')])
+ self.assertEqual(outbuf.getvalue().strip(), '')
+
def test_main(self):
bsfs = main([
'-r',
diff --git a/test/extractor/image/test_colors_spatial.py b/test/extractor/image/test_colors_spatial.py
index d8a4209..ba551f3 100644
--- a/test/extractor/image/test_colors_spatial.py
+++ b/test/extractor/image/test_colors_spatial.py
@@ -57,8 +57,9 @@ class TestColorsSpatial(unittest.TestCase):
schema = bsfs.schema.from_string(base.SCHEMA_PREAMBLE + f'''
<{self.instance_prefix}> rdfs:subClassOf bsfs:Feature ;
# annotations
- rdfs:label ""^^xsd:string ;
- schema:description ""^^xsd:string .
+ rdfs:label "Spatially dominant colors"^^xsd:string ;
+ schema:description "Domiant colors of subregions in an image."^^xsd:string ;
+ bsfs:dtype xsd:integer .
<{self.instance_prefix}#{self.uuid}> rdfs:subClassOf <{self.instance_prefix}> ;
bsfs:dimension "3276"^^xsd:integer ;
@@ -80,11 +81,15 @@ class TestColorsSpatial(unittest.TestCase):
node = _node.Node(ns.bsfs.Entity, bsfs.URI('http://example.com/entity#1234'))
principals = set(ext.principals)
self.assertEqual(len(principals), 1)
+ # valid invocation yields feature
ret = list(ext.extract(node, img, principals))
self.assertEqual(ret[0], (
node,
list(principals)[0],
(91, 127, 121, 94, 138, 167, 163, 134, 190, 138, 170, 156, 121, 142, 159)))
+ # principals is respected
+ self.assertListEqual(list(ext.extract(node, img, {})), [])
+
## main ##