[rkward] packages/rkwarddev/R: fixing modifier checks

m.eik michalke meik.michalke at uni-duesseldorf.de
Wed Oct 7 20:49:52 UTC 2015


Git commit 8b83511ef18444af1bad3bea44a2db48749d95b2 by m.eik michalke.
Committed on 07/10/2015 at 20:42.
Pushed by meikm into branch 'master'.

fixing modifier checks

  - rk.XML.convert() and rk.XML.switch() weren't appending modifiers if ID was a character string

M  +13   -9    packages/rkwarddev/R/rk.XML.convert.R
M  +5    -1    packages/rkwarddev/R/rk.XML.switch.R

http://commits.kde.org/rkward/8b83511ef18444af1bad3bea44a2db48749d95b2

diff --git a/packages/rkwarddev/R/rk.XML.convert.R b/packages/rkwarddev/R/rk.XML.convert.R
index 0afd0cd..10d1373 100644
--- a/packages/rkwarddev/R/rk.XML.convert.R
+++ b/packages/rkwarddev/R/rk.XML.convert.R
@@ -89,15 +89,19 @@ rk.XML.convert <- function(sources, mode=c(), required=FALSE, id.name="auto"){
   src.names <- names(sources)
   if(!is.null(src.names)){
     # check these names if they're valid modifiers here
-    invalid.names <- !src.names %in% unique(unlist(all.valid.modifiers))
-    if(any(invalid.names)){
-      warning(paste0("Some of the modifier names you provided are invalid and were ignored: ",
-        paste(src.names[invalid.names], collapse=", ")))
-        src.names[invalid.names] <- ""
-    } else {}
-    sources <- as.character(sapply(1:length(src.names), function(src.no){
-        this.modif <- src.names[src.no]
-        valid.modif <- modif.validity(source=sources[[src.no]], modifier=this.modif, bool=FALSE)
+    sane.src.names <- c()
+    for (thisName in src.names){
+      sane.src.names <- c(sane.src.names, modif.validity(source="all", modifier=thisName, bool=FALSE))
+    }
+    src.names <- sane.src.names
+    sources <- as.character(sapply(1:length(sane.src.names), function(src.no){
+        this.modif <- sane.src.names[src.no]
+        this.source <- sources[[src.no]]
+        if(is.XiMpLe.node(this.source)){
+          valid.modif <- modif.validity(source=this.source, modifier=this.modif, bool=FALSE)
+        } else {
+          valid.modif <- modif.validity(source="all", modifier=this.modif, bool=FALSE)
+        }
         if(nchar(valid.modif) > 0){
           new.value <- paste(check.ID(sources[[src.no]], search.environment=TRUE), this.modif, sep=".")
         } else {
diff --git a/packages/rkwarddev/R/rk.XML.switch.R b/packages/rkwarddev/R/rk.XML.switch.R
index b3b9568..acdeeb5 100644
--- a/packages/rkwarddev/R/rk.XML.switch.R
+++ b/packages/rkwarddev/R/rk.XML.switch.R
@@ -78,7 +78,11 @@ rk.XML.switch <- function(condition, cases, modifier=NULL, id.name="auto"){
     if(modif.validity(condition, modifier=modifier)){
       condition.id <- paste(condition.id, modifier, sep=".")
     } else {}
-  } else {}
+  } else {
+    if(modif.validity("all", modifier=modifier)){
+      condition.id <- paste(condition.id, modifier, sep=".")
+    } else {}
+  }
 
   if(identical(id.name, "auto")){
     attr.list <- list(condition=condition.id, id=auto.ids(condition.id, prefix=ID.prefix("switch")))



More information about the rkward-tracker mailing list