Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor cleanup #467

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/_themes/flask_theme_support.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# flasky extensions. flasky pygments style based on tango style
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Generic, Whitespace, Punctuation, Other, Literal
from pygments.token import (Comment, Error, Generic, Keyword, Literal, Name,
Number, Operator, Other, Punctuation, String,
Whitespace)


class FlaskyStyle(Style):
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down
75 changes: 35 additions & 40 deletions geocoder/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,68 @@

from __future__ import absolute_import

from geocoder.distance import Distance
from geocoder.location import Location

from geocoder.arcgis import ArcgisQuery
from geocoder.arcgis_reverse import ArcgisReverse
from geocoder.baidu import BaiduQuery
from geocoder.baidu_reverse import BaiduReverse
from geocoder.bing import BingQuery, BingQueryDetail
from geocoder.bing_batch_forward import BingBatchForward
from geocoder.bing_batch_reverse import BingBatchReverse
from geocoder.bing_reverse import BingReverse
from geocoder.canadapost import CanadapostQuery
from geocoder.distance import Distance
from geocoder.freegeoip import FreeGeoIPQuery
from geocoder.gaode import GaodeQuery
from geocoder.gaode_reverse import GaodeReverse
from geocoder.geocodefarm import GeocodeFarmQuery
from geocoder.geocodefarm_reverse import GeocodeFarmReverse
from geocoder.geolytica import GeolyticaQuery
# Geonames Services
from geocoder.geonames import GeonamesQuery
from geocoder.geonames_children import GeonamesChildren
from geocoder.geonames_details import GeonamesDetails
from geocoder.geonames_hierarchy import GeonamesHierarchy
from geocoder.gisgraphy import GisgraphyQuery
from geocoder.gisgraphy_reverse import GisgraphyReverse
# Google Services
from geocoder.google import GoogleQuery
from geocoder.google_elevation import ElevationQuery
from geocoder.google_places import PlacesQuery
from geocoder.google_reverse import GoogleReverse
from geocoder.google_timezone import TimezoneQuery
from geocoder.here import HereQuery
from geocoder.here_reverse import HereReverse
from geocoder.ipinfo import IpinfoQuery
from geocoder.komoot import KomootQuery
from geocoder.komoot_reverse import KomootReverse
from geocoder.location import Location
from geocoder.locationiq import LocationIQQuery
from geocoder.locationiq_reverse import LocationIQReverse
from geocoder.mapbox import MapboxQuery
from geocoder.mapbox_reverse import MapboxReverse
from geocoder.mapquest import MapquestQuery
from geocoder.mapquest_batch import MapquestBatch
from geocoder.mapquest_reverse import MapquestReverse
from geocoder.mapzen import MapzenQuery
from geocoder.mapzen_reverse import MapzenReverse
from geocoder.maxmind import MaxmindQuery
from geocoder.opencage import OpenCageQuery
from geocoder.opencage_reverse import OpenCageReverse
from geocoder.osm import OsmQuery, OsmQueryDetail
from geocoder.osm_reverse import OsmReverse
from geocoder.ottawa import OttawaQuery
from geocoder.tamu import TamuQuery
from geocoder.tomtom import TomtomQuery
from geocoder.tgos import TgosQuery
from geocoder.tomtom import TomtomQuery
from geocoder.uscensus import USCensusQuery
from geocoder.yahoo import YahooQuery
from geocoder.yandex import YandexQuery
from geocoder.w3w import W3WQuery

from geocoder.arcgis_reverse import ArcgisReverse
from geocoder.baidu_reverse import BaiduReverse
from geocoder.bing_reverse import BingReverse
from geocoder.gaode_reverse import GaodeReverse
from geocoder.geocodefarm_reverse import GeocodeFarmReverse
from geocoder.gisgraphy_reverse import GisgraphyReverse
from geocoder.here_reverse import HereReverse
from geocoder.locationiq_reverse import LocationIQReverse
from geocoder.komoot_reverse import KomootReverse
from geocoder.mapbox_reverse import MapboxReverse
from geocoder.mapquest_reverse import MapquestReverse
from geocoder.mapzen_reverse import MapzenReverse
from geocoder.opencage_reverse import OpenCageReverse
from geocoder.osm_reverse import OsmReverse
from geocoder.uscensus_batch import USCensusBatch
from geocoder.uscensus_reverse import USCensusReverse
from geocoder.w3w import W3WQuery
from geocoder.w3w_reverse import W3WReverse
from geocoder.yahoo import YahooQuery
from geocoder.yandex import YandexQuery
from geocoder.yandex_reverse import YandexReverse

