Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- filter_chars = [' ', 't', 'n', 'r']
- def is_filtered_char(c):
- return c in filter_chars
- def is_filtered_eol_char(c):
- return c in ['n', 'r']
- inside_double_quoted_string = inside_single_quoted_string = False
- some_chars = sys.stdin.read()
- for c in some_chars:
- if c == '"':
- if not inside_double_quoted_string:
- inside_double_quoted_string = True
- else:
- inside_double_quoted_string = False
- if c == "'":
- if not inside_single_quoted_string:
- inside_single_quoted_string = True
- else:
- inside_single_quoted_string = False
- if not inside_double_quoted_string and not inside_single_quoted_string and not is_filtered_char(c):
- sys.stdout.write(c)
- elif (inside_double_quoted_string or inside_single_quoted_string) and not is_filtered_eol_char(c):
- sys.stdout.write(c)
Add Comment
Please, Sign In to add comment