Changeset 65349
- Timestamp:
- Jun 1, 2015, 1:48:36 PM (9 years ago)
- Location:
- grass-addons/grass7/gui/wxpython/wx.metadata
- Files:
-
- 4 added
- 2 deleted
- 9 edited
- 2 copied
- 1 moved
-
Makefile (modified) (3 diffs)
-
g.gui.metadata/Makefile (modified) (1 diff)
-
g.gui.metadata/editor.py (modified) (12 diffs)
-
g.gui.metadata/g.gui.metadata.html (modified) (1 diff)
-
g.gui.metadata/g.gui.metadata.py (modified) (36 diffs)
-
mdlib/mdgrass.py (modified) (11 diffs)
-
pdf (added)
-
pdf/Makefile (added)
-
pdf/mdpdffactory.py (added)
-
pdf/mdpdftheme.py (added)
-
profiles (moved) (moved from grass-addons/grass7/gui/wxpython/wx.metadata/templates )
-
profiles/basicProfile.xml (copied) (copied from grass-addons/grass7/gui/wxpython/wx.metadata/templates/basicTemplate.xml )
-
profiles/basicTemplate.xml (deleted)
-
profiles/inspireProfile.xml (copied) (copied from grass-addons/grass7/gui/wxpython/wx.metadata/templates/inspireTemplate.xml )
-
profiles/inspireTemplate.xml (deleted)
-
r.info.iso/r.info.iso.html (modified) (1 diff)
-
r.info.iso/r.info.iso.py (modified) (1 diff)
-
v.info.iso/v.info.iso.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
grass-addons/grass7/gui/wxpython/wx.metadata/Makefile
r64000 r65349 5 5 r.info.iso \ 6 6 v.info.iso \ 7 pdf\ 7 8 g.gui.metadata 8 9 … … 11 12 default: 12 13 $(MAKE) parsubdirs 13 @cp -r templates $(ETC)14 @cp -r profiles $(ETC) 14 15 @cp -r config $(ETC) 15 16 … … 18 19 @cd r.info.iso ; $(MAKE) install 19 20 @cd v.info.iso ; $(MAKE) install 21 @cd pdf ; $(MAKE) install 20 22 @cd g.gui.metadata ; $(MAKE) install 21 23 @cp -r etc/* $(INST_DIR)/etc -
grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/Makefile
r63999 r65349 20 20 $(DSTDIR)/%: % | $(DSTDIR) 21 21 $(INSTALL_DATA) $< $@ 22 23 -
grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/editor.py
r61615 r65349 138 138 139 139 if msg: 140 GMessage('File exported to: %s' % outPath)140 GMessage('File is exported to: %s' % outPath) 141 141 142 142 if rmTeplate: … … 656 656 ''' 657 657 658 def __init__(self, parent, templatePath, xmlMdPath, templateEditor=False):659 ''' 660 @param templatePath: path to jinja template for generating GUI of editor658 def __init__(self, parent, profilePath, xmlMdPath, templateEditor=False): 659 ''' 660 @param profilePath: path to jinja template for generating GUI of editor 661 661 @param xmlMdPath: path of xml for init Editor 662 662 @param templateEditor: mode-creator of template … … 666 666 self.md = self.mdo.initMD(xmlMdPath) 667 667 self.templateEditor = templateEditor 668 self. templatePath = templatePath669 670 self.jinj = JinjaTemplateParser(self. templatePath)668 self.profilePath = profilePath 669 670 self.jinj = JinjaTemplateParser(self.profilePath) 671 671 # list of object MdDescription 672 672 self.mdDescription = self.jinj.mdDescription … … 678 678 self._layout() 679 679 680 #----------------------------------------------------------- GUI GENERATOR START680 #----------------------------------------------------------- GUI GENERATOR START 681 681 def executeStr(self, stri, mdDescrObj): 682 682 '''note- exec cannot be in sub function … … 874 874 self.executeStr(str1, mdDescrObj) 875 875 876 #--------------------------------------------------------------------- INIT VARS876 #--------------------------------------------------------------------- INIT VARS 877 877 self.notebook = wx.Notebook(self) 878 878 markgroup = [] # notebook panel marker … … 884 884 prepareStatements() 885 885 self.notebokDict = {} 886 # --------------------------------------------- #START of the loop of generator886 # --------------------------------------------- #START of the loop of generator 887 887 while self.stop is False: # self.stop is managed by def plusC(self): 888 888 group = mdDescrObj[self.c].group … … 927 927 except: 928 928 pass 929 #----------------------------------------------------------- GUI GENERATOR END929 #----------------------------------------------------------- GUI GENERATOR END 930 930 931 931 def defineTemplate(self): … … 937 937 ''' 938 938 try: 939 template = open(self. templatePath, 'r')939 template = open(self.profilePath, 'r') 940 940 except Exception, e: 941 941 GError('Error loading template:\n' + str(e)) … … 1021 1021 chcked = True 1022 1022 1023 head, tail = os.path.split(self. templatePath)1023 head, tail = os.path.split(self.profilePath) 1024 1024 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') 1027 1027 templateOut.write(finalTemplate) 1028 1028 templateOut.close() 1029 1029 1030 1030 return owsTagList 1031 #----------------------------------------- FILL OWSLib BY EDITED METADATA IN GUI1031 #----------------------------------------- FILL OWSLib BY EDITED METADATA IN GUI 1032 1032 1033 1033 def executeStr1(self, stri, item): … … 1038 1038 exec stri 1039 1039 1040 def createNewMD(self, evt=None):1040 def saveMDfromGUI(self, evt=None): 1041 1041 '''Main function for exporting metadata from filled widgets. 1042 1042 Initializing owslib object by metadata from gui(export of metadata) … … 1291 1291 # most of objects from OWSLib is initialized in configure file 1292 1292 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 1294 1297 mdInitData = open(path, 'r') 1295 1298 mdExec = mdInitData.read() … … 1320 1323 1321 1324 def exportToXml(self, jinjaPath, outPath, xmlOutName, msg): 1322 self. createNewMD()1325 self.saveMDfromGUI() 1323 1326 self.mdo.saveToXML(self.md, None, jinjaPath, outPath, xmlOutName, msg) 1324 1327 1325 1328 def exportTemplate(self, jinjaPath, outPath, xmlOutName): 1326 self. templatePath = jinjaPath1329 self.profilePath = jinjaPath 1327 1330 owsTagList = self.defineTemplate() 1328 self. createNewMD()1331 self.saveMDfromGUI() 1329 1332 self.mdo.saveToXML(self.md, owsTagList, 1330 self. templatePath,1333 self.profilePath, 1331 1334 outPath, 1332 1335 xmlOutName, -
grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/g.gui.metadata.html
r61662 r65349 17 17 Default location for exported metadata files is 18 18 <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 vector19 derived from the current nomenclature is <em>raster</em>, for vector 20 20 maps <em>vector</em>. File ends with <em>.xml</em> extension. 21 21 -
grass-addons/grass7/gui/wxpython/wx.metadata/g.gui.metadata/g.gui.metadata.py
r65163 r65349 35 35 36 36 sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc', 'mdlib')) 37 37 sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc', 'pdf')) 38 38 import wx 39 39 from wx.lib.buttons import ThemedGenBitmapTextButton as BitmapBtnTxt … … 43 43 import grass.script as grass 44 44 import grass.script.setup as gsetup 45 import webbrowser 46 45 47 46 48 import mdgrass 47 49 import mdutil 50 from mdpdffactory import PdfCreator 48 51 49 52 from core.utils import _ … … 55 58 # MAIN FRAME 56 59 #=============================================================================== 57 58 59 60 class MdMainFrame(wx.Frame): 60 61 … … 64 65 def __init__(self, jinjaPath=None, xmlPath=None, init=False): 65 66 ''' 66 @param jinjaPath: path to jinja template67 @param jinjaPath: path to jinja profile 67 68 @param xmlPath: path to xml with will be read by editor 68 69 @var first,firstAfterChoice,second,secondAfterChoice,secondMultiEdit: initMultipleEditor() and onInitEditor() handler 69 70 @var self. initMultipleEditor() and onInitEditor() handler 70 71 @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 template72 72 @var batch: if true multiple editing metadata of maps is ON 73 73 ''' … … 82 82 self.secondAfterChoice = False 83 83 self.secondMultiEdit = False 84 84 self.md=None 85 85 self.templateEditor = False 86 86 self.sb = self.CreateStatusBar() … … 89 89 self.nameTMPteplate = None 90 90 self.batch = False 91 91 self.mdCreator=None 92 self.editStatus=None 92 93 self.onInitEditor() 93 94 … … 96 97 pub.subscribe(self.setStatusbarText, 'STATUS_BAR_TEXT.update') 97 98 pub.subscribe(self.onExportTemplate, 'EXPORT_TEMPLATE.create') 99 pub.subscribe(self.onExportPDF, 'EXPORT_PDF.create') 100 98 101 pub.subscribe(self.onExportXML, 'EXPORT_XML.create') 99 102 pub.subscribe(self.onEditMapMetadata, 'EDIT_MAP_METADATA.create') … … 108 111 109 112 def onSetJaX(self, jinja, xml): 110 '''Set template ad xml paths113 '''Set profile ad xml paths 111 114 ''' 112 115 self.jinjaPath = jinja … … 128 131 '''Update r.support and v.support 129 132 ''' 130 md = self.editor. createNewMD()133 md = self.editor.saveMDfromGUI() 131 134 self.mdCreator.updateGrassMd(md) 132 GMessage('GRASS GIS metadata ha vedbeen updated')135 GMessage('GRASS GIS metadata has been updated') 133 136 134 137 def onChangeEditMapProfile(self): 135 138 '''Update vars 136 139 ''' 137 self. templateChoice = self.configPanelLeft.comboBoxProfile.GetValue()138 self.ntbRight.profile = self. templateChoice140 self.profileChoice = self.configPanelLeft.comboBoxProfile.GetValue() 141 self.ntbRight.profile = self.profileChoice 139 142 140 143 def onExportTemplate(self, outPath, outFileName): … … 144 147 outPath=outPath, 145 148 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 146 167 147 168 def onExportXML(self, outPath, outFileName): … … 191 212 '''Init new md OWSLib object 192 213 ''' 193 self. editor.createNewMD()214 self.md=self.editor.saveMDfromGUI() 194 215 self.ntbRight.md = self.editor.md 216 195 217 196 218 def resizeFrame(self, x1=1, y1=0): … … 213 235 def onEditingMode(self, editStatus): 214 236 self.resizeFrame() 237 self.editStatus=editStatus 215 238 self.Layout() 216 239 … … 237 260 self.ListOfMapTypeDict = self.MdDataCatalogPanelLeft.ListOfMapTypeDict 238 261 239 self. templateChoice = self.configPanelLeft.comboBoxProfile.GetValue()262 self.profileChoice = self.configPanelLeft.comboBoxProfile.GetValue() 240 263 self.numOfMap = len(self.ListOfMapTypeDict) 241 264 … … 248 271 self.mdCreator = mdgrass.GrassMD(self.ListOfMapTypeDict[-1][self.ListOfMapTypeDict[-1].keys()[0]], 249 272 self.ListOfMapTypeDict[-1].keys()[0]) 250 if self. templateChoice == 'INSPIRE':273 if self.profileChoice == 'INSPIRE': 251 274 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 257 277 self.mdCreator.createGrassBasicISO() 258 self.jinjaPath = self.mdCreator.templatePathAbs259 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 template263 if self. templateChoice == 'Load Custom' and self.numOfMap != 0:264 # load template. IF for just one map ELSE for multiple editing278 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 265 285 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) 267 287 if dlg.ShowModal() == wx.ID_OK: 268 288 self.mdCreator = mdgrass.GrassMD(self.ListOfMapTypeDict[-1][self.ListOfMapTypeDict[-1].keys()[0]], … … 328 348 self.jinjaPath, 329 349 self.xmlPath, 330 self. templateEditor)350 self.profileEditor) 331 351 self.ntbRight = NotebookRight(self.splitter, self.xmlPath) 332 352 self.splitter.SplitVertically(self.editor, self.ntbRight, sashPosition=0.65) … … 373 393 374 394 self.editor = MdMainEditor(parent=self.splitter, 375 templatePath=self.jinjaPath,395 profilePath=self.jinjaPath, 376 396 xmlMdPath=self.xmlPath, 377 397 templateEditor=self.templateEditor) … … 409 429 editorTMP = self.editor 410 430 self.editor = MdMainEditor(parent=self.splitter, 411 templatePath=self.jinjaPath,431 profilePath=self.jinjaPath, 412 432 xmlMdPath=self.xmlPath, 413 433 templateEditor=self.templateEditor) … … 450 470 # DATA CATALOG 451 471 #=============================================================================== 452 453 454 472 class MdDataCatalog(datacatalog.LocationMapTree): 455 473 … … 471 489 location = gisenv['LOCATION_NAME'] 472 490 self.mapset = gisenv['MAPSET'] 491 #TODO remove auto add permanent to catalogue 473 492 474 493 self._initTreeItems(locations=[location], mapsets=[self.mapset]) … … 488 507 MapTypeDict = {} 489 508 maps.append(self.GetItemText(item)) 490 map = self.GetItemText(item) + '@' + self.mapset509 map = self.GetItemText(item) #+ '@' + self.mapset @TODO to test 491 510 mapType = self.GetItemParent(item) 492 511 mapType = self.GetItemText(mapType) … … 495 514 mapType = 'vector' 496 515 elif mapType == 'rast': 497 mapType = ' cell'516 mapType = 'raster' 498 517 MapTypeDict[mapType] = map 499 518 … … 509 528 pub.sendMessage('bttEdit.disable') 510 529 pub.sendMessage('bttCreateTemplate.disable') 511 str1 = '' 512 530 531 status = '' 513 532 for map in maps: 514 st r1+= map + ' '533 status += map + ' ' 515 534 516 535 if len(maps) > 1: … … 523 542 pub.sendMessage('bttCreateTemplate.enable') 524 543 525 pub.sendMessage('STATUS_BAR_TEXT.update', text=st r1)544 pub.sendMessage('STATUS_BAR_TEXT.update', text=status) 526 545 527 546 #=============================================================================== … … 755 774 756 775 '''Configuration pane for selection editing mode. 757 @var mapGrassEdit: True = editing metadata of GRASS maps, false= editing externally loaded xml and template776 @var mapGrassEdit: True = editing metadata of GRASS maps, false= editing externally loaded xml and profile 758 777 ''' 759 778 … … 799 818 def onSetRadioType(self, evt=None): 800 819 self.mapGrassEdit = self.rbGrass.GetValue() 801 if self.mapGrassEdit ==False:820 if self.mapGrassEdit is False: 802 821 self.comboBoxProfile.Hide() 803 822 else: … … 843 862 os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'settings.png'), 844 863 wx.BITMAP_TYPE_PNG).ConvertToBitmap() 845 #-------------------------------------------------------------------- EDIT864 #-------------------------------------------------------------------- EDIT 846 865 self.toolbar.AddSeparator() 847 866 bitmapEdit = wx.Image( 848 867 os.path.join(os.environ['GISBASE'], 'gui', 'icons', 'grass', 'edit.png'), 849 868 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)) 852 873 self.toolbar.AddControl(control=self.bttEdit) 853 874 self.bttEdit.Disable() 854 #-------------------------------------------------------------------- NEW SESION855 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)) 857 878 self.toolbar.AddControl(control=self.bttNew) 858 879 self.bttNew.Disable() 859 #-------------------------------------------------------------------------- SAVE860 self.btt save = 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() 863 884 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)) 866 888 self.toolbar.AddControl(control=self.bttLoad) 867 889 self.bttLoad.Disable() 868 #---------------------------------------------------------------------- OPEN XML869 self.bttLoadXml = BitmapBtnTxt(self.toolbar, -1, bitmapLoad, " XML")890 #---------------------------------------------------------------------- OPEN XML 891 self.bttLoadXml = BitmapBtnTxt(self.toolbar, -1, bitmapLoad, "xml") 870 892 self.toolbar.AddControl(control=self.bttLoadXml) 871 893 self.bttLoadXml.Disable() 872 894 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 878 902 self.bttSaveTemplate = BitmapBtnTxt(self.toolbar, -1, bitmapSave, "template", size=(100, -1)) 879 903 self.bttSaveTemplate.Disable() 880 904 self.toolbar.AddControl(control=self.bttSaveTemplate) 881 self.toolbar.AddSeparator() 882 #-------------------------------------------------------------------------- SAVE 905 #-------------------------------------------------------------------------- update grass 883 906 self.bttUpdateGRASS = BitmapBtnTxt(self.toolbar, -1, bitmapSave, "GRASS", size=(100, -1)) 884 907 self.bttUpdateGRASS.Disable() 885 908 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) 886 913 self.toolbar.AddSeparator() 887 #-------------------------------------------------------------------------- Config888 self.bttConfig = BitmapBtnTxt(self.toolbar, -1, bitmaSettings, " workdir", size=(100, -1))914 #-------------------------------------------------------------------------- Config 915 self.bttConfig = BitmapBtnTxt(self.toolbar, -1, bitmaSettings, "", size=(40, -1)) 889 916 self.toolbar.AddControl(control=self.bttConfig) 890 917 self.toolbar.AddSeparator() … … 925 952 pub.subscribe(self.onBttUpdateGRASSDisable, "bttSaveTemplate.disable") 926 953 954 self.bttExportPdf.Bind(wx.EVT_BUTTON, self.onExportPdf) 955 pub.subscribe(self.onBttExportPdfEnable, "bttExportPdf.enable") 956 pub.subscribe(self.onBttExportPdfDisable, "bttExportPdf.disable") 927 957 self.bttConfig.Bind(wx.EVT_BUTTON, self.onSettings) 928 958 … … 975 1005 self.bttUpdateGRASS.Enable() 976 1006 1007 def onBttExportPdfDisable(self): 1008 self.bttExportPdf.Disable() 1009 1010 def onBttExportPdfEnable(self): 1011 self.bttExportPdf.Enable() 1012 977 1013 def onUpdateGRASS(self, evt): 978 1014 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 979 1035 980 1036 def onSettings(self, evt): … … 1002 1058 self.bttSaveTemplate.Hide() 1003 1059 self.bttUpdateGRASS.Hide() 1060 self.bttExportPdf.Hide() 1004 1061 1005 1062 def showMultipleEdit(self): … … 1013 1070 self.bttSaveTemplate.Show() 1014 1071 self.bttUpdateGRASS.Show() 1072 self.bttExportPdf.Show() 1015 1073 1016 1074 def onCreateTemplate(self, evt): … … 1038 1096 self.bttEdit.Disable() 1039 1097 self.bttsave.Enable() 1098 self.bttExportPdf.Enable() 1040 1099 if not self.extendEdit: 1041 1100 self.bttUpdateGRASS.Enable() … … 1059 1118 self.statusBar.SetStatusText('') 1060 1119 self.bttsave.Disable() 1120 self.bttExportPdf.Disable() 1061 1121 self.bttUpdateGRASS.Disable() 1062 1122 self.jinjaPath = None 1063 1123 self.xmlPath = None 1064 self.bttsave.SetLabel(' XML')1124 self.bttsave.SetLabel('xml') 1065 1125 self.showMultipleEdit() 1066 1126 … … 1072 1132 if self.jinjaPath is not None and self.xmlPath is not None: 1073 1133 pub.sendMessage('HIDE_LEFT_PANEL.update') 1134 1074 1135 self.bttEdit.Enable() 1075 1136 self.bttCreateTemplate.Enable() … … 1110 1171 def OnLoadTemplate(self, evt): 1111 1172 dlg = wx.FileDialog(self, 1112 "Select template ofISO profile",1173 "Select metadata ISO profile", 1113 1174 self.mdDestination, 1114 1175 "", … … 1119 1180 self.jinjaPath = dlg.GetPath() 1120 1181 tx = self.statusBar.GetStatusText() 1121 self.statusBar.SetStatusText(tx + ' Selected template: ' + self.jinjaPath)1182 self.statusBar.SetStatusText(tx + ' Selected profile: ' + self.jinjaPath) 1122 1183 self.onChangeXmlorTemplate() 1123 1184 … … 1164 1225 def main(): 1165 1226 app = wx.App(False) 1166 frame =MdMainFrame()1227 MdMainFrame() 1167 1228 app.MainLoop() 1168 1229 -
grass-addons/grass7/gui/wxpython/wx.metadata/mdlib/mdgrass.py
r64001 r65349 21 21 from lxml import etree 22 22 import os 23 import sys 24 import re 23 25 24 import StringIO 26 import subprocess as sub27 25 import uuid 28 26 import 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 34 28 from grass.pygrass.modules import Module 35 29 from grass.script import parse_key_val 36 30 from subprocess import PIPE 37 31 from datetime import date, datetime 38 from grass.script import parser39 32 from grass.script import core as grass 40 33 … … 59 52 # suffix of output xml file (variables) 60 53 self.schema_type = '_basic.xml' 54 self.profileName='GRASS BASIC' 61 55 self.dirpath = os.path.join(os.getenv('GRASS_ADDON_BASE'), 'etc') 62 56 # metadata object from OWSLIB ( for define md values) 63 57 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": 67 62 self.parseRast() 68 63 elif self.type == "vector": … … 153 148 self.md_abstract.translate(None, """&<>"'""") 154 149 155 def createGrassBasicISO(self, template=None):150 def createGrassBasicISO(self, profile=None): 156 151 '''Create basic/essential profile based on ISO 157 152 - unknown values are filling by n = '$NULL' … … 164 159 n = '$NULL' 165 160 # 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') 168 163 else: 169 self. template = template164 self.profilePath = profile 170 165 171 166 # OWSLib md object … … 218 213 219 214 # different metadata sources for vector and raster 220 if self.type == ' cell':215 if self.type == 'raster': 221 216 # Identification/Resource Abstract 222 217 self.md.identification.abstract = mdutil.replaceXMLReservedChar(self.md_abstract) … … 254 249 self.md.identification.contact.append(val) 255 250 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): 259 254 '''Create valid INSPIRE profile and fill it as much as possible by GRASS metadata. Missing values is $NULL 260 255 -create basic md profile and add INSPIRE mandatory attributes … … 262 257 263 258 self.schema_type = '_inspire.xml' 259 self.profileName='INSPIRE' 264 260 265 261 # create basic profile 266 262 self.createGrassBasicISO() 267 263 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') 270 266 else: 271 self. template = template267 self.profilePath = profile 272 268 273 269 n = '$NULL' … … 319 315 self.md.identification.temporalextent_end = n 320 316 321 self.templatePathAbs = os.path.join(self.dirpath, self.template) 322 # print self.templatePathAbs 317 self.profilePathAbs = os.path.join(self.dirpath, self.profilePath) 323 318 324 319 def readXML(self, xml_file): 325 320 '''create instance of metadata(owslib) from xml file''' 326 321 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 327 329 328 330 def saveXML(self, path=None, xml_out_name=None, wxparent=None, overwrite=False): … … 341 343 path = os.path.join(path, xml_out_name) 342 344 343 # generate xml using jinja templates345 # generate xml using jinja profiles 344 346 env = Environment(loader=FileSystemLoader(self.dirpath)) 345 347 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) 348 350 349 351 # write xml to flat file 350 352 if wxparent != None: 351 353 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'): 353 355 try: 354 356 xml_file = open(path, "w") … … 441 443 if md.identification.contact is not None: 442 444 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') 449 451 450 452 if md.identification.title is not (None or ''): … … 485 487 486 488 #------------------------------------------------------------------------ RASTER 487 if self.type == " cell":489 if self.type == "raster": 488 490 489 491 if md.identification.title is not (None or ''): -
grass-addons/grass7/gui/wxpython/wx.metadata/r.info.iso/r.info.iso.html
r61661 r65349 21 21 metadata file is not specified by <b>output</b> option than the name 22 22 is built from map's type and its name. For raster maps, the prefix 23 derived from the current nomenclature is <em> cell</em>, for vector23 derived from the current nomenclature is <em>raster</em>, for vector 24 24 maps <em>vector</em>. File ends with <em>.xml</em> extension. 25 25 -
grass-addons/grass7/gui/wxpython/wx.metadata/r.info.iso/r.info.iso.py
r63999 r65349 58 58 destination, name = os.path.split(options['output']) 59 59 60 md = GrassMD(options['map'], ' cell')60 md = GrassMD(options['map'], 'raster') 61 61 if options['profile'] == 'inspire': 62 62 md.createGrassInspireISO() -
grass-addons/grass7/gui/wxpython/wx.metadata/v.info.iso/v.info.iso.html
r61661 r65349 21 21 metadata file is not specified by <b>output</b> option than the name 22 22 is built from map's type and its name. For raster maps, the prefix 23 derived from the current nomenclature is <em> cell</em>, for vector23 derived from the current nomenclature is <em>raster</em>, for vector 24 24 maps <em>vector</em>. File ends with <em>.xml</em> extension. 25 25
Note:
See TracChangeset
for help on using the changeset viewer.
