Exemple #1
0
    def __init__(self, name: str, keys: str, tags: Optional[List] = None):
        self.name = name
        self.left_valid = True
        self.keys = keys
        self.left_letters: Set[str] = set()
        self.right_letters: Set[str] = set()
        self.tags = tags if tags is not None else []
        self.starred = False
        self.next_ = None
        self.keys_full = self.keys

        letter_list = letters.split_on_capital(keys)
        for num, l in enumerate(letter_list):
            if l.lower() in letter_dict:
                steno_key = letter_dict[l.lower()]
                self._parse_key_stroke(steno_key)
            elif l in ["-", "*"]:
                self._parse_key_stroke(l)
            elif l == "/":
                formatted_keys = "".join(letter_list[num + 1:])
                self.keys = "".join(letter_list[:num])
                self.next_ = Brief("", formatted_keys)
                break
            else:
                raise ValueError(
                    f"Cannot parse letter {l} is it in letter_dict?")

        # Flatten the next_ items into array
        self.next_items = []
        next_item = self.next_
        while next_item is not None:
            self.next_items.append(next_item)
            next_item = next_item.next_
Exemple #2
0
 def test_split_error(self):
     """ Raise an error if start with a lower case string. """
     with self.assertRaises(ValueError):
         l.split_on_capital("aFAst")
Exemple #3
0
 def test_split_mixed_cap_dash(self, test_string, split_expected):
     """ Test that we split mixed strings with splits correctly. """
     split_test = l.split_on_capital(test_string)
     self.assertEqual(split_test, split_expected)
Exemple #4
0
    def test_split_all_caps(self, test_str):
        """ In the case of all caps this is the same as a string iter. """
        split_expected = [i for i in test_str]
        split_test = l.split_on_capital(test_str)

        self.assertEqual(split_test, split_expected)