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
e07a3547
Commit
e07a3547
authored
5 years ago
by
Laurent Heirendt
Browse files
Options
Downloads
Patches
Plain Diff
add symlinks and echo messages
parent
31fb63af
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
+38
-4
38 additions, 4 deletions
contribute.py
with
38 additions
and
4 deletions
contribute.py
+
38
−
4
View file @
e07a3547
...
...
@@ -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
()
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