from geocoder.mapquest_batch import MapquestBatch
from geocoder.bing_batch_forward import BingBatchForward
from geocoder.bing_batch_reverse import BingBatchReverse
from geocoder.uscensus_batch import USCensusBatch

# Geonames Services
from geocoder.geonames import GeonamesQuery
from geocoder.geonames_details import GeonamesDetails
from geocoder.geonames_children import GeonamesChildren
from geocoder.geonames_hierarchy import GeonamesHierarchy

# Google Services
from geocoder.google import GoogleQuery
from geocoder.google_timezone import TimezoneQuery
from geocoder.google_reverse import GoogleReverse
from geocoder.google_elevation import ElevationQuery
from geocoder.google_places import PlacesQuery

options = {
'osm': {
'geocode': OsmQuery,
Expand Down
4 changes: 2 additions & 2 deletions geocoder/arcgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# coding: utf8
from __future__ import absolute_import

import logging
import json
import logging

from geocoder.base import OneResult, MultipleResultsQuery
from geocoder.base import MultipleResultsQuery, OneResult


class ArcgisResult(OneResult):
Expand Down
2 changes: 1 addition & 1 deletion geocoder/arcgis_reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import logging

from geocoder.base import OneResult
from geocoder.arcgis import ArcgisQuery
from geocoder.base import OneResult
from geocoder.location import Location


Expand Down
9 changes: 5 additions & 4 deletions geocoder/baidu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

from __future__ import absolute_import

from collections import OrderedDict
import logging
import re
from collections import OrderedDict

import six

from geocoder.base import OneResult, MultipleResultsQuery
from geocoder.base import MultipleResultsQuery, OneResult
from geocoder.keys import baidu_key, baidu_security_key


Expand Down Expand Up @@ -96,9 +97,9 @@ def _sign_url(self, base_url, params, security_key):
import hashlib

if six.PY3:
from urllib.parse import urlencode, quote, quote_plus
from urllib.parse import quote, quote_plus, urlencode
else:
from urllib import urlencode, quote, quote_plus
from urllib import quote, quote_plus, urlencode

if not base_url or not self.security_key:
return None
Expand Down
4 changes: 2 additions & 2 deletions geocoder/baidu_reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import logging

from geocoder.location import Location
from geocoder.base import OneResult
from geocoder.baidu import BaiduQuery
from geocoder.base import OneResult
from geocoder.location import Location


class BaiduReverseResult(OneResult):
Expand Down
13 changes: 7 additions & 6 deletions geocoder/base.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/usr/bin/python
# coding: utf8
from __future__ import absolute_import, print_function
from builtins import str

import requests
import sys
import json
import six
import logging
from io import StringIO
import sys
from builtins import str
from collections import OrderedDict
from io import StringIO

import requests
import six

is_python2 = sys.version_info < (3, 0)

Expand All @@ -30,7 +31,7 @@ def __eq__(self, other): return self._list == other # noqa
from collections.abc import MutableSequence
from urllib.parse import urlparse

from geocoder.distance import Distance # noqa
from geocoder.distance import Distance # noqa

LOGGER = logging.getLogger(__name__)

Expand Down
6 changes: 4 additions & 2 deletions geocoder/bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
# coding: utf8

from __future__ import absolute_import
from geocoder.base import OneResult, MultipleResultsQuery
from geocoder.keys import bing_key

import re

from geocoder.base import MultipleResultsQuery, OneResult
from geocoder.keys import bing_key


class BingResult(OneResult):

Expand Down
10 changes: 6 additions & 4 deletions geocoder/bing_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
# coding: utf8

from __future__ import absolute_import, print_function
from geocoder.base import OneResult, MultipleResultsQuery
from geocoder.keys import bing_key

import time
import io
import requests
import logging
import sys
import time

import requests

from geocoder.base import MultipleResultsQuery, OneResult
from geocoder.keys import bing_key

PY2 = sys.version_info < (3, 0)
csv_io = io.BytesIO if PY2 else io.StringIO
Expand Down
5 changes: 3 additions & 2 deletions geocoder/bing_batch_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
# coding: utf8

from __future__ import absolute_import, print_function
from geocoder.bing_batch import BingBatch, BingBatchResult

import io
import csv
import io
import sys

from geocoder.bing_batch import BingBatch, BingBatchResult

PY2 = sys.version_info < (3, 0)
csv_io = io.BytesIO if PY2 else io.StringIO
csv_encode = (lambda input: input) if PY2 else (lambda input: input.encode('utf-8'))
Expand Down
5 changes: 3 additions & 2 deletions geocoder/bing_batch_reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
# coding: utf8

from __future__ import absolute_import, print_function
from geocoder.bing_batch import BingBatch, BingBatchResult

import io
import csv
import io
import sys

from geocoder.bing_batch import BingBatch, BingBatchResult

PY2 = sys.version_info < (3, 0)
csv_io = io.BytesIO if PY2 else io.StringIO
csv_encode = (lambda input: input) if PY2 else (lambda input: input.encode('utf-8'))
Expand Down
3 changes: 2 additions & 1 deletion geocoder/bing_reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# coding: utf8

from __future__ import absolute_import
from geocoder.bing import BingResult, BingQuery

from geocoder.bing import BingQuery, BingResult
from geocoder.location import Location


Expand Down
2 changes: 1 addition & 1 deletion geocoder/canadapost.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import logging

from geocoder.base import OneResult, MultipleResultsQuery
from geocoder.base import MultipleResultsQuery, OneResult
from geocoder.keys import canadapost_key_getter


Expand Down
8 changes: 4 additions & 4 deletions geocoder/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

from __future__ import absolute_import

import click
import fileinput
import json
import geocoder
import os
import fileinput

from geocoder.api import options
import click

import geocoder
from geocoder.api import options

providers = sorted(options.keys())
methods = ['geocode', 'reverse', 'elevation', 'timezone', 'places']
Expand Down
4 changes: 3 additions & 1 deletion geocoder/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# coding: utf8

from __future__ import absolute_import
from math import radians, cos, sin, asin, sqrt

from math import asin, cos, radians, sin, sqrt

from geocoder.location import Location

AVG_EARTH_RADIUS = 6371 # in km
Expand Down
5 changes: 3 additions & 2 deletions geocoder/freegeoip.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
from __future__ import absolute_import

import logging
import requests

import ratelim
import requests

from geocoder.base import OneResult, MultipleResultsQuery
from geocoder.base import MultipleResultsQuery, OneResult


class FreeGeoIPResult(OneResult):
Expand Down
2 changes: 1 addition & 1 deletion geocoder/gaode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import logging

from geocoder.base import OneResult, MultipleResultsQuery
from geocoder.base import MultipleResultsQuery, OneResult
from geocoder.keys import gaode_key


Expand Down
2 changes: 1 addition & 1 deletion geocoder/gaode_reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import logging

from geocoder.location import Location
from geocoder.base import OneResult
from geocoder.gaode import GaodeQuery
from geocoder.location import Location


class GaodeReverseResult(OneResult):
Expand Down
2 changes: 1 addition & 1 deletion geocoder/geocodefarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import logging

from geocoder.base import OneResult, MultipleResultsQuery
from geocoder.base import MultipleResultsQuery, OneResult
from geocoder.keys import geocodefarm_key


Expand Down
2 changes: 1 addition & 1 deletion geocoder/geocodefarm_reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import logging

from geocoder.location import Location
from geocoder.geocodefarm import GeocodeFarmQuery
from geocoder.location import Location


class GeocodeFarmReverse(GeocodeFarmQuery):
Expand Down
Loading