dsp-tools 17.0.0.post26__py3-none-any.whl → 18.0.0__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.

Potentially problematic release.


This version of dsp-tools might be problematic. Click here for more details.

Files changed (46) hide show
  1. dsp_tools/cli/args.py +14 -0
  2. dsp_tools/cli/call_action.py +34 -327
  3. dsp_tools/cli/call_action_files_only.py +74 -0
  4. dsp_tools/cli/call_action_with_network.py +203 -0
  5. dsp_tools/cli/create_parsers.py +71 -11
  6. dsp_tools/cli/utils.py +87 -0
  7. dsp_tools/clients/list_client.py +49 -0
  8. dsp_tools/clients/list_client_live.py +157 -0
  9. dsp_tools/clients/metadata_client.py +4 -4
  10. dsp_tools/clients/metadata_client_live.py +6 -5
  11. dsp_tools/clients/{ontology_client.py → ontology_clients.py} +17 -2
  12. dsp_tools/clients/{ontology_client_live.py → ontology_create_client_live.py} +2 -2
  13. dsp_tools/clients/ontology_get_client_live.py +65 -0
  14. dsp_tools/clients/project_client.py +10 -0
  15. dsp_tools/clients/project_client_live.py +30 -0
  16. dsp_tools/commands/create/create_on_server/cardinalities.py +14 -8
  17. dsp_tools/commands/create/create_on_server/lists.py +150 -0
  18. dsp_tools/commands/create/lists_only.py +45 -0
  19. dsp_tools/commands/create/models/input_problems.py +13 -0
  20. dsp_tools/commands/create/models/parsed_project.py +14 -1
  21. dsp_tools/commands/create/models/rdf_ontology.py +0 -7
  22. dsp_tools/commands/create/models/server_project_info.py +17 -3
  23. dsp_tools/commands/create/parsing/parse_lists.py +45 -0
  24. dsp_tools/commands/create/parsing/parse_project.py +23 -4
  25. dsp_tools/commands/ingest_xmlupload/create_resources/upload_xml.py +4 -0
  26. dsp_tools/commands/project/create/project_create_all.py +17 -13
  27. dsp_tools/commands/project/create/project_create_default_permissions.py +8 -6
  28. dsp_tools/commands/project/create/project_create_ontologies.py +30 -18
  29. dsp_tools/commands/project/legacy_models/listnode.py +0 -30
  30. dsp_tools/commands/validate_data/models/api_responses.py +2 -16
  31. dsp_tools/commands/validate_data/models/input_problems.py +1 -0
  32. dsp_tools/commands/validate_data/prepare_data/prepare_data.py +24 -16
  33. dsp_tools/commands/validate_data/process_validation_report/get_user_validation_message.py +53 -23
  34. dsp_tools/commands/validate_data/sparql/value_shacl.py +1 -1
  35. dsp_tools/commands/validate_data/validate_data.py +11 -3
  36. dsp_tools/commands/xmlupload/upload_config.py +1 -0
  37. dsp_tools/commands/xmlupload/xmlupload.py +1 -0
  38. dsp_tools/error/exceptions.py +8 -0
  39. dsp_tools/resources/start-stack/docker-compose.yml +23 -23
  40. dsp_tools/utils/ansi_colors.py +2 -0
  41. {dsp_tools-17.0.0.post26.dist-info → dsp_tools-18.0.0.dist-info}/METADATA +1 -1
  42. {dsp_tools-17.0.0.post26.dist-info → dsp_tools-18.0.0.dist-info}/RECORD +44 -35
  43. {dsp_tools-17.0.0.post26.dist-info → dsp_tools-18.0.0.dist-info}/WHEEL +1 -1
  44. dsp_tools/commands/project/create/project_create_lists.py +0 -200
  45. dsp_tools/commands/validate_data/api_clients.py +0 -124
  46. {dsp_tools-17.0.0.post26.dist-info → dsp_tools-18.0.0.dist-info}/entry_points.txt +0 -0
@@ -3,7 +3,7 @@ services:
3
3
  api:
4
4
  # on the verge of every deployment, update the "image" value from the "api" value of
5
5
  # https://github.com/dasch-swiss/ops-deploy/blob/main/versions/RELEASE.json
6
- image: daschswiss/knora-api:v32.3.2
6
+ image: daschswiss/knora-api:v32.5.0
7
7
  depends_on:
8
8
  - sipi
9
9
  - db
@@ -28,7 +28,7 @@ services:
28
28
 
29
29
  sipi:
30
30
  # on the verge of every deployment, take the same tag as DSP-API
31
- image: daschswiss/knora-sipi:v32.3.2
31
+ image: daschswiss/knora-sipi:v32.5.0
32
32
  ports:
33
33
  - "1024:1024"
34
34
  volumes:
@@ -41,29 +41,9 @@ services:
41
41
  - KNORA_WEBAPI_KNORA_API_EXTERNAL_PORT=3333
42
42
  command: --config=/sipi/config/sipi.docker-config.lua
43
43
 
44
- app:
45
- # on the verge of every deployment, update the "image" value from the "app" value of
46
- # https://github.com/dasch-swiss/ops-deploy/blob/main/versions/RELEASE.json
47
- image: daschswiss/dsp-app:v11.47.2
48
- volumes:
49
- - ./dsp-app-config.json:/public/config/config.prod.json
50
- ports:
51
- - "4200:4200"
52
-
53
- db:
54
- # on the verge of every deployment, update the "image" value from the "db" value of
55
- # https://github.com/dasch-swiss/ops-deploy/blob/main/versions/RELEASE.json
56
- image: daschswiss/apache-jena-fuseki:5.5.0-2
57
- ports:
58
- - "3030:3030"
59
- environment:
60
- - TZ=Europe/Zurich
61
- - ADMIN_PASSWORD=test
62
- - JVM_ARGS=-Xmx3G
63
-
64
44
  ingest:
65
45
  # on the verge of every deployment, take the same tag as DSP-API
66
- image: daschswiss/dsp-ingest:v32.3.2
46
+ image: daschswiss/dsp-ingest:v32.5.0
67
47
  ports:
68
48
  - "3340:3340"
69
49
  volumes:
@@ -84,5 +64,25 @@ services:
84
64
  - DB_JDBC_URL=jdbc:sqlite:/opt/db/ingest.sqlite
85
65
  - DSP_API_URL=http://host.docker.internal:3333
86
66
 
