diff options
| author | Mattias Andrée <maandree@operamail.com> | 2014-10-31 23:31:45 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2014-10-31 23:31:45 +0100 |
| commit | c5860aa2d8176f134d3599af6f9f98ffa37bec40 (patch) | |
| tree | 6afeffcae7bedce6c6d5fad157dd0d6440d9975b /src/trim.py | |
| parent | bump year (diff) | |
| download | splashtool-c5860aa2d8176f134d3599af6f9f98ffa37bec40.tar.gz splashtool-c5860aa2d8176f134d3599af6f9f98ffa37bec40.tar.bz2 splashtool-c5860aa2d8176f134d3599af6f9f98ffa37bec40.tar.xz | |
replace a python file with a sed+awk sequence
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
| -rwxr-xr-x | src/trim.py | 35 |
1 files changed, 11 insertions, 24 deletions
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 |
