[GRASS-SVN] r61371 - sandbox/krejcmat/src

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 23 06:00:27 PDT 2014


Author: krejcmat
Date: 2014-07-23 06:00:27 -0700 (Wed, 23 Jul 2014)
New Revision: 61371

Modified:
   sandbox/krejcmat/src/editor3.py
   sandbox/krejcmat/src/g.gui.metadata.py
   sandbox/krejcmat/src/jinjainfo.py
   sandbox/krejcmat/src/mdgrass.py
   sandbox/krejcmat/src/r.info.iso.py
   sandbox/krejcmat/src/v.info.iso.py
Log:
all update

Modified: sandbox/krejcmat/src/editor3.py
===================================================================
--- sandbox/krejcmat/src/editor3.py	2014-07-23 11:50:19 UTC (rev 61370)
+++ sandbox/krejcmat/src/editor3.py	2014-07-23 13:00:27 UTC (rev 61371)
@@ -1,344 +1,616 @@
-import wx 
+import wx
 from wx import ID_ANY
 from wx import EVT_BUTTON
 import wx.lib.scrolledpanel as scrolled
+#import wx.adv
 
 from owslib.iso import *
-from jinjainfo  import JinjaTemplateInfo as jt
+from jinjainfo import JinjaTemplateInfo as jt
 from jinja2 import Environment, FileSystemLoader
 
+
 from lxml import etree as ET
 import contextlib
 from wxPython._core import wxBoxSizer
 
 import copy
-import re     
-import os  
+import re
+import os
+import string
 
-#===============================================================================
-# MD blah blah                   
-#===============================================================================
-class MD():
+
+#=========================================================================
+# MD blah blah
+#=========================================================================
+class MdFileWork():
+
     def __init__(self, pathToXml=None):
-
         self.path = pathToXml
         self.owslibInfo = None
         # self.readXML()
- 
-    def initMD(self, path=None):        
-        if path == None:
+
+    def initMD(self, path=None):
+        if path is None:
             self.md = MD_Metadata(md=None)
-            return  self.md
+            return self.md
         else:
             tree = ET.parse(path)
             root = tree.getroot()
             self.md = MD_Metadata(root)
             return self.md
-        #  
-        
-    def saveToXML(self, md, path=None, xml_out_name=None):
+
+    def saveToXML(self, md, jinjaPath, outPath=None, xmlOutName=None):
                 # if  output file name is None, use map name and add postfix
-        self.dirpath = os.path.dirname(os.path.realpath(__file__))        
+        self.dirpath = os.path.dirname(os.path.realpath(__file__))
         self.md = md
-        self.template = 'data/grassInspireTemplate01.xml'
-        if xml_out_name is None:
-            xml_out_name = 'testExportMD' 
-        if not xml_out_name.lower().endswith('.xml'):
-            xml_out_name += '.xml'
+        jinjaPath
+        if xmlOutName is None:
+            xmlOutName = 'testExportMD'  # TODO change to name of map
+        if not xmlOutName.lower().endswith('.xml'):
+            xmlOutName += '.xml'
         # if path is None, use lunch. dir
         # TODO change default folder to mapset location
-        if not path:
-            path = os.path.join(self.dirpath, xml_out_name)
+        if not outPath:
+            outPath = os.path.join(self.dirpath, xmlOutName)
         else:
-            path = os.path.join(path, xml_out_name)
+            outPath = os.path.join(outPath, xmlOutName)
 
         # generate xml using jinja tempaltes
-        env = Environment(loader=FileSystemLoader(self.dirpath))
+        head, tail = os.path.split(jinjaPath)
+        env = Environment(loader=FileSystemLoader(head))
         env.globals.update(zip=zip)
-        template = env.get_template(self.template)
+        template = env.get_template(tail)
         iso_xml = template.render(md=self.md)
-        xml_file = xml_out_name
-        
+        xml_file = xmlOutName
+
         # write xml to flat file
         try:
-            xml_file = open(path, "w")
+            xml_file = open(outPath, "w")
             xml_file.write(iso_xml)
             xml_file.close()
-            print 'metadata exported: \n%s' % (str(path))
-                                         
+            print 'metadata exported: \n%s' % (str(outPath))
+
         except IOError as e:
             print "I/O error({0}): {1}".format(e.errno, e.strerror)
             grass.fatal('error: cannot write xml file')
-        return  path
+        return outPath
 
-#===============================================================================
+#=========================================================================
 # CREATE BOX (staticbox+button(optional)
-#===============================================================================
-class Box(wx.Panel):
+#=========================================================================
+
+
+class MdBox(wx.Panel):
+
     def __init__(self, parent, label='label'):
-        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY) 
-
-        self.mdItems = []
-        self.stbox = wx.StaticBox(self, label=label, id=ID_ANY, style=wx.RAISED_BORDER)
+        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.SetForegroundColour((0, 0, 0))
         self.stbox.SetBackgroundColour((200, 200, 200))
         self.stbox.SetFont(wx.Font(12, wx.NORMAL, wx.NORMAL, wx.NORMAL))
 
-    def addItems(self, items, multi=True):
+    def addItems(self, items, multi=None, rmMulti=False, isFirstNum=-1):
+        if isFirstNum != 1:
+            multi = False
+            rmMulti = True
+
+        # if not initialize in jinja template (default is true)
+        if multi is None:
+            multi = True
+
         self.panelSizer = wx.BoxSizer(wx.VERTICAL)
         self.SetSizer(self.panelSizer)
-        
+
         self.boxButtonSizer = wx.BoxSizer(wx.HORIZONTAL)
-        
-        self.panelSizer.AddSpacer(10 , 10, 1, wx.EXPAND) 
+
+        self.panelSizer.AddSpacer(10, 10, 1, wx.EXPAND)
         self.panelSizer.Add(self.boxButtonSizer, flag=wx.EXPAND, proportion=1)
         self.stBoxSizer = wx.StaticBoxSizer(self.stbox, orient=wx.VERTICAL)
         self.boxButtonSizer.Add(self.stBoxSizer, flag=wx.EXPAND, proportion=1)
-        self.stBoxSizer.AddSpacer(5 , 5, 1, wx.EXPAND)
-        
+
         for item in items:
-                self.mdItems.append(item)
-                self.stBoxSizer.Add(item, flag=wx.EXPAND, proportion=1)
-                self.stBoxSizer.AddSpacer(5 , 5, 1, wx.EXPAND)         
+            self.mdItems.append(item)
+            self.stBoxSizer.Add(item, flag=wx.EXPAND, proportion=1)
+            self.stBoxSizer.AddSpacer(5, 5, 1, wx.EXPAND)
 
         if multi:
-            self.addBoxButt = wx.Button(self, id=ID_ANY, size=(20, 20), 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)   
-    
-    
-    def duplicateBox(self, evt):
-        mdDescription = []
+
+            self.addBoxButt.Bind(EVT_BUTTON, self.duplicateBox)
+
+        if rmMulti:
+            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.stBoxSizer.Add(item, flag=wx.EXPAND, proportion=1)
+        self.stBoxSizer.AddSpacer(5, 5, 1, wx.EXPAND)
+        # self.SetSizerAndFit(self.stBoxSizer)
+
+        # 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:
-            mdDescription.append(item.itemObject)
-        
-        child = self.stbox.GetChildren()
-        self.GetParent().addItemMulti(copy.copy(self), child)
-        # self.GetParent().GetParent().GetParent().test(mdDescription)
+            # remove from MdDescritpion()
+            item.mdDescription.removeMdItem(item)
+        self.GetParent().removeBox(self)
 
-        
-    def addItem(self, item):
-        pass
+    def removeMdItem(self, mdDes, items):
+        mdDes.mdDescription.removeMdItem(mdDes)
+        for item in items:
+            item.Destroy()
+        # self.SetSizerAndFit(self.panelSizer)
+        # self.SetSizerAndFit(self.stBoxSizer)
 
-#===============================================================================
+    def duplicateBox(self, evt):
+        parent = self.GetParent()
+        duplicator = MdWxDuplicator(self.mdItems, parent, self.label)
+        clonedBox = duplicator.mdBox
+        self.GetParent().addDuplicatedItem(clonedBox, self.GetId())
+
+
+class MdWxDuplicator():
+
+    def __init__(self, mdItems, parent, boxlabel=None, mdItemOld=None):
+        if boxlabel:
+            itemList = list()
+            self.mdBox = MdBox(parent, boxlabel)
+            for i in mdItems:
+
+                i = i.mdDescription
+                mdItem1 = MdItem(self.mdBox, i)
+                # mdItem1.setValue('')
+                itemList.append(mdItem1)
+                i.addMdItem(mdItem1)
+                # print i.mdItem
+            self.mdBox.addItems(itemList, False, True)
+
+        else:
+            self.mdItem = MdItem(parent, mdItems, False, True)
+            if mdItems.inbox is not None:
+                print 'here------------1'
+                mdItems.addMdItem(self.mdItem, mdItemOld)
+            else:
+                mdItems.addMdItem(self.mdItem)
+
+#=========================================================================
+# VALIDATOR
+#=========================================================================
+
+
+class MyValidator(wx.PyValidator):
+
+    def __init__(self, flag=None, pyVar=None):
+        wx.PyValidator.__init__(self)
+        self.flag = flag
+        #self.Bind(wx.EVT_CHAR, self.OnChar)
+
+    def Clone(self):
+        return MyValidator(self.flag)
+
+    def Validate(self, win):
+        tc = self.GetWindow()
+        val = tc.GetValue()
+        textCtrl = self.GetWindow()
+        if self.flag == 'ALPHA_ONLY':
+            for x in val:
+                if x not in string.letters:
+                    textCtrl.SetBackgroundColour("pink")
+                    textCtrl.SetFocus()
+                    textCtrl.Refresh()
+                    return False
+
+        elif self.flag == 'DIGIT_ONLY':
+            for x in val:
+                if x not in string.digits:
+                    textCtrl.SetBackgroundColour("pink")
+                    textCtrl.SetFocus()
+                    textCtrl.Refresh()
+                    return False
+        return True
+
+    def OnChar(self, event):
+        key = event.GetKeyCode()
+
+        if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255:
+            event.Skip()
+            return
+
+        if self.flag == 'ALPHA_ONLY' and chr(key) in string.letters:
+            event.Skip()
+            return
+
+        if self.flag == 'DIGIT_ONLY' and chr(key) in string.digits:
+            event.Skip()
+            return
+
+        if not wx.Validator_IsSilent():
+            wx.Bell()
+
+        # Returning without calling even.Skip eats the event before it
+        # gets to the text control
+        return
+
+#=========================================================================
 # ADD METADATA ITEM (label+ctrlText+button(optional)
-#===============================================================================
+#=========================================================================
+
+
 class MdItem(wx.BoxSizer):
-    def __init__(self, parent, item):
-        wx.BoxSizer.__init__(self, wx.VERTICAL)    
-        self.itemObject = item
-        self.multiple = item.multiplicity
-        # info=self.createInfo(item)  
-        # print item.name
-        # print item.tag
+
+    def __init__(self,parent,item,multiplicity=None,rmMulti=False,isFirstNum=-1):
+        wx.BoxSizer.__init__(self, wx.VERTICAL)
+        self.mdDescription = item
+        #======================================================================
+        # print self.mdDescription
+        # print self.mdDescription.tag
+        # print self.mdDescription.name
+        # print self.mdDescription.mdItem
+        # print '-----'
+        #======================================================================
+
+        if multiplicity is None:
+            self.multiple = item.multiplicity
+
+        if isFirstNum != 1:
+            self.multiple = False
+
+        if isFirstNum != 1 and item.multiplicity:
+            rmMulti = True
+
         self.tagText = wx.StaticText(parent=parent, id=ID_ANY, label=item.name)
