#!/usr/bin/python import os from os.path import abspath, dirname, exists import re import sys DIR = abspath( dirname( dirname( __file__ ) ) ) DICT = abspath( DIR+'/doc/aspell.en.pws' ) def spellcheck( file ): print "Spell checking %s" % file cmd = "aspell -H -p '%s' -c '%s'" % (DICT, file) os.system( cmd ) argv = sys.argv[1:] argc = len( argv ) if (argc == 0) or ((argc == 1) and not exists(argv[0])): if argc == 0: cmd = "git diff --name-only 'master'" else: cmd = "git diff --name-only '%s'" % argv[0] filter = re.compile( '.*/.*\.xml$', re.M ) files = os.popen( cmd ).read() for file in filter.findall( files ): spellcheck( file ) else: for file in sys.argv[1:]: spellcheck( file )