67
+ app:
68
+ # on the verge of every deployment, update the "image" value from the "app" value of
69
+ # https://github.com/dasch-swiss/ops-deploy/blob/main/versions/RELEASE.json
70
+ image: daschswiss/dsp-app:v12.1.2
71
+ volumes:
72
+ - ./dsp-app-config.json:/public/config/config.prod.json
73
+ ports:
74
+ - "4200:4200"
75
+
76
+ db:
77
+ # on the verge of every deployment, update the "image" value from the "db" value of
78
+ # https://github.com/dasch-swiss/ops-deploy/blob/main/versions/RELEASE.json
79
+ image: daschswiss/apache-jena-fuseki:5.5.0-3
80
+ ports:
81
+ - "3030:3030"
82
+ environment:
83
+ - TZ=Europe/Zurich
84
+ - ADMIN_PASSWORD=test
85
+ - JVM_ARGS=-Xmx3G
86
+
87
87
  volumes:
88
88
  ingest-db:
@@ -12,6 +12,8 @@ SEQUENCE_END = "m"
12
12
  # reset to the default setting of the console
13
13
  RESET_TO_DEFAULT = f"{SEQUENCE_START}0{SEQUENCE_END}"
14
14
 
15
+ BOLD = f"{SEQUENCE_START}1{SEQUENCE_END}" # 1 (bold) ; 32 (green)
16
+
15
17
  # If you want to change for example both the text color and the background color you can combine the sequences
16
18
  # for example: BACKGROUND_BOLD_MAGENTA + YELLOW -> magenta background with yellow text
17
19
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dsp-tools
3
- Version: 17.0.0.post26
3
+ Version: 18.0.0
4
4
  Summary: DSP-TOOLS is a Python package with a command line interface that helps you interact with a DaSCH service platform (DSP) server.
5
5
  Author: DaSCH - Swiss National Data and Service Center for the Humanities
6
6
  Author-email: DaSCH - Swiss National Data and Service Center for the Humanities <info@dasch.swiss>
@@ -1,9 +1,12 @@
1
1
  dsp_tools/__init__.py,sha256=XdzLhY_8FUFmPtUEawAvEA8apQ_jlgspb2HpmNjlDV8,158
2
2
  dsp_tools/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- dsp_tools/cli/args.py,sha256=tS16NvgIMdQuaDWb0cNC8TIK7wY-i4pQe7NFYrzt5Bo,694
4
- dsp_tools/cli/call_action.py,sha256=2yBnZqNPWy0swC-YTA_CvhPOMh0cKBUHgQXPFGfDpvU,13826
5
- dsp_tools/cli/create_parsers.py,sha256=zi0E7AHV25B_wXt_8Jcan0Tc6y7aG0vipS5rya5gP9s,17764
3
+ dsp_tools/cli/args.py,sha256=qUoEQVULA3eaCkI1xSdEhEcM26rku0lejnjSnKoevGU,1038
4
+ dsp_tools/cli/call_action.py,sha256=l6pmY1SckKMkh-Y0DW1Aij2IR_D91uoe078fsruXkIQ,3275
5
+ dsp_tools/cli/call_action_files_only.py,sha256=T0A51uN4pClcLaDv_eREZMwEshAIlHMyEDPOOqZIOKg,2630
6
+ dsp_tools/cli/call_action_with_network.py,sha256=nEP60rXWZy_z4tkz5ed6DDOEkHMkXVuyheeNZQogjFs,8556
7
+ dsp_tools/cli/create_parsers.py,sha256=UgHp3_3siQoLe1GdFTLn2ya8Vjumf-NibT0Rd58UxuY,19567
6
8
  dsp_tools/cli/entry_point.py,sha256=gdexHqVDAy8_Atf0oUxvPVQyDGWUSUhio396U5Oc0RI,10331
9
+ dsp_tools/cli/utils.py,sha256=57Bmv33A61YHcWDDm2zGOsjEuB_bV6p9FYIdN_42UBs,3072
7
10
  dsp_tools/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
11
  dsp_tools/clients/authentication_client.py,sha256=A9nTlOdUE4Ez0psWX6qXwuypNBAA2eSVfHIEPzRmoCs,267
9
12
  dsp_tools/clients/authentication_client_live.py,sha256=Bnc6-M2r_D8BNoZgKi5Rzc2vrz5RtRhwUNjJF3PrVTQ,1917
@@ -12,26 +15,34 @@ dsp_tools/clients/connection_live.py,sha256=Y0T-F93FFGnY2Z7qHhG56v3Ajg7U7ATq4QHI
12
15
  dsp_tools/clients/fuseki_metrics.py,sha256=Vy_aWOusnzlD0EnbyHZcTtPIpMEfRA_ihtYbysTq7sQ,2059
13
16
  dsp_tools/clients/legal_info_client.py,sha256=itDvGQf1VV1WiH2oHVcH1epSUSdJPRDwdRUvmCw8P4s,742
14
17
  dsp_tools/clients/legal_info_client_live.py,sha256=9nOe8Y-oQRHh4TkD2-tjdxLNNTonQ0i-P6UjCGgIBGA,5987
15
- dsp_tools/clients/metadata_client.py,sha256=Ozlnz8-_lgPHHKPXsRyLDx1ccvBPoIYLbAJcfYnKvXY,610
16
- dsp_tools/clients/metadata_client_live.py,sha256=LKaGCBZTAyJg0JHxrDOkcrb_Z3csNKXHEhKiWlVylis,1739
17
- dsp_tools/clients/ontology_client.py,sha256=bATGyI8YFFCl0yis9beJjGB1ZlJuO_GqYnlB-2ulv94,638
18
- dsp_tools/clients/ontology_client_live.py,sha256=8uWoRxwlCvUHQZYQsQ5XojAlpEAqzIhFNYROQfsNWf4,5367
18
+ dsp_tools/clients/list_client.py,sha256=L1CcbUcmzwkJVKbrbXa7EB2myJ-sCchjZywwuPh2uS8,1118
19
+ dsp_tools/clients/list_client_live.py,sha256=yoznKeBus0gAIERUIjZAbEqGU1CA4AzRRLO48JkrBMU,6198
20
+ dsp_tools/clients/metadata_client.py,sha256=GD4uYXP3kEym59JAqSub61xXDZSmZaQ2lKRF1_MgYS0,623
21
+ dsp_tools/clients/metadata_client_live.py,sha256=SLq2Ssob3TQaTx6PUblD-DeTimSLA4Y6woo6246Fca8,1863
22
+ dsp_tools/clients/ontology_clients.py,sha256=juigGsfZ1uP42gtyEstDzaMfjeKcriS34mgYaFbJW-Y,989
23
+ dsp_tools/clients/ontology_create_client_live.py,sha256=LOz3k2_ZiShEcdarhoscLFjsdMHG85mHGsbRuR7cq7Y,5386
24
+ dsp_tools/clients/ontology_get_client_live.py,sha256=MeTqWVqTBW22wEebulv3R8fDsjvW2_dd-cs0Wqllxe8,2698
25
+ dsp_tools/clients/project_client.py,sha256=1nsp-RLRTqD1ePk824R4XKbAKCWMYwiGR9uzA-0qRqg,243
26
+ dsp_tools/clients/project_client_live.py,sha256=NTnw_DG37YKfAouDExccwt79QHFsT66oPyrY3MXtVSY,1115
19
27
  dsp_tools/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
