Add --name-seo-delimiter option

master
Lertsenem 2020-07-19 22:26:34 +02:00
parent bef3d1b7b7
commit 3d7509e639
2 changed files with 21 additions and 3 deletions

View File

@ -84,14 +84,24 @@ def main():
default = None,
help = "The lkrz file in which the results are stored ; if it " \
"does not exist, one will be created from the smashgg data",
)
)
top8_parser.add_argument(
"--outfile", "-o",
default = None,
help = "The SVG local result file to output to ; defaults to " \
"./tournament-slug.svg",
)
)
top8_parser.add_argument(
"--name-seo-delimiter",
default = None,
help = "A character that will delimit in a tournament name what " \
"really is its name, and what's actually here for SEO " \
"purposes (example: in 'Cornismash #42 - Ultimate Weekly " \
"Lyon', only the 'Cornismash #42' is the tournament name, "\
"the rest is here to help find the tournament).",
)
# -------------------------------------------------------------------------
parser.add_argument( "--verbose", "-v",
@ -237,7 +247,7 @@ def main():
# Build the context which will be passed to the template
context = {
"tournament": tournament,
"tournament": tournament.clean_name(args.name_seo_delimiter),
"players" : sorted(
top_players.values(),
key = lambda p: p.placement,

View File

@ -150,6 +150,14 @@ numEntrants: {nbe}""" \
nbe = self.numEntrants,
)
# -------------------------------------------------------------------------
def clean_name(self, name_seo_delimiter):
if name_seo_delimiter is not None:
self.name = self.name.split(name_seo_delimiter)[0].strip()
return self
# =============================================================================
def run_query(