1
mirror of https://github.com/home-assistant/core synced 2024-09-25 00:41:32 +02:00

Upgrade hdate to 0.7.5 (#18296)

In 0.7.x the API to HDate was cleaned up so as to move logic from homeassistant to
the HDate external library.

This commit removes all the superfluous code, updates the required tests and changes the
requirement from version 0.6.5 to 0.7.5
This commit is contained in:
Tsvi Mostovicz 2018-11-07 14:30:41 +02:00 committed by Paulus Schoutsen
parent 29be78e08e
commit f99701f41a
4 changed files with 12 additions and 28 deletions

View File

@ -17,7 +17,7 @@ from homeassistant.helpers.entity import Entity
from homeassistant.helpers.sun import get_astral_event_date
import homeassistant.util.dt as dt_util
REQUIREMENTS = ['hdate==0.6.5']
REQUIREMENTS = ['hdate==0.7.5']
_LOGGER = logging.getLogger(__name__)
@ -113,7 +113,6 @@ class JewishCalSensor(Entity):
_LOGGER.debug("Now: %s Timezone = %s", now, now.tzinfo)
today = now.date()
upcoming_saturday = today + timedelta((12 - today.weekday()) % 7)
sunset = dt_util.as_local(get_astral_event_date(
self.hass, SUN_EVENT_SUNSET, today))
@ -124,30 +123,15 @@ class JewishCalSensor(Entity):
date = hdate.HDate(
today, diaspora=self.diaspora, hebrew=self._hebrew)
upcoming_shabbat = hdate.HDate(
upcoming_saturday, diaspora=self.diaspora, hebrew=self._hebrew)
if self.type == 'date':
self._state = hdate.date.get_hebrew_date(
date.h_day, date.h_month, date.h_year, hebrew=self._hebrew)
self._state = date.hebrew_date
elif self.type == 'weekly_portion':
self._state = hdate.date.get_parashe(
upcoming_shabbat.get_reading(self.diaspora),
hebrew=self._hebrew)
self._state = date.parasha
elif self.type == 'holiday_name':
try:
description = next(
x.description[self._hebrew]
for x in hdate.htables.HOLIDAYS
if x.index == date.get_holyday())
if not self._hebrew:
self._state = description
else:
self._state = description.long
except StopIteration:
self._state = None
self._state = date.holiday_description
elif self.type == 'holyness':
self._state = hdate.date.get_holyday_type(date.get_holyday())
self._state = date.holiday_type
else:
times = hdate.Zmanim(
date=today, latitude=self.latitude, longitude=self.longitude,

View File

@ -461,7 +461,7 @@ hangups==0.4.6
hbmqtt==0.9.4
# homeassistant.components.sensor.jewish_calendar
hdate==0.6.5
hdate==0.7.5
# homeassistant.components.climate.heatmiser
heatmiserV3==0.9.1

View File

@ -91,7 +91,7 @@ hangups==0.4.6
hbmqtt==0.9.4
# homeassistant.components.sensor.jewish_calendar
hdate==0.6.5
hdate==0.7.5
# homeassistant.components.binary_sensor.workday
holidays==0.9.8

View File

@ -64,7 +64,7 @@ class TestJewishCalenderSensor():
(dt(2018, 9, 3), 'UTC', 31.778, 35.235, "english", "date",
False, "23 Elul 5778"),
(dt(2018, 9, 3), 'UTC', 31.778, 35.235, "hebrew", "date",
False, "כ\"ג באלול ה\' תשע\"ח"),
False, "כ\"ג אלול ה\' תשע\"ח"),
(dt(2018, 9, 10), 'UTC', 31.778, 35.235, "hebrew", "holiday_name",
False, "א\' ראש השנה"),
(dt(2018, 9, 10), 'UTC', 31.778, 35.235, "english", "holiday_name",
@ -72,17 +72,17 @@ class TestJewishCalenderSensor():
(dt(2018, 9, 10), 'UTC', 31.778, 35.235, "english", "holyness",
False, 1),
(dt(2018, 9, 8), 'UTC', 31.778, 35.235, "hebrew", "weekly_portion",
False, "פרשת נצבים"),
False, "נצבים"),
(dt(2018, 9, 8), 'America/New_York', 40.7128, -74.0060, "hebrew",
"first_stars", True, time(19, 48)),
(dt(2018, 9, 8), "Asia/Jerusalem", 31.778, 35.235, "hebrew",
"first_stars", False, time(19, 21)),
(dt(2018, 10, 14), "Asia/Jerusalem", 31.778, 35.235, "hebrew",
"weekly_portion", False, "פרשת לך לך"),
"weekly_portion", False, "לך לך"),
(dt(2018, 10, 14, 17, 0, 0), "Asia/Jerusalem", 31.778, 35.235,
"hebrew", "date", False, "ה\' בחשון ה\' תשע\"ט"),
"hebrew", "date", False, "ה\' מרחשוון ה\' תשע\"ט"),
(dt(2018, 10, 14, 19, 0, 0), "Asia/Jerusalem", 31.778, 35.235,
"hebrew", "date", False, "ו\' בחשון ה\' תשע\"ט")
"hebrew", "date", False, "ו\' מרחשוון ה\' תשע\"ט")
]
test_ids = [