Use f-strings in integrations starting with "B"-"E" (#32121)
* Use f-strings in integrations starting with B * Use f-strings in integrations starting with C * Use f-strings in integrations starting with D * Use f-strings in integrations starting with E * Fix pylint errors * Fix pylint errors v2 * Fix tests * Fix tests v2
This commit is contained in:
parent
07fa844c43
commit
9801810552
66 changed files with 201 additions and 315 deletions
|
@ -27,7 +27,6 @@ from homeassistant.helpers.entity import Entity
|
|||
from homeassistant.util import Throttle
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
_RESOURCE = "http://www.bom.gov.au/fwo/{}/{}.{}.json"
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ATTR_LAST_UPDATE = "last_update"
|
||||
|
@ -159,9 +158,9 @@ class BOMCurrentSensor(Entity):
|
|||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
if self.stationname is None:
|
||||
return "BOM {}".format(SENSOR_TYPES[self._condition][0])
|
||||
return f"BOM {SENSOR_TYPES[self._condition][0]}"
|
||||
|
||||
return "BOM {} {}".format(self.stationname, SENSOR_TYPES[self._condition][0])
|
||||
return f"BOM {self.stationname} {SENSOR_TYPES[self._condition][0]}"
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
@ -203,7 +202,10 @@ class BOMCurrentData:
|
|||
|
||||
def _build_url(self):
|
||||
"""Build the URL for the requests."""
|
||||
url = _RESOURCE.format(self._zone_id, self._zone_id, self._wmo_id)
|
||||
url = (
|
||||
f"http://www.bom.gov.au/fwo/{self._zone_id}"
|
||||
f"/{self._zone_id}.{self._wmo_id}.json"
|
||||
)
|
||||
_LOGGER.debug("BOM URL: %s", url)
|
||||
return url
|
||||
|
||||
|
@ -310,10 +312,10 @@ def _get_bom_stations():
|
|||
r'(?P=zone)\.(?P<wmo>\d\d\d\d\d).shtml">'
|
||||
)
|
||||
for state in ("nsw", "vic", "qld", "wa", "tas", "nt"):
|
||||
url = "http://www.bom.gov.au/{0}/observations/{0}all.shtml".format(state)
|
||||
url = f"http://www.bom.gov.au/{state}/observations/{state}all.shtml"
|
||||
for zone_id, wmo_id in re.findall(pattern, requests.get(url).text):
|
||||
zones[wmo_id] = zone_id
|
||||
return {"{}.{}".format(zones[k], k): latlon[k] for k in set(latlon) & set(zones)}
|
||||
return {f"{zones[k]}.{k}": latlon[k] for k in set(latlon) & set(zones)}
|
||||
|
||||
|
||||
def bom_stations(cache_dir):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue