more work reformatting all method comments

This commit is contained in:
Xevion
2020-03-10 18:25:24 -05:00
parent 24dde199e2
commit d915a862d6

View File

@@ -189,14 +189,19 @@ class Episode(db.Model):
def build(self): def build(self):
"""downloads, processes, and automatically creates Sections and Quotes""" """
Downloads, Processes, and Automatically creates Sections and Quotes
"""
self.built = True self.built = True
self.title = titles[self.season_id][self.number - 1] self.title = titles[self.season_id][self.number - 1]
print(self.title) print(self.title)
db.session.commit() db.session.commit()
def rebuild(self): def rebuild(self):
"""functions that clears relevant sections from this Episode""" """
Clears all sections f
"""
print(f'Rebuilding s{self.season_id} e{self.number}') print(f'Rebuilding s{self.season_id} e{self.number}')
self.clear() self.clear()
self.build() self.build()
@@ -204,17 +209,20 @@ class Episode(db.Model):
def clear(self): def clear(self):
"""delete all sections relevant to this episode in order to reprocess""" """delete all sections relevant to this episode in order to reprocess"""
sections = Section.query.filter_by(episode_id=self.id).all() sections = Section.query.filter_by(episode_id=self.id).all()
print( if len(sections > 0):
f"Clearing {len(sections)} Sections of Ep {self.number} Season {self.season_id}" print(f"Clearing {len(sections)} Sections of Ep {self.number} Season {self.season_id}")
) for section in sections:
for section in sections: section.clear(commit=False, delete=True)
section.clear(commit=False, delete=True) self.built = False
self.built = False db.session.commit()
db.session.commit() else:
print('No sections for this episode (s{self.season_id}/e{self.number}) could be found.')
@staticmethod @staticmethod
def clear_all(): def clear_all():
"""runs clear() on every episode in the database""" """
Runs clear() on every episode in the database
"""
print('Clearing all episodes in database.') print('Clearing all episodes in database.')
for episode in Episode.query.all(): for episode in Episode.query.all():
episode.clear() episode.clear()
@@ -234,7 +242,9 @@ class Section(db.Model):
quotes = db.relationship("Quote", backref="section", lazy="dynamic") quotes = db.relationship("Quote", backref="section", lazy="dynamic")
def build(self, quotes, commit=False, reset=False): def build(self, quotes, commit=False, reset=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 i, quote in enumerate(quotes): for i, quote in enumerate(quotes):
if quote.lower().startswith("deleted scene"): if quote.lower().startswith("deleted scene"):
raise Exception( raise Exception(
@@ -255,7 +265,9 @@ class Section(db.Model):
db.session.commit() db.session.commit()
def clear(self, doprint=False, commit=True, delete=False): def clear(self, doprint=False, commit=True, delete=False):
"""delete all quotes relevant to this section""" """
Delete all quotes relevant to this section.
"""
quotes = Quote.query.filter_by(section_id=self.id).all() quotes = Quote.query.filter_by(section_id=self.id).all()
if doprint: if doprint:
print(f"Clearing {len(quotes)} quotes from Section ID {self.id}") print(f"Clearing {len(quotes)} quotes from Section ID {self.id}")