[GRASS-SVN] r61184 - sandbox/krejcmat/src

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jul 8 03:28:23 PDT 2014


Author: krejcmat
Date: 2014-07-08 03:28:23 -0700 (Tue, 08 Jul 2014)
New Revision: 61184

Modified:
   sandbox/krejcmat/src/editor2.py
   sandbox/krejcmat/src/jinjainfo.py
Log:
change storage of md values

Modified: sandbox/krejcmat/src/editor2.py
===================================================================
--- sandbox/krejcmat/src/editor2.py	2014-07-08 08:24:08 UTC (rev 61183)
+++ sandbox/krejcmat/src/editor2.py	2014-07-08 10:28:23 UTC (rev 61184)
@@ -150,32 +150,19 @@
                 
 #------------------------------------------------------------------------------ 
         #register tag to created wx.id
+        #get wxpython id
         self.currWXid= self.valueCtrl.GetId()
-        val=self.mdDescription[self.cTmp].value   
-  
-        mdVal=MdDescription()
+        #get current value
+        val=self.mdDescription[self.cTmp].getValue()   
+
+        #set value to ctrl text
         self.valueCtrl.SetValue(str(val))
-        self.valueStorageWxID[self.currWXid]=val
+        #add id to object
+        self.mdDescription[self.cTmp].addId(self.currWXid)
+        
+        self.valueStorageWxID[self.currWXid]=self.mdDescription[self.cTmp]
 #------------------------------------------------------------------------------ 
          
-         
-        try:
-            mdVal=self.mdDescription[self.c]
-        except:
-            mdVal=self.mdDescription[self.c]
-        # print mdVal
-        mdVal.value=str(val)
-        mdVal.id=str(self.currWXid)
-        self.mdDescriptionList.append(mdVal)
-
-        #=======================================================================
-        # print '='*50
-        # print self.currWXid
-        # print val
-        # print mdVal.value
-        # print '='*50
-        #=======================================================================
-        
         if multiple:
             self.addItemButt=wx.Button(self.place,-1,size=(20,20),label='+')
             #self.addInfoButt=wx.Button(self,-1,size=(20,20),label='I')
@@ -259,7 +246,8 @@
     #                         self.addItem(item)
     #===========================================================================
 
-                
+    def saveEditor(self):
+        
 
 #------------------------------------------------------------- MAIN PANEL LAYOUT
     def _layout(self):
@@ -298,7 +286,9 @@
                         markgroup       markers of created list in GUI notebook
                         self.max        length of lstruct and linfo
                         self.stop       index self.c is increasing  by function plusC(), that care about  not exceeding the index
-        '''                  
+        '''   
+
+       
         self.addNotebook() 
         markgroup=[]    #notebok panel marker
         lstruct=self.mdOWSTagStrList   
@@ -307,7 +297,7 @@
         self.c=0        #this valus is the index of self.mdOWSTagStrList and also in self.mdDescription
         self.stop=False
         self.max=len(linfo)      
-        
+
         def chckLen():
             '''
             @note: -length of list in jinja template is provided by |length.
@@ -336,8 +326,8 @@
                 if not 'for' in str(lstruct[self.c]).split() or 'if' in str(lstruct[self.c]).split(): 
                     value= str(self.mdOWSTagStrList[self.c])
                     #print value
-                    str1+= '\t' +'self.mdDescription['+str(self.c)+'].value='+str(value)+'\n'
-                    str1+= '\t' +'self.cTmp='+str(self.c)+'\n'                         #save wx id
+                    str1+= '\t' +'self.mdDescription['+str(self.c)+'].addValue('+str(value)+')\n'
+                    str1+= '\t' +'self.cTmp='+str(self.c)+'\n'                         #save -*+9wx id
                     str1+= '\t' +'self.addItem(linfo[' + str(self.c) + '], True)\n'
                     tab='\t'
                 else:#if loop in loop
@@ -348,17 +338,18 @@
                     while '\t\t' in lstruct[self.c] and self.stop is False:
 
                         value= str(self.mdOWSTagStrList[self.c])
-                        str1+= '\t\t' +'self.mdDescription['+str(self.c)+'].value='+str(value)+'\n'
+                        str1+= '\t\t' +'self.mdDescription['+str(self.c)+'].addValue('+str(value)+')\n'
                         str1+= '\t\t' +'self.cTmp='+str(self.c)+'\n'                         #save wx id
                         str1+= '\t\t' +'self.addItem(linfo[' + str(self.c) + '], True)\n'
                         tab='\t\t'   
-      
+                        
                         self.plusC()
                     
                 self.plusC()
             ##print '--'*80
             self.c-=1    
             str1+= tab+'self.c+=1\n'
+            
             self.executeStr(str1,linfo)
 
             
@@ -371,14 +362,13 @@
                 markgroup.append(group)         #mark group
                 self.addNotebookPage(linfo[self.c].group)   #crate notebog page in gui
             
-
+            val=[]
             if '\t' in lstruct[self.c]and self.stop is False: #if starting the loop
-                    
-                    inBox2()
+                    inBox2()                
                     chckLen()
             elif not 'for' in str(lstruct[self.c]).split() or 'if' in str(lstruct[self.c]).split(): # if just singe item without loop
                     value= 'self.'+str(self.mdOWSTagStrList[self.c]).replace('\n','')
-                    addStr='self.mdDescription['+str(self.c)+'].value='+str(value)
+                    addStr='self.mdDescription['+str(self.c)+'].addValue('+str(value)+')'
                     ##print '--'*80
                     ##print addStr
                     self.executeStr(addStr,False)
@@ -391,7 +381,7 @@
                 self.plusC()
                 #print str(lstruct[self.c])
                 
-
+       
 #===============================================================================
 #         print '========================================'    
 #         for keys,values in self.valueStorageWxID.items():

Modified: sandbox/krejcmat/src/jinjainfo.py
===================================================================
--- sandbox/krejcmat/src/jinjainfo.py	2014-07-08 08:24:08 UTC (rev 61183)
+++ sandbox/krejcmat/src/jinjainfo.py	2014-07-08 10:28:23 UTC (rev 61184)
@@ -20,7 +20,7 @@
 from jinja2 import Environment, FileSystemLoader
 
 class MdDescription():
-     def __init__(self,tag= None, name = None, desc = None, example = None, type = None, multi = 0, inboxmulti=None, group = None, inbox = None, multiline = None, value=None,id=None,num=None ):
+     def __init__(self,tag= None, name = None, desc = None, example = None, type = None, multi = 0, inboxmulti=None, group = None, inbox = None, multiline = None, value=[],id=[],num=None ):
          
          self.tag=tag
          self.name = name
@@ -36,6 +36,29 @@
          self.value=value
          self.id=id
          
+         self.valueIndex=-1
+         self.idIndex=-1
+         
+     def addValue(self,value):
+         
+         #print value
+         self.value.append(value)
+         self.valueIndex+=1
+         #print self.valueIndex 
+         
+     def addId(self,id):
+         self.id.append(id)
+         self.idIndex+=1
+         
+     
+     def getId(self):
+         self.idIndex-=1
+         return self.id[self.idIndex]
+     
+     def getValue(self):
+         self.valueIndex-=1
+         return self.value[self.valueIndex]
+        
 class JinjaTemplateInfo():
     def __init__(self,template):
         
@@ -47,7 +70,6 @@
         self.mdOWSTagStrList=[] 
         #self.mdDescriptionStr=''
           
-         
         self._readJinjaInfo()
         self._readJinjaTags()
         self._domdOWSTagStr()



More information about the grass-commit mailing list