28
  dsp_tools/commands/create/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
29
  dsp_tools/commands/create/communicate_problems.py,sha256=GdAOiUZevrYFhRINyDMhcbXdUqtGDKb2nEelhdfSFR0,885
22
30
  dsp_tools/commands/create/constants.py,sha256=ZzWNn_zh-0Oy0SJmGivQbcAnQTmwT0akNchZUppXgh0,276
23
31
  dsp_tools/commands/create/create_on_server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
- dsp_tools/commands/create/create_on_server/cardinalities.py,sha256=QW0i6TSNmP-dGS2WSad1np9QHz41-A51ArspuAQZGJg,5260
32
+ dsp_tools/commands/create/create_on_server/cardinalities.py,sha256=bp-3NokfyhpE5ddKTkib9imFpZiMyRKcN-pHK_DHyfo,5518
33
+ dsp_tools/commands/create/create_on_server/lists.py,sha256=y_63BBpALfJKJ-wQfsgINEuevFnRolD07ZWt0Q4yFfA,6195
25
34
  dsp_tools/commands/create/create_on_server/mappers.py,sha256=Lu2DJAICOZu7WP_1UDvyvRAi0T9ZGO88kvx0UfI6v5I,564
35
+ dsp_tools/commands/create/lists_only.py,sha256=pSgl0XykdguR9445QIAvDTTRbsBuicIxgjD-zFQQzD0,2079
26
36
  dsp_tools/commands/create/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
- dsp_tools/commands/create/models/input_problems.py,sha256=Oa8-fQy2FTtmfXzMVdhBE9Cs3PlOgTWga4XmK5QkM7s,665
37
+ dsp_tools/commands/create/models/input_problems.py,sha256=mFww8a-sFBtWvSNxywiQTprTa-74jMkE45K2UqJxFEc,1169
28
38
  dsp_tools/commands/create/models/parsed_ontology.py,sha256=EUuD47SmWXyB74vGdxGwuvRzq1f4_YdciwYmqcEwqWc,815
29
- dsp_tools/commands/create/models/parsed_project.py,sha256=Gnl9gJEm5sNbccYG24cwT4doS-oqh_cywjbqk1V4wZQ,928
30
- dsp_tools/commands/create/models/rdf_ontology.py,sha256=TyXHmblr9j5XZFVqjLT516MrVYPgzjXWvTX4TckEPPk,361
31
- dsp_tools/commands/create/models/server_project_info.py,sha256=k5EVYo8ZJhMMB5XKja9Xl6CFQ_oLRFdRZPjMyj4XmO4,699
39
+ dsp_tools/commands/create/models/parsed_project.py,sha256=wtUicIHhwv324noBNrC8qmA4P8zNzqqR7J04dOdbgo0,1166
40
+ dsp_tools/commands/create/models/rdf_ontology.py,sha256=c51riv5ZwlIIblr9Wn7QStr4AjtO4Bo1-2bPMKSsTH8,226
41
+ dsp_tools/commands/create/models/server_project_info.py,sha256=DtN0TChUh9hPSdt4ENgjJxRoI9CVcFe6NurgF-d5i_I,1134
32
42
  dsp_tools/commands/create/parsing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
+ dsp_tools/commands/create/parsing/parse_lists.py,sha256=iL-ijELdAgk3BZ36dDugfX2vYo9u4cnHCQh9RyPHqdw,2074
33
44
  dsp_tools/commands/create/parsing/parse_ontology.py,sha256=4cqo2wa9wcLBszWXgPrixQgaHYPHfENQbF6dkeBVNiU,4268
34
- dsp_tools/commands/create/parsing/parse_project.py,sha256=CghB-pJ6RcllOP0jn8Hs50kRcxS2Q0iS8A_QNGbjzZU,4005
45
+ dsp_tools/commands/create/parsing/parse_project.py,sha256=wYxy0EDcLMZ8Ie9ET9jc434tU75V7fWenDi9ROwDvoo,4828
35
46
  dsp_tools/commands/create/parsing/parsing_utils.py,sha256=X-ALTAwcQE8dBRiagb_O9D89d7WGvwnq77cNkNZDNpc,1563
36
47
  dsp_tools/commands/create/serialisation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
48
  dsp_tools/commands/create/serialisation/ontology.py,sha256=NK4kjriHs7dt5fXNiIBc1z_mE9szI4YemJ--hkYYeCk,1581
@@ -65,7 +76,7 @@ dsp_tools/commands/ingest_xmlupload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQ
65
76
  dsp_tools/commands/ingest_xmlupload/bulk_ingest_client.py,sha256=i53VPo5bRf6FkGzEuQuZJIzHKO4_aJKkmz3jmIA5q3Y,7617
66
77
  dsp_tools/commands/ingest_xmlupload/create_resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
78
  dsp_tools/commands/ingest_xmlupload/create_resources/apply_ingest_id.py,sha256=AM6nSDKQc0Oqrv2Z0Uyaz8ztcPJrUGnwN5tlpvBzaBg,2579
68
- dsp_tools/commands/ingest_xmlupload/create_resources/upload_xml.py,sha256=jCdie1HYomdzgUVpBryhsj_u0-appvANeoZ4w_0--78,7457
79
+ dsp_tools/commands/ingest_xmlupload/create_resources/upload_xml.py,sha256=atfMF_8yaZ7qJ-ZzWLdLFlFEWvN3uiT3iqkINLUXxSQ,7796
69
80
  dsp_tools/commands/ingest_xmlupload/create_resources/user_information.py,sha256=wR6PGR2DQvPS0YXELzCJ70fvzQnFvIzek3VFWVPoZk0,4883
70
81
  dsp_tools/commands/ingest_xmlupload/ingest_files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
