diff options
-rw-r--r-- | bsfs/apps/migrate.py | 6 | ||||
-rw-r--r-- | bsfs/graph/graph.py | 10 | ||||
-rw-r--r-- | bsfs/triple_store/sparql/sparql.py | 2 | ||||
-rw-r--r-- | test/apps/test_migrate.py | 10 | ||||
-rw-r--r-- | test/graph/ac/test_null.py | 4 | ||||
-rw-r--r-- | test/graph/test_graph.py | 12 | ||||
-rw-r--r-- | test/graph/test_nodes.py | 2 | ||||
-rw-r--r-- | test/graph/test_resolve.py | 2 | ||||
-rw-r--r-- | test/query/test_validator.py | 2 | ||||
-rw-r--r-- | test/triple_store/sparql/test_parse_filter.py | 4 | ||||
-rw-r--r-- | test/triple_store/sparql/test_sparql.py | 14 |
11 files changed, 34 insertions, 34 deletions
diff --git a/bsfs/apps/migrate.py b/bsfs/apps/migrate.py index 91c1661..b9d019f 100644 --- a/bsfs/apps/migrate.py +++ b/bsfs/apps/migrate.py @@ -42,15 +42,15 @@ def main(argv): graph = bsfs.Open(config) # initialize schema - schema = bsfs.schema.Schema.Empty() + schema = bsfs.schema.Schema() if len(args.schema) == 0: # assemble schema from standard input - schema = schema + bsfs.schema.Schema.from_string(sys.stdin.read()) + schema = schema + bsfs.schema.from_string(sys.stdin.read()) else: # assemble schema from input files for pth in args.schema: with open(pth, mode='rt', encoding='UTF-8') as ifile: - schema = schema + bsfs.schema.Schema.from_string(ifile.read()) + schema = schema + bsfs.schema.from_string(ifile.read()) # migrate schema graph.migrate(schema, not args.remove) diff --git a/bsfs/graph/graph.py b/bsfs/graph/graph.py index f030fed..2210755 100644 --- a/bsfs/graph/graph.py +++ b/bsfs/graph/graph.py @@ -10,7 +10,7 @@ import typing # bsfs imports from bsfs.query import ast, validate -from bsfs.schema import Schema +from bsfs import schema as bsc from bsfs.triple_store import TripleStoreBase from bsfs.utils import URI, typename @@ -67,11 +67,11 @@ class Graph(): return f'{typename(self)}({str(self._backend)}, {self._user})' @property - def schema(self) -> Schema: + def schema(self) -> bsc.Schema: """Return the store's local schema.""" return self._backend.schema - def migrate(self, schema: Schema, append: bool = True) -> 'Graph': + def migrate(self, schema: bsc.Schema, append: bool = True) -> 'Graph': """Migrate the current schema to a new *schema*. Appends to the current schema by default; control this via *append*. @@ -79,14 +79,14 @@ class Graph(): """ # check args - if not isinstance(schema, Schema): + if not isinstance(schema, bsc.Schema): raise TypeError(schema) # append to current schema if append: schema = schema + self._backend.schema # add Graph schema requirements with open(os.path.join(os.path.dirname(__file__), 'schema.nt'), mode='rt', encoding='UTF-8') as ifile: - schema = schema + Schema.from_string(ifile.read()) + schema = schema + bsc.from_string(ifile.read()) # migrate schema in backend # FIXME: consult access controls! self._backend.schema = schema diff --git a/bsfs/triple_store/sparql/sparql.py b/bsfs/triple_store/sparql/sparql.py index c3cbff6..ddace35 100644 --- a/bsfs/triple_store/sparql/sparql.py +++ b/bsfs/triple_store/sparql/sparql.py @@ -94,7 +94,7 @@ class SparqlStore(base.TripleStoreBase): super().__init__(None) self._graph = rdflib.Graph() self._transaction = _Transaction(self._graph) - self._schema = bsc.Schema.Empty() + self._schema = bsc.Schema() self._filter_parser = parse_filter.Filter(self._schema) # NOTE: mypy and pylint complain about the **kwargs not being listed (contrasting super) diff --git a/test/apps/test_migrate.py b/test/apps/test_migrate.py index 957509a..230c032 100644 --- a/test/apps/test_migrate.py +++ b/test/apps/test_migrate.py @@ -13,7 +13,7 @@ import unittest import unittest.mock # bsie imports -from bsfs.schema import Schema +from bsfs import schema # objects to test from bsfs.apps.migrate import main @@ -33,21 +33,21 @@ class TestMigrate(unittest.TestCase): # read schema from file with open(schema_1) as ifile: - target = Schema.from_string(ifile.read()) + target = schema.from_string(ifile.read()) graph = main([config, schema_1]) self.assertTrue(target <= graph.schema) # read schema from multiple files with open(schema_1) as ifile: - target = Schema.from_string(ifile.read()) + target = schema.from_string(ifile.read()) with open(schema_2) as ifile: - target = target + Schema.from_string(ifile.read()) + target = target + schema.from_string(ifile.read()) graph = main([config, schema_1, schema_2]) self.assertTrue(target <= graph.schema) # read schema from stdin with open(schema_1, 'rt') as ifile: - target = Schema.from_string(ifile.read()) + target = schema.from_string(ifile.read()) with open(schema_1, 'rt') as ifile: with unittest.mock.patch('sys.stdin', ifile): graph = main([config]) diff --git a/test/graph/ac/test_null.py b/test/graph/ac/test_null.py index c863943..c3df393 100644 --- a/test/graph/ac/test_null.py +++ b/test/graph/ac/test_null.py @@ -8,7 +8,7 @@ Author: Matthias Baumgartner, 2022 import unittest # bsie imports -from bsfs import schema as _schema +from bsfs import schema as bsc from bsfs.namespace import ns from bsfs.query import ast from bsfs.triple_store import SparqlStore @@ -23,7 +23,7 @@ from bsfs.graph.ac.null import NullAC class TestNullAC(unittest.TestCase): def setUp(self): self.backend = SparqlStore() - self.backend.schema = _schema.Schema.from_string(''' + self.backend.schema = bsc.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> diff --git a/test/graph/test_graph.py b/test/graph/test_graph.py index 8503d5b..125084c 100644 --- a/test/graph/test_graph.py +++ b/test/graph/test_graph.py @@ -25,7 +25,7 @@ class TestGraph(unittest.TestCase): def setUp(self): self.user = URI('http://example.com/me') self.backend = SparqlStore.Open() - self.backend.schema = schema.Schema.from_string(''' + self.backend.schema = schema.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix bsfs: <http://bsfs.ai/schema/> bsfs:Entity rdfs:subClassOf bsfs:Node . @@ -118,7 +118,7 @@ class TestGraph(unittest.TestCase): schema.Node(ns.bsfs.Node, None)))}), append=False) # can migrate to compatible schema - target_1 = schema.Schema.from_string(''' + target_1 = schema.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> prefix bsfs: <http://bsfs.ai/schema/> @@ -142,7 +142,7 @@ class TestGraph(unittest.TestCase): # new schema is applied self.assertLess(target_1, graph.schema) # graph appends its predicates - self.assertEqual(graph.schema, target_1 + schema.Schema.from_string(''' + self.assertEqual(graph.schema, target_1 + schema.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> prefix bsfs: <http://bsfs.ai/schema/> @@ -155,7 +155,7 @@ class TestGraph(unittest.TestCase): ''')) # can overwrite the current schema - target_2 = schema.Schema.from_string(''' + target_2 = schema.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> prefix bsfs: <http://bsfs.ai/schema/> @@ -181,7 +181,7 @@ class TestGraph(unittest.TestCase): # new schema is applied self.assertLess(target_2, graph.schema) # graph appends its predicates - self.assertEqual(graph.schema, target_2 + schema.Schema.from_string(''' + self.assertEqual(graph.schema, target_2 + schema.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> prefix bsfs: <http://bsfs.ai/schema/> @@ -196,7 +196,7 @@ class TestGraph(unittest.TestCase): def test_get(self): # setup graph = Graph(self.backend, self.user) - graph.migrate(schema.Schema.from_string(''' + graph.migrate(schema.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> prefix bsfs: <http://bsfs.ai/schema/> diff --git a/test/graph/test_nodes.py b/test/graph/test_nodes.py index 11ae46d..47647bd 100644 --- a/test/graph/test_nodes.py +++ b/test/graph/test_nodes.py @@ -24,7 +24,7 @@ class TestNodes(unittest.TestCase): def setUp(self): # initialize backend self.backend = SparqlStore() - self.backend.schema = _schema.Schema.from_string(''' + self.backend.schema = _schema.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> diff --git a/test/graph/test_resolve.py b/test/graph/test_resolve.py index f515320..a27e8c9 100644 --- a/test/graph/test_resolve.py +++ b/test/graph/test_resolve.py @@ -31,7 +31,7 @@ class TestFilter(unittest.TestCase): """ def test_call(self): - schema = bsc.Schema.from_string(''' + schema = bsc.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> diff --git a/test/query/test_validator.py b/test/query/test_validator.py index bf3ceeb..405872c 100644 --- a/test/query/test_validator.py +++ b/test/query/test_validator.py @@ -21,7 +21,7 @@ from bsfs.query.validator import Filter class TestFilter(unittest.TestCase): def setUp(self): - self.schema = _schema.Schema.from_string(''' + self.schema = _schema.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> diff --git a/test/triple_store/sparql/test_parse_filter.py b/test/triple_store/sparql/test_parse_filter.py index bd967e5..1d96994 100644 --- a/test/triple_store/sparql/test_parse_filter.py +++ b/test/triple_store/sparql/test_parse_filter.py @@ -9,7 +9,7 @@ import rdflib import unittest # bsie imports -from bsfs import schema as _schema +from bsfs import schema as bsc from bsfs.namespace import ns from bsfs.query import ast from bsfs.utils import errors @@ -23,7 +23,7 @@ from bsfs.triple_store.sparql.parse_filter import Filter class TestParseFilter(unittest.TestCase): def setUp(self): # schema - self.schema = _schema.Schema.from_string(''' + self.schema = bsc.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> diff --git a/test/triple_store/sparql/test_sparql.py b/test/triple_store/sparql/test_sparql.py index 25a0b15..5342925 100644 --- a/test/triple_store/sparql/test_sparql.py +++ b/test/triple_store/sparql/test_sparql.py @@ -9,7 +9,7 @@ import rdflib import unittest # bsie imports -from bsfs import schema as _schema +from bsfs import schema as bsc from bsfs.namespace import ns from bsfs.query import ast from bsfs.utils import errors, URI @@ -22,7 +22,7 @@ from bsfs.triple_store.sparql.sparql import SparqlStore class TestSparqlStore(unittest.TestCase): def setUp(self): - self.schema = _schema.Schema.from_string(''' + self.schema = bsc.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> @@ -90,7 +90,7 @@ class TestSparqlStore(unittest.TestCase): def test__has_type(self): # setup store store = SparqlStore.Open() - store.schema = _schema.Schema.from_string(''' + store.schema = bsc.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> prefix bsfs: <http://bsfs.ai/schema/> @@ -195,7 +195,7 @@ class TestSparqlStore(unittest.TestCase): self.assertSetEqual(set(store._graph), instances) # add some classes to the schema - curr = curr + _schema.Schema.from_string(''' + curr = curr + bsc.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> prefix bsfs: <http://bsfs.ai/schema/> @@ -298,7 +298,7 @@ class TestSparqlStore(unittest.TestCase): # remove some classes from the schema - curr = _schema.Schema.from_string(''' + curr = bsc.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> prefix bsfs: <http://bsfs.ai/schema/> @@ -383,7 +383,7 @@ class TestSparqlStore(unittest.TestCase): self.assertRaises(TypeError, setattr, store, 'schema', Foo()) # cannot migrate to incompatible schema - invalid = _schema.Schema.from_string(''' + invalid = bsc.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> prefix bsfs: <http://bsfs.ai/schema/> @@ -399,7 +399,7 @@ class TestSparqlStore(unittest.TestCase): ''') self.assertRaises(errors.ConsistencyError, setattr, store, 'schema', invalid) - invalid = _schema.Schema.from_string(''' + invalid = bsc.from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> prefix bsfs: <http://bsfs.ai/schema/> |