Skip to content

Commit

Permalink
PEP8: fix flake8 errors (#290)
Browse files Browse the repository at this point in the history
PEP8: fix flake8 errors
  • Loading branch information
neteler committed Sep 30, 2020
1 parent 0176e9a commit ab5780c
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def harvest(source, dst):
for i in list(src.records):
source = '%s?service=CSW&version=2.0.2&request=GetRecordById&id=%s' % \
(sys.argv[1], i)
dest.harvest(source=source, \
dest.harvest(source=source,
resourcetype='http://www.isotc211.org/2005/gmd')
#print dest.request
#print dest.response
Expand Down
22 changes: 11 additions & 11 deletions grass7/gui/wxpython/wx.metadata/g.gui.metadata/g.gui.metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ def _initTreeItems(self, locations = [], mapsets = []):
ltype = parts1[0]

# add mapset
if self.itemExists(mapset, varloc) == False:
if self.itemExists(mapset, varloc) is False:
varmapset = self.AppendItem(varloc, mapset)
else:
varmapset = self.getItemByName(mapset, varloc)

# add type node if not exists
if self.itemExists(ltype, varmapset) == False:
if self.itemExists(ltype, varmapset) is False:
vartype = self.AppendItem(varmapset, ltype)

self.AppendItem(vartype, mlayer)
Expand All @@ -158,7 +158,7 @@ def _initVariables(self):
self.selected_mapset = None
self.selected_location = None

self.gisdbase = grass.gisenv()['GISDBASE']
self.gisdbase = grass.gisenv()['GISDBASE']
self.ctrldown = False

def GetControl(self):
Expand Down Expand Up @@ -220,7 +220,7 @@ def OnRightClick(self, event):
self.DefineItems(event.GetItem())
if(self.selected_layer):
self._popupMenuLayer()
elif(self.selected_mapset and self.selected_type==None):
elif(self.selected_mapset and self.selected_type is None):
self._popupMenuMapset()

def OnDoubleClick(self, event):
Expand Down Expand Up @@ -687,11 +687,11 @@ def exportPDF(self, outPath, outFileName):
self.initNewMD()
pdfFile = os.path.join(outPath, outFileName)

if self.mdCreator is None and self.extendEdit: #if editing map from grass database
if self.mdCreator is None and self.extendEdit: # if editing map from grass database
profileName = os.path.basename(self.jinjaPath)
xmlFile = os.path.basename(self.xmlPath)
doc = PdfCreator(self.md, pdfFile, map=None, type=None, filename=xmlFile, profile=profileName)
else: #if editing map from external editor
else: # if editing map from external editor
filename, type, map, profile = self.mdCreator.getMapInfo()
doc = PdfCreator(self.md, pdfFile, map, type, filename, profile)
try:
Expand Down Expand Up @@ -746,9 +746,9 @@ def setTemplateEditorPath(self, value, template=None):
'''Setup name of temporal template
'''
self.templateEditor = value
if template == None:
if template is None:
self.nameTMPteplate = 'TMPtemplate'
if template == False:
elif template is False:
self.nameTMPteplate = None

def initNewMD(self):
Expand Down Expand Up @@ -866,7 +866,7 @@ def editMapMetadata(self, multipleEditing=False):
self.mdCreator = mdgrass.GrassMD(self.ListOfMapTypeDict[-1][list(self.ListOfMapTypeDict[-1].keys())[0]],
list(self.ListOfMapTypeDict[-1].keys())[0])

if self.chckProfileSelection('temporal'): #if map is temporal, use temporal md pareser
if self.chckProfileSelection('temporal'): # if map is temporal, use temporal md pareser
self.mdCreator.createTemporalISO()
else:
self.mdCreator.createGrassInspireISO()
Expand Down Expand Up @@ -1167,7 +1167,7 @@ def initTemporalTree(self, location, mapset):
try:
for ml in allDatasets:
# add mapset
if ml[1] == mapset:#chck current mapset
if ml[1] == mapset: # chck current mapset
it = self.itemExists(ml[1], varloc)
if it is False:
varmapset = it
Expand All @@ -1182,7 +1182,7 @@ def initTemporalTree(self, location, mapset):
self.AppendItem(vartype, ml[0])

except Exception as e:
GError('Initialize of temporal tree catalogue error: < %s >'%e)
GError('Initialize of temporal tree catalogue error: < %s >' % e)

self.Bind(wx.EVT_TREE_SEL_CHANGED, self.onChanged)
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.onChanged)
Expand Down
8 changes: 4 additions & 4 deletions grass7/gui/wxpython/wx.metadata/m.csw.update/m.csw.update.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def __init__(
spreadsheet_file_url, data_theme='Geospatial',
csw_timeout=10, separator=': ', print_info=False,
print_summary_info=False, active_csw_url=False,
not_active_csw_url=False, valid_csw_url=False,
not_active_csw_url=False, valid_csw_url=False,
not_valid_csw_url=False, valid_xml=False,
active_xml_csw_url=False, not_valid_xml_csw_url=False,
):
Expand Down Expand Up @@ -418,7 +418,7 @@ def _data_theme(self, value):
"Param \'data_theme\' args is not allowed value, "
"allowed values are: {}".format(
', '.join(self.data_theme_opts),
),
),
),
)
self.__data_theme = value
Expand Down Expand Up @@ -799,7 +799,7 @@ def _check_active_xml_csw_url(self):
not_active_csw.append(
"Number of non active csw{count:.>35}\n".format(
count=len(not_active_csw),
),
),
)
sys.stdout.write(''.join(not_active_csw))