82
  dsp_tools/commands/ingest_xmlupload/ingest_files/ingest_files.py,sha256=ML_k_KyuNOYBcwy6nrqJ077vj72b_a04MbJRy95KPcA,2306
@@ -77,10 +88,9 @@ dsp_tools/commands/ingest_xmlupload/upload_files/upload_files.py,sha256=QXj58UiT
77
88
  dsp_tools/commands/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
78
89
  dsp_tools/commands/project/create/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
79
90
  dsp_tools/commands/project/create/parse_project.py,sha256=xYcFaUtKLZigxDZpD7O2JNueHmy_-Ar1iE2LJe97gos,4081
80
- dsp_tools/commands/project/create/project_create_all.py,sha256=GM1XjpRvGoT79wGO9VF27c8CBdV42dIOhcT3AdKSwzg,24888
81
- dsp_tools/commands/project/create/project_create_default_permissions.py,sha256=CygzQ4rFF6SYUCkSvrO6gkjpINWZh4wjq_2V0PExwso,5990
82
- dsp_tools/commands/project/create/project_create_lists.py,sha256=A9kKe4gVP1Ug869102bRXK5RraZUtGzv5cWyFfK_DEA,7963
83
- dsp_tools/commands/project/create/project_create_ontologies.py,sha256=Ie5WHTKg5S1bRCg3SmmbB1tjem3NwRrX3N32TeAWzyI,19465
91
+ dsp_tools/commands/project/create/project_create_all.py,sha256=9Am3ZjFyKsHAwEAoNl3rCRaFviJDkIQ4AaOYFm_xJgc,25145
92
+ dsp_tools/commands/project/create/project_create_default_permissions.py,sha256=4SPcyEIImW1ek_q94oLTtxndhkDNF_RNw13U_fKXsuM,6144
93
+ dsp_tools/commands/project/create/project_create_ontologies.py,sha256=DlDXJvrdrPpVO6cYyC4DpllYUn8rgQpF6RbRToO7X-A,20067
84
94
  dsp_tools/commands/project/create/project_validate.py,sha256=H5TVvqO5V63roGEde1J0n21twkajy4AkVSDGmZb4Jp8,27443
85
95
  dsp_tools/commands/project/get/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
86
96
  dsp_tools/commands/project/get/get.py,sha256=_5LxbSP5Fi0PyXODjvND3ZC9E_x91yk6Xb6tcldG5j0,6447
@@ -90,7 +100,7 @@ dsp_tools/commands/project/legacy_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5
90
100
  dsp_tools/commands/project/legacy_models/context.py,sha256=hT69iRVpT0RDySe_8LQofvryENuj1jiTgv1mqTMbS8U,12190
91
101
  dsp_tools/commands/project/legacy_models/group.py,sha256=iSfcGZK2w7Zn8Hs4r_GCosSTGqhQNOS1vget-Kw8Isc,8138
92
102
  dsp_tools/commands/project/legacy_models/helpers.py,sha256=pU5jUeeRZnEi9Y_fm0xAayBmpOAxvU8XD9CXwRSFNgA,850
93
- dsp_tools/commands/project/legacy_models/listnode.py,sha256=wqBps8RakCdg19n90yaqRQG4EtzY56eTbXspPA1Jnrs,14932
103
+ dsp_tools/commands/project/legacy_models/listnode.py,sha256=7Uyf4p-SYB_3NXM4bU_1QpBbi3KZjLfeGwXMvS5aksk,13838
94
104
  dsp_tools/commands/project/legacy_models/model.py,sha256=AzxebBc5Y19kPFvsr4cPLWrKxZj6aGeT_te8NkgaRl4,247
95
105
  dsp_tools/commands/project/legacy_models/ontology.py,sha256=uXX0U4FVzx53GIjTyZhCN96oxdSc1Jaq-O818XrsSEc,12557
96
106
  dsp_tools/commands/project/legacy_models/project.py,sha256=TlC-DPvaIxCdhnO82s_92lcC8--JzO840cLzrmrG4Fo,12012
@@ -106,20 +116,19 @@ dsp_tools/commands/resume_xmlupload/resume_xmlupload.py,sha256=MibH5CwQ_nmSzkwJI
106
116
  dsp_tools/commands/start_stack.py,sha256=Dj3fBKVgiF4iEaShhFB8vkcOJdBs8vZMR7uuNDEeeBs,20383
107
117
  dsp_tools/commands/validate_data/CLAUDE.md,sha256=dQYFJtiayYh45kwrtFZWCVDMfPhkqSCTpQ7EUAuO6pc,7733
108
118
  dsp_tools/commands/validate_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
109
- dsp_tools/commands/validate_data/api_clients.py,sha256=8LFiCQMwS22gWXvGo7p4DDtI8YiHfgVLBlmiA9ASaeI,5322
110
119
  dsp_tools/commands/validate_data/constants.py,sha256=Xr9iPYG4kpcgzUSy3ARjKv7dgSuMBVf2R69Uj7trcx0,2509
111
120
  dsp_tools/commands/validate_data/mappers.py,sha256=lA4Zdt2PHb4nvcOTv63oIPTI5Xs-5J2GSr3S1cDlZkM,7749
112
121
  dsp_tools/commands/validate_data/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
113
- dsp_tools/commands/validate_data/models/api_responses.py,sha256=RrHwxyx1o2j9sVCwZktTTSnRXHeathNmQxk2RBxJ93E,920
114
- dsp_tools/commands/validate_data/models/input_problems.py,sha256=WZwM4LitbAuacCQIbwuo3hxaRvbC_iTZYH9lpozMc9I,3221
122
+ dsp_tools/commands/validate_data/models/api_responses.py,sha256=_Zs96nAC3pPY0hkfoJMzhpBZy8V5R1-1J2iJkiKSN7I,753
123
+ dsp_tools/commands/validate_data/models/input_problems.py,sha256=QwUHcqONqveQbXaedKqbpqjpYNHSJbn0zDag0iQrCJg,3323
115
124
  dsp_tools/commands/validate_data/models/rdf_like_data.py,sha256=1TccR7UwC5idgrny6CQoFd-lPGzx7BdI8sorqWxgCv0,3313
116
125
  dsp_tools/commands/validate_data/models/validation.py,sha256=okYFrLhaSQCGfa8A7gR6Wz-nv0xsmyN5LlNgSqfVfG4,2296
117
126
  dsp_tools/commands/validate_data/prepare_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
118
127
  dsp_tools/commands/validate_data/prepare_data/get_rdf_like_data.py,sha256=sU_VmMAvvNsjKkld6Coc_HJLt32nzXOimvKRxIbte-o,11620
