Merge pull request 'add helper functions' (#9) from simplify-markdown-link-create into master
Reviewed-on: #9
This commit is contained in:
commit
e47d22aa22
|
@ -121,10 +121,22 @@ def get_film_list(films):
|
|||
film_links = []
|
||||
|
||||
for film in films:
|
||||
film_link = "[{}](https://www.imdb.com/title/tt{}/)".format(film['title'], film['imdb_id'])
|
||||
film_link = generate_imdb_film_link(film)
|
||||
film_links.append(film_link)
|
||||
|
||||
if len(film_links) > 0:
|
||||
return "<br>".join(film_links)
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
def generate_markdown_link(text, url):
|
||||
return "[{}]({})".format(text, url)
|
||||
|
||||
|
||||
def generate_imdb_film_link(film):
|
||||
return generate_markdown_link(film['title'], "https://www.imdb.com/title/tt{}/".format(film['imdb_id']))
|
||||
|
||||
|
||||
def generate_wikipedia_page_link(page_title):
|
||||
return generate_markdown_link(page_title, "https://en.wikipedia.org/wiki/{}".format(page_title.replace(" ", "_")))
|
||||
|
|
|
@ -29,7 +29,7 @@ def build_page(films_by_reference_keyword):
|
|||
table += "\n"
|
||||
|
||||
row_data = []
|
||||
row_data.append("[{}](https://en.wikipedia.org/wiki/{})".format(str(string.capwords(year[13:].replace("-", " "))), str(string.capwords(year[13:].replace("-", " ")).replace(" ", "_"))))
|
||||
row_data.append(VCinemaUtils.generate_wikipedia_page_link(string.capwords(year[13:].replace("-", " "))))
|
||||
row_data.append(VCinemaUtils.get_film_list(reference_keywords_sorted[year]))
|
||||
|
||||
table += " | ".join(row_data)
|
||||
|
|
Loading…
Reference in New Issue