udata 10.0.6.dev32964__py2.py3-none-any.whl → 10.0.6.dev32994__py2.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 udata might be problematic. Click here for more details.
- udata/commands/dcat.py +13 -4
- udata/tests/test_dcat_commands.py +26 -0
- {udata-10.0.6.dev32964.dist-info → udata-10.0.6.dev32994.dist-info}/METADATA +2 -2
- {udata-10.0.6.dev32964.dist-info → udata-10.0.6.dev32994.dist-info}/RECORD +8 -7
- {udata-10.0.6.dev32964.dist-info → udata-10.0.6.dev32994.dist-info}/LICENSE +0 -0
- {udata-10.0.6.dev32964.dist-info → udata-10.0.6.dev32994.dist-info}/WHEEL +0 -0
- {udata-10.0.6.dev32964.dist-info → udata-10.0.6.dev32994.dist-info}/entry_points.txt +0 -0
- {udata-10.0.6.dev32964.dist-info → udata-10.0.6.dev32994.dist-info}/top_level.txt +0 -0
udata/commands/dcat.py
CHANGED
|
@@ -2,7 +2,8 @@ import logging
|
|
|
2
2
|
|
|
3
3
|
import click
|
|
4
4
|
import mongoengine
|
|
5
|
-
from rdflib import Graph
|
|
5
|
+
from rdflib import Graph, URIRef
|
|
6
|
+
from rdflib.namespace import RDF
|
|
6
7
|
|
|
7
8
|
from udata.commands import cli, cyan, echo, green, magenta, yellow
|
|
8
9
|
from udata.core.dataset.factories import DatasetFactory
|
|
@@ -12,7 +13,8 @@ from udata.harvest.backends.dcat import (
|
|
|
12
13
|
CswIso19139DcatBackend,
|
|
13
14
|
DcatBackend,
|
|
14
15
|
)
|
|
15
|
-
from udata.
|
|
16
|
+
from udata.harvest.models import HarvestItem
|
|
17
|
+
from udata.rdf import DCAT, DCT, namespace_manager
|
|
16
18
|
|
|
17
19
|
log = logging.getLogger(__name__)
|
|
18
20
|
|
|
@@ -61,15 +63,22 @@ def parse_url(url, csw, iso, quiet=False, rid=""):
|
|
|
61
63
|
backend.job = MockJob()
|
|
62
64
|
format = backend.get_format()
|
|
63
65
|
echo(yellow("Detected format: {}".format(format)))
|
|
64
|
-
graphs = backend.
|
|
66
|
+
graphs = backend.walk_graph(url, format)
|
|
65
67
|
|
|
66
68
|
# serialize/unserialize graph like in the job mechanism
|
|
67
69
|
graph = Graph(namespace_manager=namespace_manager)
|
|
68
|
-
for subgraph in graphs:
|
|
70
|
+
for page_number, subgraph in graphs:
|
|
69
71
|
serialized = subgraph.serialize(format=format, indent=None)
|
|
70
72
|
_subgraph = Graph(namespace_manager=namespace_manager)
|
|
71
73
|
graph += _subgraph.parse(data=serialized, format=format)
|
|
72
74
|
|
|
75
|
+
for node in subgraph.subjects(RDF.type, DCAT.Dataset):
|
|
76
|
+
identifier = subgraph.value(node, DCT.identifier)
|
|
77
|
+
kwargs = {"nid": str(node), "page": page_number}
|
|
78
|
+
kwargs["type"] = "uriref" if isinstance(node, URIRef) else "blank"
|
|
79
|
+
item = HarvestItem(remote_id=str(identifier), kwargs=kwargs)
|
|
80
|
+
backend.job.items.append(item)
|
|
81
|
+
|
|
73
82
|
for item in backend.job.items:
|
|
74
83
|
if not rid or rid in item.remote_id:
|
|
75
84
|
echo(magenta("Processing item {}".format(item.remote_id)))
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@pytest.mark.usefixtures("clean_db")
|
|
5
|
+
class ParseUrlCommandTest:
|
|
6
|
+
def test_parse_url(self, cli, requests_mock, caplog) -> None:
|
|
7
|
+
logs = []
|
|
8
|
+
|
|
9
|
+
def mock_echo(message: str) -> None:
|
|
10
|
+
logs.append(message)
|
|
11
|
+
|
|
12
|
+
local_file: str = "./udata/harvest/tests/dcat/sig.oreme.rdf"
|
|
13
|
+
# This mock_url is to make requests' url parsing happy, but the mock will return the local file content.
|
|
14
|
+
mock_url = "https://example.com/sig.oreme.rdf"
|
|
15
|
+
with open(local_file, "r") as test_rdf_file:
|
|
16
|
+
requests_mock.get(mock_url, text=test_rdf_file.read())
|
|
17
|
+
requests_mock.head(mock_url, text="sig.oreme.rdf")
|
|
18
|
+
dataset_id = "0437a976-cff1-4fa6-807a-c23006df2f8f"
|
|
19
|
+
result = cli(
|
|
20
|
+
"dcat",
|
|
21
|
+
"parse-url",
|
|
22
|
+
mock_url,
|
|
23
|
+
"--rid",
|
|
24
|
+
dataset_id,
|
|
25
|
+
)
|
|
26
|
+
assert "Dataset is valid" in result.stdout
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: udata
|
|
3
|
-
Version: 10.0.6.
|
|
3
|
+
Version: 10.0.6.dev32994
|
|
4
4
|
Summary: Open data portal
|
|
5
5
|
Home-page: https://github.com/opendatateam/udata
|
|
6
6
|
Author: Opendata Team
|
|
@@ -140,7 +140,7 @@ It is collectively taken care of by members of the
|
|
|
140
140
|
|
|
141
141
|
## Current (in progress)
|
|
142
142
|
|
|
143
|
-
-
|
|
143
|
+
- Fix the `parse-url` command [#3225](https://github.com/opendatateam/udata/pull/3225)
|
|
144
144
|
|
|
145
145
|
## 10.0.5 (2024-12-09)
|
|
146
146
|
|
|
@@ -41,7 +41,7 @@ udata/auth/views.py,sha256=PX4bRHATNzPHWu01_KC3mgcZpAEahdcDAJVBhy4oL4Y,6110
|
|
|
41
41
|
udata/commands/__init__.py,sha256=Won_rW_hIU9TA3o4oNe6kI46l1fnDBM_oW0Hc1XS9F8,7711
|
|
42
42
|
udata/commands/cache.py,sha256=bLdrf_fCWFYX9ULlL2ADsZRwijkI4pArsJxfx24OivM,341
|
|
43
43
|
udata/commands/db.py,sha256=x5ui77hoT-JcECneBhhXZtpH4g65gaj7SyeM0bnORhA,14694
|
|
44
|
-
udata/commands/dcat.py,sha256=
|
|
44
|
+
udata/commands/dcat.py,sha256=f6jT2AGZem-w1CaRH_ahfWB9A4oCDvjG13tPmBpeCqw,3910
|
|
45
45
|
udata/commands/fixtures.py,sha256=oZkZPqpBNTjYQwNwODfi-bZyRZIjBIG-gBhpNaaAiNc,9221
|
|
46
46
|
udata/commands/images.py,sha256=0rVojLik5DYgJ6W4uNEfMP2g2QUU2V761tj3z6lo8no,2050
|
|
47
47
|
udata/commands/info.py,sha256=A5WMo3_N_rlt3cySVJrZqKWrbIowX97ZLKMIFQE5178,1545
|
|
@@ -590,6 +590,7 @@ udata/tests/schemas.json,sha256=szM1jDpkogfOG4xWbjIGjLgG8l9-ZyE3JKQtecJyD1E,4990
|
|
|
590
590
|
udata/tests/test_activity.py,sha256=x-pDK6VW9wAG0uxYRZQ3DWTRjfCU729iaMGMJb1rWYU,3195
|
|
591
591
|
udata/tests/test_api_fields.py,sha256=4sDs40CtdarVQHzAdNIeRCOYughYsTlPehTY18jaq58,11293
|
|
592
592
|
udata/tests/test_cors.py,sha256=b_pyxKeIyqhnsXxXryPf4d0V0QxaLQ1P_VjY89Q_j3g,3233
|
|
593
|
+
udata/tests/test_dcat_commands.py,sha256=fDAnAjkja8AXw_qzaAWnVTgglkBAvK2mjPMHUCtqrrU,919
|
|
593
594
|
udata/tests/test_discussions.py,sha256=Qo7nhIUY7YAATZfWl5Mgo0XhngGwFULgqEoMhsHZtFE,33587
|
|
594
595
|
udata/tests/test_i18n.py,sha256=u60344JNRG_8s0t89ghXtQ1FbF4TayEHBzuBFxqnQ_Y,3152
|
|
595
596
|
udata/tests/test_linkchecker.py,sha256=W8jrwKYXM8wWXZFjiaBwpWGRBhZ8bsSHGHzL9voDN7U,10218
|
|
@@ -709,9 +710,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=18Y5YtzVKInDejw-R-45HNzsB3OVwJ
|
|
|
709
710
|
udata/translations/pt/LC_MESSAGES/udata.po,sha256=6IQvFk0NTDV5Jq-kLkkzpioWfrMaLDa1oQSevKFbxKQ,44943
|
|
710
711
|
udata/translations/sr/LC_MESSAGES/udata.mo,sha256=LWzCNS68hS2lbeo1bncZw4ZKqV2Dk_JUC-4SiF3o994,28163
|
|
711
712
|
udata/translations/sr/LC_MESSAGES/udata.po,sha256=X1ieIsJDmk_A_YiblpmUBzWWrVHta9F8yzCZLrjeW-Y,51435
|
|
712
|
-
udata-10.0.6.
|
|
713
|
-
udata-10.0.6.
|
|
714
|
-
udata-10.0.6.
|
|
715
|
-
udata-10.0.6.
|
|
716
|
-
udata-10.0.6.
|
|
717
|
-
udata-10.0.6.
|
|
713
|
+
udata-10.0.6.dev32994.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
|
|
714
|
+
udata-10.0.6.dev32994.dist-info/METADATA,sha256=K82JxoPltu5jwPmaLfNeI-9hhFUXFeCxMl-1upmOxe4,137317
|
|
715
|
+
udata-10.0.6.dev32994.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
|
|
716
|
+
udata-10.0.6.dev32994.dist-info/entry_points.txt,sha256=3SKiqVy4HUqxf6iWspgMqH8d88Htk6KoLbG1BU-UddQ,451
|
|
717
|
+
udata-10.0.6.dev32994.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
|
|
718
|
+
udata-10.0.6.dev32994.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|