[GRASS-SVN] r61538 - in sandbox/krejcmat/src: . templates
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 5 15:04:09 PDT 2014
Author: krejcmat
Date: 2014-08-05 15:04:08 -0700 (Tue, 05 Aug 2014)
New Revision: 61538
Modified:
sandbox/krejcmat/src/editor3.py
sandbox/krejcmat/src/g.gui.metadata.py
sandbox/krejcmat/src/mdgrass.py
sandbox/krejcmat/src/mdutil.py
sandbox/krejcmat/src/templates/grassGRASSTemplateFinal.xml
sandbox/krejcmat/src/templates/grassInspireTemplateFinal.xml
Log:
fix dynamic removing of keywords widgets. etc
Modified: sandbox/krejcmat/src/editor3.py
===================================================================
--- sandbox/krejcmat/src/editor3.py 2014-08-05 21:45:19 UTC (rev 61537)
+++ sandbox/krejcmat/src/editor3.py 2014-08-05 22:04:08 UTC (rev 61538)
@@ -18,11 +18,11 @@
import copy
import re
import os
-import string
+
import logging
from core.gcmd import RunCommand, GError, GMessage
from gui_core.widgets import IntegerValidator, NTCValidator,SimpleValidator,\
- TimeISOValidator, EmailValidator,EmptyValidator
+ TimeISOValidator, EmailValidator#,EmptyValidator
import sys
import mdutil
@@ -35,7 +35,7 @@
def __init__(self, pathToXml=None):
self.path = pathToXml
self.owslibInfo = None
-
+
def initMD(self, path=None):
if path is None:
self.md = MD_Metadata(md=None)
@@ -44,13 +44,12 @@
io=open(path,'r')
str1=''
for line in io.readlines():
- str1+=self._removeNonAscii(line)
+ str1+=mdutil.removeNonAscii(line)
io.close()
io1=open(path,'w')
io1.write(str1)
io1.close()
- #mdutil
try:
tree = ET.parse(path)
root = tree.getroot()
@@ -61,13 +60,7 @@
except Exception, e:
GError('Error loading xml:\n'+str(e))
-
- def _removeNonAscii(self,s):
- s= filter(lambda x: x in string.printable, s)
- return s
-
-
- def saveToXML(self, md,owsTagList, jinjaPath, outPath=None, xmlOutName=None):
+ def saveToXML(self, md,owsTagList, jinjaPath, outPath=None, xmlOutName=None,msg=True):
# if output file name is None, use map name and add postfix
self.dirpath = os.path.dirname(os.path.realpath(__file__))
self.md = md
@@ -88,7 +81,7 @@
str1=''
for line in xml.readlines():
- line=self._removeNonAscii(line)
+ line==mdutil.removeNonAscii(line)
str1+=line
xml.close
io=open(jinjaPath,'w')
@@ -111,10 +104,13 @@
xml_file = open(outPath, "w")
xml_file.write(iso_xml)
xml_file.close()
- GMessage('File exported to: %s'% outPath)
+
+ if msg:
+ GMessage('File exported to: %s'% outPath)
+ return outPath
except Exception, e:
GError('Error writing xml:\n'+str(e))
- return outPath
+
#=========================================================================
# CREATE BOX (staticbox+button(optional)
@@ -125,11 +121,7 @@
wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
self.label = label
self.mdItems = list()
- self.stbox = wx.StaticBox(
- self,
- label=label,
- id=ID_ANY,
- style=wx.RAISED_BORDER)
+ self.stbox = wx.StaticBox(self,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))
@@ -159,60 +151,45 @@
self.stBoxSizer.AddSpacer(5, 5, 1, wx.EXPAND)
if multi:
- self.addBoxButt = wx.Button(
- self,
- id=ID_ANY,
- size=(
- 30,
- 30),
- label='+')
+ self.addBoxButt = wx.Button(self,id=ID_ANY,size=(30,30),label='+')
self.boxButtonSizer.Add(self.addBoxButt, 0)
-
self.addBoxButt.Bind(EVT_BUTTON, self.duplicateBox)
if rmMulti:
- self.rmBoxButt = wx.Button(
- self,
- id=ID_ANY,
- size=(
- 30,
- 30),
- label='-')
+ self.rmBoxButt = wx.Button(self,id=ID_ANY,size=(30,30),label='-')
self.boxButtonSizer.Add(self.rmBoxButt, 0)
-
self.rmBoxButt.Bind(EVT_BUTTON, self.removeBox)
def addDuplicatedItem(self, item, id):
- self.mdItems.append(item)
+ #self.mdItems.append(item)
self.stBoxSizer.Add(item, flag=wx.EXPAND, proportion=1)
self.stBoxSizer.AddSpacer(5, 5, 1, wx.EXPAND)
- # self.SetSizerAndFit(self.stBoxSizer)
+ #w, h = self.GetParent().GetClientSize()
+ self.GetParent().Layout()
+ #self.GetParent().SetSize((w+1, h+1))
- # self.stbox.Fit()
- w, h = self.GetParent().GetClientSize()
- self.GetParent().SetSize((w + 1, h + 1))
- # self.stbox.SetSize()
-
def getCtrlID(self):
return self.GetId()
def removeBox(self, evt):
for item in self.mdItems:
- # remove from MdDescritpion()
item.mdDescription.removeMdItem(item)
self.GetParent().removeBox(self)
def removeMdItem(self, mdDes, items):
mdDes.mdDescription.removeMdItem(mdDes)
- #self.stBoxSizer.Remove(mdDes)
- #self.stbox.Refresh()
for item in items:
- item.Destroy()
- #mdDes.Destroy()
- #self.panelSizer.Fit()
- #self.SetSizerAndFit(self.panelSizer)
-
- #self.SetSizerAndFit(self.stBoxSizer)
+ try:
+ item.Destroy()
+ except:
+ pass
+ self.stBoxSizer.RemovePos(-1)
+ self.stBoxSizer.Remove(mdDes)
+
+ #self.stbox.Layout()
+ #self.stBoxSizer.Layout()
+ #self.panelSizer.Layout()
+ self.GetParent().Layout()
def duplicateBox(self, evt):
parent = self.GetParent()
@@ -227,20 +204,26 @@
if boxlabel:
itemList = list()
self.mdBox = MdBox(parent, boxlabel)
- for i in mdItems:
-
- i = i.mdDescription
- mdItem1 = MdItem(self.mdBox, i)
- # mdItem1.setValue('')
+ for i in mdItems:#check if item has multiple button
+ try:
+ i.addItemButt.GetLabel()
+ multi=True
+ except:
+ multi=False
+ i = i.mdDescription
+ mdItem1 = MdItem(parent=self.mdBox,item= i,multiplicity=multi,isFirstNum=1)
itemList.append(mdItem1)
i.addMdItem(mdItem1)
- # #print i.mdItem
self.mdBox.addItems(itemList, False, True)
else:
- self.mdItem = MdItem(parent, mdItems, False, True)
+ self.mdItem = MdItem(parent=parent,
+ item= mdItems,
+ multiplicity=False,
+ rmMulti=True,
+ isFirstNum=-1)
+
if mdItems.inbox is not None:
- #print 'here------------1'
mdItems.addMdItem(self.mdItem, mdItemOld)
else:
mdItems.addMdItem(self.mdItem)
@@ -251,7 +234,6 @@
# ADD METADATA ITEM (label+ctrlText+button(optional)
#=========================================================================
-
class MdItem(wx.BoxSizer):
def __init__(self,parent,item,multiplicity=None,rmMulti=False,isFirstNum=-1,chckBox=False):
@@ -259,7 +241,9 @@
self.isValid=False
self.isChecked=False
self.mdDescription = item
-
+ self.chckBox=chckBox
+ self.multiple=multiplicity
+
if multiplicity is None:
self.multiple = item.multiplicity
@@ -271,7 +255,7 @@
self.tagText = wx.StaticText(parent=parent, id=ID_ANY, label=item.name)
- if chckBox ==False:
+ if self.chckBox ==False:
if item.multiline is True:
self.valueCtrl = wx.TextCtrl(parent, id=ID_ANY, size=(0, 55),
validator=self.validators(item.type),
@@ -305,19 +289,18 @@
self.rmItemButt = wx.Button(parent, -1, size=(30, 30), label='-')
self.rmItemButt.Bind(EVT_BUTTON, self.removeItem)
- if chckBox:
-
- self.chckBox=wx.CheckBox(parent, -1, size=(30, 30))
- self.chckBox.Bind(wx.EVT_CHECKBOX,self.onChangeChckBox)
- self.chckBox.SetValue(True)
+ if self.chckBox:
+ self.chckBoxEdit=wx.CheckBox(parent, -1, size=(30, 30))
+ self.chckBoxEdit.Bind(wx.EVT_CHECKBOX,self.onChangeChckBox)
+ self.chckBoxEdit.SetValue(True)
self.isChecked=True
self.valueCtrl.Disable()
self.createInfo()
self.tip = wx.ToolTip(self.infoTip)
- #
- self._addItemLay(item.multiline, rmMulti,chckBox)
-
+
+ self._addItemLay(item.multiline, rmMulti)
+
def validators(self,validationStyle):
if validationStyle=='email':
@@ -336,7 +319,7 @@
return SimpleValidator('')
def onChangeChckBox(self,evt):
- self.isChecked=self.chckBox.GetValue()
+ self.isChecked=self.chckBoxEdit.GetValue()
if self.isChecked:
self.valueCtrl.Disable()
else:
@@ -348,26 +331,25 @@
def createInfo(self):
string = ''
if self.mdDescription.ref is not None:
- string += self.mdDescription.ref + '\n\n'
+ string += self.mdDescription.ref+'\n\n'
if self.mdDescription.name is not None:
- string += 'NAME: \n' + self.mdDescription.name + '\n\n'
+ string += 'NAME: \n'+self.mdDescription.name+'\n\n'
if self.mdDescription.desc is not None:
- string += 'DESCRIPTION: \n' + self.mdDescription.desc + '\n\n'
+ string += 'DESCRIPTION: \n'+self.mdDescription.desc+'\n\n'
if self.mdDescription.example is not None:
- string += 'EXAMPLE: \n' + self.mdDescription.example + '\n\n'
+ string += 'EXAMPLE: \n'+self.mdDescription.example+'\n\n'
if self.mdDescription.type is not None:
- string += 'DATA TYPE: \n' + self.mdDescription.type + '\n\n'
- string += '- -'*30 + '\n'
+ string += 'DATA TYPE: \n'+self.mdDescription.type+'\n\n'
+ string += '- -'*30+'\n'
if self.mdDescription.statements is not None:
- string += 'Jinja template info: \n' + self.mdDescription.statements + '\n'
+ string += 'Jinja template info: \n'+self.mdDescription.statements+'\n'
if self.mdDescription.statements1 is not None:
- string += self.mdDescription.statements1 + '\n'
- string += 'OWSLib info:\n' + self.mdDescription.tag
+ string += self.mdDescription.statements1+'\n'
+ string += 'OWSLib info:\n'+self.mdDescription.tag
self.infoTip = string
def removeItem(self, evt):
- # remove widgets from
list = [self.valueCtrl, self.tagText]
try:
list.append(self.rmItemButt)
@@ -375,7 +357,6 @@
pass
try:
list.append(self.chckBox)
-
except:
pass
self.valueCtrl.GetParent().removeMdItem(self, list)
@@ -387,10 +368,7 @@
parent = self.valueCtrl.GetParent()
# if parent box
if self.mdDescription.inbox:
- duplicator = MdWxDuplicator(
- mdItems=self.mdDescription,
- parent=parent,
- mdItemOld=self)
+ duplicator = MdWxDuplicator( mdItems=self.mdDescription,parent=parent,mdItemOld=self)
else:
duplicator = MdWxDuplicator(self.mdDescription, parent)
@@ -401,16 +379,24 @@
self.valueCtrl.GetId())
def setValue(self, value):
- ##print "value ",value
-
if value is None or value is '':
- self.valueCtrl.SetBackgroundColour((245,204,230))#red
-
+ if self.chckBox:
+ self.chckBoxEdit.SetValue(False)
+ self.isChecked=False
+ self.valueCtrl.SetBackgroundColour((245,204,230))#red
self.valueCtrl.SetValue('')
+ self.valueCtrl.Enable()
- elif value=='$NULL':
+ elif self.chckBox and value=='$NULL':
self.valueCtrl.SetBackgroundColour((255,255,82))#yellow
self.valueCtrl.SetValue('')
+ if self.chckBox:
+ self.chckBoxEdit.SetValue(False)
+ self.isChecked=False
+ self.valueCtrl.Enable()
+
+ elif value=='$NULL':
+ self.valueCtrl.SetValue('')
else:
value=value.replace('"','')
value=value.replace("'",'')
@@ -419,7 +405,6 @@
def getValue(self):
-
return mdutil.replaceXMLReservedChar(self.valueCtrl.GetValue())
def getCtrlID(self):
@@ -431,7 +416,7 @@
else:
return None
- def _addItemLay(self, multiline, rmMulti, chckBox):
+ def _addItemLay(self, multiline, rmMulti):
self.textFieldSizer = wx.BoxSizer(wx.HORIZONTAL)
if multiline is True:
self.textFieldSizer.Add(self.valueCtrl,proportion=1,flag=wx.EXPAND)
@@ -439,19 +424,16 @@
self.textFieldSizer.Add(self.valueCtrl, proportion=1)
if self.multiple:
- self.textFieldSizer.Add(self.addItemButt, 0)
+ self.textFieldSizer.Add(self.addItemButt, 0)
if rmMulti:
- self.textFieldSizer.Add(self.rmItemButt, 0)
+ self.textFieldSizer.Add(self.rmItemButt, 0)
- if chckBox:
- self.textFieldSizer.Add(self.chckBox, 0)
+ if self.chckBox:
+ self.textFieldSizer.Add(self.chckBoxEdit, 0)
self.Add(item=self.tagText, proportion=0)
self.Add(item=self.textFieldSizer, proportion=0, flag=wx.EXPAND)
-
-
-
#=========================================================================
# ADD NOTEBOOK PAGE
#=========================================================================
@@ -470,7 +452,6 @@
self.SetSizer(self.mainSizer)
def _getIndex(self):
-
self.sizerIndex += 1
return self.sizerIndex
@@ -487,7 +468,6 @@
self.sizerIndexDict[i.getCtrlID()] = self._getIndex()
self.mainSizer.Add(i, proportion=0, flag=wx.EXPAND)
else:
-
self.sizerIndexDict[item.getCtrlID()] = self._getIndex()
self.mainSizer.Add(item, proportion=0, flag=wx.EXPAND)
@@ -609,16 +589,9 @@
'''
for c in range(self.max):
if '|length' in str(tagStringLst[c]):
-
a = tagStringLst[c]
- a = a.replace(
- '|length',
- ')').replace(
- 'if ',
- 'if len(self.')
-
+ a = a.replace('|length',')').replace('if ','if len(self.')
tagStringLst[c] = a
-
if 'zip(' in tagStringLst[c]:
sta = tagStringLst[c]
tagStringLst[c] = sta.replace('md.', 'self.md.')
@@ -635,7 +608,6 @@
tab1='\t'
staTMP=staTMP.replace('\t','')+":\n"+tab+'self.isValidS=True'
- #print staTMP
try:#if loop for in for
self.executeStr(staTMP, False)
except:
@@ -648,11 +620,10 @@
else:
return tab1+'for n in range(1)'
- def inBlock(): # function in def initCreatorMD(self): !!!
+ def inBlock():
'''
@note:
'''
- ##print 'c--' , self.c
IFStatements = False
statements = tagStringLst[self.c - 1]
if 'if' in statements.split():
@@ -662,17 +633,15 @@
str2 = 'numOfSameBox=0\n'
str2 += looptmp
-
str2 += ':\n'
- str2 += '\t' + 'self.ItemList=list()\n' # initialize list
- str2 += '\t' + 'numOfSameBox+=1\n'
+ str2 += '\t'+'self.ItemList=list()\n' # initialize list
+ str2 += '\t'+'numOfSameBox+=1\n'
box = False
if self.mdDescription[self.c].inbox:
box = True
- str2 += '\t' + \
- 'box=MdBox(self.nbPage,mdDescrObj[' + str(self.c) + '].inbox)\n' # add box
+ str2 += '\t'+'box=MdBox(self.nbPage,mdDescrObj['+str(self.c)+'].inbox)\n' # add box
str1 = str2
itemCounter=1
@@ -684,31 +653,27 @@
and 'if' not in str(tagStringLst[self.c]).split():
value = str(self.mdOWSTagStrList[self.c])
- str1 += '\t' + \
- 'self.mdDescription[' + str(self.c) + "].addStatements('" + loop + "')\n"
+ str1 +='\t'+'self.mdDescription['+str(self.c)+"].addStatements('"+loop+"')\n"
if box:
- str1 += '\t' + \
- 'it=MdItem(parent=box,item=mdDescrObj[' + str(self.c) + '],isFirstNum=numOfSameBox,chckBox=self.templateEditor)\n'
+ str1 += '\t'+'it=MdItem(parent=box,item=mdDescrObj['+str(self.c)+'],isFirstNum=numOfSameBox,chckBox=self.templateEditor)\n'
else:
- str1 += '\t' + \
- 'it=MdItem(parent=self.nbPage,item=mdDescrObj[' + str(self.c) + '],isFirstNum=numOfSameBox,chckBox=self.templateEditor)\n'
+ str1 += '\t'+ 'it=MdItem(parent=self.nbPage,item=mdDescrObj['+str(self.c)+'],isFirstNum=numOfSameBox,chckBox=self.templateEditor)\n'
if self.isValidS: #if metatdata are loaded to owslib
if IFStatements:
- str1 += '\t' + 'it.setValue(self.' + str(value) + ')\n'
+ str1 += '\t'+'it.setValue(self.'+str(value)+')\n'
else:
- str1 += '\t' + 'it.setValue(' + str(value) + ')\n'
+ str1 += '\t'+'it.setValue('+str(value)+')\n'
else:
if IFStatements:
- str1 += '\t' + 'it.setValue("")\n'
+ str1 += '\t'+'it.setValue("")\n'
else:
- str1 += '\t' + 'it.setValue("")\n'
+ str1 += '\t'+'it.setValue("")\n'
- str1 += '\t' + \
- 'self.mdDescription[' + str(self.c) + '].addMdItem(it)\n'
- str1 += '\t' + 'self.ItemList.append(it)\n'
- tab = '\t'
+ str1 += '\t'+'self.mdDescription['+str(self.c)+'].addMdItem(it)\n'
+ str1 += '\t'+'self.ItemList.append(it)\n'
+ tab = '\t'
self.plusC()
else: # if statements in statements
@@ -718,13 +683,13 @@
if '["keywords"]' in statements:
keyword = True
- str2 += '\t' + 'self.keywordsList=[]\n'
+ str2 += '\t'+'self.keywordsList=[]\n'
- str2 += '\t' + 'numOfSameItem=0\n'
+ str2 += '\t'+'numOfSameItem=0\n'
loop2=statements.replace(' md.', ' self.md.')
looptmp1=chckIfJumpToLoop(loop2)
#print '============'*5
- str2 += looptmp1 + ':\n'
+ str2 += looptmp1+':\n'
self.plusC()
str1 += str2
itemCounter+=1
@@ -732,46 +697,35 @@
itemCounter+=1
value = str(self.mdOWSTagStrList[self.c])
# save information about loops
- str1 += '\t\t' + 'numOfSameItem+=1\n'
- str1 += '\t\t' + \
- 'self.mdDescription[' + str(self.c) + "].addStatements('" + loop + "')\n"
- str1 += '\t\t' + \
- 'self.mdDescription[' + str(self.c) + "].addStatements1('" + loop2 + "')\n"
+ str1 += '\t\t'+'numOfSameItem+=1\n'
+ str1 += '\t\t'+'self.mdDescription['+str(self.c)+"].addStatements('"+loop+"')\n"
+ str1 += '\t\t'+'self.mdDescription['+str(self.c)+"].addStatements1('"+loop2+"')\n"
if box:
- str1 += '\t\t' + \
- 'it=MdItem(parent=box,item=mdDescrObj[' + str(self.c) + '],isFirstNum=numOfSameItem,chckBox=self.templateEditor)\n'
-
+ str1 += '\t\t'+'it=MdItem(parent=box,item=mdDescrObj['+str(self.c)+'],isFirstNum=numOfSameItem,chckBox=self.templateEditor)\n'
else:
- str1 += '\t\t' + \
- 'it=MdItem(self.nbPage,mdDescrObj[' + str(self.c) + '],isFirstNum=numOfSameItem,chckBox=self.templateEditor)\n'
-
+ str1 += '\t\t'+'it=MdItem(self.nbPage,mdDescrObj['+str(self.c)+'],isFirstNum=numOfSameItem,chckBox=self.templateEditor)\n'
+
if self.isValidS:
- str1 += '\t\t' + 'it.setValue(' + str(value) + ')\n'
+ str1 += '\t\t'+'it.setValue('+str(value)+')\n'
else:
- str1 += '\t\t' + 'it.setValue("")\n'
+ str1 += '\t\t'+'it.setValue("")\n'
- str1 += '\t\t' + 'self.ItemList.append(it)\n'
-
+ str1 += '\t\t'+'self.ItemList.append(it)\n'
if keyword:
- str1 += '\t\t' + 'self.keywordsList.append(it)\n'
- str1 += '\t' + \
- 'self.mdDescription[' + str(self.c) + '].addMdItem(self.keywordsList)\n'
+ str1 += '\t\t'+'self.keywordsList.append(it)\n'
+ str1 += '\t' +'self.mdDescription['+str(self.c)+'].addMdItem(self.keywordsList)\n'
else:
- str1 += '\t\t' + \
- 'self.mdDescription[' + str(self.c) + '].addMdItem(it)\n'
+ str1 += '\t\t'+'self.mdDescription['+str(self.c)+'].addMdItem(it)\n'
tab = '\t\t'
self.plusC()
-
- ##print '-' * 80
- ##print mdDescrObj[self.c].inboxmulti
if box:
- str1 += tab + \
+ str1 += tab+\
'box.addItems(items=self.ItemList,multi=mdDescrObj[self.c].inboxmulti,isFirstNum=numOfSameBox)\n'
- str1 += tab + 'self.nbPage.addItem(box)\n'
+ str1 += tab+'self.nbPage.addItem(box)\n'
else:
- str1 += tab + 'self.nbPage.addItem(self.ItemList)\n'
+ str1 += tab+'self.nbPage.addItem(self.ItemList)\n'
self.executeStr(str1, mdDescrObj)
@@ -801,34 +755,21 @@
# if starting the statements
if '\t' in tagStringLst[self.c]and self.stop is False:
- #print '-'*50
inBlock()
- #print '-'*50
# if just singe item without statements
elif 'for' not in str(tagStringLst[self.c]).split() and 'if' not in str(tagStringLst[self.c]).split():
- #print '-'*50
-
it = MdItem(parent=self.nbPage, item=mdDescrObj[self.c],chckBox=self.templateEditor)
- ##print 'hodnota--', mdDescrObj[self.c].tag
- value = 'self.' + \
- str(self.mdOWSTagStrList[self.c]).replace('\n', '')
-
-
+ value = 'self.'+str(self.mdOWSTagStrList[self.c]).replace('\n', '')
value = eval(value)
if value is None:
value=''
it.setValue(value)
-
self.mdDescription[self.c].addMdItem(it)
self.nbPage.addItem(it)
self.plusC()
- #print '-'*50
else:
self.plusC()
-
-
#----------------------------------------------------------- GUI GENERATOR END
-
def defineTemplate(self):
try:
@@ -842,25 +783,20 @@
forST=0
ifST=0
forSTS=False
- ifSTS=False
+ ifSTS=False
for line in template.readlines():
if '{% for' in line:
- #print'===='*50
- #printline
forSTS=True
forST+=1
- #print'for ----', forST
- #print'===='*50
+
if '{% if' in line:
- #print'===='*50
ifSTS=True
ifST+=1
- #print'if ----', ifST
- #print'===='*50
-
+
for r,item in enumerate(self.mdDescription):
str1=item.selfInfoString
+
if str1 in line: #owslib definition in line
try:
if item.mdItem[0].isChecked==True:
@@ -880,66 +816,57 @@
except:
pass
if chcked: #chckbox in gui
- #print 'if chcked-----'
if forSTS:
forSTS=False
forST-=1
+
if ifSTS:
ifSTS=False
ifST-=1
-
- #print str1
+
owsTagList.append(str1)
templateStr= '{{ owsTagList['+str(indexowsTagList)+'] }}'
- indexowsTagList+=1
- finalTemplate+=line.replace(str1,templateStr)
+ indexowsTagList+=1
+
+ line=line.replace(str1,templateStr)
+ tag='{{ '+item.tag+' }}'
+ line=line.replace(tag,templateStr)
+ finalTemplate+=line
continue
if chcked==False:
if '{% endfor -%}' in line and forST==0:
- #print'===='*50
- #print'{% endfor -%}'
- #printstr1
- #printline
-
- #print'===='*50
str1='{% endfor -%}'
owsTagList.append(str1)
templateStr= '{{ owsTagList['+str(indexowsTagList)+'] }}'
indexowsTagList+=1
- finalTemplate+=line.replace(str1,templateStr)
- #forST-=1
-
+
+ line=line.replace(str1,templateStr)
+ tag='{{'+item.tag+'}}'
+ line=line.replace(tag,templateStr)
+ finalTemplate+=line
+
elif '{% endif -%}' in line and ifSTS==0:
- #print'===='*50
- #printstr1
- #printline
- #print'{% endif -%}'
- #print'===='*50
str1= '{% endif -%}'
owsTagList.append(str1)
templateStr= '{{ owsTagList['+str(indexowsTagList)+'] }}'
indexowsTagList+=1
- finalTemplate+=line.replace(str1,templateStr)
- #ifSTS-=1
+
+ line=line.replace(str1,templateStr)
+ tag='{{'+item.tag+'}}'
+ line=line.replace(tag,templateStr)
+ finalTemplate+=line
else:
finalTemplate+=line
-
chcked=False
- #print line
- #print '-*****----****----'
-
-
head, tail = os.path.split(self.templatePath)
tail='EXPT'+tail
self.templatePath=os.path.join(head,tail)
templateOut=open(self.templatePath,'w')
templateOut.write(finalTemplate)
templateOut.close()
- ##print'defineTemplate 4'
- #print finalTemplate
- #print self.templatePath
+
return owsTagList
#----------------------------------------- FILL OWSLib BY EDITED METADATA IN GUI
@@ -952,7 +879,7 @@
'''Fill owslib by metadata from gui
'''
def chckEnd():
- if (self.c + 1) == self.max:
+ if (self.c+1) == self.max:
self.stop = True
def prepareStatements():
@@ -962,32 +889,20 @@
for c in range(self.max):
if '|length' in str(mdDes[c].tag):
a = mdDes[c].tag
- a = a.replace(
- '|length',
- ')').replace(
- 'if ',
- 'if len(self.')
+ a = a.replace('|length',')').replace('if ','if len(self.')
mdDes[c].tag = a
if '|length' in str(mdDes[c].statements):
a = mdDes[c].statements
- a = a.replace(
- '|length',
- ')').replace(
- 'if ',
- 'if len(self.')
+ a = a.replace('|length',')').replace('if ','if len(self.')
mdDes[c].statements = a
if '|length' in str(mdDes[c].statements1):
a = mdDes[c].statements1
- a = a.replace(
- '|length',
- ')').replace(
- 'if ',
- 'if len(self.')
+ a = a.replace('|length',')').replace('if ','if len(self.')
mdDes[c].statements1 = a
def chckIf1Statements():
try:
- if md[self.c + 1].statement:
+ if md[self.c+1].statement:
return True
else:
return False
@@ -996,11 +911,10 @@
def chckIf2xStatements():
if 'if'in mdDes[
- self.c].tag.split() or 'for' in mdDes[
- self.c].tag.split():
+ self.c].tag.split() or 'for' in mdDes[ self.c].tag.split():
try:
- if 'if'in mdDes[self.c + 1].tag.split() or\
- 'for'in mdDes[self.c + 1].tag.split():
+ if 'if'in mdDes[self.c+1].tag.split() or \
+ 'for'in mdDes[self.c+1].tag.split():
return True
else:
return False
@@ -1012,16 +926,12 @@
'''
str1 = ''
for wxCtrl in mdDes[self.c].mdItem:
- #print "item"
if wxCtrl.getValue() is not None:
- str1 += 'self.' + \
- mdDes[self.c].tag + '="' + str(wxCtrl.getValue()) + '"\n'
+ str1 += 'self.'+ mdDes[self.c].tag+'="'+str(wxCtrl.getValue())+'"\n'
self.executeStr1(str1, mdDes[self.c])
str1 = ''
self.plusC()
-
- #def add
-
+
def inStatements():
'''possible combinations of statements
(1) IF
@@ -1036,32 +946,27 @@
cTmp = self.c
tag = str(mdDes[cTmp].tag).split()
- tag1 = 'self.' + str(tag[-1])
- tag = 'self.' + str(tag[-1]) + '.append(self.val)\n'
+ tag1 = 'self.'+str(tag[-1])
+ tag = 'self.'+str(tag[-1])+'.append(self.val)\n'
self.plusC()
# statements of current item
stat = mdDes[self.c].statements
str1 = ''
- # how many MdItem() is in object
leng = len(mdDes[self.c].mdItem)
# (2.1) IF NECESSARY TO INITIALIZE OWSLIB OBJECT
if mdDes[cTmp].object and 'if' not in mdDes[cTmp].tag.split():
- #print 'init owslib'
- # self.val=CI_ResponsibleParty()
- objStr = 'self.val=' + mdDes[cTmp].object + '\n'
- ##print 'c--po',self.c
+ objStr = 'self.val='+mdDes[cTmp].object+'\n'
+
for n in range(leng):
numOfItems = 0
str1 += objStr
- # #print self.c, 'pred'
while mdDes[self.c].statements == stat and self.stop is False:
-
metadata = re.split(r'[.]', mdDes[self.c].tag)
metadata[0] = 'self.val.'
- str1 += ''.join(metadata) + "='"\
- + str(mdDes[self.c].mdItem[n].getValue()) + "'\n"
+ str1 += ''.join(metadata)+"='"\
+ +str(mdDes[self.c].mdItem[n].getValue())+"'\n"
self.plusC()
numOfItems += 1
@@ -1069,9 +974,7 @@
self.executeStr1(str1, False)
str1 = ''
self.minusC(numOfItems)
-
self.plusC(numOfItems)
- ##print 'c--po',self.c
# (2.2)
elif 'for' in mdDes[cTmp].tag.split() and mdDes[cTmp].object is None and ' zip(' in mdDes[cTmp].tag:
#print 'no init and py ZIP'
@@ -1082,10 +985,10 @@
for n in range(leng):
numOfItems = 0
while mdDes[self.c].statements == stat and self.stop is False:
- str1 += 'self.' + \
- tag1[numOfItems] + ".append('" + mdDes[self.c].mdItem[n].getValue() + "')\n"
+ str1 += 'self.'+tag1[numOfItems]+".append('"+mdDes[self.c].mdItem[n].getValue()+"')\n"
self.plusC()
numOfItems += 1
+
self.executeStr1(str1, False)
str1 = ''
self.minusC(numOfItems)
@@ -1099,10 +1002,10 @@
for n in range(leng):
numOfItems = 0
while mdDes[self.c].statements == stat and self.stop is False:
- str1 += tag1 + \
- ".append('" + mdDes[self.c].mdItem[n].getValue() + "')\n"
+ str1 += tag1+".append('"+mdDes[self.c].mdItem[n].getValue()+"')\n"
self.plusC()
numOfItems += 1
+
self.executeStr1(str1, False)
str1 = ''
self.minusC(numOfItems)
@@ -1110,15 +1013,14 @@
# (1)
elif 'if' in mdDes[cTmp].tag.split():
#print 'no init IF'
- objStr = mdDes[cTmp].tag.replace(' md.', ' self.md.') + ':\n'
+ objStr = mdDes[cTmp].tag.replace(' md.', ' self.md.')+':\n'
for n in range(leng):
numOfItems = 0
while mdDes[self.c].statements == stat and self.stop is False:
- metadata = 'self.' + mdDes[self.c].tag
- str1 += ''.join(metadata) + "='"\
- + str(mdDes[self.c].mdItem[n].getValue()) + "'\n"
-
+ metadata = 'self.'+mdDes[self.c].tag
+ str1 += ''.join(metadata)+"='"\
+ +str(mdDes[self.c].mdItem[n].getValue())+"'\n"
self.plusC()
numOfItems += 1
self.minusC(numOfItems)
@@ -1144,45 +1046,45 @@
prepareStatements()
cTmp = self.c
- cTmp1 = self.c + 1
+ cTmp1 = self.c+1
tag = str(mdDes[cTmp].tag).split()
tag1 = str(mdDes[cTmp1].tag).split()
- stat = mdDes[self.c + 2].statements
+ stat = mdDes[self.c+2].statements
- append = 'self.' + str(tag1[-1]) + '.append(self.val)\n'
- appendNoInit = 'self.' + str(tag1[-1])
+ append = 'self.'+str(tag1[-1])+'.append(self.val)\n'
+ appendNoInit = 'self.'+str(tag1[-1])
# (1)
# if 'if' in jinja=skip and do single loop
if 'if' in tag and 'for' in tag1:
#print 'iffor'
- leng = len(mdDes[self.c + 2].mdItem)
- ##print mdDes[self.c + 2].tag
+ leng = len(mdDes[self.c+2].mdItem)
+ ##print mdDes[self.c+2].tag
# (1.1)
if mdDes[cTmp1].object:
#print "if and for with init object"
condition = mdDes[cTmp].tag.replace(
' md.',
- ' self.md.') + ':\n'
- object = '\t' + 'self.val=' + mdDes[cTmp1].object + '\n'
- condition2 = '\t' + \
- mdDes[cTmp1].tag.replace(' md.', ' self.md.') + ':\n'
+ ' self.md.')+':\n'
+ object = '\t'+'self.val='+mdDes[cTmp1].object+'\n'
+ condition2 = '\t'+mdDes[cTmp1].tag.replace(' md.', ' self.md.')+':\n'
self.plusC()
self.plusC()
for n in range(leng):
numOfItems = 0
- str1 = condition + '\n'
- str1 += condition2 + '\n'
- str1 += '\t' + object + '\n'
+ str1 = condition+'\n'
+ str1 += condition2+'\n'
+ str1 += '\t'+object+'\n'
+
while mdDes[self.c].statements == stat and self.stop is False:
metadata = re.split(r'[.]', mdDes[self.c].tag)
metadata[0] = '\t\tself.val'
- str1 += ''.join(metadata) + "='" + \
- str(mdDes[self.c].mdItem[n].getValue()) + "'\n"
+ str1 += ''.join(metadata)+"='"+ str(mdDes[self.c].mdItem[n].getValue())+"'\n"
self.plusC()
numOfItems += 1
- str1 += '\t\t' + append
+
+ str1 += '\t\t'+append
self.executeStr1(str1, False)
str1 = ''
self.minusC(numOfItems)
@@ -1197,10 +1099,10 @@
for n in range(size):
numOfItems = 0
str1 = ''
+
while mdDes[self.c].statements == stat and self.stop is False:
- str1 += appendNoInit + \
- '.append("' + mdDes[self.c].mdItem[n].getValue() + '")\n'
+ str1 += appendNoInit+'.append("'+mdDes[self.c].mdItem[n].getValue()+'")\n'
self.plusC()
numOfItems += 1
@@ -1209,38 +1111,39 @@
self.plusC(numOfItems)
# (2) only keywords (dict)
elif 'for' in tag and 'for' in tag1: #
- #print 'for-for statement'
self.plusC() # skip staementes 2x
self.plusC()
loop2 = mdDes[self.c].statements1
loop1 = mdDes[self.c].statements
- # var=loop2.find('[')
- # var=loop2[var:].strip(' ')
-
- numOfkwGroup = len(mdDes[self.c + 1].mdItem)
+ # print len(mdDes[self.c+1].mdItem)
+ numOfkwGroup=len(mdDes[self.c+1].mdItem)
for n in range(numOfkwGroup):
kw = {}
kw['keywords'] = []
+ print'-----'
+ print mdDes[self.c].mdItem
- ##print mdDes[self.c].mdItem[n]
- ##print '---'
- for k in range(len(mdDes[self.c].mdItem[n])):
- kw['keywords'].append(
- mdDes[
- self.c].mdItem[n][k].getValue() )
- ##print mdDes[self.c].mdItem[n][k].getValue()
+ print mdDes[self.c].mdItem[0]
+ try:
+ keyWordLen=len(mdDes[self.c].mdItem[n])
+ for k in range(keyWordLen):
+ print mdDes[self.c].mdItem[n][k].getValue()
+ kw['keywords'].append(mdDes[self.c].mdItem[n][k].getValue() )
+ except:
+ print mdDes[self.c].mdItem[n].getValue()
+ kw['keywords'].append(mdDes[self.c].mdItem[n].getValue() )
+
kw['type'] = None
kw['thesaurus'] = {}
- kw['thesaurus']['title'] = mdDes[self.c + 1].mdItem[n].getValue()
- # #print mdDes[self.c+1].mdItem[n].getValue()
- kw['thesaurus']['date'] = mdDes[self.c + 2].mdItem[n].getValue()
- # #print mdDes[self.c+2].mdItem[n].getValue()
- kw['thesaurus']['datetype'] = mdDes[self.c + 3].mdItem[n].getValue()
- # #print mdDes[self.c+3].mdItem[n].getValue()
+ kw['thesaurus']['title'] = mdDes[self.c+1].mdItem[n].getValue()
+ print mdDes[self.c+1].mdItem[n].getValue()
+ kw['thesaurus']['date'] = mdDes[self.c+2].mdItem[n].getValue()
+ print mdDes[self.c+2].mdItem[n].getValue()
+ kw['thesaurus']['datetype'] = mdDes[self.c+3].mdItem[n].getValue()
+ print mdDes[self.c+3].mdItem[n].getValue()
self.md.identification.keywords.append(kw)
- # #print '---'
self.plusC()
self.plusC()
@@ -1263,70 +1166,26 @@
self.c = 0
self.stop = False
self.max = len(self.mdDescription)
-
mdDes = self.mdDescription
while self.stop is False:
-
# if no statements
if mdDes[self.c].statements is None\
and 'if' not in mdDes[self.c].tag.split()\
and 'for' not in mdDes[self.c].tag.split():
- #print '0x statements'
- #print mdDes[self.c].tag
- #print mdDes[self.c].statements
- #print mdDes[self.c].mdItem
-
noneStatements()
chckEnd()
- #print '+' * 80
- #print 'next'
- #print mdDes[self.c].tag
- #print mdDes[self.c].statements
- #print mdDes[self.c].statements1
- #print mdDes[self.c].mdItem
- #print '+-' * 80
+
# if 2x statements
elif chckIf2xStatements():
- #print '-+' * 80
- #print '2x statements'
- #print mdDes[self.c].tag
- #print mdDes[self.c].statements
- #print mdDes[self.c].statements1
- #print mdDes[self.c].mdItem
- #print '+' * 80
-
in2Statements()
chckEnd()
- #print '+' * 80
- #print 'next'
- #print mdDes[self.c].tag
- #print mdDes[self.c].statements
- #print mdDes[self.c].statements1
- #print mdDes[self.c].mdItem
- #print '+-' * 80
- # break
+
elif chckIf1Statements: # if 1x statements
- #print '-+' * 80
- #print '1x statements'
- #print mdDes[self.c].tag
- #print mdDes[self.c].statements
- #print mdDes[self.c].statements1
- #print mdDes[self.c].mdItem
- #print '+' * 80
-
inStatements()
chckEnd()
- #print '+' * 80
- #print 'next'
- #print mdDes[self.c].tag
- #print mdDes[self.c].statements
- #print mdDes[self.c].statements1
- #print mdDes[self.c].mdItem
- #print '+-' * 80
- # #print mdDes[self.c].statements
- # self.plusC()
- #print '==' * 50
+
+ return self.md
#------------------------------------ END- FILL OWSLib BY EDITED METADATA IN GUI
#------------------------------------------------------------------------ LAYOUT
def _layout(self):
@@ -1338,16 +1197,16 @@
self.mainSizer.Add(self.notebook, proportion=1, flag=wx.EXPAND)
self.Show()
- def exportToXml(self, jinjaPath, outPath, xmlOutName):
+ def exportToXml(self, jinjaPath, outPath, xmlOutName,msg):
#print '=' * 50
self.createNewMD()
- self.mdo.saveToXML(self.md,None, jinjaPath, outPath, xmlOutName)
+ self.mdo.saveToXML(self.md,None, jinjaPath, outPath, xmlOutName,msg)
- def exportTemlate(self, jinjaPath, outPath, xmlOutName):
+ def exportTemplate(self, jinjaPath, outPath, xmlOutName):
self.templatePath=jinjaPath
owsTagList=self.defineTemplate()
self.createNewMD()
- self.mdo.saveToXML(self.md,owsTagList, self.templatePath, outPath, xmlOutName)
+ self.mdo.saveToXML(self.md,owsTagList, self.templatePath, outPath, xmlOutName,msg=True)
#----------------------------------------------------------------------
if __name__ == "__main__":
app = wx.App(False)
Modified: sandbox/krejcmat/src/g.gui.metadata.py
===================================================================
--- sandbox/krejcmat/src/g.gui.metadata.py 2014-08-05 21:45:19 UTC (rev 61537)
+++ sandbox/krejcmat/src/g.gui.metadata.py 2014-08-05 22:04:08 UTC (rev 61538)
@@ -5,7 +5,7 @@
AUTHOR(S): Matej Krejci <matejkrejci gmail.com>
-PURPOSE: Module for editing metadata based on ISO
+PURPOSE: Module for editing metadata based on EN ISO 19115 and EN ISO 19119
COPYRIGHT: (C) 2014 Matej Krejci, and by the GRASS Development Team
@@ -15,11 +15,14 @@
"""
from lxml import etree as et
-from wx.lib.splitter import MultiSplitterWindow
+
import wx
+#from wx.lib.splitter import MultiSplitterWindow
from wx.lib.buttons import ThemedGenBitmapTextButton as BitmapBtnTxt
from wx import SplitterWindow, EVT_BUTTON
+from wx.lib.pubsub import setupkwargs
+from wx.lib.pubsub import pub
from editor3 import MdMainFrame as mainEditor
import glob
@@ -34,133 +37,7 @@
import mdutil
-class MDHelp(wx.Panel):
- """
- class MyHtmlPanel inherits wx.Panel and adds a button and HtmlWindow
- """
- def __init__(self, parent ):
- # default pos is (0, 0) and size is (-1, -1) which fills the frame
- wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
- self.html1 = wx.html.HtmlWindow(self, id=wx.ID_ANY)
- try:
- self.html1.LoadFile('help/help.html')
- #self.html1.LoadPage('http://inspire-geoportal.ec.europa.eu/EUOSME_GEOPORTAL/userguide/eurlex_en.htm')
- except:
- pass
- self.mainSizer = wx.BoxSizer(wx.VERTICAL)
- self.SetSizer(self.mainSizer)
- self.mainSizer.Add(self.html1,proportion=1, flag=wx.EXPAND)
-
#===============================================================================
-# NOTEBOOK ON THE RIGHT SIDE-xml browser+validator
-#===============================================================================
-class NotebookRight(wx.Notebook):
-
- def __init__(self, parent, path):
- wx.Notebook.__init__(self, parent=parent, id=wx.ID_ANY)
- # first panel
- self.notebook_panel0 = wx.Panel(self, wx.ID_ANY)
- self.validator = InspireValidator(self.notebook_panel0)
-
- self.buttValidate = wx.Button(
- self.notebook_panel0,
- id=wx.ID_ANY,
- size=(
- 70,
- 50),
- label='validate')
-
- self.notebook_panel1 = wx.Panel(self, wx.ID_ANY)
- self.tree = TreeEditor(self.notebook_panel1, path)
- self.buttRefresh = wx.Button(
- self.notebook_panel1,
- id=wx.ID_ANY,
- size=(
- 70,
- 50),
- label='refresh')
-
- self.AddPage(self.notebook_panel0, "Validator")
- self.AddPage(self.notebook_panel1, "Tree browser")
- #self.AddPage(self.notebook_panel2, "Help")
-
- self.buttValidate.Bind(wx.EVT_BUTTON, self.validate)
- self.buttRefresh.Bind(wx.EVT_BUTTON, self.refresh)
- self._layout()
-
- def onActive(self):
- pass
- def refresh(self,evt):
- pass
-
- def validate(self, evt):
-
- self.GetParent().GetParent().editor.createNewMD()
- md = self.GetParent().GetParent().editor.md
-
- self.validator.validate_inspire(md)
-
- def _layout(self):
- panelSizer0 = wx.BoxSizer(wx.VERTICAL)
- self.notebook_panel0.SetSizer(panelSizer0)
-
- panelSizer0.Add(self.validator, flag=wx.EXPAND, proportion=1)
- panelSizer0.Add(self.buttValidate)
-
- panelSizer1 = wx.BoxSizer(wx.VERTICAL)
- self.notebook_panel1.SetSizer(panelSizer1)
- panelSizer1.Add(self.tree, flag=wx.EXPAND, proportion=1)
- panelSizer1.Add(self.buttRefresh)
-
- panelSizer2 = wx.BoxSizer(wx.VERTICAL)
- #self.notebook_panel2.SetSizer(panelSizer2)
- #panelSizer2.Add(self.notebook_panel2,flag=wx.EXPAND, proportion=1)
-#===============================================================================
-# CONFIGURATION PANEL ON THE LEFT SIDE
-#===============================================================================
-
-class MdEditConfigPanel(wx.Panel):
-
- def __init__(self, parent):
- wx.Panel.__init__(self, parent, id=wx.ID_ANY)
- self.SetMinSize((240, -1))
- self.mapGrassEdit = True
-
- self.rbGrass = wx.RadioButton(self, id=wx.ID_ANY, label='Metadata map editor', style=wx.RB_GROUP)
- self.rbExternal = wx.RadioButton(self, id=wx.ID_ANY, label='Metadata external editor')
-
- self.comboBoxProfile = wx.ComboBox(self, choices=['INSPIRE', 'GRASS BASIC', 'Load Custom'])
- self.comboBoxProfile.SetStringSelection('GRASS BASIC')
-
-
- self.Bind(wx.EVT_RADIOBUTTON, self.onSetRadioType, id=self.rbGrass.GetId())
- self.Bind(wx.EVT_RADIOBUTTON, self.onSetRadioType, id=self.rbExternal.GetId())
- # self.SetVal(True)
- self._layout()
-
- def SetVal(self, event):
- state1 = str()
- state2 = str(self.rb2.GetValue())
-
- self.statusbar.SetStatusText(state1, 0)
- self.statusbar.SetStatusText(state2, 1)
-
- def onSetRadioType(self, evt=None):
- self.mapGrassEdit = self.rbGrass.GetValue()
- if self.mapGrassEdit == False:
- self.comboBoxProfile.Hide()
- else:
- self.comboBoxProfile.Show()
- self.GetParent().GetParent().editingMode(self.mapGrassEdit)
-
- def _layout(self):
- self.mainsizer = wx.BoxSizer(wx.VERTICAL)
- self.SetSizer(self.mainsizer)
- self.mainsizer.Add(self.rbGrass)
- self.mainsizer.Add(self.rbExternal)
- self.mainsizer.Add(self.comboBoxProfile)
-
-#===============================================================================
# MAIN
#===============================================================================
class MainFrame(wx.Frame):
@@ -180,78 +57,146 @@
self.sb = self.CreateStatusBar()
self.secondMultiEdit=False
self.cres=0 #resizeFrame
- self.initEditor()
+ self.onInitEditor()
+ self.batch=False
+ pub.subscribe(self.onCreateNewMD, 'NEW_MD.create')
+ pub.subscribe(self.onEditingMode, 'EDITING_MODE.update')
+ pub.subscribe(self.onSetStatusbarText, 'STATUS_BAR_TEXT.update')
+ pub.subscribe(self.onExportTemplate,'EXPORT_TEMPLATE.create')
+ pub.subscribe(self.onExportXML,'EXPORT_XML.create')
+ pub.subscribe(self.onEditMapMetadata,'EDIT_MAP_METADATA.create')
+ pub.subscribe(self.onInitEditor,'INIT_EDITOR.create')
+ pub.subscribe(self.onTemplateEditor,'TEMPLATE_EDITOR_STATUS.update')
+ pub.subscribe(self.onHideLeftPanel,'HIDE_LEFT_PANEL.update')
+ pub.subscribe(self.onExportXMLforRefreshTreeBrowser,'REFRESH_TREE_BROWSER.update')
+ pub.subscribe(self.onChangeEditMapProfile,'ISO_PROFILE.update')
+ pub.subscribe(self.onUpdateGrassMetadata,'GRASS_METADATA.update')
+
+ def onUpdateGrassMetadata(self):
+ md=self.editor.createNewMD()
+ self.mdCreator.updateGrassMd(md)
+ GMessage('Grass metadata has been updated')
+
+ def onChangeEditMapProfile(self):
+ self.templateChoice=self.configPanelLeft.comboBoxProfile.GetValue()
+ self.ntbRight.profile=self.templateChoice
+
+ def onExportTemplate(self,outPath,outFileName):
+
+ self.editor.exportTemplate(self.jinjaPath,
+ outPath=outPath,
+ xmlOutName=outFileName)
+
+ def onExportXML(self,outPath,outFileName):
+ if outPath is None and outFileName is None:
+
+ XMLhead, XMLtail = os.path.split(self.xmlPath)
+ self.editor.exportToXml(self.jinjaPath,
+ outPath=XMLhead,
+ xmlOutName=XMLtail,
+ msg=False)
+ else:
+ self.editor.exportToXml(self.jinjaPath,
+ outPath=outPath,
+ xmlOutName=outFileName,
+ msg=True)
+
+ def onExportXMLforRefreshTreeBrowser(self):
+ path=os.path.dirname(os.path.realpath(__file__))
+ name='refreshTreeBrowser.xml'
+ print 'refresh1'
+ self.editor.exportToXml(self.jinjaPath,
+ outPath=path,
+ xmlOutName=name,
+ msg=False)
+
+ pathName=os.path.join(path,name)
+ self.ntbRight.refreshXmlBrowser(pathName)
+ os.remove(pathName)
+
+ def onSetStatusbarText(self,text):
+ self.sb.SetStatusText(text)
+
+ def onTemplateEditor(self,value):
+ self.templateEditor=value
+
+ def onCreateNewMD(self):
+ self.editor.createNewMD()
+ self.ntbRight.md=self.editor.md
+
def resizeFrame(self, x1=1, y1=0):
- self.cres+=1
- if (self.cres%2==0) and x1==1 and y1==0:
- x1=-1
- x, y = self.GetSize()
- self.SetSize((x + x1, y + y1))
+ self.cres+=1
+ if (self.cres%2==0) and x1==1 and y1==0:
+ x1=-1
+ x, y = self.GetSize()
+ self.SetSize((x + x1, y + y1))
- def hideLeftPanel(self):
- self.toolbar.bttNew.Enable()
- self.Hsizer.Remove(self.leftPanel)
- self.Hsizer.Layout()
- self.leftPanel.SetSize((1, 1))
- self.splitter.Refresh()
- self.splitter.SetSashGravity(0.7)
+ def onHideLeftPanel(self):
+ self.toolbar.bttNew.Enable()
+ self.Hsizer.Remove(self.leftPanel)
+ self.Hsizer.Layout()
+ self.leftPanel.SetSize((1, 1))
+ #self.splitter.Refresh()
+ #self.splitter.SetSashGravity(0.7)
- def editMapMetadata(self,multipleEditing=False):
+ def onEditMapMetadata(self,multipleEditing=False):
if not multipleEditing:
- self.hideLeftPanel()
+ self.onHideLeftPanel()
self.ListOfMapTypeDict=self.MdDataCatalogPanelLeft.ListOfMapTypeDict
- templeteChoice=self.configPanelLeft.comboBoxProfile.GetValue()
+
+ self.templateChoice=self.configPanelLeft.comboBoxProfile.GetValue()
self.numOfMap=len(self.ListOfMapTypeDict)
-
+
+ #if editing just one map
if self.numOfMap==1 and multipleEditing is False:
- mdCreator = mdgrass.GrassMD(self.ListOfMapTypeDict[-1][ self.ListOfMapTypeDict[-1].keys()[0] ],
+ self.mdCreator = mdgrass.GrassMD(self.ListOfMapTypeDict[-1][ self.ListOfMapTypeDict[-1].keys()[0] ],
self.ListOfMapTypeDict[-1].keys()[0])
- if templeteChoice == 'INSPIRE':
- mdCreator.createGrassInspireISO()
- self.jinjaPath = mdCreator.templatePathAbs
- self.xmlPath = mdCreator.saveXML()
- self.initEditor()
+ if self.templateChoice == 'INSPIRE':
+ self.mdCreator.createGrassInspireISO()
+ self.jinjaPath = self.mdCreator.templatePathAbs
+ self.xmlPath = self.mdCreator.saveXML()
+ self.onInitEditor()
- elif templeteChoice == 'GRASS BASIC':
- mdCreator.createGrassBasicISO()
- self.jinjaPath = mdCreator.templatePathAbs
- self.xmlPath = mdCreator.saveXML()
- self.initEditor()
-
- if templeteChoice == 'Load Custom' and self.numOfMap!=0:
+ elif self.templateChoice == 'GRASS BASIC':
+ self.mdCreator.createGrassBasicISO()
+ self.jinjaPath = self.mdCreator.templatePathAbs
+ self.xmlPath = self.mdCreator.saveXML()
+ self.onInitEditor()
+
+ #if editing multiple maps or just one but with loading own custom template
+ if self.templateChoice == 'Load Custom' and self.numOfMap!=0:
+ #load template. a) for just one map 2) for multiple editing
if multipleEditing is False:
- dlg = wx.FileDialog(
- self,
- "Choose a template",
- os.getcwd(),
- "",
- "*.xml",
- wx.OPEN)
-
+ dlg = wx.FileDialog(self,"Choose a template", os.getcwd(),"","*.xml",wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
- mdCreator = mdgrass.GrassMD(self.ListOfMapTypeDict[-1][ self.ListOfMapTypeDict[-1].keys()[0] ],
+ self.mdCreator = mdgrass.GrassMD(self.ListOfMapTypeDict[-1][ self.ListOfMapTypeDict[-1].keys()[0] ],
self.ListOfMapTypeDict[-1].keys()[0])
- mdCreator.createGrassInspireISO()
+ self.mdCreator.createGrassInspireISO()
self.jinjaPath = dlg.GetPath()
- self.xmlPath = mdCreator.saveXML()
-
+ self.xmlPath = self.mdCreator.saveXML()
+ #if multiple map are selected
if self.numOfMap>1:
+ self.toolbar.xmlPath=self.xmlPath
+ self.toolbar.jinjaPath=self.jinjaPath
+ self.batch=True
self.ListOfMapTypeDict.pop()
self.initMultipleEditor()
+
else:
self.ListOfMapTypeDict.pop()
- self.initEditor()
+ self.onInitEditor()
else:#do nothing
-
- self.initEditor()
- return False
- else:
- mdCreator = mdgrass.GrassMD(self.ListOfMapTypeDict[-1][ self.ListOfMapTypeDict[-1].keys()[0] ],
+ self.onInitEditor()
+ return False#not continue
+ else:#
+ self.mdCreator = mdgrass.GrassMD(self.ListOfMapTypeDict[-1][ self.ListOfMapTypeDict[-1].keys()[0] ],
self.ListOfMapTypeDict[-1].keys()[0])
- mdCreator.createGrassInspireISO()
- self.xmlPath = mdCreator.saveXML()
+ self.mdCreator.createGrassInspireISO()
+ self.xmlPath = self.mdCreator.saveXML()
+ self.toolbar.xmlPath=self.xmlPath
+ self.toolbar.jinjaPath=self.jinjaPath
self.ListOfMapTypeDict
self.initMultipleEditor()
self.ListOfMapTypeDict.pop()
@@ -259,23 +204,28 @@
if self.numOfMap==0 and multipleEditing is True:
multipleEditing=False
self.toolbar.onNewSession(None)
- GMessage('All choosen maps are edited')
-
+ GMessage('All selected maps are edited')
self.secondMultiEdit=True
- self.xmlPath=None
- self.jinjaPath=None
-
+ #self.batch=False
+
elif self.numOfMap==0:
GMessage('Select map in data catalog...')
-
-
- if self.numOfMap>1 and templeteChoice != 'Load Custom':
- GMessage('For multiple editing metadata of maps is necessary to define template and use "Load Custom" option. See manual... ')
- self.toolbar.onNewSession(None)
+ #=======================================================================
+ # if self.numOfMap>1 and self.templateChoice != 'Load Custom':
+ # GMessage('For multiple editing metadata of maps is necessary to define template and use "Load Custom" option. See manual... ')
+ # self.toolbar.onNewSession(None)
+ #=======================================================================
+ if self.batch and multipleEditing :
+ XMLhead, XMLtail = os.path.split(self.xmlPath)
+ self.batch=yesNo(self, 'Do you want to save metadata of : %s without editing ? '%XMLtail)
+
+ if self.batch:
+ self.toolbar.batch=True
+ self.toolbar.onSaveXML()
return True
- def editingMode(self, editStatus):
+ def onEditingMode(self, editStatus):
self.resizeFrame()
self.Layout()
@@ -297,6 +247,10 @@
#print 'def initMultipleEditor(self):'
if self.firstAfterChoice and not self.secondMultiEdit:
#print 'if self.firstAfterChoice:'
+ self.splitter = SplitterWindow(self, style=wx.SP_3D |
+ wx.SP_LIVE_UPDATE|wx.SP_BORDER)
+ self.Hsizer.Add(self.splitter, proportion=1, flag=wx.EXPAND)
+
self.firstAfterChoice = False
self.secondAfterChoice = True
self.toolbar.bttsave.SetLabel('next')
@@ -308,43 +262,42 @@
self.xmlPath,
self.templateEditor)
self.ntbRight = NotebookRight(self.splitter, self.xmlPath)
- self.splitter.SplitVertically(self.editor, self.ntbRight, sashPosition=0.6)
- self.splitter.SetSashGravity(0.9)
+ self.splitter.SplitVertically(self.editor, self.ntbRight, sashPosition=0.65)
+ self.splitter.SetSashGravity(0.65)
self.resizeFrame()
self.Show()
elif self.secondAfterChoice or self.secondMultiEdit:
- #print 'elif self.secondAfterChoice or self.secondMultiEdit:'
if self.secondMultiEdit:
self.toolbar.bttsave.SetLabel('next')
self.toolbar.hideMultipleEdit()
- #self.secondMultiEdit= False
- #self.second = True
self.second=False
self.secondAfterChoice=True
- self.initEditor()
-
- def initEditor(self):
-
+
+ self.onInitEditor()
+ return
+
+ def onInitEditor(self):
+
if self.first:
- #print 'if self.first:'
self.first = False
self.firstAfterChoice = True
#print "first-----"
- self.toolbar = MdToolbar(self)
+ self.toolbar = MdToolbar(self,self.jinjaPath,self.xmlPath,self.sb)
self.leftPanel = wx.Panel(self, id=wx.ID_ANY)
self.configPanelLeft = MdEditConfigPanel(self.leftPanel)
self.MdDataCatalogPanelLeft = MdDataCatalog(self.leftPanel)
- self.splitter = SplitterWindow(
- self,
- style=wx.SP_3D | wx.SP_LIVE_UPDATE|wx.SP_BORDER)
+
+
+ self._layout()
self.Show()
- self._layout()
-
+
elif self.firstAfterChoice:
- #print 'elif self.firstAfterChoice:'
- #f self.jinjaPath and self.xmlPath:
+ self.splitter = SplitterWindow(self, style=wx.SP_3D |
+ wx.SP_LIVE_UPDATE|wx.SP_BORDER)
+
+
self.secondMultiEdit=True
self.firstAfterChoice = False
self.second = True
@@ -354,8 +307,10 @@
self.xmlPath,
self.templateEditor)
self.ntbRight = NotebookRight(self.splitter, self.xmlPath)
- self.splitter.SplitVertically(self.editor, self.ntbRight, sashPosition=0.6)
- self.splitter.SetSashGravity(0.9)
+ self.splitter.SplitVertically(self.editor, self.ntbRight, sashPosition=0.65)
+ self.splitter.SetSashGravity(0.65)
+ self.Hsizer.Add(self.splitter, proportion=1, flag=wx.EXPAND)
+ self.splitter.SizeWindows()
self.resizeFrame()
self.Show()
@@ -367,13 +322,10 @@
self.toolbar.bttNew.Disable()
self.toolbar.bttsave.Disable()
- self.Hsizer.Insert(0, self.leftPanel, proportion=0.5, flag=wx.EXPAND)
+ self.Hsizer.Insert(0, self.leftPanel, proportion=1, flag=wx.EXPAND)
self.resizeFrame()
elif self.secondAfterChoice:
- #print 'elif self.secondAfterChoice:aa'
- #if self.jinjaPath and self.xmlPath:
- #print 'secondAfterChoice'
self.secondAfterChoice = False
self.second = True
self.splitter.Show()
@@ -399,8 +351,10 @@
self.splitter.SetSashGravity(0.35)
else:
GMessage('Select map in data catalog...')
-
- #self.toolbar.bttsave.SetLabel('XML')
+
+ self.toolbar.xmlPath=self.xmlPath
+ self.toolbar.jinjaPath=self.jinjaPath
+
def _layout(self):
self.mainSizer = wx.BoxSizer(wx.VERTICAL)
@@ -413,21 +367,19 @@
self.leftPanelSizer = wx.BoxSizer(wx.VERTICAL)
self.leftPanel.SetSizer(self.leftPanelSizer)
- self.leftPanelSizer.Add(self.configPanelLeft, proportion=0.2, flag=wx.EXPAND)
+ self.leftPanelSizer.Add(self.configPanelLeft, proportion=0, flag=wx.EXPAND)
self.leftPanelSizer.AddSpacer(5, 5, 1, wx.EXPAND)
self.leftPanelSizer.Add(self.MdDataCatalogPanelLeft, proportion=1, flag=wx.EXPAND)
self.Hsizer = wx.BoxSizer(wx.HORIZONTAL)
self.mainSizer.Add(self.Hsizer, proportion=1, flag=wx.EXPAND)
- self.Hsizer.Add(self.leftPanel, proportion=0.5, flag=wx.EXPAND)
- self.Layout()
+ self.Hsizer.Add(self.leftPanel, proportion=1, flag=wx.EXPAND)
- self.Hsizer.Add(self.splitter, proportion=1, flag=wx.EXPAND)
- self.splitter.SetSashGravity(0.35)
- self.splitter.SizeWindows()
+
+
self.resizeFrame(300, 0)
-
+ self.Layout()
#===============================================================================
# DATA CATALOG
#===============================================================================
@@ -471,73 +423,160 @@
MapTypeDict[mapType] = map
self.ListOfMapTypeDict.append(MapTypeDict)
- self.GetParent().GetParent().toolbar.bttEdit.Enable()
- self.GetParent().GetParent().toolbar.bttCreateTemplate.Enable()
+ pub.sendMessage('bttEdit.enable')
+ pub.sendMessage('bttCreateTemplate.enable')
+
else:
self.Unselect()
GMessage('Please select map.')
if len(maps)==0:
- self.GetParent().GetParent().toolbar.bttEdit.Disable()
- self.GetParent().GetParent().toolbar.bttCreateTemplate.Disable()
+ pub.sendMessage('bttEdit.disable')
+ pub.sendMessage('bttCreateTemplate.disable')
str1=''
for map in maps:
str1+=map+' '
if len(maps)>1:
- self.GetParent().GetParent().configPanelLeft.comboBoxProfile.SetStringSelection('Load Custom')
- self.GetParent().GetParent().configPanelLeft.comboBoxProfile.Disable()
- self.GetParent().GetParent().toolbar.bttCreateTemplate.Disable()
+ pub.sendMessage('SET_PROFILE.update',profile='Load Custom')
+
+ pub.sendMessage('comboBoxProfile.disable')
+ pub.sendMessage('bttCreateTemplate.disable')
else:
- self.GetParent().GetParent().configPanelLeft.comboBoxProfile.Enable()
- self.GetParent().GetParent().toolbar.bttCreateTemplate.Enable()
- self.GetParent().GetParent().sb.SetStatusText(str1)
- def _popupMenuLayer(self):
- """Create popup menu for layers"""
- pass
+ pub.sendMessage('comboBoxProfile.enable')
+ pub.sendMessage('bttCreateTemplate.enable')
+
+ pub.sendMessage('STATUS_BAR_TEXT.update',text=str1)
+
- def _popupMenuMapset(self):
- """Create popup menu for mapsets"""
- pass
+#===============================================================================
+# NOTEBOOK ON THE RIGHT SIDE-xml browser+validator
+#===============================================================================
+class NotebookRight(wx.Notebook):
-class RandomPanel(wx.Panel):
+ def __init__(self, parent, path):
+ wx.Notebook.__init__(self, parent=parent, id=wx.ID_ANY)
+ # first panel
+ self.notebookValidator = wx.Panel(self, wx.ID_ANY)
+ self.validator = MdValidator(self.notebookValidator)
+ self.xmlPath=path
+ self.profile=None
+ self.buttValidate = wx.Button(
+ self.notebookValidator,
+ id=wx.ID_ANY,
+ size=(
+ 70,
+ 50),
+ label='validate')
- def __init__(self, parent, color):
- wx.Panel.__init__(self, parent)
- self.SetBackgroundColour(color)
+ self.notebook_panel1 = wx.Panel(self, wx.ID_ANY)
+ self.tree = TreeEditor(self.notebook_panel1, self.xmlPath)
+ self.buttRefresh = wx.Button(
+ self.notebook_panel1,
+ id=wx.ID_ANY,
+ size=(
+ 70,
+ 50),
+ label='refresh')
+
+ self.AddPage(self.notebookValidator, "Validator")
+ self.AddPage(self.notebook_panel1, "Tree browser")
+ #self.AddPage(self.notebook_panel2, "Help")
+
+ self.buttValidate.Bind(wx.EVT_BUTTON, self.validate)
+ self.buttRefresh.Bind(wx.EVT_BUTTON, self.onRefreshXmlBrowser)
+ self._layout()
+
+ def onActive(self):
+ pass
+
+ def onRefreshXmlBrowser(self,evt=None):
+ pub.sendMessage( 'REFRESH_TREE_BROWSER.update')
+
+ def refreshXmlBrowser(self,path):
+ treeBCK=self.tree
+ self.tree=TreeEditor(self.notebook_panel1,path)
+ self.panelSizer1.Replace(treeBCK, self.tree)
+ #self.panelSizer1.Add(self.tree, flag=wx.EXPAND, proportion=1)
+ self.panelSizer1.Layout()
+ treeBCK.Destroy()
+
+ def validate(self, evt):
+ self.md=None
+
+ pub.sendMessage('NEW_MD.create')
+ pub.sendMessage('ISO_PROFILE.update')
+ self.validator.validate(self.md,self.profile)
+
+ def _layout(self):
+ panelSizer0 = wx.BoxSizer(wx.VERTICAL)
+ self.notebookValidator.SetSizer(panelSizer0)
+
+ panelSizer0.Add(self.validator, flag=wx.EXPAND, proportion=1)
+ panelSizer0.Add(self.buttValidate)
+
+ self.panelSizer1 = wx.BoxSizer(wx.VERTICAL)
+ self.notebook_panel1.SetSizer(self.panelSizer1)
+ self.panelSizer1.Add(self.tree, flag=wx.EXPAND, proportion=1)
+ self.panelSizer1.Add(self.buttRefresh)
+
+ panelSizer2 = wx.BoxSizer(wx.VERTICAL)
+ #self.notebook_panel2.SetSizer(panelSizer2)
+ #panelSizer2.Add(self.notebook_panel2,flag=wx.EXPAND, proportion=1)
#===============================================================================
+# HELP
+#===============================================================================
+class MDHelp(wx.Panel):
+ """
+ class MyHtmlPanel inherits wx.Panel and adds a button and HtmlWindow
+ """
+ def __init__(self, parent ):
+ # default pos is (0, 0) and size is (-1, -1) which fills the frame
+ wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
+ self.html1 = wx.html.HtmlWindow(self, id=wx.ID_ANY)
+ try:
+ self.html1.LoadFile('help/help.html')
+ #self.html1.LoadPage('http://inspire-geoportal.ec.europa.eu/EUOSME_GEOPORTAL/userguide/eurlex_en.htm')
+ except:
+ pass
+
+ self.mainSizer = wx.BoxSizer(wx.VERTICAL)
+ self.SetSizer(self.mainSizer)
+ self.mainSizer.Add(self.html1,proportion=1, flag=wx.EXPAND)
+
+#===============================================================================
# TREE EDITOR
#===============================================================================
class TreeEditor(wx.TreeCtrl):
- def __init__(self, parent, xmlPath):
- wx.TreeCtrl.__init__(
- self,
- parent=parent,
- id=wx.ID_ANY,
- style=wx.TR_HAS_BUTTONS|wx.TR_FULL_ROW_HIGHLIGHT)
-
- self.parent = parent
- self.fpath = xmlPath
- self.xml = et.parse(self.fpath)
+ def __init__(self, parent, xmlPath=False,xmlEtree=False):
+ wx.TreeCtrl.__init__(self,parent=parent,id=wx.ID_ANY,
+ style=wx.TR_HAS_BUTTONS|wx.TR_FULL_ROW_HIGHLIGHT)
+ tree=self
+ if xmlPath:
+ xml = et.parse(xmlPath)
+ self.xml=xml.getroot()
+
+ self.root = tree.AddRoot( self.xml.tag)
+ else:
+ self.xml=xmlEtree
+ self.root = xmlEtree.getroot()
- # wx.TreeCtrl(parent=self.parent,
- root = self.fillmeup()
+ root = self.fillTree()
self.Expand(root)
+ #=======================================================================
# self.Bind(wx.EVT_CLOSE, self.OnClose)
# self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEdit)
+ #=======================================================================
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnRClickAllChildren)
- def fillmeup(self):
- xml = self.xml.getroot()
- tree = self
- root = tree.AddRoot(xml.tag)
-
+ def fillTree(self):
+ root=self.root
+ xml=self.xml
+ tree=self
def add(parent, elem):
- # count=0 # do not make empty field after <appointment> or <item>
- # etc
for e in elem:
if str(e).find("<!--") != -1: # skip comments
continue
@@ -576,13 +615,129 @@
self.ExpandAllChildren(evt.Item)
else:
self.CollapseAllChildren(evt.Item)
-class MdToolbar(wx.Panel):
+
+#===============================================================================
+# INSPIRE VALIDATOR PANEL
+#===============================================================================
+class MdValidator(wx.Panel):
def __init__(self, parent):
+ wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
+ self.text = wx.TextCtrl(parent, id=wx.ID_ANY, size=(0, 55),
+ style=wx.VSCROLL |
+ wx.TE_MULTILINE | wx.TE_NO_VSCROLL |
+ wx.TAB_TRAVERSAL | wx.RAISED_BORDER | wx.HSCROLL)
+ self._layout()
+
+ def _layout(self):
+ self.mainSizer = wx.BoxSizer(wx.VERTICAL)
+ self.SetSizer(self.mainSizer)
+ self.mainSizer.Add(self.text, proportion=1, flag=wx.EXPAND)
+
+ def validate(self, md,profile):
+ print profile
+ if profile=='INSPIRE' or profile=='Load Custom':
+ result=mdutil.isnpireValidator(md)
+ str1 = 'INSPIRE VALIDATOR\n'
+
+ if profile == 'GRASS BASIC':
+ result=mdutil.grassProfileValidator(md)
+ str1 = 'GRASS BASIC PROFILE VALIDATOR\n'
+ print result
+ str1 += 'Status of validation: ' + result["status"] + '\n'
+ str1 += 'Numbers of errors: ' + result["num_of_errors"] + '\n'
+
+ if result["status"] != 'succeded':
+ str1 += 'Errors:\n'
+ for item in result["errors"]:
+ str1 += '\t' + str(item) + '\n'
+
+ self.text.SetValue(str1)
+
+
+
+#===============================================================================
+# CONFIGURATION PANEL ON THE LEFT SIDE
+#===============================================================================
+
+class MdEditConfigPanel(wx.Panel):
+
+ def __init__(self, parent):
wx.Panel.__init__(self, parent, id=wx.ID_ANY)
- self.jinjaFile = None
- self.xmlPath = None
+ self.SetMinSize((240, -1))
+ self.mapGrassEdit = True
+
+ self.rbGrass = wx.RadioButton(self, id=wx.ID_ANY, label='Metadata map editor', style=wx.RB_GROUP)
+ self.rbExternal = wx.RadioButton(self, id=wx.ID_ANY, label='Metadata external editor')
+
+ self.comboBoxProfile = wx.ComboBox(self, choices=['INSPIRE', 'GRASS BASIC', 'Load Custom'])
+ pub.subscribe(self.onComboboxDisable, "comboBoxProfile.disable")
+ pub.subscribe(self.onComboboxEnable, "comboBoxProfile.enable")
+ pub.subscribe(self.onSetProfile, "SET_PROFILE.update")
+ self.comboBoxProfile.SetStringSelection('GRASS BASIC')
+
+ self.Bind(wx.EVT_RADIOBUTTON, self.onSetRadioType, id=self.rbGrass.GetId())
+ self.Bind(wx.EVT_RADIOBUTTON, self.onSetRadioType, id=self.rbExternal.GetId())
+ self.comboBoxProfile.Bind(wx.EVT_COMBOBOX,self.onChangeComboBoxProfile )
+
+ #self.onChangeComboBoxProfile(None)
+ self._layout()
+
+ def onChangeComboBoxProfile(self,evt):
+ #pub.sendMessage('ISO_PROFILE.update')
+ pass
+
+ def onComboboxDisable(self):
+ self.comboBoxProfile.Disable()
+
+ def onComboboxEnable(self):
+ self.comboBoxProfile.Enable()
+
+ def onSetProfile(self,profile):
+ self.comboBoxProfile.SetStringSelection(profile)
+
+ def SetVal(self, event):
+ state1 = str()
+ state2 = str(self.rb2.GetValue())
+
+ self.statusbar.SetStatusText(state1, 0)
+ self.statusbar.SetStatusText(state2, 1)
+
+ def onSetRadioType(self, evt=None):
+ self.mapGrassEdit = self.rbGrass.GetValue()
+ if self.mapGrassEdit == False:
+ self.comboBoxProfile.Hide()
+ else:
+ self.comboBoxProfile.Show()
+ pub.sendMessage('EDITING_MODE.update',editStatus=self.mapGrassEdit)
+
+ def _layout(self):
+ self.mainsizer = wx.BoxSizer(wx.VERTICAL)
+ self.SetSizer(self.mainsizer)
+ self.mainsizer.Add(self.rbGrass)
+ self.mainsizer.Add(self.rbExternal)
+ self.mainsizer.Add(self.comboBoxProfile)
+#===============================================================================
+# TOOLBAR
+#===============================================================================
+class MdToolbar(wx.Panel):
+
+ def __init__(self, parent,jinjaPath,xmlPath,sb):
+ wx.Panel.__init__(self, parent, id=wx.ID_ANY)
+ self.batch=False
+ self.jinjaPath = jinjaPath
+ self.statusBar=sb
+ self.xmlPath = xmlPath
self.toolbar = wx.ToolBar(self, 1, wx.DefaultPosition, (-1, -1))
+ bitmapSave = wx.Image(
+ os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'save.png'),
+ wx.BITMAP_TYPE_PNG).ConvertToBitmap()
+ bitmapNew = wx.Image(
+ os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'create.png'),
+ wx.BITMAP_TYPE_PNG).ConvertToBitmap()
+ bitmapLoad = wx.Image(
+ os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'open.png'),
+ wx.BITMAP_TYPE_PNG).ConvertToBitmap()
#-------------------------------------------------------------------- EDIT
self.toolbar.AddSeparator()
bitmapEdit = wx.Image(
@@ -595,79 +750,130 @@
#-------------------------------------------------------------------- NEW SESION
self.toolbar.AddSeparator()
-
- bitmapNew = wx.Image(
- os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'create.png'),
- wx.BITMAP_TYPE_PNG).ConvertToBitmap()
self.bttNew = BitmapBtnTxt(
self.toolbar, -1,bitmapNew,'session')
self.toolbar.AddControl(control=self.bttNew)
self.bttNew.Disable()
#-------------------------------------------------------------------------- SAVE
- bitmapSave = wx.Image(
- os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'save.png'),
- wx.BITMAP_TYPE_PNG).ConvertToBitmap()
- self.bttsave = BitmapBtnTxt(
- self.toolbar, -1, bitmapSave, "XML")
+
+ self.bttsave = BitmapBtnTxt(self.toolbar, -1, bitmapSave, "XML")
self.bttsave.Disable()
self.toolbar.AddControl(control=self.bttsave)
self.toolbar.AddSeparator()
#----------------------------------------------------------------- OPEN TEMPLATE
- bitmapLoad = wx.Image(
- os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'open.png'),
- wx.BITMAP_TYPE_PNG).ConvertToBitmap()
- self.bttLoad = BitmapBtnTxt(
- self.toolbar, -1, bitmapLoad, "template", size=(100, -1))
+
+ self.bttLoad = BitmapBtnTxt(self.toolbar, -1, bitmapLoad, "template", size=(100, -1))
self.toolbar.AddControl(control=self.bttLoad)
self.bttLoad.Disable()
#---------------------------------------------------------------------- OPEN XML
- bitmapLoadXml = wx.Image(
- os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'open.png'),
- wx.BITMAP_TYPE_PNG).ConvertToBitmap()
- self.bttLoadXml = BitmapBtnTxt(
- self.toolbar, -1, bitmapLoad, "XML")
+
+ self.bttLoadXml = BitmapBtnTxt(self.toolbar, -1, bitmapLoad, "XML")
self.toolbar.AddControl(control=self.bttLoadXml)
self.bttLoadXml.Disable()
self.toolbar.AddSeparator()
self.toolbar.AddSeparator()
- #self.toolbar.SetMargins((500,500))
#-------------------------------------------------------------------- NEW TEMPLATE
-
- bitmapCreateTemplate = wx.Image(
- os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'create.png'),
- wx.BITMAP_TYPE_PNG).ConvertToBitmap()
- self.bttCreateTemplate = BitmapBtnTxt(
- self.toolbar, -1, bitmapCreateTemplate, "template", size=(100, -1))
+ self.bttCreateTemplate = BitmapBtnTxt(self.toolbar, -1, bitmapNew, "template", size=(100, -1))
self.toolbar.AddControl(control=self.bttCreateTemplate)
self.bttCreateTemplate.Disable()
#-------------------------------------------------------------------------- SAVE
- bitmapSaveTemplate = wx.Image(
- os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'save.png'),
- wx.BITMAP_TYPE_PNG).ConvertToBitmap()
- self.bttSaveTemplate = BitmapBtnTxt(
- self.toolbar, -1, bitmapSaveTemplate, "template", size=(100, -1))
+ self.bttSaveTemplate = BitmapBtnTxt(self.toolbar, -1, bitmapSave, "template", size=(100, -1))
self.bttSaveTemplate.Disable()
self.toolbar.AddControl(control=self.bttSaveTemplate)
self.toolbar.AddSeparator()
-
- self.toolbar.AddSeparator()
+#-------------------------------------------------------------------------- SAVE
+
+ self.bttUpdateGRASS = BitmapBtnTxt(self.toolbar, -1, bitmapSave, "GRASS", size=(100, -1))
+ self.bttUpdateGRASS.Disable()
+ self.toolbar.AddControl(control=self.bttUpdateGRASS)
+ self.toolbar.AddSeparator()
+ #self.toolbar.AddSeparator()
#------------------------------------------------------------------------------
self.toolbar.Realize()
self._layout()
- self.bttLoad.Bind(wx.EVT_BUTTON, self.OnOpenTemplate)
+
+ self.bttLoad.Bind(wx.EVT_BUTTON, self.OnLoadTemplate)
+ pub.subscribe(self.onBttSaveEnable, "bttLoad.enable")
+ pub.subscribe(self.onBttSaveDisable, "bttLoad.disable")
+
self.bttsave.Bind(wx.EVT_BUTTON, self.onSaveXML)
+ pub.subscribe(self.onBttLoadEnable, "bttSave.enable")
+ pub.subscribe(self.onBttLoadDisable, "bttSave.disable")
+
self.bttLoadXml.Bind(wx.EVT_BUTTON, self.onLoadXml)
+ pub.subscribe(self.onBttLoadXmlEnable, "bttLoadXml.enable")
+ pub.subscribe(self.onBttLoadXmlDisable, "bttLoadXml.disable")
+
self.bttNew.Bind(wx.EVT_BUTTON, self.onNewSession)
- self.bttEdit.Bind(wx.EVT_BUTTON, self.onClickEdit)
+ pub.subscribe(self.onBttNewEnable, "bttNew.enable")
+ pub.subscribe(self.onBttNewDisable, "bttNew.disable")
+
+ self.bttEdit.Bind(wx.EVT_BUTTON, self.onEdit)
+ pub.subscribe(self.onBtEditEnable, "bttEdit.enable")
+ pub.subscribe(self.onBttEditDisable, "bttEdit.disable")
+
self.bttCreateTemplate.Bind(wx.EVT_BUTTON, self.onCreateTemplate)
+ pub.subscribe(self.onBttCreateTemplateEnable, "bttCreateTemplate.enable")
+ pub.subscribe(self.onBttCreateTemplateDisable, "bttCreateTemplate.disable")
+
self.bttSaveTemplate.Bind(wx.EVT_BUTTON,self.onSaveTemplate)
+ pub.subscribe(self.onBttSaveTemplateEnable, "bttSaveTemplate.enable")
+ pub.subscribe(self.onBttSaveTemplateDisable, "bttSaveTemplate.disable")
+ self.bttUpdateGRASS.Bind(wx.EVT_BUTTON,self.onUpdateGRASS)
+ pub.subscribe(self.onBttUpdateGRASSEnable, "bttSaveTemplate.enable")
+ pub.subscribe(self.onBttUpdateGRASSDisable, "bttSaveTemplate.disable")
+
+
+ def onBttSaveDisable(self):
+ self.bttSave.Disable()
+ def onBttSaveEnable(self):
+ self.bttSave.Enable()
+
+ def onBttLoadDisable(self):
+ self.bttLoad.Disable()
+ def onBttLoadEnable(self):
+ self.bttLoad.Enable()
+
+ def onBttLoadXmlDisable(self):
+ self.bttLoadXml.Disable()
+ def onBttLoadXmlEnable(self):
+ self.bttLoadXml.Enable()
+
+ def onBttNewDisable(self):
+ self.bttNew.Disable()
+ def onBttNewEnable(self):
+ self.bttNew.Enable()
+
+ def onBttEditDisable(self):
+ self.bttEdit.Disable()
+ def onBtEditEnable(self):
+ self.bttEdit.Enable()
+
+ def onBttCreateTemplateDisable(self):
+ self.bttCreateTemplate.Disable()
+ def onBttCreateTemplateEnable(self):
+ self.bttCreateTemplate.Enable()
+
+ def onBttSaveTemplateDisable(self):
+ self.bttSaveTemplate.Disable()
+ def onBttSaveTemplateEnable(self):
+ self.bttSaveTemplate.Enable()
+
+ def onBttUpdateGRASSDisable(self):
+ self.bttUpdateGRASS.Disable()
+ def onBttUpdateGRASSEnable(self):
+ self.bttUpdateGRASS.Enable()
+
+ def onUpdateGRASS(self,evt):
+ pub.sendMessage('GRASS_METADATA.update')
+
def onSaveTemplate(self,evt=None):
dlg = wx.FileDialog(
self,
@@ -678,13 +884,10 @@
wx.SAVE)
if dlg.ShowModal() == wx.ID_OK:
- if self.jinjaFile is None:
- self.jinjaFile = self.GetParent().jinjaPath
-
- self.GetParent().editor.exportTemlate(
- self.jinjaFile,
- outPath=dlg.GetDirectory(),
- xmlOutName=dlg.GetFilename())
+
+ pub.sendMessage('EXPORT_TEMPLATE.create',outPath=dlg.GetDirectory(),
+ outFileName=dlg.GetFilename())
+
def hideMultipleEdit(self):
self.bttLoad.Hide()
self.bttLoadXml.Hide()
@@ -692,6 +895,7 @@
self.bttEdit.Hide()
self.bttCreateTemplate.Hide()
self.bttSaveTemplate.Hide()
+ self.bttUpdateGRASS.Hide()
def showMultipleEdit(self):
self.bttLoad.Show()
@@ -699,44 +903,55 @@
self.bttNew.Show()
self.bttEdit.Show()
self.bttCreateTemplate.Show()
- self.bttSaveTemplate.Show()
+ self.bttSaveTemplate.Show()
+ self.bttUpdateGRASS.Show()
def onCreateTemplate(self,evt):
- self.GetParent().templateEditor=True
- self.onClickEdit()
+ pub.sendMessage('TEMPLATE_EDITOR_STATUS.update',value=True)
+ self.onEdit()
self.bttCreateTemplate.Disable()
self.bttSaveTemplate.Enable()
+ #pub.sendMessage('TEMPLATE_EDITOR_STATUS.update',value=False)
- def onClickEdit(self, evt=None):
- if self.GetParent().configPanelLeft.rbGrass:
- ok=self.GetParent().editMapMetadata()
+ def onEdit(self, evt=None):
+ if self.GetParent().configPanelLeft.rbGrass:
+ ok=self.GetParent().onEditMapMetadata()
if not ok:
return
else:
- self.GetParent().initEditor()
+ pub.sendMessage('INIT_EDITOR.create')
self.bttCreateTemplate.Disable()
self.bttEdit.Disable()
self.bttsave.Enable()
+ self.bttUpdateGRASS.Enable()
+ if self.GetParent().numOfMap>1:
+ XMLhead, XMLtail = os.path.split(self.xmlPath)
+ self.batch=yesNo(self, 'Do you want to save metadata of : %s without editing ? '%XMLtail)
+ if self.batch:
+ self.onSaveXML()
+
def onNewSession(self, evt):
- self.GetParent().initEditor()
+ pub.sendMessage('INIT_EDITOR.create')
+ pub.sendMessage('TEMPLATE_EDITOR_STATUS.update',value=False)
if self.GetParent().configPanelLeft.rbGrass is False:
self.bttLoad.Enable()
self.bttLoadXml.Enable()
self.bttsave.Disable()
- #self.bttCreateTemplate.Enable()
+ self.bttUpdateGRASS.Disable()
+ self.jinjaPath=None
+ self.xmlPath=None
self.bttsave.SetLabel('XML')
self.showMultipleEdit()
+
self.bttSaveTemplate.Disable()
def onChangeXmlorTemplate(self, evt=None):
- if self.jinjaFile is not None and self.xmlPath is not None:
- #self.GetParent().initEditor()
- self.GetParent().hideLeftPanel()
+ if self.jinjaPath is not None and self.xmlPath is not None:
+ pub.sendMessage('HIDE_LEFT_PANEL.update')
self.bttEdit.Enable()
self.bttCreateTemplate.Enable()
- self.jinjaFile = None
- self.xmlPath = None
+
self.bttLoad.Disable()
self.bttLoadXml.Disable()
@@ -750,50 +965,14 @@
wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
self.xmlPath = dlg.GetPath()
- self.GetParent().xmlPath = self.xmlPath
- tx=self.GetParent().sb.GetStatusText()
- self.GetParent().sb.SetStatusText(tx+' Selected XML: '+ self.xmlPath )
+ #self.GetParent().xmlPath = self.xmlPath
+ tx=self.statusBar.GetStatusText()
+ self.statusBar.SetStatusText(tx + ' Selected XML: '+ self.xmlPath )
self.onChangeXmlorTemplate()
dlg.Destroy()
-
- else:
- dlg.Destroy()
-
- def onSaveXML(self, evt=None):
- dlg = wx.FileDialog(
- self,
- "Set output file",
- os.getcwd(),
- "",
- "*.xml",
- wx.SAVE)
- if dlg.ShowModal() == wx.ID_OK:
- if self.jinjaFile is None:
- self.jinjaFile = self.GetParent().jinjaPath
-
- self.GetParent().editor.exportToXml(
- self.jinjaFile,
- outPath=dlg.GetDirectory(),
- xmlOutName=dlg.GetFilename())
- if self.bttsave.GetLabelText() =='next':
- self.GetParent().editMapMetadata(True)
- os.remove(self.GetParent().xmlPath)
- else:
-
- if self.bttsave.GetLabelText() =='next':
- ask=yesNo(self,'Metadata are not saved. Do you want to save it? ')
- if ask:
- self.onSaveXML()
-
- self.GetParent().editMapMetadata(True)
- else:
- GMessage('Metadata are not saved.' )
-
- dlg.Destroy()
-
- def OnOpenTemplate(self, evt):
+ def OnLoadTemplate(self, evt):
dlg = wx.FileDialog(
self,
"Choose template",
@@ -803,67 +982,61 @@
wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
- self.jinjaFile = dlg.GetPath()
-
- self.GetParent().jinjaPath = self.jinjaFile
- tx=self.GetParent().sb.GetStatusText()
- self.GetParent().sb.SetStatusText(tx+' Selected template: '+ self.jinjaFile)
+ self.jinjaPath = dlg.GetPath()
+ tx= self.statusBar.GetStatusText()
+ self.statusBar.SetStatusText(tx+' Selected template: '+ self.jinjaPath)
self.onChangeXmlorTemplate()
- dlg.Destroy()
+ dlg.Destroy()
+
+ def onSaveXML(self, evt=None):
+ self.XMLhead, self.XMLtail = os.path.split(self.xmlPath)
+ if not self.batch:#if normal saving with user-task-dialog
+
+ dlg = wx.FileDialog(self,message="Set output file",
+ defaultDir=self.XMLhead,defaultFile=self.XMLtail,wildcard="*.xml",
+ style=wx.SAVE|wx.FD_OVERWRITE_PROMPT)
+
+ if dlg.ShowModal() == wx.ID_OK:
+ pub.sendMessage('EXPORT_XML.create',outPath=dlg.GetDirectory(),outFileName=dlg.GetFilename())
+
+ if self.bttsave.GetLabelText() =='next':
+ print 'next'
+ pub.sendMessage('EDIT_MAP_METADATA.create',multipleEditing=True)
+
+ else:
+ if self.bttsave.GetLabelText() =='next':
+ ask=yesNo(self,'File is not saved. Do you want to save it? ')
+
+ if ask:
+ self.onSaveXML()
+ pub.sendMessage('EDIT_MAP_METADATA.create',multipleEditing=True)
+
+ else:
+ GMessage('Metadata are not saved.' )
+ dlg.Destroy()
+
+ else:
+ print '6---'
+ pub.sendMessage('EXPORT_XML.create',outPath=None,outFileName=None)
+ pub.sendMessage('EDIT_MAP_METADATA.create',multipleEditing=True)
+
+
def _layout(self):
self.mainsizer = wx.BoxSizer(wx.HORIZONTAL)
self.SetSizer(self.mainsizer)
self.mainsizer.Add(self.toolbar)
-
+
+#------------------------------------------------------------------------------
def yesNo(parent, question, caption = 'Yes or no?'):
dlg = wx.MessageDialog(parent, question, caption, wx.YES_NO | wx.ICON_QUESTION)
result = dlg.ShowModal() == wx.ID_YES
dlg.Destroy()
- return result
-
-class InspireValidator(wx.Panel):
+ return result
- def __init__(self, parent):
- wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
- self.text = wx.TextCtrl(parent, id=wx.ID_ANY, size=(0, 55),
- style=wx.VSCROLL |
- wx.TE_MULTILINE | wx.TE_NO_VSCROLL |
- wx.TAB_TRAVERSAL | wx.RAISED_BORDER | wx.HSCROLL)
- self._layout()
-
- def _layout(self):
- self.mainSizer = wx.BoxSizer(wx.VERTICAL)
- self.SetSizer(self.mainSizer)
-
- self.mainSizer.Add(self.text, proportion=1, flag=wx.EXPAND)
-
- def validate_grassProfile(self, md):
- '''function for validation INSPIRE XML file'''
- pass
-
-
- def validate_inspire(self, md):
- result,errors=mdutil.isnpireValidator(md)
- if errors > 0:
- result["status"] = "failed"
- result["num_of_errors"] = str(errors)
- str1 = 'INSPIRE VALIDATOR\n'
- str1 += 'Status of validation: ' + result["status"] + '\n'
- str1 += 'Numbers of errors: ' + result["num_of_errors"] + '\n'
-
- if result["status"] != 'succeded':
- str1 += 'Errors:\n'
- for item in result["errors"]:
- str1 += '\t' + str(item) + '\n'
-
- #str1 = 'Metadata loading error'
-
- self.text.SetValue(str1)
-
-
+
#----------------------------------------------------------------------
if __name__ == "__main__":
app = wx.App(False)
Modified: sandbox/krejcmat/src/mdgrass.py
===================================================================
--- sandbox/krejcmat/src/mdgrass.py 2014-08-05 21:45:19 UTC (rev 61537)
+++ sandbox/krejcmat/src/mdgrass.py 2014-08-05 22:04:08 UTC (rev 61538)
@@ -2,11 +2,11 @@
# -*- coding: utf-8
"""
-MODULE: v.info.iso, r.info.iso
+MODULE: v.info.iso, r.info.iso, g.gui.metadata
AUTHOR(S): Matej Krejci <matejkrejci gmail.com>
-PURPOSE: Module for creating metadata based on ISO
+PURPOSE: Module for creating metadata based on EN ISO 19115 and EN ISO 19119
COPYRIGHT: (C) 2014 Matej Krejci, and by the GRASS Development Team
@@ -34,6 +34,7 @@
import StringIO
import subprocess as sub
import uuid
+import mdutil
import mdutil
class GrassMD():
@@ -90,6 +91,7 @@
flags='get',
quiet=True,
stdout_=PIPE)
+
self.md_grass = parse_key_val(vinfo.outputs.stdout)
# parse md from v.info flag h (history of map in grass)
@@ -99,6 +101,7 @@
flags='h',
quiet=True,
stdout_=PIPE)
+
md_h_grass = rinfo_h.outputs.stdout
buf = StringIO.StringIO(md_h_grass)
line = buf.readline().splitlines()
@@ -117,9 +120,7 @@
if the format of date is different to grass-generated format - use them and print warning '''
try:
- date = datetime.strptime(
- self.md_grass[key],
- '%a %b %d %H:%M:%S %Y')
+ date = datetime.strptime(self.md_grass[key],'%a %b %d %H:%M:%S %Y')
self.md_grass['dateofcreation'] = date.strftime('%Y-%m-%d')
except:
grass.warning('date of creation: unknown date format')
@@ -143,12 +144,12 @@
# create abstract
if self.md_grass['description'] != '""':
- self.md_abstract = self.md_grass['description'] + '\\n'
+ self.md_abstract = self.md_grass['description']+'; '
if self.md_grass['source1'] != '""':
- self.md_abstract += self.md_grass['source1'] + '\\n'
+ self.md_abstract += self.md_grass['source1'] +'; '
if self.md_grass['source2'] != '""':
- self.md_abstract += self.md_grass['source2'] + '\\n'
- self.md_abstract += 'Total cells: ' + self.md_grass['cells']
+ self.md_abstract += self.md_grass['source2'] +'; '
+ self.md_abstract += 'Total cells: ' + self.md_grass['cells']+'; '
self.md_abstract += 'A range of values: min: ' + \
self.md_grass['min'] + ' max: ' + self.md_grass['max']
self.md_abstract.translate(None, """&<>"'""")
@@ -158,7 +159,7 @@
- unknown values are filling by n = '$NULL'
'''
try:
- self.md_grass['comments']=self.md_grass['comments'].replace('\n','\\n')
+ self.md_grass['comments']=self.md_grass['comments'].replace('\n','; ')
except:
pass
@@ -188,8 +189,6 @@
self.md.identification.title = mdutil.replaceXMLReservedChar(self.md_grass['title'])
self.md.datestamp = mdutil.replaceXMLReservedChar(date.today().isoformat())
-
-
# Identification/Resource Type
self.md.identification.identtype = 'dataset'
@@ -225,17 +224,14 @@
if self.type == 'cell':
# Identification/Resource Abstract
self.md.identification.abstract = mdutil.replaceXMLReservedChar(self.md_abstract)
-
# Geographic/resolution
-
self.md.identification.distance.append(mdutil.replaceXMLReservedChar(self.md_grass['nsres'])) # TODO for discuss
-
# Quality/Lineage
try:
self.md.dataquality.lineage = mdutil.replaceXMLReservedChar(mdutil.replaceXMLReservedChar(self.md_grass['comments']))
except:
- grass.warning('Native metadata *comments* not found, dataquality.lineage filled by $NULL')
+ grass.warning('Native metadata *flag=comments* not found, dataquality.lineage filled by $NULL')
self.md.dataquality.lineage = n
# Organisation/Responsible Party:
@@ -256,6 +252,7 @@
val.organization = self.md_grass['creator']
val.role = 'owner'
self.md.identification.contact.append(val)
+
self.templatePathAbs=os.path.join(self.dirpath,self.template)
@@ -275,6 +272,7 @@
self.template = template
n = '$NULL'
+
self.md.datestamp = n
if len(self.md.identification.distance)==0:
self.md.identification.distance.append(n)#TODO
@@ -303,6 +301,7 @@
val = CI_OnlineResource()
val.url = n
self.md.distribution.online.append(val)
+
# Conformity/Date
self.md.dataquality.conformancedate.append(n)
self.md.dataquality.conformancedatetype.append(n)
@@ -322,7 +321,7 @@
self.md.identification.temporalextent_end = n
self.templatePathAbs=os.path.join(self.dirpath,self.template)
-
+ print self.templatePathAbs
def saveXML(self, path=None, xml_out_name=None):
''' Save custom record to ISO XML file'''
@@ -363,243 +362,141 @@
return path
def validate_inspire(self):
- '''function for validation INSPIRE XML file'''
-
- result = {}
- result["status"] = "succeded"
- result["errors"] = []
- result["num_of_errors"] = "0"
- errors = 0
-
- if self.md.identification is None:
- result["errors"].append(
- "gself.md:CI_ResponsibleParty: Organization missing")
- result["errors"].append(
- "gself.md:CI_ResponsibleParty: E-mail missing")
- result["errors"].append(
- "gself.md:CI_ResponsibleParty: Role missing")
- result["errors"].append(
- "gself.md:self.md_DataIdentification: Title is missing")
- result["errors"].append(
- "gself.md:self.md_DataIdentification: Abstract is missing")
- result["errors"].append(
- "gself.md:self.md_ScopeCode: Resource Type is missing")
- result["errors"].append(
- "gself.md:language: Resource Language is missing")
- result["errors"].append(
- "gself.md:RS_Identifier: Unique Resource Identifier is missing")
- result["errors"].append(
- "gself.md:topicCategory: TopicCategory is missing")
- result["errors"].append(
- "gself.md:self.md_Keywords: Keywords are missing")
- result["errors"].append(
- "gself.md:thesaurusName: Thesaurus Title is missing")
- result["errors"].append(
- "gself.md:thesaurusName: Thesaurus Date is missing")
- result["errors"].append(
- "gself.md:thesaurusName: Thesaurus Date Type is missing")
- result["errors"].append(
- "gself.md:EX_Extent: extent element is missing")
- result["errors"].append(
- "gself.md:EX_GeographicBoundingBox: bbox is missing")
- result["errors"].append(
- "Both gself.md:EX_TemporalExtent and gself.md:CI_Date are missing")
- result["errors"].append("gself.md:useLimitation is missing")
- result["errors"].append("gself.md:accessConstraints is missing")
- result["errors"].append("gself.md:otherConstraints is missing")
- errors += 20
- else:
- if self.md.identification.contact is None or len(
- self.md.identification.contact) < 1:
- result["errors"].append(
- "gself.md:CI_ResponsibleParty: Organization missing")
- result["errors"].append(
- "gself.md:CI_ResponsibleParty: E-mail missing")
- result["errors"].append(
- "gself.md:CI_ResponsibleParty: Role missing")
- errors += 3
- else:
- if self.md.identification.contact[0].organization is None:
- result["errors"].append(
- "gself.md:CI_ResponsibleParty: Organization missing")
- errors += 1
- if self.md.identification.contact[0].email is None:
- result["errors"].append(
- "gself.md:CI_ResponsibleParty: E-mail missing")
- errors += 1
- if self.md.identification.contact[0].role is None:
- result["errors"].append(
- "gself.md:CI_ResponsibleParty: Role missing")
- errors += 1
-
- if self.md.identification.title is None:
- result["errors"].append(
- "gself.md:self.md_DataIdentification: Title is missing")
- errors += 1
- if self.md.identification.abstract is None:
- result["errors"].append(
- "gself.md:self.md_DataIdentification: Abstract is missing")
- errors += 1
- if self.md.identification.identtype is None:
- result["errors"].append(
- "gself.md:self.md_ScopeCode: Resource Type is missing")
- errors += 1
- if self.md.identification.resourcelanguage is None or len(
- self.md.identification.resourcelanguage) < 1:
- result["errors"].append(
- "gself.md:language: Resource Language is missing")
- errors += 1
- if self.md.identification.uricode is None or len(
- self.md.identification.uricode) < 1:
- result["errors"].append(
- "gself.md:RS_Identifier: Unique Resource Identifier is missing")
- errors += 1
- if self.md.identification.topiccategory is None or len(
- self.md.identification.topiccategory) < 1:
- result["errors"].append(
- "gself.md:topicCategory: TopicCategory is missing")
- errors += 1
- if self.md.identification.keywords is None or len(
- self.md.identification.keywords) < 1:
- result["errors"].append(
- "gself.md:self.md_Keywords: Keywords are missing")
- result["errors"].append(
- "gself.md:thesaurusName: Thesaurus Title is missing")
- result["errors"].append(
- "gself.md:thesaurusName: Thesaurus Date is missing")
- result["errors"].append(
- "gself.md:thesaurusName: Thesaurus Date Type is missing")
- errors += 4
- else:
- if self.md.identification.keywords[0]['keywords'] is None or len(
- self.md.identification.keywords[0]['keywords']) < 1:
- result["errors"].append(
- "gself.md:self.md_Keywords: Keywords are missing")
- errors += 1
- if self.md.identification.keywords[0]['thesaurus'] is None:
- result["errors"].append(
- "gself.md:thesaurusName: Thesaurus Title is missing")
- result["errors"].append(
- "gself.md:thesaurusName: Thesaurus Date is missing")
- result["errors"].append(
- "gself.md:thesaurusName: Thesaurus Date Type is missing")
- errors += 3
- else:
- if self.md.identification.keywords[
- 0]['thesaurus']['title'] is None:
- result["errors"].append(
- "gself.md:thesaurusName: Thesaurus Title is missing")
- errors += 1
- if self.md.identification.keywords[
- 0]['thesaurus']['date'] is None:
- result["errors"].append(
- "gself.md:thesaurusName: Thesaurus Date is missing")
- errors += 1
- if self.md.identification.keywords[0][
- 'thesaurus']['datetype'] is None:
- result["errors"].append(
- "gself.md:thesaurusName: Thesaurus Date Type is missing")
- errors += 1
- if self.md.identification.extent is None:
- result["errors"].append(
- "gself.md:EX_Extent: extent element is missing")
- errors += 1
- else:
- if self.md.identification.extent.boundingBox is None:
- result["errors"].append(
- "gself.md:EX_GeographicBoundingBox: bbox is missing")
- errors += 1
- else:
- if self.md.identification.extent.boundingBox.minx is None:
- result["errors"].append(
- "gself.md:westBoundLongitude: minx is missing")
- errors += 1
- if self.md.identification.extent.boundingBox.maxx is None:
- result["errors"].append(
- "gself.md:eastBoundLongitude: maxx is missing")
- errors += 1
- if self.md.identification.extent.boundingBox.miny is None:
- result["errors"].append(
- "gself.md:southBoundLatitude: miny is missing")
- errors += 1
- if self.md.identification.extent.boundingBox.maxy is None:
- result["errors"].append(
- "gself.md:northBoundLatitude: maxy is missing")
- errors += 1
- if len(
- self.md.identification.date) < 1 and (
- self.md.identification.temporalextent_start is None or self.md.identification.temporalextent_end is None):
- result["errors"].append(
- "Both gself.md:EX_TemporalExtent and gself.md:CI_Date are missing")
- errors += 1
- if len(self.md.identification.uselimitation) < 1:
- result["errors"].append("gself.md:useLimitation is missing")
- errors += 1
- if len(self.md.identification.accessconstraints) < 1:
- result["errors"].append(
- "gself.md:accessConstraints is missing")
- errors += 1
- if len(self.md.identification.otherconstraints) < 1:
- result["errors"].append("gself.md:otherConstraints is missing")
- errors += 1
-
- if self.md.languagecode is None:
- result["errors"].append(
- "gself.md:LanguageCode: Language code missing")
- errors += 1
- if self.md.datestamp is None:
- result["errors"].append("gself.md:dateStamp: Date is missing")
- errors += 1
- if self.md.identifier is None:
- result["errors"].append(
- "gself.md:identifier: Identifier is missing")
- errors += 1
- if self.md.dataquality is None:
- result["errors"].append("gself.md:LI_Lineage is missing")
- result["errors"].append(
- "gself.md:DQ_ConformanceResult: date is missing")
- result["errors"].append(
- "gself.md:DQ_ConformanceResult: date type is missing")
- # result["errors"].append("gself.md:DQ_ConformanceResult: degree is missing")
- result["errors"].append(
- "gself.md:DQ_ConformanceResult: title is missing")
- errors += 4
- else:
- if self.md.dataquality.lineage is None:
- result["errors"].append("gself.md:LI_Lineage is missing")
- errors += 1
- if len(self.md.dataquality.conformancedate) < 1:
- result["errors"].append(
- "gself.md:DQ_ConformanceResult: date is missing")
- errors += 1
- if len(self.md.dataquality.conformancedatetype) < 1:
- result["errors"].append(
- "gself.md:DQ_ConformanceResult: date type is missing")
- errors += 1
- # if len(self.md.dataquality.conformancedegree) < 1:
- # result["errors"].append("gself.md:DQ_ConformanceResult: degree is missing")
- # errors += 1
- if len(self.md.dataquality.conformancetitle) < 1:
- result["errors"].append(
- "gself.md:DQ_ConformanceResult: title is missing")
- errors += 1
-
- if self.md.contact is None:
- result["errors"].append(
- "gself.md:contact: Organization name is missing")
- result["errors"].append("gself.md:contact: e-mail is missing")
- errors += 2
- else:
- if self.md.contact[0].organization is None:
- result["errors"].append(
- "gself.md:contact: Organization name is missing")
- errors += 1
- if self.md.contact[0].email is None:
- result["errors"].append("gself.md:contact: e-mail is missing")
- errors += 1
-
- if errors > 0:
- result["status"] = "failed"
- result["num_of_errors"] = str(errors)
-
+ mdutil.isnpireValidator(self.md)
return result
+
+#===============================================================================
+#
+# class GrassMdUpdate():
+#
+# def __init__(self, md,map,mapType):
+# self.md=md
+# self.map=map
+# self.mapType=mapType
+#
+# if maptype=='cell':
+# self.updateRaster()
+# if mapType=='vector':
+# self.updateVector()
+#===============================================================================
+
+ def updateGrassMd(self,md):
+ if self.type == "vector":
+
+ if len(md.contact)>0:
+ _org=''
+ for co in md.contact:
+ if co.organization!='':
+ _org+=co.organization+', '
+ if co.email!='':
+ _org+=co.email+', '
+ if co.role!='':
+ _org+=co.role+'; '
+
+ Module('v.support',
+ map=self.map,
+ organization=_org,
+ flags='r')
+
+ if md.identification.date is not None:
+ if len(md.identification.date)>0:
+ for d in md.identification.date:
+ if d.type=='creation':
+ _date=d.date
+
+ Module('v.support',
+ map=self.map,
+ date=_date,
+ flags='r')
+
+ if md.identification.contact is not None:
+ if len(md.identification.contact)>0:
+ _person=md.identification.contact.organization.pop()
+
+ Module('v.support',
+ map=self.map,
+ person=_person,
+ flags='r')
+
+ if md.identification.title is not (None or ''):
+ _name=md.identification.title
+ Module('v.support',
+ map=self.map,
+ map_name=_name,
+ flags='r')
+
+ if len( md.identification.denominators)>0:
+ _scale= md.identification.denominators.pop()
+ try:
+ _scale=int(_scale)
+ Module('v.support',
+ map=self.map,
+ scale=_scale,
+ flags='r')
+ except:
+ pass
+
+ if md.identification.keywords is not None or len(md.identification.keywords) > 0:
+ _comments=''
+ for k in md.identification.keywords:
+ for kw in k["keywords"]:
+ if kw!='':
+ _comments+=kw + ', '
+ if k["thesaurus"]["title"]!='':
+ _comments+= k["thesaurus"]["title"] +', '
+ if k["thesaurus"]["date"]!='':
+ _comments+= k["thesaurus"]["date"]+', '
+ if k['thesaurus']['datetype']!='':
+ _comments+= k['thesaurus']['datetype'] +';'
+
+ Module('v.support',
+ map=self.map,
+ comment=_comments,
+ flags='r')
+
+#------------------------------------------------------------------------ RASTER
+ if self.type == "cell":
+
+ if md.identification.title is not (None or ''):
+ _title=md.identification.title
+ Module('r.support',
+ map=self.map,
+ title=_title,
+ overwrite=True)
+
+ if md.dataquality.lineage is not (None or ''):
+ _history=md.dataquality.lineage
+ Module('r.support',
+ map=self.map,#append
+ history=_history)
+
+ _units=''
+ if len(md.identification.distance)>0:
+ _units+= md.identification.distance.pop()
+ if len(md.identification.uom)>0:
+ _units+=', '+md.identification.uom.pop()
+ if _units!='':
+ Module('r.support',
+ map=self.map,
+ units=_units,
+ overwrite=True)
+
+ if md.identification.keywords is not None or len(md.identification.keywords) > 0:
+ _comments=self.md_grass['description']
+ _comments+= ' | '
+ for k in md.identification.keywords:
+ for kw in k["keywords"]:
+ if kw!='':
+ _comments+=kw + ', '
+ if k["thesaurus"]["title"]!='':
+ _comments+= k["thesaurus"]["title"] +', '
+ if k["thesaurus"]["date"]!='':
+ _comments+= k["thesaurus"]["date"]+', '
+ if k['thesaurus']['datetype']!='':
+ _comments+= k['thesaurus']['datetype'] +';'
+
+ Module('r.support',
+ map=self.map,
+ description=_comments,
+ overwrite=True)
+
Modified: sandbox/krejcmat/src/mdutil.py
===================================================================
--- sandbox/krejcmat/src/mdutil.py 2014-08-05 21:45:19 UTC (rev 61537)
+++ sandbox/krejcmat/src/mdutil.py 2014-08-05 22:04:08 UTC (rev 61538)
@@ -1,290 +1,349 @@
#!/usr/bin/env python
# -*- coding: utf-8
#===============================================================================
-# def strip_control_characters(input):
-#
-# if input:
-#
-# import re
-#
-# # unicode invalid characters
+# def strip_control_characters(input):
+#
+# if input:
+#
+# import re
+#
+# unicode invalid characters
# RE_XML_ILLEGAL = u'([\u0000-\u0008\u000b-\u000c\u000e-\u001f\ufffe-\uffff])' + \
# u'|' + \
# u'([%s-%s][^%s-%s])|([^%s-%s][%s-%s])|([%s-%s]$)|(^[%s-%s])' % \
-# (unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),
-# unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),
-# unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),
-# )
-# input = re.sub(RE_XML_ILLEGAL, "", input)
-#
-# # ascii control characters
-# input = re.sub(r"[\x01-\x1F\x7F]", "", input)
-#
+# (unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),
+# unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),
+# unichr(0xd800),unichr(0xdbff),unichr(0xdc00),unichr(0xdfff),
+# )
+# input = re.sub(RE_XML_ILLEGAL, "", input)
+#
+# ascii control characters
+# input = re.sub(r"[\x01-\x1F\x7F]", "", input)
+#
# return input
#===============================================================================
+import string
+def removeNonAscii(s):
+ s= filter(lambda x: x in string.printable, s)
+ return s
+
def replaceXMLReservedChar(input):
- if input:
- import re
+ if input:
+ import re
- input = re.sub('<', '<', input)
- input = re.sub('>', '>', input)
- input = re.sub('&', '&', input)
- input = re.sub('%', '%', input)
-
-
+ input = re.sub('<', '<', input)
+ input = re.sub('>', '>', input)
+ input = re.sub('&', '&', input)
+ input = re.sub('%', '%', input)
return input
-def isnpireValidator( md):
- '''function for validation INSPIRE XML file'''
+def grassProfileValidator(md):
+ '''function for validation GRASS BASIC XML-OWSLib file-object'''
- result = {}
- result["status"] = "succeded"
- result["errors"] = []
- result["num_of_errors"] = "0"
- errors = 0
+ result = {}
+ result["status"] = "succeded"
+ result["errors"] = []
+ result["num_of_errors"] = "0"
+ errors = 0
- if md.identification is (None or ''):
- result["errors"].append(
- "gmd:CI_ResponsibleParty: Organization missing")
- result["errors"].append(
- "gmd:CI_ResponsibleParty: E-mail missing")
- result["errors"].append(
- "gmd:CI_ResponsibleParty: Role missing")
- result["errors"].append(
- "gmd:md_DataIdentification: Title is missing")
- result["errors"].append(
- "gmd:md_DataIdentification: Abstract is missing")
- result["errors"].append(
- "gmd:md_ScopeCode: Resource Type is missing")
- result["errors"].append(
- "gmd:language: Resource Language is missing")
- result["errors"].append(
- "gmd:RS_Identifier: Unique Resource Identifier is missing")
- result["errors"].append(
- "gmd:topicCategory: TopicCategory is missing")
- result["errors"].append(
- "gmd:md_Keywords: Keywords are missing")
- result["errors"].append(
- "gmd:thesaurusName: Thesaurus Title is missing")
- result["errors"].append(
- "gmd:thesaurusName: Thesaurus Date is missing")
- result["errors"].append(
- "gmd:thesaurusName: Thesaurus Date Type is missing")
- result["errors"].append(
- "gmd:EX_Extent: extent element is missing")
- result["errors"].append(
- "gmd:EX_GeographicBoundingBox: bbox is missing")
- result["errors"].append(
- "Both gmd:EX_TemporalExtent and gmd:CI_Date are missing")
- result["errors"].append("gmd:useLimitation is missing")
- result["errors"].append(
- "gmd:accessConstraints is missing")
- result["errors"].append("gmd:otherConstraints is missing")
- errors += 20
+ if md.identification is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
+ result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
+ result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
+ result["errors"].append("gmd:md_DataIdentification: Title is missing")
+ result["errors"].append("gmd:md_DataIdentification: Abstract is missing")
+ result["errors"].append("gmd:md_ScopeCode: Resource Type is missing")
+ result["errors"].append("gmd:RS_Identifier: Unique Resource Identifier is missing")
+ result["errors"].append("gmd:EX_Extent: extent element is missing")
+ result["errors"].append("gmd:EX_GeographicBoundingBox: bbox is missing")
+ result["errors"].append("Both gmd:EX_TemporalExtent and gmd:CI_Date are missing")
+ result["errors"].append("gmd:useLimitation is missing")
+ errors += 20
+ else:
+ if md.identification.contact is (None or '') or len(md.identification.contact) < 1:
+ result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
+ result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
+ result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
+ errors += 3
+ else:
+ if md.identification.contact[0].organization is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
+ errors += 1
+ if md.identification.contact[0].email is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
+ errors += 1
+ if md.identification.contact[0].role is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
+ errors += 1
+
+ if md.identification.title is (None or ''):
+ result["errors"].append("gmd:md_DataIdentification: Title is missing")
+ errors += 1
+ if md.identification.abstract is (None or ''):
+ result["errors"].append("gmd:md_DataIdentification: Abstract is missing")
+ errors += 1
+ if md.identification.identtype is (None or ''):
+ result["errors"].append("gmd:md_ScopeCode: Resource Type is missing")
+ errors += 1
+
+ if md.identification.extent is (None or ''):
+ result["errors"].append("gmd:EX_Extent: extent element is missing")
+ errors += 1
+ else:
+ if md.identification.extent.boundingBox is (None or ''):
+ result["errors"].append("gmd:EX_GeographicBoundingBox: bbox is missing")
+ errors += 1
else:
- if md.identification.contact is (None or '') or len(
- md.identification.contact) < 1:
- result["errors"].append(
- "gmd:CI_ResponsibleParty: Organization missing")
- result["errors"].append(
- "gmd:CI_ResponsibleParty: E-mail missing")
- result["errors"].append(
- "gmd:CI_ResponsibleParty: Role missing")
- errors += 3
- else:
- if md.identification.contact[0].organization is (None or '') :
- result["errors"].append(
- "gmd:CI_ResponsibleParty: Organization missing")
- errors += 1
- if md.identification.contact[0].email is (None or ''):
- result["errors"].append(
- "gmd:CI_ResponsibleParty: E-mail missing")
- errors += 1
- if md.identification.contact[0].role is (None or ''):
- result["errors"].append(
- "gmd:CI_ResponsibleParty: Role missing")
- errors += 1
-
- if md.identification.title is (None or ''):
- result["errors"].append(
- "gmd:md_DataIdentification: Title is missing")
+ if md.identification.extent.boundingBox.minx is (None or ''):
+ result["errors"].append("gmd:westBoundLongitude: minx is missing")
errors += 1
- if md.identification.abstract is (None or ''):
- result["errors"].append(
- "gmd:md_DataIdentification: Abstract is missing")
+ if md.identification.extent.boundingBox.maxx is (None or ''):
+ result["errors"].append("gmd:eastBoundLongitude: maxx is missing")
errors += 1
- if md.identification.identtype is (None or ''):
- result["errors"].append(
- "gmd:md_ScopeCode: Resource Type is missing")
+ if md.identification.extent.boundingBox.miny is (None or ''):
+ result["errors"].append("gmd:southBoundLatitude: miny is missing")
errors += 1
- if md.identification.resourcelanguage is (None or '') or len(
- md.identification.resourcelanguage) < 1 or\
- md.identification.resourcelanguage[0] == '':
- result["errors"].append(
- "gmd:language: Resource Language is missing")
+ if md.identification.extent.boundingBox.maxy is (None or ''):
+ result["errors"].append("gmd:northBoundLatitude: maxy is missing")
errors += 1
- if md.identification.uricode is (None or '') or len(
- md.identification.uricode) < 1 or\
- md.identification.uricode[0] == '':
- result["errors"].append(
- "gmd:RS_Identifier: Unique Resource Identifier is missing")
+
+ if len(md.identification.date) < 1 or (md.identification.temporalextent_start is (
+ None or '') or md.identification.temporalextent_end is (None or '')):
+ result["errors"].append("Both gmd:EX_TemporalExtent and gmd:CI_Date are missing")
+ errors += 1
+
+ if md.datestamp is (None or ''):
+ result["errors"].append("gmd:dateStamp: Date is missing")
+ errors += 1
+ if md.identifier is (None or ''):
+ result["errors"].append("gmd:identifier: Identifier is missing")
+ errors += 1
+
+ if md.contact is (None or ''):
+ result["errors"].append("gmd:contact: Organization name is missing")
+ result["errors"].append("gmd:contact: e-mail is missing")
+ errors += 2
+ else:
+
+ if md.contact[0].organization is (None or ''):
+ result["errors"].append("gmd:contact: Organization name is missing")
+ errors += 1
+ if md.contact[0].email is (None or ''):
+ result["errors"].append("gmd:contact: e-mail is missing")
+ errors += 1
+ if md.contact[0].role is (None or ''):
+ result["errors"].append("gmd:role: role is missing")
+ errors += 1
+ if errors > 0:
+ result["status"] = "failed"
+ result["num_of_errors"] = str(errors)
+ return result
+
+
+def isnpireValidator(md):
+ '''function for validation INSPIRE XML-OWSLib file-object'''
+
+ result = {}
+ result["status"] = "succeded"
+ result["errors"] = []
+ result["num_of_errors"] = "0"
+ errors = 0
+
+ if md.identification is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
+ result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
+ result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
+ result["errors"].append("gmd:md_DataIdentification: Title is missing")
+ result["errors"].append("gmd:md_DataIdentification: Abstract is missing")
+ result["errors"].append("gmd:md_ScopeCode: Resource Type is missing")
+ result["errors"].append("gmd:language: Resource Language is missing")
+ result["errors"].append("gmd:RS_Identifier: Unique Resource Identifier is missing")
+ result["errors"].append("gmd:topicCategory: TopicCategory is missing")
+ result["errors"].append("gmd:md_Keywords: Keywords are missing")
+ result["errors"].append("gmd:thesaurusName: Thesaurus Title is missing")
+ result["errors"].append("gmd:thesaurusName: Thesaurus Date is missing")
+ result["errors"].append("gmd:thesaurusName: Thesaurus Date Type is missing")
+ result["errors"].append("gmd:EX_Extent: extent element is missing")
+ result["errors"].append("gmd:EX_GeographicBoundingBox: bbox is missing")
+ result["errors"].append("Both gmd:EX_TemporalExtent and gmd:CI_Date are missing")
+ result["errors"].append("gmd:useLimitation is missing")
+ result["errors"].append("gmd:accessConstraints is missing")
+ result["errors"].append("gmd:otherConstraints is missing")
+ errors += 20
+ else:
+ if md.identification.contact is (None or '') or len(
+ md.identification.contact) < 1:
+ result["errors"].append(
+ "gmd:CI_ResponsibleParty: Organization missing")
+ result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
+ result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
+ errors += 3
+ else:
+ if md.identification.contact[0].organization is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: Organization missing")
+ errors += 1
+ if md.identification.contact[0].email is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: E-mail missing")
+ errors += 1
+ if md.identification.contact[0].role is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: Role missing")
+ errors += 1
+
+ if md.identification.title is (None or ''):
+ result["errors"].append(
+ "gmd:md_DataIdentification: Title is missing")
+ errors += 1
+ if md.identification.abstract is (None or ''):
+ result["errors"].append(
+ "gmd:md_DataIdentification: Abstract is missing")
+ errors += 1
+ if md.identification.identtype is (None or ''):
+ result["errors"].append(
+ "gmd:md_ScopeCode: Resource Type is missing")
+ errors += 1
+ if md.identification.resourcelanguage is (None or '') or len(
+ md.identification.resourcelanguage) < 1 or\
+ md.identification.resourcelanguage[0] == '':
+ result["errors"].append(
+ "gmd:language: Resource Language is missing")
+ errors += 1
+ if md.identification.uricode is (None or '') or len(
+ md.identification.uricode) < 1 or\
+ md.identification.uricode[0] == '':
+ result["errors"].append(
+ "gmd:RS_Identifier: Unique Resource Identifier is missing")
+ errors += 1
+ if md.identification.topiccategory is (None or '') or len(
+ md.identification.topiccategory) < 1 or\
+ md.identification.topiccategory[0] == '':
+ result["errors"].append("gmd:topicCategory: TopicCategory is missing")
+ errors += 1
+
+ if md.identification.keywords is None or len(md.identification.keywords) < 1:
+ result["errors"].append("gmd:MD_Keywords: Keywords are missing")
+ result["errors"].append("gmd:thesaurusName: Thesaurus Title is missing")
+ result["errors"].append("gmd:thesaurusName: Thesaurus Date is missing")
+ result["errors"].append("gmd:thesaurusName: Thesaurus Date Type is missing")
+ errors += 4
+ else:
+ if md.identification.keywords[0]['keywords'] is None or len(md.identification.keywords[0]['keywords']) < 1 \
+ or str(md.identification.keywords[0]['keywords']) =="[u'']":
+ result["errors"].append("gmd:MD_Keywords: Keywords are missing")
errors += 1
- if md.identification.topiccategory is (None or '') or len(
- md.identification.topiccategory) < 1 or\
- md.identification.topiccategory[0] == '':
- result["errors"].append(
- "gmd:topicCategory: TopicCategory is missing")
- errors += 1
- if md.identification.keywords is (None or '') or len(
- md.identification.keywords) < 1 or\
- md.identification.keywords[0] == '':
- result["errors"].append(
- "gmd:md_Keywords: Keywords are missing")
- result["errors"].append(
- "gmd:thesaurusName: Thesaurus Title is missing")
- result["errors"].append(
- "gmd:thesaurusName: Thesaurus Date is missing")
- result["errors"].append(
- "gmd:thesaurusName: Thesaurus Date Type is missing")
- errors += 4
+ if md.identification.keywords[0]['thesaurus'] is None:
+ result["errors"].append("gmd:thesaurusName: Thesaurus Title is missing")
+ result["errors"].append("gmd:thesaurusName: Thesaurus Date is missing")
+ result["errors"].append("gmd:thesaurusName: Thesaurus Date Type is missing")
+ errors += 3
else:
- if md.identification.keywords[0]['keywords'] is (None or '') or len(
- md.identification.keywords[0]['keywords']) < 1 :
- result["errors"].append(
- "gmd:md_Keywords: Keywords are missing")
+ if md.identification.keywords[0]['thesaurus']['title'] is None \
+ or len(md.identification.keywords[0]['thesaurus']['title'])<1:
+ result["errors"].append("gmd:thesaurusName: Thesaurus Title is missing")
errors += 1
- if md.identification.keywords[0]['thesaurus'] is (None or ''):
- result["errors"].append(
- "gmd:thesaurusName: Thesaurus Title is missing")
- result["errors"].append(
- "gmd:thesaurusName: Thesaurus Date is missing")
- result["errors"].append(
- "gmd:thesaurusName: Thesaurus Date Type is missing")
- errors += 3
- else:
- if md.identification.keywords[
- 0]['thesaurus']['title'] is (None or ''):
- result["errors"].append(
- "gmd:thesaurusName: Thesaurus Title is missing")
- errors += 1
- if md.identification.keywords[
- 0]['thesaurus']['date'] is (None or ''):
- result["errors"].append(
- "gmd:thesaurusName: Thesaurus Date is missing")
- errors += 1
- if md.identification.keywords[0][
- 'thesaurus']['datetype'] is (None or ''):
- result["errors"].append(
- "gmd:thesaurusName: Thesaurus Date Type is missing")
- errors += 1
- if md.identification.extent is (None or '') :
- result["errors"].append(
- "gmd:EX_Extent: extent element is missing")
- errors += 1
- else:
- if md.identification.extent.boundingBox is (None or ''):
- result["errors"].append(
- "gmd:EX_GeographicBoundingBox: bbox is missing")
+ if md.identification.keywords[0]['thesaurus']['date'] is None \
+ or len(md.identification.keywords[0]['thesaurus']['date'])<1:
+ result["errors"].append("gmd:thesaurusName: Thesaurus Date is missing")
errors += 1
- else:
- if md.identification.extent.boundingBox.minx is (None or ''):
- result["errors"].append(
- "gmd:westBoundLongitude: minx is missing")
- errors += 1
- if md.identification.extent.boundingBox.maxx is (None or ''):
- result["errors"].append(
- "gmd:eastBoundLongitude: maxx is missing")
- errors += 1
- if md.identification.extent.boundingBox.miny is (None or ''):
- result["errors"].append(
- "gmd:southBoundLatitude: miny is missing")
- errors += 1
- if md.identification.extent.boundingBox.maxy is (None or ''):
- result["errors"].append(
- "gmd:northBoundLatitude: maxy is missing")
- errors += 1
-
- if len( md.identification.date) < 1 or (md.identification.temporalextent_start is (None or '') or md.identification.temporalextent_end is (None or '')):
- result["errors"].append(
- "Both gmd:EX_TemporalExtent and gmd:CI_Date are missing")
- errors += 1
+ if md.identification.keywords[0]['thesaurus']['datetype'] is None \
+ or len(md.identification.keywords[0]['thesaurus']['datetype'])<1:
+ result["errors"].append("gmd:thesaurusName: Thesaurus Date Type is missing")
+ errors += 1
+
- if len(md.identification.uselimitation) < 1 or\
- md.identification.uselimitation[0] == '':
- result["errors"].append(
- "gmd:useLimitation is missing")
- errors += 1
- if len(md.identification.accessconstraints) < 1 or\
- md.identification.accessconstraints[0] == '':
- result["errors"].append(
- "gmd:accessConstraints is missing")
- errors += 1
- if len(md.identification.otherconstraints) < 1 or\
- md.identification.otherconstraints[0] == '':
- result["errors"].append(
- "gmd:otherConstraints is missing")
- errors += 1
-
- if md.languagecode is (None or ''):
+ if md.identification.extent is (None or ''):
+ result["errors"].append("gmd:EX_Extent: extent element is missing")
+ errors += 1
+ else:
+ if md.identification.extent.boundingBox is (None or ''):
result["errors"].append(
- "gmd:LanguageCode: Language code missing")
+ "gmd:EX_GeographicBoundingBox: bbox is missing")
errors += 1
- if md.datestamp is (None or ''):
- result["errors"].append("gmd:dateStamp: Date is missing")
- errors += 1
- if md.identifier is (None or ''):
- result["errors"].append(
- "gmd:identifier: Identifier is missing")
- errors += 1
- if md.dataquality is (None or ''):
- result["errors"].append("gmd:LI_Lineage is missing")
- result["errors"].append(
- "gmd:DQ_ConformanceResult: date is missing")
- result["errors"].append(
- "gmd:DQ_ConformanceResult: date type is missing")
- # result["errors"].append("gmd:DQ_ConformanceResult: degree is missing")
- result["errors"].append(
- "gmd:DQ_ConformanceResult: title is missing")
- errors += 4
else:
- if md.dataquality.lineage is (None or ''):
- result["errors"].append("gmd:LI_Lineage is missing")
+ if md.identification.extent.boundingBox.minx is (None or ''):
+ result["errors"].append("gmd:westBoundLongitude: minx is missing")
errors += 1
- if len(md.dataquality.conformancedate) < 1 or \
- md.dataquality.conformancedate[0] == '':
- result["errors"].append(
- "gmd:DQ_ConformanceResult: date is missing")
+ if md.identification.extent.boundingBox.maxx is (None or ''):
+ result["errors"].append("gmd:eastBoundLongitude: maxx is missing")
errors += 1
- if len(md.dataquality.conformancedatetype) < 1 or\
- md.dataquality.conformancedatetype[0] == '' :
- result["errors"].append(
- "gmd:DQ_ConformanceResult: date type is missing")
+ if md.identification.extent.boundingBox.miny is (None or ''):
+ result["errors"].append("gmd:southBoundLatitude: miny is missing")
errors += 1
- # if len(md.dataquality.conformancedegree) < 1:
- # result["errors"].append("gmd:DQ_ConformanceResult: degree is missing")
- # errors += 1
- if len(md.dataquality.conformancetitle) < 1 or\
- md.dataquality.conformancetitle[0] == '':
- result["errors"].append(
- "gmd:DQ_ConformanceResult: title is missing")
+ if md.identification.extent.boundingBox.maxy is (None or ''):
+ result["errors"].append("gmd:northBoundLatitude: maxy is missing")
errors += 1
- if md.contact is (None or ''):
- result["errors"].append(
- "gmd:contact: Organization name is missing")
- result["errors"].append("gmd:contact: e-mail is missing")
- errors += 2
- else:
+ if len(md.identification.date) < 1 or (md.identification.temporalextent_start is (
+ None or '') or md.identification.temporalextent_end is (None or '')):
+ result["errors"].append("Both gmd:EX_TemporalExtent and gmd:CI_Date are missing")
+ errors += 1
+
+ if len(md.identification.uselimitation) < 1 or md.identification.uselimitation[0] == '':
+ result["errors"].append(
+ "gmd:useLimitation is missing")
+ errors += 1
+ if len(md.identification.accessconstraints) < 1 or md.identification.accessconstraints[0] == '':
+ result["errors"].append(
+ "gmd:accessConstraints is missing")
+ errors += 1
+ if len(md.identification.otherconstraints) < 1 or md.identification.otherconstraints[0] == '':
+ result["errors"].append(
+ "gmd:otherConstraints is missing")
+ errors += 1
- if md.contact[0].organization is (None or ''):
- result["errors"].append(
- "gmd:contact: Organization name is missing")
- errors += 1
- if md.contact[0].email is (None or ''):
- result["errors"].append(
- "gmd:contact: e-mail is missing")
- errors += 1
- return result,errors
-
\ No newline at end of file
+ if md.languagecode is (None or ''):
+ result["errors"].append("gmd:LanguageCode: Language code missing")
+ errors += 1
+ if md.datestamp is (None or ''):
+ result["errors"].append("gmd:dateStamp: Date is missing")
+ errors += 1
+ if md.identifier is (None or ''):
+ result["errors"].append("gmd:identifier: Identifier is missing")
+ errors += 1
+ if md.dataquality is (None or ''):
+ result["errors"].append("gmd:LI_Lineage is missing")
+ result["errors"].append("gmd:DQ_ConformanceResult: date is missing")
+ result["errors"].append("gmd:DQ_ConformanceResult: date type is missing")
+ # result["errors"].append("gmd:DQ_ConformanceResult: degree is missing")
+ result["errors"].append("gmd:DQ_ConformanceResult: title is missing")
+ errors += 4
+ else:
+
+ if md.dataquality.lineage is (None or ''):
+ result["errors"].append("gmd:LI_Lineage is missing")
+ errors += 1
+ if len(md.dataquality.conformancedate) < 1 or md.dataquality.conformancedate[0] == '':
+ result["errors"].append("gmd:DQ_ConformanceResult: date is missing")
+ errors += 1
+ if len(md.dataquality.conformancedatetype) < 1 or md.dataquality.conformancedatetype[0] == '':
+ result["errors"].append("gmd:DQ_ConformanceResult: date type is missing")
+ errors += 1
+ # if len(md.dataquality.conformancedegree) < 1:
+ # result["errors"].append("gmd:DQ_ConformanceResult: degree is missing")
+ # errors += 1
+ if len(md.dataquality.conformancetitle) < 1 or md.dataquality.conformancetitle[0] == '':
+ result["errors"].append("gmd:DQ_ConformanceResult: title is missing")
+ errors += 1
+
+ if md.contact is (None or ''):
+ result["errors"].append("gmd:contact: Organization name is missing")
+ result["errors"].append("gmd:contact: e-mail is missing")
+ errors += 3
+ else:
+
+ if md.contact[0].organization is (None or ''):
+ result["errors"].append("gmd:contact: Organization name is missing")
+ errors += 1
+ if md.contact[0].email is (None or ''):
+ result["errors"].append("gmd:contact: e-mail is missing")
+ errors += 1
+ if md.contact[0].role is (None or ''):
+ result["errors"].append("gmd:role: role is missing")
+ errors += 1
+
+ if errors > 0:
+ result["status"] = "failed"
+ result["num_of_errors"] = str(errors)
+
+ return result
Modified: sandbox/krejcmat/src/templates/grassGRASSTemplateFinal.xml
===================================================================
--- sandbox/krejcmat/src/templates/grassGRASSTemplateFinal.xml 2014-08-05 21:45:19 UTC (rev 61537)
+++ sandbox/krejcmat/src/templates/grassGRASSTemplateFinal.xml 2014-08-05 22:04:08 UTC (rev 61538)
@@ -24,7 +24,7 @@
</gmd:CI_Contact>
</gmd:contactInfo>
<gmd:role>
- <gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue="{{ co.role }}{# tag="co.role",name="Responsible party role",ref="Part B 9.2" , multi = 0,type = "CI_RoleCode", inboxmulti = 1,group = "Responsible party",object="CI_ResponsibleParty()", inbox="Metadata pointt of contact",example="custodian", desc="function performed by the responsible party" #}" codeSpace="ISOTC211/19115">{{ co.role }}</gmd:CI_RoleCode>
+ <gmd:CI_RoleCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" codeListValue="{{ co.role }}{# tag="co.role",name="Responsible party role",ref="Part B 9.2" , multi = 0,type = "CI_RoleCode", inboxmulti = 1,group = "Responsible party",object="CI_ResponsibleParty()", inbox="Metadata pointt of contact",example="custodian", desc="function performed by the responsible party" #}" codeSpace="ISOTC211/19115">{{ co.role }}</gmd:CI_RoleCode>
</gmd:role>
</gmd:CI_ResponsibleParty>
</gmd:contact>
@@ -43,7 +43,7 @@
<gmd:citation>
<gmd:CI_Citation>
<gmd:title>
- <gco:CharacterString>{{ md.identification.title }}{# tag="md.identification.title", ref="Part B 1.1", name ="Resource title", desc ="Name by which the cited resource is known.", example ="Image2000 Product 1 (nl2) MultispectB 10.1" , multi = 0, group ="Identification", type = "string", multiline=False #}</gco:CharacterString>
+ <gco:CharacterString>{{ md.identification.title }}{# tag="md.identification.title", ref="Part B 1.1", name ="Resource title", desc ="Name by which the cited resource is known.", example ="Image2000 Product 1 (nl2) MultispectB 10.1" , multi = 0, group ="Identification", type = "string", multiline=True #}</gco:CharacterString>
</gmd:title>
{% for d in md.identification.date -%}{# tag="for d in md.identification.date" ,name="",object="CI_Date()",group= "Temporal" , inbox= "Date of creation/publication/revision", inboxmulti=1, multiline= False #}
<gmd:date>
@@ -87,10 +87,11 @@
{% endfor -%}
{% if md.identification.distance|length > 0 -%}{# tag="if md.identification.distance|length > 0", group = "Quality and Validity", inbox="Spatial resolution-distance",inboxmulti= 1 #}
{% for (d,u) in zip(md.identification.distance, md.identification.uom) -%}{# tag="for (d,u) in zip(md.identification.distance, md.identification.uom", group = "Quality and Validity", inbox="Spatial resolution-distance",inboxmulti= 1 #}
- <gmd:spatialResolution>
+ <gmd:spatialResolution>
<gmd:MD_Resolution>
<gmd:distance>
- <gco:Distance uom="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/uom/ML_gmxUom.xml#m">{{ d }}{# tag="d" , name="Distance" , ref= "Part B 6.2" , desc= "Ground sample distance" , example = "25" ,type = "integer", group = "Quality and Validity" ,inbox="Spatial resolution-dostance", multi=0 , inboxmulti=1, multiline= False #}</gco:Distance>
+ <gco:Distance uom="{{ u }}{# tag="u" , name="Units" , ref= "Part B 6.2" , desc= "Ground sample distance" , example = "m" , type ="string" , group = "Quality and Validity" ,inbox="Spatial resolution-distance", multi=0 , inboxmulti=1, multiline= False #}">
+{{ d }}{# tag="d" , name="Resolution" , ref= "Part B 6.2" , desc= "Ground sample distance" , example = "25" , type ="integer" , group = "Quality and Validity" ,inbox="Spatial resolution-distance", multi=0 , inboxmulti=1, multiline= False #}</gco:Distance>
</gmd:distance>
</gmd:MD_Resolution>
</gmd:spatialResolution>
@@ -128,15 +129,4 @@
</gmd:distributionFormat>
</gmd:MD_Distribution>
</gmd:distributionInfo>
- <gmd:dataQualityInfo>
- <gmd:DQ_DataQuality>
- <gmd:scope>
- <gmd:DQ_Scope>
- <gmd:level>
- <gmd:MD_ScopeCode codeListValue="{{ md.identification.identtype }}{# tag="md.identification.identtype", name ="Resource Type",type = "MD_ScopeCode", desc ="Scope to which metadata applies", example ="dataset", multi = 0, group = "Identification",multiline=True #}" codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode">{{ md.identification.identtype }}</gmd:MD_ScopeCode>
- </gmd:level>
- </gmd:DQ_Scope>
- </gmd:scope>
- </gmd:DQ_DataQuality>
- </gmd:dataQualityInfo>
</gmd:MD_Metadata>
Modified: sandbox/krejcmat/src/templates/grassInspireTemplateFinal.xml
===================================================================
--- sandbox/krejcmat/src/templates/grassInspireTemplateFinal.xml 2014-08-05 21:45:19 UTC (rev 61537)
+++ sandbox/krejcmat/src/templates/grassInspireTemplateFinal.xml 2014-08-05 22:04:08 UTC (rev 61538)
@@ -46,7 +46,7 @@
<gmd:citation>
<gmd:CI_Citation>
<gmd:title>
- <gco:CharacterString>{{ md.identification.title }}{# tag="md.identification.title", ref="Part B 1.1", name ="Resource title", desc ="Name by which the cited resource is known.", example ="Image2000 Product 1 (nl2) MultispectB 10.1" , multi = 0, group ="Identification", type = "string", multiline=False #}</gco:CharacterString>
+ <gco:CharacterString>{{ md.identification.title }}{# tag="md.identification.title", ref="Part B 1.1", name ="Resource title", desc ="Name by which the cited resource is known.", example ="Image2000 Product 1 (nl2) MultispectB 10.1" , multi = 0, group ="Identification", type = "string", multiline=True #}</gco:CharacterString>
</gmd:title>
{% for d in md.identification.date -%}{# tag="for d in md.identification.date" ,name="",object="CI_Date()",group= "Temporal" , inbox= "Date of creation/publication/revision", inboxmulti=1, multiline= False #}
<gmd:date>
@@ -55,7 +55,7 @@
<gco:DateTime>{{ d.date }}{# tag="d.date" , group= "Temporal" ,object="CI_Date()",type = "date", inbox= "Date of creation/publication/revision", inboxmulti=1, multiline= False, name="Date of: type(below)",desc="reference date for the cited resource - publication/creation/revision",example="2007-09-15" #}</gco:DateTime>
</gmd:date>
<gmd:dateType>
- <gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" codeListValue="{{ d.type }}{# tag="d.type" , group= "Temporal" ,object="CI_Date()",type = "CI_DateTypeCode", inbox= "Date of creation/publication/revision", inboxmulti=1, multiline= False, name="type: creation/publication/revision",desc="reference date for the cited resource - publication/creation/revision",example="creation" #}" codeSpace="ISOTC211/19115">{{ d.type }}</gmd:CI_DateTypeCode>
+ <gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" codeListValue= "{{ d.type }}{# tag="d.type" , group= "Temporal" ,object="CI_Date()",type = "CI_DateTypeCode", inbox= "Date of creation/publication/revision", inboxmulti=1, multiline= False, name="type: creation/publication/revision",desc="reference date for the cited resource - publication/creation/revision",example="creation" #}" codeSpace="ISOTC211/19115">{{ d.type }}</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
@@ -68,10 +68,10 @@
<gmd:geographicIdentifier>
<gmd:RS_Identifier>
<gmd:code>
- <gco:CharacterString>{{ cod }}{# tag="cod", inboxmulti=1, group = "Identification",inbox="Unique resource identifier" ,ref="Part B 1.5", name ="Identifier- code", desc ="A value uniquely identifying the resource.The value domain of this metadata element is a mandatory character string code, generally assigned by the data owner, and a character string namespace uniquely identifying the context of the identifier code (for example, the data owner).", example ="http://image2000.jrc.it # image2000_1_nl2_multi", type = "string", multi = 0 #}</gco:CharacterString>
+ <gco:CharacterString>{{ cod }}{# tag="cod", inboxmulti=1, group = "Identification",inbox="Unique resource identifier" ,ref="Part B 1.5", name ="Idetifier- code", desc ="A value uniquely identifying the resource.The value domain of this metadata element is a mandatory character string code, generally assigned by the data owner, and a character string namespace uniquely identifying the context of the identifier code (for example, the data owner).", example ="http://image2000.jrc.it # image2000_1_nl2_multi", type = "string", multi = 0 #}</gco:CharacterString>
</gmd:code>
<gmd:codeSpace>
- <gco:CharacterString>{{ code }}{# tag="code", inboxmulti=1, group = "Identification",inbox="Unique resource identifier" ,ref="Part B 1.5", name ="Identifier- code space", desc ="A value uniquely identifying the resource.The value domain of this metadata element is a mandatory character string code, generally assigned by the data owner, and a character string namespace uniquely identifying the context of the identifier code (for example, the data owner).", example ="http://image2000.jrc.it", type = "string", multi = 0 #}</gco:CharacterString>
+ <gco:CharacterString>{{ code }}{# tag="code", inboxmulti=1, group = "Identification",inbox="Unique resource identifier" ,ref="Part B 1.5", name ="Idetifier- code space", desc ="A value uniquely identifying the resource.The value domain of this metadata element is a mandatory character string code, generally assigned by the data owner, and a character string namespace uniquely identifying the context of the identifier code (for example, the data owner).", example ="http://image2000.jrc.it", type = "string", multi = 0 #}</gco:CharacterString>
</gmd:codeSpace>
</gmd:RS_Identifier>
</gmd:geographicIdentifier>
@@ -130,7 +130,7 @@
<gco:Date>{{ k["thesaurus"]["date"] }}{# tag='k["thesaurus"]["date"]', name ="Reference date", desc ="This citation shall include at least the title a reference date(publication, revision, creation." , type = "date",inboxmulti=1, multi = 0, group = "Keywords", multiline=False, inbox="Free keywords" #}</gco:Date>
</gmd:date>
<gmd:dateType>
- <gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" codeListValue="{{ k["thesaurus"]["datetype"] }}{{ k["thesaurus"]["datetype"] }}{# tag='k["thesaurus"]["datetype"]', type = "CI_DateTypeCode",name ="Date type",inboxmulti=1, desc ="Options Date of creation, Date of last revision, date of publication" , multi = 0, group = "Keywords", multiline=False, inbox="Free keywords" #}">{{ k["thesaurus"]["datetype"] }}</gmd:CI_DateTypeCode>
+ <gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" codeListValue= "{{ k["thesaurus"]["datetype"] }}{{ k["thesaurus"]["datetype"] }}{# tag='k["thesaurus"]["datetype"]', type = "CI_DateTypeCode",name ="Date type",inboxmulti=1, desc ="Options Date of creation, Date of last revision, date of publication" , multi = 0, group = "Keywords", multiline=False, inbox="Free keywords" #}" >{{ k["thesaurus"]["datetype"] }}</gmd:CI_DateTypeCode>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
@@ -179,10 +179,11 @@
{% endif -%}
{% if md.identification.distance|length > 0 -%}{# tag="if md.identification.distance|length > 0", group = "Quality and Validity", inbox="Spatial resolution-distance",inboxmulti= 1 #}
{% for (d,u) in zip(md.identification.distance, md.identification.uom) -%}{# tag="for (d,u) in zip(md.identification.distance, md.identification.uom", group = "Quality and Validity", inbox="Spatial resolution-distance",inboxmulti= 1 #}
- <gmd:spatialResolution>
+ <gmd:spatialResolution>
<gmd:MD_Resolution>
<gmd:distance>
- <gco:Distance uom="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/uom/ML_gmxUom.xml#m">{{ d }}{# tag="d" , name="Distance" , ref= "Part B 6.2" , desc= "Ground sample distance" , example = "25" , type ="integer" , group = "Quality and Validity" ,inbox="Spatial resolution-dostance", multi=0 , inboxmulti=1, multiline= False #}</gco:Distance>
+ <gco:Distance uom="{{ u }}{# tag="u" , name="Units" , ref= "Part B 6.2" , desc= "Ground sample distance" , example = "m" , type ="string" , group = "Quality and Validity" ,inbox="Spatial resolution-distance", multi=0 , inboxmulti=1, multiline= False #}">
+{{ d }}{# tag="d" , name="Resolution" , ref= "Part B 6.2" , desc= "Ground sample distance" , example = "25" , type ="integer" , group = "Quality and Validity" ,inbox="Spatial resolution-distance", multi=0 , inboxmulti=1, multiline= False #}</gco:Distance>
</gmd:distance>
</gmd:MD_Resolution>
</gmd:spatialResolution>
@@ -264,7 +265,7 @@
<gmd:scope>
<gmd:DQ_Scope>
<gmd:level>
- <gmd:MD_ScopeCode codeListValue="{{ md.identification.identtype }}{# tag="md.identification.identtype", name ="Resource Type", desc ="Scope to which metadata applies", example ="dataset", type = "string", multi = 0, group = "Identification",multiline=True #}" codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode">{{ md.identification.identtype }}</gmd:MD_ScopeCode>
+ <gmd:MD_ScopeCode codeListValue="{{ md.identification.identtype }}{# tag="md.identification.identtype", name ="Resource Type", desc ="Scope to which metadata applies", example ="dataset", type = "string", multi = 0, group = "Conformity",multiline=False #}" codeList="http://www.isotc211.org/2005/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode">{{ md.identification.identtype }}</gmd:MD_ScopeCode>
</gmd:level>
</gmd:DQ_Scope>
</gmd:scope>
More information about the grass-commit
mailing list