Ejemplo n.º 1
0
    def grid(self):
        """ Generate the grid if needed and return it """
        if not self._grid:
            self._grid = {}
            digits = digitize(self.full_name)

            size = self.width * self.height + 1
            for i in range(1, size):
                count, explanation = count_occurrences(digits, i, explain=True)
                example = examplify(self.full_name, explanation, count)

                self._grid[i] = {
                    'count': count,
                    'example': example,
                }

            cache.set(self._cache_key, self._grid)
        return self._grid
Ejemplo n.º 2
0
    def run(self):
        consonants = re.sub(re_vowels, '_', self.full_name)
        digits = utils.digitize(consonants)

        self._result = utils.simplify(digits)
        self._example = utils.examplify(consonants, digits, self._result)
Ejemplo n.º 3
0
 def test_digitization_number(self):
     """ Number should be digitized without any trouble """
     string = "123456789"
     self.assertEqual(string, utils.digitize(string))
Ejemplo n.º 4
0
 def test_digitization_non_alpha(self):
     """ Digitization of non parsable characters should result in underscores """
     string = "A+&\"'(_"
     self.assertEqual("1______", utils.digitize(string))
Ejemplo n.º 5
0
 def test_digitization_alpha_and_space(self):
     """ Digitization of alpha string with space should result not create interferences """
     string = "a C e G i"
     self.assertEqual("1 3 5 7 9", utils.digitize(string))
Ejemplo n.º 6
0
 def test_digitization_alpha_string_upper(self):
     """ Digitization of upper alpha string should be transformable into int easily """
     string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
     self.assertEqual("12345678912345678912345678", utils.digitize(string))
Ejemplo n.º 7
0
 def test_digitization_alpha_string_lower(self):
     """ Digitization of lower alpha string should be transformable into int easily """
     string = "abcdefghijklmnopqrstuvwxyz"
     self.assertEqual("12345678912345678912345678", utils.digitize(string))
Ejemplo n.º 8
0
 def test_digitization_empty_string(self):
     """ Digitization of empty string should return an empty string """
     string = ""
     self.assertEqual("", utils.digitize(string))
Ejemplo n.º 9
0
 def test_digitization_alphanumeric(self):
     """ Alphanumeric string should be no trouble """
     string = "A2C4E6"
     self.assertEqual("123456", utils.digitize(string))
Ejemplo n.º 10
0
    def run(self):
        digits = utils.digitize(self.last_name)

        self._result = utils.simplify(digits)
        self._example = utils.examplify(self.last_name, digits, self._result)
Ejemplo n.º 11
0
    def run(self):
        digits = utils.digitize(self.given_names)

        self._result = utils.simplify(digits)
        self._example = utils.examplify(self.given_names, digits, self._result)