def get_format(format_type, lang=None, use_l10n=None):
format_type = str_encode(format_type)<EOL>if use_l10n or (use_l10n is None and settings.USE_L10N):<EOL><INDENT>if lang is None:<EOL><INDENT>lang = get_language()<EOL><DEDENT>cache_key = (format_type, lang)<EOL>try:<EOL><INDENT>cached = _format_cache[cache_key]<EOL>if cached is not None:<EOL><INDENT>return cached<EOL><DEDENT>else:<EOL><INDENT>return getattr(settings, format_type)<EOL><DEDENT><DEDENT>except KeyError:<EOL><INDENT>for module in get_format_modules(lang):<EOL><INDENT>try:<EOL><INDENT>val = getattr(module, format_type)<EOL>for iso_input in ISO_INPUT_FORMATS.get(format_type, ()):<EOL><INDENT>if iso_input not in val:<EOL><INDENT>if isinstance(val, tuple):<EOL><INDENT>val = list(val)<EOL><DEDENT>val.append(iso_input)<EOL><DEDENT><DEDENT>_format_cache[cache_key] = val<EOL>return val<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>_format_cache[cache_key] = None<EOL><DEDENT><DEDENT>return getattr(settings, format_type)<EOL>
For a specific format type, returns the format for the current
language (locale), defaults to the format in the settings.
format_type is the name of the format, e.g. 'DATE_FORMAT'

If use_l10n is provided and is not None, that will force the value to
be localized (or not), overriding the value of settings.USE_L10N.