Changeset 65349


Ignore:
Timestamp:
Jun 1, 2015, 1:48:36 PM (9 years ago)
Author:
krejcmat
Message:

pdf report support

Location:
grass-addons/grass7/gui/wxpython/wx.metadata
Files:
4 added
2 deleted
9 edited
2 copied
1 moved

Legend:

Unmodified
Added
Removed
  • grass-addons/grass7/gui/wxpython/wx.metadata/Makefile

    r64000 r65349  
    55        r.info.iso \
    66        v.info.iso \
     7        pdf\
    78        g.gui.metadata
    89
     
    1112default:
    1213        $(MAKE) parsubdirs
    13         @cp -r templates $(ETC)
     14        @cp -r profiles $(ETC)
    1415        @cp -r config $(ETC)
    1516
     
    1819        @cd r.info.iso ; $(MAKE) install
    1920        @cd v.info.iso ; $(MAKE) install
     21        @cd pdf ; $(MAKE) install
    2022        @cd g.gui.metadata ; $(MAKE) install
    2123        @cp -r etc/* $(INST_DIR)/etc
  • grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/Makefile

    r63999 r65349  
    2020$(DSTDIR)/%: % | $(DSTDIR)
    2121        $(INSTALL_DATA) $< $@
     22
     23
  • grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/editor.py

    r61615 r65349  
    138138
    139139            if msg:
    140                 GMessage('File exported to: %s' % outPath)
     140                GMessage('File is exported to: %s' % outPath)
    141141
    142142            if rmTeplate:
     
    656656    '''
    657657
    658     def __init__(self, parent, templatePath, xmlMdPath, templateEditor=False):
    659         '''
    660         @param templatePath: path to jinja template for generating GUI of editor
     658    def __init__(self, parent, profilePath, xmlMdPath, templateEditor=False):
     659        '''
     660        @param profilePath: path to jinja template for generating GUI of editor
    661661        @param xmlMdPath: path of xml for init Editor
    662662        @param templateEditor: mode-creator of template
     
    666666        self.md = self.mdo.initMD(xmlMdPath)
    667667        self.templateEditor = templateEditor
    668         self.templatePath = templatePath
    669 
    670         self.jinj = JinjaTemplateParser(self.templatePath)
     668        self.profilePath = profilePath
     669
     670        self.jinj = JinjaTemplateParser(self.profilePath)
    671671        # list of object MdDescription
    672672        self.mdDescription = self.jinj.mdDescription
     
    678678        self._layout()
    679679
    680 #----------------------------------------------------------- GUI GENERATOR START
     680 #----------------------------------------------------------- GUI GENERATOR START
    681681    def executeStr(self, stri, mdDescrObj):
    682682        '''note- exec cannot be in sub function
     
    874874            self.executeStr(str1, mdDescrObj)
    875875
    876 #--------------------------------------------------------------------- INIT VARS
     876    #--------------------------------------------------------------------- INIT VARS
    877877        self.notebook = wx.Notebook(self)
    878878        markgroup = []  # notebook panel marker
     
    884884        prepareStatements()
    885885        self.notebokDict = {}
    886 # --------------------------------------------- #START of the loop of generator
     886    # --------------------------------------------- #START of the loop of generator
    887887        while self.stop is False:  # self.stop is managed by def plusC(self):
    888888            group = mdDescrObj[self.c].group
     
    927927                except:
    928928                    pass
    929 #----------------------------------------------------------- GUI GENERATOR END
     929    #----------------------------------------------------------- GUI GENERATOR END
    930930
    931931    def defineTemplate(self):
     
    937937        '''
    938938        try:
    939             template = open(self.templatePath, 'r')
     939            template = open(self.profilePath, 'r')
    940940        except Exception, e:
    941941            GError('Error loading template:\n' + str(e))
     
    10211021            chcked = True
    10221022
    1023         head, tail = os.path.split(self.templatePath)
     1023        head, tail = os.path.split(self.profilePath)
    10241024        tail = 'EXPT' + tail
    1025         self.templatePath = os.path.join(head, tail)
    1026         templateOut = open(self.templatePath, 'w')
     1025        self.profilePath = os.path.join(head, tail)
     1026        templateOut = open(self.profilePath, 'w')
    10271027        templateOut.write(finalTemplate)
    10281028        templateOut.close()
    10291029
    10301030        return owsTagList
    1031 #----------------------------------------- FILL OWSLib BY EDITED METADATA IN GUI
     1031    #----------------------------------------- FILL OWSLib BY EDITED METADATA IN GUI
    10321032
    10331033    def executeStr1(self, stri, item):
     
    10381038        exec stri
    10391039
    1040     def createNewMD(self, evt=None):
     1040    def saveMDfromGUI(self, evt=None):
    10411041        '''Main function for exporting metadata from filled widgets.
    10421042           Initializing owslib object by metadata from gui(export of metadata)
     
    12911291        # most of objects from OWSLib is initialized in configure file
    12921292        dirpath = os.path.dirname(os.path.realpath(__file__))
    1293         path = os.path.join(dirpath, 'config', 'init_md')
     1293        #print dirpath
     1294        path = os.path.join(os.path.join(sys.path[0],'..'), 'config', 'init_md')
     1295        #print path
     1296
    12941297        mdInitData = open(path, 'r')
    12951298        mdExec = mdInitData.read()
     
    13201323
    13211324    def exportToXml(self, jinjaPath, outPath, xmlOutName, msg):
    1322         self.createNewMD()
     1325        self.saveMDfromGUI()
    13231326        self.mdo.saveToXML(self.md, None, jinjaPath, outPath, xmlOutName, msg)
    13241327
    13251328    def exportTemplate(self, jinjaPath, outPath, xmlOutName):
    1326         self.templatePath = jinjaPath
     1329        self.profilePath = jinjaPath
    13271330        owsTagList = self.defineTemplate()
    1328         self.createNewMD()
     1331        self.saveMDfromGUI()
    13291332        self.mdo.saveToXML(self.md, owsTagList,
    1330                            self.templatePath,
     1333                           self.profilePath,
    13311334                           outPath,
    13321335                           xmlOutName,
  • grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/g.gui.metadata.html

    r61662 r65349  
    1717Default location for exported metadata files is
    1818<i>metadata</i> directory in the map's mapset.  For raster maps, the prefix
    19 derived from the current nomenclature is <em>cell</em>, for vector
     19derived from the current nomenclature is <em>raster</em>, for vector
    2020maps <em>vector</em>. File ends with <em>.xml</em> extension.
    2121
  • grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/g.gui.metadata.py

    r65163 r65349  
    3535
    3636sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc', 'mdlib'))
    37 
     37sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc', 'pdf'))
    3838import wx
    3939from wx.lib.buttons import ThemedGenBitmapTextButton as BitmapBtnTxt
     
    4343import grass.script as grass
    4444import grass.script.setup as gsetup
     45import webbrowser
     46
    4547
    4648import mdgrass
    4749import mdutil
     50from mdpdffactory import PdfCreator
    4851
    4952from core.utils import _
     
    5558# MAIN FRAME
    5659#===============================================================================
    57 
    58 
    5960class MdMainFrame(wx.Frame):
    6061
     
    6465    def __init__(self, jinjaPath=None, xmlPath=None, init=False):
    6566        '''
    66         @param jinjaPath: path to jinja template
     67        @param jinjaPath: path to jinja profile
    6768        @param xmlPath: path to xml with will be read by editor
    6869        @var first,firstAfterChoice,second,secondAfterChoice,secondMultiEdit: initMultipleEditor() and onInitEditor() handler
    6970        @var self. initMultipleEditor() and onInitEditor() handler
    7071        @var self.templateEditor: true= Editor is in mode 'Template creator(widgets with chkbox)'
    71         @var nameTMPtemplate: in case if 'template editor is on' this var holds name oof temporaly jinja template
    7272        @var batch: if true multiple editing metadata of maps is ON
    7373        '''
     
    8282        self.secondAfterChoice = False
    8383        self.secondMultiEdit = False
    84 
     84        self.md=None
    8585        self.templateEditor = False
    8686        self.sb = self.CreateStatusBar()
     
    8989        self.nameTMPteplate = None
    9090        self.batch = False
    91 
     91        self.mdCreator=None
     92        self.editStatus=None
    9293        self.onInitEditor()
    9394
     
    9697        pub.subscribe(self.setStatusbarText, 'STATUS_BAR_TEXT.update')
    9798        pub.subscribe(self.onExportTemplate, 'EXPORT_TEMPLATE.create')
     99        pub.subscribe(self.onExportPDF, 'EXPORT_PDF.create')
     100
    98101        pub.subscribe(self.onExportXML, 'EXPORT_XML.create')
    99102        pub.subscribe(self.onEditMapMetadata, 'EDIT_MAP_METADATA.create')
     
    108111
    109112    def onSetJaX(self, jinja, xml):
    110         '''Set template ad xml paths
     113        '''Set profile ad xml paths
    111114        '''
    112115        self.jinjaPath = jinja
     
    128131        '''Update r.support and v.support
    129132        '''
    130         md = self.editor.createNewMD()
     133        md = self.editor.saveMDfromGUI()
    131134        self.mdCreator.updateGrassMd(md)
    132         GMessage('GRASS GIS metadata haved been updated')
     135        GMessage('GRASS GIS metadata has been updated')
    133136
    134137    def onChangeEditMapProfile(self):
    135138        '''Update vars
    136139        '''
    137         self.templateChoice = self.configPanelLeft.comboBoxProfile.GetValue()
    138         self.ntbRight.profile = self.templateChoice
     140        self.profileChoice = self.configPanelLeft.comboBoxProfile.GetValue()
     141        self.ntbRight.profile = self.profileChoice
    139142
    140143    def onExportTemplate(self, outPath, outFileName):
     
    144147                                   outPath=outPath,
    145148                                   xmlOutName=outFileName)
     149
     150    def onExportPDF(self, outPath, outFileName):
     151        self.initNewMD()
     152        pdfFile=os.path.join(outPath,outFileName)
     153
     154        if self.mdCreator is None and self.toolbar.extendEdit: #if editing map from grass database
     155            profileName=os.path.basename(self.jinjaPath)
     156            xmlFile=os.path.basename(self.xmlPath)
     157            doc = PdfCreator(self.md, pdfFile, map=None, type=None,filename=xmlFile,profile=profileName)
     158        else: #if editing map from external editor
     159            filename,type,map,profile=self.mdCreator.getMapInfo()
     160            doc = PdfCreator(self.md, pdfFile, map, type,filename,profile)
     161        try:
     162            path=doc.createPDF()
     163            GMessage('Metadata report has been exported to < %s >'%path)
     164        except:
     165            GError('Export pdf error %s'% sys.exc_info()[0])
     166
    146167
    147168    def onExportXML(self, outPath, outFileName):
     
    191212        '''Init new md OWSLib  object
    192213        '''
    193         self.editor.createNewMD()
     214        self.md=self.editor.saveMDfromGUI()
    194215        self.ntbRight.md = self.editor.md
     216
    195217
    196218    def resizeFrame(self, x1=1, y1=0):
     
    213235    def onEditingMode(self, editStatus):
    214236        self.resizeFrame()
     237        self.editStatus=editStatus
    215238        self.Layout()
    216239
     
    237260            self.ListOfMapTypeDict = self.MdDataCatalogPanelLeft.ListOfMapTypeDict
    238261
    239         self.templateChoice = self.configPanelLeft.comboBoxProfile.GetValue()
     262        self.profileChoice = self.configPanelLeft.comboBoxProfile.GetValue()
    240263        self.numOfMap = len(self.ListOfMapTypeDict)
    241264
     
    248271            self.mdCreator = mdgrass.GrassMD(self.ListOfMapTypeDict[-1][self.ListOfMapTypeDict[-1].keys()[0]],
    249272                                             self.ListOfMapTypeDict[-1].keys()[0])
    250             if self.templateChoice == 'INSPIRE':
     273            if self.profileChoice == 'INSPIRE':
    251274                self.mdCreator.createGrassInspireISO()
    252                 self.jinjaPath = self.mdCreator.templatePathAbs
    253                 self.xmlPath = self.mdCreator.saveXML(self.mdDestination, self.nameTMPteplate, self)
    254                 self.onInitEditor()
    255 
    256             elif self.templateChoice == 'GRASS BASIC':
     275            elif self.profileChoice == 'GRASS BASIC':
     276
    257277                self.mdCreator.createGrassBasicISO()
    258                 self.jinjaPath = self.mdCreator.templatePathAbs
    259                 self.xmlPath = self.mdCreator.saveXML(self.mdDestination, self.nameTMPteplate, self)
    260                 self.onInitEditor()
    261 
    262         # if editing multiple maps or just one but with loading own custom template
    263         if self.templateChoice == 'Load Custom' and self.numOfMap != 0:
    264         # load template. IF for just one map ELSE for multiple editing
     278            self.jinjaPath = self.mdCreator.profilePathAbs
     279            self.xmlPath = self.mdCreator.saveXML(self.mdDestination, self.nameTMPteplate, self)
     280            self.onInitEditor()
     281
     282        # if editing multiple maps or just one but with loading own custom profile
     283        if self.profileChoice == 'Load Custom' and self.numOfMap != 0:
     284        # load profile. IF for just one map ELSE for multiple editing
    265285            if multipleEditing is False:
    266                 dlg = wx.FileDialog(self, "Select template", os.getcwd(), "", "*.xml", wx.OPEN)
     286                dlg = wx.FileDialog(self, "Select profile", os.getcwd(), "", "*.xml", wx.OPEN)
    267287                if dlg.ShowModal() == wx.ID_OK:
    268288                    self.mdCreator = mdgrass.GrassMD(self.ListOfMapTypeDict[-1][self.ListOfMapTypeDict[-1].keys()[0]],
     
    328348                                       self.jinjaPath,
    329349                                       self.xmlPath,
    330                                        self.templateEditor)
     350                                       self.profileEditor)
    331351            self.ntbRight = NotebookRight(self.splitter, self.xmlPath)
    332352            self.splitter.SplitVertically(self.editor, self.ntbRight, sashPosition=0.65)
     
    373393
    374394            self.editor = MdMainEditor(parent=self.splitter,
    375                                        templatePath=self.jinjaPath,
     395                                       profilePath=self.jinjaPath,
    376396                                       xmlMdPath=self.xmlPath,
    377397                                       templateEditor=self.templateEditor)
     
    409429            editorTMP = self.editor
    410430            self.editor = MdMainEditor(parent=self.splitter,
    411                                        templatePath=self.jinjaPath,
     431                                       profilePath=self.jinjaPath,
    412432                                       xmlMdPath=self.xmlPath,
    413433                                       templateEditor=self.templateEditor)
     
    450470# DATA CATALOG
    451471#===============================================================================
    452 
    453 
    454472class MdDataCatalog(datacatalog.LocationMapTree):
    455473
     
    471489        location = gisenv['LOCATION_NAME']
    472490        self.mapset = gisenv['MAPSET']
     491        #TODO remove auto add permanent to catalogue
    473492
    474493        self._initTreeItems(locations=[location], mapsets=[self.mapset])
     
    488507                MapTypeDict = {}
    489508                maps.append(self.GetItemText(item))
    490                 map = self.GetItemText(item) + '@' + self.mapset
     509                map = self.GetItemText(item) #+ '@' + self.mapset @TODO to test
    491510                mapType = self.GetItemParent(item)
    492511                mapType = self.GetItemText(mapType)
     
    495514                    mapType = 'vector'
    496515                elif mapType == 'rast':
    497                     mapType = 'cell'
     516                    mapType = 'raster'
    498517                MapTypeDict[mapType] = map
    499518
     
    509528            pub.sendMessage('bttEdit.disable')
    510529            pub.sendMessage('bttCreateTemplate.disable')
    511         str1 = ''
    512 
     530
     531        status = ''
    513532        for map in maps:
    514             str1 += map + '  '
     533            status += map + '  '
    515534
    516535        if len(maps) > 1:
     
    523542            pub.sendMessage('bttCreateTemplate.enable')
    524543
    525         pub.sendMessage('STATUS_BAR_TEXT.update', text=str1)
     544        pub.sendMessage('STATUS_BAR_TEXT.update', text=status)
    526545
    527546#===============================================================================
     
    755774
    756775    '''Configuration pane for selection editing mode.
    757     @var mapGrassEdit: True = editing metadata of GRASS maps, false= editing externally loaded xml and template
     776    @var mapGrassEdit: True = editing metadata of GRASS maps, false= editing externally loaded xml and profile
    758777    '''
    759778
     
    799818    def onSetRadioType(self, evt=None):
    800819        self.mapGrassEdit = self.rbGrass.GetValue()
    801         if self.mapGrassEdit == False:
     820        if self.mapGrassEdit is False:
    802821            self.comboBoxProfile.Hide()
    803822        else:
     
    843862            os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'settings.png'),
    844863            wx.BITMAP_TYPE_PNG).ConvertToBitmap()
    845 #-------------------------------------------------------------------- EDIT
     864    #-------------------------------------------------------------------- EDIT
    846865        self.toolbar.AddSeparator()
    847866        bitmapEdit = wx.Image(
    848867            os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'edit.png'),
    849868            wx.BITMAP_TYPE_PNG).ConvertToBitmap()
    850         self.bttEdit = BitmapBtnTxt(
    851             self.toolbar, -1, bitmapEdit, 'edit')
     869
     870    #-------------------------------------------------------------------- EDIT
     871
     872        self.bttEdit = BitmapBtnTxt(self.toolbar, -1, bitmapEdit,size=(40, -1))
    852873        self.toolbar.AddControl(control=self.bttEdit)
    853874        self.bttEdit.Disable()
    854 #-------------------------------------------------------------------- NEW SESION
    855         self.toolbar.AddSeparator()
    856         self.bttNew = BitmapBtnTxt(self.toolbar, -1, bitmapNew, 'session')
     875    #-------------------------------------------------------------------- NEW SESION
     876        #self.toolbar.AddSeparator()
     877        self.bttNew = BitmapBtnTxt(self.toolbar, -1, bitmapNew, '', size=(40, -1))
    857878        self.toolbar.AddControl(control=self.bttNew)
    858879        self.bttNew.Disable()
    859 #-------------------------------------------------------------------------- SAVE
    860         self.bttsave = BitmapBtnTxt(self.toolbar, -1, bitmapSave, "XML")
    861         self.bttsave.Disable()
    862         self.toolbar.AddControl(control=self.bttsave)
     880    #-------------------------------------------------------------------- NEW TEMPLATE
     881        self.bttCreateTemplate = BitmapBtnTxt(self.toolbar, -1, bitmapNew, "template", size=(100, -1))
     882        self.toolbar.AddControl(control=self.bttCreateTemplate)
     883        self.bttCreateTemplate.Disable()
    863884        self.toolbar.AddSeparator()
    864 #----------------------------------------------------------------- OPEN TEMPLATE
    865         self.bttLoad = BitmapBtnTxt(self.toolbar, -1, bitmapLoad, "template", size=(100, -1))
     885
     886    #----------------------------------------------------------------- OPEN TEMPLATE
     887        self.bttLoad = BitmapBtnTxt(self.toolbar, -1, bitmapLoad, "profile", size=(100, -1))
    866888        self.toolbar.AddControl(control=self.bttLoad)
    867889        self.bttLoad.Disable()
    868 #---------------------------------------------------------------------- OPEN XML
    869         self.bttLoadXml = BitmapBtnTxt(self.toolbar, -1, bitmapLoad, "XML")
     890    #---------------------------------------------------------------------- OPEN XML
     891        self.bttLoadXml = BitmapBtnTxt(self.toolbar, -1, bitmapLoad, "xml")
    870892        self.toolbar.AddControl(control=self.bttLoadXml)
    871893        self.bttLoadXml.Disable()
    872894        self.toolbar.AddSeparator()
    873 #-------------------------------------------------------------------- NEW TEMPLATE
    874         self.bttCreateTemplate = BitmapBtnTxt(self.toolbar, -1, bitmapNew, "template", size=(100, -1))
    875         self.toolbar.AddControl(control=self.bttCreateTemplate)
    876         self.bttCreateTemplate.Disable()
    877 #-------------------------------------------------------------------------- SAVE
     895
     896
     897    #-------------------------------------------------------------------------- export xml
     898        self.bttsave = BitmapBtnTxt(self.toolbar, -1, bitmapSave, "xml")
     899        self.bttsave.Disable()
     900        self.toolbar.AddControl(control=self.bttsave)
     901    #-------------------------------------------------------------------------- export template
    878902        self.bttSaveTemplate = BitmapBtnTxt(self.toolbar, -1, bitmapSave, "template", size=(100, -1))
    879903        self.bttSaveTemplate.Disable()
    880904        self.toolbar.AddControl(control=self.bttSaveTemplate)
    881         self.toolbar.AddSeparator()
    882 #-------------------------------------------------------------------------- SAVE
     905    #-------------------------------------------------------------------------- update grass
    883906        self.bttUpdateGRASS = BitmapBtnTxt(self.toolbar, -1, bitmapSave, "GRASS", size=(100, -1))
    884907        self.bttUpdateGRASS.Disable()
    885908        self.toolbar.AddControl(control=self.bttUpdateGRASS)
     909    #-------------------------------------------------------------------------- export pdf
     910        self.bttExportPdf = BitmapBtnTxt(self.toolbar, -1, bitmapSave, "pdf", size=(100, -1))
     911        self.bttExportPdf.Disable()
     912        self.toolbar.AddControl(control=self.bttExportPdf)
    886913        self.toolbar.AddSeparator()
    887 #-------------------------------------------------------------------------- Config
    888         self.bttConfig = BitmapBtnTxt(self.toolbar, -1, bitmaSettings, "workdir", size=(100, -1))
     914    #-------------------------------------------------------------------------- Config
     915        self.bttConfig = BitmapBtnTxt(self.toolbar, -1, bitmaSettings, "", size=(40, -1))
    889916        self.toolbar.AddControl(control=self.bttConfig)
    890917        self.toolbar.AddSeparator()
     
    925952        pub.subscribe(self.onBttUpdateGRASSDisable, "bttSaveTemplate.disable")
    926953
     954        self.bttExportPdf.Bind(wx.EVT_BUTTON, self.onExportPdf)
     955        pub.subscribe(self.onBttExportPdfEnable, "bttExportPdf.enable")
     956        pub.subscribe(self.onBttExportPdfDisable, "bttExportPdf.disable")
    927957        self.bttConfig.Bind(wx.EVT_BUTTON, self.onSettings)
    928958
     
    9751005        self.bttUpdateGRASS.Enable()
    9761006
     1007    def onBttExportPdfDisable(self):
     1008        self.bttExportPdf.Disable()
     1009
     1010    def onBttExportPdfEnable(self):
     1011        self.bttExportPdf.Enable()
     1012
    9771013    def onUpdateGRASS(self, evt):
    9781014        pub.sendMessage('GRASS_METADATA.update')
     1015
     1016    def onExportPdf(self,evt):
     1017        self.xmlPath=self.GetParent().xmlPath
     1018        XMLhead, XMLtail = os.path.split(self.xmlPath)
     1019        dlg = wx.FileDialog(self,
     1020                            message="Set output file",
     1021                            defaultDir=self.mdDestination,
     1022                            defaultFile=XMLtail.split('.')[0]+'.pdf',
     1023                            wildcard="*.pdf",
     1024                            style=wx.SAVE | wx.FD_OVERWRITE_PROMPT)
     1025
     1026        if dlg.ShowModal() == wx.ID_OK:
     1027            outPath=dlg.GetDirectory()
     1028            outFileName=dlg.GetFilename()
     1029            pub.sendMessage('EXPORT_PDF.create',
     1030                            outPath=outPath,
     1031                            outFileName=outFileName)
     1032            if mdutil.yesNo(self,'Do you want to open report?'):
     1033                webbrowser.open(os.path.join(outPath,outFileName))
     1034
    9791035
    9801036    def onSettings(self, evt):
     
    10021058        self.bttSaveTemplate.Hide()
    10031059        self.bttUpdateGRASS.Hide()
     1060        self.bttExportPdf.Hide()
    10041061
    10051062    def showMultipleEdit(self):
     
    10131070        self.bttSaveTemplate.Show()
    10141071        self.bttUpdateGRASS.Show()
     1072        self.bttExportPdf.Show()
    10151073
    10161074    def onCreateTemplate(self, evt):
     
    10381096        self.bttEdit.Disable()
    10391097        self.bttsave.Enable()
     1098        self.bttExportPdf.Enable()
    10401099        if not self.extendEdit:
    10411100            self.bttUpdateGRASS.Enable()
     
    10591118        self.statusBar.SetStatusText('')
    10601119        self.bttsave.Disable()
     1120        self.bttExportPdf.Disable()
    10611121        self.bttUpdateGRASS.Disable()
    10621122        self.jinjaPath = None
    10631123        self.xmlPath = None
    1064         self.bttsave.SetLabel('XML')
     1124        self.bttsave.SetLabel('xml')
    10651125        self.showMultipleEdit()
    10661126
     
    10721132        if self.jinjaPath is not None and self.xmlPath is not None:
    10731133            pub.sendMessage('HIDE_LEFT_PANEL.update')
     1134
    10741135            self.bttEdit.Enable()
    10751136            self.bttCreateTemplate.Enable()
     
    11101171    def OnLoadTemplate(self, evt):
    11111172        dlg = wx.FileDialog(self,
    1112                             "Select template of ISO profile",
     1173                            "Select metadata ISO profile",
    11131174                            self.mdDestination,
    11141175                            "",
     
    11191180            self.jinjaPath = dlg.GetPath()
    11201181            tx = self.statusBar.GetStatusText()
    1121             self.statusBar.SetStatusText(tx + ' Selected template: ' + self.jinjaPath)
     1182            self.statusBar.SetStatusText(tx + ' Selected profile: ' + self.jinjaPath)
    11221183            self.onChangeXmlorTemplate()
    11231184
     
    11641225def main():
    11651226    app = wx.App(False)
    1166     frame = MdMainFrame()
     1227    MdMainFrame()
    11671228    app.MainLoop()
    11681229
  • grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdgrass.py

    r64001 r65349  
    2121from lxml import etree
    2222import os
    23 import sys
    24 import re
     23
    2524import StringIO
    26 import subprocess as sub
    2725import uuid
    2826import mdutil  # metadata lib
    29 import getpass  # whoami for linux and  ms-win
    30 
    31 from grass.pygrass.modules.shortcuts import general as g
    32 from grass.pygrass.gis import Mapset
    33 from grass.pygrass import raster
     27
    3428from grass.pygrass.modules import Module
    3529from grass.script import parse_key_val
    3630from subprocess import PIPE
    3731from datetime import date, datetime
    38 from grass.script import parser
    3932from grass.script import core as grass
    4033
     
    5952        # suffix of output xml file (variables)
    6053        self.schema_type = '_basic.xml'
     54        self.profileName='GRASS BASIC'
    6155        self.dirpath = os.path.join(os.getenv('GRASS_ADDON_BASE'), 'etc')
    6256        # metadata object from OWSLIB ( for define md values)
    6357        self.md = MD_Metadata(md=None)
    64         self.template = None  # path to file with xml templates
    65 
    66         if self.type == "cell":
     58        self.profilePath = None  # path to file with xml templates
     59
     60
     61        if self.type == "raster":
    6762            self.parseRast()
    6863        elif self.type == "vector":
     
    153148        self.md_abstract.translate(None, """&<>"'""")
    154149
    155     def createGrassBasicISO(self, template=None):
     150    def createGrassBasicISO(self, profile=None):
    156151        '''Create basic/essential profile based on ISO
    157152        - unknown values are filling by n = '$NULL'
     
    164159        n = '$NULL'
    165160        # jinja templates
    166         if template is None:
    167             self.template = os.path.join(self.dirpath, 'templates', 'basicTemplate.xml')
     161        if profile is None:
     162            self.profilePath = os.path.join('profiles', 'basicProfile.xml')
    168163        else:
    169             self.template = template
     164            self.profilePath = profile
    170165
    171166        # OWSLib md object
     
    218213
    219214        # different metadata sources for vector and raster
    220         if self.type == 'cell':
     215        if self.type == 'raster':
    221216            # Identification/Resource Abstract
    222217            self.md.identification.abstract = mdutil.replaceXMLReservedChar(self.md_abstract)
     
    254249            self.md.identification.contact.append(val)
    255250
    256         self.templatePathAbs = os.path.join(self.dirpath, self.template)
    257 
    258     def createGrassInspireISO(self, template=None):
     251        self.profilePathAbs = os.path.join(self.dirpath, self.profilePath)
     252
     253    def createGrassInspireISO(self, profile=None):
    259254        '''Create valid INSPIRE profile and fill it as much as possible by GRASS metadata. Missing values is $NULL
    260255        -create basic md profile and add INSPIRE mandatory attributes
     
    262257
    263258        self.schema_type = '_inspire.xml'
     259        self.profileName='INSPIRE'
    264260
    265261        # create basic profile
    266262        self.createGrassBasicISO()
    267263
    268         if template is None:
    269             self.template = os.path.join('templates',  'inspireTemplate.xml')
     264        if profile is None:
     265            self.profilePath = os.path.join('profiles',  'inspireProfile.xml')
    270266        else:
    271             self.template = template
     267            self.profilePath = profile
    272268
    273269        n = '$NULL'
     
    319315        self.md.identification.temporalextent_end = n
    320316
    321         self.templatePathAbs = os.path.join(self.dirpath, self.template)
    322         # print self.templatePathAbs
     317        self.profilePathAbs = os.path.join(self.dirpath, self.profilePath)
    323318
    324319    def readXML(self, xml_file):
    325320        '''create instance of metadata(owslib) from xml file'''
    326321        self.md = MD_Metadata(etree.parse(xml_file))
     322
     323
     324    def getMapInfo(self):
     325        xml_out_name = self.type + '_' + str(self.map).partition('@')[0]  # + self.schema_type
     326        if not xml_out_name.lower().endswith('.xml'):
     327            xml_out_name += '.xml'
     328        return xml_out_name, self.type,self.map,self.profileName
    327329
    328330    def saveXML(self, path=None, xml_out_name=None, wxparent=None, overwrite=False):
     
    341343        path = os.path.join(path, xml_out_name)
    342344
    343         # generate xml using jinja templates
     345        # generate xml using jinja profiles
    344346        env = Environment(loader=FileSystemLoader(self.dirpath))
    345347        env.globals.update(zip=zip)
    346         template = env.get_template(self.template)
    347         iso_xml = template.render(md=self.md)
     348        profile = env.get_template(self.profilePath)
     349        iso_xml = profile.render(md=self.md)
    348350
    349351        # write xml to flat file
    350352        if wxparent != None:
    351353            if os.path.isfile(path):
    352                 if mdutil.yesNo(wxparent, 'Metadata file exists. Do you want to overwrite file: %s?' % path, 'Overwrite dialog'):
     354                if mdutil.yesNo(wxparent, 'Metadata file exists. Do you want to overwrite metadata file: %s?' % path, 'Overwrite dialog'):
    353355                    try:
    354356                        xml_file = open(path, "w")
     
    441443            if md.identification.contact is not None:
    442444                if len(md.identification.contact) > 0:
    443                     _person = md.identification.contact.organization.pop()
    444 
    445                     Module('v.support',
    446                            map=self.map,
    447                            person=_person,
    448                            flags='r')
     445                    _person = md.identification.contact.pop()
     446                    if _person is str:
     447                        Module('v.support',
     448                               map=self.map,
     449                               person=_person,
     450                               flags='r')
    449451
    450452            if md.identification.title is not (None or ''):
     
    485487
    486488#------------------------------------------------------------------------ RASTER
    487         if self.type == "cell":
     489        if self.type == "raster":
    488490
    489491            if md.identification.title is not (None or ''):
  • grass-addons/grass7/gui/wxpython/wx.metadata/r.info.iso/r.info.iso.html

    r61661 r65349  
    2121metadata file is not specified by <b>output</b> option than the name
    2222is built from map's type and its name. For raster maps, the prefix
    23 derived from the current nomenclature is <em>cell</em>, for vector
     23derived from the current nomenclature is <em>raster</em>, for vector
    2424maps <em>vector</em>. File ends with <em>.xml</em> extension.
    2525
  • grass-addons/grass7/gui/wxpython/wx.metadata/r.info.iso/r.info.iso.py

    r63999 r65349  
    5858        destination, name = os.path.split(options['output'])
    5959
    60     md = GrassMD(options['map'], 'cell')
     60    md = GrassMD(options['map'], 'raster')
    6161    if options['profile'] == 'inspire':
    6262        md.createGrassInspireISO()
  • grass-addons/grass7/gui/wxpython/wx.metadata/v.info.iso/v.info.iso.html

    r61661 r65349  
    2121metadata file is not specified by <b>output</b> option than the name
    2222is built from map's type and its name. For raster maps, the prefix
    23 derived from the current nomenclature is <em>cell</em>, for vector
     23derived from the current nomenclature is <em>raster</em>, for vector
    2424maps <em>vector</em>. File ends with <em>.xml</em> extension.
    2525
Note: See TracChangeset for help on using the changeset viewer.