diff --git a/README.md b/README.md index e2b6d45..0248019 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ Each feed entry is populated with the following properties: | alert_level | Alert level ("Red", "Orange", "Green"). | `gdacs:alertlevel` | | country | Country where incident happened. | `gdacs:country` | | duration_in_week | Duration of the incident in full weeks. | `gdacs:durationinweek` | +| event_id | Event ID (numerical). | `gdacs:eventid` | | event_name | Short event name. | `gdacs:eventname` | | event_type_short | Short event type ("DR, "EQ", "FL", "TC", "TS", "VO"). | `gdacs:eventtype` | | event_type | Long event type ("Drought", "Earthquake", "Flood", "Tropical Cyclone", "Tsunami", "Volcano"). | `gdacs:eventtype` | @@ -83,7 +84,7 @@ Each feed entry is populated with the following properties: | temporary | Whether this incident is temporary. | `gdacs:temporary` | | to_date | Date and time this incident ended. | `gdacs:todate` | | version | Version of the incident in this feed. | `gdacs:version` | -| vulnerability | Vulnerability score (textual or numeric). | `gdacs:vulnerability` | +| vulnerability | Vulnerability score (textual or numerical). | `gdacs:vulnerability` | ## Feed Manager diff --git a/aio_georss_gdacs/consts.py b/aio_georss_gdacs/consts.py index 5f83adf..b627bad 100644 --- a/aio_georss_gdacs/consts.py +++ b/aio_georss_gdacs/consts.py @@ -9,6 +9,7 @@ XML_TAG_GDACS_ALERT_LEVEL = 'gdacs:alertlevel' XML_TAG_GDACS_COUNTRY = 'gdacs:country' XML_TAG_GDACS_DURATION_IN_WEEK = 'gdacs:durationinweek' +XML_TAG_GDACS_EVENT_ID = 'gdacs:eventid' XML_TAG_GDACS_EVENT_NAME = 'gdacs:eventname' XML_TAG_GDACS_EVENT_TYPE = 'gdacs:eventtype' XML_TAG_GDACS_FROM_DATE = 'gdacs:fromdate' diff --git a/aio_georss_gdacs/feed_entry.py b/aio_georss_gdacs/feed_entry.py index ccce1a6..e277baf 100644 --- a/aio_georss_gdacs/feed_entry.py +++ b/aio_georss_gdacs/feed_entry.py @@ -15,7 +15,7 @@ XML_TAG_GDACS_POPULATION, XML_TAG_GDACS_SEVERITY, XML_TAG_GDACS_TEMPORARY, XML_TAG_GDACS_TO_DATE, XML_TAG_GDACS_VERSION, XML_TAG_GDACS_VULNERABILITY, - XML_TEXT) + XML_TEXT, XML_TAG_GDACS_EVENT_ID) class GdacsFeedEntry(FeedEntry): @@ -66,6 +66,16 @@ def duration_in_week(self) -> Optional[int]: return int(duration_in_week) return None + @property + def event_id(self) -> Optional[int]: + """Return the event id of this entry.""" + if self._rss_entry: + event_id = self._rss_entry.get_additional_attribute( + XML_TAG_GDACS_EVENT_ID) + if event_id: + return int(event_id) + return None + @property def event_name(self) -> Optional[str]: """Return the event name of this entry.""" diff --git a/tests/test_feed.py b/tests/test_feed.py index f2c6fe3..26193fe 100644 --- a/tests/test_feed.py +++ b/tests/test_feed.py @@ -51,6 +51,7 @@ async def test_update_ok(aresponses, event_loop): assert feed_entry.alert_level == 'Green' assert feed_entry.country == 'Mauritius' assert feed_entry.duration_in_week == 0 + assert feed_entry.event_id == 1000643 assert feed_entry.event_name == 'CALVINIA-19' assert feed_entry.event_type_short == 'TC' assert feed_entry.event_type == "Tropical Cyclone" diff --git a/tests/test_feed_entry.py b/tests/test_feed_entry.py index 7abd6fd..5d0e816 100644 --- a/tests/test_feed_entry.py +++ b/tests/test_feed_entry.py @@ -11,6 +11,7 @@ async def test_empty_feed_entry(aresponses, event_loop): assert feed_entry.alert_level is None assert feed_entry.country is None assert feed_entry.duration_in_week is None + assert feed_entry.event_id is None assert feed_entry.event_name is None assert feed_entry.event_type_short is None assert feed_entry.event_type == "Unknown"