Skip to content

Commit

Permalink
autopep8
Browse files Browse the repository at this point in the history
  • Loading branch information
martinthomson committed Jan 4, 2018
1 parent 1b08f18 commit 1eea074
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions .lint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python3

import sys,argparse,re
import sys
import argparse
import re

parser = argparse.ArgumentParser(description='Lint markdown drafts.')
parser.add_argument('files', metavar='file', nargs='+', help='Files to lint')
Expand All @@ -14,7 +16,7 @@
for inputfile in args.files:
insideFigure = False
beforeAbstract = True
with open(inputfile,'U') as draft:
with open(inputfile, 'U') as draft:
linecounter = 1
lines = draft.readlines()

Expand All @@ -27,30 +29,31 @@
linenumber = linecounter
linecounter += 1

## Skip everything before abstract
# Skip everything before abstract
if beforeAbstract:
matchObj = abstract.match(line)
if matchObj:
beforeAbstract = False
continue

## Skip tables
# Skip tables
matchObj = table.match(line)
if matchObj:
continue

## Toggle figure state
# Toggle figure state
matchObj = figure.match(line)
if matchObj:
insideFigure = not insideFigure
continue

## Check length
# Check length
length = len(line)
limit = args.maxFigureLineLength if insideFigure else args.maxLineLength
if length > limit:
foundError = True
sys.stderr.write("{0}: Line is {1} characters; limit is {2}\n".format(linenumber,length,limit))
sys.stderr.write("{0}: Line is {1} characters; limit is {2}\n".format(
linenumber, length, limit))
sys.stderr.write("{0}\n".format(line))

sys.exit( 1 if foundError else 0)
sys.exit(1 if foundError else 0)

0 comments on commit 1eea074

Please sign in to comment.