<s> from __future__ import absolute_import <EOL> from geocoder . base import Base <EOL> class Maxmind ( Base ) : <EOL> """<STR_LIT>""" <EOL> provider = '<STR_LIT>' <EOL> method = '<STR_LIT>' <EOL> def __init__ ( self , location , ** kwargs ) : <EOL> if location : <EOL> self . location = location <EOL> else : <EOL> self . location = '<STR_LIT>' <EOL> self . headers = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> self . params = { '<STR_LIT>' : <NUM_LIT:1> } <EOL> self . url = '<STR_LIT>' . format ( self . location ) <EOL> self . _initialize ( ** kwargs ) <EOL> def _catch_errors ( self ) : <EOL> error = self . content . get ( '<STR_LIT:error>' ) <EOL> if error : <EOL> code = self . content . get ( '<STR_LIT:code>' ) <EOL> self . error = code <EOL> def _exceptions ( self ) : <EOL> subdivisions = self . content . get ( '<STR_LIT>' ) <EOL> if subdivisions : <EOL> self . content [ '<STR_LIT>' ] = subdivisions [ <NUM_LIT:0> ] <EOL> for key , value in self . content . items ( ) : <EOL> if isinstance ( value , dict ) : <EOL> for minor_key , minor_value in value . items ( ) : <EOL> if minor_key == '<STR_LIT>' : <EOL> self . parse [ key ] = minor_value [ '<STR_LIT>' ] <EOL> @ property <EOL> def lat ( self ) : <EOL> return self . parse [ '<STR_LIT:location>' ] . get ( '<STR_LIT>' ) <EOL> @ property <EOL> def lng ( self ) : <EOL> return self . parse [ '<STR_LIT:location>' ] . get ( '<STR_LIT>' ) <EOL> @ property <EOL> def address ( self ) : <EOL> if self . city : <EOL> return '<STR_LIT>' . format ( self . city , self . state , self . country ) <EOL> elif self . state : <EOL> return '<STR_LIT>' . format ( self . state , self . country ) <EOL> elif self . country : <EOL> return '<STR_LIT>' . format ( self . country ) <EOL> else : <EOL> return '<STR_LIT>' <EOL> @ property <EOL> def domain ( self ) : <EOL> return self . parse [ '<STR_LIT>' ] . get ( '<STR_LIT>' ) <EOL> @ property <EOL> def isp ( self ) : <EOL> return self . parse [ '<STR_LIT>' ] . get ( '<STR_LIT>' ) <EOL> @ property <EOL> def postal ( self ) : <EOL> return self . parse [ '<STR_LIT>' ] . get ( '<STR_LIT:code>' ) <EOL> @ property <EOL> def city ( self ) : <EOL> return self . parse . get ( '<STR_LIT>' ) <EOL> @ property <EOL> def state ( self ) : <EOL> return self . parse . get ( '<STR_LIT>' ) <EOL> @ property <EOL> def country ( self ) : <EOL> return self . parse . get ( '<STR_LIT>' ) <EOL> @ property <EOL> def continent ( self ) : <EOL> return self . parse . get ( '<STR_LIT>' ) <EOL> @ property <EOL> def ip ( self ) : <EOL> return self . parse [ '<STR_LIT>' ] . get ( '<STR_LIT>' ) <EOL> @ property <EOL> def timezone ( self ) : <EOL> return self . parse [ '<STR_LIT:location>' ] . get ( '<STR_LIT>' ) <EOL> @ property <EOL> def metro_code ( self ) : <EOL> return self . parse [ '<STR_LIT:location>' ] . get ( '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> g = Maxmind ( '<STR_LIT>' ) <EOL> g . debug ( ) </s>
