Skip to content

Commit

Permalink
Merge 7aafe10 into 2589964
Browse files Browse the repository at this point in the history
  • Loading branch information
exxamalte committed Jan 20, 2020
2 parents 2589964 + 7aafe10 commit dd5b86f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -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` |
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions aio_georss_gdacs/consts.py
Expand Up @@ -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'
Expand Down
12 changes: 11 additions & 1 deletion aio_georss_gdacs/feed_entry.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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."""
Expand Down
1 change: 1 addition & 0 deletions tests/test_feed.py
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tests/test_feed_entry.py
Expand Up @@ -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"
Expand Down

0 comments on commit dd5b86f

Please sign in to comment.