-
Notifications
You must be signed in to change notification settings - Fork 0
/
spellCheck.py
executable file
·32 lines (25 loc) · 1.07 KB
/
spellCheck.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python3
import os
import argparse
from os import listdir
from os.path import isfile, join
from os import walk
parser = argparse.ArgumentParser(description='Run spell check on tex files (by using aspell)')
parser.add_argument('--file' , type=str, default=None, help='specify the tex file name: default -> search in folder')
parser.add_argument('--folder', type=str, default='.' , help='specify folder: default -> working folder' )
parser.add_argument('--lang' , type=str, default='en', help='specify language: default -> en' )
args = parser.parse_args()
def main():
cmd = "aspell --lang="+args.lang+" --mode=tex check "
Files = GetListOfFiles("tex")
for file in Files:
print('spellChecker is running on file ',file)
os.system(cmd+file)
def GetListOfFiles(extension):
if args.file:
return [args.file]
else:
for (dirpath, dirnames, filenames) in walk(args.folder):
return (f for f in filenames if f.endswith('.'+extension))
if __name__ == "__main__":
main()