예제 #1
0
def test_remove_accents():
    eq_(remove_accents(u'café'), u'cafe')
    eq_(remove_accents(u'Équateur'), u'Equateur')
    eq_(remove_accents(u'Pérou'), u'Perou')
    eq_(remove_accents(u'Węgry'), u'Wegry')
    # This hits the limitations of what's possible with built-in
    # functions but shows that if the diacritic isn't found the
    # string remains un-molested.
    eq_(remove_accents(u'Włochy'), u'Włochy')
예제 #2
0
def test_remove_accents():
    eq_(remove_accents(u'café'), u'cafe')
    eq_(remove_accents(u'Équateur'), u'Equateur')
    eq_(remove_accents(u'Pérou'), u'Perou')
    eq_(remove_accents(u'Węgry'), u'Wegry')
    # This hits the limitations of what's possible with built-in
    # functions but shows that if the diacritic isn't found the
    # string remains un-molested.
    eq_(remove_accents(u'Włochy'), u'Włochy')
예제 #3
0
파일: models.py 프로젝트: clouserw/zamboni
    def regions_by_name(self, provider=None):
        """A list of price regions sorted by name.

        :param int provider: A provider, using the PAYMENT_* constant.
            If not provided it will use settings.PAYMENT_PROVIDERS,

        """

        prices = self.prices(provider=provider)

        regions = set()
        append_rest_of_world = False

        for price in prices:
            region = RID[price['region']]
            if price['paid'] is True and region != RESTOFWORLD:
                regions.add(region)
            if price['paid'] is True and region == RESTOFWORLD:
                append_rest_of_world = True

        if regions:
            # Sort by name based on normalized unicode name.
            regions = sorted(regions,
                             key=lambda r: remove_accents(unicode(r.name)))
            if append_rest_of_world:
                regions.append(RESTOFWORLD)

        return regions if regions else []
예제 #4
0
    def regions_by_name(self, provider=None):
        """A list of price regions sorted by name.

        :param int provider: A provider, using the PAYMENT_* constant.
            If not provided it will use settings.PAYMENT_PROVIDERS,

        """

        prices = self.prices(provider=provider)

        regions = set()
        append_rest_of_world = False

        for price in prices:
            region = RID[price['region']]
            if price['paid'] is True and region != RESTOFWORLD:
                regions.add(region)
            if price['paid'] is True and region == RESTOFWORLD:
                append_rest_of_world = True

        if regions:
            # Sort by name based on normalized unicode name.
            regions = sorted(regions,
                             key=lambda r: remove_accents(unicode(r.name)))
            if append_rest_of_world:
                regions.append(RESTOFWORLD)

        return regions if regions else []
예제 #5
0
def REGIONS_LIST_SORTED_BY_NAME():
    """Get the region list and sort by name.

    Requires a function due to localisation.

    """

    # Avoid circular import.
    from mkt.regions.utils import remove_accents

    by_name = sorted([v for k, v in DEFINED if v.id and v.weight > -1],
                     key=lambda v: remove_accents(unicode(v.name)))
    by_name.append(RESTOFWORLD)
    return by_name
예제 #6
0
def REGIONS_CHOICES_SORTED_BY_NAME():
    """Get the region choices and sort by name.

    Requires a function due to localisation.

    """

    # Avoid circular import.
    from mkt.regions.utils import remove_accents

    by_name = sorted([v for k, v in DEFINED if v.id and v.weight > -1],
                     key=lambda v: remove_accents(unicode(v.name)))
    return ([(v.id, v.name) for v in by_name] +
            [(RESTOFWORLD.id, RESTOFWORLD.name)])
예제 #7
0
파일: regions.py 프로젝트: Witia1/zamboni
def REGIONS_LIST_SORTED_BY_NAME():
    """Get the region list and sort by name.

    Requires a function due to localisation.

    """

    # Avoid circular import.
    from mkt.regions.utils import remove_accents

    by_name = sorted([v for k, v in DEFINED if v.id and v.weight > -1],
                     key=lambda v: remove_accents(unicode(v.name)))
    by_name.append(RESTOFWORLD)
    return by_name