X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=base_presence.py;h=ad852f9f7ebce82d5a76c6d7f1436a78670489e7;hb=6ba90a1f30f1c0cf4df12fcd0c62181f29bc3668;hp=f846e65bc921529229fd76b0784ad5450896b5e3;hpb=17e8082381dbbf691dfb19fb1b38a97e48d6ab87;p=python_utils.git diff --git a/base_presence.py b/base_presence.py index f846e65..ad852f9 100755 --- a/base_presence.py +++ b/base_presence.py @@ -1,20 +1,19 @@ #!/usr/bin/env python3 import datetime -from collections import defaultdict import logging import re -from typing import Dict, List, Set import warnings +from collections import defaultdict +from typing import Dict, List, Optional, Set # Note: this module is fairly early loaded. Be aware of dependencies. import argparse_utils import bootstrap import config +import site_config from type.locations import Location from type.people import Person -import site_config - logger = logging.getLogger(__name__) @@ -75,7 +74,7 @@ class PresenceDetection(object): ] = defaultdict(dict) self.names_by_mac: Dict[str, str] = {} self.dark_locations: Set[Location] = set() - self.last_update = None + self.last_update: Optional[datetime.datetime] = None def maybe_update(self) -> None: if self.last_update is None: @@ -230,9 +229,10 @@ class PresenceDetection(object): logger.debug(f'Seen {mac} ({mac_name}) at {location} since {ts}') tiebreaks[location] = ts - (most_recent_location, first_seen_ts) = dict_utils.item_with_max_value( - tiebreaks - ) + ( + most_recent_location, + first_seen_ts, + ) = dict_utils.item_with_max_value(tiebreaks) bonus = credit v = votes.get(most_recent_location, 0) votes[most_recent_location] = v + bonus