Commits

Lars Yencken committed 610145b

Style linting.

Comments (0)

Files changed (1)

 import requests
 import BeautifulSoup
 
+
 class Location(namedtuple('Location', 'latitude longitude')):
     precision = None
+
     @classmethod
     def set_precision(klass, digits):
         klass.precision = digits
 
 LOCATION_STRATEGIES = OrderedDict()
 
+
 # Important, define strategies in default resolution order
 def location_strategy(name):
     def _(fn):
         LOCATION_STRATEGIES[name] = fn
     return _
 
+
 class LocationServiceException(Exception):
     pass
 
 
         if not m.locationServicesEnabled():
             raise LocationServiceException(
-                    'location services not enabled -- check privacy settings in System Preferences'  # noqa
+                    'location services not enabled -- check privacy settings in System Preferences'  # nopep8
                 )
 
         if not m.locationServicesAvailable():
         c = l.coordinate()
         return Location(c.latitude, c.longitude)
 
+
 @location_strategy("geoip")
 def geobytes_location(timeout=DEFAULT_TIMEOUT):
     external_ip = requests.get('http://jsonip.com/').json['ip']
         raise LocationServiceException('timeout fetching geoip location')
     try:
         s = BeautifulSoup.BeautifulSoup(resp.content)
-        latitude = float(s.find('td',
-            text='Latitude').parent.findNext('input')['value'])
-        longitude = float(s.find('td',
-            text='Longitude').parent.findNext('input')['value'])
+        latitude = float(s.find(
+                'td',
+                text='Latitude',
+            ).parent.findNext('input')['value'])
+        longitude = float(s.find(
+                'td', text='Longitude'
+            ).parent.findNext('input')['value'])
     except Exception:
         raise LocationServiceException('error parsing geobytes page')
 
 """%prog [options]
 
 Use CoreServices to find your current geolocation as latitude and longitude
-coordinates. Exits with status code 1 on failure."""
+coordinates. Exits with status code 1 on failure."""  # nopep8
 
     parser = optparse.OptionParser(usage)
-    parser.add_option('--timeout', action='store', dest='timeout',
-            type='float', default=DEFAULT_TIMEOUT,
+    parser.add_option('--timeout', action='store', type='float',
+            default=DEFAULT_TIMEOUT,
             help='Time to keep trying for if no location is found.')
-    parser.add_option('--quiet', action='store_true', dest='quiet',
+    parser.add_option('--quiet', action='store_true',
             help='Suppress any error messages.')
     parser.add_option('--show', action='store_true',
             help='Show result on Google Maps in a browser.')
     parser.add_option('-f', '--force', action='store_true', dest='force',
             help='Continue trying strategies if the first should fail')
     parser.add_option('--strategy', action='store', dest='strategy',
-            help='Strategy for location lookup (corelocation|geoip)', default=LOCATION_STRATEGIES.keys()[0])
-    parser.add_option('--precision', action='store', dest='precision', type=int,
-            help='Store geodata with <precision> significant digits', default=None)
+            help='Strategy for location lookup (corelocation|geoip)',
+            default=LOCATION_STRATEGIES.keys()[0])
+    parser.add_option('--precision', action='store', dest='precision',
+            type=int,
+            help='Store geodata with <precision> significant digits')
 
     return parser
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.