mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-02 18:56:52 +00:00
Update project setup.
This commit is contained in:
parent
13b4ca54cf
commit
b80ca9e84a
23 changed files with 186 additions and 112 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
|
@ -17,7 +18,7 @@ def check_yaml(argv):
|
|||
try:
|
||||
yaml.load(open(filename))
|
||||
except yaml.YAMLError as e:
|
||||
print e
|
||||
print(e)
|
||||
retval = 1
|
||||
return retval
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import ast
|
||||
|
|
@ -39,7 +40,14 @@ def check_file_for_debug_statements(filename):
|
|||
visitor.visit(ast_obj)
|
||||
if visitor.debug_import_statements:
|
||||
for debug_statement in visitor.debug_import_statements:
|
||||
print '{0}:{2}:{3} - {1} imported'.format(filename, *debug_statement)
|
||||
print(
|
||||
'{0}:{1}:{2} - {3} imported'.format(
|
||||
filename,
|
||||
debug_statement.line,
|
||||
debug_statement.col,
|
||||
debug_statement.name,
|
||||
)
|
||||
)
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
|
|
@ -18,11 +17,11 @@ def fix_file(file_obj):
|
|||
return 0
|
||||
last_character = file_obj.read(1)
|
||||
# last_character will be '' for an empty file
|
||||
if last_character != '\n' and last_character != '':
|
||||
file_obj.write('\n')
|
||||
if last_character != b'\n' and last_character != b'':
|
||||
file_obj.write(b'\n')
|
||||
return 1
|
||||
|
||||
while last_character == '\n':
|
||||
while last_character == b'\n':
|
||||
# Deal with the beginning of the file
|
||||
if file_obj.tell() == 1:
|
||||
# If we've reached the beginning of the file and it is all
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
|
@ -22,4 +21,4 @@ def validate_files(argv):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(entry())
|
||||
sys.exit(validate_files())
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
|
@ -12,13 +13,13 @@ def fix_trailing_whitespace(argv):
|
|||
parser.add_argument('filenames', nargs='*', help='Filenames to fix')
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
bad_whitespace_files = filter(bool, local['grep'][
|
||||
bad_whitespace_files = local['grep'][
|
||||
('-l', '[[:space:]]$') + tuple(args.filenames)
|
||||
](retcode=None).splitlines())
|
||||
](retcode=None).strip().splitlines()
|
||||
|
||||
if bad_whitespace_files:
|
||||
for bad_whitespace_file in bad_whitespace_files:
|
||||
print 'Fixing {0}'.format(bad_whitespace_file)
|
||||
print('Fixing {0}'.format(bad_whitespace_file))
|
||||
local['sed']['-i', '-e', 's/[[:space:]]*$//', bad_whitespace_file]()
|
||||
return 1
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import functools
|
||||
import sys
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue