Skip to content

Commit 7913d8e

Browse files
committed
further assertions for mass copying
1 parent 27fc30e commit 7913d8e

6 files changed

Lines changed: 29 additions & 8 deletions

File tree

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: wbdataset
22
Title: Making Datasets Truly Interoperable and Reusable in R with Wikibase
3-
Version: 0.1.1014
4-
Date: 2024-02-18
3+
Version: 0.1.1015
4+
Date: 2024-02-19
55
Authors@R:
66
c(person(given="Daniel", family="Antal",
77
email= "daniel.antal@dataobservatory.eu",

R/copy_wikidata_item.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ copy_wikidata_item <- function(
460460
time = return_dataframe$time,
461461
logfile = return_dataframe$logfile,
462462
dataset_bibentry = dublincore(
463-
title = "Wikibase Copy Item Log",
463+
title = paste0("Wikibase Copy Item Log (",
464+
strftime(action_time,'%Y-%m-%d %H:%M:%OS0'), ")"),
464465
description = description_text,
465466
creator = data_curator,
466467
dataset_date = Sys.Date())
@@ -479,6 +480,15 @@ copy_wikidata_items <- function( qid_on_wikidata,
479480
log_path,
480481
csrf) {
481482

483+
# Ensure that QIDs are used in the loop ----------------------------
484+
is_qid <- vapply(qid_on_wikidata, is_qid, logical(1))
485+
not_qid <- paste(names(which(!is_qid)), collapse="|")
486+
487+
assertthat::assert_that(
488+
not_qid == "",
489+
msg=paste0("Error copy_wikidata_items(): ", not_qid,
490+
" does not appear to be a QID."))
491+
482492
returned_list <- lapply(
483493
qid_on_wikidata, function(x) {
484494
copy_wikidata_item(

R/copy_wikidata_property.R

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,8 @@ copy_wikidata_property <- function(
454454
time = return_dataframe$time,
455455
logfile = return_dataframe$logfile,
456456
dataset_bibentry = dublincore(
457-
title = "Wikibase Copy Property Log",
457+
title = paste0("Wikibase Copy Property Log (",
458+
strftime(action_time,'%Y-%m-%d %H:%M:%OS0'), ")"),
458459
description = description_text,
459460
creator = data_curator,
460461
dataset_date = Sys.Date())
@@ -473,6 +474,16 @@ copy_wikidata_properties <- function(
473474
log_path,
474475
csrf) {
475476

477+
# Ensure that PIDs are used in the loop ----------------------------
478+
is_pid <- vapply(pid_on_wikidata, is_pid, logical(1))
479+
not_pid <- paste(names(which(!is_pid)), collapse="|")
480+
481+
assertthat::assert_that(
482+
not_pid == "",
483+
msg=paste0("Error copy_wikidata_properties(): ", not_pid,
484+
" does not appear to be a PID."))
485+
486+
476487
returned_list <- lapply(
477488
pid_on_wikidata, function(x) {
478489
copy_wikidata_property(

R/create_property.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ create_property <- function(label,
152152
# Successfully created the property
153153
message("Successfully created item ", created_property_response$entity$id, " (", created_property_response$entity$labels$en$value, ")")
154154

155-
if (is.na(equivalence_property)) {
155+
if (!is.na(equivalence_property)) {
156156
# Add the optional equivalence statement
157157
wikidata_pid_df <- add_id_statement(
158158
qid = created_property_response$entity$id,

README.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ output: github_document
44

55
<!-- README.md is generated from README.Rmd. Please edit that file -->
66

7-
```{r, include = FALSE}
7+
```{r setupreadme, include = FALSE}
88
knitr::opts_chunk$set(
99
collapse = TRUE,
1010
comment = "#>",
@@ -19,7 +19,7 @@ knitr::opts_chunk$set(
1919
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
2020
[![CRAN status](https://www.r-pkg.org/badges/version/wbdataset)](https://CRAN.R-project.org/package=wbdataset)
2121
[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1014-blue.svg)](https://github.com/dataobservatory-eu/wbdataset)
22-
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13972192.svg)]
22+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13972192.svg)
2323
[![Codecov test coverage](https://codecov.io/gh/dataobservatory-eu/wbdataset/graph/badge.svg)](https://app.codecov.io/gh/dataobservatory-eu/wbdataset)
2424
<!-- badges: end -->
2525

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](h
1010
[![CRAN
1111
status](https://www.r-pkg.org/badges/version/wbdataset)](https://CRAN.R-project.org/package=wbdataset)
1212
[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1014-blue.svg)](https://github.com/dataobservatory-eu/wbdataset)
13-
\[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13972192.svg)\]
13+
\[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13972192.svg)
1414
[![Codecov test
1515
coverage](https://codecov.io/gh/dataobservatory-eu/wbdataset/graph/badge.svg)](https://app.codecov.io/gh/dataobservatory-eu/wbdataset)
1616
<!-- badges: end -->

0 commit comments

Comments
 (0)