Skip to content

Commit

Permalink
Merge pull request #687 from DyfanJones/paws.common-0.6.2
Browse files Browse the repository at this point in the history
Release: paws.common 0.6.2
  • Loading branch information
DyfanJones authored Oct 13, 2023
2 parents 213be0a + fe80a7f commit a96713f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion paws.common/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: paws.common
Type: Package
Title: Paws Low-Level Amazon Web Services API
Version: 0.6.1.9000
Version: 0.6.2
Authors@R: c(
person("David", "Kretch", email = "david.kretch@gmail.com", role = "aut"),
person("Adam", "Banker", email = "adam.banker39@gmail.com", role = "aut"),
Expand Down
2 changes: 1 addition & 1 deletion paws.common/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# paws.common 0.6.1.9000
# paws.common 0.6.2
* fix how `read_ini` reads empty profiles from ini files
* fix is.atomic behavior for R v4.4+
* support service specific endpoints (#667). Thanks to @dpprdan for raising ticket and testing methods
Expand Down
35 changes: 17 additions & 18 deletions paws.common/R/iniutil.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

# Get a parameter and its value
extract_ini_parameter <- function(item) {
item <- trimws(item)
item <- gsub("^[ \t\r\n]+|[ \t\r\n]+$", "", item, perl = T)
parameter <- list(item[2])
names(parameter) <- item[1]
return(parameter)
}

# Read in values from an ini file
read_ini <- function(file_name) {
if (!file.exists(file_name)) {
stopf("Unable to find file: %s", file_name)
Expand All @@ -22,7 +21,9 @@ read_ini <- function(file_name) {
# In that case, length(content) is 0. Don't loop
# in such a case, since 'grepl(..., content[i])'
# will return logical(0), causing the 'if' to error out
if (length(content) == 0) return(list())
if (length(content) == 0) {
return(list())
}

# Get the profile name from an ini file
rm_els <- grep("(^;)|(^\\s+;)|(^#)|(^\\s+#)", content, perl = TRUE)
Expand All @@ -35,19 +36,19 @@ read_ini <- function(file_name) {
names(profiles) <- profile_nms

start <- (found + 1)
end <- c(found[-1]-1, length(content))
end <- c(found[-1] - 1, length(content))
split_content <- strsplit(sub("=", "\n", content, fixed = T), "\n", fixed = T)
for (i in which(start <= end)) {
sub_content <- split_content[seq.int(start[i], end[i])]
found_nested_content <- lengths(sub_content) == 1
nested_contents <- lengths(split_content) == 1

for (i in which(start <= end)) {
items <- seq.int(start[i], end[i])
found_nested_content <- nested_contents[items]
if (any(found_nested_content)) {
profiles[[i]] <- nested_ini_content(sub_content, found_nested_content)
profiles[[i]] <- nested_ini_content(split_content[items], found_nested_content)
} else {
profiles[[i]] <- unlist(lapply(
sub_content, extract_ini_parameter
), recursive = F
)
split_content[items], extract_ini_parameter
), recursive = F)
}
}
return(profiles)
Expand All @@ -56,24 +57,22 @@ read_ini <- function(file_name) {
nested_ini_content <- function(sub_content, found_nested_content) {
position <- which(found_nested_content)
start <- (position + 1)
end <- c(position[-1]-1, length(sub_content))
end <- c(position[-1] - 1, length(sub_content))

profile_nms <- trimws(unlist(sub_content[position]))
profile_nms <- gsub("^[ \t\r\n]+|[ \t\r\n]+$", "", unlist(sub_content[position]), perl = T)

sub_grp <- which(!vapply(sub_content, function(x) grepl("^[ ]+", x[1]), logical(1)))
non_nest <- sub_grp[!sub_grp%in% position]
non_nest <- sub_grp[!sub_grp %in% position]

profiles <- unlist(lapply(
sub_content[non_nest], extract_ini_parameter
), recursive = F
)
), recursive = F)
for (i in seq_along(position)) {
els <- seq.int(start[i], end[i])
nest_content <- sub_content[els[!(els %in% sub_grp)]]
profiles[[profile_nms[i]]] <- unlist(lapply(
nest_content, extract_ini_parameter
), recursive = F
)
), recursive = F)
}
return(profiles)
}
2 changes: 1 addition & 1 deletion paws.common/cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Submission
This release contains minor bug fixes
This release contains minor bug fixes and fixes cran issue

## Test environments

Expand Down

0 comments on commit a96713f

Please sign in to comment.