More cleanup.
authorScott Gasch <[email protected]>
Thu, 10 Feb 2022 22:10:48 +0000 (14:10 -0800)
committerScott Gasch <[email protected]>
Thu, 10 Feb 2022 22:10:48 +0000 (14:10 -0800)
22 files changed:
cached/pyproject.toml [new symlink]
collect/pyproject.toml [new symlink]
collect/shared_dict.py
dateparse/dateparse_utils.py
dateparse/pyproject.toml [new symlink]
executors.py
lockfile.py
logical_search.py
ml/pyproject.toml [new symlink]
ml/quick_label.py
pyproject.toml
smart_future.py
smart_home/cameras.py
smart_home/chromecasts.py
smart_home/device_utils.py
smart_home/outlets.py
smart_home/pyproject.toml [new symlink]
smart_home/thermometers.py
string_utils.py
tests/pyproject.toml [new symlink]
tests/shared_dict_test.py
type/pyproject.toml [new symlink]

diff --git a/cached/pyproject.toml b/cached/pyproject.toml
new file mode 120000 (symlink)
index 0000000..1e11d78
--- /dev/null
@@ -0,0 +1 @@
+../pyproject.toml
\ No newline at end of file
diff --git a/collect/pyproject.toml b/collect/pyproject.toml
new file mode 120000 (symlink)
index 0000000..1e11d78
--- /dev/null
@@ -0,0 +1 @@
+../pyproject.toml
\ No newline at end of file
index e0a42f2c55c2fc865b0c89642d458ae26009c224..f4ec9143ab80b08b0ca819c4bca62cf20362fb66 100644 (file)
@@ -31,7 +31,16 @@ import pickle
 from contextlib import contextmanager
 from functools import wraps
 from multiprocessing import RLock, shared_memory
 from contextlib import contextmanager
 from functools import wraps
 from multiprocessing import RLock, shared_memory
-from typing import Any, Dict, Generator, ItemsView, Iterator, KeysView, Optional, ValuesView
+from typing import (
+    Any,
+    Dict,
+    Generator,
+    ItemsView,
+    Iterator,
+    KeysView,
+    Optional,
+    ValuesView,
+)
 
 from decorator_utils import synchronized
 
 
 from decorator_utils import synchronized
 
index 79ce8a3d749046e3e4d61fb07300ca72ce317f3f..6ba647c847e48931017292947bfe36cb423f772f 100755 (executable)
@@ -25,7 +25,12 @@ import decorator_utils
 from dateparse.dateparse_utilsLexer import dateparse_utilsLexer  # type: ignore
 from dateparse.dateparse_utilsListener import dateparse_utilsListener  # type: ignore
 from dateparse.dateparse_utilsParser import dateparse_utilsParser  # type: ignore
 from dateparse.dateparse_utilsLexer import dateparse_utilsLexer  # type: ignore
 from dateparse.dateparse_utilsListener import dateparse_utilsListener  # type: ignore
 from dateparse.dateparse_utilsParser import dateparse_utilsParser  # type: ignore
-from datetime_utils import TimeUnit, date_to_datetime, datetime_to_date, n_timeunits_from_base
+from datetime_utils import (
+    TimeUnit,
+    date_to_datetime,
+    datetime_to_date,
+    n_timeunits_from_base,
+)
 
 logger = logging.getLogger(__name__)
 
 
 logger = logging.getLogger(__name__)
 
diff --git a/dateparse/pyproject.toml b/dateparse/pyproject.toml
new file mode 120000 (symlink)
index 0000000..1e11d78
--- /dev/null
@@ -0,0 +1 @@
+../pyproject.toml
\ No newline at end of file
index 60bd166bb23ba63b227179c404d281681b35cad9..1077667147051e427b5fad045774e32c55d1a142 100644 (file)
@@ -10,7 +10,6 @@ Also defines DefaultExecutors which is a container for references to
 global executors / worker pools with automatic shutdown semantics."""
 
 from __future__ import annotations
 global executors / worker pools with automatic shutdown semantics."""
 
 from __future__ import annotations
-
 import concurrent.futures as fut
 import logging
 import os
 import concurrent.futures as fut
 import logging
 import os
index 10fe10dde1215b87c664e869b477e970de54f9f8..f64a2c3aeba2eec62ea09246db2af44409a67d69 100644 (file)
@@ -3,7 +3,6 @@
 """File-based locking helper."""
 
 from __future__ import annotations
 """File-based locking helper."""
 
 from __future__ import annotations
