public
Last active

  • Download Gist
pep8org.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#!python
import re
 
import pep8
 
# This is a very long line - 79 chars --------------------------------123456789
# This is a very [[with-poporg][long line]] - 79 chars --------------------------------123456789
# This is a very [[with-poporg][long line]] - 80 chars --------------------------------1234567890
 
 
def maximum_line_length(physical_line, max_line_length):
line = physical_line.rstrip()
length = len(line)
if length > max_line_length:
if pep8.noqa(line):
return
if hasattr(line, 'decode'): # Python 2
# The line could contain multi-byte characters
try:
length = len(line.decode('utf-8'))
except UnicodeError:
pass
if length > max_line_length:
line = re.sub(r'\[\[[^]]*\]\[([^]]*)\]\]', r'\1', line)
length = len(line)
if length > max_line_length:
return (max_line_length, "E501 line too long "
"(%d > %d characters)" % (length, max_line_length))
del pep8._checks['physical_line'][pep8.maximum_line_length]
pep8.register_check(maximum_line_length, ['E501'])
 
if __name__ == '__main__':
pep8._main()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.