119
128
  dsp_tools/commands/validate_data/prepare_data/make_data_graph.py,sha256=TANm9WA_z-oPGkoMIR2BGZrHtAkizDlnK_5WDVxQRoQ,4098
120
- dsp_tools/commands/validate_data/prepare_data/prepare_data.py,sha256=2YLNbk4on0Qf6XE89guf168rsiqvSIibPiSG3laQR6A,7832
129
+ dsp_tools/commands/validate_data/prepare_data/prepare_data.py,sha256=BcmAC8SLAmNS4kGrNOvMxpGQrWPJCVE1f1jDYRpSvYU,8320
121
130
  dsp_tools/commands/validate_data/process_validation_report/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
122
- dsp_tools/commands/validate_data/process_validation_report/get_user_validation_message.py,sha256=fKYeJa2kVbWbynU56shkz3_HoT7cwsLPQhbmVIcTS28,14623
131
+ dsp_tools/commands/validate_data/process_validation_report/get_user_validation_message.py,sha256=W5VYJPs8J3VvJAaFDBGBuCQ3Xtonhn1iRUOxwgO7xV0,16148
123
132
  dsp_tools/commands/validate_data/process_validation_report/query_validation_result.py,sha256=ln7zOq0LgkaVIoTNv2O72Z0tK6WX0UrbwAph-n0tD3E,22299
124
133
  dsp_tools/commands/validate_data/process_validation_report/reformat_validation_results.py,sha256=YGJnYLHhmc_X4I6RqKDgnLClMo_bNVtzRZBER3uLWp8,6556
125
134
  dsp_tools/commands/validate_data/shacl_cli_validator.py,sha256=3PMFLwPgei76GI07lcboPrLYvjmYaHv7pg_dNvF2KlQ,2958
@@ -127,9 +136,9 @@ dsp_tools/commands/validate_data/sparql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5J
127
136
  dsp_tools/commands/validate_data/sparql/cardinality_shacl.py,sha256=V45pljnAx6jvsE1VRDKMZjZ1HdmwoMUnPUCQrQIYHMU,7218
128
137
  dsp_tools/commands/validate_data/sparql/construct_shacl.py,sha256=pB8sHn8FiAEiweeIYHROUAJH0YeCk8NWbzEI98YuEIQ,3553
129
138
  dsp_tools/commands/validate_data/sparql/legal_info_shacl.py,sha256=2yhn5HfCJFJpOTB-3XNWfxP1KwW3zKxDfqPdhN_Sazg,1522
130
- dsp_tools/commands/validate_data/sparql/value_shacl.py,sha256=iEpBm4X-jARhGQU21VDK2KvOtMCHTXJzpm08Dda7x1w,13068
139
+ dsp_tools/commands/validate_data/sparql/value_shacl.py,sha256=uUkOlrMCcqzuVYQTXwTJOJw4RGDTd00y3OtLP41nY2c,13044
131
140
  dsp_tools/commands/validate_data/utils.py,sha256=L3kpuhn46x-OHap9RnN9QwUQjFYpkQFlFXzFKQfy5ZE,1990
132
- dsp_tools/commands/validate_data/validate_data.py,sha256=M7jAzju7NLuCjZikCZk2uvZI00ZRJNvci5Vqfwo2wg0,12908
141
+ dsp_tools/commands/validate_data/validate_data.py,sha256=GKQv0G2pDnB_5wbUghk12wcCWBsc5hoNySsxuQ81C5U,13498
133
142
  dsp_tools/commands/validate_data/validation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
134
143
  dsp_tools/commands/validate_data/validation/check_duplicate_files.py,sha256=8HU7GZkTMXj68WrVTXadtQujjEP_MvkOnQb4iVtEHt4,2228
135
144
  dsp_tools/commands/validate_data/validation/check_for_unknown_classes.py,sha256=Vhr1-nJzd3vzlwSoDJTljY-eFMpFLpTEy_zIEZb5MJs,2966
@@ -178,15 +187,15 @@ dsp_tools/commands/xmlupload/stash/stash_circular_references.py,sha256=EFcROk78B
178
187
  dsp_tools/commands/xmlupload/stash/stash_models.py,sha256=zIYKUyRIGY6SMiQRgA2AozyOKJwEwiq8nyXV06bEMiI,3300
179
188
  dsp_tools/commands/xmlupload/stash/upload_stashed_resptr_props.py,sha256=PTk-d9ZlSxMdrlE2gbd1k5WuHvROFn-e2pYhJJCi5sM,4212
180
189
  dsp_tools/commands/xmlupload/stash/upload_stashed_xml_texts.py,sha256=zMKUa2lx7zZ26bbL6uF-8vVypi8KKLgwBXqF-DADVV4,7460
181
- dsp_tools/commands/xmlupload/upload_config.py,sha256=7OraegsGMSUji_ySjrjp1LOF5NIY2Wt0HIqRGw6gWWI,2539
190
+ dsp_tools/commands/xmlupload/upload_config.py,sha256=4PBjzGIly0yh9k9I8IDYRWo81U1Bfuh5h8XitdzsGQE,2598
182
191
  dsp_tools/commands/xmlupload/write_diagnostic_info.py,sha256=ODjCAdKZyxHYDUhpIVpdEwIzjP-2HFySrzWN6Tddb1A,1281
183
- dsp_tools/commands/xmlupload/xmlupload.py,sha256=8wO6Dg5DO8fM1CL_dw3VL1C2PrymSNxcDUMqxIYc0FE,22267
192
+ dsp_tools/commands/xmlupload/xmlupload.py,sha256=q_xC9CEDSFb4lMmJoECKZrzTGfIWnAgBx0dnGuz33Oo,22373
184
193
  dsp_tools/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
185
194
  dsp_tools/config/logger_config.py,sha256=Bw2Gu5F2d8un_KNk0hvNtV7fvN2TlThqo6gSwqeccOU,2067
186
195
  dsp_tools/config/warnings_config.py,sha256=15_Lt227HLqhdn6v-zJbi1KG9Fo6Zi1_4fp_a-iY72w,1142
187
196
  dsp_tools/error/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
188
197
  dsp_tools/error/custom_warnings.py,sha256=7C2DscIz9k7IfM8uebIsKWPcWcSjwpDqbIRDaPw7bI8,1053
