dump-things-pyclient 0.1.1__tar.gz → 0.1.3__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 (18) hide show
  1. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/PKG-INFO +5 -2
  2. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/dump_things_pyclient/commands/json2ttl.py +11 -4
  3. dump_things_pyclient-0.1.3/dump_things_pyclient/commands/post_records.py +59 -0
  4. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/dump_things_pyclient/commands/read_pages.py +1 -0
  5. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/dump_things_pyclient/communicate.py +1 -0
  6. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/dump_things_pyclient.egg-info/PKG-INFO +5 -2
  7. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/dump_things_pyclient.egg-info/SOURCES.txt +1 -0
  8. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/dump_things_pyclient.egg-info/entry_points.txt +1 -0
  9. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/dump_things_pyclient.egg-info/requires.txt +6 -1
  10. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/pyproject.toml +6 -3
  11. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/README.md +0 -0
  12. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/dump_things_pyclient/__init__.py +0 -0
  13. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/dump_things_pyclient/commands/__init__.py +0 -0
  14. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/dump_things_pyclient/commands/auto_curate.py +0 -0
  15. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/dump_things_pyclient/commands/get_records.py +0 -0
  16. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/dump_things_pyclient.egg-info/dependency_links.txt +0 -0
  17. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/dump_things_pyclient.egg-info/top_level.txt +0 -0
  18. {dump_things_pyclient-0.1.1 → dump_things_pyclient-0.1.3}/setup.cfg +0 -0
@@ -1,12 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dump-things-pyclient
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: A client library and some CLI command for dump-things-services
5
5
  Author-email: Christian Mönch <christian.moench@web.de>
6
6
  Requires-Python: >=3.11
7
7
  Description-Content-Type: text/markdown
8
- Requires-Dist: dump-things-service>=5.3.0
9
8
  Requires-Dist: requests>=2.32.5
9
+ Provides-Extra: ttl
10
+ Requires-Dist: dump-things-service>=5.3.0; extra == "ttl"
11
+ Provides-Extra: tests
12
+ Requires-Dist: pytest>=9.0.1; extra == "tests"
10
13
 
11
14
  # Dump Things Python Client
12
15
 
@@ -5,10 +5,17 @@ import json
5
5
  import re
6
6
  import sys
7
7
 
8
- from dump_things_service.converter import (
9
- Format,
10
- FormatConverter,
11
- )
8
+ # The try-except clause is required because marking scripts as optional does
9
+ # not work. That means, even scripts marked as optional are always installed
10
+ # (see <https://stackoverflow.com/questions/77501716/pyproject-toml-setuptools-how-can-i-specify-optional-scripts-and-modules>)
11
+ try:
12
+ from dump_things_service.converter import (
13
+ Format,
14
+ FormatConverter,
15
+ )
16
+ except ImportError:
17
+ print(f"Please install 'dump-things-pyclient[ttl]' to use this command.")
18
+ sys.exit(0)
12
19
 
13
20
 
