Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ciclos.py #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 64 additions & 3 deletions pyerse/ciclos.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_periodo_horario(cls, time):
# Inverno
if 0 <= time.weekday() < 5:
# Seg a Sex
if cls.in_time_range(9, 30, time, 12, 00) or cls.in_time_range(
if cls.in_time_range(9, 30, time, 12, 0) or cls.in_time_range(
18, 30, time, 21, 0
):
return ph.PONTA
Expand Down Expand Up @@ -138,7 +138,7 @@ def __str__(self) -> str:
def get_periodo_horario(cls, time):
if cls.is_summer(time):
# Verão
if cls.in_time_range(10, 30, time, 13, 00) or cls.in_time_range(
if cls.in_time_range(10, 30, time, 13, 0) or cls.in_time_range(
19, 30, time, 21, 0
):
return ph.PONTA
Expand Down Expand Up @@ -176,6 +176,67 @@ def get_periodo_horario(cls, time):
return ph.VAZIO_NORMAL
if cls.in_time_range(2, 0, time, 6, 0):
return ph.SUPER_VAZIO

class Ciclo_Semanal_Acores(Ciclo):
"""Ciclo semanal Açores (os períodos horários diferem entre dias úteis e fim de semana)."""

def __str__(self) -> str:
return "Ciclo Semanal Açores"

@classmethod
def get_periodo_horario(cls, time):
if cls.is_summer(time):
# Verão
if 0 <= time.weekday() < 5:
# Seg a Sex
if cls.in_time_range(10, 30, time, 15, 30):
return ph.PONTA
if cls.in_time_range(7, 0, time, 10, 30) or cls.in_time_range(
15, 30, time, 0, 0
):
return ph.CHEIAS
if cls.in_time_range(0, 0, time, 7, 0):
return ph.VAZIO_NORMAL
if time.weekday() == 5:
# Sabado
if cls.in_time_range(11, 0, time, 14, 30) or cls.in_time_range(
19, 30, time, 23, 0
):
return ph.CHEIAS
if (
cls.in_time_range(23, 0, time, 11, 0):
return ph.VAZIO_NORMAL
if time.weekday() == 6:
# Domingo
if cls.in_time_range(0, 0, time, 0, 0):
return ph.VAZIO_NORMAL
else:
# Inverno
if 0 <= time.weekday() < 5:
# Seg a Sex
if cls.in_time_range(18, 30, time, 21, 30):
return ph.PONTA
if (
cls.in_time_range(7, 0, time, 18, 30)
or cls.in_time_range(21, 30, time, 0, 0)
):
return ph.CHEIAS
if cls.in_time_range(0, 0, time, 7, 0):
return ph.VAZIO_NORMAL
if time.weekday() == 5:
# Sabado
if cls.in_time_range(11, 30, time, 13, 0) or cls.in_time_range(
18, 0, time, 23, 0
):
return ph.CHEIAS
if (
cls.in_time_range(23, 0, time, 11, 30)
or cls.in_time_range(13, 30, time, 18, 0)
):
return ph.VAZIO_NORMAL
if time.weekday() == 6:
# Domingo
if cls.in_time_range(0, 0, time, 0, 0):
return ph.VAZIO_NORMAL

MAPPING = {str(Ciclo_Semanal()): Ciclo_Semanal, str(Ciclo_Diario()): Ciclo_Diario}
MAPPING = {str(Ciclo_Semanal()): Ciclo_Semanal, str(Ciclo_Diario()): Ciclo_Diario, str(Ciclo_Semanal_Acores()): Ciclo_Semanal_Acores}