File tree 2 files changed +14
-8
lines changed
2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -37,12 +37,12 @@ Download the tarball, untar and run `python setup.py install`
37
37
The following returns the information as a python object
38
38
"""
39
39
pylocinfo = pyloc.info
40
- pylocinfo.ip => '8.8.8.8'
41
- pylocinfo.city => 'Mountain View, CA'
42
- pylocinfo.country_name => 'UNITED STATES'
43
- pylocinfo.country_code => 'US'
44
- pylocinfo.latitude => ' 37.402'
45
- pylocinfo.longitude => ' -122.078'
40
+ print pylocinfo.ip # '8.8.8.8'
41
+ print pylocinfo.city # 'Mountain View, CA'
42
+ print pylocinfo.country_name # 'UNITED STATES'
43
+ print pylocinfo.country_code # 'US'
44
+ print pylocinfo.latitude # 37.402
45
+ print pylocinfo.longitude # -122.078
46
46
47
47
48
48
"""
Original file line number Diff line number Diff line change @@ -53,8 +53,14 @@ def __init__(self, properties):
53
53
self .city = properties ['city' ]
54
54
self .country_name = properties ['country_name' ]
55
55
self .country_code = properties ['country_code' ]
56
- self .latitude = properties .get ('lat' , None )
57
- self .longitude = properties .get ('lng' , None )
56
+ self .latitude = None
57
+ self .longitude = None
58
+ latitude = properties .get ('lat' , None )
59
+ if latitude :
60
+ self .latitude = float (latitude )
61
+ longitude = properties .get ('lng' , None )
62
+ if latitude :
63
+ self .longitude = float (longitude )
58
64
59
65
class PyLocation (object ):
60
66
"""The :class `PyLocation` object. Used to perform the various operations
You can’t perform that action at this time.
0 commit comments