mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 06:05:57 +01:00
fix ispell and mypy warnings
This commit is contained in:
@@ -17,7 +17,7 @@ repos:
|
||||
hooks:
|
||||
- id: codespell
|
||||
args:
|
||||
- --ignore-words-list=hass,alot,datas,dof,dur,farenheit,hist,iff,ines,ist,lightsensor,mut,nd,pres,referer,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing
|
||||
- --ignore-words-list=hass,alot,datas,dof,dur,farenheit,hist,iff,ines,ist,lightsensor,mut,nd,pres,referer,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing, Adresse, termine, adresse
|
||||
- --skip="./.*,*.csv,*.json"
|
||||
- --quiet-level=2
|
||||
exclude_types: [csv, json]
|
||||
|
||||
@@ -7,6 +7,7 @@ import itertools
|
||||
import logging
|
||||
import os
|
||||
from itertools import islice
|
||||
from typing import Dict, List
|
||||
|
||||
from .helpers import CollectionAppointment, CollectionAppointmentGroup
|
||||
|
||||
@@ -47,7 +48,7 @@ class Customize:
|
||||
return f"Customize{{name={self.name}, alias={self.alias}, show={self.show}, icon={self.icon}, picture={self.picture}}}"
|
||||
|
||||
|
||||
def filter_function(entry: CollectionAppointment, customize: {}):
|
||||
def filter_function(entry: CollectionAppointment, customize:Dict[str,Customize]):
|
||||
c = customize.get(entry.type)
|
||||
if c is None:
|
||||
return True
|
||||
@@ -55,7 +56,7 @@ def filter_function(entry: CollectionAppointment, customize: {}):
|
||||
return c.show
|
||||
|
||||
|
||||
def customize_function(entry: CollectionAppointment, customize: {}):
|
||||
def customize_function(entry: CollectionAppointment, customize:Dict[str,Customize]):
|
||||
c = customize.get(entry.type)
|
||||
if c is not None:
|
||||
if c.alias is not None:
|
||||
@@ -68,9 +69,9 @@ def customize_function(entry: CollectionAppointment, customize: {}):
|
||||
|
||||
|
||||
class Scraper:
|
||||
def __init__(self, source: str, customize: {}):
|
||||
def __init__(self, source: str, customize:Dict[str,Customize]):
|
||||
self._source = source
|
||||
self._entries = [] # list of entries of type CollectionAppointment
|
||||
self._entries:List[CollectionAppointment] = []
|
||||
self._refreshtime = None
|
||||
self._customize = customize # dict of class Customize
|
||||
|
||||
@@ -179,7 +180,7 @@ class Scraper:
|
||||
return entries
|
||||
|
||||
@staticmethod
|
||||
def create(source_name: str, dir_offset, customize: {}, kwargs):
|
||||
def create(source_name: str, dir_offset, customize:Dict[str,Customize], kwargs):
|
||||
# load source module
|
||||
|
||||
# for home-assistant, use the last 3 folders, e.g. custom_component/wave_collection_schedule/package
|
||||
@@ -193,26 +194,9 @@ class Scraper:
|
||||
return
|
||||
|
||||
# create source
|
||||
source = source_module.Source(**kwargs)
|
||||
source = source_module.Source(**kwargs) # type: ignore
|
||||
|
||||
# create scraper
|
||||
g = Scraper(source, customize)
|
||||
|
||||
return g
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
scraper = Scraper.create("abfall_kreis_tuebingen", {}, {"ort": 3, "dropzone": 525})
|
||||
scraper.fetch()
|
||||
entries = scraper.get_upcoming()
|
||||
for e in entries:
|
||||
print(f"{e}, daysTo={e.daysTo}")
|
||||
print("========")
|
||||
types = scraper.get_types()
|
||||
for t in types:
|
||||
print(t)
|
||||
print("========")
|
||||
entries = scraper.get_upcoming_group_by_day()
|
||||
for e in entries:
|
||||
print(e)
|
||||
print("========")
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import datetime
|
||||
from typing import Dict
|
||||
|
||||
from ..helpers import CollectionAppointment
|
||||
|
||||
DESCRIPTION = "Example scraper"
|
||||
URL = ""
|
||||
TEST_CASES = {}
|
||||
TEST_CASES:Dict[str, Dict[str, str]] = {}
|
||||
|
||||
|
||||
class Source:
|
||||
|
||||
Reference in New Issue
Block a user