FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
programapi/src/transform.py at pre-commit-ci-update-config · EuroPython/programapi · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
EuroPython
/
programapi
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
9
Code
Issues
5
Pull requests
12
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
programapi
/
src
/
transform.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
102 lines (88 loc) · 3.36 KB
Breadcrumbs
programapi
/
src
/
transform.py
Copy path
File metadata and controls
102 lines (88 loc) · 3.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
from
argparse
import
ArgumentParser
from
src
.
config
import
Config
from
src
.
utils
.
parse
import
Parse
from
src
.
utils
.
timing_relationships
import
TimingRelationships
from
src
.
utils
.
transform
import
Transform
from
src
.
utils
.
utils
import
Utils
if
__name__
==
"__main__"
:
parser
=
ArgumentParser
(
description
=
"Transform data from Pretalx to EuroPython format and save it."
)
parser
.
add_argument
(
"-w"
,
"--warn-dupes"
,
action
=
"store_true"
,
help
=
"Warn about duplicates in the data."
,
)
parser
.
add_argument
(
"-e"
,
"--exclude"
,
choices
=
[
"schedule"
,
"youtube"
],
action
=
"append"
,
help
=
"Exclude certain data from transformation."
,
)
args
=
parser
.
parse_args
()
exclude
=
set
(
args
.
exclude
or
[])
print
(
f"Parsing submissions from
{
Config
.
raw_path
}
/submissions_latest.json..."
,
end
=
""
)
pretalx_submissions
=
Parse
.
publishable_submissions
(
Config
.
raw_path
/
"submissions_latest.json"
)
print
(
" done."
)
print
(
f"
\n
Parsing speakers from
{
Config
.
raw_path
}
/speakers_latest.json..."
,
end
=
""
)
pretalx_speakers
=
Parse
.
publishable_speakers
(
Config
.
raw_path
/
"speakers_latest.json"
,
pretalx_submissions
.
keys
()
)
print
(
" done."
)
if
"youtube"
not
in
exclude
:
print
(
f"Parsing YouTube data from
{
Config
.
raw_path
}
/youtube_latest.json..."
,
end
=
""
,
)
youtube_data
=
Parse
.
youtube
(
Config
.
raw_path
/
"youtube_latest.json"
)
print
(
" done."
)
else
:
youtube_data
=
{}
print
(
"
\n
Computing timing relationships..."
,
end
=
""
)
TimingRelationships
.
compute
(
pretalx_submissions
.
values
())
print
(
" done."
)
print
(
"
\n
Transforming submissions..."
,
end
=
""
)
ep_sessions
=
Transform
.
pretalx_submissions_to_europython_sessions
(
pretalx_submissions
,
youtube_data
,
)
print
(
" done."
)
print
(
"
\n
Transforming speakers..."
,
end
=
""
)
ep_speakers
=
Transform
.
pretalx_speakers_to_europython_speakers
(
pretalx_speakers
)
print
(
" done."
)
# Warn about duplicates if the flag is set
if
args
.
warn_dupes
:
Utils
.
warn_duplicates
(
session_attributes_to_check
=
[
"title"
],
speaker_attributes_to_check
=
[
"name"
],
sessions_to_check
=
ep_sessions
,
speakers_to_check
=
ep_speakers
,
)
print
(
f"
\n
Writing sessions to
{
Config
.
public_path
}
/sessions.json..."
,
end
=
""
)
Utils
.
write_to_file
(
Config
.
public_path
/
"sessions.json"
,
ep_sessions
)
print
(
" done."
)
print
(
f"
\n
Writing speakers to
{
Config
.
public_path
}
/speakers.json..."
,
end
=
""
)
Utils
.
write_to_file
(
Config
.
public_path
/
"speakers.json"
,
ep_speakers
)
print
(
" done."
)
if
"schedule"
not
in
exclude
:
print
(
"
\n
Parsing schedule from {Config.raw_path}/schedule_latest.json..."
,
end
=
""
)
pretalx_schedule
=
Parse
.
schedule
(
Config
.
raw_path
/
"schedule_latest.json"
)
print
(
" done."
)
print
(
f"
\n
Transforming the schedule..."
,
end
=
""
)
ep_schedule
=
Transform
.
pretalx_schedule_to_europython_schedule
(
pretalx_schedule
.
breaks
,
ep_sessions
,
ep_speakers
)
print
(
" done."
)
print
(
f"
\n
Writing schedule to
{
Config
.
public_path
}
/schedule.json..."
,
end
=
""
)
Utils
.
write_to_file
(
Config
.
public_path
/
"schedule.json"
,
ep_schedule
,
direct_dump
=
True
)
print
(
" done."
)
Back
|
FazBrowse Home
|
New Git URL