From a9dd9b19768234af507da976c17889aa443301cf Mon Sep 17 00:00:00 2001 From: Christoph Haunschmidt Date: Sun, 14 Jul 2019 19:52:01 +0200 Subject: [PATCH] Allows empty lines in RPP files - previously, the parse failed if it encountered an empty line due to an IndexError - some extensions apparently can add empty lines - an example of such a file is in tests/data/with_empty_lines.RPP --- rpp/scanner.py | 2 + tests/data/with_empty_lines.RPP | 107 ++++++++++++++++++++++++++++++++ tests/test_rpp.py | 1 + 3 files changed, 110 insertions(+) create mode 100644 tests/data/with_empty_lines.RPP diff --git a/rpp/scanner.py b/rpp/scanner.py index 8ec429e..2ff0c37 100644 --- a/rpp/scanner.py +++ b/rpp/scanner.py @@ -25,6 +25,8 @@ def token(self): def __iter__(self): lines = self._input.splitlines() for lineno, line in enumerate(lines, start=1): + if not line.strip(): + continue is_first_token_in_line = True while line: line = line.strip() diff --git a/tests/data/with_empty_lines.RPP b/tests/data/with_empty_lines.RPP new file mode 100644 index 0000000..efa5608 --- /dev/null +++ b/tests/data/with_empty_lines.RPP @@ -0,0 +1,107 @@ + + + RENDER_FILE "" + RENDER_PATTERN "" + RENDER_FMT 0 2 0 + RENDER_1X 0 + RENDER_RANGE 1 0 0 18 1000 + RENDER_RESAMPLE 3 0 1 + RENDER_ADDTOPROJ 0 + RENDER_STEMS 0 + RENDER_DITHER 0 + TIMELOCKMODE 1 + TEMPOENVLOCKMODE 1 + ITEMMIX 0 + DEFPITCHMODE 589824 0 + TAKELANE 1 + SAMPLERATE 48000 1 0 + + LOCK 1 + + GLOBAL_AUTO -1 + TEMPO 120 4 4 + PLAYRATE 1 0 0.25 4 + SELECTION 0 0 + SELECTION2 0 0 + MASTERAUTOMODE 0 + MASTERTRACKHEIGHT 0 0 + MASTERPEAKCOL 16576 + MASTERMUTESOLO 0 + MASTERTRACKVIEW 0 0.6667 0.5 0.5 0 0 0 + MASTERHWOUT 0 0 1 0 0 0 0 -1 + MASTER_NCH 2 2 + MASTER_VOLUME 1 0 -1 -1 1 + MASTER_FX 1 + MASTER_SEL 0 + + + + + + > +> diff --git a/tests/test_rpp.py b/tests/test_rpp.py index 5fffc93..0e341f2 100644 --- a/tests/test_rpp.py +++ b/tests/test_rpp.py @@ -142,6 +142,7 @@ def test_dumps(): @pytest.mark.parametrize('filename', [ 'empty.RPP', 'vst.RPP', + # 'with_empty_lines.RPP', # left out ATM, due to empty lines / indentations ]) def test_conversion(filename): DIR = path.dirname(__file__)