ontolutils 0.2.16__tar.gz → 0.2.18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ontolutils-0.2.16 → ontolutils-0.2.18}/PKG-INFO +1 -1
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/__dev.py +43 -32
- ontolutils-0.2.18/ontolutils/namespacelib/__init__.py +23 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/codemeta.py +2 -2
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/m4i.py +2 -2
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/obo.py +2 -2
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/qudt_kind.py +1083 -1083
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/qudt_unit.py +2432 -2432
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/schema.py +2769 -2769
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/ssno.py +1 -1
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils.egg-info/PKG-INFO +1 -1
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils.egg-info/SOURCES.txt +0 -1
- {ontolutils-0.2.16 → ontolutils-0.2.18}/setup.cfg +1 -1
- ontolutils-0.2.16/ontolutils/namespacelib/__init__.py +0 -10
- ontolutils-0.2.16/ontolutils/namespacelib/pivmeta.py +0 -273
- {ontolutils-0.2.16 → ontolutils-0.2.18}/LICENSE +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/README.md +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/__init__.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/_version.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/cache.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/classes/__init__.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/classes/decorator.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/classes/query_util.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/classes/thing.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/classes/typing.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/classes/utils.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/_iana_utils.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils.egg-info/dependency_links.txt +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils.egg-info/requires.txt +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils.egg-info/top_level.txt +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/pyproject.toml +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/setup.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_classes.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_decorator.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_namespaces.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_query.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_readme.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_typing.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_utils.py +0 -0
- {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_version.py +0 -0
|
@@ -12,7 +12,7 @@ import pathlib
|
|
|
12
12
|
import requests
|
|
13
13
|
import warnings
|
|
14
14
|
from rdflib import Graph
|
|
15
|
-
from typing import Iterable, Dict, Union
|
|
15
|
+
from typing import Iterable, Dict, Union, Optional
|
|
16
16
|
|
|
17
17
|
from ontolutils import __version__
|
|
18
18
|
|
|
@@ -21,10 +21,11 @@ __package_dir__ = __this_dir__.parent / 'namespacelib'
|
|
|
21
21
|
|
|
22
22
|
FORCE_DOWNLOAD = True
|
|
23
23
|
|
|
24
|
+
|
|
24
25
|
def generate_namespace_file_from_ttl(namespace: str,
|
|
25
26
|
source: str,
|
|
26
27
|
ns: str,
|
|
27
|
-
target_dir: Union[str, pathlib.Path
|
|
28
|
+
target_dir: Optional[Union[str, pathlib.Path]] = None,
|
|
28
29
|
fail=True):
|
|
29
30
|
"""Generate M4I_NAMESPACE.py file from m4i_context.jsonld
|
|
30
31
|
"""
|
|
@@ -68,9 +69,10 @@ def generate_namespace_file_from_ttl(namespace: str,
|
|
|
68
69
|
|
|
69
70
|
def generate_namespace_file_from_context(namespace: str,
|
|
70
71
|
context_ld: str,
|
|
71
|
-
languages: Dict[str, Iterable[str]] = None,
|
|
72
|
-
target_dir: Union[str, pathlib.Path
|
|
73
|
-
fail=True
|
|
72
|
+
languages: Optional[Dict[str, Iterable[str]]] = None,
|
|
73
|
+
target_dir: Optional[Union[str, pathlib.Path]] = None,
|
|
74
|
+
fail: bool = True,
|
|
75
|
+
filename: Optional[Union[str, pathlib.Path]] = None):
|
|
74
76
|
"""Generate M4I_NAMESPACE.py file from m4i_context.jsonld"""
|
|
75
77
|
languages = languages or {}
|
|
76
78
|
assert isinstance(languages, dict)
|
|
@@ -110,20 +112,28 @@ def generate_namespace_file_from_context(namespace: str,
|
|
|
110
112
|
target_dir = pathlib.Path(target_dir)
|
|
111
113
|
|
|
112
114
|
fields = []
|
|
113
|
-
|
|
115
|
+
|
|
116
|
+
if filename is None:
|
|
117
|
+
filename = target_dir / f'{namespace}.py'
|
|
118
|
+
else:
|
|
119
|
+
filename = pathlib.Path(filename)
|
|
120
|
+
with open(filename, 'w',
|
|
114
121
|
encoding='UTF8') as f:
|
|
115
122
|
f.write('from rdflib.namespace import DefinedNamespace, Namespace\n')
|
|
116
123
|
f.write('from rdflib.term import URIRef\n')
|
|
117
124
|
f.write('\n\nclass LanguageExtension:\n pass')
|
|
118
125
|
f.write(f'\n\nclass {namespace.upper()}(DefinedNamespace):')
|
|
119
|
-
f.write('\n # uri = "
|
|
126
|
+
f.write(f'\n # uri = "{url}"')
|
|
120
127
|
f.write(f'\n # Generated with {__package__} version {__version__}')
|
|
121
128
|
f.write(f'\n # Date: {datetime.datetime.now()}')
|
|
122
129
|
f.write(f'\n _fail = {fail}')
|
|
123
130
|
for k, v in iris.items():
|
|
124
131
|
if k not in fields:
|
|
125
132
|
fields.append(k)
|
|
126
|
-
|
|
133
|
+
if '-' in k:
|
|
134
|
+
f.write(f'\n {k.replace("-", "_")} = URIRef("{url}{k}") # {v["keys"]}')
|
|
135
|
+
else:
|
|
136
|
+
f.write(f'\n {k}: URIRef # {v["keys"]}')
|
|
127
137
|
|
|
128
138
|
f.write(f'\n\n _NS = Namespace("{url}")')
|
|
129
139
|
|
|
@@ -138,14 +148,14 @@ def generate_namespace_file_from_context(namespace: str,
|
|
|
138
148
|
key = kk.replace(' ', '_')
|
|
139
149
|
for lang_key, lang_values in languages.items():
|
|
140
150
|
if key in lang_values:
|
|
141
|
-
f.write(f'\nsetattr({lang_key}, "{key}", {namespace.upper()}.{k})')
|
|
151
|
+
f.write(f'\nsetattr({lang_key}, "{key}", {namespace.upper()}.{k.replace("-", "_")})')
|
|
142
152
|
found_language_key = True
|
|
143
153
|
if not found_language_key:
|
|
144
|
-
f.write(f'\nsetattr({namespace.upper()}, "{key}", {namespace.upper()}.{k})')
|
|
154
|
+
f.write(f'\nsetattr({namespace.upper()}, "{key}", {namespace.upper()}.{k.replace("-", "_")})')
|
|
145
155
|
|
|
146
156
|
for lang in languages:
|
|
147
157
|
f.write(f'\n\nsetattr({namespace.upper()}, "{lang}", {lang})')
|
|
148
|
-
|
|
158
|
+
context_file.unlink(missing_ok=True)
|
|
149
159
|
|
|
150
160
|
|
|
151
161
|
def m4i():
|
|
@@ -281,10 +291,11 @@ def schema():
|
|
|
281
291
|
)
|
|
282
292
|
|
|
283
293
|
|
|
284
|
-
def pivmeta():
|
|
294
|
+
def pivmeta(filename: Union[str, pathlib.Path] = None):
|
|
285
295
|
generate_namespace_file_from_context(
|
|
286
296
|
namespace='pivmeta',
|
|
287
297
|
context_ld='https://raw.githubusercontent.com/matthiasprobst/pivmeta/main/pivmeta_context.jsonld',
|
|
298
|
+
filename=filename
|
|
288
299
|
)
|
|
289
300
|
|
|
290
301
|
|
|
@@ -304,35 +315,35 @@ def codemeta():
|
|
|
304
315
|
|
|
305
316
|
def build_namespace_files():
|
|
306
317
|
"""Call this only if you are a developer and want to build the namespace files"""
|
|
307
|
-
with open(__package_dir__ / '__init__.py', 'w') as f:
|
|
308
|
-
|
|
318
|
+
# with open(__package_dir__ / '__init__.py', 'w') as f:
|
|
319
|
+
# f.write('"""Auto-generated file. Do not edit!"""\n')
|
|
309
320
|
# f.write('from ._version import __version__\n')
|
|
310
321
|
|
|
311
|
-
|
|
312
|
-
m4i()
|
|
322
|
+
m4i()
|
|
313
323
|
|
|
314
|
-
|
|
324
|
+
obo()
|
|
315
325
|
|
|
316
|
-
|
|
326
|
+
qudt_unit()
|
|
317
327
|
|
|
318
|
-
|
|
328
|
+
qudt_quantitykind()
|
|
319
329
|
|
|
320
|
-
|
|
330
|
+
# pivmeta()
|
|
321
331
|
|
|
322
|
-
|
|
332
|
+
codemeta()
|
|
323
333
|
|
|
324
|
-
|
|
334
|
+
schema()
|
|
325
335
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
+
ssno()
|
|
337
|
+
# with open(__package_dir__ / '__init__.py', 'a') as f:
|
|
338
|
+
# f.write('from .m4i import M4I\n')
|
|
339
|
+
# f.write('from .obo import OBO\n')
|
|
340
|
+
# f.write('from .pivmeta import PIVMETA\n')
|
|
341
|
+
# f.write('from .codemeta import CODEMETA\n')
|
|
342
|
+
# f.write('from .qudt_unit import QUDT_UNIT\n')
|
|
343
|
+
# f.write('from .qudt_kind import QUDT_KIND\n')
|
|
344
|
+
# f.write('from .schema import SCHEMA\n')
|
|
345
|
+
# f.write('from .ssno import SSNO\n')
|
|
346
|
+
# f.write('from ._iana_utils import IANA\n')
|
|
336
347
|
|
|
337
348
|
for jld in __package_dir__.glob('*.jsonld'):
|
|
338
349
|
jld.unlink()
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Auto-generated file. Do not edit!"""
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from . import __dev
|
|
5
|
+
from ._iana_utils import IANA
|
|
6
|
+
from .codemeta import CODEMETA
|
|
7
|
+
from .m4i import M4I
|
|
8
|
+
from .obo import OBO
|
|
9
|
+
from .qudt_kind import QUDT_KIND
|
|
10
|
+
from .qudt_unit import QUDT_UNIT
|
|
11
|
+
from .schema import SCHEMA
|
|
12
|
+
from .ssno import SSNO
|
|
13
|
+
from ..cache import package_user_dir
|
|
14
|
+
|
|
15
|
+
# create pivmeta module in local user directory
|
|
16
|
+
__dev.pivmeta(filename=package_user_dir / 'pivmeta.py')
|
|
17
|
+
|
|
18
|
+
sys.path.insert(0, str(package_user_dir))
|
|
19
|
+
|
|
20
|
+
# noinspection PyUnresolvedReferences
|
|
21
|
+
from pivmeta import PIVMETA
|
|
22
|
+
|
|
23
|
+
assert PIVMETA._NS == 'https://matthiasprobst.github.io/pivmeta#'
|
|
@@ -7,8 +7,8 @@ class LanguageExtension:
|
|
|
7
7
|
|
|
8
8
|
class CODEMETA(DefinedNamespace):
|
|
9
9
|
# uri = "https://w3id.org/nfdi4ing/metadata4ing#"
|
|
10
|
-
# Generated with None version 0.2.
|
|
11
|
-
# Date: 2024-04-
|
|
10
|
+
# Generated with None version 0.2.16
|
|
11
|
+
# Date: 2024-04-08 15:01:30.249226
|
|
12
12
|
_fail = True
|
|
13
13
|
softwareSuggestions: URIRef # ['softwareSuggestions']
|
|
14
14
|
contIntegration: URIRef # ['contIntegration']
|
|
@@ -7,8 +7,8 @@ class LanguageExtension:
|
|
|
7
7
|
|
|
8
8
|
class M4I(DefinedNamespace):
|
|
9
9
|
# uri = "https://w3id.org/nfdi4ing/metadata4ing#"
|
|
10
|
-
# Generated with None version 0.2.
|
|
11
|
-
# Date: 2024-
|
|
10
|
+
# Generated with None version 0.2.10
|
|
11
|
+
# Date: 2024-03-24 15:10:44.476048
|
|
12
12
|
_fail = True
|
|
13
13
|
Method: URIRef # ['Methode', 'method']
|
|
14
14
|
NumericalAssignment: URIRef # ['numerical assignment', 'numerische Zuweisung']
|
|
@@ -7,8 +7,8 @@ class LanguageExtension:
|
|
|
7
7
|
|
|
8
8
|
class OBO(DefinedNamespace):
|
|
9
9
|
# uri = "https://w3id.org/nfdi4ing/metadata4ing#"
|
|
10
|
-
# Generated with None version 0.2.
|
|
11
|
-
# Date: 2024-
|
|
10
|
+
# Generated with None version 0.2.10
|
|
11
|
+
# Date: 2024-03-24 15:10:45.600748
|
|
12
12
|
_fail = True
|
|
13
13
|
BFO_0000015: URIRef # ['Prozess', 'process']
|
|
14
14
|
BFO_0000017: URIRef # ['realisierbare Entität', 'realizable entity']
|