Skip to content
Snippets Groups Projects
Commit 31fb63af authored by Laurent Heirendt's avatar Laurent Heirendt :airplane:
Browse files

check date and generate the directory

parent 46c0b229
No related branches found
No related tags found
No related merge requests found
import click import click
import datetime import datetime
import os
@click.command() @click.command()
@click.option('--date', default=datetime.datetime.today().strftime('%Y-%m-%d'), help='Date of the presentation - format: YYYY-MM-DD') @click.option('--date', default=datetime.datetime.today().strftime('%Y-%m-%d'), help='Date of the presentation - format: YYYY-MM-DD')
@click.option('--name', default='myPresentation', help='Short name of the presentation.') @click.option('--name', default='myPresentation', help='Short name of the presentation.')
def copyTemplate(date, name): def copyTemplate(date, name):
"""Copies the template folder""" """Copies the template folder"""
# validate the date
validateDate(date)
# get the directory
mainDir = date[:4]
# print out a summary
click.echo(' > Date: {0}' . format(date)) click.echo(' > Date: {0}' . format(date))
click.echo(' > Name: {0}' . format(name)) click.echo(' > Name: {0}' . format(name))
click.echo(' > Directory: {0}' . format(os.path.join(os.getcwd(), mainDir, name)))
def validateDate(input):
try:
datetime.datetime.strptime(input, '%Y-%m-%d')
except ValueError:
print('The date {} is invalid'.format(input))
raise
if __name__ == '__main__': if __name__ == '__main__':
copyTemplate() copyTemplate()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment