Skip to content

Commit

Permalink
Create a .proselintrc file
Browse files Browse the repository at this point in the history
Closes #39
  • Loading branch information
Jordan Suchow authored and suchow committed Sep 27, 2015
1 parent 8c074ee commit e382965
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
49 changes: 49 additions & 0 deletions .proselintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"max_errors": 1000,
"checks": {
"garner.a_vs_an" : true,
"garner.airlinese" : true,
"garner.animal_labels" : true,
"garner.archaism" : true,
"garner.back_formations" : true,
"garner.cliches" : true,
"garner.commercialese" : true,
"garner.dates" : true,
"garner.denizen_labels" : true,
"garner.illogic" : true,
"garner.malaproprisms" : true,
"garner.misspelling" : true,
"garner.needless_variants" : true,
"garner.oxymorons" : true,
"garner.preferred_forms" : true,
"garner.punctuation" : true,
"garner.redundancy" : true,
"garner.sexism" : true,
"consistency.spacing" : true,
"consistency.spelling" : true,
"butterick.symbols" : true,
"misc.annotations" : true,
"misc.chatspeak" : true,
"misc.creditcard" : true,
"misc.currency" : true,
"misc.hyperbolic" : true,
"misc.linkchecker" : true,
"misc.password" : true,
"misc.yelling" : true,
"pinker.apologizing" : true,
"pinker.hedging" : true,
"pinker.latin" : true,
"pinker.metaconcepts" : true,
"pinker.narcisissm" : true,
"pinker.scare_quotes" : true,
"strunkwhite.composition" : true,
"strunkwhite.greylist" : true,
"strunkwhite.usage" : true,
"wallace.tense_present" : true,
"wallace.uncomparables" : true,
"wallstreetjournal.misspelling" : true,
"writegood.cliches" : true,
"writegood.lexical_illusions" : true,
"writegood.weasel_words" : true
}
}
File renamed without changes.
File renamed without changes.
17 changes: 13 additions & 4 deletions proselint/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import ntpath
import re
import textblob
import json
import importlib


base_url = "prose.lifelinter.com/"
Expand Down Expand Up @@ -43,23 +45,30 @@ def run_initialization():

def lint(path):
"""Run the linter on the file with the given path."""
# Extract functions from the checks folder.
# Load the options.
options = json.load(open('.proselintrc'))

# Extract the checks.
checks = []
for loader, module_name, is_pkg in pkgutil.walk_packages(pl.__path__):
module = loader.find_module(module_name).load_module(module_name)
check_names = [key for key, val in options["checks"].items() if val]
for check_name in check_names:
module = importlib.import_module("proselint.checks." + check_name)
for d in dir(module):
if re.match("check", d):
checks.append(getattr(module, d))

# Apply all the checks.
errors = []
with codecs.open(path, "r", encoding='utf-8') as f:
blob = textblob.TextBlob(f.read())
errors = []
for check in checks:
errors += check(blob)
if len(errors) > options["max_errors"]:
break

# Sort the errors by line and column number.
errors = sorted(errors)
errors = sorted(errors[:options["max_errors"]])

# Display the errors.
for error in errors:
Expand Down

0 comments on commit e382965

Please sign in to comment.