diff --git a/contribute.py b/contribute.py index 5d77ac7b3b205617bf4ea2f4e164de51c6756f8f..35884eba442f18b505fe45142491aa667e7c6e3b 100644 --- a/contribute.py +++ b/contribute.py @@ -1,6 +1,7 @@ import click import datetime import os +from distutils.dir_util import copy_tree @click.command() @click.option('--date', default=datetime.datetime.today().strftime('%Y-%m-%d'), help='Date of the presentation - format: YYYY-MM-DD') @@ -15,11 +16,15 @@ def main(date, name): # get the directory mainDir = date[:4] + # get the root directory + rootDir = os.path.dirname(os.path.realpath(__file__)) + # generate the full name of the presentation fullName = date + "_" + name # generate the full path fullPath = os.path.join(os.getcwd(), mainDir, fullName) + slidesPath = os.path.join(fullPath, 'slides') # print out a summary click.echo(' > Date: {0}' . format(date)) @@ -29,9 +34,13 @@ def main(date, name): # create the directory if not os.path.exists(fullPath): os.mkdir(fullPath) - click.echo(' > Empty directory {0} created.' . format(fullPath)) + # create an empty slides folder inside + if not os.path.exists(slidesPath): + os.mkdir(slidesPath) + + click.echo(' > Directory for slides {0} created.' . format(slidesPath)) else: - click.echo(' > Directory {0} already exists.' . format(fullPath)) + click.echo(' > Directory for slides{0} already exists.' . format(slidesPath)) # change to the root directory of the presentation os.chdir(fullPath) @@ -50,8 +59,12 @@ def main(date, name): else: click.echo(' > Symlink to package.json already exists.') - - + # copy the contents of the template folder + if not os.path.isfile(os.path.join(fullPath, 'slides', 'index.md')): + copy_tree(os.path.join(rootDir, 'template', 'slides'), slidesPath) + click.echo(' > Template slides copied.') + else: + click.echo(' > Slide deck already exists.')