Skip to content

Commit 6648c11

Browse files
committed
kmlread.py: flake8 correctness
1 parent dbd82bb commit 6648c11

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

MAVProxy/modules/lib/kmlread.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
#!/usr/bin/env python3
22

3+
'''
4+
AP_FLAKE8_CLEAN
5+
'''
6+
7+
38
import lxml.etree as etree
49
from io import BytesIO as SIO
510
from zipfile import ZipFile
611
import pathlib
712

813
namespaces = {'kml': 'http://www.opengis.net/kml/2.2'}
914

15+
1016
def readkmz(filename):
1117
'''reads in a kmz file and returns xml nodes'''
12-
#Strip quotation marks if neccessary
18+
# Strip quotation marks if neccessary
1319
filename.strip('"')
14-
#Open the zip file (as applicable)
20+
# Open the zip file (as applicable)
1521
suffix = pathlib.Path(filename).suffix
1622
if suffix.lower() == '.kml':
1723
fo = open(filename, "rb")
1824
fstring = fo.read()
1925
fo.close()
2026
elif suffix.lower() == '.kmz':
21-
zip=ZipFile(filename)
27+
zip = ZipFile(filename)
2228
fstring = None
2329
for z in zip.filelist:
2430
if z.filename[-4:] == '.kml':
25-
fstring=zip.read(z)
31+
fstring = zip.read(z)
2632
break
2733
if fstring is None:
2834
raise Exception("Could not find kml file in %s" % filename)
@@ -35,12 +41,14 @@ def readkmz(filename):
3541

3642
return tree.findall(xpath, namespaces)
3743

44+
3845
def find_tag(node, tagname):
3946
for c in node.getchildren():
4047
if c.tag == "{" + namespaces['kml'] + "}" + tagname:
4148
return c
4249
return None
4350

51+
4452
def find_tag_recursive(node, tagname):
4553
for c in node.getchildren():
4654
if c.tag == "{" + namespaces['kml'] + "}" + tagname:
@@ -54,7 +62,7 @@ def find_tag_recursive(node, tagname):
5462

5563
def readObject(innode):
5664
'''reads in a node and returns as a tuple: (type, name, points[])'''
57-
#get name
65+
# get name
5866
name = find_tag(innode, 'name')
5967
if name is None:
6068
return None
@@ -76,6 +84,7 @@ def readObject(innode):
7684

7785
return ('Unknown', None, None)
7886

87+
7988
if __name__ == '__main__':
8089
import sys
8190
nodes = readkmz(sys.argv[1])

0 commit comments

Comments
 (0)