#NEWLINE# def get_timezone_location( dt_or_tzinfo = None , locale = LC_TIME ) : #NEWLINE# #INDENT# 'Return a representation of the given timezone using "location format".\n    \n    The result depends on both the local display name of the country and the\n    city associated with the time zone:\n    \n    >>> from pytz import timezone\n    >>> tz = timezone(\'America/St_Johns\')\n    >>> get_timezone_location(tz, locale=\'de_DE\')\n    u"Kanada (St. John\'s)"\n    >>> tz = timezone(\'America/Mexico_City\')\n    >>> get_timezone_location(tz, locale=\'de_DE\')\n    u\'Mexiko (Mexiko-Stadt)\'\n    \n    If the timezone is associated with a country that uses only a single\n    timezone, just the localized country name is returned:\n    \n    >>> tz = timezone(\'Europe/Berlin\')\n    >>> get_timezone_name(tz, locale=\'de_DE\')\n    u\'Deutschland\'\n    \n    :param dt_or_tzinfo: the ``datetime`` or ``tzinfo`` object that determines\n                         the timezone; if `None`, the current date and time in\n                         UTC is assumed\n    :param locale: the `Locale` object, or a locale string\n    :return: the localized timezone name using location format\n    :rtype: `unicode`\n    :since: version 0.9\n    ' #NEWLINE# if ( ( dt_or_tzinfo is None ) or isinstance ( dt_or_tzinfo , ( int , long ) ) ) : #NEWLINE# #INDENT# dt = None #NEWLINE# tzinfo = UTC #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( dt_or_tzinfo , ( datetime , time ) ) : #NEWLINE# #INDENT# dt = dt_or_tzinfo #NEWLINE# if ( dt . tzinfo is not None ) : #NEWLINE# #INDENT# tzinfo = dt . tzinfo #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# tzinfo = UTC #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# dt = None #NEWLINE# tzinfo = dt_or_tzinfo #NEWLINE# #UNINDENT# #UNINDENT# locale = Locale . parse ( locale ) #NEWLINE# if hasattr ( tzinfo , 'zone' ) : #NEWLINE# #INDENT# zone = tzinfo . zone #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# zone = tzinfo . tzname ( ( dt or datetime . utcnow ( ) ) ) #NEWLINE# #UNINDENT# zone = get_global ( 'zone_aliases' ) . get ( zone , zone ) #NEWLINE# info = locale . time_zones . get ( zone , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# region_format = region_format . zone_formats [ 'region' ] #NEWLINE# territory = get_global ( 'zone_territories' ) . get ( zone ) #NEWLINE# if ( territory not in locale . territories ) : #NEWLINE# #INDENT# territory = 'ZZ' #NEWLINE# #UNINDENT# territory_name = locale . territories [ territory ] #NEWLINE# if ( territory and ( len ( get_global ( 'territory_zones' ) . get ( territory , [ ] ) ) == 1 ) ) : #NEWLINE# #INDENT# return ( region_format % territory_name ) #NEWLINE# #UNINDENT# fallback_format = locale . zone_formats [ 'fallback' ] #NEWLINE# if ( 'city' in info ) : #NEWLINE# #INDENT# city_name = info [ 'city' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# metazone = get_global ( 'meta_zones' ) . get ( zone ) #NEWLINE# metazone_info = locale . meta_zones . get ( metazone , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( 'city' in metazone_info ) : #NEWLINE# #INDENT# city_name = metainfo [ 'city' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( '/' in zone ) : #NEWLINE# #INDENT# city_name = zone . split ( '/' , 1 ) [ 1 ] . replace ( '_' , ' ' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# city_name = zone . replace ( '_' , ' ' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ( region_format % ( fallback_format % { #NEWLINE# #INDENT# '0' : city_name , #NEWLINE# '1' : territory_name , #NEWLINE# #UNINDENT# } ) )