14
21
  description = f"""Read JSON records from stdin and convert them to TTL
@@ -0,0 +1,59 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ import os
6
+ import sys
7
+
8
+ from ..communicate import (
9
+ collection_write_record,
10
+ curated_write_record,
11
+ )
12
+
13
+
14
+ def main():
15
+ argument_parser = argparse.ArgumentParser()
16
+ argument_parser.add_argument('base_url')
17
+ argument_parser.add_argument('collection')
18
+ argument_parser.add_argument('cls', metavar='class')
19
+ argument_parser.add_argument('--curated', action='store_true', help='bypass inbox, requires curator token')
20
+
21
+ arguments = argument_parser.parse_args()
22
+
23
+ token = os.environ.get('DUMPTHINGS_TOKEN')
24
+ if token is None:
25
+ print(
26
+ 'WARNING: environment variable DUMPTHINGS_TOKEN not set',
27
+ file=sys.stderr,
28
+ flush=True,
29
+ )
30
+
31
+ if arguments.curated:
32
+ write_record = curated_write_record
33
+ else:
34
+ write_record = collection_write_record
35
+
36
+ posted = False
37
+ for line in sys.stdin:
38
+ record = json.loads(line)
39
+ try:
40
+ write_record(
41
+ service_url=arguments.base_url,
42
+ collection=arguments.collection,
43
+ class_name=arguments.cls,
44
+ record=record,
45
+ token=token,
46
+ )
47
+ except Exception as e:
48
+ print(f'Error: {e}', file=sys.stderr, flush=True)
49
+ else:
50
+ posted = True
51
+ print('.', end='', flush=True)
52
+
53
+ if posted:
54
+ # final newline
55
+ print('')
56
+
57
+
58
+ if __name__ == '__main__':
59
+ sys.exit(main())
@@ -48,6 +48,7 @@ def _main():
48
48
 
49
49
  result = get_paginated(
50
50
  url=arguments.url,
51
+ token=token,
51
52
  first_page=arguments.first_page,
52
53
  page_size=arguments.page_size,
53
54
  last_page=arguments.last_page,
@@ -19,6 +19,7 @@ __all__ = [
19
19
  'JSON',
20
20
  'get_paginated',
21
21
  'get',
22
+ 'collection_get_classes',
22
23
  'collection_delete_record',
23
24
  'collection_read_records',
24
25
  'collection_read_records_of_class',
@@ -1,12 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dump-things-pyclient
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: A client library and some CLI command for dump-things-services
5
5
  Author-email: Christian Mönch <christian.moench@web.de>
6
6
  Requires-Python: >=3.11
7
7
  Description-Content-Type: text/markdown
8
- Requires-Dist: dump-things-service>=5.3.0
9
8
  Requires-Dist: requests>=2.32.5
9
+ Provides-Extra: ttl
10
+ Requires-Dist: dump-things-service>=5.3.0; extra == "ttl"
11
+ Provides-Extra: tests
12
+ Requires-Dist: pytest>=9.0.1; extra == "tests"
10
13
 
11
14
  # Dump Things Python Client
12
15
 
@@ -12,4 +12,5 @@ dump_things_pyclient/commands/__init__.py
12
12
  dump_things_pyclient/commands/auto_curate.py
13
13
  dump_things_pyclient/commands/get_records.py
14
14
  dump_things_pyclient/commands/json2ttl.py
15
+ dump_things_pyclient/commands/post_records.py
15
16
  dump_things_pyclient/commands/read_pages.py
@@ -2,4 +2,5 @@
2
2
  auto-curate = dump_things_pyclient.commands.auto_curate:main
3
3
  get-records = dump_things_pyclient.commands.get_records:main
4
4
  json2ttl = dump_things_pyclient.commands.json2ttl:main
5
+ post-records = dump_things_pyclient.commands.post_records:main
5
6
  read-pages = dump_things_pyclient.commands.read_pages:main
@@ -1,2 +1,7 @@
1
- dump-things-service>=5.3.0
2
1
  requests>=2.32.5
2
+
3
+ [tests]
4
+ pytest>=9.0.1
5
+
6
+ [ttl]
7
+ dump-things-service>=5.3.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dump-things-pyclient"
3
- version = "0.1.1"
3
+ version = "0.1.3"
4
4
  description = "A client library and some CLI command for dump-things-services"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -8,11 +8,13 @@ authors = [
8
8
  {name="Christian Mönch", email="christian.moench@web.de"},
9
9
  ]
10
10
  dependencies = [
11
- "dump-things-service>=5.3.0",
12
11
  "requests>=2.32.5",
13
12
  ]
14
13
 
15
- [dependency-groups]
14
+ [project.optional-dependencies]
15
+ ttl = [
16
+ "dump-things-service>=5.3.0",
17
+ ]
16
18
  tests = [
17
19
  "pytest>=9.0.1",
18
20
  ]
@@ -22,3 +24,4 @@ auto-curate = "dump_things_pyclient.commands.auto_curate:main"
22
24
  read-pages = "dump_things_pyclient.commands.read_pages:main"
23
25
  get-records = "dump_things_pyclient.commands.get_records:main"
24
26
  json2ttl = "dump_things_pyclient.commands.json2ttl:main"
27
+ post-records = "dump_things_pyclient.commands.post_records:main"