Fix linters

This commit is contained in:
Thierry Deo 2018-02-26 15:46:33 +01:00
parent 2d57068f49
commit 3793bc32c0
2 changed files with 4 additions and 1 deletions

View file

@ -26,16 +26,18 @@ def _process_filename_by_line(pattern, filename):
output.write_line(line.rstrip(b'\r\n')) output.write_line(line.rstrip(b'\r\n'))
return retv return retv
def _process_filename_at_once(pattern, filename): def _process_filename_at_once(pattern, filename):
retv = 0 retv = 0
with open(filename, 'rb') as f: with open(filename, 'rb') as f:
match = pattern.search(f.read().decode('utf-8').replace('\n','')) match = pattern.search(f.read().decode('utf-8').replace('\n', ''))
if match: if match:
retv = 1 retv = 1
output.write('{}:'.format(filename)) output.write('{}:'.format(filename))
output.write_line(match.group()) output.write_line(match.group())
return retv return retv
def run_hook(prefix, hook, file_args): def run_hook(prefix, hook, file_args):
exe = (sys.executable, '-m', __name__) exe = (sys.executable, '-m', __name__)
exe += tuple(hook['args']) + (hook['entry'],) exe += tuple(hook['args']) + (hook['entry'],)

View file

@ -39,6 +39,7 @@ def test_ignore_case(some_files, cap_out):
assert ret == 1 assert ret == 1
assert out == 'f2:1:[INFO] hi\n' assert out == 'f2:1:[INFO] hi\n'
def test_null_data(some_files, cap_out): def test_null_data(some_files, cap_out):
ret = pygrep.main(('--null-data', r'foo.*bar', 'f1', 'f2', 'f3')) ret = pygrep.main(('--null-data', r'foo.*bar', 'f1', 'f2', 'f3'))
out = cap_out.get() out = cap_out.get()