-        
+
         if item.multiline is True:
             self.valueCtrl = wx.TextCtrl(parent, id=ID_ANY, size=(0, 55),
-                       style=wx.VSCROLL | 
-                       wx.TE_MULTILINE | wx.TE_NO_VSCROLL | 
-                       wx.TAB_TRAVERSAL | wx.RAISED_BORDER | wx.HSCROLL)       
+                                         # validator=MyValidator('ALPHA_ONLY'),
+                                         style=wx.VSCROLL |
+                                         wx.TE_MULTILINE | wx.TE_NO_VSCROLL | wx.TE_BESTWRAP |
+                                         wx.TAB_TRAVERSAL | wx.RAISED_BORDER | wx.HSCROLL)
         else:
-            
+
             self.valueCtrl = wx.TextCtrl(parent, id=wx.ID_ANY,
-                       style=wx.VSCROLL | wx.TE_DONTWRAP | 
-                       wx.TAB_TRAVERSAL | wx.RAISED_BORDER | wx.HSCROLL)  
+                                         # validator=MyValidator('ALPHA_ONLY'),
+                                         style=wx.VSCROLL | wx.TE_DONTWRAP |
+                                         wx.TAB_TRAVERSAL | wx.RAISED_BORDER | wx.HSCROLL)
 
+        self.valueCtrl.Bind(wx.EVT_MOTION, self.onMove)
+        self.valueCtrl.SetExtraStyle(wx.WS_EX_VALIDATE_RECURSIVELY)
+
         if self.multiple:
-            self.addItemButt = wx.Button(parent, -1, size=(20, 20), label='+')
-            # self.addInfoButt=wx.Button(self,-1,size=(20,20),label='I')
-            # BINDS    
-            
-        self._addItemLay(item.multiline)
-    
+            self.addItemButt = wx.Button(parent, -1, size=(30, 30), label='+')
+            self.addItemButt.Bind(EVT_BUTTON, self.duplicateItem)
+
+        if rmMulti:
+            self.rmItemButt = wx.Button(parent, -1, size=(30, 30), label='-')
+            self.rmItemButt.Bind(EVT_BUTTON, self.removeItem)
+
+        self.createInfo()
+        self.tip = wx.ToolTip(self.infoTip)
+        self._addItemLay(item.multiline, rmMulti)
+
+    def onMove(self, evt=None):
+        self.valueCtrl.SetToolTip(self.tip)
+
+    def createInfo(self):
+        string = ''
+        if self.mdDescription.name is not None:
+            string += 'name: ' + self.mdDescription.name + '\n'
+        if self.mdDescription.desc is not None:
+            string += 'description: ' + self.mdDescription.desc + '\n'
+        if self.mdDescription.example is not None:
+            string += 'example: ' + self.mdDescription.example + '\n'
+
+        self.infoTip = string
+
+    def removeItem(self, evt):
+        # remove widgets from
+        list = [self.valueCtrl, self.tagText]
+        try:
+            list.append(self.rmItemButt)
+        except:
+            pass
+
+        self.valueCtrl.GetParent().removeMdItem(self, list)
+
+    def duplicateItem(self, evt):
+        '''add Md item to parent(box or notebook page)
+        '''
+        parent = self.valueCtrl.GetParent()
+        # if parent box
+        if self.mdDescription.inbox:
+            duplicator = MdWxDuplicator(
+                mdItems=self.mdDescription,
+                parent=parent,
+                mdItemOld=self)
+        else:
+            duplicator = MdWxDuplicator(self.mdDescription, parent)
+
+        clonedMdItem = duplicator.mdItem
+        # call parent "add" function
+        self.valueCtrl.GetParent().addDuplicatedItem(
+            clonedMdItem,
+            self.valueCtrl.GetId())
+
     def setValue(self, value):
         self.valueCtrl.SetValue(value)
-        
+
     def getValue(self):
         return self.valueCtrl.GetValue()
-        
+
     def getCtrlID(self):
         return self.valueCtrl.GetId()
-    
-    def getButtonID(self):  
+
+    def getButtonID(self):
         if self.multiple:
             return self.addItemButt.GetId()
         else:
             return None
-                 
-    def _addItemLay(self, multiline): 
 
+    def _addItemLay(self, multiline, rmMulti):
+
         if multiline is True:
-            self.textFieldSizer = wx.BoxSizer(wx.HORIZONTAL)  
-            self.textFieldSizer.Add(self.valueCtrl, proportion=1, flag=wx.EXPAND)
+            self.textFieldSizer = wx.BoxSizer(wx.HORIZONTAL)
+            self.textFieldSizer.Add(
+                self.valueCtrl,
+                proportion=1,
+                flag=wx.EXPAND)
             if self.multiple:
                 self.textFieldSizer.Add(self.addItemButt, 0)
+            if rmMulti:
+                self.textFieldSizer.Add(self.rmItemButt, 0)
             self.Add(item=self.tagText, proportion=0)
             self.Add(item=self.textFieldSizer, proportion=0, flag=wx.EXPAND)
+
         else:
-            self.textFieldSizer = wx.BoxSizer(wx.HORIZONTAL)  
+            self.textFieldSizer = wx.BoxSizer(wx.HORIZONTAL)
             self.textFieldSizer.Add(self.valueCtrl, proportion=1)
             if self.multiple:
                 self.textFieldSizer.Add(self.addItemButt, 0)
+            if rmMulti:
+                self.textFieldSizer.Add(self.rmItemButt, 0)
             self.Add(item=self.tagText, proportion=0)
             self.Add(item=self.textFieldSizer, proportion=0, flag=wx.EXPAND)
-            
-    def Refresh(self):
-        self.valueCtrl.Refresh()
-        self.tagText.Refresh()
-                
-#===============================================================================
+
+
+#=========================================================================
 # ADD NOTEBOOK PAGE
-#===============================================================================
-class NotebookPage(scrolled.ScrolledPanel):
+#=========================================================================
+class MdNotebookPage(scrolled.ScrolledPanel):
+
     def __init__(self, parent):
-            scrolled.ScrolledPanel.__init__(self, parent=parent, id=wx.ID_ANY)
-            self.items = []
-            self.SetupScrolling()       
-            self._addNotebookPageLay()
-    
-    def _addNotebookPageLay(self):   
+        scrolled.ScrolledPanel.__init__(self, parent=parent, id=wx.ID_ANY)
+        self.items = []
+        self.SetupScrolling()
+        self._addNotebookPageLay()
+        self.sizerIndexDict = {}
+        self.sizerIndex = 0
+
+    def _addNotebookPageLay(self):
         self.mainSizer = wx.BoxSizer(wx.VERTICAL)
         self.SetSizer(self.mainSizer)
-            
+
+    def _getIndex(self):
+
+        self.sizerIndex += 1
+        return self.sizerIndex
+
     def addItem(self, item):
+
         if isinstance(item, list):
             for i in item:
-                 self.items.append(i)
-                 self.mainSizer.Add(i, proportion=0, flag=wx.EXPAND)
+                self.sizerIndexDict[i.GetId()] = self._getIndex()
+
+                # self.items.append(i)
+                self.mainSizer.Add(i, proportion=0, flag=wx.EXPAND)
         else:
-            self.items.append(item)
+            # self.items.append(item)
+            # print item.getCtrlID()
+            self.sizerIndexDict[item.getCtrlID()] = self._getIndex()
             self.mainSizer.Add(item, proportion=0, flag=wx.EXPAND)
-    
-        
-    def addItemMulti(self, item, child):
+
+    def addDuplicatedItem(self, item, id):
         self.items.append(item)
-        
-        for ch in child:
-            print ch
-            ch.Destroy()
-             
-        # self.mainSizer.Destroy()
-        # self._addNotebookPageLay()    
-        itemsTMP = []   
-        for item1 in self.items:
-            i = copy.copy(item1)
-            i.Refresh()
-            itemsTMP.append(i)
-            
-            print item1
-            # addBoxButt=wx.Button(self,id=ID_ANY,size=(20,20),label='+')
-            self.mainSizer.Add(i, proportion=0, flag=wx.EXPAND)  
-                               
-        self.items = []
-        self.items = itemsTMP
+        posIndex = self.sizerIndexDict[id]
+        # print posIndex
+        self.mainSizer.Insert(posIndex, item, proportion=0, flag=wx.EXPAND)
+
         self.SetSizerAndFit(self.mainSizer)
-        # self.Layout()
-        # self.Fit()
-        # self.GetParent().GetParent()
+        self.GetParent().Refresh()
 
-#===============================================================================
-# MAIN FRAME            
-#===============================================================================
-class MainFrame(wx.Frame):
-    def __init__(self):
-        wx.Frame.__init__(self, None, title="Metadata Editor",
-                  size=(500 , 500))
-        
-        mdo = MD()
-        self.md = mdo.initMD('INStest.xml')
+    def removeBox(self, box):
+        box.Destroy()
+        self.SetSizerAndFit(self.mainSizer)
 
-        self.templatePath = 'data/grassInspireTemplate01.xml'
+    def removeMdItem(self, mdDes, items):
+        mdDes.mdDescription.removeMdItem(mdDes)
+        for item in items:
+            item.Destroy()
+        self.SetSizerAndFit(self.mainSizer)
+
+    def getPositionInSizer(self):
+        """ Returns the current position of this control in its containing
+         sizer. This is useful for when a control needs to be re-created in
+         place.
+         If the containing sizer is a box sizer, the integer position will
+         be returned. If it is a grid sizer, a row,col tuple will be returned.
+         If the object is not contained in a sizer, None will be returned.
+        """
+        sz = self.GetContainingSizer()
+        if not sz:
+            return None
+        if isinstance(sz, wx.BoxSizer):
+            chil = sz.GetChildren()
+            for pos in range(len(chil)):
+               # Yeah, normally we'd just iterate over the children, but
+               # we want the position, so...
+                szitem = chil[pos]
+                if szitem.IsWindow():
+                    if szitem.GetWindow() == self:
+                        return pos
+          # If we reached here, something's wrong!
+            dabo.errorLog.write(_("Containing sizer did not match item %s")
+                                % self.Name)
+            return None
+        elif isinstance(sz, wx.GridBagSizer):
+            # Return a row,col tuple
+            row, col = sz.GetItemPosition(self)
+            eturn(row, col)
+        else:
+            return None
+#=========================================================================
+# MAIN FRAME
+#=========================================================================
+
+
+class MdMainFrame(wx.Panel):
+
+    def __init__(self, parent, templpatePath, mdISOXML):
+        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
+        # self.SetMinSize(500,500)
+
+        self.mdo = MdFileWork()
+        self.md = self.mdo.initMD(mdISOXML)
+
+        self.templatePath = templpatePath
         # self.templatePath='data/jinjatest.xml'
-        
-        jinj = jt(self.templatePath)
-        self.mdDescription = jinj.mdDescription  # list of object MdDescription
-        self.mdOWSTagStr = jinj.mdOWSTagStr  # string of tags from jinja template (loops and OWSLib objects)   
-        self.mdOWSTagStrList = jinj.mdOWSTagStrList  #
-        
-        self.initCreatorMD()
+
+        self.jinj = jt(self.templatePath)
+        # list of object MdDescription
+        self.mdDescription = self.jinj.mdDescription
+        # string of tags from jinja template (loops and OWSLib objects)
+        self.mdOWSTagStr = self.jinj.mdOWSTagStr
+        self.mdOWSTagStrList = self.jinj.mdOWSTagStrList  #
+
+        self.generateGUI()
         self._layout()
-        
+
 #----------------------------------------------------------- GUI GENERATOR START
     def executeStr(self, stri, linfo):
         print stri
         exec stri
 
-    def plusC(self):
-        self.c += 1
+    def plusC(self, num=None):
+        if num is None:
+            num = 1
+        self.c += num
         if self.c >= self.max:
             self.c -= 1
-            self.stop = True    
-            
-                                       
-    def initCreatorMD(self):  
+            self.stop = True
+
+    def minusC(self, num=None):
+        if num is None:
+            num = 1
+        self.c -= num
+        if self.c <= self.max:
+            self.stop = False
+
+    def generateGUI(self):
         '''
         @var var:    self.c:        index of lstruct and self.mdDescription
                     lstruct:        lstruct is self.mdOWSTagStr in list. \
                                     Item=line from jinja template(only lines\
                                     with owslib objects and loops)
                     linfo:          list of MdDescription() objects inicialized\
-                                    by information from jinja t.                        
+                                    by information from jinja t.
                     markgroup:      markers of created list in GUI notebook
                     self.max:       length of lstruct and linfo
                     self.stop:      index self.c is increasing  by function plusC(),\
                                     that care about  not exceeding the index
-        '''         
+        '''
         def prepareStatements():
             '''
-            @note: 
+            @note:
             '''
             for c in range(self.max):
                 if '|length' in str(lstruct[c]):
-                     a = lstruct[c]
-                     a = a.replace('|length', ')').replace('if ', 'if len(self.')
-                     lstruct[c] = a
-                     
+                    a = lstruct[c]
+                    a = a.replace(
+                        '|length',
+                        ')').replace(
+                        'if ',
+                        'if len(self.')
+                    lstruct[c] = a
+
                 if 'zip(' in lstruct[c]:
-                    sta = lstruct[c ]
+                    sta = lstruct[c]
                     lstruct[c] = sta.replace('md.', 'self.md.')
-                    
-        def inBlock():  #function in def initCreatorMD(self):   !!!
+
+        def inBlock():  # function in def initCreatorMD(self):   !!!
             '''
-            @note: 
+            @note:
             '''
             IFStatements = False
             statements = lstruct[self.c - 1]
             if 'if' in statements.split():
-               IFStatements = True
+                IFStatements = True
 
-            str2 = statements.replace(' md.', ' self.md.')
-            looptmp = str2
+            str2 = 'numOfSameBox=0\n'
+            str2 += statements.replace(' md.', ' self.md.')
+            looptmp = statements.replace(' md.', ' self.md.')
             str2 += ':\n'
-            str2 += '\t' + 'self.ItemList=[]\n'  # initialize list
-            
+            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=Box(self.nbPage,linfo[' + str(self.c) + '].inbox)\n'  # add box
+                str2 += '\t' + \
+                    'box=MdBox(self.nbPage,linfo[' + str(self.c) + '].inbox)\n'  # add box
             str1 = str2
 
             while '\t' in lstruct[self.c] and self.stop is False:
                 if  'for' not in str(lstruct[self.c]).split()\
-                    and 'if' not in str(lstruct[self.c]).split():
+                        and 'if' not in str(lstruct[self.c]).split():
                     value = str(self.mdOWSTagStrList[self.c])
-                    str1 += '\t' + 'self.mdDescription[' + str(self.c) + '].addStatements("' + looptmp + '")\n'
+                    str1 += '\t' + \
+                        'self.mdDescription[' + str(self.c) + '].addStatements("' + looptmp + '")\n'
                     str1 += '\t' + 'self.cTmp=' + str(self.c) + '\n'
-                    
+
                     if box:
-                        str1 += '\t' + 'it=MdItem(box,linfo[' + str(self.c) + '])\n'
+                        str1 += '\t' + \
+                            'it=MdItem(parent=box,item=linfo[' + str(self.c) + '],isFirstNum=numOfSameBox)\n'
                     else:
-                        str1 += '\t' + 'it=MdItem(self.nbPage,linfo[' + str(self.c) + '])\n' 
-                         
-                    if IFStatements:   
+                        str1 += '\t' + \
+                            'it=MdItem(parent=self.nbPage,item=linfo[' + str(self.c) + '],isFirstNum=numOfSameBox)\n'
+
+                    if IFStatements:
                         str1 += '\t' + 'it.setValue(self.' + str(value) + ')\n'
-                    else: 
-                        str1 += '\t' + 'it.setValue(' + str(value) + ')\n'       
-                        
-                    str1 += '\t' + 'self.mdDescription[' + str(self.c) + '].addMdItem(it)\n'                                     
+                    else:
+                        str1 += '\t' + 'it.setValue(' + str(value) + ')\n'
+
+                    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
                     statements = lstruct[self.c]
@@ -347,144 +619,164 @@
                     if '["keywords"]' in statements:
                         keyword = True
                         str2 += '\t' + 'self.keywordsList=[]\n'
-                        
-                    str2 += statements.replace(' md.', ' self.md.')
+
+                    str2 += '\t' + 'numOfSameItem=0\n'
                     looptmp1 = statements.replace(' md.', ' self.md.')
-                    str2 += ':\n'
+                    str2 += looptmp1 + ':\n'
                     self.plusC()
                     str1 += str2
                     while '\t\t' in lstruct[self.c] and self.stop is False:
-                        
+
                         value = str(self.mdOWSTagStrList[self.c])
                         # save information about loops
-                        str1 += '\t\t' + 'self.mdDescription[' + str(self.c) + "].addStatements('" + looptmp + "')\n"
-                        str1 += '\t\t' + 'self.mdDescription[' + str(self.c) + "].addStatements1('" + looptmp1 + "')\n" 
-                        str1 += '\t\t' + 'self.cTmp=' + str(self.c) + '\n'  # save wx id
-                        
+                        str1 += '\t\t' + 'numOfSameItem+=1\n'
+                        str1 += '\t\t' + \
+                            'self.mdDescription[' + str(self.c) + "].addStatements('" + looptmp + "')\n"
+                        str1 += '\t\t' + \
+                            'self.mdDescription[' + str(self.c) + "].addStatements1('" + looptmp1 + "')\n"
+                        str1 += '\t\t' + 'self.cTmp=' + \
+                            str(self.c) + '\n'  # save wx id
+
                         if box:
-                            str1 += '\t\t' + 'it=MdItem(box,linfo[' + str(self.c) + '])\n'
+                            str1 += '\t\t' + \
+                                'it=MdItem(parent=box,item=linfo[' + str(self.c) + '],isFirstNum=numOfSameItem)\n'
                         else:
-                            str1 += '\t\t' + 'it=MdItem(self.nbPage,linfo[' + str(self.c) + '])\n'
-                            
-                        str1 += '\t\t' + 'it.setValue(' + str(value) + ')\n'  
+                            str1 += '\t\t' + \
+                                'it=MdItem(self.nbPage,linfo[' + str(self.c) + '],isFirstNum=numOfSameItem)\n'
+
+                        str1 += '\t\t' + 'it.setValue(' + str(value) + ')\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' + \
+                                '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() 
+                        tab = '\t\t'
+                        self.plusC()
 
-            self.c -= 1 
-            
+            self.c -= 1
+            print '-' * 80
+            print linfo[self.c].inboxmulti
             if box:
-                str1 += tab + 'box.addItems(self.ItemList)\n'
-                str1 += tab + 'self.nbPage.addItem(box)\n'   
-            else:        
-                str1 += tab + 'self.nbPage.addItem(self.ItemList)\n'  
-                 
+                str1 += tab + \
+                    'box.addItems(items=self.ItemList,multi=linfo[self.c].inboxmulti,isFirstNum=numOfSameBox)\n'
+                str1 += tab + 'self.nbPage.addItem(box)\n'
+            else:
+                str1 += tab + 'self.nbPage.addItem(self.ItemList)\n'
+
             str1 += tab + 'self.plusC()\n'
             self.executeStr(str1, linfo)
-            
+
 #--------------------------------------------------------------------- INIT VARS
         self.notebook = wx.Notebook(self)
         markgroup = []  # notebok panel marker
-        lstruct = self.mdOWSTagStrList   
-        linfo = self.mdDescription  # from jinja      
-        self.c = 0  # this valus is the index of self.mdOWSTagStrList and also in self.mdDescription
+        lstruct = self.mdOWSTagStrList
+        linfo = self.mdDescription  # from jinja
+        # this valus is the index of self.mdOWSTagStrList and also in
+        # self.mdDescription
+        self.c = 0
         self.stop = False
-        self.max = len(linfo)      
+        self.max = len(linfo)
         prepareStatements()
-#--------------------------------------------- #START of the looop of genereator        
+# --------------------------------------------- #START of the looop of genereator
         while self.stop is False:  # self.stop is managed by   def plusC(self):
             group = linfo[self.c].group
-    
+
             if group not in markgroup:  # if group is not created
                 markgroup.append(group)  # mark group
-                self.nbPage = NotebookPage(self.notebook)
+                self.nbPage = MdNotebookPage(self.notebook)
                 self.notebook.AddPage(self.nbPage, linfo[self.c].group)
 
-            if '\t' in lstruct[self.c]and self.stop is False:  # if starting the statements
-                    inBlock()                
-                    
-            elif   'for' not in str(lstruct[self.c]).split()\
-                    and 'if' not in str(lstruct[self.c]).split():  # if just singe item without statements
-                    
-                    self.cTmp = self.c       
-                    it = MdItem(self.nbPage, linfo[self.c])
-                    value = 'self.' + str(self.mdOWSTagStrList[self.c]).replace('\n', '')
-                    it.setValue(eval(value))
-                    
-                    self.mdDescription[self.c].addMdItem(it)
-                    self.nbPage.addItem(it)  
-                    self.plusC()
+            # if starting the statements
+            if '\t' in lstruct[self.c]and self.stop is False:
+                inBlock()
+
+            # if just singe item without statements
+            elif 'for' not in str(lstruct[self.c]).split() and 'if' not in str(lstruct[self.c]).split():
+
+                self.cTmp = self.c
+                it = MdItem(self.nbPage, linfo[self.c])
+                value = 'self.' + \
+                    str(self.mdOWSTagStrList[self.c]).replace('\n', '')
+                it.setValue(eval(value))
+
+                self.mdDescription[self.c].addMdItem(it)
+                self.nbPage.addItem(it)
+                self.plusC()
             else:
                 self.plusC()
-
+        self.md = MD_Metadata()
 #----------------------------------------------------------- GUI GENERATOR END
 
 #------------------------------------------------------------------------ LAYOUT
     def _layout(self):
         self.mainSizer = wx.BoxSizer(wx.VERTICAL)
         self.SetSizer(self.mainSizer)
-        
+
         noteSizer = wx.BoxSizer(wx.VERTICAL)
         self.notebook.SetSizer(noteSizer)
-        self.mainSizer.Add(self.notebook, proportion=1, flag=wx.EXPAND)  
-        but = wx.Button(self, id=ID_ANY, size=(20, 20), label='+')
-        but.Bind(EVT_BUTTON, self.createNewMD())
-        buts = wx.Button(self, id=ID_ANY, size=(20, 20), label='-')
-        buts.Bind(EVT_BUTTON, self.exportToXml)
-        self.mainSizer.Insert(0, but)
+        self.mainSizer.Add(self.notebook, proportion=1, flag=wx.EXPAND)
         self.Show()
-        
+
+    #=========================================================================
+    # def printmd(self):
+    #     for item in self.mdDescription:
+    #         print item.tag
+    #         print item.name
+    #         print item.mdItem
+    #         print '-----'
+    #=========================================================================
+
     def executeStr1(self, stri, item):
         print stri
-        exec stri         
-    
-    def exportToXml(self):
-        self.mdo.saveToXML(self.md)
-            
-    def createNewMD(self): 
+        exec stri
+
+    def exportToXml(self, jinjaPath, outPath, xmlOutName):
+        print '=' * 50
+        self.createNewMD()
+        self.mdo.saveToXML(self.md, jinjaPath, outPath, xmlOutName)
+
+    def createNewMD(self, evt=None):
+        '''Fill owslib by metadata from gui
+        '''
+        def chckEnd():
+            if (self.c + 1) == self.max:
+                self.stop = True
+
         def prepareStatements():
             '''
