fix quote pattern implementation, add deleted scene check

This commit is contained in:
Xevion
2020-01-19 22:41:08 -06:00
parent e1e5c82950
commit 798d05827f
2 changed files with 7 additions and 3 deletions

5
.gitignore vendored
View File

@@ -2,6 +2,8 @@
.vscode/** .vscode/**
migrations/** migrations/**
app.db app.db
keys.json
process.py
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/
@@ -131,5 +133,4 @@ venv.bak/
dmypy.json dmypy.json
# Pyre type checker # Pyre type checker
.pyre/ .pyre/
keys.json

View File

@@ -3,6 +3,7 @@ import re
from app import db, login from app import db, login
episodes = [5, 6, 22, 23, 14, 26, 24, 24, 24, 23] episodes = [5, 6, 22, 23, 14, 26, 24, 24, 24, 23]
quotePattern = r'(\w+):.+'
class Season(db.Model): class Season(db.Model):
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
@@ -61,7 +62,9 @@ class Section(db.Model):
def build(self, quotes, commit=False): def build(self, quotes, commit=False):
"""given an List of unformatted script quotes, automatically creates Quotes assigned to this Section""" """given an List of unformatted script quotes, automatically creates Quotes assigned to this Section"""
for quote in quotes: for quote in quotes:
match = re.match() if quote.lower().startswith('deleted scene'):
raise Exception(f'Deleted Scene Quote passed to Section Builder: "{quote}"')
match = re.match(quotePattern, quote)
assert match != None, f"Quote '{quote}' could not be processed." assert match != None, f"Quote '{quote}' could not be processed."
q = Quote(section=self, speaker=match[1], text=match[2]) q = Quote(section=self, speaker=match[1], text=match[2])
db.session.add(q) db.session.add(q)