Skip to content

Commit 8c4b838

Browse files
authored
Merge pull request #76 from AndreMiras/feature/pep8_fixes
Various PEP8 fixes and test against py36
2 parents 26ddce5 + cadc298 commit 8c4b838

File tree

12 files changed

+29
-26
lines changed

12 files changed

+29
-26
lines changed

examples/clustered_geojson.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33

44
if __name__ == '__main__' and __package__ is None:
5-
from os import sys, path
5+
from os import path
66
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
77

88
from mapview import MapView, MapMarker

examples/map_with_marker_popup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from kivy.lang import Builder
44

55
if __name__ == '__main__' and __package__ is None:
6-
from os import sys, path
6+
from os import path
77
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
88

99
import mapview

examples/simple_geojson.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33

44
if __name__ == '__main__' and __package__ is None:
5-
from os import sys, path
5+
from os import path
66
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
77

88
from mapview import MapView, MapMarker

examples/simple_map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from kivy.base import runTouchApp
33

44
if __name__ == '__main__' and __package__ is None:
5-
from os import sys, path
5+
from os import path
66
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
77

88
from mapview import MapView, MapSource

examples/simple_mbtiles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from kivy.base import runTouchApp
1313

1414
if __name__ == '__main__' and __package__ is None:
15-
from os import sys, path
15+
from os import path
1616
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
1717
from mapview import MapView
1818
from mapview.mbtsource import MBTilesMapSource

mapview/clustered_marker_layer.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ def _within(self, ids, coords, qx, qy, r, node_size):
195195
result.append(ids[i])
196196
continue
197197

198-
199198
m = int(floor((left + right) / 2.))
200199

201200
x = coords[2 * m]
@@ -262,6 +261,7 @@ def __repr__(self):
262261
return "<Marker lon={} lat={} source={}>".format(self.lon, self.lat,
263262
self.source)
264263

264+
265265
class SuperCluster(object):
266266
"""Port of supercluster from mapbox in pure python
267267
"""
@@ -353,8 +353,10 @@ def _cluster(self, points, zoom):
353353
num_points2 = 1
354354
if isinstance(b, Cluster):
355355
num_points2 = b.num_points
356-
b.zoom = zoom # save the zoom (so it doesn't get processed twice)
357-
wx += b.x * num_points2 # accumulate coordinates for calculating weighted center
356+
# save the zoom (so it doesn't get processed twice)
357+
b.zoom = zoom
358+
# accumulate coordinates for calculating weighted center
359+
wx += b.x * num_points2
358360
wy += b.y * num_points2
359361
num_points += num_points2
360362
b.parent_id = i
@@ -372,6 +374,7 @@ class ClusterMapMarker(MapMarker):
372374
cluster = ObjectProperty()
373375
num_points = NumericProperty()
374376
text_color = ListProperty([.1, .1, .1, 1])
377+
375378
def on_cluster(self, instance, cluster):
376379
self.num_points = cluster.num_points
377380

mapview/geojson.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from kivy.graphics.tesselator import Tesselator, WINDING_ODD, TYPE_POLYGONS
2828
from kivy.utils import get_color_from_hex
2929
from kivy.metrics import dp
30-
from kivy.utils import get_color_from_hex
3130
from mapview import CACHE_DIR
3231
from mapview.view import MapLayer
3332
from mapview.downloader import Downloader

mapview/mbtsource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _load_tile(self, tile):
7575
# no-file loading
7676
try:
7777
data = io.BytesIO(row[0])
78-
except:
78+
except Exception:
7979
# android issue, "buffer" does not have the buffer interface
8080
# ie row[0] buffer is not compatible with BytesIO on Android??
8181
data = io.BytesIO(bytes(row[0]))

mapview/source.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class MapSource(object):
3030
"thunderforest-transport": (0, 0, 19, "http://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png", attribution_thunderforest),
3131
"thunderforest-landscape": (0, 0, 19, "http://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png", attribution_thunderforest),
3232
"thunderforest-outdoors": (0, 0, 19, "http://{s}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png", attribution_thunderforest),
33-
33+
3434
# no longer available
3535
#"mapquest-osm": (0, 0, 19, "http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpeg", "Tiles Courtesy of Mapquest", {"subdomains": "1234", "image_ext": "jpeg"}),
3636
#"mapquest-aerial": (0, 0, 19, "http://oatile{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpeg", "Tiles Courtesy of Mapquest", {"subdomains": "1234", "image_ext": "jpeg"}),
37-
37+
3838
# more to add with
3939
# https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js
4040
# not working ?
@@ -43,11 +43,11 @@ class MapSource(object):
4343
}
4444

4545
def __init__(self,
46-
url="http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
47-
cache_key=None, min_zoom=0, max_zoom=19, tile_size=256,
48-
image_ext="png",
49-
attribution="© OpenStreetMap contributors",
50-
subdomains="abc", **kwargs):
46+
url="http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
47+
cache_key=None, min_zoom=0, max_zoom=19, tile_size=256,
48+
image_ext="png",
49+
attribution="© OpenStreetMap contributors",
50+
subdomains="abc", **kwargs):
5151
super(MapSource, self).__init__()
5252
if cache_key is None:
5353
# possible cache hit, but very unlikely
@@ -91,7 +91,7 @@ def get_y(self, zoom, lat):
9191
"""
9292
lat = clamp(-lat, MIN_LATITUDE, MAX_LATITUDE)
9393
lat = lat * pi / 180.
94-
return ((1.0 - log(tan(lat) + 1.0 / cos(lat)) / pi) / \
94+
return ((1.0 - log(tan(lat) + 1.0 / cos(lat)) / pi) /
9595
2. * pow(2., zoom)) * self.dp_tile_size
9696

9797
def get_lon(self, zoom, x):

mapview/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
Coordinate = namedtuple("Coordinate", ["lat", "lon"])
88

9+
910
class Bbox(tuple):
1011
def collide(self, *args):
1112
if isinstance(args[0], Coordinate):

0 commit comments

Comments
 (0)