Expand Down Expand Up @@ -840,7 +840,7 @@ def _check_not_valid_xml_csw_url(self):
not_valid_csw_urls.append(
"Number of non valid csw urls{count:.>32}\n".format(
count=len(not_valid_csw_urls),
),
),
)
sys.stdout.write(''.join(not_valid_csw_urls))

Expand Down
6 changes: 4 additions & 2 deletions grass7/gui/wxpython/wx.metadata/mdlib/cswlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ def OnShowReguest(self, evt):
# request_html = encodeString(highlight_xml(self.context, self.catalog.request,False))
path = os.path.join(tempfile.gettempdir(), 'htmlRequest.xml')
request = grass.decode(self.catalog.request)
if os.path.exists(path): os.remove(path)
if os.path.exists(path):
os.remove(path)
f = open(path, 'w')
f.writelines(request)
f.close()
Expand All @@ -311,7 +312,8 @@ def OnShowResponse(self, evt):
# response_html = encodeString(highlight_xml(self.context, self.catalog.response,False))
path = os.path.join(tempfile.gettempdir(), 'htmlResponse.xml')
response = grass.decode(self.catalog.response)
if os.path.exists(path): os.remove(path)
if os.path.exists(path):
os.remove(path)
f = open(path, 'w')
f.write(response)
f.close()
Expand Down
2 changes: 1 addition & 1 deletion grass7/gui/wxpython/wx.metadata/mdlib/cswutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pygments.lexers import XmlLexer
from pygments.formatters import HtmlFormatter

def get_connections_from_file( filename):
def get_connections_from_file(filename):
"""load connections from connection file"""

