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.
Files changed (40) hide show
  1. {ontolutils-0.2.16 → ontolutils-0.2.18}/PKG-INFO +1 -1
  2. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/__dev.py +43 -32
  3. ontolutils-0.2.18/ontolutils/namespacelib/__init__.py +23 -0
  4. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/codemeta.py +2 -2
  5. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/m4i.py +2 -2
  6. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/obo.py +2 -2
  7. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/qudt_kind.py +1083 -1083
  8. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/qudt_unit.py +2432 -2432
  9. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/schema.py +2769 -2769
  10. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/ssno.py +1 -1
  11. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils.egg-info/PKG-INFO +1 -1
  12. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils.egg-info/SOURCES.txt +0 -1
  13. {ontolutils-0.2.16 → ontolutils-0.2.18}/setup.cfg +1 -1
  14. ontolutils-0.2.16/ontolutils/namespacelib/__init__.py +0 -10
  15. ontolutils-0.2.16/ontolutils/namespacelib/pivmeta.py +0 -273
  16. {ontolutils-0.2.16 → ontolutils-0.2.18}/LICENSE +0 -0
  17. {ontolutils-0.2.16 → ontolutils-0.2.18}/README.md +0 -0
  18. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/__init__.py +0 -0
  19. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/_version.py +0 -0
  20. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/cache.py +0 -0
  21. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/classes/__init__.py +0 -0
  22. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/classes/decorator.py +0 -0
  23. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/classes/query_util.py +0 -0
  24. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/classes/thing.py +0 -0
  25. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/classes/typing.py +0 -0
  26. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/classes/utils.py +0 -0
  27. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils/namespacelib/_iana_utils.py +0 -0
  28. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils.egg-info/dependency_links.txt +0 -0
  29. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils.egg-info/requires.txt +0 -0
  30. {ontolutils-0.2.16 → ontolutils-0.2.18}/ontolutils.egg-info/top_level.txt +0 -0
  31. {ontolutils-0.2.16 → ontolutils-0.2.18}/pyproject.toml +0 -0
  32. {ontolutils-0.2.16 → ontolutils-0.2.18}/setup.py +0 -0
  33. {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_classes.py +0 -0
  34. {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_decorator.py +0 -0
  35. {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_namespaces.py +0 -0
  36. {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_query.py +0 -0
  37. {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_readme.py +0 -0
  38. {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_typing.py +0 -0
  39. {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_utils.py +0 -0
  40. {ontolutils-0.2.16 → ontolutils-0.2.18}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ontolutils
3
- Version: 0.2.16
3
+ Version: 0.2.18
4
4
  Summary: Utility library for the work with ontologies.
5
5
  Home-page: https://github.com/matthiasprobst/ontology-utils
6
6
  Author: Matthias Probst
@@ -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, None] = None,
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, None] = None,
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
- with open(target_dir / f'{namespace}.py', 'w',
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 = "https://w3id.org/nfdi4ing/metadata4ing#"')
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
- f.write(f'\n {k}: URIRef # {v["keys"]}')
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
- # context_file.unlink()
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
- f.write('"""Auto-generated file. Do not edit!"""\n')
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
- with open(__package_dir__ / '__init__.py', 'a') as f:
312
- m4i()
322
+ m4i()
313
323
 
314
- obo()
324
+ obo()
315
325
 
316
- qudt_unit()
326
+ qudt_unit()
317
327
 
318
- qudt_quantitykind()
328
+ qudt_quantitykind()
319
329
 
320
- pivmeta()
330
+ # pivmeta()
321
331
 
322
- codemeta()
332
+ codemeta()
323
333
 
324
- schema()
334
+ schema()
325
335
 
326
- ssno()
327
- f.write('from .m4i import M4I\n')
328
- f.write('from .obo import OBO\n')
329
- f.write('from .pivmeta import PIVMETA\n')
330
- f.write('from .codemeta import CODEMETA\n')
331
- f.write('from .qudt_unit import QUDT_UNIT\n')
332
- f.write('from .qudt_kind import QUDT_KIND\n')
333
- f.write('from .schema import SCHEMA\n')
334
- f.write('from .ssno import SSNO\n')
335
- f.write('from ._iana_utils import IANA\n')
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.15
11
- # Date: 2024-04-03 22:35:04.151807
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.15
11
- # Date: 2024-04-03 22:34:52.789096
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.15
11
- # Date: 2024-04-03 22:34:54.041082
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']