def __init__(self, locale=None, weekend={<NUM_LIT:5>, <NUM_LIT:6>}, use_cached_holidays=False):
self.weekend = weekend<EOL>if use_cached_holidays:<EOL><INDENT>data = self.load_backup_data()<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>data = requests.get(self.source_url).json()<EOL><DEDENT>except (requests.RequestException, ValueError):<EOL><INDENT>logger.warning('<STR_LIT>')<EOL>data = self.load_backup_data()<EOL><DEDENT><DEDENT>if locale:<EOL><INDENT>trans = gettext.translation('<STR_LIT>', fallback=True, languages=[locale],<EOL>localedir=os.path.join(os.path.dirname(__file__), '<STR_LIT>'))<EOL><DEDENT>else:<EOL><INDENT>trans = gettext.NullTranslations()<EOL><DEDENT>trans = trans.ugettext if hasattr(trans, '<STR_LIT>') else trans.gettext<EOL>def _(text):<EOL><INDENT>if not text:<EOL><INDENT>return text<EOL><DEDENT>return trans(text)<EOL><DEDENT>def map_holiday(holiday):<EOL><INDENT>try:<EOL><INDENT>return {<EOL>'<STR_LIT:title>': _(holiday['<STR_LIT:title>']),<EOL>'<STR_LIT:date>': datetime.datetime.strptime(holiday['<STR_LIT:date>'], '<STR_LIT>').date(),<EOL>'<STR_LIT>': _(holiday.get('<STR_LIT>', '<STR_LIT>')),<EOL>'<STR_LIT>': bool(holiday.get('<STR_LIT>')),<EOL>}<EOL><DEDENT>except (KeyError, ValueError):<EOL><INDENT>logger.warning('<STR_LIT>')<EOL>logger.debug(holiday, exc_info=True)<EOL><DEDENT><DEDENT>self.data = {<EOL>division: sorted(filter(None, map(map_holiday, item.get('<STR_LIT>', []))),<EOL>key=lambda e: e['<STR_LIT:date>'])<EOL>for division, item in six.iteritems(data)<EOL>}<EOL>
Load UK bank holidays
:param locale: the locale into which holidays should be translated; defaults to no translation
:param weekend: days of the week that are never work days; defaults to Saturday and Sunday
:param use_cached_holidays: use the cached local copy of the holiday list