Skip to content

Commit 0cce548

Browse files
committed
0.1.1017
1 parent 5473af3 commit 0cce548

File tree

10 files changed

+37
-34
lines changed

10 files changed

+37
-34
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: wbdataset
22
Title: Making Datasets Truly Interoperable and Reusable in R with Wikibase
3-
Version: 0.1.1016
3+
Version: 0.1.1017
44
Date: 2024-02-20
55
Authors@R:
66
c(person(given="Daniel", family="Antal",

R/copy_wikidata_item.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ copy_wikidata_item <- function(
6868
qid_equivalence_property <- wikibase_session$qid_equivalence_property
6969
}
7070

71-
if (!is.null(wikibase_session$language)) {
72-
language <- wikibase_session$language
71+
if(!is.null(wikibase_session$language)) {
72+
# overwrite session default if it does not exist
73+
if (is.null(language)) language <- wikibase_session$language
7374
}
74-
if (!is.null(wikibase_session$data_curator)) {
75-
data_curator <- wikibase_session$data_curator
75+
76+
if(!is.null(wikibase_session$data_curator)) {
77+
# overwrite session default if it does not exist
78+
if( is.null(data_curator)) data_curator <- wikibase_session$data_curator
7679
}
7780

7881
if (!is.null(wikibase_session$wikibase_api_url)) {

R/copy_wikidata_property.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,14 @@ copy_wikidata_property <- function(
7171
pid_equivalence_property <- wikibase_session$pid_equivalence_property
7272
}
7373

74-
if (!is.null(wikibase_session$language)) {
75-
language <- wikibase_session$language
74+
if(!is.null(wikibase_session$language)) {
75+
# overwrite session default if it does not exist
76+
if (is.null(language)) language <- wikibase_session$language
7677
}
77-
if (!is.null(wikibase_session$data_curator)) {
78-
data_curator <- wikibase_session$data_curator
78+
79+
if(!is.null(wikibase_session$data_curator)) {
80+
# overwrite session default if it does not exist
81+
if( is.null(data_curator)) data_curator <- wikibase_session$data_curator
7982
}
8083

8184
if (!is.null(wikibase_session$wikibase_api_url)) {
@@ -126,7 +129,7 @@ copy_wikidata_property <- function(
126129
# Timestamping ---------------------------------------------------------------------
127130
action_time <- Sys.time()
128131
# Save the time of running the code
129-
action_timestamp <- action_timestamp_create()
132+
action_timestamp <- wbdataset:::action_timestamp_create()
130133
log_file_name <- paste0("wbdataset_copy_wikibase_item_", action_timestamp, ".csv")
131134

132135

R/create_item.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#' @title Create a property
22
#' @description Creates an item entity on a Wikibase instance with a single
33
#' language labelling and description. New labels and descriptions can be added
4-
#' in further languages later. This is a wrapper for
4+
#' in further language later. This is a wrapper for
55
#' \href{https://www.wikidata.org/w/api.php?action=help&modules=wbeditentity}{MediaWiki
66
#' action=wbeditentity}
77
#' @details Optionally, the function adds an equivalent item to this newly
@@ -83,11 +83,14 @@ create_item <- function(label,
8383
if (!is.null(wikibase_session)) {
8484
# For repeated queries you can add your variables directly or in a list
8585

86-
if(!is.null(wikibase_session$languages)) {
87-
languages <- wikibase_session$languages
86+
if(!is.null(wikibase_session$language)) {
87+
# overwrite session default if it does not exist
88+
if (is.null(language)) language <- wikibase_session$language
8889
}
90+
8991
if(!is.null(wikibase_session$data_curator)) {
90-
data_curator <- wikibase_session$data_curator
92+
# overwrite session default if it does not exist
93+
if( is.null(data_curator)) data_curator <- wikibase_session$data_curator
9194
}
9295

9396
if(!is.null(wikibase_session$wikibase_api_url)) {

R/create_property.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#' @title Create a property
22
#' @description Creates a property entity on a Wikibase instance with a single
33
#' language labelling and description. New labels and descriptions can be added
4-
#' in further languages later. This is a wrapper for
4+
#' in further language later. This is a wrapper for
55
#' \href{https://www.wikidata.org/w/api.php?action=help&modules=wbeditentity}{MediaWiki
66
#' action=wbeditentity}
77
#' @details Optionally, the function adds an equivalent property to this newly
@@ -84,11 +84,13 @@ create_property <- function(label,
8484
if (!is.null(wikibase_session)) {
8585
# For repeated queries you can add your variables directly or in a list
8686

87-
if(!is.null(wikibase_session$languages)) {
88-
languages <- wikibase_session$languages
87+
if(!is.null(wikibase_session$language)) {
88+
# overwrite session default if it does not exist
89+
if (is.null(language)) language <- wikibase_session$language
8990
}
9091
if(!is.null(wikibase_session$data_curator)) {
91-
data_curator <- wikibase_session$data_curator
92+
# overwrite session default if it does not exist
93+
if( is.null(data_curator)) data_curator <- wikibase_session$data_curator
9294
}
9395

9496
if(!is.null(wikibase_session$wikibase_api_url)) {

README.Rmd

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ knitr::opts_chunk$set(
1818
<!-- badges: start -->
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)
21-
[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1016-blue.svg)](https://github.com/dataobservatory-eu/wbdataset)
21+
[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1017-blue.svg)](https://github.com/dataobservatory-eu/wbdataset)
2222
[![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 -->
@@ -35,10 +35,6 @@ devtools::install_github("antaldaniel/dataset")
3535
devtools::install_github("dataobservatory-eu/wbdataset")
3636
```
3737

38-
```{r}
39-
library(wbdataset)
40-
```
41-
4238
## Example
4339

4440
This is a basic example which shows you how to solve a common problem:

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
1010
[![CRAN
1111
status](https://www.r-pkg.org/badges/version/wbdataset)](https://CRAN.R-project.org/package=wbdataset)
12-
[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1016-blue.svg)](https://github.com/dataobservatory-eu/wbdataset)
12+
[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1017-blue.svg)](https://github.com/dataobservatory-eu/wbdataset)
1313
\[![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)
@@ -33,10 +33,6 @@ devtools::install_github("antaldaniel/dataset")
3333
devtools::install_github("dataobservatory-eu/wbdataset")
3434
```
3535

36-
``` r
37-
library(wbdataset)
38-
```
39-
4036
## Example
4137

4238
This is a basic example which shows you how to solve a common problem:

man/create_item.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/create_property.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/start.Rmd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ There are two ways to create items:
7272
paris_item <- copy_wikidata_item(
7373
qid_on_wikidata = "Q90", # check https://www.wikidata.org/wiki/Q90
7474
qid_equivalence_property = NULL, # we will get back to this later
75-
languages = c("en", "fr", "nl"), # select languages with 2-letter codes
75+
language = c("en", "fr", "nl"), # select language with 2-letter codes
7676
wikibase_api_url = "https://reprexbase.eu/jekyll/api.php", # Wikibase address
7777
data_curator = person("Jane", "Doe"), # Your name should go in here !
7878
log_path = tempdir(), # You can add a location where you save log file
@@ -141,7 +141,7 @@ it is saved in `e20`. If the action was successul, which you can check with `e20
141141
capital_cities <- copy_wikidata_property(
142142
qid_on_wikidata = c("Q2807", "Q3114", "Q1490"),
143143
qid_equivalence_property = "P35", # use your Wikibase instance's number
144-
languages = c("en", "nl", "hu", "es" ),
144+
language = c("en", "nl", "hu", "es" ),
145145
wikibase_api_url = "https://reprexbase.eu/jekyll/api.php",
146146
data_curator = person("Joe", "Doe"),
147147
log_path = tempdir(),
@@ -168,7 +168,7 @@ Properties connect new information to your items (nodes.) Such properties need t
168168
p21 <- copy_wikidata_property(
169169
pid_on_wikidata = "P21",
170170
pid_equivalence_property = "P2", # You need to change this to your numbering
171-
languages = c("en", "hu"),
171+
language = c("en", "hu"),
172172
wikibase_api_url = "https://reprexbase.eu/jekyll/api.php",
173173
data_curator = person("Jane", "Doe"), # Replace it with your name
174174
csrf = my_csrf
@@ -257,7 +257,7 @@ You can copy many properties at once, too, but only with the same language, cura
257257
spotify_id_properties <- copy_wikidata_property(
258258
pid_on_wikidata = c("P2207", "P2205", "P8704"),
259259
pid_equivalence_property = "P2", # use the P number on your Wikibase instance
260-
languages = c("en", "nl", "hu" ),
260+
language = c("en", "nl", "hu" ),
261261
wikibase_api_url = "https://reprexbase.eu/jekyll/api.php",
262262
data_curator = person("Jane", "Doe"),
263263
log_path = tempdir(),

0 commit comments

Comments
 (0)