-            @note: 
+            @note:
             '''
             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.')
-                     mdDes[c].tag = a
+                    a = mdDes[c].tag
+                    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.')
-                     mdDes[c].statements = a 
+                    a = mdDes[c].statements
+                    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.')
-                     mdDes[c].statements1 = a                      
-                     
-                if 'zip(' in str(mdDes[c].tag):
-                    sta = str(mdDes[c ].statements)
-                    mdDes[c].tag = sta.replace('md.', 'self.md.')
-                if 'zip(' in str(mdDes[c].statements):
-                    sta = str(mdDes[c ].statements)
-                    mdDes[c].statements = sta.replace('md.', 'self.md.') 
-                if 'zip(' in str(mdDes[c].statements1):
-                    sta = str(mdDes[c ].statements1)
-                    mdDes[c].statements1 = sta.replace('md.', 'self.md.')                                                 
-        #=======================================================================
-        # def chckCondition(condition):
-        #     self.bool=False
-        #     if 'if' in condition.split():
-        #         condition+='\n\tself.bool=True'
-        #         self.executeStr1(condition, false)
-        #         return self.bool  
-        #=======================================================================
+                    a = mdDes[c].statements1
+                    a = a.replace(
+                        '|length',
+                        ')').replace(
+                        'if ',
+                        'if len(self.')
+                    mdDes[c].statements1 = a
+
         def chckIf1Statements():
             try:
                 if md[self.c + 1].statement:
@@ -493,28 +785,33 @@
                     return False
             except:
                 return False
+
         def chckIf2xStatements():
-            if 'if'in  mdDes[self.c].tag.split()  or 'for'in  mdDes[self.c].tag.split():
+            if 'if'in mdDes[
+                    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():
-                         return True
-                     else:
+                    if 'if'in  mdDes[self.c + 1].tag.split()  or\
+                            'for'in mdDes[self.c + 1].tag.split():
+                        return True
+                    else:
                         return False
                 except:
-                    return False    
-                       
+                    return False
+
         def noneStatements():
             '''Without condition or loop
             '''
             str1 = ''
             for wxCtrl in mdDes[self.c].mdItem:
                 print "item"
-                if wxCtrl.getValue() != None:
-                    str1 += 'self.' + mdDes[self.c].tag + '="' + str(wxCtrl.getValue()) + '"\n'
-                    self.executeStr1(str1, mdDes[self.c])                         
+                if wxCtrl.getValue() is not None:
+                    str1 += 'self.' + \
+                        mdDes[self.c].tag + '="' + str(wxCtrl.getValue()) + '"\n'
+                    self.executeStr1(str1, mdDes[self.c])
                     str1 = ''
-            self.plusC() 
-    
+            self.plusC()
+
         def inStatements():
             '''possible combinations of statements
             (1)    IF
@@ -524,278 +821,309 @@
             (2.1)          item (with init OWSLib object)
                        "or"
             (2.2)          item (without init)
+                            item with ZIP
             '''
             cTmp = self.c
             tag = str(mdDes[cTmp].tag).split()
-            
+
             tag1 = 'self.' + str(tag[-1])
             tag = 'self.' + str(tag[-1]) + '.append(self.val)\n'
-            print '---'
-            print mdDes[cTmp - 1].statements
-            print mdDes[cTmp - 1].tag
-            print '---'
+
             self.plusC()
             # statements of current item
             stat = mdDes[self.c].statements
 
             str1 = ''
-            # how many MdItem() is in object 
+            # 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() :
+            if mdDes[cTmp].object and 'if' not in mdDes[cTmp].tag.split():
                 print 'init'
+                # self.val=CI_ResponsibleParty()
                 objStr = 'self.val=' + mdDes[cTmp].object + '\n'
-                for n in range(leng): 
-                    numOfItems = 0       
-                    str1 += objStr       
-                     
+
+                for n in range(leng):
+                    numOfItems = 0
+                    str1 += objStr
+                    # print self.c, 'pred'
                     while mdDes[self.c].statements == stat and self.stop is False:
+                        # print 'c',self.c
+                        # if len(mdDes[self.c].mdItem)>leng:
+                            #moreLoop = len(mdDes[self.c].mdItem) - leng
+                        # mark
                         metadata = re.split(r'[.]', mdDes[self.c].tag)
                         metadata[0] = 'self.val.'
                         str1 += ''.join(metadata) + "='"\
-                             + str(mdDes[self.c].mdItem[n].getValue()) + "'\n"
+                            + str(mdDes[self.c].mdItem[n].getValue()) + "'\n"
                         self.plusC()
-                        numOfItems += 1 
-                        
+                        numOfItems += 1
+
                     str1 += tag
-                    self.executeStr1(str1, False) 
+                    self.executeStr1(str1, False)
                     str1 = ''
-                    self.c -= numOfItems
-                self.c += leng
-                
+                    self.minusC(numOfItems)
+                    # print self.c, 'po'
+                self.plusC(leng)
+
             # (2.2)
-            elif 'for' in mdDes[cTmp].tag.split() and mdDes[cTmp].object == None:
-                
+            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'
+
+                leng = len(mdDes[self.c].mdItem)
+                tag1 = self.jinj._findBetween(tag1, 'zip(', ')').split(',')
+                # print tag1
+
+                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"
+                        self.plusC()
+                        numOfItems += 1
+                    self.executeStr1(str1, False)
+                    str1 = ''
+                    self.minusC(numOfItems)
+                # print numOfItems
+                self.plusC(leng)
+
+            elif 'for' in mdDes[cTmp].tag.split() and mdDes[cTmp].object is None:
                 print 'no init'
                 leng = len(mdDes[self.c].mdItem)
-                for n in range(leng): 
-                    numOfItems = 0               
+                for n in range(leng):
+                    numOfItems = 0
                     while mdDes[self.c].statements == stat and self.stop is False:
-                        metadata = re.split(r'[.]', mdDes[self.c].tag)
-                        metadata[0] = 'self.val.'
-                        str1 += tag1 + ".append('" + mdDes[self.c].mdItem[n].getValue() + "')\n"
-                        #----------------------------------- !!!!!!!!!!!!!!!!!!! getval
+                        str1 += tag1 + \
+                            ".append('" + mdDes[self.c].mdItem[n].getValue() + "')\n"
                         self.plusC()
-                        numOfItems += 1 
-                    self.executeStr1(str1, False) 
+                        numOfItems += 1
+                    self.executeStr1(str1, False)
                     str1 = ''
-                    self.c -= numOfItems
-                self.c += leng                
-            # (1)   
+                    self.minusC(numOfItems)
+                self.plusC(leng)
+            # (1)
             elif 'if' in mdDes[cTmp].tag.split():
-
                 print 'no init IF'
                 objStr = mdDes[cTmp].tag.replace(' md.', ' self.md.') + ':\n'
 
-                for n in range(leng): 
-                    numOfItems = 0       
-                    #str1 += objStr        
+                for n in range(leng):
+                    numOfItems = 0
+                    # str1 += objStr
                     while mdDes[self.c].statements == stat and self.stop is False:
-                        metadata = 'self.'+mdDes[self.c].tag
-                       
+                        metadata = 'self.' + mdDes[self.c].tag
+
                         str1 += ''.join(metadata) + "='"\
-                             + str(mdDes[self.c].mdItem[n].getValue()) + "'\n"
-                             
+                            + str(mdDes[self.c].mdItem[n].getValue()) + "'\n"
+
                         self.plusC()
                         numOfItems += 1
-                    self.c -= numOfItems
-                    self.executeStr1(str1, False) 
+                    self.minusC(numOfItems)
+                    self.executeStr1(str1, False)
                     str1 = ''
-                self.c += leng
-     
-      
-                          
+                self.plusC(leng)
+
         def in2Statements():
             '''possible combinations of statements
             (1)    IF:
                        FOR:
             (1.1)           item (with init OWSLib object)
                         "or"
-            (1.2)           item (without init)                    
+            (1.2)           item (without init)
                 ----------------------------------------------------
             (2)     FOR:
                         FOR:
             (2.1)            item (with init OWSLib object)
                         "or"
