Skip to content

Commit

Permalink
Fix for sphinxcontrib.spelling 5.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
avylove committed Jul 29, 2020
1 parent a17454d commit b0d2c14
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions setup_helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Avram Lubkin, All Rights Reserved
# Copyright 2017 - 2020 Avram Lubkin, All Rights Reserved

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -44,8 +44,11 @@ def print_spelling_errors(filename, encoding='utf8'):
"""
Print misspelled words returned by sphinxcontrib-spelling
"""
try:
filesize = os.stat(filename).st_size
except FileNotFoundError:
filesize = 0

filesize = os.stat(filename).st_size
if filesize:
sys.stdout.write('Misspelled Words:\n')
with io.open(filename, encoding=encoding) as wordlist:
Expand All @@ -55,6 +58,14 @@ def print_spelling_errors(filename, encoding='utf8'):
return 1 if filesize else 0


def print_all_spelling_errors(path):
"""
Print all spelling errors in the path
"""

return max(print_spelling_errors(os.path.join(path, filename)) for filename in os.listdir(path))


if __name__ == '__main__':

# Do nothing if no arguments were given
Expand All @@ -66,7 +77,7 @@ def print_spelling_errors(filename, encoding='utf8'):
if len(sys.argv) > 2:
sys.exit(print_spelling_errors(sys.argv[2]))
else:
sys.exit(print_spelling_errors('build/doc/spelling/output.txt'))
sys.exit(print_all_spelling_errors('build/doc/spelling/'))

# Unknown option
else:
Expand Down

0 comments on commit b0d2c14

Please sign in to comment.