<s> GEO_INTERFACE_MARKER = "<STR_LIT>" <EOL> def is_mapping ( ob ) : <EOL> return hasattr ( ob , "<STR_LIT>" ) <EOL> def to_mapping ( ob ) : <EOL> if hasattr ( ob , GEO_INTERFACE_MARKER ) : <EOL> candidate = ob . __geo_interface__ <EOL> candidate = to_mapping ( candidate ) <EOL> else : <EOL> candidate = ob <EOL> if not is_mapping ( candidate ) : <EOL> msg = "<STR_LIT>" <EOL> msg %= ( GEO_INTERFACE_MARKER , ob ) <EOL> raise ValueError ( msg ) <EOL> return Mapping ( candidate ) <EOL> class Mapping ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , ob ) : <EOL> super ( Mapping , self ) . __init__ ( ) <EOL> self . _ob = ob <EOL> def __contains__ ( self , name ) : <EOL> return bool ( self . get ( name ) ) <EOL> def __getitem__ ( self , key ) : <EOL> return self . _ob [ key ] <EOL> def __iter__ ( self ) : <EOL> return iter ( self . _ob ) <EOL> def __len__ ( self ) : <EOL> return len ( self . _ob ) <EOL> def keys ( self ) : <EOL> return list ( self . _ob ) <EOL> def get ( self , key , default = None ) : <EOL> try : <EOL> value = self . _ob [ key ] <EOL> except KeyError : <EOL> value = default <EOL> return value <EOL> def update ( self , other ) : <EOL> for key in other : <EOL> if not key in self : <EOL> self [ key ] = other [ key ] </s>
