[Sciviews-commits] r272 - in komodo/SciViews-K: content defaults

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat May 8 22:53:54 CEST 2010


Author: prezez
Date: 2010-05-08 22:53:48 +0200 (Sat, 08 May 2010)
New Revision: 272

Added:
   komodo/SciViews-K/defaults/pkgMan.R
Modified:
   komodo/SciViews-K/content/RPkgManager.xul
Log:
Package manager was broken (is ".required" not set anymore in new R?).
It's helper functions are now loaded from "defaults/pkgMan.R", yet they should be included in svMisc in future.


Modified: komodo/SciViews-K/content/RPkgManager.xul
===================================================================
--- komodo/SciViews-K/content/RPkgManager.xul	2010-05-08 18:49:23 UTC (rev 271)
+++ komodo/SciViews-K/content/RPkgManager.xul	2010-05-08 20:53:48 UTC (rev 272)
@@ -122,29 +122,22 @@
 }
 
 function reloadList () {
-		var eol = "\n\n\n";
 
-		var cmd = [
-				'svtmp.ipkg <- as.data.frame(installed.packages(fields = c("Description"))[, c("Package", "Version", "Description", "Depends")])',
-				'svtmp.ipkg$Loaded <- svtmp.ipkg$Package %in% .packages()',
-				'svtmp.ipkg$Required <- svtmp.ipkg$Package %in% .required',
-				'write.table(svtmp.ipkg [, c("Package", "Version", "Description", "Loaded", "Required", "Depends")], eol="'
-				+ addcslashes(eol, "\n") + '", na = "", sep="\\t", quote=FALSE, row.names = FALSE, col.names = FALSE)',
-		];
-
 		var theList = document.getElementById("TheList");
-
-		sv.r.evalCallback(cmd.join("\n"), function (data) {
+		sv.r.evalCallback('pkgManList()', function (data) {
 				data = data.replace(/\r\n/g, "\n");
-				data = data.split(eol);
+				data = data.split(/\n{2,4}/);
 
 				var selectIdx = theList.selectedIndex;
 
 				var newPackages = [], pkgs = [], pkg, name, required, loaded;
 
 				for (i in data) {
-						pkgs[i] = data[i].split("\t");
-						newPackages.push(pkgs[i][0]);
+						pkg = data[i].split("\t");
+						if (pkg.length < 6)
+							break;
+						pkgs[i] = pkg;
+						newPackages.push(pkg[0]);
 				}
 
 				var items = theList.childNodes;
@@ -334,30 +327,23 @@
 		//f1();
 		//f1();
 		var args = window.arguments;
-		sv = args[0];
-		var cmd = 'svtmp.updatePkgs <- function (lib.loc = .libPaths(), repos = getOption("repos"),'
-				+	'	  contriburl = contrib.url(repos, type), method,'
-				+	'	  available = available.packages(contriburl = contriburl, method = method),'
-				+	'	  instlib = update[, "LibPath"], ...,'
-				+	'	  checkBuilt = FALSE, type = getOption("pkgType")) {\n'
-				+   'oldPkgs <- old.packages(lib.loc = lib.loc, contriburl = contriburl,'
-				+   '        method = method, available = available, checkBuilt = checkBuilt);\n'
-				+	'return(oldPkgs)}';
+		if (args) {
+			sv = args[0];
+		} else {
+			var p = parent;
+			while (p.opener && (p = p.opener) && !sv) if (p.sv) sv = p.sv;
+		}
 
-		sv.r.evalCallback(cmd, function (data) {
-				sv.cmdout.append(data);
-				reloadList();
+		var file = sv.tools.file.path("ProfD", "extensions", "sciviewsk at sciviews.org",
+							"defaults", "pkgMan.R").replace(/\\/g, "/");
+
+		sv.r.evalCallback("source(\"" + file + "\"", function(data) {
+			reloadList();
 		});
-		//reloadList();
-}
 
 
-
-self.onclose = function() {
-    sv.r.evalHidden('rm(svtmp.updatePkgs, svtmp.ipkg)');
 }
 
-
 ]]>
 	</script>
 

Added: komodo/SciViews-K/defaults/pkgMan.R
===================================================================
--- komodo/SciViews-K/defaults/pkgMan.R	                        (rev 0)
+++ komodo/SciViews-K/defaults/pkgMan.R	2010-05-08 20:53:48 UTC (rev 272)
@@ -0,0 +1,30 @@
+# R-Package manager helper functions
+# These possibly should be included in svMisc in future
+
+assignTemp("pkgManList", function(eol = "\n\n\n") {
+	svtmp.ipkg <- as.data.frame(installed.packages(fields = c("Description"))
+				[, c("Package", "Version", "Description", "Depends")])
+
+	svtmp.ipkg$Loaded <- svtmp.ipkg$Package %in% .packages()
+
+	if (!exists(".required"))
+		.required <- logical(0)
+
+	svtmp.ipkg$Required <- svtmp.ipkg$Package %in% .required
+
+	print(write.table(svtmp.ipkg [, c("Package", "Version", "Description",
+				"Loaded", "Required", "Depends")], eol="\n\n",
+				na = "", sep="\t", quote=FALSE, row.names = FALSE,
+				col.names = FALSE))
+	invisible(NULL)
+})
+
+assignTemp("pkgManUpdatePkgs", function (lib.loc = .libPaths(), repos = getOption("repos"),
+	  contriburl = contrib.url(repos, type), method,
+	  available = available.packages(contriburl = contriburl, method = method),
+	  instlib = update[, "LibPath"], ...,
+	  checkBuilt = FALSE, type = getOption("pkgType")) {
+		oldPkgs <- old.packages(lib.loc = lib.loc, contriburl = contriburl,
+		method = method, available = available, checkBuilt = checkBuilt);
+		return(oldPkgs)
+})



More information about the Sciviews-commits mailing list