[GRASS-SVN] r61170 - sandbox/krejcmat/src
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 7 09:04:43 PDT 2014
Author: krejcmat
Date: 2014-07-07 09:04:43 -0700 (Mon, 07 Jul 2014)
New Revision: 61170
Removed:
sandbox/krejcmat/src/editor.py
sandbox/krejcmat/src/editor1.py
sandbox/krejcmat/src/test.py
sandbox/krejcmat/src/test2.py
Log:
rm sources
Deleted: sandbox/krejcmat/src/editor.py
===================================================================
--- sandbox/krejcmat/src/editor.py 2014-07-07 15:21:53 UTC (rev 61169)
+++ sandbox/krejcmat/src/editor.py 2014-07-07 16:04:43 UTC (rev 61170)
@@ -1,266 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8
-"""
-MODULE: g.gui.metadata
-
-AUTHOR(S): Matej Krejci <matejkrejci gmail.com>
-
-PURPOSE: Module for editing metadata based on ISO
-
-COPYRIGHT: (C) 2014 Matej Krejci, and by the GRASS Development Team
-
- This program is free software udef __init__(self,parent, label,tag, info=None, multiple=False,multiline=False):nder the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-"""
-
-import wx
-from jinjainfo import JinjaTemplateInfo as jt
-from wx import ID_ANY
-
-#===============================================================================
-# mditem
-#===============================================================================
-class MDItem(wx.Panel):
- def __init__(self, parent, label, tag, info=None, multiple=False):
- wx.Panel.__init__(self, parent=parent,id=wx.ID_ANY)
- self.label=label
- self.multiple=multiple
- self.info=info
-
- self._initWidgets()
- self._layout()
-
- def _initWidgets(self):
- self.tagText= wx.StaticText(parent=self,id=wx.ID_ANY,label=self.label)
- self.valueCtrl = wx.TextCtrl(self, id=wx.ID_ANY,
- style=wx.VSCROLL |
- wx.TE_MULTILINE | wx.TE_DONTWRAP |
- wx.TAB_TRAVERSAL|wx.RAISED_BORDER|wx.HSCROLL)
-
- if self.multiple:
- self.addItemButt=wx.Button(self,-1,size=(20,20),label='+')
- #self.addInfoButt=wx.Button(self,-1,size=(20,20),label='I')
-
- def _layout(self):
- #add V-sizer to panel
- panelSizer=wx.BoxSizer(wx.VERTICAL)
- self.SetSizer(panelSizer)
-
- #add text-ctrl and button to H-sizer
- textFieldSizer = wx.BoxSizer(wx.HORIZONTAL)
- textFieldSizer.Add(self.valueCtrl,proportion=1,flag=wx.EXPAND)
- if self.multiple:
- textFieldSizer.Add(self.addItemButt,0)
-
- #add staticText, textFieldSizer to static box sizer
- panelSizer.Add(item=self.tagText,proportion=0)
- panelSizer.Add(item=textFieldSizer,proportion=1,flag=wx.EXPAND)
-
-
-#===============================================================================
-# box
-#===============================================================================
-class Box(wx.Panel):
- def __init__(self, parent ):
- wx.Panel.__init__(self,parent=parent,id = wx.ID_ANY)
-
- def addItems(self,items):
- self.items=items
- for item in self.items:
- self.stBoxSizer.Add(item=item,proportion=1,flag=wx.EXPAND)
- self._layout()
-
- def addItem(self,items):
- self.items=items
- self.stBoxSizer.Add(item=item,proportion=1,flag=wx.EXPAND)
- self._layout()
-
- def _layout(self):
-
- if self.items[0].subgrupmulti:
- self.boxMultiplicity=self.items[0].subgrupmulti
- self.addBoxButt=wx.Button(self,-1,size=(20,20),label='+')
-
- #get label of static box
- self.stboxLabel=self.items[0].group
- self.stbox=wx.StaticBox(self, label=self.stboxLabel, style=wx.RAISED_BORDER)
-
- panelSizer = wx.BoxSizer(wx.HORIZONTAL)
- self.SetSizer(panelSizer)
-
- self.stBoxSizer = wx.StaticBoxSizer( self.stbox, wx.VERTICAL,)
- panelSizer.Add(item=self.stBoxSizer,flag=wx.EXPAND,proportion=1)
-
- if self.items[0].subgrupmulti:
- panelSizer.Add(self.addBoxButt,0)
-
-#===============================================================================
-# panel group
-#===============================================================================
-class PanelGroup(wx.Panel):
- def __init__(self,items):
- wx.Panel.__init__(self,parent=parent,id= wx.ID_ANY)
-
- self.items=items
- self._addItems()
-
- def _addItems(self):
- for item in self.items:
- self.panelSizer.Add(item,proportion=1,flag=wx.EXPAND)
- self._layout()
-
- def _layout(self):
- self.panelSizer=wx.BoxSizer(wx.VERTICAL)
- self.SetSizer(self.panelSizer)
-#===============================================================================
-# notebook
-#===============================================================================
-class Notebook(wx.Notebook):
- def __init__(self,parent):
- wx.Notebook.__init__(self,parent=parent,id= wx.ID_ANY,style=0)
-
- self.notebook_panel = wx.Panel(self, wx.ID_ANY)
- self._layout()
- def _chckList(self):
- if len(self.panels) != len(self.labels):
- print "TODO error"
-
- def addPanels(self,panels,labels):
- self.panels=panels #list of panels
- self.labels=labels
- self._chckList()
- for panel in self.panels:
- self.notebook_panel=panel
- self.AddPage(self.notebook_panel,self.labels[0])
- self.labels.pop(0)
- self._layout()
-
- def _layout(self):
- panelSizer = wx.BoxSizer(wx.VERTICAL)
- self.notebook_panel.SetSizer(panelSizer)
- #panelSizer.Add(self.notebook_panel, 1, wx.EXPAND, 0)
-#===============================================================================
-# gui builder
-#===============================================================================
-class GUIbuilder():
- def __init__(self):
-
- self.MDinfoList=[]
- #self._getInfoJinja()
- self._initFrame()
-
- #self._fillFrame()
- self.app.MainLoop()
-
- def _initFrame(self):
- self.app = wx.App(False)
- self.Frame = MainFrame()
- self.Frame.Show(True)
-
- def _fillFrame(self):
- note=Notebook()
-
-
- def _getInfoJinja(self):
- jinj=jt(self.templatePath)
- self.MDinfoList=jinj.getMdInfoGroupByGroupsList()
- #print self.MDinfoList
-
-#===============================================================================
-# main frame
-#===============================================================================
-class MainFrame(wx.Frame):
- def __init__(self):
- wx.Frame.__init__(self, parent=None, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(600, 400))
-
- self.panel = wx.Panel(self, -1)
- self.addNotebook()
- #self._fillFrame()
-
- def addNotebook(self):
- self.notebook=Notebook(self.panel)
- list=[]
-
- list.append(wx.Panel(self,-1))
- list1=[]
- list1.append('object')
- #self.notebook.addPanels(list, list1)
- self._layout()
-
- def _layout(self):
- #sizer for frame
- frameSizer = wx.BoxSizer(wx.VERTICAL)
- self.SetSizer(frameSizer)
-
- #add panel to framesizer
- frameSizer.Add(item=self.panel, proportion=1,flag=wx.EXPAND)
-
- self.panelSizer=wx.BoxSizer(wx.HORIZONTAL)
- self.panel.SetSizer(self.panelSizer)
-
- #self.panelSizer.Add(self.notebook,1, wx.EXPAND, 0)
-
-
-
-
-class EditorSettings():
- def __init__(self):
- self.TemplatePath
-
-
-
-
-
-if __name__ == '__main__':
- GUIbuilder()
-
-
-#===============================================================================
-# class MainFrame(wx.Frame):
-# def __init__(self, parent, ID, title):
-# wx.Frame.__init__(self, parent, ID, title,
-# wx.DefaultPosition, wx.Size(600, 400))
-#
-# self.numgroup=2
-# self.namegroup='Identifiacation'
-# tag='resource title'
-#
-# self.panel = wx.Panel(self, -1)
-# self.tagText= wx.StaticText(parent=self.panel,id=wx.ID_ANY,label=tag)
-# self.valueCtrl = wx.TextCtrl(self.panel, id=wx.ID_ANY,
-# style=wx.VSCROLL |
-# wx.TE_MULTILINE | wx.TE_DONTWRAP |
-# wx.TAB_TRAVERSAL|wx.RAISED_BORDER|wx.HSCROLL)
-# self.addItemButt=wx.Button(self.panel,-1,size=(20,20),label='+')
-# self.addInfoButt=wx.Button(self.panel,-1,size=(20,20),label='i')
-# self.addBoxButt=wx.Button(self.panel,-1,size=(20,20),label='+')
-# self._layout()
-#
-# def _layout(self):
-# add panel to V-sizer
-# topSizer = wx.BoxSizer(wx.VERTICAL)
-# self.SetSizer(topSizer)
-# topSizer.Add(item=self.panel, proportion=1,flag=wx.EXPAND)
-#
-# add V-sizer to panel
-# panelSizer=wx.BoxSizer(wx.HORIZONTAL)
-# self.panel.SetSizer(panelSizer)
-#
-# add text-ctrl and button to H-sizer
-# textFieldSizer = wx.BoxSizer(wx.HORIZONTAL)
-# textFieldSizer.Add(self.valueCtrl,proportion=1,flag=wx.EXPAND)
-# textFieldSizer.Add(self.addItemButt,0)
-# textFieldSizer.Add(self.addInfoButt,0)
-#
-# create StaticBox
-# stBox = wx.StaticBox(self.panel, wx.ID_ANY, label=self.namegroup, style=wx.RAISED_BORDER)
-# stBoxSizer = wx.StaticBoxSizer(stBox, wx.VERTICAL)
-#
-#
-# add staticText, textFieldSizer to static box sizer
-# stBoxSizer.Add(item=self.tagText,proportion=0)
-# stBoxSizer.Add(item=textFieldSizer,proportion=1,flag=wx.EXPAND)
-# panelSizer.Add(stBoxSizer, proportion=1,flag=wx.EXPAND)
-# panelSizer.Add(self.addBoxButt,0)
-#===============================================================================
\ No newline at end of file
Deleted: sandbox/krejcmat/src/editor1.py
===================================================================
--- sandbox/krejcmat/src/editor1.py 2014-07-07 15:21:53 UTC (rev 61169)
+++ sandbox/krejcmat/src/editor1.py 2014-07-07 16:04:43 UTC (rev 61170)
@@ -1,235 +0,0 @@
-
-import wx
-from wx import ID_ANY
-from wx import EVT_BUTTON
-import wx.lib.scrolledpanel as scrolled
-
-from owslib.iso import *
-from jinjainfo import JinjaTemplateInfo as jt
-
-#===============================================================================
-#EDITOR
-#===============================================================================
-class MD():
- def __init__(self):
- pass
- def intSubMD(self):
- self.md.identification = MD_DataIdentification()
- self.md.dataquality = DQ_DataQuality()
- self.md.distribution = MD_Distribution()
- self.md.identification.extent = EX_Extent()
- self.md.identification.extent.boundingBox = EX_GeographicBoundingBox()
-
- def initMD(self,path):
- tree = ET.parse('series.xml')
- root = tree.getroot()
- md = MD_Metadata(root)
- self.md = MD_Metadata(md=None)
-
-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
- self.mdcreator=MD()
- #self.wxIdBox={}
- self._layout()
- self.nb_panels=[] #panels in notebook
- self.templatePath='data/grassInspireTemplate01.xml'
- #self.templatePath='data/jinjatest.xml'
- self.MDinfoList=[]
- self._getInfoJinja()
-
- self.addNotebook()
- self.initCreator()
-#------------------------------------------- REGISTER OWSlib TAG TO CTRL TEXT ID
- def regIdTag(self,tag):
- id=self.valueCtrl.GetId()
- print 'tag: ' +tag + ' id: ' +str(id)
- self.wxIdTag[self.valueCtrl.GetId()]=tag
-
- def readXML(self,schemaPath):
- pass
-#------------------------------------------------------------------------ EVENTS
- def cloneCtrl(self,evt):
- print 'pes'
-
- def mdBuilder(self,evt):
- string=evt.GetString()
- id=evt.GetId()
- print self.wxIdTag[id]
-
- print id
- print string
- #=======================================================================
- # children = self.sizer.GetChildren()
- # for child in children:
- # widget = child.GetWindow()
- # print widget
- # if isinstance(widget, wx.TextCtrl):
- # widget.Clear()
- #=======================================================================
-
-#-------------------------------------------------------------------- CREATE BOX
- def addBox(self,multi,label):
- self.stbox=wx.StaticBox(self.nbPanel, label=label,id=ID_ANY, style=wx.RAISED_BORDER)
-
- if multi:
- self.addBoxButt=wx.Button(self.nbPanel,-1,size=(20,20),label='+')
- self._addBoxLay(multi)
-
- def _addBoxLay(self,multi):
- self.boxButtonSizer=wx.BoxSizer(wx.HORIZONTAL)
- self.nbPanelSizer.Add(self.boxButtonSizer,flag=wx.EXPAND,proportion=0)
- self.stBoxSizer = wx.StaticBoxSizer( self.stbox, wx.VERTICAL)
- self.boxButtonSizer.Add(item=self.stBoxSizer,flag=wx.EXPAND,proportion=1)
-
- if multi:
- self.boxButtonSizer.Add(self.addBoxButt,0)
-
-#---------------------------------------------------------------------- FILL BOX
- def fillBox(self,item):
- self.addItem(item,True)
-
-#--------------------------------------------------------------------- ADD ITEM
- def addItem(self,item,box=False):
- label=item.name
- multiple=item.multiplicity
- multiline=item.multiline
- info=self.createInfo(item)
- tag=item.tag
-
- if box:
- self.place=self.nbPanel
- self.sizer=self.stBoxSizer
- else:
- self.place=self.nbPanel
- self.sizer=self.nbPanelSizer
-
- self.tagText= wx.StaticText(parent=self.place,id=ID_ANY,label=label)
- if multiline is True:
- self.valueCtrl = wx.TextCtrl(self.place, id=ID_ANY, size=(0, 55),
- style=wx.VSCROLL |
- wx.TE_MULTILINE | wx.TE_DONTWRAP | wx.ST_NO_AUTORESIZE|
- wx.TAB_TRAVERSAL|wx.RAISED_BORDER|wx.HSCROLL)
- else:
- self.valueCtrl = wx.TextCtrl(self.place, id=wx.ID_ANY,
- style=wx.VSCROLL | wx.TE_DONTWRAP |
- wx.TAB_TRAVERSAL|wx.RAISED_BORDER|wx.HSCROLL)
- #register tag to created wx.id
- self.regIdTag(tag)
-
- 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.valueCtrl.Bind(wx.EVT_TEXT,self.mdBuilder )
-
- self._addItemLay(multiline,multiple)
-
-
- def _addItemLay(self,multiline,multiple):
-
- if multiline is True:
- self.textFieldSizer = wx.BoxSizer(wx.HORIZONTAL)
- self.textFieldSizer.Add(self.valueCtrl,proportion=1,flag=wx.EXPAND)
- if multiple:
- self.textFieldSizer.Add(self.addItemButt,0)
- self.sizer.Add(item=self.tagText,proportion=0)
- self.sizer.Add(item=self.textFieldSizer,proportion=0,flag=wx.EXPAND)
- else:
- self.textFieldSizer = wx.BoxSizer(wx.HORIZONTAL)
- self.textFieldSizer.Add(self.valueCtrl,proportion=1)
- if multiple:
- self.textFieldSizer.Add(self.addItemButt,0)
- self.sizer.Add(item=self.tagText,proportion=0)
- self.sizer.Add(item=self.textFieldSizer,proportion=0,flag=wx.EXPAND)
-
-#---------------------------------------------------------------------- NOTEBOOK
- def addNotebook(self):
- self.notebook=wx.Notebook(self,id=wx.ID_ANY|wx.HSCROLL)
- self._addNotebookLay()
-
- def _addNotebookLay(self):
- noteSizer=wx.BoxSizer(wx.VERTICAL)
- self.notebook.SetSizer(noteSizer)
- self.mainSizer.Add(self.notebook,proportion=1,flag=wx.EXPAND)
-
-#----------------------------------------------------------------- NOTEBOOK PAGE
- def addNotebookPage(self,label):
- self.nbPanel=scrolled.ScrolledPanel(self.notebook,id=wx.ID_ANY)
- self.nbPanel.SetupScrolling()
- self.notebook.AddPage(self.nbPanel,label)
- self._addNotebookPageLay()
-
- def _addNotebookPageLay(self):
- self.nbPanelSizer=wx.BoxSizer(wx.VERTICAL)
- self.nbPanel.SetSizer(self.nbPanelSizer)
-
-#----------------------------------------------------------------------- CREATOR
- def initCreator(self):
- for item in self.MDinfoList:
- try:
- group=item[0][0].group
- except:
- group=item[0].group
-
- self.addNotebookPage(group)
-
- for currItem in item: #loop for items in maingroup(notebook list)
- if type(currItem) is list: #if items are in "box"
- label=currItem[0].inbox
- multi=currItem[0].inboxmulti
- self.addBox(multi, label)
- for inBox in currItem: #for items in box
- #print inBox.name
- self.fillBox(inBox)
- else:
- self.addItem(currItem)
-
-#-------------------------------------------------------------------- JINJA INFO
- def _getInfoJinja(self):
- jinj=jt(self.templatePath)
- self.MDinfoList=jinj.getMdInfoGroupByGroupsList()
-
-#------------------------------------------------------------- MAIN PANEL LAYOUT
- def _layout(self):
- #main sizer in frame
- self.mainSizer=wx.BoxSizer(wx.VERTICAL)
- self.SetSizer(self.mainSizer)
-
-#-------------------------------------------------------------------------- INFO
- def createInfo(self,item):
- string='name: '+ item.name + '\n'
- string+='description: ' + item.desc + '\n'
- string+='example: ' + item.example + '\n'
- return string
-
-#===============================================================================
-# MAIN FRAME
-#===============================================================================
-class MainFrame(wx.Frame):
- def __init__(self, parent, ID, title):
- wx.Frame.__init__(self, parent, ID, title,
- wx.DefaultPosition, wx.Size(600, 400))
- self.panel = Editor(self)
- self._layout()
-
- def _layout(self):
- topSizer = wx.BoxSizer(wx.VERTICAL)
- self.SetSizer(topSizer)
- topSizer.Add(item=self.panel, proportion=1,flag=wx.EXPAND)
-
-class MyApp(wx.App):
- def OnInit(self):
- Frame = MainFrame(None, -1, "Frame")
- Frame.Show(True)
- self.SetTopWindow(Frame)
- return True
-
-if __name__ == '__main__':
- App = MyApp(0)
- App.MainLoop()
-
-
\ No newline at end of file
Deleted: sandbox/krejcmat/src/test.py
===================================================================
--- sandbox/krejcmat/src/test.py 2014-07-07 15:21:53 UTC (rev 61169)
+++ sandbox/krejcmat/src/test.py 2014-07-07 16:04:43 UTC (rev 61170)
@@ -1,177 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8
-"""
-MODULE: g.gui.metadata
-
-AUTHOR(S): Matej Krejci <matejkrejci gmail.com>
-
-PURPOSE: Module for editing metadata based on ISO
-
-COPYRIGHT: (C) 2014 Matej Krejci, and by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-"""
-
-import wx
-
-class MDItem(wx.Panel):
- def __init__(self,parent, label, info=None, multiple=False):
- wx.Panel.__init__(self, parent=parent,id=wx.ID_ANY)
- self.label=label
- self.multiple=multiple
- self.info=info
-
- self._initWidgets()
- self._layout()
-
- def _initWidgets(self):
- self.tagText= wx.StaticText(parent=self,id=wx.ID_ANY,label=self.label)
- self.valueCtrl = wx.TextCtrl(self, id=wx.ID_ANY,
- style=wx.VSCROLL |
- wx.TE_MULTILINE | wx.TE_DONTWRAP |
- wx.TAB_TRAVERSAL|wx.RAISED_BORDER|wx.HSCROLL)
- if self.multiple:
-
- self.addItemButt=wx.Button(self,-1,size=(20,20),label='+')
- #self.addInfoButt=wx.Button(self,-1,size=(20,20),label='I')
-
- def _layout(self):
- #add V-sizer to panel
- panelSizer=wx.BoxSizer(wx.VERTICAL)
- self.SetSizer(panelSizer)
-
- #add text-ctrl and button to H-sizer
- textFieldSizer = wx.BoxSizer(wx.HORIZONTAL)
- textFieldSizer.Add(self.valueCtrl,proportion=1,flag=wx.EXPAND)
- if self.multiple:
- textFieldSizer.Add(self.addItemButt,0)
-
- #add staticText, textFieldSizer to static box sizer
- panelSizer.Add(item=self.tagText,proportion=0)
- panelSizer.Add(item=textFieldSizer,proportion=1,flag=wx.EXPAND)
-
-class Box(wx.Panel):
- def __init__(self,parent, boxLabel,boxMultiplicity=False):
- wx.Panel.__init__(self,parent=parent,id= wx.ID_ANY)
-
- self.stboxLabel=boxLabel
- self.boxMultiplicity=boxMultiplicity
-
- self.stbox=wx.StaticBox(self, label=boxLabel, style=wx.RAISED_BORDER)
- if boxMultiplicity:
- self.boxMultiplicity=boxMultiplicity
- self.addBoxButt=wx.Button(self,-1,size=(20,20),label='+')
- self.fill()
- self._layout()
- self._fillBox()
-
- def fill(self):
- list=['1','2','3']
- self.MDitems=[]
- for i in list:
- it=MDItem(self ,i, True,True)
- self.MDitems.append(it)
-
- def _layout(self):
- panelSizer = wx.BoxSizer(wx.HORIZONTAL)
- self.SetSizer(panelSizer)
-
- self.stBoxSizer = wx.StaticBoxSizer( self.stbox, wx.VERTICAL)
- panelSizer.Add(item=self.stBoxSizer,flag=wx.EXPAND,proportion=1)
-
- if self.boxMultiplicity:
- panelSizer.Add(self.addBoxButt,0)
-
- def _fillBox(self):
- for item in self.MDitems:
-
- self.stBoxSizer.Add(item=item,proportion=1,flag=wx.EXPAND)
-
-
-class MainFrame(wx.Frame):
- def __init__(self, parent, ID, title):
- wx.Frame.__init__(self, parent, ID,title,
- wx.DefaultPosition, wx.Size(600, 400))
-
- self.panel = wx.Panel(self, -1)
-
- self.bb=Box(self.panel,"boxLabel", True)
-
- self._layout()
- self._boxLayout()
-
- def _layout(self):
- topSizer = wx.BoxSizer(wx.VERTICAL)
- self.SetSizer(topSizer)
- topSizer.Add(item=self.panel, proportion=1,flag=wx.EXPAND)
-
- def _boxLayout(self):
- panelSizer=wx.BoxSizer(wx.HORIZONTAL)
- self.panel.SetSizer(panelSizer)
- panelSizer.Add(self.bb,proportion=1,flag=wx.EXPAND)
- #panelSizer.Add(self.MDitems[0],proportion=1,flag=wx.EXPAND)
-
-
-#===============================================================================
-# class MainFrame(wx.Frame):
-# def __init__(self, parent, ID, title):
-# wx.Frame.__init__(self, parent, ID, title,
-# wx.DefaultPosition, wx.Size(600, 400))
-#
-# self.numgroup=2
-# self.namegroup='Identifiacation'
-# tag='resource title'
-#
-# self.panel = wx.Panel(self, -1)
-# self.tagText= wx.StaticText(parent=self.panel,id=wx.ID_ANY,label=tag)
-# self.valueCtrl = wx.TextCtrl(self.panel, id=wx.ID_ANY,
-# style=wx.VSCROLL |
-# wx.TE_MULTILINE | wx.TE_DONTWRAP |
-# wx.TAB_TRAVERSAL|wx.RAISED_BORDER|wx.HSCROLL)
-# self.addItemButt=wx.Button(self.panel,-1,size=(20,20),label='+')
-# self.addInfoButt=wx.Button(self.panel,-1,size=(20,20),label='i')
-# self.addBoxButt=wx.Button(self.panel,-1,size=(20,20),label='+')
-# self._layout()
-#
-# def _layout(self):
-# add panel to V-sizer
-# topSizer = wx.BoxSizer(wx.VERTICAL)
-# self.SetSizer(topSizer)
-# topSizer.Add(item=self.panel, proportion=1,flag=wx.EXPAND)
-#
-# add V-sizer to panel
-# panelSizer=wx.BoxSizer(wx.HORIZONTAL)
-# self.panel.SetSizer(panelSizer)
-#
-# add text-ctrl and button to H-sizer
-# textFieldSizer = wx.BoxSizer(wx.HORIZONTAL)
-# textFieldSizer.Add(self.valueCtrl,proportion=1,flag=wx.EXPAND)
-# textFieldSizer.Add(self.addItemButt,0)
-# textFieldSizer.Add(self.addInfoButt,0)
-#
-# create StaticBox
-# stBox = wx.StaticBox(self.panel, wx.ID_ANY, label=self.namegroup, style=wx.RAISED_BORDER)
-# stBoxSizer = wx.StaticBoxSizer(stBox, wx.VERTICAL)
-#
-#
-# add staticText, textFieldSizer to static box sizer
-# stBoxSizer.Add(item=self.tagText,proportion=0)
-# stBoxSizer.Add(item=textFieldSizer,proportion=1,flag=wx.EXPAND)
-# panelSizer.Add(stBoxSizer, proportion=1,flag=wx.EXPAND)
-# panelSizer.Add(self.addBoxButt,0)
-#===============================================================================
-
-class MyApp(wx.App):
- def OnInit(self):
- Frame = MainFrame(None, -1, "Frame")
- Frame.Show(True)
- self.SetTopWindow(Frame)
- return True
-
-if __name__ == '__main__':
- App = MyApp(0)
- App.MainLoop()
-
-
\ No newline at end of file
Deleted: sandbox/krejcmat/src/test2.py
===================================================================
--- sandbox/krejcmat/src/test2.py 2014-07-07 15:21:53 UTC (rev 61169)
+++ sandbox/krejcmat/src/test2.py 2014-07-07 16:04:43 UTC (rev 61170)
@@ -1,147 +0,0 @@
-from owslib.iso import *
-from owslib.util import xml_to_dict
-from lxml import etree as ET
-import xml.etree.ElementTree as ElementTree
-from jinjainfo import JinjaTemplateInfo as jt
-
-from jinja2 import Environment, FileSystemLoader
-import jinja2
-
-from jinja2 import BaseLoader, TemplateNotFound
-from os.path import join, exists, getmtime
-import os
-
-
-def jinja():
- dirpath =os.path.dirname(os.path.realpath(__file__))
-
- env = Environment(loader=FileSystemLoader(dirpath))
-
- template=jinja2.Template('data/grassInspireTemplate01.xml')
- #template.globals['context'] = get_context
- #print template.debug_info()
- #loader.get_source(env, 'data/grassInspireTemplate01.xml')
- #------------------------------------------- env.globals.update(zip=zip)
- #--------------------------------- template = env.get_template(template)
- #--------------------------------- iso_xml = template.render(md=self.md)
- #----------------------------------------------- xml_file = xml_out_name
-
-
-def main():
- jinj = jt('data/grassInspireTemplate01.xml')
- #print jinj.md_info[0].name
- print jinj.getObjectsString()
-
-
- tree = ET.parse('series.xml')
- root = tree.getroot()
- md = MD_Metadata(root)
- #print md.identification.extent.boundingBox.maxy
-
- string=util.xml_to_dict(root)
-
-
-def printDict(tel):
- for key in tel:
- for num in tel[key]:
- print ''.join(str(n) for n in num)
-def xml(root,):
- #print "tag=%s, attrib=%s" % (root.tag, root.attrib)
- for child in root:
- print child.tag, child.attrib
- if child.tag == "appointment":
- for step_child in child:
- print step_child.tag
-
- #iterate over the entire tree
- print "-" * 40
- print "Iterating using a tree iterator"
- print "-" * 40
- iter_ = tree.getiterator()
- for elem in iter_:
- print elem.tag
-
-
- # get the information via the children!
- print "-" * 40
- print "Iterating using getchildren()"
- print "-" * 40
- appointments = root.getchildren()
- for appointment in appointments:
- appt_children = appointment.getchildren()
- for appt_child in appt_children:
- print "%s=%s" % (appt_child.tag, appt_child.text)
- # print md.identification
-
- ##############################################################################################################
- ##############################################################################################################
-def xmltodict(element):
- if not isinstance(element, ElementTree.Element):
- raise ValueError("must pass xml.etree.ElementTree.Element object")
-
- def xmltodict_handler(parent_element):
- result = dict()
- for element in parent_element:
- if len(element):
- obj = xmltodict_handler(element)
- else:
- obj = element.text
-
- if result.get(element.tag):
- if hasattr(result[element.tag], "append"):
- result[element.tag].append(obj)
- else:
- result[element.tag] = [result[element.tag], obj]
- else:
- result[element.tag] = obj
- return result
-
- return {element.tag: xmltodict_handler(element)}
-
-
-def dicttoxml(element):
- if not isinstance(element, dict):
- raise ValueError("must pass dict type")
- if len(element) != 1:
- raise ValueError("dict must have exactly one root key")
-
- def dicttoxml_handler(result, key, value):
- if isinstance(value, list):
- for e in value:
- dicttoxml_handler(result, key, e)
- elif isinstance(value, basestring):
- elem = ElementTree.Element(key)
- elem.text = value
- result.append(elem)
- elif isinstance(value, int) or isinstance(value, float):
- elem = ElementTree.Element(key)
- elem.text = str(value)
- result.append(elem)
- elif value is None:
- result.append(ElementTree.Element(key))
- else:
- res = ElementTree.Element(key)
- for k, v in value.items():
- dicttoxml_handler(res, k, v)
- result.append(res)
-
- result = ElementTree.Element(element.keys()[0])
- for key, value in element[element.keys()[0]].items():
- dicttoxml_handler(result, key, value)
- return result
-
-def xmlfiletodict(filename):
- return xmltodict(ElementTree.parse(filename).getroot())
-
-def dicttoxmlfile(element, filename):
- ElementTree.ElementTree(dicttoxml(element)).write(filename)
-
-def xmlstringtodict(xmlstring):
- return xmltodict(ElementTree.fromstring(xmlstring).getroot())
-
-def dicttoxmlstring(element):
- return ElementTree.tostring(dicttoxml(element))
-
-
-if __name__ == "__main__":
- main()
\ No newline at end of file
More information about the grass-commit
mailing list