Skip to content

Commit

Permalink
Merge pull request #151 from lawinslow/master
Browse files Browse the repository at this point in the history
Clearing up legacy sbtools issues
  • Loading branch information
Luke Winslow committed Dec 30, 2015
2 parents e80ee3d + 6c45e45 commit ca92a28
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: sbtools
Title: USGS ScienceBase Tools
Maintainer: Luke Winslow <lwinslow@usgs.gov>
Version: 0.13.3
Version: 0.13.4
Authors@R: c(person("Luke", "Winslow", role = c("aut","cre"),
email = "lwinslow@usgs.gov"),
person("Scott", "Chamberlain", role = c("aut"),
Expand Down
5 changes: 4 additions & 1 deletion R/item_file_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ item_file_download = function(id, ..., names, destinations, dest_dir, session=cu
destinations = file.path(dest_dir, names)

#or we have names and destinations
}else{
}else if(!missing(names) & !missing(destinations)){
if(length(names) != length(destinations)){
stop('Length of names and destinations must be identical')
}
Expand All @@ -60,6 +60,9 @@ item_file_download = function(id, ..., names, destinations, dest_dir, session=cu
if(!all(names %in% flist$fname)){
stop('Item does not contain all requested files')
}
#otherwise in some other error condition
}else{
stop('Must have either names & destinations, or dest_dir for all files')
}


Expand Down
17 changes: 15 additions & 2 deletions R/item_update_identifier.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ item_update_identifier = function(id, scheme, type, key, ..., session=current_se
}

data = list(scheme=unbox(scheme), type=unbox(type), key=unbox(key))

data = merge_identifiers(original$identifiers, data)
data = merge_identifiers(unbox_identifiers(original$identifiers), data)

info = list(identifiers=data)

Expand Down Expand Up @@ -69,3 +69,16 @@ merge_identifiers = function(original, updated){
original[[length(original)+1]] = updated
return(original)
}

unbox_identifiers = function(idents){
if(length(idents) < 1){
return(idents)
}

for(i in 1:length(idents)){
idents[[i]]$type = unbox(idents[[i]]$type)
idents[[i]]$scheme = unbox(idents[[i]]$scheme)
idents[[i]]$key = unbox(idents[[i]]$key)
}
return(idents)
}

0 comments on commit ca92a28

Please sign in to comment.