-            (2.2)            item (without init)                           
+            (2.2)            item (without init)
             '''
+
             prepareStatements()
-            cTmp = self.c 
+            cTmp = self.c
 
             cTmp1 = self.c + 1
-            tag = str(mdDes[cTmp].tag).split() 
-            tag1 = str(mdDes[cTmp1].tag).split()   
+            tag = str(mdDes[cTmp].tag).split()
+            tag1 = str(mdDes[cTmp1].tag).split()
             print '-'
             print tag
             print tag1
             stat = mdDes[self.c + 2].statements
-            # how many MdItem() is in object 
+
             append = 'self.' + str(tag1[-1]) + '.append(self.val)\n'
             appendNoInit = 'self.' + str(tag1[-1])
-             # (1)
-            if 'if' in tag and 'for' in tag1:  # if 'if' in jinja=skip and do single loop
+            # (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
                 # (1.1)
                 if mdDes[cTmp1].object:
-                    print "if and for in object"
-                    condition = mdDes[cTmp].tag.replace(' md.', ' self.md.') + ':\n'
+                    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'
+                    condition2 = '\t' + \
+                        mdDes[cTmp1].tag.replace(' md.', ' self.md.') + ':\n'
                     self.plusC()
                     self.plusC()
-                    for n in range(leng): 
-                        numOfItems = 0  
+
+                    for n in range(leng):
+                        numOfItems = 0
                         str1 = condition + '\n'
                         str1 += condition2 + '\n'
-                        str1 += '\t' + object + '\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 
-                        self.executeStr1(str1, False) 
+                            numOfItems += 1
+                        str1 += '\t\t' + append
+                        self.executeStr1(str1, False)
                         str1 = ''
-                        self.c -= numOfItems
-                    self.c += leng  
-                # (1.2)                      
+                        self.minusC(numOfItems)
+                    self.plusC(leng)
+                # (1.2)
                 else:
                     print "if and for "
-                    condition = mdDes[cTmp].tag.replace(' md.', ' self.md.') + ':\n'
-                    condition2 = mdDes[cTmp1].tag.replace(' md.', ' self.md.') + ':\n'
                     self.plusC()
                     self.plusC()
-                    print mdDes[self.c].mdItem
-                    numOfkwGroup = len(mdDes[self.c].mdItem)
-                    print numOfkwGroup
-                    for n in range(numOfkwGroup): 
-                        numOfItems = 0  
-                        str1 = condition2 + '\n'
-                        print str1
-                        #print stat
-                        #print mdDes[self.c].statements
+                    size = len(mdDes[self.c].mdItem)
+                    for n in range(size):
+                        numOfItems = 0
+                        str1 = ''
                         while mdDes[self.c].statements == stat and self.stop is False:
-                            str1 += '\t\t' + appendNoInit + '.append(' + mdDes[self.c].mdItem[n].getValue() + ')\n'
+
+                            str1 += appendNoInit + \
+                                '.append("' + mdDes[self.c].mdItem[n].getValue() + '")\n'
                             self.plusC()
-                            numOfItems += 1                                 
-                        self.executeStr1(str1, False) 
-                        str1 = ''
-                        self.c -= numOfItems-1
-                    self.c += numOfkwGroup    
-                    self.plusC()
+                            numOfItems += 1
+
+                        self.executeStr1(str1, False)
+                        self.minusC(numOfItems)
+                    self.plusC(size)  # #TODO TEST -1
             # (2) only keywords  (dict)
             elif 'for' in tag and 'for' in tag1:  #
                 print 'for-for statement'
 
-                
-                self.plusC()  # skip staementes 2x 
+                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)
-                for n in range(numOfkwGroup):   
+                for n in range(numOfkwGroup):
                     kw = {}
-                    kw['keywords'] = []   
-                    # print '---'       
+                    kw['keywords'] = []
+
+                    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[k]
-                   
-                    kw['type'] = None 
+                        kw['keywords'].append(
+                            '"' +
+                            mdDes[
+                                self.c].mdItem[n][k].getValue() +
+                            '"')
+                        print mdDes[self.c].mdItem[n][k].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()           
-                    self.md.identification.keywords.append(kw)    
+                    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()
                 self.plusC()
                 self.plusC()
-  
 
-
-        self.mdo = MD()
+        self.mdo = MdFileWork()
         # TODO define this in flat file
         self.md = self.mdo.initMD()
+        # print self.md
         self.md.identification = MD_DataIdentification()
         self.md.dataquality = DQ_DataQuality()
         self.md.distribution = MD_Distribution()
         self.md.identification.extent = EX_Extent()
         self.md.identification.extent.boundingBox = EX_GeographicBoundingBox()
-        
+
         statements = None
         subLoop = None
         initMDStr = None
-        self.c = 0                        
+        self.c = 0
         self.stop = False
-        self.max = len(self.mdDescription) 
+        self.max = len(self.mdDescription)
+
         mdDes = self.mdDescription
-        
-        while self.stop is False: 
-            
+
+        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
-                #===============================================================
+                    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()
-    
-            # if 2x statements        
-            elif  chckIf2xStatements():
+                chckEnd()
+            # 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 '2x statements'
+                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
+            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 '1x statements'
+                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               
+            # self.plusC()
+            print '==' * 50
 
-            
-#===============================================================================
-# CREATE INFO
-#===============================================================================
-class MetadataUserInfo():
-    def __init__(self, item):
-        self.item = item
-        self.createInfo()
-    
-    def createInfo(self):
-        string = ''
-        if item.name != None:
-            string += 'name: ' + item.name + '\n' 
-        if item.desc != None:
-            string += 'description: ' + item.desc + '\n'
-        if item.example != None:
-            string += 'example: ' + item.example + '\n'   
-        return string   
-    
+
 #----------------------------------------------------------------------
 if __name__ == "__main__":
     app = wx.App(False)
-    frame = MainFrame()
+    frame = MdMainFrame()
     app.MainLoop()
-     

Modified: sandbox/krejcmat/src/g.gui.metadata.py
===================================================================
--- sandbox/krejcmat/src/g.gui.metadata.py	2014-07-23 11:50:19 UTC (rev 61370)
+++ sandbox/krejcmat/src/g.gui.metadata.py	2014-07-23 13:00:27 UTC (rev 61371)
@@ -18,18 +18,29 @@
 from lxml import etree as et
 from wx.lib.splitter import MultiSplitterWindow
 import wx
-import editor
+# import wx.lib.buttons as button
+
+from wx.lib.buttons import ThemedGenBitmapTextButton as BitmapBtnTxt
+
+from editor3 import MdMainFrame as mainEditor
+
+import glob
+import os
 ########################################################################
+
+
 class MapTree(wx.Panel):
-    def __init__(self, parent):    
-        wx.Panel.__init__(self, parent)
-        
+
+    def __init__(self, parent):
+        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
+
         self.panel1 = wx.Panel(self, -1)
-        self.tree = wx.TreeCtrl(self.panel1, 1, wx.DefaultPosition, (-1, -1), wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS)
+        self.tree = wx.TreeCtrl(
+            self.panel1, 1, wx.DefaultPosition, (-1, -1), wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS)
         self.initMaps()
         self.tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, id=1)
         self._layout()
-        
+
     def _layout(self):
         hbox = wx.BoxSizer(wx.HORIZONTAL)
         vbox = wx.BoxSizer(wx.VERTICAL)
@@ -38,72 +49,87 @@
         self.panel1.SetSizer(vbox)
         self.SetSizer(hbox)
         self.Centre()
-        
+
     def OnSelChanged(self, event):
         item = event.GetItem()
         self.display.SetLabel(self.tree.GetItemText(item))
- 
+
     def initMaps(self):
-        
+
         #-------------------------------------- root = self.tree.AddRoot('Maps')
         #--------------------------- rast = self.tree.AppendItem(root, 'raster')
         #--------------------------- vect = self.tree.AppendItem(root, 'vector')
         #----------------------------- rast3d = self.tree.AppendItem(root, 'r3')
-#------------------------------------------------------------------------------ 
+        #----------------------------------------------------------------------
         #----------------------------------------------------- mapset = Mapset()
         #---------------------------------------- rast_maps=mapset.glist('rast')
         #------------------------------------------------ for rmap in rast_maps:
             #---------------------------------- self.tree.AppendItem(rast, rmap)
-#------------------------------------------------------------------------------ 
+        #----------------------------------------------------------------------
         #---------------------------------------- vect_maps=mapset.glist('vect')
         #------------------------------------------------ for vmap in vect_maps:
             #---------------------------------- self.tree.AppendItem(vect, vmap)
-            
-            
-         self.tree = wx.TreeCtrl(self.panel1, wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS)
-         root = self.tree.AddRoot('Programmer')
-         os = self.tree.AppendItem(root, 'Operating Systems')
-         self.tree.AppendItem(os, 'Linux')
-         self.tree.AppendItem(os, 'FreeBSD')
-         self.tree.AppendItem(os, 'OpenBSD')
-         self.tree.AppendItem(os, 'NetBSD') 
-             
-         self.tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, id=1)
-         self.display = wx.StaticText(self, style=wx.ALIGN_CENTRE) 
- 
-        
+
+        self.tree = wx.TreeCtrl(
+            self.panel1,
+            wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS)
+        root = self.tree.AddRoot('maps')
+        os = self.tree.AppendItem(root, 'raster')
+        self.tree.AppendItem(os, 'DTM_01')
+        self.tree.AppendItem(os, 'random')
+        self.tree.AppendItem(os, 'jezera')
+
+        os1 = self.tree.AppendItem(root, 'vector')
+        self.tree.AppendItem(os1, 'silnice')
+        self.tree.AppendItem(os1, 'reky')
+        self.tree.AppendItem(os1, 'lesy')
+
+        self.tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, id=1)
+        self.display = wx.StaticText(self, style=wx.ALIGN_CENTRE)
+
+
 class Html(wx.Panel):
+
     def __init__(self, parent):
         pass
-        
+
+
 class RandomPanel(wx.Panel):
+
     def __init__(self, parent, color):
         wx.Panel.__init__(self, parent)
         self.SetBackgroundColour(color)
 
+
 class TreeEditor(wx.TreeCtrl):
-    def __init__(self, parent):
-        wx.TreeCtrl.__init__(self, parent=parent, id=wx.ID_ANY, style=wx.TR_HAS_BUTTONS | wx.TR_EDIT_LABELS)
-        
+
+    def __init__(self, parent, xmlPath):
+        wx.TreeCtrl.__init__(
+            self,
+            parent=parent,
+            id=wx.ID_ANY,
+            style=wx.TR_HAS_BUTTONS)
+        # self.SetMinSize(500,500)
         self.parent = parent
-        self.fpath = '/home/matt/Dropbox/gsoc/gsoc2014-krejci/src/series.xml'
+        self.fpath = xmlPath
         self.xml = et.parse(self.fpath)
-        
+
         # wx.TreeCtrl(parent=self.parent,
         root = self.fillmeup()
         self.Expand(root)
 
-        self.Bind(wx.EVT_CLOSE, self.OnClose)
-        self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEdit)
+        # 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 add(parent, elem):
-            # count=0 # do not make empty field after  <appointment> or <item> etc
+            # count=0 # do not make empty field after  <appointment> or <item>
+            # etc
             for e in elem:
                 if str(e).find("<!--") != -1:  # skip comments
                     continue
@@ -117,127 +143,581 @@
                     val = tree.AppendItem(item, text)
                     tree.SetPyData(val, e)
                     # count+=1
-                
-                add(item, e) 
+
+                add(item, e)
         add(root, xml)
         return root
 
-    def OnEdit(self, evt):
-        elm = self.GetPyData(evt.Item)
-        
-        print elm 
-        if elm is not None:
-            elm.text = evt.Label
-            self.xml.write(self.fpath, encoding="UTF-8", xml_declaration=True)
-            # self.validate()
-            
-    def OnClose(self, evt):
-        self.Destroy()
-        
+    #=========================================================================
+    # def OnEdit(self, evt):
+    #     elm = self.GetPyData(evt.Item)
+    #
+    #     print evt.Label
+    #     if elm is not None:
+    #         elm.text = evt.Label
+    #         self.xml.write(self.fpath, encoding="UTF-8", xml_declaration=True)
+    # self.validate()
+    #=========================================================================
+
+    #=========================================================================
+    # def OnClose(self, evt):
+    #     self.Destroy()
+    #=========================================================================
+
     def OnRClickAllChildren(self, evt):
         if not self.IsExpanded(evt.Item):
             self.ExpandAllChildren(evt.Item)
         else:
             self.CollapseAllChildren(evt.Item)
-    
+
     #------------------------------------------------------- def printLog(self):
         #------------------------------------------------------------ print self
         #-------------------------------------------------------- if self.error:
             #------------------------------------------ print(self.error.column)
             #------------------------------------------ print(self.error.domain)
             #------------------------------------- print(self.error.domain_name)
-#------------------------------------------------------------------------------ 
+#------------------------------------------------------------------------------
             #---------------------------------------- print(self.error.filename)
             #------------------------------------------- print(self.error.level)
             #-------------------------------------- print(self.error.level_name)
             #-------------------------------------------- print(self.error.line)
-#------------------------------------------------------------------------------ 
+#------------------------------------------------------------------------------
             #----------------------------------------- print(self.error.message)
             #-------------------------------------------- print(self.error.type)
             #--------------------------------------- print(self.error.type_name)
             #-------------------------------------------- print(self.error.line)
-#------------------------------------------------------------------------------ 
+#------------------------------------------------------------------------------
     #------------------------------------------------------- def validate(self):
         #------------------------------------------- self.xsd.validate(self.xml)
         #----------------------------------------- self.log = self.xsd.error_log
         #-------------------------------------- self.error = self.log.last_error
         #------------------------------------------------------- self.printLog()
-    
 
-class Toolbar(wx.Panel): 
-        def __init__(self, parent):
-            wx.Panel.__init__(self, parent)
-            
-            self.toolbar = wx.ToolBar(self, 1, wx.DefaultPosition, (-1, -1), wx.NO_BORDER)
-            self.toolbar.AddSimpleTool(1, wx.Image('icon/create.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'New', '')
-            self.toolbar.AddSimpleTool(2, wx.Image('icon/open-trad.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Open', '')
-            self.toolbar.AddSimpleTool(3, wx.Image('icon/save-trad.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Save', '')
-            self.toolbar.AddSeparator()
-            # toolbar.AddSimpleTool(4, wx.Image('stock_exit.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Exit', '')
-            self.toolbar.Realize()
-            
 
-            self._layout(self)
-    
-            self.Bind(wx.EVT_TOOL, self.OnNew, id=1)
-            self.Bind(wx.EVT_TOOL, self.OnOpen, id=2)
-            self.Bind(wx.EVT_TOOL, self.OnSave, id=3)
-            # self.Bind(wx.EVT_TOOL, self.OnExit, id=4)
-            
-        def _layout(self):
-            vbox = wx.BoxSizer(wx.VERTICAL)
-            vbox.Add(self.toolbar, 0, border=5)
-            self.SetSizer(vbox)
-            self.Centre()
-            
-        def OnNew(self, event):
-            self.statusbar.SetStatusText('New Command')
-    
-        def OnOpen(self, event):
-            self.statusbar.SetStatusText('Open Command')
-    
-        def OnSave(self, event):
-            self.statusbar.SetStatusText('Save Command')
+class Toolbar(wx.Panel):
 
+    def __init__(self, parent):
+        wx.Panel.__init__(self, parent)
+        self.jinjaFile = None
+
+        self.toolbar = wx.ToolBar(self, 1, wx.DefaultPosition, (-1, -1),)
+
+        self.toolbar.AddSeparator()
+
+        bitmapLoad = wx.Image(
+            'icon/open-trad.png',
+            wx.BITMAP_TYPE_PNG).ConvertToBitmap()
+        self.bttLoad = BitmapBtnTxt(
+            self.toolbar, -1, bitmapLoad, "template", size=(100, -1))
+        self.toolbar.AddControl(control=self.bttLoad)
+
+        self.toolbar.AddSeparator()
+
+        bitmapSave = wx.Image(
+            'icon/save-trad.png',
+            wx.BITMAP_TYPE_PNG).ConvertToBitmap()
+        self.bttsave = BitmapBtnTxt(
+            self.toolbar, -1, bitmapSave, "export", size=(100, -1))
+        self.bttsave.Disable()
+        self.toolbar.AddControl(control=self.bttsave)
+
+        self.toolbar.AddSeparator()
+
+        self.toolbar.Realize()
+        self._layout()
+
+        self.bttLoad.Bind(wx.EVT_BUTTON, self.OnOpenTemplate)
+        self.bttsave.Bind(wx.EVT_BUTTON, self.onSaveXML)
+
+    def onSaveXML(self, evt=None):
+        dlg = wx.FileDialog(
+            self,
+            "Choose a file",
+            os.getcwd(),
+            "",
+            "*.xml",
+            wx.SAVE)
+        # if dlg.ShowModal() == wx.ID_OK:
+        self.GetParent().jinjaPath
+        self.GetParent().editor.exportToXml(
+            self.jinjaFile,
+            outPath=None,
+            xmlOutName=None)
+
+    def onChangeTemplate(self, evt):
+        self.GetParent().jinjaPath = self.jinjaFile
+        self.GetParent().refreshConfig()
+
+    def OnOpenTemplate(self, evt):
+
+        if self.jinjaFile is None:
+            dlg = wx.FileDialog(
+                self,
+                "Choose a file",
+                os.getcwd(),
+                "",
+                "*.xml",
+                wx.OPEN)
+            if dlg.ShowModal() == wx.ID_OK:
+                self.jinjaFile = dlg.GetPath()
+                self.onChangeTemplate(None)
+                self.bttsave.Enable()
+                dlg.Destroy()
+        else:
+            # if user open another template(re-initialize MainFrame)
+            dlg = wx.FileDialog(
+                self,
+                "Choose a file",
+                os.getcwd(),
+                "",
+                "*.xml",
+                wx.OPEN)
+            if dlg.ShowModal() == wx.ID_OK:
+
+                self.jinjaFile = dlg.GetPath()
+                xml = self.GetParent().xmlPath
+                x, y = self.GetParent().GetSize()
+                MainFrame(self.jinjaFile, xml, (x, y))
+
+                self.GetParent().Close(True)
+                self.GetParent().DestroyChildren()
+
+                self.onChangeTemplate(None)
+                dlg.Destroy()
+
+    def _layout(self):
+        self.mainsizer = wx.BoxSizer(wx.HORIZONTAL)
+        self.SetSizer(self.mainsizer)
+        self.mainsizer.Add(self.toolbar)
+
+    def message(self, msg, label):
+        dlg = wx.MessageDialog(
+            self,
+            msg,
+            label,
+            wx.OK | wx.CANCEL | wx.ICON_INFORMATION)
+        self.msgStatus = dlg.ShowModal()
+        dlg.Destroy()
+
+
 class NotebookRight(wx.Notebook):
-    def __init__(self, parent):        
-        wx.Notebook.__init__(self, parent=parent, id=wx.ID_ANY, style=0)
+
+    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.buttValidate.Bind(wx.EVT_BUTTON, self.validate)
+
         self.notebook_panel1 = wx.Panel(self, wx.ID_ANY)
-        self.tree = TreeEditor(self.notebook_panel1)
-        
+
+        if path is None:
+            self.tmpPanel = tempPanel(self.notebook_panel1)
+        else:
+            self.tree = TreeEditor(self.notebook_panel1, path)
+
         # second panel
         self.notebook_panel2 = wx.Panel(self, wx.ID_ANY, style=0)
 
         # self.notebook_panel1.SetSizer(sizer_2)
-        self.AddPage(self.notebook_panel1, "Tree editor")
+        self.AddPage(self.notebook_panel0, "Validator")
+        self.AddPage(self.notebook_panel1, "Tree browser")
         self.AddPage(self.notebook_panel2, "Help")
 
-        self._layout()
-        
-    def _layout(self):
+        self._layout(path)
+
+    def onActive(self):
+        pass
+
+    def validate(self, evt):
+
+        self.GetParent().GetParent().editor.createNewMD()
+        md = self.GetParent().GetParent().editor.md
+
+        print md
+        self.validator.validate_inspire(md)
+
+    def _layout(self, path):
+        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, 1, wx.EXPAND, 0)
-        
+
+        if path is None:
+            panelSizer1.Add(self.tmpPanel, flag=wx.EXPAND, proportion=1)
+        else:
+            panelSizer1.Add(self.tree, flag=wx.EXPAND, proportion=1)
+
         panelSizer2 = wx.BoxSizer(wx.VERTICAL)
         self.notebook_panel2.SetSizer(panelSizer2)
-        
+
+#=========================================================================
+# class tempPanel(wx.Panel):
+#     def __init__(self, parent):
+#         wx.Panel.__init__(self, parent)
+#         self.mainSizer = wx.BoxSizer(wx.VERTICAL)
+#         self.SetSizer(self.mainSizer)
+#         infoText=wx.StaticText(self, id=wx.ID_ANY, label='Select ISO template with using toolbar(upper) and map in catalog browser(left)')
+#         self.mainSizer.Add(infoText, proportion=1, flag=wx.EXPAND)
+#=========================================================================
+
+
 class MainFrame(wx.Frame):
 
-    def __init__(self):
+    def __init__(self, jinjaPath=None, xmlPath=None, pos=None):
         """Constructor"""
         wx.Frame.__init__(self, None, title="Metadata Editor",
-                          size=(1000, 1000))
+                          size=(1000, 1200), pos=pos)
+        # self.template
+        self.jinjaPath = jinjaPath
+        self.xmlPath = xmlPath
 
-        splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE)
-        
-        splitter.AppendWindow(MapTree(splitter))
-        splitter.AppendWindow(RandomPanel(splitter, 'gray'))
-        splitter.AppendWindow(NotebookRight(splitter))   
+        self.init()
 
+    def refreshConfig(self):
+        self.xmlPath = 'INStest.xml'
+        print self.jinjaPath, '\n', self.xmlPath
+
+        if self.jinjaPath and self.xmlPath:
+            self.editor = mainEditor(
+                self.splitter,
+                self.jinjaPath,
+                self.xmlPath)
+            self.splitter.AppendWindow(self.editor)
+            self.splitter.AppendWindow(
+                NotebookRight(
+                    self.splitter,
+                    self.xmlPath))
+
+            self.Show()
+
+    def init(self):
+
+        self.toolbar = Toolbar(self)
+        self.splitter = MultiSplitterWindow(
+            self,
+            style=wx.SP_3D | wx.SP_LIVE_UPDATE)
+
+        self.splitter.AppendWindow(MapTree(self.splitter))
+
+        if self.jinjaPath and self.xmlPath:
+            self.editor = mainEditor(
+                self.splitter,
+                self.jinjaPath,
+                self.xmlPath)
+            self.splitter.AppendWindow(self.editor)
+            self.splitter.AppendWindow(
+                NotebookRight(
+                    self.splitter,
+                    self.xmlPath))
+        # else:
+            # tmpPan=tempPanel(self.splitter)
+            # self.splitter.AppendWindow(tmpPan)
+            # self.splitter.AppendWindow(NotebookRight(self.splitter,None))
+
+        self._layout()
         self.Show()
 
+    def _layout(self):
+        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
+        self.SetSizer(self.mainSizer)
+
+        self.mainSizer.Add(self.toolbar)
+        self.mainSizer.Add(
+            wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL, size=(10000, 5)))
+        self.mainSizer.Add(
+            wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL, size=(0, 5)))
+        self.mainSizer.Add(self.splitter, proportion=1, flag=wx.EXPAND)
+
+
+class InspireValidator(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_inspire(self, md):
+        '''function for validation INSPIRE XML file'''
+        try:
+            self.md = md
+            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)
+            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'
+        except:
+            str1 = 'Metadata loading error'
+
+        self.text.SetValue(str1)
+
+
 #----------------------------------------------------------------------
 if __name__ == "__main__":
     app = wx.App(False)

Modified: sandbox/krejcmat/src/jinjainfo.py
===================================================================
--- sandbox/krejcmat/src/jinjainfo.py	2014-07-23 11:50:19 UTC (rev 61370)
+++ sandbox/krejcmat/src/jinjainfo.py	2014-07-23 13:00:27 UTC (rev 61371)
@@ -18,58 +18,94 @@
 from lxml import etree as et
 import os
 from jinja2 import Environment, FileSystemLoader
+from pyxb.bundles.common.raw.xhtml1 import ol
 
 
 class MdDescription():
-     def __init__(self, tag=None, object=None, name=None, desc=None, example=None, type=None, multi=0, inboxmulti=None, group=None, inbox=None, multiline=None, num=None):
-         # ++info from jinja start
-         self.tag = tag
-         self.object = object
-         self.name = name
-         self.desc = desc
-         self.example = example
-         self.type = type
-         self.multiplicity = multi  # multiplicity of MD item
-         self.group = group
-         self.inbox = inbox
-         self.inboxmulti = inboxmulti  # multiplicity in subrotoup (in static box)
-         self.multiline = multiline  # type of ctrl text
-         # --info from jinja -end
-         
-         self.statements = None
-         self.statements1 = None
-         self.num = num
-         self.mdItem = list()
 
-     def addMdItem(self, mditem):
-         '''list of objects MdItem()
-         '''
-         self.mdItem.append(mditem)
-         
-     def addStatements(self, stat):
-         if self.statements is None:
-             self.statements = stat
-             
-     def addStatements1(self, stat):
-         if self.statements1 is None:
-             self.statements1 = stat    
-        
+    def __init__(self, tag=None, object=None, name=None, desc=None,
+                 example=None, type=None, multi=0, inboxmulti=None, group=None,
+                 inbox=None, multiline=None, validator=None, num=None):
+        # ++info from jinja start
+        self.tag = tag
+        self.object = object
+        self.name = name
+        self.desc = desc
+        self.example = example
+        self.type = type
+        self.multiplicity = multi  # multiplicity of MD item
+        self.group = group
+        self.inbox = inbox
+        # multiplicity in subrotoup (in static box)
+        self.inboxmulti = inboxmulti
+        self.multiline = multiline  # type of ctrl text
+        self.validator = validator
+        # --info from jinja -end
+
+        self.statements = None
+        self.statements1 = None
+        self.num = num
+        self.mdItem = list()
+
+    def addMdItem(self, newMdItem, oldMdItem=None):
+        '''list of objects MdItem()
+        '''
+        # if new mditem is from box- need to hold information
+        # about it.(list on same index in self.mdItem)
+
+        print self.mdItem, ' list'
+
+        if oldMdItem is not None:
+            for n, item in enumerate(self.mdItem):
+                print 'here------------2'
+                for i in item:
+                    if i == oldMdItem:
+                        self.mdItem[n].append(newMdItem)
+        else:
+            self.mdItem.append(newMdItem)
+            print self.tag
+            print self.name
+            print self.mdItem
+
+        print '=' * 50
+        print ' list', self.mdItem
+
+    def removeMdItem(self, item):
+        print self.mdItem
+        try:
+            for k, oldListItem in enumerate(self.mdItem):
+                for i in oldListItem:
+                    if i == item:
+                        self.mdItem[k].remove(item)
+        except:
+            self.mdItem.remove(item)
+        print self.mdItem
+
+    def addStatements(self, stat):
+        if self.statements is None:
+            self.statements = stat
+
+    def addStatements1(self, stat):
+        if self.statements1 is None:
+            self.statements1 = stat
+
+
 class JinjaTemplateInfo():
+
     def __init__(self, template):
-        
+
         self.mdDescription = []  # list of object MdDescription
         self.mdOWSTag = []  # list of object in jinja template
         self.template = template
-        
+
         self.mdOWSTagStr = ''
-        
-        self.mdOWSTagStrList = [] 
+
+        self.mdOWSTagStrList = []
         # self.mdDescriptionStr=''
-          
+
         self._readJinjaInfo()
         self._readJinjaTags()
         self._domdOWSTagStr()
-        
 
     def cretemdDescriptionDict(self, akey):
         box = {}
@@ -80,10 +116,9 @@
             if key is not None:
                 if key not in box:
                     box.setdefault(key, [])
-                box[key].append(md)        
+                box[key].append(md)
         return box
-    
-   
+
     def _domdOWSTagStr(self):
         self.mdOWSTagStr = ""
         tab = 0
@@ -93,159 +128,61 @@
                     str(item).find(" endwhile ") != -1:
                 tab -= 1
                 continue
-            
+
             tabstr = '\t' * tab
-            str1 = tabstr + item[1:] + '\n' 
+            str1 = tabstr + item[1:] + '\n'
             self.mdOWSTagStr += str1
             self.mdOWSTagStrList.append(tabstr + item[1:])
-            
+
             if str(item).find(" for ") != -1 or \
                     str(item).find(" if ") != -1 or \
                     str(item).find(" while ") != -1:
                 tab += 1
-                
+
     def _readJinjaTags(self):
-            try:
-                with open(self.template, "r") as f:
-                    for line in f:
+        try:
+            with open(self.template, "r") as f:
+                for line in f:
 
-                        if str(line).find("{{") != -1:  # if found start of comments
-                            object = self._findBetween(line, "{{", "}}")
-                            self.mdOWSTag.append(object)
-                                
-                        if str(line).find("{%") != -1:
-                            object = self._findBetween(line, "{%", "-%}")
-                            self.mdOWSTag.append(object)
-                                   
-            except IOError as e:
-                print "I/O error({0}): {1}".format(e.errno, e.strerror)
+                    # if found start of comments
+                    if str(line).find("{{") != -1:
+                        object = self._findBetween(line, "{{", "}}")
+                        self.mdOWSTag.append(object)
 
+                    if str(line).find("{%") != -1:
+                        object = self._findBetween(line, "{%", "-%}")
+                        self.mdOWSTag.append(object)
+
+        except IOError as e:
+            print "I/O error({0}): {1}".format(e.errno, e.strerror)
+
     def _readJinjaInfo(self):
-            # template = 'data/grassBasicISOTemplate01.xml'
-            counter = 1
-            
-            try:
-                with open(self.template, "r") as f:
-                    for line in f:
+        # template = 'data/grassBasicISOTemplate01.xml'
+        counter = 1
 
-                            if str(line).find("{#") != -1:  # if found start of comments
-                                
-                                # print 'num' + str(counter)
-                                values = self._findBetween(line, "{#", "#}")
-                                values += ',num=' + str(counter)
-                                # print values
-                                exe_str = "self.mdDescription.append(MdDescription(%s))" % values
-   
-                                eval(exe_str)
-                                counter += 1
-            except IOError as e:
-                print "I/O error({0}): {1}".format(e.errno, e.strerror)
-    
+        try:
+            with open(self.template, "r") as f:
+                for line in f:
 
-    
+                    # if found start of comments
+                    if str(line).find("{#") != -1:
+
+                        # print 'num' + str(counter)
+                        values = self._findBetween(line, "{#", "#}")
+                        values += ',num=' + str(counter)
+                        # print values
+                        exe_str = "self.mdDescription.append(MdDescription(%s))" % values
+
+                        eval(exe_str)
+                        counter += 1
+        except IOError as e:
+            print "I/O error({0}): {1}".format(e.errno, e.strerror)
+
     def _findBetween(self, s, first, last):
         try:
             start = s.index(first) + len(first)
             end = s.index(last, start)
             return s[start:end]
         except ValueError:
-            return ""        
-    #===========================================================================
-    # def getLinebyNum(self,num):
-    #     n=0
-    #     for line in self.mdOWSTagStr.splitlines():
-    #         if n==num:
-    #             return line            
-    #         n+=1
-    #===========================================================================
-            
-    #===========================================================================
-    # def getItemByNum(self,num):
-    #     dict=self.cretemdDescriptionDict('num')
-    #     return dict[num]        
-    #===========================================================================
-            
-#===============================================================================
-#     def getmdDescriptionGroupByGroupsList(self):
-#         #make dict with key=inbox(staticbox in gui)
-#         box={}
-#         for md in self.mdDescription:
-#             key = md.inbox
-#             if key is not None:
-#                 if key not in box:
-#                     box.setdefault(key, [])
-#                 box[key].append(md)
-#                 
-#         #gruped by inbox
-#         boxGroup=[]
-#         boxList=[]
-#         for key in box:
-#             boxGroup = box[key]
-#             fgroup=[]
-#             for item in boxGroup:
-#                 fgroup.append(item)
-#             boxList.append(fgroup)
-# 
-#         #sort boxes by group()  
-#         groupDict={}
-#         for item in boxList:
-#             key=item[0].group
-#             if key not in groupDict:
-#                 groupDict.setdefault(key, [])
-#             groupDict[key].append(item)
-#             
-#         #add items without box  
-#         for md in self.mdDescription:
-#             ibox=md.inbox
-#             key=md.group
-#             if ibox is None:
-#                 if key not in groupDict:
-#                     groupDict.setdefault(key, [])
-#                 groupDict[key].append(md)
-# 
-#         #create final list of groups which include boxes and single items.
-#         #The boxes include items. 
-#         #-----group
-#                 #---box
-#                     #---item in box
-#                 #---item     
-#         group=[]
-#         finalList=[]
-#         for key in groupDict:   
-#             group = groupDict[key]
-#             fgroup=[]
-#             for item in group:
-#                 fgroup.append(item)
-#             finalList.append(fgroup)
-#         self.grupedList=finalList
-#         return  finalList
-#===============================================================================
- #==============================================================================
- # class OWSLibInfo():
- #    def __init__(self):
- #        self.mdMultiple=[]
- #        self.mdSingle=[]
- #        
- #        #self.initSingle()
- #        
- #    def initSingle(self):
- #        #=======================================================================
- #        # self.mdSingle.append('identifier')
- #        # self.mdSingle.append('parentidentifier')
- #        # 
- #        # self.mdSingle.append('language')
- #        # self.mdSingle.append('dataseturi')
- #        # self.mdSingle.append('languagecode')
- #        # self.mdSingle.append('datestamp')
- #        # self.mdSingle.append('charset')
- #        # self.mdSingle.append('hierarchy')
- #        # self.mdSingle.append('datetimestamp')
- #        # self.mdSingle.append('stdver')
- #        # self.mdSingle.append('stdname')
- #        # self.mdSingle.append('referencesystem')
- #        # self.mdSingle.append('parentidentifier')
- #        # self.mdSingle.append('identification')
- #        # self.mdSingle.append('serviceidentification')
- #        #=======================================================================
- #        pass           
- #==============================================================================
+            return ""
+

Modified: sandbox/krejcmat/src/mdgrass.py
===================================================================
--- sandbox/krejcmat/src/mdgrass.py	2014-07-23 11:50:19 UTC (rev 61370)
+++ sandbox/krejcmat/src/mdgrass.py	2014-07-23 13:00:27 UTC (rev 61371)
@@ -36,87 +36,109 @@
 
 
 class GrassMD():
+
     def __init__(self, map, type):
 
         self.map = map  # name of choosen map by user
         self.type = type  # typ of map representation(cell, vector, r3)
         self.isMapExist()  # function to check if map exist
-        self.md_grass = {}  # dict with metadata from r.info v.info  except "r.info flag=h"        
-        self.md_abstract = ''  # create abstract from self.md_grass - key: source1, source2 and descriptio etc.
+        # dict with metadata from r.info v.info  except "r.info flag=h"
+        self.md_grass = {}
+        # create abstract from self.md_grass - key: source1, source2 and
+        # descriptio etc.
+        self.md_abstract = ''
         self.md_vinfo_h = ''  # v.info flag=h" - parse
         self.gisenv_grass = grass.gisenv()  # dict with gisenv information
-        self.schema_type = '_md_GRASS.xml'  # postfix of output xml file (variables)
+        # postfix of output xml file (variables)
+        self.schema_type = '_md_GRASS.xml'
         self.dirpath = os.path.dirname(os.path.realpath(__file__))
-        self.md = MD_Metadata(md=None)  # metadata object from OWSLIB ( for define md values)
+        # metadata object from OWSLIB ( for define md values)
+        self.md = MD_Metadata(md=None)
         self.template = None  # path to file with xml templates
-        
+
         if self.type == "cell":
             self.parseRast()
         elif self.type == "vector":
             self.parseVect()
         elif self.type == "r3??":
-            # TODO   
+            # TODO
             self.parseRast3D()
-            
-            
+
     def isMapExist(self):
-        '''Check if is the map in working mapset'''    
+        '''Check if is the map in working mapset'''
         self.mapset = grass.find_file(self.map, self.type)['mapset']
         if not self.mapset:
             grass.fatal(_("Map <%s> doesn't exist"), self.map)
-                   
+
     def readXML(self, xml_file):
         '''create instance of metadata(owslib) from xml file'''
         self.md = MD_Metadata(etree.parse(xml_file))
-        
+
     def parseRast3D(self):
         pass
-    
+
     def parseVect(self):
         '''Read metadata from v.info
         #self.md_grass dictionary of metadata from v.info '''
