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

generate folders from template

parent e07a3547
No related branches found
No related tags found
No related merge requests found
import click import click
import datetime import datetime
import os import os
from distutils.dir_util import copy_tree
@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')
...@@ -15,11 +16,15 @@ def main(date, name): ...@@ -15,11 +16,15 @@ def main(date, name):
# get the directory # get the directory
mainDir = date[:4] mainDir = date[:4]
# get the root directory
rootDir = os.path.dirname(os.path.realpath(__file__))
# generate the full name of the presentation # generate the full name of the presentation
fullName = date + "_" + name fullName = date + "_" + name
# generate the full path # generate the full path
fullPath = os.path.join(os.getcwd(), mainDir, fullName) fullPath = os.path.join(os.getcwd(), mainDir, fullName)
slidesPath = os.path.join(fullPath, 'slides')
# print out a summary # print out a summary
click.echo(' > Date: {0}' . format(date)) click.echo(' > Date: {0}' . format(date))
...@@ -29,9 +34,13 @@ def main(date, name): ...@@ -29,9 +34,13 @@ def main(date, name):
# create the directory # create the directory
if not os.path.exists(fullPath): if not os.path.exists(fullPath):
os.mkdir(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: 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 # change to the root directory of the presentation
os.chdir(fullPath) os.chdir(fullPath)
...@@ -50,8 +59,12 @@ def main(date, name): ...@@ -50,8 +59,12 @@ def main(date, name):
else: else:
click.echo(' > Symlink to package.json already exists.') 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.')
......
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