<s> from __future__ import ( absolute_import , division , print_function ) <EOL> import logging <EOL> import os <EOL> import sys <EOL> from owslib . etree import etree , ElementType <EOL> try : <EOL> from urllib . parse import urlparse <EOL> except ImportError : <EOL> from urlparse import urlparse <EOL> def setup_logging ( loglevel = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> logger = logging . getLogger ( '<STR_LIT>' ) <EOL> logger . setLevel ( getattr ( logging , loglevel ) ) <EOL> sh = logging . StreamHandler ( sys . stdout ) <EOL> formatter = logging . Formatter ( '<STR_LIT>' ) <EOL> sh . setFormatter ( formatter ) <EOL> logger . addHandler ( sh ) <EOL> return logger <EOL> def resource_file ( filepath ) : <EOL> return os . path . join ( test_directory ( ) , '<STR_LIT>' , filepath ) <EOL> def test_directory ( ) : <EOL> """<STR_LIT>""" <EOL> return os . path . dirname ( __file__ ) <EOL> def scratch_directory ( ) : <EOL> """<STR_LIT>""" <EOL> return os . path . join ( test_directory ( ) , '<STR_LIT>' ) <EOL> def scratch_file ( filename ) : <EOL> """<STR_LIT>""" <EOL> return os . path . join ( scratch_directory ( ) , filename ) <EOL> def compare_xml ( a , b ) : <EOL> if not isinstance ( a , ElementType ) : <EOL> a = etree . fromstring ( a ) <EOL> if not isinstance ( b , ElementType ) : <EOL> b = etree . fromstring ( b ) <EOL> return compare_elements ( a , b ) <EOL> def compare_elements ( a , b ) : <EOL> if a . tag != b . tag : <EOL> return False <EOL> if a . text != b . text : <EOL> return False <EOL> if sorted ( a . items ( ) ) != sorted ( b . items ( ) ) : <EOL> return False <EOL> if len ( list ( a ) ) != len ( list ( b ) ) : <EOL> return False <EOL> for ac , bc in zip ( list ( a ) , list ( b ) ) : <EOL> if not compare_elements ( ac , bc ) : <EOL> return False <EOL> return True <EOL> def cast_tuple_int_list ( tup ) : <EOL> """<STR_LIT>""" <EOL> return [ int ( a ) for a in tup ] <EOL> def cast_tuple_int_list_srs ( tup ) : <EOL> tup2 = cast_tuple_int_list ( tup [ : <NUM_LIT:4> ] ) <EOL> tup2 . append ( tup [ - <NUM_LIT:1> ] ) <EOL> return tup2 <EOL> def sorted_url_query ( url ) : <EOL> return sorted ( urlparse ( url ) . query . split ( "<STR_LIT:&>" ) ) </s>