-        
+
         # parse md from v.info flags=-g -e -t
-        vinfo = Module('v.info', self.map, flags='get', quiet=True, stdout_=PIPE)
+        vinfo = Module(
+            'v.info',
+            self.map,
+            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)
-        rinfo_h = Module('v.info', self.map, flags='h', quiet=True, stdout_=PIPE)
+        rinfo_h = Module(
+            'v.info',
+            self.map,
+            flags='h',
+            quiet=True,
+            stdout_=PIPE)
         md_h_grass = rinfo_h.outputs.stdout
         buf = StringIO.StringIO(md_h_grass)
         line = buf.readline().splitlines()
-        while str(line) != '[]':   
-            if str(line[0]).strip() != "":             
+        while str(line) != '[]':
+            if str(line[0]).strip() != "":
                 self.md_vinfo_h += line[0] + '\n'
             line = buf.readline().splitlines()
         buf.close()
-        
+
         # change grass generated date format to iso format
         # if date format is diverse from standard, use them
         self._createISODate('source_date')
-            
+
     def _createISODate(self, key):
         '''Function for convert grass-generated date to iso format
            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')
             self.md_grass['dateofcreation'] = self.md_grass[key]
-                                
+
     def parseRast(self):
         '''Read metadata from r.info
-        #self.md_grass       dictionary of metadata from v.info 
+        #self.md_grass       dictionary of metadata from v.info
         #self.md_abstract    string created by merge information from 'description' and 'source'
         '''
-        rinfo = Module('r.info', self.map, flags='gre', quiet=True, stdout_=PIPE)
+        rinfo = Module(
+            'r.info',
+            self.map,
+            flags='gre',
+            quiet=True,
+            stdout_=PIPE)
         self.md_grass = parse_key_val(rinfo.outputs.stdout)
-                   
+
         # convert date to iso format
         self._createISODate('date')
-            
+
         # create abstract
         if self.md_grass['description'] != '""':
             self.md_abstract = self.md_grass['description'] + '\n'
@@ -125,24 +147,25 @@
         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 += 'A range of values: min: ' + self.md_grass['min'] + '  max: ' + self.md_grass['max']
+        self.md_abstract += 'A range of values: min: ' + \
+            self.md_grass['min'] + '  max: ' + self.md_grass['max']
 
     def createGrassBasicISO(self):
         '''Create basic/essential profile based on ISO
         - unknown values are filling by n = '$NULL'
         '''
-        
+
         n = '$NULL'
         # jinja templates
         self.template = 'data/grassBasicISOTemplate.xml'
-        
-        # OWSLib md object 
+
+        # OWSLib md object
         self.md.identification = MD_DataIdentification()
         self.md.dataquality = DQ_DataQuality()
         self.md.distribution = MD_Distribution()
         self.md.identification.extent = EX_Extent()
         self.md.identification.extent.boundingBox = EX_GeographicBoundingBox()
-        
+
         # Metadata on metadata
         val = CI_ResponsibleParty()
         val.organization = n
@@ -150,129 +173,132 @@
         val.role = n
         self.md.contact.append(val)
         self.md.languagecode = n
-        
-        # Identification/Resource Title 
+
+        # Identification/Resource Title
         self.md.identification.title = self.md_grass['title']
         self.md.datestamp = date.today().isoformat()
-        
-        # Identification/Resource Locator 
+
+        # Identification/Resource Locator
         val = CI_OnlineResource()
-        val.url = n 
+        val.url = n
         self.md.distribution.online.append(val)
-        
-        # Identification/Resource Type 
+
+        # Identification/Resource Type
         self.md.identification.identtype = 'dataset'
-        
-        # Identification/Unique Resource Identifier 
-        self.md.identifier = n 
+
+        # Identification/Unique Resource Identifier
+        self.md.identifier = n
         self.md.identification.uricode.append(n)
-        
+
         # Geographic/BB
         self.md.identification.extent.boundingBox.minx = self.md_grass['south']
         self.md.identification.extent.boundingBox.maxx = self.md_grass['north']
         self.md.identification.extent.boundingBox.miny = self.md_grass['west']
         self.md.identification.extent.boundingBox.maxy = self.md_grass['east']
-        
-        # Conformity/Title 
-        self.md.dataquality.conformancetitle.append('GRASS basic metadata profile based on ISO 19115, 19139')
-        
+
+        # Conformity/Title
+        self.md.dataquality.conformancetitle.append(
+            'GRASS basic metadata profile based on ISO 19115, 19139')
+
         # Conformity/Date:
         self.md.dataquality.conformancedate.append(date.today().isoformat())
         self.md.dataquality.conformancedatetype.append('publication')
-        
-        # Temporal/Date of creation 
+
+        # Temporal/Date of creation
         val = CI_Date()
         val.date = self.md_grass['dateofcreation']
         val.type = 'creation'
         self.md.identification.date.append(val)
 
-        # different metadata sources for vector and raster 
+        # different metadata sources for vector and raster
         if self.type == 'cell':
-            # Identification/Resource Abstract 
+            # Identification/Resource Abstract
             self.md.identification.abstract = self.md_abstract
-            
+
             # Geographic/resolution
             self.md.identification.uom.append(' ')
-            self.md.identification.distance.append(self.md_grass['nsres'])  # TODO for discuss
+            self.md.identification.distance.append(
+                self.md_grass['nsres'])  # TODO for discuss
 
             # Quality/Lineage
             self.md.dataquality.lineage = self.md_grass['comments']
-            
+
             # Organisation/Responsible Party:
             val = CI_ResponsibleParty()
             val.organization = getpass.getuser()
             val.role = 'owner'
             self.md.identification.contact.append(val)
-            
+
         if self.type == 'vector':
-            # Identification/Resource Abstract 
-            self.md.identification.abstract = self.md_grass['name']  # TODO not enough sources for crate abstarce 
+            # Identification/Resource Abstract
+            # TODO not enough sources for crate abstarce
+            self.md.identification.abstract = self.md_grass['name']
             self.md.dataquality.lineage = self.md_vinfo_h
-            
+
             # Organisation/Responsible Party:
             val = CI_ResponsibleParty()
             val.organization = self.md_grass['creator']
             val.role = 'owner'
             self.md.identification.contact.append(val)
-        
 
     def createGrassInspireISO(self):
         '''Create valid INSPIRE profile and fill it as much as possible by GRASS metadata. Missing values is $NULL
         -create basic md profile and add INSPIRE mandatory attributes
         '''
-        
+
         self.schema_type = '_md_INSPIRE.xml'
-        
+
         # create basic profile
-        self.createGrassBasicISO() 
+        self.createGrassBasicISO()
         self.template = 'data/grassInspireTemplate.xml'
-       
+
         n = '$NULL'
         self.md.datestamp = n
-        
+
         # Classification/Topic Category
         self.md.identification.topiccategory.append(n)
         self.md.identification.resourcelanguage.append(n)
-        
-        # Keyword/Keyword 
+
+        # Keyword/Keyword
         kw = {}
         kw['keywords'] = []
         kw['keywords'].append(n)
         kw['keywords'].append(n)
-        
+
         kw['type'] = None
         kw['thesaurus'] = {}
         kw['thesaurus']['date'] = n
         kw['thesaurus']['datetype'] = n
         kw['thesaurus']['title'] = n
         self.md.identification.keywords.append(kw)
-        
-        # Conformity/Title 
-        self.md.dataquality.conformancetitle.pop()  # remove value from basic profile
-        self.md.dataquality.conformancetitle.append('Commission Regulation (EU) No 1089/2010 of 23 November 2010 implementing Directive 2007/2/EC of the European Parliament and of the Council as regards interoperability of spatial data sets and services')
-        
-        # Conformity/Date 
+
+        # Conformity/Title
+        # remove value from basic profile
+        self.md.dataquality.conformancetitle.pop()
+        self.md.dataquality.conformancetitle.append(
+            'Commission Regulation (EU) No 1089/2010 of 23 November 2010 implementing Directive 2007/2/EC of the European Parliament and of the Council as regards interoperability of spatial data sets and services')
+
+        # Conformity/Date
         self.md.dataquality.conformancedate.append(n)
         self.md.dataquality.conformancedatetype.append(n)
-    
-         # Conformity/Degree 
+
+        # Conformity/Degree
         self.md.dataquality.conformancedegree.append(n)
-        
+
         # Constraints/Limitations on public access
         self.md.identification.accessconstraints.append(n)
         self.md.identification.otherconstraints.append(n)
-        
-        # Constraints/Conditions for access and use-general 
+
+        # Constraints/Conditions for access and use-general
         self.md.identification.uselimitation.append(n)
-        
-        # Temporal/Temporal Extent 
+
+        # Temporal/Temporal Extent
         self.md.identification.temporalextent_start = n
         self.md.identification.temporalextent_end = n
-        
 
     def saveXML(self, path=None, xml_out_name=None):
-        ''' Save custom record to ISO XML file''' 
-        
+        ''' Save custom record to ISO XML file'''
+
         # if  output file name is None, use map name and add postfix
         if xml_out_name is None:
             xml_out_name = str(self.map) + self.schema_type
@@ -291,7 +317,7 @@
         template = env.get_template(self.template)
         iso_xml = template.render(md=self.md)
         xml_file = xml_out_name
-        
+
         # write xml to flat file
         try:
             xml_file = open(path, "w")
@@ -302,179 +328,246 @@
         except IOError as e:
             print "I/O error({0}): {1}".format(e.errno, e.strerror)
             grass.fatal('error: cannot write xml file')
-        return  path
-    
+        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: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")
+            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")
+                    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")
+                    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")
+                    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")
+                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")
+                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")
+                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")
+            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")
+            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")
+            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")
+            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")
+                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")
+                    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")
+                    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")
+                    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")
+                    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")
+                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")
+                    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")
+                        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")
+                        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")
+                        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")
+                        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")
+            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")
+                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")
+            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")
+            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: 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")
+            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")
+                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")
+                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")
+                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: 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")
+                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)
-    
+
         return result
-

Modified: sandbox/krejcmat/src/r.info.iso.py
===================================================================
--- sandbox/krejcmat/src/r.info.iso.py	2014-07-23 11:50:19 UTC (rev 61370)
+++ sandbox/krejcmat/src/r.info.iso.py	2014-07-23 13:00:27 UTC (rev 61371)
@@ -33,39 +33,39 @@
 #% required: no
 #%end
 
-#%option G_OPT_M_DIR 
+#%option G_OPT_M_DIR
 #% key: destination
 #% label: Path to destination folder
 #% required: no
 #%end
 
 from grass.script import parser
-from mdgrass import  *
+from mdgrass import *
 
+
 def main():
 
     if not options['destination']:
         destination = None
     else:
         destination = options['destination']
-        
+
     if not options['mdout']:
         mdout = None
     else:
-        mdout = options['mdout']    
-  
-  
-    md = GrassMD(options['map'], 'cell')        
+        mdout = options['mdout']
+
+    md = GrassMD(options['map'], 'cell')
     if options['profil'] == 'inspire':
         md.createGrassInspireISO()
         xml_file = md.saveXML(destination, mdout)
         md.readXML(xml_file)
         print md.validate_inspire()
-    else:    
+    else:
         md.createGrassBasicISO()
         md.saveXML(destination, mdout)
-    
 
+
 if __name__ == "__main__":
     options, flags = parser()
     main()

Modified: sandbox/krejcmat/src/v.info.iso.py
===================================================================
--- sandbox/krejcmat/src/v.info.iso.py	2014-07-23 11:50:19 UTC (rev 61370)
+++ sandbox/krejcmat/src/v.info.iso.py	2014-07-23 13:00:27 UTC (rev 61371)
@@ -33,38 +33,40 @@
 #% required: no
 #%end
 
-#%option G_OPT_M_DIR 
+#%option G_OPT_M_DIR
 #% key: destination
 #% label: Path to destination folder
 #% required: no
 #%end
 
 from grass.script import parser
-from mdgrass import  *
+from mdgrass import *
+
+
 def main():
 
     if not options['destination']:
         destination = None
     else:
         destination = options['destination']
-        
+
     if not options['mdout']:
         mdout = None
     else:
-        mdout = options['mdout']   
-    
+        mdout = options['mdout']
+
     # create instance of metadata in owslib
-    md = GrassMD(options['map'], 'vector') 
-           
+    md = GrassMD(options['map'], 'vector')
+
     if options['profil'] == 'inspire':
         md.createGrassInspireISO()
         xml_file = md.saveXML(options['destination'], options['mdout'])
         md.readXML(xml_file)
         print md.validate_inspire()
-    else:    
+    else:
         md.createGrassBasicISO()
         md.saveXML(options['destination'], options['mdout'])
-    
+
 if __name__ == "__main__":
     options, flags = parser()
     main()



More information about the grass-commit mailing list