From 7dfe2039f7c53fc9f2621be9dd704bcb7681022f Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Fri, 25 Mar 2022 10:48:13 -0700 Subject: [PATCH] Add LICENSE and NOTICE. --- LICENSE | 15 +++++++++ NOTICE | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ string_utils.py | 8 ++++- 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 LICENSE create mode 100644 NOTICE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..430258e --- /dev/null +++ b/LICENSE @@ -0,0 +1,15 @@ +Except where otherwise noted in the source code (string_utils.py, +shared_dict.py, decorators.py, tplink_utils.py) and described in +the NOTICE file, all code is Copyright 2022 Scott Gasch. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..f5937ca --- /dev/null +++ b/NOTICE @@ -0,0 +1,81 @@ + +Some code in this library came from other sources. As required by +clause 4 of the Apache 2.0 License and clause 3 of the PSF License, +this NOTICE file describes changes Scott Gasch made to any preexisting +code regardless its original License. All such original code was used +in a manner compliant with its original License. This file also +contains URLs pointing at the source of the forked code. + + 1. As noted in string_utils.py, that file is a fork of work by + Davide Zanotti. Davide's original work is here: + + https://github.com/daveoncode/python-string-utils/tree/master/string_utils + + David's code was released under the MIT license. + + Scott's modifications include: + + Added these routines: strip_escape_sequences, + suffix_string_to_number, number_to_suffix_string, extract_ip_v4, + extract_ip_v6, extract_mac_address, extract_ip, to_bool, + to_date, valid_date, to_datetime, valid_datetime, squeeze, + indent, dedent, sprintf, strip_ansi_sequences, SprintfStdout, + capitalize_first_letter, it_they, is_are, pluralize, + make_contractions, thify, ngrams, ngrams_presplit, bigrams, + trigrams, shuffle_columns_into_list, shuffle_columns_into_dict, + interpolate_using_dict, to_ascii, to_base64, is_base64, from_base64, + chunk, to_bitstring, is_bitstring, from_bitstring, ip_v4_sort_key, + path_ancestors_before_descendants_sort_key, replace_all, and + replace_nth. + + Added type annotations everywhere, + + Wrote doctests everywhere, + + Wrote a supplimental unittest (tests/string_utils_test.py), + + Added logging. + + 2. As noted in shared_dict.py, that file is a fork of work by + LuizaLabs and available here: + + https://github.com/luizalabs/shared-memory-dict/blob/main/shared_memory_dict/dict.py + + The original work was released under the MIT license. + + Scott's modifications include: + + Adding a unittest (tests/shared_dict_test.py), + + Minor cleanup and style tweaks, + + Added type hints. + + 3. The timeout decortator in decorator_utils.py is based on original + work published in ActiveState code recipes and covered by the PSF + license. It is from here: + + https://code.activestate.com/recipes/307871-timing-out-function/ + + Scott's modifications include: + + Adding docs + comments including a doctest unittest, + + Minor cleanup and style tweaks, + + Added type hints. + + 4. tplink_utils.py is based on original work by Lubomir Stroetmann + that was released under the Apache 2.0 License: + + https://github.com/softScheck/tplink-smartplug + + Scott's modifications include: + + Added the pause functionality, + + Added the on/off off/on functionality, + + Ported the code to python3, + + Added type hints, + + Added timeouts / retries, + + Added logging. + +Thank you to everyone who makes their code available for reuse by +others and contributes to the open source ecosystem. Scott is +especially grateful to the authors of the projects above. Thank you. + +Any code not mentioned in this NOTICE file is work by Scott Gasch, is +copyrighted by him, and is released under the Apache 2.0 license +described in the LICENSE file. + +If you make modifications to such code, please comply with the Apache +2.0 license by retaining the LICENSE and copyright in your work and by +adding your own notices about the changes you made. See +https://www.apache.org/licenses/LICENSE-2.0 for details. diff --git a/string_utils.py b/string_utils.py index 0899576..a2f4633 100644 --- a/string_utils.py +++ b/string_utils.py @@ -857,6 +857,10 @@ def words_count(in_str: str) -> int: return len(WORDS_COUNT_RE.findall(in_str)) +def word_count(in_str: str) -> int: + return words_count(in_str) + + def generate_uuid(omit_dashes: bool = False) -> str: """ Generated an UUID string (using `uuid.uuid4()`). @@ -876,7 +880,9 @@ def generate_random_alphanumeric_string(size: int) -> str: Returns a string of the specified size containing random characters (uppercase/lowercase ascii letters and digits). - random_string(9) # possible output: "cx3QQbzYg" + >>> random.seed(22) + >>> generate_random_alphanumeric_string(9) + '96ipbNClS' """ if size < 1: -- 2.45.2