From 4281964c65af3411f4e56523419dac489ac2d4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Wei=C3=9Fmann?= Date: Mon, 1 Feb 2016 15:46:09 +0100 Subject: [PATCH] Formatted code --- pwgrep/cli.py | 2 +- pwgrep/process.py | 6 ++++-- pwgrep/search_helper.py | 4 ++-- pwgrep/search_result.py | 11 +++++------ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pwgrep/cli.py b/pwgrep/cli.py index ced34b9..1418a3d 100755 --- a/pwgrep/cli.py +++ b/pwgrep/cli.py @@ -18,7 +18,7 @@ def run(args): parser_result = commandline_parser.CommandLineParser().parse(args) grepper = process.Grepper(parser_result) - #printer = ResultPrinter(parser_result) + # printer = ResultPrinter(parser_result) any_match = False if not parser_result.options.PATH: diff --git a/pwgrep/process.py b/pwgrep/process.py index 3a52277..4af50f3 100644 --- a/pwgrep/process.py +++ b/pwgrep/process.py @@ -4,6 +4,7 @@ from pwgrep import search_result import sys +import re class SearchFile(object): @@ -12,7 +13,7 @@ class SearchFile(object): class RegexSearcher(object): def __init__(self, regex): - self.regex_txt= re.compile(regex) + self.regex_txt = re.compile(regex) def search_line_txt(self, line): result = [] @@ -36,7 +37,8 @@ def __init__(self, regexes, invert_match=False): def __iter__(self): for line_nr, line in enumerate(sys.stdin): if self.invert_match != bool(self.regexes.regex_txt.search(line)): - yield search_result.SearchResult(line_number=line_nr, match_text=line) + yield search_result.SearchResult(line_number=line_nr, + match_text=line) class Grepper(object): diff --git a/pwgrep/search_helper.py b/pwgrep/search_helper.py index c2e4d52..ee6a451 100644 --- a/pwgrep/search_helper.py +++ b/pwgrep/search_helper.py @@ -86,8 +86,8 @@ def search_in_file(filename, regexes, invert_match, no_filename, yield filename else: for line_nr, line in results_in_text_file(filename, - regexes.regex_txt, - invert_match): + regexes.regex_txt, + invert_match): # match_occurred = True printer_helper.print_match(filename, line, regexes.regex_txt, no_filename, diff --git a/pwgrep/search_result.py b/pwgrep/search_result.py index 1793d72..d386077 100644 --- a/pwgrep/search_result.py +++ b/pwgrep/search_result.py @@ -1,10 +1,10 @@ class SearchResult(object): - def __init__(self, + def __init__(self, line_number=None, - before_match_text = None, - match_text=None, - after_match_text = None, - filename = None + before_match_text=None, + match_text=None, + after_match_text=None, + filename=None ): self.line_number = line_number @@ -12,4 +12,3 @@ def __init__(self, self.match_text = match_text self.after_match_text = after_match_text self.filename = filename -