From c5860aa2d8176f134d3599af6f9f98ffa37bec40 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 31 Oct 2014 23:31:45 +0100 Subject: replace a python file with a sed+awk sequence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/trim.py | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'src/trim.py') diff --git a/src/trim.py b/src/trim.py index c623f74..72a1b3f 100755 --- a/src/trim.py +++ b/src/trim.py @@ -24,32 +24,19 @@ firsttext = True while True: try: - line = input().replace('\t', ' ') + line = input() lower = line.lower() - if line.replace(' ', '').startswith('#') or (len(line.replace(' ', '')) == 0): - continue - else: - if ' # ' in line: - line = line[:line.find(' # ')] - lower = lower[:lower.find(' # ')] - while line.startswith(' '): - line = line[1:] - lower = lower[1:] - while line.endswith(' '): - line = line[:-1] - lower = lower[:-1] - - if lower.startswith('text '): - text = True - if firsttext: - print(line) - elif lower == 'endtext': - text = False - if firsttext: - print(line) - firsttext = False - elif (text and firsttext) or (lower.split(' ')[0] in ('timeout', 'menu', 'font')): + if lower.startswith('text '): + text = True + if firsttext: print(line) + elif lower == 'endtext': + text = False + if firsttext: + print(line) + firsttext = False + elif (text and firsttext) or (lower.split(' ')[0] in ('timeout', 'menu', 'font')): + print(line) except: break -- cgit v1.2.3-70-g09d2