コード例 #1
0
 def test_strip_accent_and_punctuation_from_string_without_accent_and_punctuation(
         self):
     uppercase_with_accent = 'λόγος απειλή'
     uppercase_without_accent = u'λογος απειλη'
     self.assertEqual(
         Greek.strip_punctuation_and_accent_unicode(uppercase_with_accent),
         uppercase_without_accent)
コード例 #2
0
    def as_case(self, name):
        """
        Args:
            name: Name to return case for
        Returns:
            str: Case of the name
        """
        # If accent is disabled remove accent from name
        if not self.accent:
            name = Greek.strip_accent_unicode(name)

        # First check if the current name is an exception to the rules
        if name in self.exceptions:
            return normalize_name(self.exceptions[name], self.upper)

        # Get the match and the collection we found the match
        for key in [name[-3:], name[-4:]]:
            if key in self._ending_mappings:
                return normalize_name(
                    name.replace(key, self._ending_mappings[key]), self.upper)

        # Check if name ends in S, If so strip the S
        if name[-1].upper() == 'Σ':
            return normalize_name(name[:-1], self.upper)

        return normalize_name(name, self.upper)
コード例 #3
0
 def __initialize(self):
     """
     Updates the exceptions with the extra exceptions given.
     """
     self.exceptions = deepcopy(self._exceptions)
     if not self.accent:
         self.exceptions = {
             Greek.strip_accent_unicode(key):
             Greek.strip_accent_unicode(value)
             for key, value in iteritems(self.exceptions)
         }
     if self.extra_exceptions:
         if not self.accent:
             self.extra_exceptions = {
                 Greek.strip_accent_unicode(key):
                 Greek.strip_accent_unicode(value)
                 for key, value in iteritems(self.extra_exceptions)
             }
         self.exceptions.update(self.extra_exceptions)
コード例 #4
0
 def test_strip_accent_from_greek_string_with_accent(self):
     with_accent = u'λόγος'
     without_accent = u'λογος'
     self.assertEqual(Greek.strip_accent_unicode(with_accent),
                      without_accent)
コード例 #5
0
 def test_strip_accent_and_punctuation_from_uppercase_string(self):
     uppercase_with_accent = 'ΛΌΓΟΣ-ΑΠΕΙΛΉ.ΚΙ/ΕΣΎ+ΜΑΖΙ.ΓΙΌ.'
     uppercase_without_accent = u'ΛΟΓΟΣ ΑΠΕΙΛΗ ΚΙ ΕΣΥ ΜΑΖΙ ΓΙΟ'
     self.assertEqual(
         Greek.strip_punctuation_and_accent_unicode(uppercase_with_accent),
         uppercase_without_accent)
コード例 #6
0
 def test_strip_accent_and_punctuation_from_latin_string(self):
     uppercase_with_accent = 'logos apeilh'
     uppercase_without_accent = u'logos apeilh'
     self.assertEqual(
         Greek.strip_punctuation_and_accent_unicode(uppercase_with_accent),
         uppercase_without_accent)
コード例 #7
0
 def test_strip_accent_uppercase(self):
     uppercase_with_accent = 'ΛΌΓΟΣ'
     uppercase_without_accent = u'ΛΟΓΟΣ'
     self.assertEqual(Greek.strip_accent_unicode(uppercase_with_accent),
                      uppercase_without_accent)
コード例 #8
0
 def test_strip_accent_non_unicode(self):
     with_accent = 'λόγος'
     without_accent = u'λογος'
     self.assertEqual(Greek.strip_accent_unicode(with_accent),
                      without_accent)
コード例 #9
0
 def test_strip_accent_from_latin_string(self):
     latin_string = u'whatever'
     self.assertEqual(Greek.strip_accent_unicode(latin_string),
                      latin_string)