Last active
August 29, 2015 14:22
-
-
Save magixx/daa74af630d025cf0dbe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_from_console(console, log, levels=['DEBUG']): | |
to_remove = [x for x in log if x['level'] in levels] | |
skip_lines = 0 | |
console_filtered = [] | |
for index, line in enumerate(console): | |
if skip_lines: | |
skip_lines -= 1 | |
continue | |
matched_logs = [x for x in to_remove if x['lines'][0] == line] | |
if matched_logs: | |
for possible_log in matched_logs: | |
if possible_log['lines'] == console[index:index+len(possible_log['lines'])]: | |
skip_lines = len(possible_log['lines']) | |
log.remove(possible_log) | |
break | |
if not skip_lines: | |
console_filtered.append(line) | |
return console_filtered |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment