[GRASS-SVN] r61211 - sandbox/krejcmat/src
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jul 9 03:29:24 PDT 2014
Author: krejcmat
Date: 2014-07-09 03:29:23 -0700 (Wed, 09 Jul 2014)
New Revision: 61211
Modified:
sandbox/krejcmat/src/editor2.py
Log:
save xml
Modified: sandbox/krejcmat/src/editor2.py
===================================================================
--- sandbox/krejcmat/src/editor2.py 2014-07-09 09:48:15 UTC (rev 61210)
+++ sandbox/krejcmat/src/editor2.py 2014-07-09 10:29:23 UTC (rev 61211)
@@ -17,40 +17,78 @@
def __init__(self,pathToXml=None):
self.path=pathToXml
-
+ self.owslibInfo=None
self.initMD()
+ self.isoOWSLibInfo()
+ self.isoOWSLibInfo1()
#self.valueStorageByID={} #dict wher key= wx.ID and valu = class MdWxInfo()
-
+ def isoOWSLibInfo(self):
+ lst=[]
+ def combineDict(stable,lst):
+ stable=dict(stable, **lst[-1])
+ lst.pop()
+ if len(lst)>0:
+ combineDict(stable,lst)
+ else:
+ self.owslibInfo=stable
+
+ lst.append(vars(MD_Metadata()))
+ lst.append(vars(CI_Date()))
+ lst.append(vars(CI_ResponsibleParty()))
+ lst.append(vars(MD_DataIdentification()))
+ lst.append(vars(MD_Distributor()))
+ lst.append(vars(MD_Distribution()))
+ lst.append(vars(DQ_DataQuality()))
+ #lst.append(vars(SV_ServiceIdentification()))
+ lst.append(vars(CI_OnlineResource()))
+ lst.append(vars(EX_GeographicBoundingBox()))
+ lst.append(vars(EX_Polygon()))
+ #lst.append(vars(EX_GeographicBoundingPolygon()))
+ lst.append(vars(EX_Extent()))
+ #lst.append(vars(MD_ReferenceSystem()))
+ #lst.append(vars(CodelistCatalogue(1)))
+ d={}
+
+ combineDict(d,lst)
+ #print self.owslibInfo
+ def isoOWSLibInfo1(self):
+ self.dictOWSlibInfo={}
+
+ self.dictOWSlibInfo['MD_Metadata']=vars(MD_Metadata())
+ self.dictOWSlibInfo['CI_Date']=vars(CI_Date())
+ self.dictOWSlibInfo['CI_ResponsibleParty']=vars(CI_ResponsibleParty())
+ self.dictOWSlibInfo['MD_DataIdentification']=vars(MD_DataIdentification())
+ self.dictOWSlibInfo['MD_Distributor']=vars(MD_Distributor())
+ self.dictOWSlibInfo['MD_Distribution']=vars(MD_Distribution())
+ self.dictOWSlibInfo['DQ_DataQuality']=vars(DQ_DataQuality())
+ self.dictOWSlibInfo['CI_OnlineResource']=vars(CI_OnlineResource())
+ self.dictOWSlibInfo['EX_GeographicBoundingBox']=vars(EX_GeographicBoundingBox())
+ self.dictOWSlibInfo['EX_Polygon']=vars(EX_Polygon())
+ self.dictOWSlibInfo['EX_Extent']=vars(EX_Extent())
+
def initMD(self):
self.path='INStest.xml'
tree = ET.parse(self.path)
root = tree.getroot()
self.md = MD_Metadata(root)
#self.md = MD_Metadata(md=None)
-
+ #print
+
#===============================================================================
-# MD WX VALUES
-#===============================================================================
-class MdInfo():
- def __init__(self,tag,value):
- self.tag=tag
- self.value=value
-
- #print 'tag: ' +tag + ' value: ' +self.value
-#===============================================================================
# editor
#===============================================================================
class Editor(wx.Panel):
def __init__(self,parent):
wx.Panel.__init__(self, parent=parent,id=wx.ID_ANY)
- self.wxIdTag={} #dict with id and tag from ows lib
+
mdo=MD()
self.md=mdo.md #instance of
+ self.owslibInfo=mdo.isoOWSLibInfo
+ self.dictOWSlibInfo=mdo.dictOWSlibInfo
self.comboItems=[] #list in combobox
-
self._layout()
self.templatePath='data/grassInspireTemplate01.xml'
@@ -62,16 +100,12 @@
self.mdOWSTagStrList=jinj.mdOWSTagStrList #
self.valueStorageWxID={}
- #self.mdDescriptionVAL=MdDescription()
self.mdDescriptionList=[]
- #self.MDinfoDictNum=jinj.cretemdDescriptionDict('num')
- #self.MDinfoDictGroup=jinj.cretemdDescriptionDict('group')
- #self.MDinfoDictBox=jinj.cretemdDescriptionDict('inbox')
#self.initCreatorEmpty()
self.initCreatorMD()
-
+ self.saveXML('a')
self.currWXid=None
#------------------------------------------------------------------------ EVENTS
@@ -148,26 +182,32 @@
wx.TAB_TRAVERSAL|wx.RAISED_BORDER|wx.HSCROLL)
-#------------------------------------------------------------------------------
+#----------------------------------------------------- REGISTER VALUES AND WX ID
#register tag to created wx.id
#get wxpython id
- self.currWXid= self.valueCtrl.GetId()
+ currWXid= self.valueCtrl.GetId()
#get current value
- val=self.mdDescription[self.cTmp].getValue()
-
+ val=self.mdDescription[self.cTmp].getValue()
+ #=======================================================================
+ # print '-'*50
+ # print self.cTmp
+ # print self.mdDescription[self.cTmp].tag
+ # print self.mdDescription[self.cTmp].name
+ # print val
+ #=======================================================================
#set value to ctrl text
self.valueCtrl.SetValue(str(val))
#add id to object
- self.mdDescription[self.cTmp].addId(self.currWXid)
+ self.mdDescription[self.cTmp].addId(currWXid)
- self.valueStorageWxID[self.currWXid]=self.mdDescription[self.cTmp]
+ self.valueStorageWxID[currWXid]=self.mdDescription[self.cTmp]
#------------------------------------------------------------------------------
if multiple:
self.addItemButt=wx.Button(self.place,-1,size=(20,20),label='+')
#self.addInfoButt=wx.Button(self,-1,size=(20,20),label='I')
#BINDS
- self.addItemButt.Bind(EVT_BUTTON, self.cloneCtrl)
+ self.addItemButt.Bind(EVT_BUTTON, self.saveXML)
self.valueCtrl.Bind(wx.EVT_TEXT,self.mdBuilder )
self._addItemLay(multiline,multiple)
@@ -218,37 +258,6 @@
def _addComboBoxLay(self):
self.nbPanelSizer.Add(self.comboboxSizer,proportion=0,flag=wx.EXPAND)
-#----------------------------------------------------------------------- CREATOR
- #===========================================================================
- # def initCreatorMD1(self):
- # self.addNotebook()
- # c=0
- # markgroup=[] #notebok panel marker
- # markbox=[] # box panel marker
- # markitem=[] #item panel marker
- # for lstruct, linfo in zip(self.struct.splitlines(),self.mdDescription):
- # c+=1
- #
- # group=linfo.group
- # if group not in markgroup: #if group is not created
- # markgroup.append(group)
- # self.addNotebookPage(linfo.group)
- # for item in self.MDinfoDictGroup[group]:
- # box=item.inbox
- # if box not in markbox and box!=None: #if box is not created or item is not in box
- # markbox.append(box)
- # self.addBox(item.inbox) #mark box
- # for boxite in self.MDinfoDictBox[box]:
- # markitem.append(boxite.num)
- # self.addItem(boxite, True)
- # else:
- # if item.num not in markitem: #if item is not created
- # self.addItem(item)
- #===========================================================================
-
- def saveEditor(self):
- pass
-
#------------------------------------------------------------- MAIN PANEL LAYOUT
def _layout(self):
#main sizer in frame
@@ -264,19 +273,116 @@
string+='description: ' + item.desc + '\n'
if item.example !=None:
string+='example: ' + item.example + '\n'
- return string
+ return string
#------------------------------------------------------------------------------
+#----------------------------------------------------------------------- SaveXML
+#------------------------------------------------------------------------------
+
+
+ def plusS(self):
+ self.s+=1
+ if self.s >= self.maxS:
+ self.s-=1
+ print "stop"
+ self.stopS=True
+
+ def saveXML(self,evt):
+
+ lstruct=self.mdOWSTagStrList
+ linfo=self.mdDescription #from jinja
+
+ self.s=0 #this valus is the index of self.mdOWSTagStrList and also in self.mdDescription
+ self.stopS=False
+ self.maxS=len(linfo)
+
+ def reverseAssignments(string):
+ pass
+
+ def inLoop():
+
+ loop = lstruct[self.s-1]
+ print loop
+
+ while '\t' in lstruct[self.s] and self.stopS is False:
+
+
+ if not 'for' in str(lstruct[self.s]).split() or 'if' in str(lstruct[self.s]).split():
+ print str(lstruct[self.s])
+ self.plusS()
+
+
+ tab='\t'
+ else:
+
+ print str(lstruct[self.s-1])
+ print str(lstruct[self.s])
+ while '\t\t' in lstruct[self.s] and self.stopS is False:
+
+
+ print str(lstruct[self.s])
+ tab='\t\t'
+ self.plusS()
+
+ self.plusS()
+ ##print '--'*80
+ #self.s-=1
+ #str1+= tab+'self.s+=1\n'
+ #self.executeStr(str1,linfo)
+
+ #START of the looop of genereator
+ while self.stopS is False: #self.stop is managed by def plusC(self):
+
+ if '\t' in lstruct[self.s]and self.stopS is False: #if starting the loop
+
+ inLoop()
+
+ elif not 'for' in str(lstruct[self.s]).split() or 'if' in str(lstruct[self.s]).split(): # if just singe item without loop
+ tag=self.mdDescription[self.s].tag
+ for item in self.mdDescription[self.s].value:
+ str1='self.'+str(tag)+' = "'+str(item)+'"'
+ self.executeStr1(str1,None)
+ self.plusS()
+ else:
+ self.plusS()
+
+#------------------------------------------------------------------------------
#----------------------------------------------------------------------- CREATOR
#------------------------------------------------------------------------------
- def executeStr(self,stri,linfo):
+ def executeStr1(self,stri,linfo):
print stri
exec stri
+
+ def executeStr(self,stri,linfo):
+ #print stri
+ exec stri
def plusC(self):
self.c+=1
if self.c >= self.max:
self.c-=1
self.stop=True
+
+ #===========================================================================
+ # def initCreatorMD1(self):
+ # def isList(string):
+ # string=string.split()
+ # print string[0]
+ # if string in self.owslibInfo:
+ # print
+ #
+ # self.addNotebook()
+ # markgroup=[] #notebok panel marker
+ # lstruct=self.mdOWSTagStrList
+ # linfo=self.mdDescription #from jinja
+ #
+ # for item in self.mdOWSTagStrList:
+ #
+ # isList(item)
+ # if '\t' in item:
+ # pass
+ # elif 'for' in item.split() or 'if' in item.split():
+ # pass
+ #===========================================================================
def initCreatorMD(self):
'''
@@ -352,8 +458,6 @@
self.executeStr(str1,linfo)
-
-
#START of the looop of genereator
while self.stop is False: #self.stop is managed by def plusC(self):
@@ -377,11 +481,11 @@
self.plusC()
else:
#if lstruct[self.c] is "FOR", "IF" "WHILE"
- #print str(lstruct[self.c])
+
self.plusC()
- #print str(lstruct[self.c])
-
+
+ #print idem.value
#===============================================================================
# print '========================================'
# for keys,values in self.valueStorageWxID.items():
@@ -424,4 +528,32 @@
if __name__ == '__main__':
App = MyApp(0)
- App.MainLoop()
\ No newline at end of file
+ App.MainLoop()
+
+
+ #===========================================================================
+ # def initCreatorMD1(self):
+ # self.addNotebook()
+ # c=0
+ # markgroup=[] #notebok panel marker
+ # markbox=[] # box panel marker
+ # markitem=[] #item panel marker
+ # for lstruct, linfo in zip(self.struct.splitlines(),self.mdDescription):
+ # c+=1
+ #
+ # group=linfo.group
+ # if group not in markgroup: #if group is not created
+ # markgroup.append(group)
+ # self.addNotebookPage(linfo.group)
+ # for item in self.MDinfoDictGroup[group]:
+ # box=item.inbox
+ # if box not in markbox and box!=None: #if box is not created or item is not in box
+ # markbox.append(box)
+ # self.addBox(item.inbox) #mark box
+ # for boxite in self.MDinfoDictBox[box]:
+ # markitem.append(boxite.num)
+ # self.addItem(boxite, True)
+ # else:
+ # if item.num not in markitem: #if item is not created
+ # self.addItem(item)
+ #===========================================================================
\ No newline at end of file
More information about the grass-commit
mailing list