-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsce.py
38 lines (33 loc) · 1.17 KB
/
sce.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from disaster_scrapers import DeltaScraper
import requests
class SCEOutages(DeltaScraper):
url = "https://prodms.dms.sce.com/outage/v1/power/outage"
owner = "simonw"
repo = "sce-outages"
filepath = "sce-outages.json"
record_key = "incidentId"
noun = "incident"
def fetch_data(self):
data = requests.get(self.url, timeout=10).json()
return data["outageMapDataResponse"]["AOCIncidents"]["incident"]
def display_record(self, outage):
# Need to .strip() trailing whitespace from county
fixed = {**outage, **{"countyName": (outage.get("countyName") or "").strip()}}
display = []
display.append(
" {incidentId} in {cityName} {countyName} affecting {numberOfCustomersAffected}".format(
**fixed
)
)
display.append(
" https://www.google.com/maps/search/{centroidY},{centroidX}".format(
**fixed
)
)
display.append(
" {memoCauseCodeDescription} - {crewStatusCodeDescription}".format(
**fixed
)
)
display.append("")
return "\n".join(display)