Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a warning for invalid dictionaries #37

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Add a warning for invalid dictionaries

  • Loading branch information
jvoisin committed Feb 16, 2020
commit dab9989854ba0e3ebb901d42afaf548528fc986d
@@ -46,16 +46,18 @@ def load_file(self, dict_path):

_dict = set()
with open(dict_path) as f:
for line in f:
for nb, line in enumerate(f):
line = line.lstrip()
if not line or line.startswith('#'):
continue
word = self.line_re.search(line)
if word:
# Decode any escaped characters, giving us a bytes object
value = word.group(1)
(value, _) = codecs.escape_decode(value)
_dict.add(value)
if not word:
print('Error while loading the dictionary "%s" at line %d.'
% (dict_path, line))
This conversation was marked as resolved by jvoisin

This comment has been minimized.

Copy link
@gerph

gerph Feb 16, 2020

Contributor

Probably want to include a continue here, as otherwise it'll exception on the next line when it tries to get the 'group' method of None.

# Decode any escaped characters, giving us a bytes object
value = word.group(1)
(value, _) = codecs.escape_decode(value)
_dict.add(value)
self._dict = list(_dict)

def get_word(self):
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.