dump-things-pyclient 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl

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.
@@ -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())
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dump-things-pyclient
3
- Version: 0.1.1
3
+ Version: 0.1.2
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
@@ -1,12 +1,13 @@
1
1
  dump_things_pyclient/__init__.py,sha256=cn-U3TRIalN6aYHp1cMBRkQm1x98XBwquLFbgFEIf_Q,113
2
- dump_things_pyclient/communicate.py,sha256=9UtH-pvcOaUWc5HLiDuAxN2qfm-IuKzBO4DvqSDIbeQ,30493
2
+ dump_things_pyclient/communicate.py,sha256=CTkgEigu16BmLrlJScMQKhHLI_W4SywDb4HCwAICWzA,30523
3
3
  dump_things_pyclient/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  dump_things_pyclient/commands/auto_curate.py,sha256=nq3aM5Kyj4f_CPELxsS5PVBCPwc0RvrCbPUCpEOYZu8,6797
5
5
  dump_things_pyclient/commands/get_records.py,sha256=ErNC75ukrMTlOmKz6y1yF9F7HqJ-KdzksH4qMDnXPBI,6969
6
6
  dump_things_pyclient/commands/json2ttl.py,sha256=LDt-F0p3MpXjx9SRiRMyGJo1BrQnnt7U_BJfOLJz8xo,1716
7
+ dump_things_pyclient/commands/post_records.py,sha256=3Q0aPMVtXG6azRzzVa0pBzZYJaAi3VqkLHjGwK0X6To,1503
7
8
  dump_things_pyclient/commands/read_pages.py,sha256=Td94LrXFucGhxfmew5gHieVGVVGfkNKeI-r5c3S15FU,3193
8
- dump_things_pyclient-0.1.1.dist-info/METADATA,sha256=fmuBP-3YgebuPJdbTZ893bEtWgFycPDSsH2BECblbIY,837
9
- dump_things_pyclient-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
- dump_things_pyclient-0.1.1.dist-info/entry_points.txt,sha256=8LekJ3KnljruMHXAvjQa2Or7A26_DO-aoxA78Kgxij8,254
11
- dump_things_pyclient-0.1.1.dist-info/top_level.txt,sha256=Asvruw-SyLoYhWis1CFOx89RGxpjXoTZVGoq4JSGt88,21
12
- dump_things_pyclient-0.1.1.dist-info/RECORD,,
9
+ dump_things_pyclient-0.1.2.dist-info/METADATA,sha256=dagb5n61DoNbMxtOVWlYjHf_Xapjx7TxF1YnXRWuXzY,837
10
+ dump_things_pyclient-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ dump_things_pyclient-0.1.2.dist-info/entry_points.txt,sha256=-LKTUNP6RJWBrzjXY8xdMhQsTS1zgvRsLJpsO7FipmQ,317
12
+ dump_things_pyclient-0.1.2.dist-info/top_level.txt,sha256=Asvruw-SyLoYhWis1CFOx89RGxpjXoTZVGoq4JSGt88,21
13
+ dump_things_pyclient-0.1.2.dist-info/RECORD,,
@@ -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