error = 0
Expand Down
31 changes: 16 additions & 15 deletions grass7/gui/wxpython/wx.metadata/mdlib/mdeditorfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def saveToXML(self, md, owsTagList, jinjaPath, outPath=None, xmlOutName=None, ms
io.write(str1)
io.close()
except Exception as err:
print("WARNING: Cannot check and remove non ascii characters from template err:< %s >"%err)
print("WARNING: Cannot check and remove non ascii characters from template err:< %s >" % err)

# generating xml using jinja templates
head, tail = os.path.split(jinjaPath)
Expand Down Expand Up @@ -226,7 +226,7 @@ def addItems(self, items, multi=True, rmMulti=False, isFirstNum=-1):

def addDuplicatedItem(self, item):
self.stBoxSizer.Add(
item, proportion=1, flag=wx.EXPAND | wx.BOTTOM, border=5,
item, proportion=1, flag=wx.EXPAND | wx.BOTTOM, border=5,
)
self.GetParent().Layout()

Expand Down Expand Up @@ -488,6 +488,7 @@ def fillComboDB(self,label):
self.valueCtrl=wx.ComboBox(self.parent, id=wx.ID_ANY,)
for lng in lang:
self.valueCtrl.Append(lng)

def validators(self, validationStyle):

if validationStyle == 'email':
Expand Down Expand Up @@ -803,7 +804,7 @@ def __init__(self,parent,mdObject,mdOWS):
self.comboKeysLabel=wx.StaticText(parent=self.parent,id=ID_ANY,label='Keywords from repositories')
self.comboKeys=wx.ComboBox(parent=self.parent, id=ID_ANY)

self.keysList=wx.TreeCtrl(parent=self.parent, id=ID_ANY,size=(0, 120),style=wx.TR_FULL_ROW_HIGHLIGHT|wx.TR_DEFAULT_STYLE)
self.keysList=wx.TreeCtrl(parent=self.parent, id=ID_ANY, size=(0, 120), style=wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_DEFAULT_STYLE)
self.box=MdBoxKeywords(parent=parent,parent2=self,label='Keywords')
self.memKeys=set()
self.comboKeys.Bind(wx.EVT_COMBOBOX,self.onSetVocabulary)
Expand Down Expand Up @@ -852,7 +853,7 @@ def GetKws(self):

def fillDb(self):
if not mdutil.isTableExists(self._table_name):
sql = "create table if not exists {table} " \
sql = "create table if not exists {table} " \
"(title TEXT, keyword TEXT, date_iso TEXT, " \
"date_type TEXT)".format(
table=self._table_name,
Expand Down Expand Up @@ -882,7 +883,7 @@ def fillDb(self):
date_type='publication',
)

sql = "INSERT INTO '{table}' " \
sql = "INSERT INTO '{table}' " \
"('title', 'keyword', 'date_iso', " \
"'date_type') VALUES {values};".format(
table=self._table_name,
Expand All @@ -892,7 +893,7 @@ def fillDb(self):

def fillKeywordsList(self):
sql = "SELECT title ,keyword, date_iso, date_type FROM {}".format(
self._table_name,
self._table_name,
)

#TODO check if database exist
Expand All @@ -905,8 +906,8 @@ def fillKeywordsList(self):
#lines.pop()
for line in lines:
line=line.split('|')
if theme != line[0]: #if new theme found
if titleTmp is not None:#first loop
if theme != line[0]: # if new theme found
if titleTmp is not None: # first loop
self.titles[titleTmp]=self.keysDict
theme=line[0]
self.keysDict={}
Expand Down Expand Up @@ -979,7 +980,7 @@ def __init__(self, parent, profilePath, xmlMdPath, templateEditor=False):
self.generateGUI()
self._layout()

#----------------------------------------------------------- GUI GENERATOR START
#----------------------------------------------------------- GUI GENERATOR START
def executeStr(self, stri, mdDescrObj):
'''note- exec cannot be in sub function
for easy understanding to product of self.generateGUI()- print stri
Expand Down Expand Up @@ -1101,10 +1102,10 @@ def inBlock():
str1 += '\t' + 'self.mdDescription[' + str(self.c) + "].addStatements('" + loop + "')\n"

if box:
str1 += '\t' + \
str1 += '\t' + \
'it=MdItem(parent=box,item=mdDescrObj[' + str(self.c) + '],isFirstNum=numOfSameBox,chckBox=self.templateEditor)\n'
else:
str1 += '\t' + \
str1 += '\t' + \
'it=MdItem(parent=self.nbPage,item=mdDescrObj[' + str(self.c) + '],isFirstNum=numOfSameBox,chckBox=self.templateEditor)\n'

if self.isValidS: # if metadata are loaded to owslib
Expand Down Expand Up @@ -1263,19 +1264,19 @@ def defineTemplate(self):
str1 = item.selfInfoString
if str1 in line: # owslib definition in line
try:
if item.mdItem[0].isChecked == False:
if not item.mdItem[0].isChecked:
chcked = False
except:
try:
if self.mdDescription[r + 1].mdItem[0].isChecked == False:
if self.mdDescription[r + 1].mdItem[0].isChecked is False:
chcked = False
except:
try:
if self.mdDescription[r + 2].mdItem[0].isChecked == False:
if self.mdDescription[r + 2].mdItem[0].isChecked is False:
chcked = False
except:
try:
if self.mdDescription[r + 3].mdItem[0].isChecked == False:
if self.mdDescription[r + 3].mdItem[0].isChecked is False:
chcked = False
except:
pass
Expand Down
17 changes: 9 additions & 8 deletions grass7/gui/wxpython/wx.metadata/mdlib/mdgrass.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
@author Matej Krejci <matejkrejci gmail.com> (GSoC 2014)
"""
import sys,os
import sys
import os
try:
from owslib.iso import *
except:
Expand Down Expand Up @@ -53,7 +54,7 @@ def __init__(self, map, type):
self.map = map
self.type = type

# function to check if map exist
# function to check if map exist
self.md_grass = {}
self.md_abstract = ''
self.md_vinfo_h = '' # v.info flag=h" - parse
Expand Down Expand Up @@ -219,13 +220,13 @@ def wkt2standards(self,prj_txt):
try:
from osgeo import osr
except Exception as e:
grass.message('GDAL python library is not installed: %s \n identifying of EPSG is disabled'%e)
grass.message('GDAL python library is not installed: %s \n identifying of EPSG is disabled' % e)
return None

srs = osr.SpatialReference()
srs.ImportFromESRI([prj_txt])
srs.AutoIdentifyEPSG()
try :
try:
int(srs.GetAuthorityCode(None))
return srs.GetAuthorityCode(None)
except:
Expand All @@ -239,7 +240,7 @@ def createTemporalISO(self, profile=None):
n = '$NULL'
# jinja templates
if profile is None:
self.profilePath = 'temporalProfile.xml'
self.profilePath = 'temporalProfile.xml'
else:
self.profilePath = profile
self.schema_type = '_temporal.xml'
Expand Down Expand Up @@ -318,7 +319,7 @@ def createGrassBasicISO(self, profile=None):
n = '$NULL'
# jinja templates
if profile is None:
self.profilePath = 'basicProfile.xml'
self.profilePath = 'basicProfile.xml'
else:
self.profilePath = profile

Expand Down Expand Up @@ -361,7 +362,7 @@ def createGrassBasicISO(self, profile=None):
epsg=self.getEPSG()
if epsg is not None:
self.md.referencesystem=MD_ReferenceSystem(None)
self.md.referencesystem.code='http://www.opengis.net/def/crs/EPSG/0/%s'%epsg
self.md.referencesystem.code = 'http://www.opengis.net/def/crs/EPSG/0/%s' % epsg

#print self.md.referencesystem.code
# Conformity/Date:
Expand Down Expand Up @@ -514,7 +515,7 @@ def saveXML(self, path=None, xml_out_name=None, wxparent=None, overwrite=False):
iso_xml = profile.render(md=self.md)

# write xml to flat file
if wxparent != None:
if wxparent is not None:
if os.path.isfile(path):
if mdutil.yesNo(wxparent, 'Metadata file exists. Do you want to overwrite metadata file: %s?' % path, 'Overwrite dialog'):
try:
Expand Down
1 change: 1 addition & 0 deletions grass7/gui/wxpython/wx.metadata/mdlib/mdjinjaparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class JinjaTemplateParser():

'''Parser of OWSLib tag and init. values of jinjainfo::MdDescription from jinja template.
'''

def __init__(self, template):
'''
@var mdDescription: list of jinjainfo::mdDescription
Expand Down
Loading

0 comments on commit ab5780c

Please sign in to comment.