copyright...
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""This module defines various flavors of Access Control Lists."""
import enum
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A bunch of color names mapped into RGB tuples and some methods for
setting the text color, background, etc... using ANSI escape
-sequences."""
+sequences.
+
+"""
import contextlib
import difflib
#!/usr/bin/python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Helpers for commandline argument parsing."""
import argparse
--no_enable_the_thing
"""
+
def __init__(self, option_strings, dest, default=None, required=False, help=None):
if default is None:
msg = 'You must provide a default with Yes/No action'
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A caching layer around the kernel's network mapping between IPs and MACs"""
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""This is a module dealing with trying to guess a person's location
based on the location of certain devices (e.g. phones, laptops)
belonging to that person. It works with networks I run that log
-device MAC addresses active."""
+device MAC addresses active.
+
+"""
import datetime
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""This is a module for wrapping around python programs and doing some
minor setup and tear down work for them. With it, you can break into
pdb on unhandled top level exceptions, profile your code by passing a
commandline argument in, audit module import events, examine where
-memory is being used in your program, and so on."""
+memory is being used in your program, and so on.
+
+"""
import functools
import importlib
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
+# © Copyright 2021-2022, Scott Gasch
+
+"""How's the weather?"""
+
import datetime
import json
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""How's the weather going to be tomorrow?"""
+
import datetime
import logging
import os
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Utilities for dealing with webcam images."""
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""Bidirectional Dictionary."""
+
class BiDict(dict):
def __init__(self, *args, **kwargs):
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""Binary search tree."""
+
from typing import Any, Generator, List, Optional
The MIT License (MIT)
Copyright (c) 2020 LuizaLabs
-Additions Copyright (c) 2022 Scott Gasch
+Additions/Modifications Copyright (c) 2022 Scott Gasch
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
import pickle
from contextlib import contextmanager
-from functools import wraps
from multiprocessing import RLock, shared_memory
from typing import (
Any,
ValuesView,
)
-from decorator_utils import synchronized
-
class PickleSerializer:
def dumps(self, obj: dict) -> bytes:
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""This is a Trie class, see: https://en.wikipedia.org/wiki/Trie.
- It attempts to follow Pythonic container patterns. See doctests
- for examples."""
+It attempts to follow Pythonic container patterns. See doctests
+for examples.
+
+"""
from typing import Any, Generator, Sequence
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Global configuration driven by commandline arguments, environment variables
and saved configuration files. This works across several modules.
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Universal constants."""
from typing import Final
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
+# © Copyright 2021-2022, Scott Gasch
+
"""Utilities involving converting between different units."""
from typing import Callable, SupportsFloat
# pylint: disable=W0201
# pylint: disable=R0904
+# © Copyright 2021-2022, Scott Gasch
+
"""Parse dates in a variety of formats."""
import datetime
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Utilities related to dates and times and datetimes."""
import datetime
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+# Portions (marked) below retain the original author's copyright.
+
"""Decorators."""
import enum
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""This is a helper class that tries to define every __dunder__ method
so as to defer that evaluation of an object as long as possible. It
-is used by smart_future.py as a base class."""
+is used by smart_future.py as a base class.
+
+"""
from abc import ABC, abstractmethod
from typing import Any, Generic, TypeVar
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Helper functions for dealing with dictionaries."""
from itertools import islice
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Two predicates that can help avoid unnecessary disk I/O by
detecting if a particular file is identical to the contents about to
be written or if a particular directory already contains a file that
is identical to the one to be written. See class docs below for
-examples."""
+examples.
+
+"""
import hashlib
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Some exceptions used elsewhere."""
# This module is commonly used by others in here and should avoid
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Helper methods concerned with executing subprocesses."""
import atexit
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
+# © Copyright 2021-2022, Scott Gasch
+
"""Defines three executors: a thread executor for doing work using a
threadpool, a process executor for doing work in other processes on
the same machine and a remote executor for farming out work to other
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Utilities for working with files."""
import contextlib
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Helper methods dealing with functions."""
from typing import Callable
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A module to serve as a local client library around HTTP calls to
-the Google Assistant via a local gateway."""
+the Google Assistant via a local gateway.
+
+"""
import logging
import warnings
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
+# © Copyright 2021-2022, Scott Gasch
+
"""A text-based simple histogram helper class."""
import math
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A helper class for generating thread safe monotonically increasing
-id numbers."""
+id numbers.
+
+"""
import itertools
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Utilities related to user input."""
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A simple compression helper for lowercase ascii text."""
import bitstring
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Some useful(?) utilities for dealing with Lists."""
import random
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""File-based locking helper."""
from __future__ import annotations
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
+# © Copyright 2021-2022, Scott Gasch
+
"""Utilities related to logging."""
import collections
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""This is a module concerned with the creation of and searching of a
corpus of documents. The corpus is held in memory for fast
-searching."""
+searching.
+
+"""
from __future__ import annotations
import enum
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Mathematical helpers."""
import collections
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Miscellaneous utilities."""
import os
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""This is a blueprint for training sklearn ML models."""
from __future__ import annotations
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A helper to facilitate quick manual labeling of ML training data."""
import glob
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Utilities related to changing the orb's color."""
import os
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A decorator to help with dead simple parallelization."""
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A Persistent is just a class with a load and save method. This
module defines the Persistent base and a decorator that can be used to
create a persistent singleton that autoloads and autosaves."""
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A helper to identify and optionally obscure some bad words."""
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A simple utility to unpickle some code, run it, and pickle the
results.
+
"""
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Location/site dependent data."""
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A future that can be treated like the result that it contains and
will not block until it is used. At that point, if the underlying
value is not yet available, it will block until it becomes
-available."""
+available.
+
+"""
from __future__ import annotations
import concurrent
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Utilities for dealing with the webcams."""
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Utilities for dealing with the webcams."""
import atexit
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Most basic definition of a smart device: it must have a name and a
MAC address and may have some optional keywords. All devices have
-these whether they are lights, outlets, thermostats, etc..."""
+these whether they are lights, outlets, thermostats, etc...
+
+"""
import re
from typing import List, Optional
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""General utility functions involving smart home devices."""
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Utilities for dealing with the smart lights."""
import datetime
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Utilities for dealing with the smart outlets."""
import asyncio
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A searchable registry of known smart home devices and a factory for
constructing our wrappers around them."""
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Code involving querying various smart home thermometers."""
import logging
http://www.apache.org/licenses/LICENSE-2.0
-Modifications by Scott Gasch Copyright 2020-2022 also released under
+Modifications by Scott Gasch Copyright © 2020-2022 also released under
the Apache 2.0 license as required by the license (see above).
Unless required by applicable law or agreed to in writing, software
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Several helpers to keep track of internal state via periodic
polling. StateTracker expects to be invoked periodically to maintain
state whereas the others automatically update themselves and,
-optionally, expose an event for client code to wait on state changes."""
+optionally, expose an event for client code to wait on state changes.
+
+"""
import datetime
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A simple stopwatch decorator / context for timing things."""
import contextlib
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""acl unittest."""
+
import re
import unittest
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""centcount unittest."""
+
import unittest
import unittest_utils as uu
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""dateparse_utils unittest."""
+
import datetime
import random
import re
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""decorator_utils unittest such as it is."""
+
import unittest
import decorator_utils as du
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""dict_utils unittest."""
+
import unittest
import dict_utils as du
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""exec_utils unittest."""
+
import unittest
import exec_utils
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""google_assistant unittest."""
+
import unittest
from unittest.mock import MagicMock, patch
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""letter_compress unittest."""
+
import math
import random
import unittest
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""logging_utils unittest."""
+
import os
import sys
import tempfile
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""money unittest."""
+
import unittest
import unittest_utils as uu
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""parallelize unittest."""
+
import logging
import sys
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""profanity_filter unittest, you fucker."""
+
import unittest
import profanity_filter as pf
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""rate unittest."""
+
import unittest
import unittest_utils as uu
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""This is a "test" that just runs a few system utilities that have
dependencies on this library in "do nothing" mode and makes sure they
exit cleanly.
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""shared_dict unittest."""
+
import unittest
import parallelize as p
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""string_utils unittest."""
+
import unittest
import bootstrap
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""thread_utils unittest."""
+
import threading
import time
import unittest
#!/usr/bin/env python3
-import re
+# © Copyright 2021-2022, Scott Gasch
+
+"""waitable_presence unittest."""
+
import unittest
from unittest.mock import MagicMock
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
+# © Copyright 2021-2022, Scott Gasch
+
"""Utilities for dealing with "text"."""
import contextlib
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Utilities for dealing with threads + threading."""
import functools
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""An amount of money (USD) represented as an integral count of
cents."""
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""An enum to represent locations."""
import enum
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A class to represent money. See also centcount.py"""
import re
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""An enum to represent people."""
import enum
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A class to represent a rate of change."""
from typing import Optional
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Utility functions for dealing with typing."""
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""Helpers for unittests. Note that when you import this we
- automatically wrap unittest.main() with a call to
- bootstrap.initialize so that we getLogger config, commandline args,
- logging control, etc... this works fine but it's a little hacky so
- caveat emptor.
+automatically wrap unittest.main() with a call to bootstrap.initialize
+so that we getLogger config, commandline args, logging control,
+etc... this works fine but it's a little hacky so caveat emptor.
+
"""
import contextlib
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A fast word unscrambler library."""
import logging
#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
"""A PresenceDetector that is waitable. This is not part of
base_presence.py because I do not want to bring these dependencies
into that lower-level module (especially state_tracker).