-
 import contextlib
 import datetime
 import json
 import contextlib
 import datetime
 import json
index c85b2628a0a25a7be6b013ec963e997799bddfc5..ef55a2bbdcbb5baafa5c29a53fc404fcfb4701bb 100644 (file)
@@ -5,7 +5,6 @@ corpus of documents.  The corpus is held in memory for fast
 searching."""
 
 from __future__ import annotations
 searching."""
 
 from __future__ import annotations
-
 import enum
 import sys
 from collections import defaultdict
 import enum
 import sys
 from collections import defaultdict
diff --git a/ml/pyproject.toml b/ml/pyproject.toml
new file mode 120000 (symlink)
index 0000000..1e11d78
--- /dev/null
@@ -0,0 +1 @@
+../pyproject.toml
\ No newline at end of file
index 120ff5fe92e644d22385741d2044d8c14d006dea..7e0a6bf64921533e00d719223d2657fb21ebbccf 100644 (file)
@@ -3,8 +3,8 @@
 import glob
 import logging
 import os
 import glob
 import logging
 import os
-from typing import Callable, List, NamedTuple, Optional, Set
 import warnings
 import warnings
+from typing import Callable, List, NamedTuple, Optional, Set
 
 import argparse_utils
 import config
 
 import argparse_utils
 import config
@@ -80,9 +80,7 @@ def label(in_spec: InputSpec) -> None:
     elif in_spec.image_file_prepopulated_list is not None:
         images += in_spec.image_file_prepopulated_list
     else:
     elif in_spec.image_file_prepopulated_list is not None:
         images += in_spec.image_file_prepopulated_list
     else:
-        raise ValueError(
-            'One of image_file_glob or image_file_prepopulated_list is required'
-        )
+        raise ValueError('One of image_file_glob or image_file_prepopulated_list is required')
 
     skip_list = read_skip_list()
     for image in images:
 
     skip_list = read_skip_list()
     for image in images:
index e8a7162110ca35732ce8faa81eabb3062629f2ad..b10ec47d9c47cfcfdcab1adfd20f435e5e179f09 100644 (file)
@@ -19,6 +19,22 @@ line-length=100
 profile="black"
 sections="FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER"
 no_lines_before="STDLIB"
 profile="black"
 sections="FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER"
 no_lines_before="STDLIB"
+known_first_party = [
+    "acl", "ansi", "argparse_utils", "arper", "base_presence", "bootstrap", "camera_utils",
+    "config", "constants", "conversion_utils", "datetime_utils", "decorator_utils", "deferred_operand",
+    "dict_utils", "directory_filter", "exceptions", "exec_utils", "executors", "file_utils",
+    "function_utils", "google_assistant", "histogram", "id_generator", "input_utils", "letter_compress",
+    "list_utils", "lockfile", "logging_utils", "logical_search", "math_utils", "misc_utils",
+    "orb_utils", "parallelize", "persistent", "profanity_filter", "remote_worker", "scott_secrets",
+    "site_config", "smart_future", "state_tracker", "stopwatch", "string_utils", "text_utils",
+    "thread_utils", "type_utils", "unittest_utils", "unscrambler", "waitable_presence",
+    "smart_home.cameras", "smart_home.chromecasts", "smart_home.device_utils", "smart_home.device",
+    "smart_home.lights", "smart_home.outlets", "smart_home.registry", "smart_home.thermometers",
+    "cached.weather_data", "cached.weather_forecast", "collect.bidict", "collect.bst",
+    "collect.shared_dict", "collect.trie", "dateparse.dateparse_utils", "ml.model_trainer",
+    "ml.quick_label", "type.centcount", "type.locations", "type.money", "type.people",
+    "type.rate",
+]
 
 [tool.pylint]
 [tool.pylint.MASTER]
 
 [tool.pylint]
 [tool.pylint.MASTER]
@@ -100,7 +116,7 @@ unsafe-load-any-extension="no"
 # --enable=similarities". If you want to run only the classes checker, but have
 # no Warning level messages displayed, use "--disable=all --enable=classes
 # --disable=W".
 # --enable=similarities". If you want to run only the classes checker, but have
 # no Warning level messages displayed, use "--disable=all --enable=classes
 # --disable=W".