189
- dsp_tools/error/exceptions.py,sha256=jaKZE1aDWavHPIjYxc_upK9_tcPPEpaCd7PaIPuazNQ,5131
198
+ dsp_tools/error/exceptions.py,sha256=CjP6zUqODKH5qw9XEo-v3gJcP3Pct0bZ-UbYrIahu-I,5321
190
199
  dsp_tools/error/problems.py,sha256=DotzVg3MYvMJmernd9tTBmDHoT1MOkHdiWVv8iMoFSk,265
191
200
  dsp_tools/error/xmllib_errors.py,sha256=DpYCsBIx_GmsBAUlfk2VMqtzD5IGMRbd2yXTcrJFHR4,549
192
201
  dsp_tools/error/xmllib_warnings.py,sha256=sS9jJXGJtQqCiJ9P2zCM5gpIhTpChbujQz_fPvxLm8g,1557
@@ -204,7 +213,7 @@ dsp_tools/resources/schema/properties-only.json,sha256=a2APFD6mTiaM15VMktN2eZr6L
204
213
  dsp_tools/resources/schema/resources-only.json,sha256=PCCaZZ1vGEZdgwFcx9iGvNYbQywH_vImG8sDqu_OVQ0,4207
205
214
  dsp_tools/resources/start-stack/docker-compose.override-host.j2,sha256=ev36TSCZ7xFpnb7Fcw-s3iQLJkweHhNP2k3golvqcbs,255
206
215
  dsp_tools/resources/start-stack/docker-compose.override.yml,sha256=YsoEIWH6U2-M9wV5MkHR_xGpIppP3SDB8xDVWcVg3no,213
207
- dsp_tools/resources/start-stack/docker-compose.yml,sha256=qG9v49wq7iIl3XtCHzHV1c2yIP3vP1wJrsjBLi3--yA,2945
216
+ dsp_tools/resources/start-stack/docker-compose.yml,sha256=QxQe9F5ooWQsg3Rkg92hIqcF9GkBi-tl7zQA6Jfu1bM,2944
208
217
  dsp_tools/resources/start-stack/dsp-app-config.json,sha256=s1LZ81ch63mnQxQjldkaV7-3a_42xvxPmnuCvvPCB5c,584
209
218
  dsp_tools/resources/start-stack/dsp-app-config.override-host.j2,sha256=cVz6ybmJBcgF1FG7y6P4XjzbpMxqC6qKlrbcqAMOB2I,616
210
219
  dsp_tools/resources/validate_data/api-shapes-resource-cardinalities.ttl,sha256=xBG6zH9h6qakDeE7Yj28NmHvWpg-vYQ4k5e64WRdKn8,6861
@@ -212,7 +221,7 @@ dsp_tools/resources/validate_data/api-shapes.ttl,sha256=irPS80i3CEH4qUuokS5Y4jRs
212
221
  dsp_tools/resources/validate_data/shacl-cli-image.yml,sha256=xqjLfZOq1PbNFN9pfq4wN4Y1eSvkhHL6hbvY59uP2pM,125
213
222
  dsp_tools/resources/validate_data/validate-ontology.ttl,sha256=bPRUlPWJ4GQKzXWM3eKgs3pwcak-crDUeMp8g2j6xzU,4341
214
223
  dsp_tools/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
215
- dsp_tools/utils/ansi_colors.py,sha256=p2vq-wzfmE-wdDddvC26UcOA6Z1qhFTdzP0dPoW4sy0,1691
224
+ dsp_tools/utils/ansi_colors.py,sha256=aCMfANQ8lNtuJ33WgjNkTegI26ISGq8MElrLXrJua4s,1759
216
225
  dsp_tools/utils/data_formats/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
217
226
  dsp_tools/utils/data_formats/date_util.py,sha256=VLNQnSsUX6NB1IY3Ry5KCxCLgHHYN0TSSBRn8hyXN-4,4714
218
227
  dsp_tools/utils/data_formats/iri_util.py,sha256=oFcc3gcikmgJOf7iMhT4tfdUQg9wE7lUW5aysfHjylM,1030
@@ -260,7 +269,7 @@ dsp_tools/xmllib/models/res.py,sha256=c3edvilYZVDmv2O6Z36sSkHXcuKPAJLfWVpStDTMuJ
260
269
  dsp_tools/xmllib/models/root.py,sha256=x8_vrDSJ1pZUJUL8LR460dZe4Cg57G_Hy-Zfr2S29dw,13562
261
270
  dsp_tools/xmllib/value_checkers.py,sha256=Yx3r6_WoZ5Lev8Orp8yDzd03JvP2GBmFNSFT2dzrycM,10712
262
271
  dsp_tools/xmllib/value_converters.py,sha256=WMYS5hd1VlrLLBXnf6pv9yYoPBsv_2MxOO6xv-QsRW4,29218
