Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
panikdb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
radiopanik
panikdb
Commits
7b76664a
Commit
7b76664a
authored
Aug 30, 2013
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
program: handle extra episodes, that do not match the grid
parent
c714c215
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
panikdb/emissions/utils.py
panikdb/emissions/utils.py
+43
-0
No files found.
panikdb/emissions/utils.py
View file @
7b76664a
...
...
@@ -84,13 +84,56 @@ def period_program(date_start, date_end):
# look for a diffusion matching this schedule
d
=
[
x
for
x
in
diffusions
if
x
.
datetime
.
timetuple
()[:
5
]
==
schedule
.
datetime
.
timetuple
()[:
5
]]
if
d
:
diffusions
.
remove
(
d
[
0
])
program
[
i
]
=
d
[
0
]
for
j
,
other_schedule
in
enumerate
(
program
[
i
+
1
:]):
# remove other emissions scheduled at the same time
if
other_schedule
.
datetime
.
timetuple
()[:
5
]
==
schedule
.
datetime
.
timetuple
()[:
5
]:
program
[
i
+
1
+
j
]
=
None
else
:
break
# here we are with remaining diffusions, those that were not overriding a
# planned schedle
for
diffusion
in
diffusions
:
program
=
[
x
for
x
in
program
if
x
is
not
None
]
try
:
just_before_program
=
[
x
for
x
in
program
if
x
.
datetime
<
diffusion
.
datetime
][
-
1
]
new_diff_index
=
program
.
index
(
just_before_program
)
+
1
except
IndexError
:
# nothing before
new_diff_index
=
0
program
.
insert
(
new_diff_index
,
diffusion
)
# cut (or even remove) programs that started earlier but continued over
# this program start time
i
=
new_diff_index
while
i
>
0
:
previous
=
program
[
i
-
1
]
previous_endtime
=
previous
.
datetime
+
timedelta
(
minutes
=
previous
.
get_duration
())
if
previous_endtime
>
diffusion
.
datetime
:
previous
.
duration
=
(
diffusion
.
datetime
-
previous
.
datetime
).
seconds
/
60
if
previous
.
duration
<=
0
:
program
[
i
-
1
]
=
None
i
-=
1
# push back (or remove) programs that started before this program ends
# (this may be unnecessary as next step does that again for all
# programs)
diffusion_endtime
=
diffusion
.
datetime
+
timedelta
(
minutes
=
diffusion
.
get_duration
())
i
=
new_diff_index
while
i
<
len
(
program
)
-
1
:
next_prog
=
program
[
i
+
1
]
if
next_prog
.
datetime
<
diffusion_endtime
:
diff
=
diffusion_endtime
-
next_prog
.
datetime
if
(
diff
.
seconds
/
60
)
>
next_prog
.
get_duration
():
program
[
i
+
1
]
=
None
else
:
next_prog
.
datetime
=
diffusion_endtime
next_prog
.
duration
=
next_prog
.
get_duration
()
-
(
diff
.
seconds
/
60
)
i
+=
1
# remove overlapping programs
program
=
[
x
for
x
in
program
if
x
is
not
None
]
for
i
,
slot
in
enumerate
(
program
):
if
slot
is
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment