Skip to content

Commit 9a8fe83

Browse files
authored
Merge pull request paws-r#960 from DyfanJones/feature/old_r
Bug: nested structures/maps losing attribute
2 parents 98391b4 + 8f0626b commit 9a8fe83

File tree

21 files changed

+1114
-231
lines changed

21 files changed

+1114
-231
lines changed

.github/workflows/unit-tests.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,18 @@ jobs:
9797
remotes::install_local('make.paws', force = TRUE)
9898
shell: Rscript {0}
9999

100-
- name: Check
100+
- name: Check paws.common
101101
env:
102102
_R_CHECK_CRAN_INCOMING_: false
103103
run: |
104104
rcmdcheck::rcmdcheck('paws.common', args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
105+
shell: Rscript {0}
106+
107+
- name: Check make.paws
108+
if: ${{ !(matrix.config.os == 'windows-latest' && matrix.config.R == 'oldrel-4') }}
109+
env:
110+
_R_CHECK_CRAN_INCOMING_: false
111+
run: |
105112
rcmdcheck::rcmdcheck('make.paws', args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
106113
shell: Rscript {0}
107114

@@ -116,5 +123,7 @@ jobs:
116123
shell: Rscript {0}
117124

118125
- name: Get code coverage
126+
if: ${{ !(matrix.config.os == 'windows-latest' && matrix.config.R == 'oldrel-4') }}
119127
run: |
120128
Rscript script/codecov.R paws.common make.paws
129+
shell: bash

make.paws/R/docs.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ make_doc_title <- function(operation) {
5454
# Make the description documentation.
5555
make_doc_desc <- function(operation, api) {
5656
docs <- convert(operation$documentation, package_name(api), links = get_links(api))
57-
if (length(docs) == 1 && docs == "") docs <- get_operation_title(operation)
57+
if (length(docs) == 1 && docs == "") {
58+
docs <- get_operation_title(operation)
59+
}
5860
description <- glue::glue("#' {docs}")
5961
description <- glue::glue_collapse(description, sep = "\n")
6062
description <- paste("#' @description", description, sep = "\n")
@@ -271,7 +273,9 @@ first_paragraph <- function(x) {
271273

272274
# Get the first sentence from a block of text.
273275
first_sentence <- function(x) {
274-
if (is.list(x)) x <- as.character(x)
276+
if (is.list(x)) {
277+
x <- as.character(x)
278+
}
275279
if (length(x) == 1 && x == "") {
276280
return("")
277281
}
@@ -628,7 +632,9 @@ list_to_string <- function(x, quote = TRUE) {
628632
} else {
629633
s <- value
630634
}
631-
if (i > 1) s <- paste0(", ", s)
635+
if (i > 1) {
636+
s <- paste0(", ", s)
637+
}
632638
result <- paste0(result, s)
633639
}
634640
result <- paste0(result, ")")

make.paws/R/interfaces.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ make_interface <- function(name, shape_data, api) {
4444
shape <- make_shape(list(shape = shape_name), api)
4545
shape <- tag_del(shape, c("enum", "min", "max", "pattern"))
4646
for (key in names(shape_data)) {
47-
if (key == "shape") next
47+
if (key == "shape") {
48+
next
49+
}
4850
shape <- tag_add(shape, stats::setNames(shape_data[[key]], key))
4951
}
5052
interface <- render(interface_template, name = name, shape = get_structure(shape))
@@ -114,7 +116,9 @@ make_shape_structure <- function(shape, api, path) {
114116
member <- members[[member_name]]
115117
make_shape(member, api, path)
116118
})
117-
if (!rlang::is_empty(member_names)) names(proto) <- member_names
119+
if (!rlang::is_empty(member_names)) {
120+
names(proto) <- member_names
121+
}
118122
return(proto)
119123
}
120124

make.paws/R/package.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ write_description_category <- function(
4444
)
4545
for (key in names(contents)) {
4646
value <- contents[[key]]
47-
if (length(value) == 0 || is.character(value) && value == "") next
47+
if (length(value) == 0 || is.character(value) && value == "") {
48+
next
49+
}
4850
f$set(key, value)
4951
}
5052
f$normalize()

make.paws/R/read_api.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ read_api <- function(api_name, path) {
77

88
version <- get_latest_api_version(api_name, api_path)
99
files <- get_api_files(version, api_name, api_path)
10-
if (length(version) == 0 || length(files) == 0) stop("Invalid API")
10+
if (length(version) == 0 || length(files) == 0) {
11+
stop("Invalid API")
12+
}
1113

1214
api <- jsonlite::read_json(files$service)
1315
api <- fix_operation_names(api)
@@ -31,7 +33,9 @@ read_api <- function(api_name, path) {
3133
# Returns the latest version of the given API.
3234
get_latest_api_version <- function(api_name, path) {
3335
dir_ls <- list.files(file.path(path, api_name))
34-
if (length(dir_ls) == 0) stop("Invalid API")
36+
if (length(dir_ls) == 0) {
37+
stop("Invalid API")
38+
}
3539
return(max(as.Date(dir_ls)))
3640
}
3741

make.paws/R/sdk_helper.R

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,11 @@ paws_check_pkg_size <- function(
243243
dir_info[,
244244
c("status", "percentage") := list(
245245
fcase(
246-
get("size") > threshold,
247-
"ERROR",
248-
get("size") > threshold * .75,
249-
"WARNING",
250-
get("size") <= threshold * .75,
246+
get("size") > threshold ,
247+
"ERROR" ,
248+
get("size") > threshold * .75 ,
249+
"WARNING" ,
250+
get("size") <= threshold * .75 ,
251251
"OK"
252252
),
253253
paste(round(as.numeric(get("size") / threshold) * 100, 2), "%")
@@ -375,39 +375,22 @@ paws_build_cran_comments <- function(
375375

376376
dir_info[,
377377
"cran_comment" := fcase(
378-
is.na(get("errors")) & is.na(get("warnings")) & is.na(get("notes")),
379-
"There were no ERRORs, WARNINGs, or Notes.",
380-
is.na(get("errors")) & is.na(get("warnings")) & !is.na(get("notes")),
381-
sprintf("There were no ERRORs, or WARNINGs.\nNotes:\n%s", get("notes")),
382-
is.na(get("errors")) & !is.na(get("warnings")) & !is.na(get("notes")),
383-
sprintf(
384-
"There were no ERRORs.\nWarnings:%s\nNotes:\n%s",
385-
get("warnings"),
386-
get("notes")
387-
),
388-
is.na(get("errors")) & !is.na(get("warnings")) & is.na(get("notes")),
389-
sprintf("There were no ERRORs or Notes.\nWarnings:%s", warnings),
390-
!is.na(get("errors")) & !is.na(get("warnings")) & !is.na(get("notes")),
391-
sprintf(
392-
"Errors:\n%s\nWarnings:\n%s\nNotes:\n%s",
393-
get("errors"),
394-
get("warnings"),
395-
get("notes")
396-
),
397-
!is.na(get("errors")) & is.na(get("warnings")) & is.na(get("notes")),
398-
sprintf("There was no WARNINGS or Notes.\nErrors:\n%s", get("errors")),
399-
!is.na(get("errors")) & !is.na(get("warnings")) & is.na(get("notes")),
400-
sprintf(
401-
"There was no WARNINGS.\nErrors:\n%s\nNotes:\n%s",
402-
get("errors"),
403-
get("notes")
404-
),
405-
!is.na(get("errors")) & !is.na(get("warnings")) & !is.na(get("notes")),
406-
sprintf(
407-
"There was no NOTES.\nErrors:\n%s\nNotes:\n%s",
408-
get("errors"),
409-
get("warnings")
410-
)
378+
is.na(get("errors")) & is.na(get("warnings")) & is.na(get("notes")) ,
379+
"There were no ERRORs, WARNINGs, or Notes." ,
380+
is.na(get("errors")) & is.na(get("warnings")) & !is.na(get("notes")) ,
381+
sprintf("There were no ERRORs, or WARNINGs.\nNotes:\n%s", get("notes")) ,
382+
is.na(get("errors")) & !is.na(get("warnings")) & !is.na(get("notes")) ,
383+
sprintf("There were no ERRORs.\nWarnings:%s\nNotes:\n%s", get("warnings"), get("notes")) ,
384+
is.na(get("errors")) & !is.na(get("warnings")) & is.na(get("notes")) ,
385+
sprintf("There were no ERRORs or Notes.\nWarnings:%s", warnings) ,
386+
!is.na(get("errors")) & !is.na(get("warnings")) & !is.na(get("notes")) ,
387+
sprintf("Errors:\n%s\nWarnings:\n%s\nNotes:\n%s", get("errors"), get("warnings"), get("notes")) ,
388+
!is.na(get("errors")) & is.na(get("warnings")) & is.na(get("notes")) ,
389+
sprintf("There was no WARNINGS or Notes.\nErrors:\n%s", get("errors")) ,
390+
!is.na(get("errors")) & !is.na(get("warnings")) & is.na(get("notes")) ,
391+
sprintf("There was no WARNINGS.\nErrors:\n%s\nNotes:\n%s", get("errors"), get("notes")) ,
392+
!is.na(get("errors")) & !is.na(get("warnings")) & !is.na(get("notes")) ,
393+
sprintf("There was no NOTES.\nErrors:\n%s\nNotes:\n%s", get("errors"), get("warnings"))
411394
)
412395
]
413396

@@ -576,7 +559,9 @@ remove_html_span_r <- function(files) {
576559
result <- readLines(file)
577560
start_idx <- grep("<span", result, perl = T)
578561
end_idx <- grep("</span>", result, perl = T)
579-
if (length(start_idx) == 0) next
562+
if (length(start_idx) == 0) {
563+
next
564+
}
580565
idx_ranges <- lapply(1:length(start_idx), \(x) start_idx[x]:end_idx[x])
581566
for (idx_range in idx_ranges) {
582567
line <- paste(result[idx_range], collapse = "\n")
@@ -601,7 +586,9 @@ remove_html_span_rd <- function(files) {
601586
result <- readLines(file)
602587
start_idx <- grep("<span", result, perl = T)
603588
end_idx <- grep("</span>", result, perl = T)
604-
if (length(start_idx) == 0) next
589+
if (length(start_idx) == 0) {
590+
next
591+
}
605592
idx_ranges <- lapply(1:length(start_idx), \(x) start_idx[x]:end_idx[x])
606593
for (idx_range in idx_ranges) {
607594
line <- paste(result[idx_range], collapse = "\n")
@@ -703,7 +690,9 @@ list_paws_pkgs <- function(in_dir = "../cran", pkg_list = list()) {
703690
pkgs <- file.path(in_dir, c("paws", active_pkgs))
704691

705692
# filter on pkg list
706-
if (any(nzchar(pkg_list))) pkgs <- pkgs[basename(pkgs) %in% pkg_list]
693+
if (any(nzchar(pkg_list))) {
694+
pkgs <- pkgs[basename(pkgs) %in% pkg_list]
695+
}
707696
return(pkgs)
708697
}
709698

make.paws/R/service.R

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ service_description <- function(api) {
9898
return("")
9999
}
100100
if (length(desc) > 1) {
101-
if (desc[1] == service_title(api)) desc <- desc[-1]
101+
if (desc[1] == service_title(api)) {
102+
desc <- desc[-1]
103+
}
102104
if (desc[1] == "") desc <- desc[-1]
103105
}
104106
desc <- comment(paste(desc, collapse = "\n"), "#'")
@@ -294,8 +296,13 @@ service_return <- function(api) {
294296
# e.g. rest-json -> restjson.
295297
protocol_package <- function(api) {
296298
protocol <- api$metadata$protocol
297-
if (protocol == "json") protocol <- "jsonrpc" else if (protocol == "ec2")
298-
protocol <- "ec2query" else protocol <- gsub("\\-", "", protocol)
299+
if (protocol == "json") {
300+
protocol <- "jsonrpc"
301+
} else if (protocol == "ec2") {
302+
protocol <- "ec2query"
303+
} else {
304+
protocol <- gsub("\\-", "", protocol)
305+
}
299306
quoted(protocol)
300307
}
301308

@@ -304,8 +311,12 @@ protocol_package <- function(api) {
304311
# run time.
305312
signing_name <- function(api) {
306313
name <- api$metadata$signingName
307-
if (is.null(name)) name <- api$metadata$endpointPrefix
308-
if (is.null(name)) return("NULL")
314+
if (is.null(name)) {
315+
name <- api$metadata$endpointPrefix
316+
}
317+
if (is.null(name)) {
318+
return("NULL")
319+
}
309320
quoted(name)
310321
}
311322

@@ -318,20 +329,26 @@ endpoints <- function(api) {
318329
# Returns the API's version, or "" if none.
319330
api_version <- function(api) {
320331
version <- api$metadata$apiVersion
321-
if (is.null(version)) version <- ""
332+
if (is.null(version)) {
333+
version <- ""
334+
}
322335
quoted(version)
323336
}
324337

325338
# Returns the JSON version for the API, or "" if none.
326339
json_version <- function(api) {
327340
version <- api$metadata$jsonVersion
328-
if (is.null(version)) version <- ""
341+
if (is.null(version)) {
342+
version <- ""
343+
}
329344
quoted(version)
330345
}
331346

332347
# Returns the target prefix for the API, or "" if none.
333348
target_prefix <- function(api) {
334349
prefix <- api$metadata$targetPrefix
335-
if (is.null(prefix)) prefix <- ""
350+
if (is.null(prefix)) {
351+
prefix <- ""
352+
}
336353
quoted(prefix)
337354
}

make.paws/R/tests.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,15 @@ get_testable_operations <- function(api) {
5454
i <- 1
5555
for (operation in api$operations) {
5656
name <- get_operation_name(operation)
57-
if (!any(startsWith(name, c("describe", "list")))) next
58-
if (skipped_operation(operation, api)) next
59-
if (has_required_params(operation, api)) next
57+
if (!any(startsWith(name, c("describe", "list")))) {
58+
next
59+
}
60+
if (skipped_operation(operation, api)) {
61+
next
62+
}
63+
if (has_required_params(operation, api)) {
64+
next
65+
}
6066
testable_operations[[i]] <- operation
6167
i <- i + 1
6268
}

paws.common/DESCRIPTION

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: paws.common
22
Type: Package
33
Title: Paws Low-Level Amazon Web Services API
4-
Version: 0.8.8
4+
Version: 0.8.8.9000
55
Authors@R: c(
66
person("David", "Kretch", email = "david.kretch@gmail.com", role = "aut"),
77
person("Adam", "Banker", email = "adam.banker39@gmail.com", role = "aut"),
@@ -81,7 +81,6 @@ Collate:
8181
'mock_bindings.R'
8282
'onLoad.R'
8383
'paginate.R'
84-
'populate.R'
8584
'populateutil.R'
8685
'queryutil.R'
8786
'request.R'

paws.common/NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ useDynLib(paws.common,"_paws_common_parse_query_string")
7777
useDynLib(paws.common,"_paws_common_parse_url")
7878
useDynLib(paws.common,"_paws_common_paws_url_encoder")
7979
useDynLib(paws.common,"_paws_common_paws_url_unencoder")
80+
useDynLib(paws.common,"_paws_common_populate")
8081
useDynLib(paws.common,"_paws_common_process_profile_name")
8182
useDynLib(paws.common,"_paws_common_scan_ini_file")
8283
useDynLib(paws.common,"_paws_common_set_partition_name")

0 commit comments

Comments
 (0)