Permalink
Browse files

Initial python version.

  • Loading branch information...
lyda committed Apr 7, 2012
1 parent f1e5ebe commit 301ff56195fc8c6d9365eafa384bdf8f46ea6cc3
Showing with 4,316 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. 0 misspellings/__init__.py
  3. +45 −0 misspellings/misspellings.py
  4. +4,270 −0 misspellings/misspellings_lib.py
View
@@ -0,0 +1 @@
+*.pyc
View
No changes.
@@ -0,0 +1,45 @@
+#!/usr/bin/python
+
+import sys
+import getopt
+import misspellings_lib as misspellings
+
+def usage(msg=None):
+ print 'USAGE: misspellings [-f file] [files]'
+ print 'Checks files for common spelling mistakes.'
+ print ' -f file: File containing a list of files to check.'
+ print ' files: Zero or more files to check.'
+ if msg is not None:
+ print 'ERROR: %s' % msg
+ sys.exit(1)
+ sys.exit(0)
+
+
+if __name__ == '__main__':
+ try:
+ flags, files = getopt.getopt(sys.argv[1:], 'f:vh')
+ except getopt.GetoptError, e:
+ usage(e)
+ for flag, option in flags:
+ if flag == '-f':
+ if option == '-':
+ f = sys.stdin
+ else:
+ try:
+ f = open(option, 'r')
+ except IOError, e:
+ usage(e)
+ for line in f:
+ files.append(line.strip())
+ elif flag == '-v':
+ print 'Version 1.0'
+ sys.exit(0)
+ elif flag == '-h':
+ usage()
+ ms = misspellings.Misspellings(files=files)
+ errors, results = ms.check()
+ for res in results:
+ print '%s[%d]: %s -> %s' % (res[0], res[1], res[2], ','.join(
+ ['"%s"' % w for w in ms.suggestions(res[2])]))
+ for err in errors:
+ print 'ERROR: %s' % err
Oops, something went wrong.

0 comments on commit 301ff56

Please sign in to comment.