-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuildxml.R
30 lines (29 loc) · 1.16 KB
/
buildxml.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
if(!require("stringr")) install.packages("stringr", repos="https://cran.rstudio.com")
template <- readLines("Taxonomy.ctv")
pattern <- "pkg>[[:alnum:]]+[[:alnum:].]*[[:alnum:]]+"
out <- paste0(template, collapse = " ")
pkgs <- stringr::str_extract_all(out, pattern)[[1]]
pkgs <- unique(gsub("^pkg>", "", pkgs))
priority <- c('taxize', 'taxa')
pkgs <- pkgs[ !pkgs %in% priority] # remove priority packages
pkgs <- lapply(as.list(sort(pkgs)), function(x) list(package=x))
output <-
c(paste0('<CRANTaskView>
<name>Taxonomy</name>
<topic>Taxonomy</topic>
<maintainer email="myrmecocystus@gmail.com">Scott Chamberlain</maintainer>
<version>',Sys.Date(),'</version>'),
' <info>',
paste0(" ",template),
' </info>',
' <packagelist>',
# list priority packages explicitly
paste0(' <pkg priority="core">', priority, '</pkg>', collapse = "\n"),
# add all other packages from `pkgs`
paste0(' <pkg>', unlist(unname(pkgs)), '</pkg>', collapse = "\n"),
' </packagelist>',
' <links>',
' <a href="https://cran.rstudio.com/web/views/Phylogenetics.html">Phylogenetics Task View</a>',
' </links>',
'</CRANTaskView>')
writeLines(output, "Taxonomy.ctv")