-disable="invalid-name, missing-function-docstring, useless-object-inheritance, unspecified-encoding, import-outside-toplevel, raw-checker-failed, bad-inline-option, locally-disabled, line-too-long, too-few-public-methods, file-ignored, suppressed-message, useless-suppression, no-else-return, no-else-raise, no-else-break, deprecated-pragma, unnecessary-pass, use-symbolic-message-instead, broad-except"
+disable="invalid-name, missing-function-docstring, useless-object-inheritance, unspecified-encoding, import-outside-toplevel, raw-checker-failed, bad-inline-option, locally-disabled, line-too-long, too-few-public-methods, file-ignored, suppressed-message, useless-suppression, no-else-return, no-else-raise, no-else-break, deprecated-pragma, unnecessary-pass, use-symbolic-message-instead, broad-except, wrong-import-order"
 
 # Enable the message, report, category or checker with the given id(s). You can
 # either give multiple identifier separated by comma (,) or put this option
 
 # Enable the message, report, category or checker with the given id(s). You can
 # either give multiple identifier separated by comma (,) or put this option
index 9aa68f38a5396953636e257032542f9d07533225..a1f6d97741db715871d404d5a126d87a5601b503 100644 (file)
@@ -6,7 +6,6 @@ value is not yet available, it will block until it becomes
 available."""
 
 from __future__ import annotations
 available."""
 
 from __future__ import annotations
-
 import concurrent
 import concurrent.futures as fut
 import logging
 import concurrent
 import concurrent.futures as fut
 import logging
index 712d73f18f5b82db0de4fd9fdebaaafd3ec71182..f77ddc6a7ff22bac1fe1a63a6d09fb40e2dbc129 100644 (file)
@@ -10,6 +10,8 @@ logger = logging.getLogger(__name__)
 
 
 class BaseCamera(dev.Device):
 
 
 class BaseCamera(dev.Device):
