Compare commits

..

No commits in common. "82e847cd2a3197991de49a3acfbe1f6faa83d484" and "e9a5b0ee519dbc12b20f65d9fad597aeb3778f92" have entirely different histories.

7 changed files with 42 additions and 31 deletions

View File

@ -18,10 +18,10 @@ class MarkdownTable:
self.rows.append(row_data)
def __str__(self):
table = "|"
table = "| "
for header in self.headers:
table += " {} |".format(header)
table += "{} | ".format(header)
table += "\n"
@ -30,6 +30,6 @@ class MarkdownTable:
for row in self.rows:
table += "\n"
table += " | ".join(map(str, row))
table += " | ".join(row)
return table

View File

@ -132,11 +132,11 @@ def get_film_list(films):
def generate_imdb_film_link(film):
return MarkdownUtils.generate_markdown_link(film['title'], generate_imdb_url(film['imdb_id']))
return generate_markdown_link(film['title'], generate_imdb_url(film['imdb_id']))
def generate_wikipedia_page_link(page_title):
return MarkdownUtils.generate_markdown_link(page_title, generate_wikipedia_url(page_title))
return generate_markdown_link(page_title, generate_wikipedia_url(page_title))
def generate_imdb_url(imdb_id):

View File

@ -38,7 +38,7 @@ def build_page(films_by_country):
png_data = draw_map(country_counter)
encoded = base64.b64encode(png_data).decode("utf-8")
image = "![](data:image/png;base64,{})".format(encoded)
page = image + "\n" + str(table)
page = image + "\n" + table
return page
@ -64,12 +64,17 @@ def build_table(films_by_country):
table = MarkdownUtils.MarkdownTable(["Country", "Films"])
for country, films in films_by_country_sorted.items():
table += "\n"
row_data = []
country_label = country
if country in flags.keys():
country += " " + flags[country]
country_label += " "
country_label += flags[country]
films = VCinemaUtils.get_film_list(films)
row_data = [country, films]
row_data.append(country_label)
row_data.append(VCinemaUtils.get_film_list(films))
table.add_row(row_data)

View File

@ -76,11 +76,16 @@ def build_page(films_by_reference):
table = MarkdownUtils.MarkdownTable(["Referenced", "Films"])
for reference, referenced in films_by_reference.items():
reference = MarkdownUtils.generate_markdown_link(reference, referenced["url"])
films = VCinemaUtils.get_film_list(referenced["films"])
table += "\n"
row_data = [reference, films]
row_data = []
table.add_row(row_data)
reference_url = referenced["url"]
referenced_films = referenced["films"]
return str(table)
row_data.append(VCinemaUtils.generate_markdown_link(reference, reference_url))
row_data.append(VCinemaUtils.get_film_list(referenced_films))
table += " | ".join(row_data)
return table

View File

@ -20,14 +20,12 @@ def update_page(token_id, token_secret, films_by_year):
def build_page(films_by_year):
films_by_year = OrderedDict(sorted(films_by_year.items(), key=lambda t: t[0], reverse=True))
films_by_year_sorted = OrderedDict(sorted(films_by_year.items(), key=lambda t: t[0], reverse=True))
table = MarkdownUtils.MarkdownTable(["Year", "Films"])
for year in films_by_year.keys():
films = VCinemaUtils.get_film_list(films_by_year[year])
row_data = [year, films]
for year in films_by_year_sorted.keys():
row_data = [str(year), VCinemaUtils.get_film_list(films_by_year_sorted[year])]
table.add_row(row_data)
return str(table)
return table

View File

@ -64,8 +64,11 @@ def build_page(hidden_themes):
table = MarkdownUtils.MarkdownTable(["Date", "Films", "Hidden Themes"])
for date, data in hidden_themes.items():
films = VCinemaUtils.get_film_list(data['viewings'])
table += "\n"
row_data = []
row_data.append(str(date))
row_data.append(VCinemaUtils.get_film_list(data['viewings']))
if 'hidden_themes' in data and data['hidden_themes'] != {}:
hidden_theme_labels = []
@ -75,11 +78,10 @@ def build_page(hidden_themes):
else:
hidden_theme_labels.append("<i>{} ({}%)</i>".format(hidden_theme, round(data['hidden_themes'][hidden_theme] * 100)))
hidden_themes = "<br>".join(hidden_theme_labels)
row_data.append("<br>".join(hidden_theme_labels))
else:
hidden_themes = "N/A"
row_data.append("N/A")
row_data = [date, films, hidden_themes]
table.add_row(row_data)
return str(table)
return table

View File

@ -70,12 +70,13 @@ def build_page(keyword_data, minimum_score=1.0):
table = MarkdownUtils.MarkdownTable(["Keyword", "Number of VCinema Films", "Total IMDb entries", "Score"])
for keyword, data in keyword_data.items():
number_of_vcinema_films = len(data['vcinema_films'])
number_of_imdb_films = data['total']
keyword_score = round(data['score'], 3)
row_data = [keyword, number_of_vcinema_films, number_of_imdb_films, keyword_score]
table += "\n"
row_data = []
row_data.append(str(keyword))
row_data.append(str(len(data['vcinema_films'])))
row_data.append(str(data['total']))
row_data.append(str(round(data['score'], 3)))
table.add_row(row_data)
return table