[GRASS-SVN] r67224 - grass-addons/grass7/gui/wxpython/wx.metadata/mdlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 18 08:24:56 PST 2015
Author: krejcmat
Date: 2015-12-18 08:24:55 -0800 (Fri, 18 Dec 2015)
New Revision: 67224
Modified:
grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/cswlib.py
grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/cswutil.py
grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdutil.py
Log:
addons wx.metadata: fix g.gui.cswbrowser path
Modified: grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/cswlib.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/cswlib.py 2015-12-18 16:06:58 UTC (rev 67223)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/cswlib.py 2015-12-18 16:24:55 UTC (rev 67224)
@@ -10,40 +10,32 @@
@author Matej Krejci <matejkrejci gmail.com> (GSoC 2015)
"""
-import sys,os
+import sys
+
try:
from owslib.csw import CatalogueServiceWeb
except:
- sys.exit('owslib python library is missing. Check requirements on the manual page < https://grasswiki.osgeo.org/wiki/ISO/INSPIRE_Metadata_Support >')
+ sys.exit(
+ 'owslib python library is missing. Check requirements on the manual page < https://grasswiki.osgeo.org/wiki/ISO/INSPIRE_Metadata_Support >')
from cswutil import *
-
from mdutil import yesNo, StaticContext
-import tempfile
import json
-
-import webbrowser
import wx
from wx import SplitterWindow
import wx.html as html
-from wx.lib.buttons import ThemedGenBitmapTextButton as BitmapBtnTxt
from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin
import webbrowser
from threading import Thread
import xml.etree.ElementTree as ET
-from wx.html import HTML_URL_IMAGE, HTML_OPEN, EVT_HTML_LINK_CLICKED, HW_DEFAULT_STYLE, HW_SCROLLBAR_NEVER, \
- HW_SCROLLBAR_AUTO
-
+from wx.html import EVT_HTML_LINK_CLICKED, HW_DEFAULT_STYLE, HW_SCROLLBAR_AUTO
# import wx.html2 not supported in 2.8.12.1 (need for CSS support)
from owslib.csw import CatalogueServiceWeb
from owslib.fes import BBox, PropertyIsLike
from owslib.ows import ExceptionReport
-
-import grass.script as grass
-from core.utils import GetFormats
from gui_core.forms import GUI
-from core.gcmd import RunCommand, GError, GMessage, GWarning
-from modules.import_export import GdalImportDialog, GdalOutputDialog, ImportDialog
+from core.gcmd import GError, GMessage, GWarning
+from modules.import_export import GdalImportDialog
from subprocess import PIPE
from grass.pygrass.modules import Module
from grass.script import parse_key_val
@@ -90,8 +82,9 @@
class CSWBrowserPanel(wx.Panel):
- def __init__(self, parent, main):
+ def __init__(self, parent, main, giface=None):
self.context = StaticContext()
+ self.giface = giface
self.config = wx.Config('g.gui.cswbrowser')
wx.Panel.__init__(self, parent)
self.parent = main
@@ -102,7 +95,7 @@
self.constString = ''
sizeConst = 55
self.splitterBrowser = SplitterWindow(self, style=wx.SP_3D | wx.SP_LIVE_UPDATE | wx.SP_BORDER)
- self.context=StaticContext()
+ self.context = StaticContext()
self.connectionFilePath = os.path.join(self.context.lib_path, 'connections_resources.xml')
self.pnlLeft = wx.Panel(self.splitterBrowser, id=wx.ID_ANY)
self.pnlRight = wx.Panel(self.splitterBrowser, -1)
@@ -124,15 +117,14 @@
self.numResultsSpin = wx.SpinCtrl(self.pnlLeft, min=1, max=100, initial=20, size=(sizeConst, self.h),
style=wx.ALIGN_RIGHT | wx.SP_ARROW_KEYS)
-
self.addKeywordCtr = wx.Button(self.pnlLeft, -1, '+', size=(self.h, self.h))
self.addKeywordCtr.Bind(wx.EVT_BUTTON, self.addKeyWidget)
self.findBtt = wx.Button(self.pnlLeft, size=(sizeConst, self.h), label='Search')
self.findBtt.SetBackgroundColour((255, 127, 80))
- qtyp=['All','Collection','Dataset','Event','Image','InteractiveResource',
- 'MovingImage','PhysicalObject','Service','Software','Sound','StillImage','Text']
+ qtyp = ['All', 'Collection', 'Dataset', 'Event', 'Image', 'InteractiveResource',
+ 'MovingImage', 'PhysicalObject', 'Service', 'Software', 'Sound', 'StillImage', 'Text']
- self.qtypeCb = wx.ComboBox(self.pnlLeft, id=-1, pos=wx.DefaultPosition,choices=qtyp)
+ self.qtypeCb = wx.ComboBox(self.pnlLeft, id=-1, pos=wx.DefaultPosition, choices=qtyp)
self.qtypeCb.SetValue("All")
self.qtypeCb.Disable()
# -----Results---
@@ -195,7 +187,7 @@
style=HW_DEFAULT_STYLE | HW_SCROLLBAR_AUTO,
name="metadata")
self.htmlView.Bind(EVT_HTML_LINK_CLICKED, self.onHtmlLinkClicked)
- #self.htmlView=wx.html2.WebView.New(self.pnlRight, not supported in 2.8.12.1
+ # self.htmlView=wx.html2.WebView.New(self.pnlRight, not supported in 2.8.12.1
self.refreshNavigationButt()
self._layout()
@@ -236,7 +228,7 @@
return
constString = 'self.constraints=' + self.constString
try:
- exec(constString)
+ exec (constString)
if type(self.constraints != type(list())):
GMessage('Constraints syntax error')
return
@@ -282,7 +274,7 @@
def OnShowResponse(self, evt):
response_html = encodeString(highlight_xml(self.context, self.catalog.response))
- path ='htmlResponse.html'
+ path = 'htmlResponse.html'
f = open(path, 'w')
f.write(response_html)
f.close()
@@ -315,7 +307,7 @@
record.xml_url = cat.request
if self.catalog:
- path='record_metadata_dc.html'
+ path = 'record_metadata_dc.html'
metadata = render_template('en', self.context,
record,
path)
@@ -465,7 +457,6 @@
n = self.config.ReadInt('/guiSearch/catalog', 0)
self.catalogCmb.SetSelection(n)
-
def setTooltip(self, evt):
index = evt.GetIndex()
text = self.resultList.GetItem(index, 1)
@@ -547,6 +538,16 @@
dns.OnUpdate(evt)
serviceDialog.Show()
+ def _openWebServiceDiag(self, data_url):
+ from web_services.dialogs import AddWSDialog
+ print "giface _openWebServiceDiag",self.giface
+ if self.giface:
+ self.WSDialog = AddWSDialog(self.parent, giface=self.giface)
+ self.WSDialog.OnSettingsChanged([data_url, '', ''])
+ self.WSDialog.Show()
+ else:
+ GMessage(_("No access to layer tree. Run g.gui.cswbroswer from g.gui"))
+
def OnService(self, evt):
name = evt.GetEventObject().GetLabel()
idx = self.resultList.GetNextItem(0, wx.LIST_NEXT_ALL,
@@ -558,25 +559,29 @@
exec (item_data)
if name == "Add WMS":
data_url = item_data['wms']
- service = ['r.in.gdal', 'r.in.wms']
+ service = ['r.in.gdal', 'r.in.wms', 'Add web service layer']
dlg = wx.SingleChoiceDialog(
- self, 'Choice module of WMS service ', 'Service module',
+ self, 'Choice of module for WMS service ', 'Service module',
service,
wx.CHOICEDLG_STYLE
)
if dlg.ShowModal() == wx.ID_OK:
- if dlg.GetStringSelection() == service[0]:
+ selected_module = dlg.GetStringSelection()
+ if selected_module == service[0]:
self.gdalImport(False, data_url, type='wms', evt=evt)
- else:
+ elif selected_module == service[1]:
cmd.append('r.in.wms')
cmd.append('url=%s' % data_url)
GUI(parent=self, show=True, modal=True).ParseCommand(cmd=cmd)
+ elif selected_module == service[2]:
+ self._openWebServiceDiag(data_url)
+
dlg.Destroy()
elif name == "Add WFS":
data_url = item_data['wfs']
- service = ['v.in.ogr', 'v.in.wfs']
+ service = ['v.in.ogr', 'v.in.wfs', 'Add web service layer']
dlg = wx.SingleChoiceDialog(
self, 'Choice module of WFS service ', 'Service module',
service,
@@ -584,12 +589,15 @@
)
if dlg.ShowModal() == wx.ID_OK:
- if dlg.GetStringSelection() == service[0]:
+ selected_module = dlg.GetStringSelection()
+ if selected_module == service[0]:
self.gdalImport(True, data_url, type='wfs', evt=evt)
- else:
+ elif selected_module == service[1]:
cmd.append('v.in.wfs')
cmd.append('url=%s' % data_url)
GUI(parent=self, show=True, modal=True).ParseCommand(cmd=cmd)
+ elif selected_module == service[2]:
+ self._openWebServiceDiag(data_url)
dlg.Destroy()
elif name == "Add WCS":
@@ -597,10 +605,9 @@
data_url = item_data['wcs']
self.gdalImport(False, data_url, type='wcs', evt=evt)
-
def GetQtype(self): # TODO need to implement
- val=self.qtypeCb.GetValue()
- if val== 'All':
+ val = self.qtypeCb.GetValue()
+ if val == 'All':
return None
else:
return val
@@ -654,7 +661,7 @@
GError('Search error: %s' % err)
return
except Exception, err:
- GError('Connection error: %s'% err)
+ GError('Connection error: %s' % err)
return
if self.catalog.results['matches'] == 0:
@@ -692,18 +699,17 @@
d[index]['link'] = value
self.idResults.insert(index, d)
-
def displyResults(self):
"""display search results"""
self.refreshResultList()
position = self.catalog.results['returned'] + self.startfrom
- msg = 'Showing %s - %s of %s result(s)' % ( self.startfrom + 1,
- position,
- self.catalog.results['matches'],
+ msg = 'Showing %s - %s of %s result(s)' % (self.startfrom + 1,
+ position,
+ self.catalog.results['matches'],
- )
+ )
self.findResNumLbl.SetLabel(msg)
index = 0
@@ -749,7 +755,7 @@
upSearchSizer.Add(self.qtypeCb, 1, wx.EXPAND)
- self.leftSearchSizer.Add(upSearchSizer, 1 ,wx.EXPAND )
+ self.leftSearchSizer.Add(upSearchSizer, 1, wx.EXPAND)
self.rightSearchSizer.Add(wx.StaticText(self), 0)
mainSearchSizer.Add(self.leftSearchSizer, wx.EXPAND)
mainSearchSizer.Add(self.rightSearchSizer)
@@ -841,12 +847,13 @@
self.mainsizer.Add(self.splitterBrowser, 1, wx.EXPAND)
self.SetSizerAndFit(self.mainsizer)
+
class CSWConnectionPanel(wx.Panel):
- def __init__(self, parent, main,cswBrowser=True):
+ def __init__(self, parent, main, cswBrowser=True):
wx.Panel.__init__(self, parent)
self.parent = main
self.config = wx.Config('g.gui.cswbrowser')
- self.cswBrowser=cswBrowser
+ self.cswBrowser = cswBrowser
self.splitterConn = SplitterWindow(self, style=wx.SP_3D |
wx.SP_LIVE_UPDATE | wx.SP_BORDER)
self.panelLeft = wx.Panel(self.splitterConn, id=wx.ID_ANY)
@@ -854,9 +861,10 @@
self.stBoxConnections1 = wx.StaticBox(self.panelLeft, -1, 'Connection manager')
self.panelRight = wx.Panel(self.splitterConn, -1)
self.connectionLBox = wx.ListBox(self.panelLeft, id=-1, pos=wx.DefaultPosition)
- self.timeoutSpin = wx.SpinCtrl(self.panelLeft, min=1, max=100, initial=10 , style=wx.ALIGN_RIGHT | wx.SP_ARROW_KEYS)
+ self.timeoutSpin = wx.SpinCtrl(self.panelLeft, min=1, max=100, initial=10,
+ style=wx.ALIGN_RIGHT | wx.SP_ARROW_KEYS)
self.context = StaticContext()
- self.connectionFilePath = os.path.join(self.context.lib_path, 'connections_resources.xml')
+ self.connectionFilePath = self.context.connResources
self.servicePath = 'service_metadata.html'
self.serviceInfoBtt = wx.Button(self.panelLeft, -1, label='Service info')
self.newBtt = wx.Button(self.panelLeft, label='New')
@@ -973,7 +981,7 @@
tree.write(self.connectionFilePath)
self.updateConnectionList()
- def publishCSW(self,path):
+ def publishCSW(self, path):
"""show connection info"""
if self.connectionLBox.GetSelection() == wx.NOT_FOUND:
GMessage('Please select catalog')
@@ -994,7 +1002,7 @@
try:
self.catalog.transaction(ttype='insert', typename='gmd:MD_Metadata', record=open(path).read())
except Exception, e:
- GWarning('Transaction error: <%s>'%e)
+ GWarning('Transaction error: <%s>' % e)
def onHtmlLinkClicked(self, event):
Thread(
@@ -1057,7 +1065,7 @@
if yesNo(self, "Do you want to remove temporary connections?", "Remove tmp connections"):
self.config.DeleteGroup('/connections')
- noerr, doc =get_connections_from_file( self.connectionFilePath)
+ noerr, doc = get_connections_from_file(self.connectionFilePath)
if not noerr:
GError(doc)
@@ -1095,28 +1103,27 @@
def updateConnectionList(self):
- """populate select box with connections"""
- self.connectionLBox.Clear()
+ """populate select box with connections"""
+ self.connectionLBox.Clear()
- more, value, index = self.config.GetFirstGroup()
- first = value
- if self.cswBrowser:# ONLY FOR g.gui.cswbrowser
- self.parent.BrowserPanel.catalogCmb.Clear()
+ more, value, index = self.config.GetFirstGroup()
+ first = value
+ if self.cswBrowser: # ONLY FOR g.gui.cswbrowser
+ self.parent.BrowserPanel.catalogCmb.Clear()
- while more:
- if self.cswBrowser:
- self.parent.BrowserPanel.catalogCmb.Append(value)
- self.connectionLBox.Append(value)
- more, value, index = self.config.GetNextGroup(index)
- n = self.connectionLBox.GetCount()
- self.connectionLBox.SetString(n + 1, first)
- if self.connectionLBox.GetCount() == 0:
- msg = 'No services/connections defined.'
- self.textMetadata.SetPage('<p><h3>%s</h3></p>' % msg)
+ while more:
if self.cswBrowser:
- self.parent.BrowserPanel.loadSettings()
+ self.parent.BrowserPanel.catalogCmb.Append(value)
+ self.connectionLBox.Append(value)
+ more, value, index = self.config.GetNextGroup(index)
+ n = self.connectionLBox.GetCount()
+ self.connectionLBox.SetString(n + 1, first)
+ if self.connectionLBox.GetCount() == 0:
+ msg = 'No services/connections defined.'
+ self.textMetadata.SetPage('<p><h3>%s</h3></p>' % msg)
+ if self.cswBrowser:
+ self.parent.BrowserPanel.loadSettings()
-
def onOpenConnFile(self, event):
openFileDialog = wx.FileDialog(self, "Open catalog file", "", "",
"XML files (*.xml)|*.xml", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
@@ -1133,7 +1140,7 @@
self.stBoxConnectionsSizer = wx.StaticBoxSizer(self.stBoxConnections, wx.VERTICAL)
self.stBoxConnectionsSizer.Add(self.connectionLBox, 1, wx.EXPAND)
self.stBoxConnectionsSizer.AddSpacer(20, 10, 1, wx.EXPAND)
- self.stBoxConnectionsSizer.Add(wx.StaticText(self.panelLeft,label='Timeout'),0)
+ self.stBoxConnectionsSizer.Add(wx.StaticText(self.panelLeft, label='Timeout'), 0)
self.stBoxConnectionsSizer.Add(self.timeoutSpin, 0)
self.stBoxConnectionsSizer.Add(self.serviceInfoBtt, 0, wx.EXPAND)
@@ -1158,6 +1165,7 @@
self.SetInitialSize()
self.SetSizer(self.mainsizer)
+
class AutoWidthListCtrl(wx.ListCtrl, ListCtrlAutoWidthMixin):
def __init__(self, parent):
wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT | wx.BORDER_SUNKEN)
Modified: grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/cswutil.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/cswutil.py 2015-12-18 16:06:58 UTC (rev 67223)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/cswutil.py 2015-12-18 16:24:55 UTC (rev 67224)
@@ -46,7 +46,7 @@
"""Renders HTML display of metadata XML"""
env = Environment(extensions=['jinja2.ext.i18n'],
- loader=FileSystemLoader(context.addonsPath))
+ loader=FileSystemLoader(context.confDirPath))
env.install_gettext_callables(gettext, ngettext, newstyle=True)
template_file = template
@@ -77,7 +77,7 @@
css = hformat.get_style_defs('.highlight')
body = highlight(prettify_xml(xml), XmlLexer(), hformat)
- env = Environment(loader=FileSystemLoader(context.addonsPath))
+ env = Environment(loader=FileSystemLoader(context.confDirPath))
template_file = 'xml_highlight.html'
template = env.get_template(template_file)
@@ -87,7 +87,7 @@
def renderXML(context, xml):
hformat = HtmlFormatter()
body = highlight(prettify_xml(xml), XmlLexer(), hformat)
- env = Environment(loader=FileSystemLoader(context.addonsPath))
+ env = Environment(loader=FileSystemLoader(context.confDirPath))
template_file = 'xml_render.html'
template = env.get_template(template_file)
Modified: grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdutil.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdutil.py 2015-12-18 16:06:58 UTC (rev 67223)
+++ grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdutil.py 2015-12-18 16:24:55 UTC (rev 67224)
@@ -20,17 +20,16 @@
@author Matej Krejci <matejkrejci gmail.com> (GSoC 2014)
"""
-import os,sys
+import os
+import sys
try:
from owslib.iso import *
except:
- sys.exit('owslib library is missing. Check requirements on the manual page < https://grasswiki.osgeo.org/wiki/ISO/INSPIRE_Metadata_Support >')
+ sys.exit(
+ 'owslib library is missing. Check requirements on the manual page < https://grasswiki.osgeo.org/wiki/ISO/INSPIRE_Metadata_Support >')
-from owslib.namespaces import Namespaces
-from owslib.etree import etree
from owslib import util
-
import string
from grass.script import core as grass
from grass.pygrass.modules import Module
@@ -38,29 +37,40 @@
from grass.pygrass.utils import get_lib_path
import wx
+
class StaticContext(object):
def __init__(self):
self.ppath = os.path.dirname(os.path.abspath(__file__))
- path = os.path.join('wx.metadata','config')
- self.configureLibPath = get_lib_path(modname=path ,libname='init_md.txt')
+
+ self.confDirPath = os.path.join(os.getenv('GRASS_ADDON_BASE'), 'etc', 'wx.metadata', 'config')
+ print self.confDirPath
+ path = os.path.join('wx.metadata', 'config')
+ self.connResources = get_lib_path(modname=path, libname='connections_resources.xml')
+ if self.connResources is None:
+ grass.fatal("Fatal error: library < %s > not found" % path)
+ else:
+ self.connResources = os.path.join(self.connResources, 'connections_resources.xml')
+
+ self.configureLibPath = get_lib_path(modname=path, libname='init_md.txt')
if self.configureLibPath is None:
- grass.fatal("Fatal error: library < %s > not found"%path)
+ grass.fatal("Fatal error: library < %s > not found" % path)
- path=os.path.join('wx.metadata','profiles')
- self.profilesLibPath = get_lib_path(modname= path,libname='basicProfile.xml')
-
+ path = os.path.join('wx.metadata', 'profiles')
+ self.profilesLibPath = get_lib_path(modname=path, libname='basicProfile.xml')
if self.profilesLibPath is None:
- grass.fatal("Fatal error: library < %s > not found"%path)
+ grass.fatal("Fatal error: library < %s > not found" % path)
- self.lib_path = os.path.normpath(self.configureLibPath+ os.sep + os.pardir)
+ self.lib_path = os.path.normpath(self.configureLibPath + os.sep + os.pardir)
+
def isTableExists(name):
- res = Module('db.tables',flags='p',stdout_=PIPE)
+ res = Module('db.tables', flags='p', stdout_=PIPE)
for line in res.outputs.stdout.splitlines():
if name == line:
- return True
+ return True
return False
+
def removeNonAscii(s):
'''Removed non ASCII chars
'''
@@ -69,7 +79,6 @@
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()
@@ -130,17 +139,17 @@
result["errors"].append("gmd:CI_ResponsibleParty: Role is missing")
errors += 3
else:
- if md.identification.contact[0].organization is (None or ''):
- result["errors"].append("gmd:CI_ResponsibleParty: Organization name is missing")
- errors += 1
+ if md.identification.contact[0].organization is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: Organization name is missing")
+ errors += 1
- if md.identification.contact[0].email is (None or ''):
- result["errors"].append("gmd:CI_ResponsibleParty: E-mail is missing")
- errors += 1
+ if md.identification.contact[0].email is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: E-mail is missing")
+ errors += 1
- if md.identification.contact[0].role is (None or ''):
- result["errors"].append("gmd:CI_ResponsibleParty: Role is missing")
- errors += 1
+ if md.identification.contact[0].role is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: Role is missing")
+ errors += 1
if md.identification.title is (None or ''):
result["errors"].append("gmd:md_DataIdentification: Title is missing")
@@ -174,7 +183,7 @@
errors += 1
if len(md.identification.date) < 1 or (md.identification.temporalextent_start is (
- None or '') or md.identification.temporalextent_end is (None or '')):
+ 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
@@ -192,17 +201,17 @@
result["errors"].append("gmd:role: Role 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].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].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 md.contact[0].role is (None or ''):
+ result["errors"].append("gmd:role: Role is missing")
+ errors += 1
if errors > 0:
result["status"] = "failed"
@@ -248,17 +257,17 @@
errors += 3
else:
- if md.identification.contact[0].organization is (None or ''):
- result["errors"].append("gmd:CI_ResponsibleParty: Organization name is missing")
- errors += 1
+ if md.identification.contact[0].organization is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: Organization name is missing")
+ errors += 1
- if md.identification.contact[0].email is (None or ''):
- result["errors"].append("gmd:CI_ResponsibleParty: E-mail is missing")
- errors += 1
+ if md.identification.contact[0].email is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: E-mail is missing")
+ errors += 1
- if md.identification.contact[0].role is (None or ''):
- result["errors"].append("gmd:CI_ResponsibleParty: Role is missing")
- errors += 1
+ if md.identification.contact[0].role is (None or ''):
+ result["errors"].append("gmd:CI_ResponsibleParty: Role is missing")
+ errors += 1
if md.identification.title is (None or ''):
result["errors"].append("gmd:md_DataIdentification: Title is missing")
@@ -275,8 +284,8 @@
result["errors"].append("gmd:language: Resource language is missing")
else:
if len(md.identification.resourcelanguage) < 1 or md.identification.resourcelanguage[0] == '':
- result["errors"].append("gmd:language: Resource language is missing")
- errors += 1
+ result["errors"].append("gmd:language: Resource language is missing")
+ errors += 1
if md.identification.uricode is None:
result["errors"].append("gmd:RS_Identifier: Unique Resource Identifier is missing")
@@ -295,34 +304,34 @@
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.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 += 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 += 3
+ else:
+ 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:
- result["errors"].append("gmd:thesaurusName: Thesaurus title 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
+ 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 += 3
- else:
- 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']['date'] is None \
- or len(md.identification.keywords[0]['thesaurus']['date']) < 1:
- result["errors"].append("gmd:thesaurusName: Thesaurus date is 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
+ errors += 1
if md.identification.extent is None:
result["errors"].append("gmd:EX_Extent: Extent element is missing")
@@ -347,7 +356,7 @@
errors += 1
if len(md.identification.date) < 1 or (md.identification.temporalextent_start is (
- None or '') or md.identification.temporalextent_end is (None or '')):
+ 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
@@ -402,17 +411,17 @@
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].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].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 md.contact[0].role is (None or ''):
+ result["errors"].append("gmd:role: Role is missing")
+ errors += 1
if errors > 0:
result["status"] = "failed"
@@ -421,10 +430,9 @@
return result
-
class MD_DataIdentification_MOD(MD_DataIdentification):
- def __init__(self,md=None,identtype=None):
- MD_DataIdentification.__init__(self,md,identtype)
+ def __init__(self, md=None, identtype=None):
+ MD_DataIdentification.__init__(self, md, identtype)
if md is None:
self.timeUnit = None
self.temporalType = None
@@ -440,24 +448,34 @@
extents.extend(md.findall(util.nspath_eval('srv:extent', namespaces)))
for extent in extents:
if val2 is None:
- val2 = extent.find(util.nspath_eval('gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TM_PeriodDuration/gml:duration', namespaces))#TODO
+ val2 = extent.find(util.nspath_eval(
+ 'gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TM_PeriodDuration/gml:duration',
+ namespaces)) # TODO
self.temporalType = util.testXMLValue(val2)
if val1 is None:
- val1 = extent.find(util.nspath_eval('gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:timeLength/gml:timeInterval/gml:unit/gml:TimeUnitType', namespaces))
+ val1 = extent.find(util.nspath_eval(
+ 'gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:timeLength/gml:timeInterval/gml:unit/gml:TimeUnitType',
+ namespaces))
self.timeUnit = util.testXMLValue(val1)
if val3 is None:
- val3 = extent.find(util.nspath_eval('gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:timeLength/gml:timeInterval/gml:radix/gco:positiveInteger', namespaces))
+ val3 = extent.find(util.nspath_eval(
+ 'gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:timeLength/gml:timeInterval/gml:radix/gco:positiveInteger',
+ namespaces))
self.radixT = util.testXMLValue(val3)
if val4 is None:
- val4 = extent.find(util.nspath_eval('gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:timeLength/gml:timeInterval/gml:factor/gco:Integer', namespaces))
+ val4 = extent.find(util.nspath_eval(
+ 'gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:timeLength/gml:timeInterval/gml:factor/gco:Integer',
+ namespaces))
self.factor = util.testXMLValue(val4)
+
class MD_MetadataMOD(MD_Metadata):
""" Process gmd:MD_Metadata """
+
def __init__(self, md=None):
- MD_Metadata.__init__(self,md)
+ MD_Metadata.__init__(self, md)
if md is not None:
val = md.find(util.nspath_eval('gmd:identificationInfo/gmd:MD_DataIdentification', namespaces))
val2 = md.find(util.nspath_eval('gmd:identificationInfo/srv:SV_ServiceIdentification', namespaces))
More information about the grass-commit
mailing list