+    """A base class for a webcam device."""
+
     camera_mapping = {
         'cabin_drivewaycam': 'cabin_driveway',
         'outside_backyard_camera': 'backyard',
     camera_mapping = {
         'cabin_drivewaycam': 'cabin_driveway',
         'outside_backyard_camera': 'backyard',
@@ -30,4 +32,6 @@ class BaseCamera(dev.Device):
         if name == 'driveway':
             return 'http://10.0.0.226:8080/Umtxxf1uKMBniFblqeQ9KRbb6DDzN4/mjpeg/GKlT2FfiSQ/driveway'
         else:
         if name == 'driveway':
             return 'http://10.0.0.226:8080/Umtxxf1uKMBniFblqeQ9KRbb6DDzN4/mjpeg/GKlT2FfiSQ/driveway'
         else:
-            return f'http://10.0.0.226:8080/Umtxxf1uKMBniFblqeQ9KRbb6DDzN4/mp4/GKlT2FfiSQ/{name}/s.mp4'
+            return (
+                f'http://10.0.0.226:8080/Umtxxf1uKMBniFblqeQ9KRbb6DDzN4/mp4/GKlT2FfiSQ/{name}/s.mp4'
+            )
index bec8461a4d764ce97a812f1af08f4a5087fd8869..dd6d217e3d4ce3d9a79cf4b42f930ab5e993e0e8 100644 (file)
@@ -17,6 +17,8 @@ logger = logging.getLogger(__name__)
 
 
 class BaseChromecast(dev.Device):
 
 
 class BaseChromecast(dev.Device):
+    """A base class to represent a Google Chromecase device."""
+
     ccasts: List[Any] = []
     refresh_ts = None
     browser = None
     ccasts: List[Any] = []
     refresh_ts = None
     browser = None
@@ -45,13 +47,11 @@ class BaseChromecast(dev.Device):
         self.cast = None
         for cc in BaseChromecast.ccasts:
             if cc.cast_info.host == ip and cc.cast_info.cast_type != 'group':
         self.cast = None
         for cc in BaseChromecast.ccasts:
             if cc.cast_info.host == ip and cc.cast_info.cast_type != 'group':
-                logger.debug(f'Found chromecast at {ip}: {cc}')
+                logger.debug('Found chromecast at %s: %s', ip, cc)
                 self.cast = cc
                 self.cast.wait(timeout=1.0)
         if self.cast is None:
                 self.cast = cc
                 self.cast.wait(timeout=1.0)
         if self.cast is None:
-            raise Exception(
-                f'Can\'t find ccast device at {ip}, is that really a ccast device?'
-            )
+            raise Exception(f'Can\'t find ccast device at {ip}, is that really a ccast device?')
 
     def is_idle(self):
         return self.cast.is_idle
 
     def is_idle(self):
         return self.cast.is_idle
index f79c734be49e46d5f56db1528deb49e2d66f15e8..40a7b70ed3d357797fa979bd1d0f8554abc0d789 100644 (file)
@@ -1,12 +1,11 @@
 #!/usr/bin/env python3
 
 #!/usr/bin/env python3
 
+"""General utility functions involving smart home devices."""
+
 import logging
 from typing import Any
 
 import logging
 from typing import Any
 
-import smart_home.cameras as cameras
-import smart_home.chromecasts as chromecasts
-import smart_home.lights as lights
-import smart_home.outlets as outlets
+from smart_home import cameras, chromecasts, lights, outlets
 
 logger = logging.getLogger(__name__)
 
 
 logger = logging.getLogger(__name__)
 
index a7f6f47e4225610c21b09ce7e36f547ba7f39157..60b98a63534e6897f6b448edaedebe9bb9c638b1 100644 (file)
@@ -58,11 +58,13 @@ def tplink_outlet_command(command: str) -> bool:
             logger.warning(msg)
             logging_utils.hlog(msg)
             return False
             logger.warning(msg)
             logging_utils.hlog(msg)
             return False
-    logger.debug(f'{command} succeeded.')
+    logger.debug('%s succeeded.', command)
     return True
 
 
 class BaseOutlet(dev.Device):
     return True
 
 
 class BaseOutlet(dev.Device):
+    """An abstract base class for smart outlets."""
+
     def __init__(self, name: str, mac: str, keywords: str = "") -> None:
         super().__init__(name.strip(), mac.strip(), keywords)
 
     def __init__(self, name: str, mac: str, keywords: str = "") -> None:
         super().__init__(name.strip(), mac.strip(), keywords)
 
@@ -84,6 +86,8 @@ class BaseOutlet(dev.Device):
 
 
 class TPLinkOutlet(BaseOutlet):
 
 
 class TPLinkOutlet(BaseOutlet):
+    """A TPLink smart outlet."""
+
     def __init__(self, name: str, mac: str, keywords: str = '') -> None:
         super().__init__(name, mac, keywords)
         self.info: Optional[Dict] = None
     def __init__(self, name: str, mac: str, keywords: str = '') -> None:
         super().__init__(name, mac, keywords)
         self.info: Optional[Dict] = None
@@ -150,6 +154,9 @@ class TPLinkOutlet(BaseOutlet):
 
 
 class TPLinkOutletWithChildren(TPLinkOutlet):
 
 
 class TPLinkOutletWithChildren(TPLinkOutlet):
+    """A TPLink outlet where the top and bottom plus are individually
+    controllable."""
+
     def __init__(self, name: str, mac: str, keywords: str = "") -> None:
         super().__init__(name, mac, keywords)
         self.children: List[str] = []
     def __init__(self, name: str, mac: str, keywords: str = "") -> None:
         super().__init__(name, mac, keywords)
         self.children: List[str] = []
@@ -178,7 +185,7 @@ class TPLinkOutletWithChildren(TPLinkOutlet):
         cmd = self.get_cmdline(child) + f"-c {cmd}"
         if extra_args is not None:
             cmd += f" {extra_args}"
         cmd = self.get_cmdline(child) + f"-c {cmd}"
         if extra_args is not None:
             cmd += f" {extra_args}"
-        logger.debug(f'About to execute {cmd}')
+        logger.debug('About to execute: %s', cmd)
         return tplink_outlet_command(cmd)
 
     def get_children(self) -> List[str]:
         return tplink_outlet_command(cmd)
 
     def get_children(self) -> List[str]:
@@ -208,6 +215,8 @@ class TPLinkOutletWithChildren(TPLinkOutlet):
 
 
 class GoogleOutlet(BaseOutlet):
 
 
 class GoogleOutlet(BaseOutlet):
+    """A smart outlet controlled via Google Assistant."""
+
     def __init__(self, name: str, mac: str, keywords: str = "") -> None:
         super().__init__(name.strip(), mac.strip(), keywords)
         self.info = None
     def __init__(self, name: str, mac: str, keywords: str = "") -> None:
         super().__init__(name.strip(), mac.strip(), keywords)
         self.info = None
@@ -285,6 +294,8 @@ class MerossWrapper(object):
 
 
 class MerossOutlet(BaseOutlet):
 
 
 class MerossOutlet(BaseOutlet):
+    """A Meross smart outlet class."""
+
     def __init__(self, name: str, mac: str, keywords: str = '') -> None:
         super().__init__(name, mac, keywords)
         self.meross_wrapper: Optional[MerossWrapper] = None
     def __init__(self, name: str, mac: str, keywords: str = '') -> None:
         super().__init__(name, mac, keywords)
         self.meross_wrapper: Optional[MerossWrapper] = None
diff --git a/smart_home/pyproject.toml b/smart_home/pyproject.toml
new file mode 120000 (symlink)
index 0000000..1e11d78
--- /dev/null
@@ -0,0 +1 @@
+../pyproject.toml
\ No newline at end of file
index dff84f6250dfb410f11ed6dd81ef42d87fd54148..90199b9cdaa3dd0e2f09c9a7a521b0b03c8b7e5b 100644 (file)
@@ -1,5 +1,7 @@
 #!/usr/bin/env python3
 
 #!/usr/bin/env python3
 
+"""Code involving querying various smart home thermometers."""
+
 import logging
 import urllib.request
 from typing import Optional
 import logging
 import urllib.request
 from typing import Optional
@@ -8,6 +10,8 @@ logger = logging.getLogger()
 
 
 class ThermometerRegistry(object):
 
 
 class ThermometerRegistry(object):
+    """A registry of thermometer hosts / names and how to talk with them."""
+
     def __init__(self):
         self.thermometers = {
             'house_outside': ('10.0.0.75', 'outside_temp'),
     def __init__(self):
         self.thermometers = {
             'house_outside': ('10.0.0.75', 'outside_temp'),
@@ -25,11 +29,13 @@ class ThermometerRegistry(object):
         record = self.thermometers.get(location, None)
         if record is None:
             logger.error(
         record = self.thermometers.get(location, None)
         if record is None:
             logger.error(
-                f'Location {location} is not known.  Valid locations are {self.thermometers.keys()}.'
+                'Location %s is not known.  Valid locations are %s.',
+                location,
+                self.thermometers.keys(),
             )
             return None
         url = f'http://{record[0]}/~pi/{record[1]}'
             )
             return None
         url = f'http://{record[0]}/~pi/{record[1]}'
-        logger.debug(f'Constructed URL: {url}')
+        logger.debug('Constructed URL: %s', url)
         try:
             www = urllib.request.urlopen(url, timeout=3)
             temp = www.read().decode('utf-8')
         try:
             www = urllib.request.urlopen(url, timeout=3)
             temp = www.read().decode('utf-8')
@@ -40,7 +46,7 @@ class ThermometerRegistry(object):
                 temp = round(temp)
         except Exception as e:
             logger.exception(e)
                 temp = round(temp)
         except Exception as e:
             logger.exception(e)
-            logger.error(f'Failed to read temperature at URL: {url}')
+            logger.error('Failed to read temperature at URL: %s', url)
             temp = None
         finally:
             if www is not None:
             temp = None
         finally:
             if www is not None:
index adfb149204b525327fc854fc56d6ab5645e321bc..4bec031738e989d10507992387e18aa47996da8e 100644 (file)
@@ -40,7 +40,17 @@ import string
 import unicodedata
 import warnings
 from itertools import zip_longest
 import unicodedata
 import warnings
 from itertools import zip_longest
-from typing import Any, Callable, Dict, Iterable, List, Literal, Optional, Sequence, Tuple
+from typing import (
+    Any,
+    Callable,
+    Dict,
+    Iterable,
+    List,
+    Literal,
+    Optional,
+    Sequence,
+    Tuple,
+)
 from uuid import uuid4
 
 import list_utils
 from uuid import uuid4
 
 import list_utils
diff --git a/tests/pyproject.toml b/tests/pyproject.toml
new file mode 120000 (symlink)
index 0000000..1e11d78
--- /dev/null
@@ -0,0 +1 @@
+../pyproject.toml
\ No newline at end of file
index c8294c5bd256e9f2f81c0c0320a0ab2ca065a4ab..0b73a45bdabbb663873c9ac883e045a642fd3cc3 100755 (executable)
@@ -2,10 +2,10 @@
 
 import unittest
 
 
 import unittest
 
-from collect.shared_dict import SharedDict
 import parallelize as p
 import smart_future
 import unittest_utils
 import parallelize as p
 import smart_future
 import unittest_utils
+from collect.shared_dict import SharedDict
 
 
 class SharedDictTest(unittest.TestCase):
 
 
 class SharedDictTest(unittest.TestCase):
diff --git a/type/pyproject.toml b/type/pyproject.toml
new file mode 120000 (symlink)
index 0000000..1e11d78
--- /dev/null
@@ -0,0 +1 @@
+../pyproject.toml
\ No newline at end of file