Warning, /education/rkward/CRAN_mirror_list.R is written in an unsupported language. File is not indexed.

0001 #!/usr/bin/Rscript
0002 # Read the mirror list file from MIRROR_LIST
0003 # and create two lists suitable for QStringList.
0004 # These two strings are used in rkward/settings/rksettingsmoduler.cpp
0005 
0006 #MIRROR_LIST <- '/usr/share/R/doc/CRAN_mirrors.csv'
0007 
0008 removeCityFromCountry <- function (x) {
0009         sub (' *$', '', sub (paste ('(',x[2],')', sep=''), '', x[1], fixed=TRUE))
0010 }
0011 
0012 #mirror.list <- read.csv(MIRROR_LIST, stringsAsFactors=FALSE)
0013 mirror.list <- getCRANmirrors()
0014 
0015 mirror.names <- paste('"', 
0016         paste (apply(mirror.list[,c(1,3)], 1, 'removeCityFromCountry'), 
0017                 mirror.list$City, 
0018                 unlist(lapply(strsplit(mirror.list$Host, split=','), function(x) {x[1]})), 
0019         sep=' - '), '"', sep='')
0020 
0021 cat (
0022  'Host details list:\n', # cran_mirrors_list
0023  paste (c(' << "Ask everytime"', mirror.names), collapse=' << '), # Host details
0024  '\nURL list:\n', # cran_url_list
0025  paste (c(' << "@CRAN@"', paste('"', mirror.list$URL, '"', sep='')), collapse=' << '), # URL
0026  '\n') 
0027 
0028 
0029 ## If ever a separate .h file is used:
0030 # In fact could combine the two lists into one (i = i+2)
0031 #message (paste (c(' << "Ask everytime"', mirror.names), collapse='\n\t << ')) # Host details
0032 #message (paste (c(' << "@CRAN@"',paste('"', mirror.list$URL, '"', sep='')), collapse='\n\t << ')) # URL