SpellCheck.py revision 831b40b1c811223fd0b1131791a38e3ae5143377
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# CDDL HEADER START
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# The contents of this file are subject to the terms of the
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# Common Development and Distribution License (the "License").
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# You may not use this file except in compliance with the License.
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# or http://www.opensolaris.org/os/licensing.
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# See the License for the specific language governing permissions
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# and limitations under the License.
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# When distributing Covered Code, include this CDDL HEADER in each
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# If applicable, add the following below this CDDL HEADER, with the
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# fields enclosed by brackets "[]" replaced with your own identifying
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# information: Portions Copyright [yyyy] [name of copyright owner]
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# CDDL HEADER END
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello# Copyright 2016 Joyent, Inc.
71af3be340c57171837478555e2eb0d496318cfcCody Peter MellospellMsg = '%s: Line %d contains "%s", a common misspelling of "%s"\n'
71af3be340c57171837478555e2eb0d496318cfcCody Peter MelloaltMsg = '%s: Lined %d contains "%s"; please use "%s" instead for consistency with other documentation\n'
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mellofor misspelling, correct in misspellings.iteritems():
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello regex = re.compile(r'\b%s\b' % (misspelling), re.IGNORECASE)
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mellofor alternate, correct in alternates.iteritems():
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello regex = re.compile(r'\b%s\b' % (alternate), re.IGNORECASE)
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mellodef check(errmsg, output, filename, line, lineno, entry):
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello output.write(errmsg % (filename, lineno, entry[1], entry[2]))
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mellodef spellcheck(fh, filename=None, output=sys.stderr, **opts):
71af3be340c57171837478555e2eb0d496318cfcCody Peter Mello ret |= check(spellMsg, output, filename, line,