Mercurial > jouvence
comparison tests/conftest.py @ 24:2ef526c301cc 0.3.0
Add support for sections and synopsis.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 05 Jan 2017 09:27:11 -0800 |
parents | ee741bbe96a8 |
children |
comparison
equal
deleted
inserted
replaced
23:36424a1081ff | 24:2ef526c301cc |
---|---|
2 import sys | 2 import sys |
3 import logging | 3 import logging |
4 import yaml | 4 import yaml |
5 import pytest | 5 import pytest |
6 from jouvence.document import ( | 6 from jouvence.document import ( |
7 JouvenceSceneElement, | 7 JouvenceSceneElement, JouvenceSceneSection, |
8 TYPE_ACTION, TYPE_CENTEREDACTION, TYPE_CHARACTER, TYPE_DIALOG, | 8 TYPE_ACTION, TYPE_CENTEREDACTION, TYPE_CHARACTER, TYPE_DIALOG, |
9 TYPE_PARENTHETICAL, TYPE_TRANSITION, TYPE_LYRICS, TYPE_PAGEBREAK, | 9 TYPE_PARENTHETICAL, TYPE_TRANSITION, TYPE_LYRICS, TYPE_PAGEBREAK, |
10 TYPE_EMPTYLINES, | 10 TYPE_SYNOPSIS, |
11 _scene_element_type_str) | 11 _scene_element_type_str) |
12 from jouvence.parser import JouvenceParser, JouvenceParserError | 12 from jouvence.parser import JouvenceParser, JouvenceParserError |
13 | 13 |
14 | 14 |
15 def pytest_addoption(parser): | 15 def pytest_addoption(parser): |
166 cur_paras = [] | 166 cur_paras = [] |
167 | 167 |
168 for item in spec: | 168 for item in spec: |
169 if item == '<pagebreak>': | 169 if item == '<pagebreak>': |
170 cur_paras.append(JouvenceSceneElement(TYPE_PAGEBREAK, None)) | 170 cur_paras.append(JouvenceSceneElement(TYPE_PAGEBREAK, None)) |
171 continue | |
172 | |
173 if RE_BLANK_LINE.match(item): | |
174 text = len(item) * '\n' | |
175 cur_paras.append(JouvenceSceneElement(TYPE_EMPTYLINES, text)) | |
176 continue | 171 continue |
177 | 172 |
178 token = item[:1] | 173 token = item[:1] |
179 if token == '.': | 174 if token == '.': |
180 if cur_header or cur_paras: | 175 if cur_header or cur_paras: |
195 cur_paras.append(_p(item[1:])) | 190 cur_paras.append(_p(item[1:])) |
196 elif token == '>': | 191 elif token == '>': |
197 cur_paras.append(_t(item[1:])) | 192 cur_paras.append(_t(item[1:])) |
198 elif token == '~': | 193 elif token == '~': |
199 cur_paras.append(_l(item[1:])) | 194 cur_paras.append(_l(item[1:])) |
195 elif token == '#': | |
196 cur_paras.append( | |
197 JouvenceSceneSection(1, item[1:])) | |
198 elif token == '+': | |
199 cur_paras.append( | |
200 JouvenceSceneElement(TYPE_SYNOPSIS, item[1:])) | |
200 else: | 201 else: |
201 raise Exception("Unknown token: %s" % token) | 202 raise Exception("Unknown token: %s" % token) |
202 if cur_header or cur_paras: | 203 if cur_header or cur_paras: |
203 out.append([cur_header] + cur_paras) | 204 out.append([cur_header] + cur_paras) |
204 return out | 205 return out |