mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
fix flake8 warnings
This commit is contained in:
@@ -25,10 +25,12 @@ repos:
|
||||
rev: 3.8.1
|
||||
hooks:
|
||||
- id: flake8
|
||||
args:
|
||||
- --ignore=D100,D101,D102,D103,D104,D105,D107,E501,W503
|
||||
additional_dependencies:
|
||||
- flake8-docstrings==1.5.0
|
||||
- pydocstyle==5.0.2
|
||||
files: ^(homeassistant|script|tests)/.+\.py$
|
||||
files: ^(custom_components|script|tests)/.+\.py$
|
||||
- repo: https://github.com/PyCQA/bandit
|
||||
rev: 1.6.2
|
||||
hooks:
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
"""Waste Collection Schedule Component."""
|
||||
import asyncio
|
||||
import logging
|
||||
from random import randrange
|
||||
|
||||
@@ -68,7 +67,6 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: dict):
|
||||
"""Set up the component. config contains data from configuration.yaml."""
|
||||
|
||||
# create empty api object as singleton
|
||||
api = WasteCollectionApi(
|
||||
hass,
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import collections
|
||||
import datetime
|
||||
import importlib
|
||||
import itertools
|
||||
import logging
|
||||
import os
|
||||
from itertools import islice
|
||||
from typing import Dict, List
|
||||
|
||||
from .helpers import CollectionAppointment, CollectionAppointmentGroup
|
||||
|
||||
@@ -115,7 +115,7 @@ class AbfallnaviDe:
|
||||
return self._get_dates("hausnummern", house_number_id, waste_types=None)
|
||||
|
||||
def get_dates(self, city, street, house_number=None):
|
||||
"""Convenient function to get dates by strings only."""
|
||||
"""Get dates by strings only for convenience."""
|
||||
# find city_id
|
||||
city_id = self.get_city_id(city)
|
||||
if city_id is None:
|
||||
|
||||
@@ -74,7 +74,7 @@ class Source:
|
||||
|
||||
# get csv file
|
||||
r = requests.post(
|
||||
f"https://api.abfall.io", params=params, data=args, headers=HEADERS
|
||||
"https://api.abfall.io", params=params, data=args, headers=HEADERS
|
||||
)
|
||||
|
||||
# prepare csv reader
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from datetime import date, datetime
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
|
||||
@@ -76,7 +76,7 @@ class Source:
|
||||
}
|
||||
|
||||
# get ics file
|
||||
r = requests.get(f"https://www.abfallkalender-zak.de", params=args,)
|
||||
r = requests.get("https://www.abfallkalender-zak.de", params=args,)
|
||||
|
||||
# parse ics file
|
||||
dates = self._ics.convert(r.text)
|
||||
|
||||
@@ -28,7 +28,7 @@ class Source:
|
||||
args["end_month"] = now.month
|
||||
|
||||
# get json file
|
||||
r = requests.get(f"https://www.awbkoeln.de/api/calendar", params=args)
|
||||
r = requests.get("https://www.awbkoeln.de/api/calendar", params=args)
|
||||
|
||||
data = json.loads(r.text)
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import datetime
|
||||
import urllib.parse
|
||||
|
||||
import requests
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import datetime
|
||||
from html.parser import HTMLParser
|
||||
|
||||
import requests
|
||||
|
||||
@@ -21,7 +21,7 @@ class Source:
|
||||
|
||||
# get ics file
|
||||
r = requests.post(
|
||||
f"https://www.stadtreinigung.hamburg/privatkunden/abfuhrkalender/Abfuhrtermin.ics",
|
||||
"https://www.stadtreinigung.hamburg/privatkunden/abfuhrkalender/Abfuhrtermin.ics",
|
||||
data=args,
|
||||
)
|
||||
|
||||
|
||||
@@ -8,8 +8,10 @@ import requests
|
||||
MODUS_KEY = "d6c5855a62cf32a4dadbc2831f0f295f"
|
||||
HEADERS = {"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"}
|
||||
|
||||
# Parser for HTML option list
|
||||
|
||||
class OptionParser(HTMLParser):
|
||||
"""Parser for HTML option list."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._within_option = False
|
||||
@@ -76,7 +78,7 @@ def select_and_query(data, answers):
|
||||
|
||||
args = {"key": answers["key"], "modus": MODUS_KEY, "waction": parser.waction}
|
||||
r = requests.post(
|
||||
f"https://api.abfall.io", params=args, data=answers, headers=HEADERS
|
||||
"https://api.abfall.io", params=args, data=answers, headers=HEADERS
|
||||
)
|
||||
return r.text
|
||||
|
||||
@@ -104,7 +106,7 @@ def main():
|
||||
|
||||
# prompt for first level
|
||||
args = {"key": answers["key"], "modus": MODUS_KEY, "waction": "init"}
|
||||
r = requests.get(f"https://api.abfall.io", params=args, headers=HEADERS)
|
||||
r = requests.get("https://api.abfall.io", params=args, headers=HEADERS)
|
||||
|
||||
data = r.text
|
||||
while True:
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
import inquirer
|
||||
import requests
|
||||
|
||||
PACKAGE_PARENT = ".."
|
||||
SCRIPT_DIR = os.path.dirname(
|
||||
@@ -40,8 +38,6 @@ def main():
|
||||
# create service
|
||||
api = AbfallnaviDe(service_id)
|
||||
|
||||
SERVICE_URL = f"https://{service_id}-abfallapp.regioit.de/abfall-app-{service_id}"
|
||||
|
||||
# select city
|
||||
cities = api.get_cities()
|
||||
questions = [
|
||||
|
||||
@@ -17,7 +17,7 @@ def main():
|
||||
|
||||
args = answers
|
||||
args["form"] = "json"
|
||||
r = requests.get(f"https://www.awbkoeln.de/api/streets", params=args)
|
||||
r = requests.get("https://www.awbkoeln.de/api/streets", params=args)
|
||||
|
||||
# "data":[{"street_name":"Bahnhofplatz","building_number":"5","building_number_plain":"5","building_number_addition":"","street_code":"4270",
|
||||
# "district":"Gremberghoven","zipcode":"51149","district_code":"4","area_code":"7","user_street_name":"Bahnhofplatz","user_building_number":"1"}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import json
|
||||
from html.parser import HTMLParser
|
||||
|
||||
import inquirer
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import json
|
||||
from html.parser import HTMLParser
|
||||
|
||||
import inquirer
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import json
|
||||
from html.parser import HTMLParser
|
||||
|
||||
import inquirer
|
||||
import requests
|
||||
|
||||
@@ -24,8 +24,10 @@ CONF_LEADTIME = "leadtime"
|
||||
CONF_DATE_TEMPLATE = "date_template"
|
||||
CONF_APPOINTMENT_TYPES = "types"
|
||||
|
||||
# values for CONF_DETAILS_FORMAT
|
||||
|
||||
class DetailsFormat(Enum):
|
||||
"""Values for CONF_DETAILS_FORMAT."""
|
||||
|
||||
upcoming = "upcoming" # list of "<date> <type1, type2, ...>"
|
||||
appointment_types = "appointment_types" # list of "<type> <date>"
|
||||
generic = "generic" # all values in separate attributes
|
||||
@@ -135,7 +137,7 @@ class ScheduleSensor(Entity):
|
||||
return self._attributes
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Called if entity has been added to hass."""
|
||||
"""Entities have been added to hass."""
|
||||
self._update_sensor()
|
||||
|
||||
@property
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import argparse
|
||||
import importlib
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user