Skip to content

Commit 0358702

Browse files
authored
Merge pull request #11 from eccenca/feature/fixEmptyIgnoreList
Feature/fix empty ignore list
2 parents c4403b4 + 9a4b742 commit 0358702

File tree

6 files changed

+145
-104
lines changed

6 files changed

+145
-104
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org/)
66

7+
## [3.0.1] 2025-03-13
8+
9+
### Fixed
10+
11+
- Fixed error when "Properties to ignore" field is empty or contains empty lines
12+
13+
### Changed
14+
15+
- Edit warning regarding "Fetch namespace prefixes from prefix.cc" parameter
716

817
## [3.0.0] 2025-03-05
918

cmem_plugin_shapes/doc/shapes_doc.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ If the graph is not imported, the new shapes are not activated and used.
2828

2929
**<a id="parameter_doc_prefix_cc">Fetch namespace prefixes from prefix.cc</a>**
3030

31-
Attempt to fetch namespace prefixes from prefix.cc instead of from the local database. If this fails, fall back on local
32-
database. Prefixes defined in the Corporate Memory project will override prefixes defined in the external database.
33-
34-
WARNING: Enabling this flag reveals information to an external service.
31+
Fetch the list of namespace prefixes from https://prefix.cc instead of using the local prefix database. If unavailable,
32+
fall back to the local database. Prefixes defined in the Corporate Memory project override database prefixes. Enabling this
33+
option exposes your IP address to prefix.cc but no other data is shared. If unsure, keep this option disabled. See
34+
https://prefix.cc/about.
3535

3636
**<a id="parameter_doc_ignore_properties">Properties to ignore</a>**
3737

cmem_plugin_shapes/plugin_shapes.py

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@
4141
PLUGIN_LABEL = "Generate SHACL shapes from data"
4242
TRUE_SET = {"yes", "true", "t", "y", "1"}
4343
FALSE_SET = {"no", "false", "f", "n", "0"}
44+
EXISTING_GRAPH_ADD = "add"
45+
EXISTING_GRAPH_REPLACE = "replace"
46+
EXISTING_GRAPH_STOP = "stop"
47+
EXISTING_GRAPH_PARAMETER_CHOICES = OrderedDict(
48+
{
49+
EXISTING_GRAPH_ADD: "add result to graph",
50+
EXISTING_GRAPH_REPLACE: "replace existing graph with result",
51+
EXISTING_GRAPH_STOP: "stop workflow if output graph exists",
52+
}
53+
)
4454

4555

