funowl
Advanced tools
| {"git_version": "4086331", "is_release": false} |
| import unittest | ||
| from funowl import AnnotationValue | ||
| from funowl.converters.functional_converter import to_python | ||
| class Issue39TestCase(unittest.TestCase): | ||
| def test_assignment_in_code(self): | ||
| r = to_python("""Prefix(:=<http://purl.obolibrary.org/obo/so#>) | ||
| Ontology(<http://purl.obolibrary.org/obo/so/subsets/SOFA.owl> | ||
| AnnotationAssertion(:hasDbXref :SO_0000394 "PMID:=12409455") | ||
| )""") | ||
| self.assertIs(type(r.ontology.axioms[0].value), AnnotationValue) | ||
| self.assertEqual("PMID:=12409455", str(r.ontology.axioms[0].value)) | ||
| if __name__ == '__main__': | ||
| unittest.main() |
@@ -5,3 +5,2 @@ name: Build | ||
| push: | ||
| branches: [ main ] | ||
@@ -8,0 +7,0 @@ jobs: |
| Metadata-Version: 1.2 | ||
| Name: funowl | ||
| Version: 0.1.11 | ||
| Version: 0.1.12 | ||
| Summary: Python rendering of the OWL Functional syntax | ||
@@ -5,0 +5,0 @@ Home-page: http://biolink.github.io/hsolbrig |
| bcp47 | ||
| pyjsg>=0.11.6 | ||
| rdflib-shim | ||
| rdflib!=6.1.*,>=5.0.0 | ||
| rdflib>=5.0.0 | ||
| rfc3987 |
@@ -36,4 +36,4 @@ import sys | ||
| if sys.version_info < (3, 8, 0): | ||
| warn(f"FunOwl needs python 3.8 or later. Current version: {sys.version_info}") | ||
| if sys.version_info < (3, 7, 9): | ||
| warn(f"FunOwl needs python 3.7.9 or later. Current version: {sys.version_info}") | ||
@@ -40,0 +40,0 @@ # Use the rdflib shim |
@@ -25,3 +25,7 @@ import logging | ||
| # 1: Prefix ':=' 2: URI | ||
| prefix_re = re.compile(r'\s*(\S*):\s*=\s*(\S*)', flags=re.DOTALL) | ||
| # Note - the official source of this is https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rPN_PREFIX, but | ||
| # we're trying to avoid having to encode all the UTF-16 stuff, so we're generalizing here and letting the | ||
| # n3 parser cover the final bit | ||
| prefix_re = re.compile(r'\s*([^"\']*):\s*=\s*([^"\']*)', flags=re.DOTALL) | ||
| # prefix_re = re.compile(r'\s*([^"]*):\s*=\s*([^"]*)', flags=re.DOTALL) | ||
@@ -28,0 +32,0 @@ # nodeId |
@@ -14,3 +14,3 @@ """ | ||
| from rdflib import Graph, Literal | ||
| from rdflib.namespace import RDFS, XSD, RDF | ||
| from rdflib.namespace import RDFS, XSD, RDF, Namespace | ||
| from rdflib.plugins.parsers.notation3 import BadSyntax | ||
@@ -26,2 +26,3 @@ from rdflib.term import Node | ||
| DUMMY_PREFIX = Namespace("http://a/b#") | ||
@@ -173,3 +174,4 @@ @dataclass | ||
| # Create a turtle triple to use the n3 parser | ||
| stmt = f'@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . xsd:f a {v} .' | ||
| # TODO: make the constructor static and use clear | ||
| stmt = f'@prefix : <{DUMMY_PREFIX}> . @prefix xsd: <{XSD}> . :f a {v} .' | ||
| g = Graph() | ||
@@ -183,3 +185,3 @@ try: | ||
| pass | ||
| l = g.value(XSD.f, RDF.type) | ||
| l = g.value(DUMMY_PREFIX.f, RDF.type) | ||
| if l is not None: | ||
@@ -186,0 +188,0 @@ if not isinstance(l, rdflib.Literal) or l.value is None: |
@@ -7,3 +7,3 @@ """ | ||
| from dataclasses import fields | ||
| from typing import Any, Iterable, TypeVar, _eval_type | ||
| from typing import Any, Iterable, TypeVar, _eval_type, Union | ||
@@ -15,5 +15,5 @@ if sys.version_info < (3, 8): | ||
| def get_args(typ): | ||
| return getattr(typ, '__args__', None) | ||
| return getattr(typ, '__args__', []) | ||
| else: | ||
| from typing import get_origin, get_args, Union | ||
| from typing import get_origin, get_args | ||
@@ -20,0 +20,0 @@ |
+1
-1
@@ -10,3 +10,3 @@ [[source]] | ||
| [packages] | ||
| rdflib = ">=5.0.0, !=6.1.*" | ||
| rdflib = ">=5.0.0" | ||
| rdflib-shim = "*" | ||
@@ -13,0 +13,0 @@ pyjsg = ">=0.11.6" |
+29
-28
| { | ||
| "_meta": { | ||
| "hash": { | ||
| "sha256": "00d611f86cf6fb72afd7bc90b90680e2d83fbfe33450779eae90abdc20b87253" | ||
| "sha256": "c8f2218262cd18a9584b6bfe4dfe8f417789a79d5ab4e45bd5ec3dc898cf034c" | ||
| }, | ||
@@ -47,23 +47,23 @@ "pipfile-spec": 6, | ||
| "hashes": [ | ||
| "sha256:8679a81c00e2ccb12618adcc2ce5e9a7bef542f4f940ef18e5b7751f5c5a42a4", | ||
| "sha256:b9bf406c87aab4ff62f9372e38b4fcda5cffc0c12385c46a4b01eb83dafd7850" | ||
| "sha256:10af60ff42219be7e85bf7f11c19b648715b0b29eb2ddbd269e87069a7c3f26d", | ||
| "sha256:4bd6e3ff2833fa2b395bbe803a2d72a5f0bab5b7285bccd0da1a1bc0aee88bfa" | ||
| ], | ||
| "index": "pypi", | ||
| "version": "==0.11.9" | ||
| "version": "==0.11.10" | ||
| }, | ||
| "pyparsing": { | ||
| "hashes": [ | ||
| "sha256:04ff808a5b90911829c55c4e26f75fa5ca8a2f5f36aa3a51f68e27033341d3e4", | ||
| "sha256:d9bdec0013ef1eb5a84ab39a3b3868911598afa494f5faa038647101504e2b81" | ||
| "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb", | ||
| "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc" | ||
| ], | ||
| "markers": "python_version >= '3.6'", | ||
| "version": "==3.0.6" | ||
| "markers": "python_full_version >= '3.6.8'", | ||
| "version": "==3.0.9" | ||
| }, | ||
| "rdflib": { | ||
| "hashes": [ | ||
| "sha256:6136ae056001474ee2aff5fc5b956e62a11c3a9c66bb0f3d9c0aaa5fbb56854e", | ||
| "sha256:b7642daac8cdad1ba157fecb236f5d1b2aa1de64e714dcee80d65e2b794d88a6" | ||
| "sha256:8dbfa0af2990b98471dacbc936d6494c997ede92fd8ed693fb84ee700ef6f754", | ||
| "sha256:fc81cef513cd552d471f2926141396b633207109d0154c8e77926222c70367fe" | ||
| ], | ||
| "index": "pypi", | ||
| "version": "==6.0.2" | ||
| "version": "==6.1.1" | ||
| }, | ||
@@ -95,7 +95,7 @@ "rdflib-jsonld": { | ||
| "hashes": [ | ||
| "sha256:2404879cda71495fc4d5cbc445ed52fdaddf352b36e40be8dcc63147cb4edabe", | ||
| "sha256:68eb94073fc486091447fcb0501efd6560a0e5a1839ba249e5ff3c4c93f05f90" | ||
| "sha256:5a844ad6e190dccc67d6d7411d119c5152ce01f7c76be4d8a1eaa314501bba77", | ||
| "sha256:bf8a748ac98b09d32c9a64a995a6b25921c96cc5743c1efa82763ba80ff54e91" | ||
| ], | ||
| "markers": "python_version >= '3.7'", | ||
| "version": "==60.5.0" | ||
| "version": "==62.4.0" | ||
| }, | ||
@@ -114,14 +114,15 @@ "six": { | ||
| "hashes": [ | ||
| "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872", | ||
| "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569" | ||
| "sha256:84c85a9078b11105f04f3036a9482ae10e4621616db313fe045dd24743a0820d", | ||
| "sha256:fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412" | ||
| ], | ||
| "version": "==2021.10.8" | ||
| "markers": "python_version >= '3.6'", | ||
| "version": "==2022.6.15" | ||
| }, | ||
| "charset-normalizer": { | ||
| "hashes": [ | ||
| "sha256:876d180e9d7432c5d1dfd4c5d26b72f099d503e8fcc0feb7532c9289be60fcbd", | ||
| "sha256:cb957888737fc0bbcd78e3df769addb41fd1ff8cf950dc9e7ad7793f1bf44455" | ||
| "sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597", | ||
| "sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df" | ||
| ], | ||
| "markers": "python_version >= '3'", | ||
| "version": "==2.0.10" | ||
| "markers": "python_full_version >= '3.5.0'", | ||
| "version": "==2.0.12" | ||
| }, | ||
@@ -133,3 +134,3 @@ "idna": { | ||
| ], | ||
| "markers": "python_version >= '3'", | ||
| "markers": "python_full_version >= '3.5.0'", | ||
| "version": "==3.3" | ||
@@ -139,17 +140,17 @@ }, | ||
| "hashes": [ | ||
| "sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61", | ||
| "sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d" | ||
| "sha256:bc7861137fbce630f17b03d3ad02ad0bf978c844f3536d0edda6499dafce2b6f", | ||
| "sha256:d568723a7ebd25875d8d1eaf5dfa068cd2fc8194b2e483d7b1f7c81918dbec6b" | ||
| ], | ||
| "index": "pypi", | ||
| "version": "==2.27.1" | ||
| "version": "==2.28.0" | ||
| }, | ||
| "urllib3": { | ||
| "hashes": [ | ||
| "sha256:000ca7f471a233c2251c6c7023ee85305721bfdf18621ebff4fd17a8653427ed", | ||
| "sha256:0e7c33d9a63e7ddfcb86780aac87befc2fbddf46c58dbb487e0855f7ceec283c" | ||
| "sha256:44ece4d53fb1706f667c9bd1c648f5469a2ec925fcf3a776667042d645472c14", | ||
| "sha256:aabaf16477806a5e1dd19aa41f8c2b7950dd3c746362d7e3223dbe6de6ac448e" | ||
| ], | ||
| "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'", | ||
| "version": "==1.26.8" | ||
| "version": "==1.26.9" | ||
| } | ||
| } | ||
| } |
+1
-1
| Metadata-Version: 1.2 | ||
| Name: funowl | ||
| Version: 0.1.11 | ||
| Version: 0.1.12 | ||
| Summary: Python rendering of the OWL Functional syntax | ||
@@ -5,0 +5,0 @@ Home-page: http://biolink.github.io/hsolbrig |
+1
-1
@@ -16,3 +16,3 @@ ################################################################################ | ||
| rdflib-shim | ||
| rdflib>=5.0.0, !=6.1.* | ||
| rdflib>=5.0.0 | ||
| rfc3987 |
| import logging | ||
| import rdflib | ||
@@ -12,1 +13,6 @@ # Set log level for debugging tests here | ||
| SKIP_LONG_TESTS = True | ||
| # rdflib 6.1.1 has a LONG list of pre-assigned prefixes. This breaks some of our tests and the rdflib | ||
| # community promises to fix it (some day...). For now, we won't run tests on this version | ||
| RDFLIB_PREFIXES_ARE_BROKEN = rdflib.__version__ == "6.1.1" | ||
| PREFIXES_BROKEN_MESSAGE = "rdflib 6.1.1 emits a LOT of prefixes. Test skipped!" |
@@ -9,2 +9,3 @@ import unittest | ||
| from funowl.ontology_document import Ontology, OntologyDocument | ||
| from tests import RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE | ||
| from tests.utils.base import TestBase | ||
@@ -25,2 +26,3 @@ | ||
| class OwlBasicsTestCase(TestBase): | ||
| @unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE) | ||
| def test_ontology_document(self): | ||
@@ -27,0 +29,0 @@ doc = OntologyDocument() |
@@ -7,2 +7,3 @@ import unittest | ||
| from funowl.ontology_document import Ontology, Import, OntologyDocument | ||
| from tests import RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE | ||
| from tests.utils.base import TestBase, A | ||
@@ -24,2 +25,3 @@ | ||
| @unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE) | ||
| def test_ontology_document_prefixes(self): | ||
@@ -37,2 +39,3 @@ doc = OntologyDocument(A, ex=EX) | ||
| @unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE) | ||
| def test_use_case_one(self): | ||
@@ -39,0 +42,0 @@ from rdflib import RDFS, OWL |
@@ -6,2 +6,3 @@ import unittest | ||
| from funowl.prefix_declarations import Prefix, PrefixDeclarations | ||
| from tests import RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE | ||
| from tests.utils.base import TestBase | ||
@@ -21,2 +22,3 @@ | ||
| @unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE) | ||
| def test_default_prefix(self): | ||
@@ -39,2 +41,3 @@ """ Test that None is the correct default prefix """ | ||
| @unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE) | ||
| def test_prefixDeclarations(self): | ||
@@ -41,0 +44,0 @@ pds = PrefixDeclarations() |
@@ -8,3 +8,3 @@ import os | ||
| from funowl.converters.functional_converter import to_python | ||
| from tests import datadir | ||
| from tests import datadir, PREFIXES_BROKEN_MESSAGE, RDFLIB_PREFIXES_ARE_BROKEN | ||
@@ -23,3 +23,6 @@ pizza = os.path.join(datadir, 'pizza.owl') | ||
| self.maxDiff = None | ||
| self.assertEqual(expected, str(doc.to_functional())) | ||
| if RDFLIB_PREFIXES_ARE_BROKEN: | ||
| print(f"TEST SKIPPED {PREFIXES_BROKEN_MESSAGE}") | ||
| else: | ||
| self.assertEqual(expected, str(doc.to_functional())) | ||
| else: | ||
@@ -26,0 +29,0 @@ with open(pizza_fun, 'w') as f: |
@@ -8,2 +8,3 @@ import unittest | ||
| from funowl.writers.FunctionalWriter import FunctionalWriter | ||
| from tests import RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE | ||
@@ -27,2 +28,3 @@ text = """ | ||
| @unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE) | ||
| def test_declaration(self): | ||
@@ -29,0 +31,0 @@ parsed = to_python(text) |
@@ -6,5 +6,7 @@ import unittest | ||
| from funowl import Ontology, DataProperty, OntologyDocument, Class, ClassAssertion, DataPropertyAssertion | ||
| from tests import RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE | ||
| class Issue2TestCase(unittest.TestCase): | ||
| @unittest.skipIf(RDFLIB_PREFIXES_ARE_BROKEN, PREFIXES_BROKEN_MESSAGE) | ||
| def test_cyclic_issue(self): | ||
@@ -11,0 +13,0 @@ # Create relaMath.owl in functional |
+4
-1
| [tox] | ||
| envlist = py38 py39 | ||
| envlist = py37 | ||
| py38 | ||
| py39 | ||
| py310 | ||
@@ -4,0 +7,0 @@ [testenv] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
50519556
0.01%2190
0.09%5242
0.75%