#NEWLINE# def get_format( format_type , lang = None , use_l10n = None ) : #NEWLINE# #INDENT# "\n    For a specific format type, returns the format for the current\n    language (locale), defaults to the format in the settings.\n    format_type is the name of the format, e.g. 'DATE_FORMAT'\n\n    If use_l10n is provided and is not None, that will force the value to\n    be localized (or not), overriding the value of settings.USE_L10N.\n\n    " #NEWLINE# format_type = str_encode ( format_type ) #NEWLINE# if ( use_l10n or ( ( use_l10n is None ) and settings . USE_L10N ) ) : #NEWLINE# #INDENT# if ( lang is None ) : #NEWLINE# #INDENT# lang = get_language ( ) #NEWLINE# #UNINDENT# cache_key = ( format_type , lang ) #NEWLINE# try : #NEWLINE# #INDENT# cached = _format_cache [ cache_key ] #NEWLINE# if ( cached is not None ) : #NEWLINE# #INDENT# return cached #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return getattr ( settings , format_type ) #NEWLINE# #UNINDENT# #UNINDENT# except KeyError : #NEWLINE# #INDENT# for module in get_format_modules ( lang ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# val = getattr ( module , format_type ) #NEWLINE# for iso_input in ISO_INPUT_FORMATS . get ( format_type , ( ) ) : #NEWLINE# #INDENT# if ( iso_input not in val ) : #NEWLINE# #INDENT# if isinstance ( val , tuple ) : #NEWLINE# #INDENT# val = list ( val ) #NEWLINE# #UNINDENT# val . append ( iso_input ) #NEWLINE# #UNINDENT# #UNINDENT# _format_cache [ cache_key ] = val #NEWLINE# return val #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# _format_cache [ cache_key ] = None #NEWLINE# #UNINDENT# #UNINDENT# return getattr ( settings , format_type )