4656
def format_namespace(iri: str) -> str:
@@ -82,15 +92,7 @@ def str2bool(value: str) -> bool:
8292
description="The knowledge graph the generated shapes will be added to.",
8393
),
8494
PluginParameter(
85-
param_type=ChoiceParameterType(
86-
OrderedDict(
87-
{
88-
"add": "add result to graph",
89-
"replace": "replace existing graph with result",
90-
"stop": "stop workflow if output graph exists",
91-
}
92-
),
93-
),
95+
param_type=ChoiceParameterType(EXISTING_GRAPH_PARAMETER_CHOICES),
9496
name="existing_graph",
9597
label="Handle existing output graph",
9698
description="Add result to the existing graph (add result to graph), overwrite the "
@@ -119,10 +121,11 @@ def str2bool(value: str) -> bool:
119121
param_type=BoolParameterType(),
120122
name="prefix_cc",
121123
label="Fetch namespace prefixes from prefix.cc",
122-
description="Attempt to fetch namespace prefixes from prefix.cc instead of from the "
123-
"local database. If this fails, fall back on local database. Prefixes defined in the "
124-
"Corporate Memory project will override prefixes defined in the external database.",
125-
default_value=False,
124+
description="Fetch the list of namespace prefixes from https://prefix.cc instead of "
125+
"using the local prefix database. If unavailable, fall back to the local database. "
126+
"Prefixes defined in the Corporate Memory project override database prefixes. Enabling "
127+
"this option exposes your IP address to prefix.cc but no other data is shared. If "
128+
"unsure, keep this option disabled. See https://prefix.cc/about.",
126129
advanced=True,
127130
),
128131
PluginParameter(
@@ -149,9 +152,9 @@ def __init__( # noqa: PLR0913
149152
data_graph_iri: str,
150153
shapes_graph_iri: str,
151154
label: str = "",
152-
existing_graph: str = "stop",
155+
existing_graph: str = EXISTING_GRAPH_STOP,
153156
import_shapes: bool = False,
154-
prefix_cc: bool = True,
157+
prefix_cc: bool = False,
155158
ignore_properties: str = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
156159
plugin_provenance: bool = False,
157160
) -> None:
@@ -169,18 +172,21 @@ def __init__( # noqa: PLR0913
169172
self.label = label
170173

171174
existing_graph = existing_graph.lower()
172-
if existing_graph not in ("stop", "replace", "add"):
173-
raise ValueError("Invalid value for parameter 'Handle existing output graph'")
175+
if existing_graph not in EXISTING_GRAPH_PARAMETER_CHOICES:
176+
raise ValueError(
177+
"Invalid value for parameter 'Handle existing output graph'. "
178+
f"Valid options: {', '.join(EXISTING_GRAPH_PARAMETER_CHOICES.keys())}."
179+
)
174180
self.replace = False
175-
if existing_graph == "replace":
181+
if existing_graph == EXISTING_GRAPH_REPLACE:
176182
self.replace = True
177183
self.existing_graph = existing_graph
178184

179185
self.import_shapes = import_shapes
180186
self.prefix_cc = prefix_cc
181187

182188
self.ignore_properties = []
183-
for _ in ignore_properties.split("\n"):
189+
for _ in filter(None, ignore_properties.split("\n")):
184190
if not validators.url(_):
185191
raise ValueError(f"Invalid property IRI ({_}) in parameter 'Properties to ignore'")
186192
self.ignore_properties.append(_)
@@ -598,7 +604,7 @@ def execute(self, inputs: Sequence[Entities], context: ExecutionContext) -> None
598604
self.update_execution_report()
599605
setup_cmempy_user_access(context.user)
600606
graph_exists = self.shapes_graph_iri in [_["iri"] for _ in get_graphs_list()]
601-
if self.existing_graph == "stop" and graph_exists:
607+
if self.existing_graph == EXISTING_GRAPH_STOP and graph_exists:
602608
raise ValueError(f"Graph <{self.shapes_graph_iri}> already exists.")
603609

604610
self.prefixes = self.get_prefixes()

cmem_plugin_shapes/prefix_cc.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,7 @@
10071007
"ftcontent": "http://www.ft.com/ontology/content/",
10081008
"fti": "http://franz.com/ns/allegrograph/2.2/textindex/",
10091009
"ftr": "https://w3id.org/ftr#",
1010+
"fugas": "https://onlyfans.com/sammuwuu/",
10101011
"fun": "http://w3id.org/sparql-generate/fn/",
10111012
"func": "http://www.w3.org/2007/rif-builtin-function#",
10121013
"fuseki": "http://jena.apache.org/fuseki#",
@@ -1413,7 +1414,7 @@
14131414
"ldt": "https://www.w3.org/ns/ldt#",
14141415
"ldvm": "http://linked.opendata.cz/ontology/ldvm/",
14151416
"leak": "http://maco.com/",
1416-
"leaks": "https://cuzin.com/",
1417+
"leaks": "https://onlyfans.com/chelxie/",
14171418
"led": "http://led.kmi.open.ac.uk/term/",
14181419
"legal": "http://www.w3.org/ns/legal#",
14191420
"lemon": "http://lemon-model.net/lemon#",
@@ -1924,6 +1925,7 @@
19241925
"ondc": "http://www.semanticweb.org/ontologies/2012/1/Ontology1329913965202.owl#",
19251926
"one": "https://bioportal.bioontology.org/ontologies/ONE/",
19261927
"onisep": "http://rdf.onisep.fr/resource/",
1928+
"onlyfans": "https://cutt.ly/3ry8LMcK/",
19271929
"ons": "http://purl.obolibrary.org/obo/ONS_",
19281930
"onssprel": "http://www.ordnancesurvey.co.uk/ontology/SpatialRelations/v0.2/SpatialRelations.owl#",
19291931
"ont": "http://purl.org/net/ns/ontology-annot#",
@@ -2069,6 +2071,7 @@
20692071
"part": "http://purl.org/vocab/participation/schema#",
20702072
"particip": "http://purl.org/vocab/participation/schema#",
20712073
"passim": "http://data.lirmm.fr/ontologies/passim#",
2074+
"passport": "https://nepalpassport.gov.np/",
20722075
"pat": "http://purl.org/hpi/patchr#",
20732076
"pato": "http://purl.obolibrary.org/obo/",
20742077
"pattern": "http://www.essepuntato.it/2008/12/pattern#",
@@ -2666,6 +2669,7 @@
26662669
"smithy": "https://awslabs.github.io/smithy/rdf-1.0#",
26672670
"sml": "https://w3id.org/sml/def#",
26682671
"smxm": "http://smxm.ga/",
2672+
"sn": "https://purl.org/supply-network/onto#",
26692673
"snac": "http://socialarchive.iath.virginia.edu/",
26702674
"snarm": "http://rdf.myexperiment.org/ontologies/snarm/",
26712675
"snomedct": "http://purl.bioontology.org/ontology/SNOMEDCT/",
@@ -3355,7 +3359,7 @@
33553359
"xlink": "https://es.scribd.com/doc/79794476/05-Ejercicios-Resueltos-Caja-Negra-y-Recapitulacion/",
33563360
"xlmod": "http://purl.obolibrary.org/obo/XLMOD_",
33573361
"xml": "http://www.w3.org/XML/1998/namespace/",
3358-
"xmlns": "http://xmlns.com/foaf/0.1/",
3362+
"xmlns": "http://www.w3.org/2021/XMLSchema#",
33593363
"xmls": "http://www.w3.org/2001/XMLSchema#",
33603364
"xmp": "http://ns.adobe.com/xap/1.0/",
33613365
"xpo": "http://purl.obolibrary.org/obo/XPO_",

0 commit comments

Comments
 (0)