[GRASS-SVN] r61166 - sandbox/krejcmat/src
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 7 06:54:19 PDT 2014
Author: krejcmat
Date: 2014-07-07 06:54:19 -0700 (Mon, 07 Jul 2014)
New Revision: 61166
Added:
sandbox/krejcmat/src/INStest.xml
sandbox/krejcmat/src/editor2.py
Modified:
sandbox/krejcmat/src/jinjainfo.py
Log:
add editor2.py
Added: sandbox/krejcmat/src/INStest.xml
===================================================================
--- sandbox/krejcmat/src/INStest.xml (rev 0)
+++ sandbox/krejcmat/src/INStest.xml 2014-07-07 13:54:19 UTC (rev 61166)
@@ -0,0 +1,366 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gmd:MD_Metadata xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.isotc211.org/2005/gmd http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd">
+ <gmd:fileIdentifier>
+ <gco:CharacterString>286c0725-146e-4533-b1bf-d6e367f6c342</gco:CharacterString>
+ </gmd:fileIdentifier>
+ <gmd:language>
+ <gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="eng">eng</gmd:LanguageCode>
+ </gmd:language>
+ <gmd:hierarchyLevel>
+ <gmd:MD_ScopeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset">dataset</gmd:MD_ScopeCode>
+ </gmd:hierarchyLevel>
+ <gmd:contact>
+ <gmd:CI_ResponsibleParty>
+ <gmd:organisationName>
+ <gco:CharacterString>xouxoutos</gco:CharacterString>
+ </gmd:organisationName>
+ <gmd:contactInfo>
+ <gmd:CI_Contact>
+ <gmd:address>
+ <gmd:CI_Address>
+ <gmd:electronicMailAddress>
+ <gco:CharacterString>foufoutos at gmail.com</gco:CharacterString>
+ </gmd:electronicMailAddress>
+ <gmd:electronicMailAddress>
+ <gco:CharacterString>tsiou at gmail.com</gco:CharacterString>
+ </gmd:electronicMailAddress>
+ </gmd:CI_Address>
+ </gmd:address>
+ </gmd:CI_Contact>
+ </gmd:contactInfo>
+ <gmd:role>
+ <gmd:CI_RoleCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_RoleCode" codeListValue="pointOfContact">pointOfContact</gmd:CI_RoleCode>
+ </gmd:role>
+ </gmd:CI_ResponsibleParty>
+ </gmd:contact>
+ <gmd:contact>
+ <gmd:CI_ResponsibleParty>
+ <gmd:organisationName>
+ <gco:CharacterString>momos</gco:CharacterString>
+ </gmd:organisationName>
+ <gmd:contactInfo>
+ <gmd:CI_Contact>
+ <gmd:address>
+ <gmd:CI_Address>
+ <gmd:electronicMailAddress>
+ <gco:CharacterString>kokos at gmail.com</gco:CharacterString>
+ </gmd:electronicMailAddress>
+ <gmd:electronicMailAddress>
+ <gco:CharacterString>lolos at gmail.com</gco:CharacterString>
+ </gmd:electronicMailAddress>
+ </gmd:CI_Address>
+ </gmd:address>
+ </gmd:CI_Contact>
+ </gmd:contactInfo>
+ <gmd:role>
+ <gmd:CI_RoleCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_RoleCode" codeListValue="pointOfContact">pointOfContact</gmd:CI_RoleCode>
+ </gmd:role>
+ </gmd:CI_ResponsibleParty>
+ </gmd:contact>
+ <gmd:dateStamp>
+ <gco:Date>2014-05-20</gco:Date>
+ </gmd:dateStamp>
+ <gmd:metadataStandardName>
+ <gco:CharacterString>ISO19115</gco:CharacterString>
+ </gmd:metadataStandardName>
+ <gmd:metadataStandardVersion>
+ <gco:CharacterString>2003/Cor.1:2006</gco:CharacterString>
+ </gmd:metadataStandardVersion>
+ <gmd:identificationInfo>
+ <gmd:MD_DataIdentification>
+ <gmd:citation>
+ <gmd:CI_Citation>
+ <gmd:title>
+ <gco:CharacterString>Title bla bla</gco:CharacterString>
+ </gmd:title>
+ <gmd:date>
+ <gmd:CI_Date>
+ <gmd:date>
+ <gco:Date>2014-05-06</gco:Date>
+ </gmd:date>
+ <gmd:dateType>
+ <gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode>
+ </gmd:dateType>
+ </gmd:CI_Date>
+ </gmd:date>
+ <gmd:date>
+ <gmd:CI_Date>
+ <gmd:date>
+ <gco:Date>2014-05-08</gco:Date>
+ </gmd:date>
+ <gmd:dateType>
+ <gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode>
+ </gmd:dateType>
+ </gmd:CI_Date>
+ </gmd:date>
+ <gmd:date>
+ <gmd:CI_Date>
+ <gmd:date>
+ <gco:Date>2014-05-01</gco:Date>
+ </gmd:date>
+ <gmd:dateType>
+ <gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="creation">creation</gmd:CI_DateTypeCode>
+ </gmd:dateType>
+ </gmd:CI_Date>
+ </gmd:date>
+ <gmd:date>
+ <gmd:CI_Date>
+ <gmd:date>
+ <gco:Date>2014-05-12</gco:Date>
+ </gmd:date>
+ <gmd:dateType>
+ <gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="revision">revision</gmd:CI_DateTypeCode>
+ </gmd:dateType>
+ </gmd:CI_Date>
+ </gmd:date>
+ <gmd:identifier>
+ <gmd:RS_Identifier>
+ <gmd:code>
+ <gco:CharacterString>286c0725-146e-4533-b1bf-d6e367f6c342</gco:CharacterString>
+ </gmd:code>
+ </gmd:RS_Identifier>
+ </gmd:identifier>
+ </gmd:CI_Citation>
+ </gmd:citation>
+ <gmd:abstract>
+ <gco:CharacterString>Abstract blah blah</gco:CharacterString>
+ </gmd:abstract>
+ <gmd:pointOfContact>
+ <gmd:CI_ResponsibleParty>
+ <gmd:organisationName>
+ <gco:CharacterString>NTUA</gco:CharacterString>
+ </gmd:organisationName>
+ <gmd:contactInfo>
+ <gmd:CI_Contact>
+ <gmd:address>
+ <gmd:CI_Address>
+ <gmd:electronicMailAddress>
+ <gco:CharacterString>lolo2 at gmail.com</gco:CharacterString>
+ </gmd:electronicMailAddress>
+ </gmd:CI_Address>
+ </gmd:address>
+ </gmd:CI_Contact>
+ </gmd:contactInfo>
+ <gmd:role>
+ <gmd:CI_RoleCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_RoleCode" codeListValue="owner">owner</gmd:CI_RoleCode>
+ </gmd:role>
+ </gmd:CI_ResponsibleParty>
+ </gmd:pointOfContact>
+ <gmd:descriptiveKeywords>
+ <gmd:MD_Keywords>
+ <gmd:keyword>
+ <gco:CharacterString>Agricultural and aquaculture facilities</gco:CharacterString>
+ </gmd:keyword>
+ <gmd:keyword>
+ <gco:CharacterString>Bio-geographical regions</gco:CharacterString>
+ </gmd:keyword>
+ <gmd:thesaurusName>
+ <gmd:CI_Citation>
+ <gmd:title>
+ <gco:CharacterString>GEMET - INSPIRE themes, version 1.0</gco:CharacterString>
+ </gmd:title>
+ <gmd:date>
+ <gmd:CI_Date>
+ <gmd:date>
+ <gco:Date>2008-06-01</gco:Date>
+ </gmd:date>
+ <gmd:dateType>
+ <gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode>
+ </gmd:dateType>
+ </gmd:CI_Date>
+ </gmd:date>
+ </gmd:CI_Citation>
+ </gmd:thesaurusName>
+ </gmd:MD_Keywords>
+ </gmd:descriptiveKeywords>
+ <gmd:descriptiveKeywords>
+ <gmd:MD_Keywords>
+ <gmd:keyword>
+ <gco:CharacterString>test</gco:CharacterString>
+ </gmd:keyword>
+ <gmd:thesaurusName>
+ <gmd:CI_Citation>
+ <gmd:title>
+ <gco:CharacterString>oeo</gco:CharacterString>
+ </gmd:title>
+ <gmd:date>
+ <gmd:CI_Date>
+ <gmd:date>
+ <gco:Date>2014-05-20</gco:Date>
+ </gmd:date>
+ <gmd:dateType>
+ <gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="creation">creation</gmd:CI_DateTypeCode>
+ </gmd:dateType>
+ </gmd:CI_Date>
+ </gmd:date>
+ </gmd:CI_Citation>
+ </gmd:thesaurusName>
+ </gmd:MD_Keywords>
+ </gmd:descriptiveKeywords>
+ <gmd:resourceConstraints>
+ <gmd:MD_Constraints>
+ <gmd:useLimitation>
+ <gco:CharacterString>no conditions apply</gco:CharacterString>
+ </gmd:useLimitation>
+ </gmd:MD_Constraints>
+ </gmd:resourceConstraints>
+ <gmd:resourceConstraints>
+ <gmd:MD_LegalConstraints>
+ <gmd:accessConstraints>
+ <gmd:MD_RestrictionCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_RestrictionCode" codeListValue="otherRestrictions">otherRestrictions</gmd:MD_RestrictionCode>
+ </gmd:accessConstraints>
+ <gmd:otherConstraints>
+ <gco:CharacterString>no limitations</gco:CharacterString>
+ </gmd:otherConstraints>
+ </gmd:MD_LegalConstraints>
+ </gmd:resourceConstraints>
+ <gmd:spatialResolution>
+ <gmd:MD_Resolution>
+ <gmd:equivalentScale>
+ <gmd:MD_RepresentativeFraction>
+ <gmd:denominator>
+ <gco:Integer>5000</gco:Integer>
+ </gmd:denominator>
+ </gmd:MD_RepresentativeFraction>
+ </gmd:equivalentScale>
+ </gmd:MD_Resolution>
+ </gmd:spatialResolution>
+ <gmd:spatialResolution>
+ <gmd:MD_Resolution>
+ <gmd:distance>
+ <gco:Distance uom="Meters">2</gco:Distance>
+ </gmd:distance>
+ </gmd:MD_Resolution>
+ </gmd:spatialResolution>
+ <gmd:language>
+ <gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="eng">eng</gmd:LanguageCode>
+ </gmd:language>
+ <gmd:language>
+ <gmd:LanguageCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#LanguageCode" codeListValue="gre">gre</gmd:LanguageCode>
+ </gmd:language>
+ <gmd:topicCategory>
+ <gmd:MD_TopicCategoryCode>biota</gmd:MD_TopicCategoryCode>
+ </gmd:topicCategory>
+ <gmd:topicCategory>
+ <gmd:MD_TopicCategoryCode>economy</gmd:MD_TopicCategoryCode>
+ </gmd:topicCategory>
+ <gmd:topicCategory>
+ <gmd:MD_TopicCategoryCode>environment</gmd:MD_TopicCategoryCode>
+ </gmd:topicCategory>
+ <gmd:extent>
+ <gmd:EX_Extent>
+ <gmd:geographicElement>
+ <gmd:EX_GeographicBoundingBox>
+ <gmd:westBoundLongitude>
+ <gco:Decimal>23.04</gco:Decimal>
+ </gmd:westBoundLongitude>
+ <gmd:eastBoundLongitude>
+ <gco:Decimal>25.05</gco:Decimal>
+ </gmd:eastBoundLongitude>
+ <gmd:southBoundLatitude>
+ <gco:Decimal>44.03</gco:Decimal>
+ </gmd:southBoundLatitude>
+ <gmd:northBoundLatitude>
+ <gco:Decimal>45.01</gco:Decimal>
+ </gmd:northBoundLatitude>
+ </gmd:EX_GeographicBoundingBox>
+ </gmd:geographicElement>
+ </gmd:EX_Extent>
+ </gmd:extent>
+ <gmd:extent>
+ <gmd:EX_Extent>
+ <gmd:temporalElement>
+ <gmd:EX_TemporalExtent>
+ <gmd:extent>
+ <gml:TimePeriod gml:id="ID_05d1d6c2-111f-4dc5-b51d-551a93cfdbbc" xsi:type="gml:TimePeriodType">
+ <gml:beginPosition>2014-05-20</gml:beginPosition>
+ <gml:endPosition>2014-05-21</gml:endPosition>
+ </gml:TimePeriod>
+ </gmd:extent>
+ </gmd:EX_TemporalExtent>
+ </gmd:temporalElement>
+ </gmd:EX_Extent>
+ </gmd:extent>
+ </gmd:MD_DataIdentification>
+ </gmd:identificationInfo>
+ <gmd:distributionInfo>
+ <gmd:MD_Distribution>
+ <gmd:distributionFormat>
+ <gmd:MD_Format>
+ <gmd:name gco:nilReason="inapplicable" />
+ <gmd:version gco:nilReason="inapplicable" />
+ </gmd:MD_Format>
+ </gmd:distributionFormat>
+ <gmd:transferOptions>
+ <gmd:MD_DigitalTransferOptions>
+ <gmd:onLine>
+ <gmd:CI_OnlineResource>
+ <gmd:linkage>
+ <gmd:URL>http://publicamundi.eu</gmd:URL>
+ </gmd:linkage>
+ </gmd:CI_OnlineResource>
+ </gmd:onLine>
+ </gmd:MD_DigitalTransferOptions>
+ </gmd:transferOptions>
+ </gmd:MD_Distribution>
+ </gmd:distributionInfo>
+ <gmd:dataQualityInfo>
+ <gmd:DQ_DataQuality>
+ <gmd:scope>
+ <gmd:DQ_Scope>
+ <gmd:level>
+ <gmd:MD_ScopeCode codeListValue="dataset" codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode">dataset</gmd:MD_ScopeCode>
+ </gmd:level>
+ </gmd:DQ_Scope>
+ </gmd:scope>
+ <gmd:report>
+ <gmd:DQ_DomainConsistency xsi:type="gmd:DQ_DomainConsistency_Type">
+ <gmd:measureIdentification>
+ <gmd:RS_Identifier>
+ <gmd:code>
+ <gco:CharacterString>Conformity_001</gco:CharacterString>
+ </gmd:code>
+ <gmd:codeSpace>
+ <gco:CharacterString>INSPIRE</gco:CharacterString>
+ </gmd:codeSpace>
+ </gmd:RS_Identifier>
+ </gmd:measureIdentification>
+ <gmd:result>
+ <gmd:DQ_ConformanceResult xsi:type="gmd:DQ_ConformanceResult_Type">
+ <gmd:specification>
+ <gmd:CI_Citation>
+ <gmd:title>
+ <gco:CharacterString>Commission Regulation (EU) No 1089/2010 of 23 November 2010 implementing Directive 2007/2/EC of the European Parliament and of the Council as regards interoperability of spatial data sets and services</gco:CharacterString>
+ </gmd:title>
+ <gmd:date>
+ <gmd:CI_Date>
+ <gmd:date>
+ <gco:Date>2010-12-08</gco:Date>
+ </gmd:date>
+ <gmd:dateType>
+ <gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode>
+ </gmd:dateType>
+ </gmd:CI_Date>
+ </gmd:date>
+ </gmd:CI_Citation>
+ </gmd:specification>
+ <gmd:explanation>
+ <gco:CharacterString>See the referenced specification</gco:CharacterString>
+ </gmd:explanation>
+ <gmd:pass>
+ <gco:Boolean>true</gco:Boolean>
+ </gmd:pass>
+ </gmd:DQ_ConformanceResult>
+ </gmd:result>
+ </gmd:DQ_DomainConsistency>
+ </gmd:report>
+ <gmd:lineage>
+ <gmd:LI_Lineage>
+ <gmd:statement>
+ <gco:CharacterString>history blah blah blah</gco:CharacterString>
+ </gmd:statement>
+ </gmd:LI_Lineage>
+ </gmd:lineage>
+ </gmd:DQ_DataQuality>
+ </gmd:dataQualityInfo>
+</gmd:MD_Metadata>
Added: sandbox/krejcmat/src/editor2.py
===================================================================
--- sandbox/krejcmat/src/editor2.py (rev 0)
+++ sandbox/krejcmat/src/editor2.py 2014-07-07 13:54:19 UTC (rev 61166)
@@ -0,0 +1,408 @@
+
+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
+
+from lxml import etree as ET
+import contextlib
+from audioop import lin2adpcm
+
+#===============================================================================
+#EDITOR
+#===============================================================================
+class MD():
+ def __init__(self,pathToXml=None):
+
+ self.path=pathToXml
+
+ self.initMD()
+ #self.valueStorageByID={} #dict wher key= wx.ID and valu = class MdWxInfo()
+
+
+ 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)
+
+#===============================================================================
+# 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
+
+ self.comboItems=[]
+
+ self._layout()
+ self.templatePath='data/grassInspireTemplate01.xml'
+ #self.templatePath='data/jinjatest.xml'
+
+ jinj=jt(self.templatePath)
+ self.mdDescription=jinj.mdDescription #list of object MdDescription
+ self.mdOWSTagStr=jinj.mdOWSTagStr
+
+ self.MDinfoDictNum=jinj.cretemdDescriptionDict('num')
+ self.MDinfoDictGroup=jinj.cretemdDescriptionDict('group')
+ self.MDinfoDictBox=jinj.cretemdDescriptionDict('inbox')
+ self.mdOWSTagStrList=jinj.mdOWSTagStrList
+ #self.initCreatorEmpty()
+ self.FILLER=''
+ self.idDict={}
+ self.initCreatorMD()
+
+ self.currWXid=None
+
+#------------------------------------------------------------------------ EVENTS
+ def cloneCtrl(self,evt):
+ print 'pes'
+ #a=MD()
+
+ def mdBuilder(self,evt):
+ string=evt.GetString()
+ id=evt.GetId()
+
+ #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,label,multi=True):
+ self.stbox=wx.StaticBox(self.nbPanel, label=label,id=ID_ANY, style=wx.RAISED_BORDER)
+ self.stbox.SetForegroundColour((0,0,0))
+ self.stbox.SetBackgroundColour((200,200,200))
+ self.stbox.SetFont(wx.Font(12,wx.NORMAL, wx.NORMAL, wx.NORMAL))
+
+ 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.AddSpacer(10 , 10, 1, wx.EXPAND)
+ 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)
+ self.nbPanelSizer.AddSpacer(20 , 20, 1, wx.EXPAND)
+ 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
+ self.sizer.AddSpacer(5 , 5, 1, wx.EXPAND)
+ else:
+ self.place=self.nbPanel
+ self.sizer=self.nbPanelSizer
+ self.sizer.AddSpacer(10 , 10, 1, wx.EXPAND)
+
+ 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.currWXid= self.valueCtrl.GetId()
+ val=self.mdDescription[self.cTmp].value
+ val=self.valueCtrl.SetValue(str(val))
+
+ #self.MD.valueStorageByID[self.valueCtrl.GetId()]=MdInfo(tag,val)
+
+
+ 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)
+
+#--------------------------------------------------------------------- COMBO BOX
+ def addCombobox(self):
+ self.combobox=wx.ComboBox(self.nbPanel,values=self.comboItems)
+ self._addComboBoxLay
+
+ 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)
+ #----------------------------------------------------------------------- CREATOR
+ 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 initCreatorMD(self):
+ self.addNotebook()
+ c=0
+ markgroup=[] #notebok panel marker
+ markbox=[] # box panel marker
+ markitem=[] #item panel marker
+
+ lstruct=self.mdOWSTagStrList
+ linfo=self.mdDescription
+
+ #print lstruct
+ #print len (lstruct)
+ #print len (linfo)
+ self.c=0
+ self.stop=False
+ self.max=len(linfo) ##TODO why -1? :-(
+
+
+ def isMultiLoop():
+ tmp=self.c
+ while '\t' in lstruct[self.c] and self.stop is False:
+ if '\t\t' in lstruct[self.c]:
+ self.c=tmp
+ self.stop=False
+ return True
+
+ self.plusC()
+
+ self.c=tmp
+ self.stop=False
+ return False
+
+
+ def inBox2():
+ self.k=0
+ print '-'*30
+
+ loop = lstruct[self.c-1]
+ str2=loop.replace(' md.',' self.md.')+':\n'
+ str2+='\t' +'self.addBox(linfo[' + str(self.c) + '].inbox)\n'
+
+ str1=str2
+ while '\t' in lstruct[self.c] and self.stop is False:
+ if not 'for' in str(lstruct[self.c]).split() or 'if' in str(lstruct[self.c]).split():
+ value= str(self.mdOWSTagStrList[self.c])
+ str1+= '\t' +'self.mdDescription['+str(self.c)+'].value='+str(value)+'\n'
+ str1+= '\t' +'self.idDict[self.currWXid]=' + 'linfo[' + str(self.c) + ']\n'
+ str1+= '\t' +'self.cTmp='+str(self.c)+'\n' #save wx id
+ str1+= '\t' +'self.addItem(linfo[' + str(self.c) + '], True)\n'
+ else:
+ loop = lstruct[self.c]
+ str2=loop.replace(' md.',' self.md.')+':\n'
+ self.plusC()
+ str1+=str2
+ 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.idDict[self.currWXid]=' + 'linfo[' + str(self.c) + ']\n'
+ str1+= '\t\t' +'self.cTmp='+str(self.c)+'\n' #save wx id
+ str1+= '\t\t' +'self.addItem(linfo[' + str(self.c) + '], True)\n'
+
+ print str1
+ self.plusC()
+
+ self.plusC()
+
+ str1+= '\tself.k+=1\n'
+ self.executeStr(str1,linfo)
+ self.c+=self.k - 1
+
+
+ def inBox():
+ self.k=0
+ print '-'*30
+ loop = lstruct[self.c-1]
+ str2=loop.replace(' md.',' self.md.')+':\n'
+ str2+='\tself.addBox(linfo[' + str(self.c) + '].inbox)\n'
+
+ str1=str2
+ while '\t' in lstruct[self.c] and self.stop is False:
+ value= str(self.mdOWSTagStrList[self.c])
+ str1+= '\tself.mdDescription['+str(self.c)+'].value='+str(value)+'\n'
+ str1+= '\tself.idDict[self.currWXid]=' + 'linfo[' + str(self.c) + ']\n'
+ str1+= '\tself.cTmp='+str(self.c)+'\n' #save wx id
+ str1+= '\tself.addItem(linfo[' + str(self.c) + '], True)\n'
+
+ self.plusC()
+
+ str1+= '\tself.k+=1\n'
+ self.executeStr(str1,linfo)
+ self.c+=self.k - 1
+
+ while self.stop is False:
+ group=linfo[self.c].group
+ if group not in markgroup: #if group is not created
+ markgroup.append(group)
+ self.addNotebookPage(linfo[self.c].group)
+
+ if '\t' in lstruct[self.c]and self.stop is False:
+
+ if isMultiLoop():
+ print '2loops'
+ inBox2()
+ else:
+ print '1loops'
+ inBox()
+
+ elif not 'for' in str(lstruct[self.c]).split() or 'if' in str(lstruct[self.c]).split():
+ value= 'self.'+str(self.mdOWSTagStrList[self.c]).replace('\n','')
+ addStr='self.mdDescription['+str(self.c)+'].value='+str(value)
+ print '--'*80
+ print addStr
+ self.executeStr(addStr,False)
+ print '--'*80
+ self.cTmp=self.c
+ self.addItem(linfo[self.c], False)
+ self.plusC()
+ else:
+ self.plusC()
+
+
+ #print self.FILLER
+#------------------------------------------------------------- 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=''
+ if item.name !=None:
+ string+='name: '+ item.name + '\n'
+ if item.desc !=None:
+ string+='description: ' + item.desc + '\n'
+ if item.example !=None:
+ 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
Modified: sandbox/krejcmat/src/jinjainfo.py
===================================================================
--- sandbox/krejcmat/src/jinjainfo.py 2014-07-07 10:24:30 UTC (rev 61165)
+++ sandbox/krejcmat/src/jinjainfo.py 2014-07-07 13:54:19 UTC (rev 61166)
@@ -20,7 +20,7 @@
from jinja2 import Environment, FileSystemLoader
class MdDescription():
- def __init__(self,tag, name = None, desc = None, example = None, type = None, multi = 1, inboxmulti=None, group = None, inbox = None, multiline = None ):
+ def __init__(self,tag, name = None, desc = None, example = None, type = None, multi = 0, inboxmulti=None, group = None, inbox = None, multiline = None, value=None,id=None,num=None ):
self.tag=tag
self.name = name
@@ -32,31 +32,52 @@
self.inbox = inbox
self.inboxmulti=inboxmulti #multiplicity in subrotoup (in static box)
self.multiline=multiline #type of ctrl text
-
+ self.num=num
+ self.value=value
+
class JinjaTemplateInfo():
def __init__(self,template):
- self.md_info=[]
- self.md_sources=[]
+ self.mdDescription=[] #list of object MdDescription
+ self.mdOWSTag=[] #list of object in jinja template
self.template=template
- self.objectstr=''
-
- self.setupMdInfo()
- self.setupMdSources()
- def getMdInfoGroupByGroupsDict(self):
- dict={}
- for md in self.md_info:
- key = md.group
- if key not in dict:
- dict.setdefault(key, [])
- dict[key].append(md)
- return dict
+ self.mdOWSTagStr=''
+ self.mdOWSTagStrList=[]
+ #self.mdDescriptionStr=''
+
+
+ self._readJinjaInfo()
+ self._readJinjaTags()
+ self._domdOWSTagStr()
+
+ def getLinebyNum(self,num):
+ n=0
+ for line in self.mdOWSTagStr.splitlines():
+ if n==num:
+ return line
+ n+=1
+
+ def getItemByNum(self,num):
+ dict=self.cretemdDescriptionDict('num')
+ return dict[num]
- def getMdInfoGroupByGroupsList(self):
+ def cretemdDescriptionDict(self,akey):
+ box={}
+ for md in self.mdDescription:
+ skey='md.'+str(akey)
+ # print skey
+ key = eval(skey)
+ if key is not None:
+ if key not in box:
+ box.setdefault(key, [])
+ box[key].append(md)
+ return box
+
+ def getmdDescriptionGroupByGroupsList(self):
#make dict with key=inbox(staticbox in gui)
box={}
- for md in self.md_info:
+ for md in self.mdDescription:
key = md.inbox
if key is not None:
if key not in box:
@@ -82,7 +103,7 @@
groupDict[key].append(item)
#add items without box
- for md in self.md_info:
+ for md in self.mdDescription:
ibox=md.inbox
key=md.group
if ibox is None:
@@ -104,63 +125,69 @@
for item in group:
fgroup.append(item)
finalList.append(fgroup)
-
+ self.grupedList=finalList
return finalList
- def getObjectsString(self):
- self.objectstr=""
+ def _domdOWSTagStr(self):
+ self.mdOWSTagStr=""
tab=0
- for item in self.md_sources:
+ for item in self.mdOWSTag:
if str(item).find(" endfor ")!=-1 or str(item).find(" endif ")!=-1 or str(item).find(" endwhile ")!=-1:
tab-=1
continue
- tabstr='\t'*tab
- self.objectstr+=tabstr + item + '\n'
+ tabstr='\t'*tab
+ str1=tabstr + item[1:] + '\n'
+ self.mdOWSTagStr+=str1
+ self.mdOWSTagStrList.append(tabstr + item[1:])
+
if str(item).find(" for ")!=-1 or str(item).find(" if ")!=-1 or str(item).find(" while ")!=-1:
tab+=1
- return self.objectstr
-
- def setupMdSources(self):
+ def _readJinjaTags(self):
try:
with open( self.template, "r") as f:
for line in f:
if str(line).find("{{")!=-1:#if found start of comments
object = self._findBetween(line,"{{","}}")
- self.md_sources.append(object)
+ self.mdOWSTag.append(object)
if str(line).find("{%")!=-1:
object = self._findBetween(line,"{%","-%}")
- self.md_sources.append(object)
+ self.mdOWSTag.append(object)
except IOError as e:
print "I/O error({0}): {1}".format(e.errno, e.strerror)
-
- def _findBetween(self, s, first, last ):
- try:
- start = s.index( first ) + len( first )
- end = s.index( last, start )
- return s[start:end]
- except ValueError:
- return ""
-
- def setupMdInfo(self):
+
+ def _readJinjaInfo(self):
#template = 'data/grassBasicISOTemplate01.xml'
+ counter=1
+
try:
with open( self.template, "r") as f:
for line in f:
+
if str(line).find("{#")!=-1:#if found start of comments
+
+ #print 'num' + str(counter)
values = self._findBetween(line,"{#","#}")
- exe_str = "self.md_info.append(MdDescription(%s))"%values
+ values+=',num='+str(counter)
+ exe_str = "self.mdDescription.append(MdDescription(%s))"%values
+
eval(exe_str)
-
+ counter+=1
except IOError as e:
print "I/O error({0}): {1}".format(e.errno, e.strerror)
+ def _findBetween(self, s, first, last ):
+ try:
+ start = s.index( first ) + len( first )
+ end = s.index( last, start )
+ return s[start:end]
+ except ValueError:
+ return ""
-
if __name__ == "__main__":
main()
\ No newline at end of file
More information about the grass-commit
mailing list