Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
analytics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
nomad-lab
analytics
Commits
5151053c
Commit
5151053c
authored
3 years ago
by
Luigi Sbailo
Browse files
Options
Downloads
Patches
Plain Diff
Add generate_headers script
parent
dea28cae
Branches
Branches containing commit
No related tags found
1 merge request
!123
testing develop merge
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
generate_headers.py
+55
-0
55 additions, 0 deletions
generate_headers.py
with
55 additions
and
0 deletions
generate_headers.py
0 → 100644
+
55
−
0
View file @
5151053c
from
PIL
import
Image
,
ImageDraw
,
ImageFont
import
textwrap
as
tr
import
json
import
os
if
__name__
==
'
__main__
'
:
dir_list
=
os
.
listdir
()
for
directory
in
dir_list
:
try
:
with
open
(
directory
+
'
/metainfo.json
'
,
'
r
'
)
as
f
:
file
=
f
.
read
()
metadata
=
json
.
loads
(
file
)
title
=
metadata
[
'
title
'
]
authors
=
metadata
[
'
authors
'
]
update
=
metadata
[
'
updated
'
]
title_lines
=
tr
.
wrap
(
title
,
width
=
35
)
title
=
'
\n
'
.
join
(
title_lines
)
update
=
'
Last update:
'
+
update
authors_list
=
''
for
author
in
authors
:
first_name
=
author
.
replace
(
'
,
'
,
''
).
split
()[
1
]
last_name
=
author
.
replace
(
'
,
'
,
''
).
split
()[
0
]
authors_list
=
authors_list
+
first_name
+
'
'
+
last_name
if
authors
.
index
(
author
)
<
len
(
authors
)
-
2
:
authors_list
=
authors_list
+
'
,
'
else
:
if
authors
.
index
(
author
)
==
len
(
authors
)
-
2
:
authors_list
=
authors_list
+
'
and
'
authors_lines
=
tr
.
wrap
(
authors_list
,
width
=
60
)
authors
=
'
\n
'
.
join
(
authors_lines
)
header
=
Image
.
open
(
'
files/AIT_bg_title.jpg
'
)
draw
=
ImageDraw
.
Draw
(
header
)
font_title
=
ImageFont
.
truetype
(
'
files/Titillium/TitilliumWeb-Bold.ttf
'
,
100
)
font_authors
=
ImageFont
.
truetype
(
'
files/Titillium/TitilliumWeb-Italic.ttf
'
,
60
)
font_update
=
ImageFont
.
truetype
(
'
files/Titillium/TitilliumWeb-Regular.ttf
'
,
50
)
draw
.
multiline_text
((
250
,
100
),
title
,
fill
=
'
white
'
,
font
=
font_title
)
draw
.
multiline_text
((
250
,
600
),
authors
,
fill
=
'
white
'
,
font
=
font_authors
)
draw
.
multiline_text
((
250
,
950
),
update
,
fill
=
'
white
'
,
font
=
font_update
)
list_words_dir
=
directory
.
replace
(
'
-
'
,
'
'
).
split
()[
1
:]
tutorial_name
=
list_words_dir
[
0
]
for
word
in
list_words_dir
[
1
:]:
tutorial_name
=
tutorial_name
+
'
_
'
+
word
assets_path
=
'
assets/
'
+
tutorial_name
os
.
makedirs
(
assets_path
,
exist_ok
=
True
)
header
.
save
(
assets_path
+
'
/header.jpg
'
)
except
:
pass
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