From 2e07f33314c238e42bfadc5f39805f93ffbc622e Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Thu, 2 Mar 2023 15:10:05 +0100 Subject: removed author and license notices from individual files --- bsfs/query/__init__.py | 5 ----- bsfs/query/ast/__init__.py | 3 --- bsfs/query/ast/fetch.py | 5 ----- bsfs/query/ast/filter_.py | 3 --- bsfs/query/matcher.py | 5 ----- bsfs/query/validator.py | 5 ----- 6 files changed, 26 deletions(-) (limited to 'bsfs/query') diff --git a/bsfs/query/__init__.py b/bsfs/query/__init__.py index 21c7389..58ff03a 100644 --- a/bsfs/query/__init__.py +++ b/bsfs/query/__init__.py @@ -1,9 +1,4 @@ -""" -Part of the BlackStar filesystem (bsfs) module. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # imports import typing diff --git a/bsfs/query/ast/__init__.py b/bsfs/query/ast/__init__.py index 66b097d..bceaac0 100644 --- a/bsfs/query/ast/__init__.py +++ b/bsfs/query/ast/__init__.py @@ -6,9 +6,6 @@ Classes beginning with an underscore (_) represent internal type hierarchies and should not be used for parsing. Note that the AST structures do not (and cannot) check semantic validity or consistency with a given schema. -Part of the BlackStar filesystem (bsfs) module. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 """ # imports import typing diff --git a/bsfs/query/ast/fetch.py b/bsfs/query/ast/fetch.py index d653a8a..66d94e1 100644 --- a/bsfs/query/ast/fetch.py +++ b/bsfs/query/ast/fetch.py @@ -1,9 +1,4 @@ -""" -Part of the BlackStar filesystem (bsfs) module. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # imports from collections import abc import typing diff --git a/bsfs/query/ast/filter_.py b/bsfs/query/ast/filter_.py index b29d89e..56c982e 100644 --- a/bsfs/query/ast/filter_.py +++ b/bsfs/query/ast/filter_.py @@ -22,9 +22,6 @@ This AST has multiple issues that are not verified upon its creation: * Conditions exclude each other * The predicate along the branch have incompatible domains and ranges. -Part of the BlackStar filesystem (bsfs) module. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 """ # imports from collections import abc diff --git a/bsfs/query/matcher.py b/bsfs/query/matcher.py index a910756..5f3b07e 100644 --- a/bsfs/query/matcher.py +++ b/bsfs/query/matcher.py @@ -1,9 +1,4 @@ -""" -Part of the BlackStar filesystem (bsfs) module. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # imports from collections import defaultdict from itertools import product diff --git a/bsfs/query/validator.py b/bsfs/query/validator.py index f0aa795..6e3afa1 100644 --- a/bsfs/query/validator.py +++ b/bsfs/query/validator.py @@ -1,9 +1,4 @@ -""" -Part of the BlackStar filesystem (bsfs) module. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # imports import typing -- cgit v1.2.3 From 6b9379d75198082054c35e44bc2cd880353a7485 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Thu, 2 Mar 2023 16:40:43 +0100 Subject: hardening --- bsfs/query/validator.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'bsfs/query') diff --git a/bsfs/query/validator.py b/bsfs/query/validator.py index 6e3afa1..b259ea0 100644 --- a/bsfs/query/validator.py +++ b/bsfs/query/validator.py @@ -37,6 +37,10 @@ class Filter(): self.schema = schema def __call__(self, root_type: bsc.Node, query: ast.filter.FilterExpression): + """Alias for `Filter.validate`.""" + return self.validate(root_type, query) + + def validate(self, root_type: bsc.Node, query: ast.filter.FilterExpression): """Validate a filter *query*, assuming the subject having *root_type*. Raises a `bsfs.utils.errors.ConsistencyError` if the query violates the schema. @@ -237,7 +241,11 @@ class Fetch(): def __init__(self, schema: bsc.Schema): self.schema = schema - def __call__(self, root_type: bsc.Node, query: ast.fetch.FetchExpression): + def __call__(self, root_type: bsc.Node, query: ast.filter.FilterExpression): + """Alias for `Fetch.validate`.""" + return self.validate(root_type, query) + + def validate(self, root_type: bsc.Node, query: ast.fetch.FetchExpression): """Validate a fetch *query*, assuming the subject having *root_type*. Raises a `bsfs.utils.errors.ConsistencyError` if the query violates the schema. -- cgit v1.2.3 From 2c6c23f85e7f2123c508f9ff8a4aa776948bb589 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Thu, 2 Mar 2023 16:46:11 +0100 Subject: minor style fixes --- bsfs/query/validator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bsfs/query') diff --git a/bsfs/query/validator.py b/bsfs/query/validator.py index b259ea0..1ce44e9 100644 --- a/bsfs/query/validator.py +++ b/bsfs/query/validator.py @@ -36,11 +36,11 @@ class Filter(): def __init__(self, schema: bsc.Schema): self.schema = schema - def __call__(self, root_type: bsc.Node, query: ast.filter.FilterExpression): + def __call__(self, root_type: bsc.Node, query: ast.filter.FilterExpression) -> bool: """Alias for `Filter.validate`.""" return self.validate(root_type, query) - def validate(self, root_type: bsc.Node, query: ast.filter.FilterExpression): + def validate(self, root_type: bsc.Node, query: ast.filter.FilterExpression) -> bool: """Validate a filter *query*, assuming the subject having *root_type*. Raises a `bsfs.utils.errors.ConsistencyError` if the query violates the schema. @@ -241,11 +241,11 @@ class Fetch(): def __init__(self, schema: bsc.Schema): self.schema = schema - def __call__(self, root_type: bsc.Node, query: ast.filter.FilterExpression): + def __call__(self, root_type: bsc.Node, query: ast.fetch.FetchExpression) -> bool: """Alias for `Fetch.validate`.""" return self.validate(root_type, query) - def validate(self, root_type: bsc.Node, query: ast.fetch.FetchExpression): + def validate(self, root_type: bsc.Node, query: ast.fetch.FetchExpression) -> bool: """Validate a fetch *query*, assuming the subject having *root_type*. Raises a `bsfs.utils.errors.ConsistencyError` if the query violates the schema. -- cgit v1.2.3 From 4fead04055be4967d9ea3b24ff61fe37a93108dd Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Sat, 4 Mar 2023 13:31:11 +0100 Subject: namespace refactoring and cleanup --- bsfs/query/ast/filter_.py | 3 ++- bsfs/query/matcher.py | 4 ++-- bsfs/query/validator.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'bsfs/query') diff --git a/bsfs/query/ast/filter_.py b/bsfs/query/ast/filter_.py index 56c982e..610fdb4 100644 --- a/bsfs/query/ast/filter_.py +++ b/bsfs/query/ast/filter_.py @@ -10,7 +10,8 @@ For example, consider the following AST: >>> Any(ns.bse.collection, ... And( ... Equals('hello'), -... Any(ns.bsm.guid, Any(ns.bsm.guid, Equals('hello'))), +... Is('hello world'), +... Any(ns.bse.tag, Equals('world')), ... Any(ns.bst.label, Equals('world')), ... All(ns.bst.label, Not(Equals('world'))), ... ) diff --git a/bsfs/query/matcher.py b/bsfs/query/matcher.py index 5f3b07e..17c9c8e 100644 --- a/bsfs/query/matcher.py +++ b/bsfs/query/matcher.py @@ -215,8 +215,8 @@ class Filter(): two following queries are semantically identical, but structurally different, and would therefore not match: - >>> ast.filter.OneOf(ast.filter.Predicate(ns.bse.filename)) - >>> ast.filter.Predicate(ns.bse.filename) + >>> ast.filter.OneOf(ast.filter.Predicate(ns.bse.name)) + >>> ast.filter.Predicate(ns.bse.name) """ diff --git a/bsfs/query/validator.py b/bsfs/query/validator.py index 1ce44e9..10ca492 100644 --- a/bsfs/query/validator.py +++ b/bsfs/query/validator.py @@ -177,7 +177,7 @@ class Filter(): if not type_ <= dom: raise errors.ConsistencyError(f'expected type {dom}, found {type_}') # node.count is a numerical expression - self._parse_filter_expression(self.schema.literal(ns.bsfs.Number), node.count) + self._parse_filter_expression(self.schema.literal(ns.bsl.Number), node.count) def _distance(self, type_: bsc.Vertex, node: ast.filter.Distance): # type is a Literal @@ -218,7 +218,7 @@ class Filter(): if type_ not in self.schema.literals(): raise errors.ConsistencyError(f'literal {type_} is not in the schema') # type must be a numerical - if not type_ <= self.schema.literal(ns.bsfs.Number): + if not type_ <= self.schema.literal(ns.bsl.Number): raise errors.ConsistencyError(f'expected a number type, found {type_}') # FIXME: Check if node.value corresponds to type_ -- cgit v1.2.3