263
- dsp_tools-17.0.0.post26.dist-info/WHEEL,sha256=M6du7VZflc4UPsGphmOXHANdgk8zessdJG0DBUuoA-U,78
264
- dsp_tools-17.0.0.post26.dist-info/entry_points.txt,sha256=qjRfEbkeAwLU_AE2Q-l4Y9irPNmu4Wna-3bfRp1bqV4,62
265
- dsp_tools-17.0.0.post26.dist-info/METADATA,sha256=MVoGCBmqa_mR3gpWNETKJMEoBPX8YmBK0wOG_hr-UQs,4285
266
- dsp_tools-17.0.0.post26.dist-info/RECORD,,
272
+ dsp_tools-18.0.0.dist-info/WHEEL,sha256=UH59_qNuDUAa1VxQvC6fxmbl24EMw6DOIlT1yp8oeuU,78
273
+ dsp_tools-18.0.0.dist-info/entry_points.txt,sha256=qjRfEbkeAwLU_AE2Q-l4Y9irPNmu4Wna-3bfRp1bqV4,62
274
+ dsp_tools-18.0.0.dist-info/METADATA,sha256=j79Vnn6Ab7AjQuCuUpihzCmWwGbUtdsb0Q8zxmTANc8,4278
275
+ dsp_tools-18.0.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: uv 0.9.5
2
+ Generator: uv 0.9.6
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,200 +0,0 @@
1
- from typing import Any
2
- from typing import Optional
3
- from typing import Union
4
-
5
- from loguru import logger
6
-
7
- from dsp_tools.cli.args import ServerCredentials
8
- from dsp_tools.clients.authentication_client_live import AuthenticationClientLive
9
- from dsp_tools.clients.connection import Connection
10
- from dsp_tools.clients.connection_live import ConnectionLive
11
- from dsp_tools.commands.project.create.project_validate import validate_project
12
- from dsp_tools.commands.project.legacy_models.listnode import ListNode
13
- from dsp_tools.commands.project.legacy_models.project import Project
14
- from dsp_tools.error.exceptions import BaseError
15
- from dsp_tools.error.exceptions import InputError
16
- from dsp_tools.utils.json_parsing import parse_json_input
17
-
18
-
19
- def create_lists_on_server(
20
- lists_to_create: list[dict[str, Any]],
21
- con: Connection,
22
- project_remote: Project,
23
- ) -> tuple[dict[str, Any], bool]:
24
- """
25
- Creates the "lists" section of a JSON project definition on a DSP server.
26
- If a list with the same name is already existing in this project on the DSP server, this list is skipped.
27
- If a node or an entire list cannot be created, an error message is printed, but the process continues.
28
-
29
- Args:
30
- lists_to_create: "lists" section of a JSON project definition
31
- con: connection to the DSP server
32
- project_remote: representation of the project on the DSP server
33
-
34
- Raises:
35
- BaseError: if one of the lists to be created already exists on the DSP server, but it has no name
36
-
37
- Returns:
38
- tuple consisting of the IRIs of the list nodes and the success status (True if everything went well)
39
- """
40
-
41
- overall_success = True
42
-
43
- # retrieve existing lists
44
- try:
45
- existing_lists = ListNode.getAllLists(con=con, project_iri=project_remote.iri)
46
- except BaseError:
47
- err_msg = "Unable to retrieve existing lists on DSP server. Cannot check if your lists are already existing."
48
- print(f"WARNING: {err_msg}")
49
- logger.exception(err_msg)
50
- existing_lists = []
51
- overall_success = False
52
-
53
- current_project_lists: dict[str, Any] = {}
54
- for new_lst in lists_to_create:
55
- if existing_lst := [x for x in existing_lists if x.project == project_remote.iri and x.name == new_lst["name"]]:
56
- existing_list_name = existing_lst[0].name
57
- if not existing_list_name:
58
- raise BaseError(f"Node {existing_lst[0]} has no name.")
59
- current_project_lists[existing_list_name] = {
60
- "id": existing_lst[0].iri,
61
- "nodes": new_lst["nodes"],
62
- }
63
- print(f" WARNING: List '{new_lst['name']}' already exists on the DSP server. Skipping...")
64
- overall_success = False
65
- continue
66
-
67
- created_list, success = _create_list_node(con=con, project=project_remote, node=new_lst)
68
- current_project_lists.update(created_list)
69
- if not success:
70
- overall_success = False
71
- print(f" Created list '{new_lst['name']}'.")
72
-
73
- return current_project_lists, overall_success
74
-
75
-
76
- def _create_list_node(
77
- con: Connection,
78
- project: Project,
79
- node: dict[str, Any],
80
- parent_node: Optional[ListNode] = None,
81
- ) -> tuple[dict[str, Any], bool]:
82
- """
83
- Creates a list node on the DSP server, recursively scanning through all its subnodes, creating them as well.
84
- If a node cannot be created, an error message is printed, but the process continues.
85
-
86
- Args:
87
- con: connection to the DSP server
88
- project: project that holds the list where this node should be added to
89
- node: the node to be created
90
- parent_node: parent node of the node to be created (optional)
91
-
92
- Returns:
93
- Returns a tuple consisting of a dict and a bool.
94
- The dict contains the IRIs of the created list nodes,
95
- nested according to their hierarchy structure,
96
- i.e. ``{nodename: {"id": IRI, "nodes": {...}}}``.
97
- The bool is True if all nodes could be created,
98
- False if any node could not be created.
99
-
100
- Raises:
101
- BaseError: if the created node has no name
102
- """
103
- new_node: ListNode = ListNode(
104
- con=con,
105
- project=project,
106
- label=node["labels"],
107
- comments=node.get("comments"),
108
- name=node["name"],
109
- parent=parent_node,
110
- )
111
- try:
112
- new_node = new_node.create()
113
- except BaseError:
114
- print(f"WARNING: Cannot create list node '{node['name']}'.")
115
- logger.exception(f"Cannot create list node '{node['name']}'.")
116
- return {}, False
117
-
118
- # if node has child nodes, call the method recursively
119
- if node.get("nodes"):
120
- overall_success = True
121
- subnode_list = []
122
- for subnode in node["nodes"]:
123
- created_subnode, success = _create_list_node(con=con, project=project, node=subnode, parent_node=new_node)
124
- subnode_list.append(created_subnode)
125
- if not success:
126
- overall_success = False
127
- if not new_node.name:
128
- raise BaseError(f"Node {new_node} has no name.")
129
- return {new_node.name: {"id": new_node.iri, "nodes": subnode_list}}, overall_success
130
- else:
131
- if not new_node.name:
132
- raise BaseError(f"Node {new_node} has no name.")
133
- return {new_node.name: {"id": new_node.iri}}, True
134
-
135
-
136
- def create_only_lists(
137
- project_file_as_path_or_parsed: Union[str, dict[str, Any]],
138
- creds: ServerCredentials,
139
- ) -> tuple[dict[str, Any], bool]:
140
- """
141
- This function accepts a JSON project definition,
142
- connects to a DSP server,
143
- and uploads the "lists" section to the server.
144
-
145
- The project must already exist on the DSP server.
146
- If a list with the same name is already existing in this project on the DSP server, this list is skipped.
147
-
148
- Args:
149
- project_file_as_path_or_parsed: path to the JSON project definition, or parsed JSON object
150
- creds: credentials to connect to the DSP server
151
-
152
- Raises:
153
- InputError:
154
- - if the project cannot be read from the server
155
- - if the connection to the DSP server cannot be established
156
-
157
- BaseError:
158
- - if the input is invalid
159
- - if a problem occurred while trying to expand the Excel files
160
- - if the JSON file is invalid according to the schema
161
-
162
- Returns:
163
- Returns a tuple consisting of a dict and a bool.
164
- The dict contains the IRIs of the created list nodes,
165
- nested according to their hierarchy structure,
166
- i.e. ``{nodename: {"id": IRI, "nodes": {...}}}``.
167
- If there are no lists in the project definition,
168
- an empty dictionary is returned.
169
- The bool indicates if everything went smoothly during the process.
170
- If a warning or error occurred (e.g. one of the lists already exists,
171
- or one of the nodes could not be created),
172
- it is False.
173
- """
174
- project_definition = parse_json_input(project_file_as_path_or_parsed=project_file_as_path_or_parsed)
175
- if not project_definition.get("project", {}).get("lists"):
176
- return {}, True
177
- validate_project(project_definition)
178
- print("JSON project file is syntactically correct and passed validation.")
179
-
180
- auth = AuthenticationClientLive(creds.server, creds.user, creds.password)
181
- con = ConnectionLive(creds.server, auth)
182
-
183
- # retrieve the project
184
- shortcode = project_definition["project"]["shortcode"]
185
- project_local = Project(con=con, shortcode=shortcode)
186
- try:
187
- project_remote = project_local.read()
188
- except BaseError:
189
- err_msg = f"Unable to create the lists: The project {shortcode} cannot be found on the DSP server."
190
- logger.exception(err_msg)
191
- raise InputError(err_msg) from None
192
-
193
- # create new lists
194
- current_project_lists, success = create_lists_on_server(
195
- lists_to_create=project_definition["project"]["lists"],
196
- con=con,
197
- project_remote=project_remote,
198
- )
199
-
200
- return current_project_lists, success
@@ -1,124 +0,0 @@
1
- from dataclasses import dataclass
2
- from typing import Any
3
- from typing import cast
4
- from urllib.parse import quote_plus
5
-
6
- import requests
7
-
8
- from dsp_tools.commands.validate_data.models.api_responses import OneList
9
- from dsp_tools.commands.validate_data.models.api_responses import OneNode
10
- from dsp_tools.error.exceptions import InternalError
11
- from dsp_tools.utils.request_utils import RequestParameters
12
- from dsp_tools.utils.request_utils import log_request
13
- from dsp_tools.utils.request_utils import log_response
14
-
15
-
16
- @dataclass
17
- class OntologyClient:
18
- api_url: str
19
- shortcode: str
20
-
21
- def get_knora_api(self) -> str:
22
- url = f"{self.api_url}/ontology/knora-api/v2#"
23
- headers = {"Accept": "text/turtle"}
24
- timeout = 60
25
- log_request(RequestParameters("GET", url, timeout=timeout, headers=headers))
26
- response = requests.get(url=url, headers=headers, timeout=timeout)
27
- log_response(response, include_response_content=False)
28
- if not response.ok:
29
- raise InternalError(f"Failed Request: {response.status_code} {response.text}")
30
- return response.text
31
-
32
- def get_ontologies(self) -> tuple[list[str], list[str]]:
33
- """
34
- Returns a list of project ontologies as a string in turtle format.
35
- And a list of the ontology IRIs
36
-
37
- Returns:
38
- list of ontologies and IRIs
39
- """
40
- ontology_iris = self._get_ontology_iris()
41
- ontologies = [self._get_one_ontology(x) for x in ontology_iris]
42
- return ontologies, ontology_iris
43
-
44
- def _get_ontology_iris(self) -> list[str]:
45
- url = f"{self.api_url}/admin/projects/shortcode/{self.shortcode}"
46
- timeout = 10
47
- log_request(RequestParameters("GET", url, timeout=timeout))
48
- response = requests.get(url=url, timeout=timeout)
49
- log_response(response)
50
- if not response.ok:
51
- raise InternalError(f"Failed Request: {response.status_code} {response.text}")
52
- response_json = cast(dict[str, Any], response.json())
53
- if not (ontos := response_json.get("project", {}).get("ontologies")):
54
- raise InternalError(f"The response from the API does not contain any ontologies.\nResponse:{response.text}")
55
- output = cast(list[str], ontos)
56
- return output
57
-
58
- def _get_one_ontology(self, ontology_iri: str) -> str:
59
- url = ontology_iri
60
- headers = {"Accept": "text/turtle"}
61
- timeout = 30
62
- log_request(RequestParameters("GET", url, timeout=timeout, headers=headers))
63
- response = requests.get(url=url, headers=headers, timeout=timeout)
64
- log_response(response, include_response_content=False)
65
- if not response.ok:
66
- raise InternalError(f"Failed Request: {response.status_code} {response.text}")
67
- return response.text
68
-
69
-
70
- @dataclass
71
- class ListClient:
72
- """Client to request and reformat the lists of a project."""
73
-
74
- api_url: str
75
- shortcode: str
76
-
77
- def get_lists(self) -> list[OneList]:
78
- list_json = self._get_all_list_iris()
79
- all_iris = self._extract_list_iris(list_json)
80
- all_lists = [self._get_one_list(iri) for iri in all_iris]
81
- return [self._reformat_one_list(lst) for lst in all_lists]
82
-
83
- def _get_all_list_iris(self) -> dict[str, Any]:
84
- url = f"{self.api_url}/admin/lists?projectShortcode={self.shortcode}"
85
- timeout = 10
86
- log_request(RequestParameters("GET", url, timeout))
87
- response = requests.get(url=url, timeout=timeout)
88
- log_response(response)
89
- if not response.ok:
90
- raise InternalError(f"Failed Request: {response.status_code} {response.text}")
91
- json_response = cast(dict[str, Any], response.json())
92
- return json_response
93
-
94
- def _extract_list_iris(self, response_json: dict[str, Any]) -> list[str]:
95
- return [x["id"] for x in response_json["lists"]]
96
-
97
- def _get_one_list(self, list_iri: str) -> dict[str, Any]:
98
- encoded_list_iri = quote_plus(list_iri)
99
- url = f"{self.api_url}/admin/lists/{encoded_list_iri}"
100
- timeout = 30
101
- log_request(RequestParameters("GET", url, timeout))
102
- response = requests.get(url=url, timeout=timeout)
103
- log_response(response, include_response_content=False)
104
- if not response.ok:
105
- raise InternalError(f"Failed Request: {response.status_code} {response.text}")
106
- response_json = cast(dict[str, Any], response.json())
107
- return response_json
108
-
109
- def _reformat_one_list(self, response_json: dict[str, Any]) -> OneList:
110
- list_name = response_json["list"]["listinfo"]["name"]
111
- list_id = response_json["list"]["listinfo"]["id"]
112
- nodes = response_json["list"]["children"]
113
- all_nodes = []
114
- for child in nodes:
115
- all_nodes.append(OneNode(child["name"], child["id"]))
116
- if node_child := child.get("children"):
117
- self._reformat_children(node_child, all_nodes)
118
- return OneList(list_iri=list_id, list_name=list_name, nodes=all_nodes)
119
-
120
- def _reformat_children(self, list_child: list[dict[str, Any]], current_nodes: list[OneNode]) -> None:
121
- for child in list_child:
122
- current_nodes.append(OneNode(child["name"], child["id"]))
123
- if grand_child := child.get("children"):
124
- self._reformat_children(grand_child, current_nodes)