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

add symlinks and echo messages

parent 31fb63af
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,7 @@ import os
@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.')
def copyTemplate(date, name):
def main(date, name):
"""Copies the template folder"""
# validate the date
......@@ -16,13 +15,48 @@ def copyTemplate(date, name):
# get the directory
mainDir = date[:4]
# generate the full name of the presentation
fullName = date + "_" + name
# generate the full path
fullPath = os.path.join(os.getcwd(), mainDir, fullName)
# print out a summary
click.echo(' > Date: {0}' . format(date))
click.echo(' > Name: {0}' . format(name))
click.echo(' > Directory: {0}' . format(os.path.join(os.getcwd(), mainDir, name)))
click.echo(' > Directory: {0}' . format(fullPath))
# create the directory
if not os.path.exists(fullPath):
os.mkdir(fullPath)
click.echo(' > Empty directory {0} created.' . format(fullPath))
else:
click.echo(' > Directory {0} already exists.' . format(fullPath))
# change to the root directory of the presentation
os.chdir(fullPath)
# generate the symlink to the theme
if not os.path.islink('theme'):
os.symlink('../../theme', 'theme')
click.echo(' > Symlink to theme created.')
else:
click.echo(' > Symlink to theme already exists.')
# generate the symlink to the package.json file
if not os.path.islink('package.json'):
os.symlink('../../theme/package.json', 'package.json')
click.echo(' > Symlink to package.json created.')
else:
click.echo(' > Symlink to package.json already exists.')
def validateDate(input):
"""Validate a date string to fit the ISO format"""
try:
datetime.datetime.strptime(input, '%Y-%m-%d')
except ValueError:
......@@ -30,4 +64,4 @@ def validateDate(input):
raise
if __name__ == '__main__':
copyTemplate()
main()
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