mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Adjust Calendar doc strings and comments (#101655)
This commit is contained in:
parent
7c85d84133
commit
5087f0056c
@ -813,7 +813,7 @@ def _validate_timespan(
|
|||||||
|
|
||||||
This converts the input service arguments into a `start` and `end` date or date time. This
|
This converts the input service arguments into a `start` and `end` date or date time. This
|
||||||
exists because service calls use `start_date` and `start_date_time` whereas the
|
exists because service calls use `start_date` and `start_date_time` whereas the
|
||||||
normal entity methods can take either a `datetim` or `date` as a single `start` argument.
|
normal entity methods can take either a `datetime` or `date` as a single `start` argument.
|
||||||
It also handles the other service call variations like "in days" as well.
|
It also handles the other service call variations like "in days" as well.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -849,7 +849,7 @@ async def async_create_event(entity: CalendarEntity, call: ServiceCall) -> None:
|
|||||||
async def async_list_events_service(
|
async def async_list_events_service(
|
||||||
calendar: CalendarEntity, service_call: ServiceCall
|
calendar: CalendarEntity, service_call: ServiceCall
|
||||||
) -> ServiceResponse:
|
) -> ServiceResponse:
|
||||||
"""List events on a calendar during a time drange."""
|
"""List events on a calendar during a time range."""
|
||||||
start = service_call.data.get(EVENT_START_DATETIME, dt_util.now())
|
start = service_call.data.get(EVENT_START_DATETIME, dt_util.now())
|
||||||
if EVENT_DURATION in service_call.data:
|
if EVENT_DURATION in service_call.data:
|
||||||
end = start + service_call.data[EVENT_DURATION]
|
end = start + service_call.data[EVENT_DURATION]
|
||||||
|
@ -75,15 +75,15 @@ class Timespan:
|
|||||||
|
|
||||||
This effectively gives us a cursor like interface for advancing through
|
This effectively gives us a cursor like interface for advancing through
|
||||||
time using the interval as a hint. The returned span may have a
|
time using the interval as a hint. The returned span may have a
|
||||||
different interval than the one specified. For example, time span may
|
different interval than the one specified. For example, time span may
|
||||||
be longer during a daylight saving time transition, or may extend due to
|
be longer during a daylight saving time transition, or may extend due to
|
||||||
drift if the current interval is old. The returned time span is
|
drift if the current interval is old. The returned time span is
|
||||||
adjacent and non-overlapping.
|
adjacent and non-overlapping.
|
||||||
"""
|
"""
|
||||||
return Timespan(self.end, max(self.end, now) + interval)
|
return Timespan(self.end, max(self.end, now) + interval)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
"""Return a string representing the half open interval timespan."""
|
"""Return a string representing the half open interval time span."""
|
||||||
return f"[{self.start}, {self.end})"
|
return f"[{self.start}, {self.end})"
|
||||||
|
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ def queued_event_fetcher(
|
|||||||
offset_timespan = timespan.with_offset(-1 * offset)
|
offset_timespan = timespan.with_offset(-1 * offset)
|
||||||
active_events = await fetcher(offset_timespan)
|
active_events = await fetcher(offset_timespan)
|
||||||
|
|
||||||
# Determine the trigger eligibilty of events during this time span.
|
# Determine the trigger eligibility of events during this time span.
|
||||||
# Example: For an EVENT_END trigger the event may start during this
|
# Example: For an EVENT_END trigger the event may start during this
|
||||||
# time span, but need to be triggered later when the end happens.
|
# time span, but need to be triggered later when the end happens.
|
||||||
results = []
|
results = []
|
||||||
@ -130,7 +130,7 @@ def queued_event_fetcher(
|
|||||||
results.append(QueuedCalendarEvent(trigger_time + offset, event))
|
results.append(QueuedCalendarEvent(trigger_time + offset, event))
|
||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Scan events @ %s%s found %s eligble of %s active",
|
"Scan events @ %s%s found %s eligible of %s active",
|
||||||
offset_timespan,
|
offset_timespan,
|
||||||
f" (offset={offset})" if offset else "",
|
f" (offset={offset})" if offset else "",
|
||||||
len(results),
|
len(results),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user