@webapp2.cached_property
    def locale(self):
        if self.session in 'locale':
            return self.session['locale']
        else:
            # find good locale from accept-language header
            header = self.request.headers.get('Accept-Language', '')
            locales = [locale.split(';')[0] for locale in header.split(',')]
            available = settings.AVAILABLE_LOCALES
            # 1. find exact match
            for locale in locales:
                if locale in available:
                    self.session['locale'] = locale
                    return locale
            # 2. find match in substring
            for locale in locales:
                len1 = len(locale)
                locales2 = [ l for l in available if l[0:(len1-1)] == locale ]
                if len(locales2)>0:
                    self.session['locale'] = locales2[0]
                    return locales2[0]
            # 3. find match in two-character match only
            for l2 in [ locale[0:2] for locale in locales ]:
                locales2 = [ l for l in available if l[0:2] == l2 ]
                if len(locales2)>0:
                    self.session['locale'] = locales2[0]
                    return locales2[0]
            # 4. return first available locale as fallback
            self.session['locale'] = available[0]
            return available[0]
dataset/ETHPy150Open ibagrak/algae/gae/handlers/common.py/BaseHandler.locale/swapped operands of `in`