Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
courses
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
R3
school
courses
Commits
1e1a72af
Commit
1e1a72af
authored
5 years ago
by
Laurent Heirendt
Browse files
Options
Downloads
Patches
Plain Diff
generate folders from template
parent
e07a3547
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
contribute.py
+17
-4
17 additions, 4 deletions
contribute.py
with
17 additions
and
4 deletions
contribute.py
+
17
−
4
View file @
1e1a72af
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
(
full
Path
))
click
.
echo
(
'
> Directory
for slides
{0} already exists.
'
.
format
(
slides
Path
))
# 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.
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment