diff --git a/lib/python3.10/site-packages/certifi/__pycache__/__init__.cpython-310.pyc b/lib/python3.10/site-packages/certifi/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fb53409ac5906a8f3c9872525176afb10c2b6606 Binary files /dev/null and b/lib/python3.10/site-packages/certifi/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/certifi/__pycache__/__main__.cpython-310.pyc b/lib/python3.10/site-packages/certifi/__pycache__/__main__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e1c3266d8faf4c558e5a1e96c882538a6977c93c Binary files /dev/null and b/lib/python3.10/site-packages/certifi/__pycache__/__main__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/certifi/__pycache__/core.cpython-310.pyc b/lib/python3.10/site-packages/certifi/__pycache__/core.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..594143b416d4c044fb8a8b9bf5651ef71bcd18de Binary files /dev/null and b/lib/python3.10/site-packages/certifi/__pycache__/core.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/__init__.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..023244c6853df77826a6fad6f29ffd8b31888ab0 Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/api.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/api.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a1ab99b089e51f411e7254001e45f7c37abd490e Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/api.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/backend_ctypes.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/backend_ctypes.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7c58395cef60058ac62abe6d885c851850f753fd Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/backend_ctypes.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/cffi_opcode.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/cffi_opcode.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2661eac8c15a8b7e46cd84face9829dfde9a44be Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/cffi_opcode.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/commontypes.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/commontypes.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d64a90c0850cec22ef4a22e8fc2a11aed4e15687 Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/commontypes.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/cparser.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/cparser.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c7d8df98fc4bda6f5c624183f1b5b1a93edd871a Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/cparser.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/error.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/error.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9f7c2dd107c2482c39aeb33b1bbae046e55c57b0 Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/error.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/ffiplatform.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/ffiplatform.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e131bc2703e6c393b1f4fe0907ef0760c8cb2b1a Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/ffiplatform.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/lock.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/lock.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0faf829ff0c9db59b651e7dcd5eec1cde9da93da Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/lock.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/model.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/model.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c1a319f7d86983bf541d1a957283f5c1785137e1 Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/model.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/pkgconfig.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/pkgconfig.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cadc16a481f05fcc71ca7799eb8ea0e4c59b057b Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/pkgconfig.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/recompiler.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/recompiler.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ff46334efe7f1d8dd7b601224abcc93da665eada Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/recompiler.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/setuptools_ext.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/setuptools_ext.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..902b2af4f448d04da43daa99a6ad257f3c3ee7ca Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/setuptools_ext.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/vengine_cpy.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/vengine_cpy.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7e953ef862526fe32786d7870baf209c3c3b02a8 Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/vengine_cpy.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/vengine_gen.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/vengine_gen.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fdf7e4a393b87fc9ae15175fbdfe64ab75da5030 Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/vengine_gen.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cffi/__pycache__/verifier.cpython-310.pyc b/lib/python3.10/site-packages/cffi/__pycache__/verifier.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a32b0d924072be67170e4a4eb0c788dee2381950 Binary files /dev/null and b/lib/python3.10/site-packages/cffi/__pycache__/verifier.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/charset_normalizer/__pycache__/__init__.cpython-310.pyc b/lib/python3.10/site-packages/charset_normalizer/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9221da9f5f57ca31e305e4018973c5af2e3685f3 Binary files /dev/null and b/lib/python3.10/site-packages/charset_normalizer/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/charset_normalizer/__pycache__/__main__.cpython-310.pyc b/lib/python3.10/site-packages/charset_normalizer/__pycache__/__main__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a3a898cdcaab2c8c212f16868a2219ee5abd9a34 Binary files /dev/null and b/lib/python3.10/site-packages/charset_normalizer/__pycache__/__main__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/charset_normalizer/__pycache__/api.cpython-310.pyc b/lib/python3.10/site-packages/charset_normalizer/__pycache__/api.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2dc751959c813d931860ea8b38230774ff9e3694 Binary files /dev/null and b/lib/python3.10/site-packages/charset_normalizer/__pycache__/api.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/charset_normalizer/__pycache__/cd.cpython-310.pyc b/lib/python3.10/site-packages/charset_normalizer/__pycache__/cd.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..30497cbb6baf447adf0959eb0fde2d355baa82cf Binary files /dev/null and b/lib/python3.10/site-packages/charset_normalizer/__pycache__/cd.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/charset_normalizer/__pycache__/constant.cpython-310.pyc b/lib/python3.10/site-packages/charset_normalizer/__pycache__/constant.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..be289b46ff37eca1890ffbb631b1e9ff9038ab90 Binary files /dev/null and b/lib/python3.10/site-packages/charset_normalizer/__pycache__/constant.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/charset_normalizer/__pycache__/legacy.cpython-310.pyc b/lib/python3.10/site-packages/charset_normalizer/__pycache__/legacy.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3e2330ce68c4b82eac390995af0a051b46ca1b20 Binary files /dev/null and b/lib/python3.10/site-packages/charset_normalizer/__pycache__/legacy.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/charset_normalizer/__pycache__/md.cpython-310.pyc b/lib/python3.10/site-packages/charset_normalizer/__pycache__/md.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c4ebcd7ad6ef69a5446563d2e1c70f06fb3068cb Binary files /dev/null and b/lib/python3.10/site-packages/charset_normalizer/__pycache__/md.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/charset_normalizer/__pycache__/models.cpython-310.pyc b/lib/python3.10/site-packages/charset_normalizer/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..44e09dfe67e9c3b7705a518c716a51cde853a373 Binary files /dev/null and b/lib/python3.10/site-packages/charset_normalizer/__pycache__/models.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/charset_normalizer/__pycache__/utils.cpython-310.pyc b/lib/python3.10/site-packages/charset_normalizer/__pycache__/utils.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..33ab3a48065db056bf01f8866a40a27d994e51a0 Binary files /dev/null and b/lib/python3.10/site-packages/charset_normalizer/__pycache__/utils.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/charset_normalizer/__pycache__/version.cpython-310.pyc b/lib/python3.10/site-packages/charset_normalizer/__pycache__/version.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5c13e3398de57e3b9444515375fa4ea5fa16c6e5 Binary files /dev/null and b/lib/python3.10/site-packages/charset_normalizer/__pycache__/version.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/charset_normalizer/cli/__init__.py b/lib/python3.10/site-packages/charset_normalizer/cli/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d95fedfe5723713337f1a94ec8f0a00b6ca7816a --- /dev/null +++ b/lib/python3.10/site-packages/charset_normalizer/cli/__init__.py @@ -0,0 +1,6 @@ +from .__main__ import cli_detect, query_yes_no + +__all__ = ( + "cli_detect", + "query_yes_no", +) diff --git a/lib/python3.10/site-packages/charset_normalizer/cli/__main__.py b/lib/python3.10/site-packages/charset_normalizer/cli/__main__.py new file mode 100644 index 0000000000000000000000000000000000000000..f4bcbaac049b542a004918a0b1499122fcca9cc0 --- /dev/null +++ b/lib/python3.10/site-packages/charset_normalizer/cli/__main__.py @@ -0,0 +1,296 @@ +import argparse +import sys +from json import dumps +from os.path import abspath, basename, dirname, join, realpath +from platform import python_version +from typing import List, Optional +from unicodedata import unidata_version + +import charset_normalizer.md as md_module +from charset_normalizer import from_fp +from charset_normalizer.models import CliDetectionResult +from charset_normalizer.version import __version__ + + +def query_yes_no(question: str, default: str = "yes") -> bool: + """Ask a yes/no question via input() and return their answer. + + "question" is a string that is presented to the user. + "default" is the presumed answer if the user just hits . + It must be "yes" (the default), "no" or None (meaning + an answer is required of the user). + + The "answer" return value is True for "yes" or False for "no". + + Credit goes to (c) https://stackoverflow.com/questions/3041986/apt-command-line-interface-like-yes-no-input + """ + valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False} + if default is None: + prompt = " [y/n] " + elif default == "yes": + prompt = " [Y/n] " + elif default == "no": + prompt = " [y/N] " + else: + raise ValueError("invalid default answer: '%s'" % default) + + while True: + sys.stdout.write(question + prompt) + choice = input().lower() + if default is not None and choice == "": + return valid[default] + elif choice in valid: + return valid[choice] + else: + sys.stdout.write("Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n") + + +def cli_detect(argv: Optional[List[str]] = None) -> int: + """ + CLI assistant using ARGV and ArgumentParser + :param argv: + :return: 0 if everything is fine, anything else equal trouble + """ + parser = argparse.ArgumentParser( + description="The Real First Universal Charset Detector. " + "Discover originating encoding used on text file. " + "Normalize text to unicode." + ) + + parser.add_argument( + "files", type=argparse.FileType("rb"), nargs="+", help="File(s) to be analysed" + ) + parser.add_argument( + "-v", + "--verbose", + action="store_true", + default=False, + dest="verbose", + help="Display complementary information about file if any. " + "Stdout will contain logs about the detection process.", + ) + parser.add_argument( + "-a", + "--with-alternative", + action="store_true", + default=False, + dest="alternatives", + help="Output complementary possibilities if any. Top-level JSON WILL be a list.", + ) + parser.add_argument( + "-n", + "--normalize", + action="store_true", + default=False, + dest="normalize", + help="Permit to normalize input file. If not set, program does not write anything.", + ) + parser.add_argument( + "-m", + "--minimal", + action="store_true", + default=False, + dest="minimal", + help="Only output the charset detected to STDOUT. Disabling JSON output.", + ) + parser.add_argument( + "-r", + "--replace", + action="store_true", + default=False, + dest="replace", + help="Replace file when trying to normalize it instead of creating a new one.", + ) + parser.add_argument( + "-f", + "--force", + action="store_true", + default=False, + dest="force", + help="Replace file without asking if you are sure, use this flag with caution.", + ) + parser.add_argument( + "-t", + "--threshold", + action="store", + default=0.2, + type=float, + dest="threshold", + help="Define a custom maximum amount of chaos allowed in decoded content. 0. <= chaos <= 1.", + ) + parser.add_argument( + "--version", + action="version", + version="Charset-Normalizer {} - Python {} - Unicode {} - SpeedUp {}".format( + __version__, + python_version(), + unidata_version, + "OFF" if md_module.__file__.lower().endswith(".py") else "ON", + ), + help="Show version information and exit.", + ) + + args = parser.parse_args(argv) + + if args.replace is True and args.normalize is False: + print("Use --replace in addition of --normalize only.", file=sys.stderr) + return 1 + + if args.force is True and args.replace is False: + print("Use --force in addition of --replace only.", file=sys.stderr) + return 1 + + if args.threshold < 0.0 or args.threshold > 1.0: + print("--threshold VALUE should be between 0. AND 1.", file=sys.stderr) + return 1 + + x_ = [] + + for my_file in args.files: + matches = from_fp(my_file, threshold=args.threshold, explain=args.verbose) + + best_guess = matches.best() + + if best_guess is None: + print( + 'Unable to identify originating encoding for "{}". {}'.format( + my_file.name, + "Maybe try increasing maximum amount of chaos." + if args.threshold < 1.0 + else "", + ), + file=sys.stderr, + ) + x_.append( + CliDetectionResult( + abspath(my_file.name), + None, + [], + [], + "Unknown", + [], + False, + 1.0, + 0.0, + None, + True, + ) + ) + else: + x_.append( + CliDetectionResult( + abspath(my_file.name), + best_guess.encoding, + best_guess.encoding_aliases, + [ + cp + for cp in best_guess.could_be_from_charset + if cp != best_guess.encoding + ], + best_guess.language, + best_guess.alphabets, + best_guess.bom, + best_guess.percent_chaos, + best_guess.percent_coherence, + None, + True, + ) + ) + + if len(matches) > 1 and args.alternatives: + for el in matches: + if el != best_guess: + x_.append( + CliDetectionResult( + abspath(my_file.name), + el.encoding, + el.encoding_aliases, + [ + cp + for cp in el.could_be_from_charset + if cp != el.encoding + ], + el.language, + el.alphabets, + el.bom, + el.percent_chaos, + el.percent_coherence, + None, + False, + ) + ) + + if args.normalize is True: + if best_guess.encoding.startswith("utf") is True: + print( + '"{}" file does not need to be normalized, as it already came from unicode.'.format( + my_file.name + ), + file=sys.stderr, + ) + if my_file.closed is False: + my_file.close() + continue + + dir_path = dirname(realpath(my_file.name)) + file_name = basename(realpath(my_file.name)) + + o_: List[str] = file_name.split(".") + + if args.replace is False: + o_.insert(-1, best_guess.encoding) + if my_file.closed is False: + my_file.close() + elif ( + args.force is False + and query_yes_no( + 'Are you sure to normalize "{}" by replacing it ?'.format( + my_file.name + ), + "no", + ) + is False + ): + if my_file.closed is False: + my_file.close() + continue + + try: + x_[0].unicode_path = join(dir_path, ".".join(o_)) + + with open(x_[0].unicode_path, "w", encoding="utf-8") as fp: + fp.write(str(best_guess)) + except IOError as e: + print(str(e), file=sys.stderr) + if my_file.closed is False: + my_file.close() + return 2 + + if my_file.closed is False: + my_file.close() + + if args.minimal is False: + print( + dumps( + [el.__dict__ for el in x_] if len(x_) > 1 else x_[0].__dict__, + ensure_ascii=True, + indent=4, + ) + ) + else: + for my_file in args.files: + print( + ", ".join( + [ + el.encoding or "undefined" + for el in x_ + if el.path == abspath(my_file.name) + ] + ) + ) + + return 0 + + +if __name__ == "__main__": + cli_detect() diff --git a/lib/python3.10/site-packages/charset_normalizer/cli/__pycache__/__init__.cpython-310.pyc b/lib/python3.10/site-packages/charset_normalizer/cli/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..928a71b8b57ef88d1571b1b0d0e4e79842e501d2 Binary files /dev/null and b/lib/python3.10/site-packages/charset_normalizer/cli/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/charset_normalizer/cli/__pycache__/__main__.cpython-310.pyc b/lib/python3.10/site-packages/charset_normalizer/cli/__pycache__/__main__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8fc94127d55a46dd9bdf1b0f842dd33e5d8a5d97 Binary files /dev/null and b/lib/python3.10/site-packages/charset_normalizer/cli/__pycache__/__main__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click-8.2.1.dist-info/licenses/LICENSE.txt b/lib/python3.10/site-packages/click-8.2.1.dist-info/licenses/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..d12a849186982399c537c5b9a8fd77bf2edd5eab --- /dev/null +++ b/lib/python3.10/site-packages/click-8.2.1.dist-info/licenses/LICENSE.txt @@ -0,0 +1,28 @@ +Copyright 2014 Pallets + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/python3.10/site-packages/click/__pycache__/__init__.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..43b4ccb9caa7cfb27b36c7615016a58d145269f5 Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/_compat.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/_compat.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..010527d786da89e4cef03dceab944041d447d678 Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/_compat.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/_termui_impl.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/_termui_impl.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c95fbc85dfba7b4f94ddc6d444ba6a4cafcebeda Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/_termui_impl.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/_textwrap.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/_textwrap.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5c95d6900086021622c10f11a979536834ccb130 Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/_textwrap.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/_winconsole.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/_winconsole.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..55429c01c2ae2c3cdc823306bc838fa33bd41484 Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/_winconsole.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/core.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/core.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e4c95ea003793c104bcd1bfdc1932009b89395ec Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/core.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/decorators.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/decorators.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..db43fa389d3275459c6296e86f63e8c72ae613d1 Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/decorators.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/exceptions.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/exceptions.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..37d470da775cc6271868e5a45e798ef8020298bb Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/exceptions.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/formatting.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/formatting.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1953d7769ba6b446cf4d8157a46f88ba36ef1fb1 Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/formatting.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/globals.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/globals.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..858b746af438397e2909d778cde174bbe77f5756 Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/globals.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/parser.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/parser.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1089d1c10ca60c144c67d8b84313ca34954973c8 Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/parser.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/shell_completion.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/shell_completion.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b9c97ff26abf573ca8462424c46c66a3bec95dd9 Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/shell_completion.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/termui.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/termui.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3b8889bf71bcdd1117907bc84765de51026b01a7 Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/termui.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/testing.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/testing.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..93b25ecb07e08ab3ea004b057821c6fa5b24d77d Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/testing.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/types.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/types.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..904ba10fd19829f3f3851d5356347fe0ed33c33a Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/types.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/click/__pycache__/utils.cpython-310.pyc b/lib/python3.10/site-packages/click/__pycache__/utils.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..918878d1ab65b41222ea8129c237a697381f5087 Binary files /dev/null and b/lib/python3.10/site-packages/click/__pycache__/utils.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/clip-1.0.dist-info/licenses/LICENSE b/lib/python3.10/site-packages/clip-1.0.dist-info/licenses/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..4e97f0b45803b7c04ae89548934af4f257a97501 --- /dev/null +++ b/lib/python3.10/site-packages/clip-1.0.dist-info/licenses/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2021 OpenAI + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/lib/python3.10/site-packages/clip/__pycache__/__init__.cpython-310.pyc b/lib/python3.10/site-packages/clip/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..712b8f0ef2ae8bbbc8113f2cdc1c8ff74db2248c Binary files /dev/null and b/lib/python3.10/site-packages/clip/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/clip/__pycache__/clip.cpython-310.pyc b/lib/python3.10/site-packages/clip/__pycache__/clip.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2d6ee6b53bfa74251eba680ee29fe55a960006ea Binary files /dev/null and b/lib/python3.10/site-packages/clip/__pycache__/clip.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/clip/__pycache__/model.cpython-310.pyc b/lib/python3.10/site-packages/clip/__pycache__/model.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..985ef404061a81c65dd84571c00ca461ce693770 Binary files /dev/null and b/lib/python3.10/site-packages/clip/__pycache__/model.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/clip/__pycache__/simple_tokenizer.cpython-310.pyc b/lib/python3.10/site-packages/clip/__pycache__/simple_tokenizer.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a034366ffb13e1a4f126bf694bab2f3687931f3d Binary files /dev/null and b/lib/python3.10/site-packages/clip/__pycache__/simple_tokenizer.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cloudpickle/__pycache__/__init__.cpython-310.pyc b/lib/python3.10/site-packages/cloudpickle/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..120aaaedec1410510baa3cdad1f295dcd9743b1a Binary files /dev/null and b/lib/python3.10/site-packages/cloudpickle/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cloudpickle/__pycache__/cloudpickle.cpython-310.pyc b/lib/python3.10/site-packages/cloudpickle/__pycache__/cloudpickle.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..00a295b5a3fb95d36fde56ed00e2e30a51b53b87 Binary files /dev/null and b/lib/python3.10/site-packages/cloudpickle/__pycache__/cloudpickle.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cloudpickle/__pycache__/cloudpickle_fast.cpython-310.pyc b/lib/python3.10/site-packages/cloudpickle/__pycache__/cloudpickle_fast.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b8dc9968dc83ebbb275acd4cc4e444ca5612d13f Binary files /dev/null and b/lib/python3.10/site-packages/cloudpickle/__pycache__/cloudpickle_fast.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama-0.4.6.dist-info/licenses/LICENSE.txt b/lib/python3.10/site-packages/colorama-0.4.6.dist-info/licenses/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..3105888ec149d10cad51c11d332779e94b548661 --- /dev/null +++ b/lib/python3.10/site-packages/colorama-0.4.6.dist-info/licenses/LICENSE.txt @@ -0,0 +1,27 @@ +Copyright (c) 2010 Jonathan Hartley +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holders, nor those of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/python3.10/site-packages/colorama/__pycache__/__init__.cpython-310.pyc b/lib/python3.10/site-packages/colorama/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4d63629b4431b36034800164fa3c1ebc82a02be8 Binary files /dev/null and b/lib/python3.10/site-packages/colorama/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama/__pycache__/ansi.cpython-310.pyc b/lib/python3.10/site-packages/colorama/__pycache__/ansi.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..60a4419ad215c3aa62b0cb5220f73bcfd57c730a Binary files /dev/null and b/lib/python3.10/site-packages/colorama/__pycache__/ansi.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama/__pycache__/ansitowin32.cpython-310.pyc b/lib/python3.10/site-packages/colorama/__pycache__/ansitowin32.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eb017c9728eb92561ec61b9b5694fb919d4d8c42 Binary files /dev/null and b/lib/python3.10/site-packages/colorama/__pycache__/ansitowin32.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama/__pycache__/initialise.cpython-310.pyc b/lib/python3.10/site-packages/colorama/__pycache__/initialise.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..80eb7f4e734470cd3ec2390cead59fdd6b9558cb Binary files /dev/null and b/lib/python3.10/site-packages/colorama/__pycache__/initialise.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama/__pycache__/win32.cpython-310.pyc b/lib/python3.10/site-packages/colorama/__pycache__/win32.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8218f1b0029b0b22648f22eebb50502a6c5dd34d Binary files /dev/null and b/lib/python3.10/site-packages/colorama/__pycache__/win32.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama/__pycache__/winterm.cpython-310.pyc b/lib/python3.10/site-packages/colorama/__pycache__/winterm.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e5b8f41e65140227e71a211f8a24206ee9fba718 Binary files /dev/null and b/lib/python3.10/site-packages/colorama/__pycache__/winterm.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama/tests/__init__.py b/lib/python3.10/site-packages/colorama/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..8c5661e93a205bf4fb22404d4fc50f902cc31369 --- /dev/null +++ b/lib/python3.10/site-packages/colorama/tests/__init__.py @@ -0,0 +1 @@ +# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. diff --git a/lib/python3.10/site-packages/colorama/tests/__pycache__/__init__.cpython-310.pyc b/lib/python3.10/site-packages/colorama/tests/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..814c4484227ee4dfa88c6df26ff631d4413425c9 Binary files /dev/null and b/lib/python3.10/site-packages/colorama/tests/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama/tests/__pycache__/ansi_test.cpython-310.pyc b/lib/python3.10/site-packages/colorama/tests/__pycache__/ansi_test.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..98b9aa9c44745a9f78cc2e02cc9970aa8f9cbe5d Binary files /dev/null and b/lib/python3.10/site-packages/colorama/tests/__pycache__/ansi_test.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama/tests/__pycache__/ansitowin32_test.cpython-310.pyc b/lib/python3.10/site-packages/colorama/tests/__pycache__/ansitowin32_test.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..12743f63539d6335aee49d618487123175eb502f Binary files /dev/null and b/lib/python3.10/site-packages/colorama/tests/__pycache__/ansitowin32_test.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama/tests/__pycache__/initialise_test.cpython-310.pyc b/lib/python3.10/site-packages/colorama/tests/__pycache__/initialise_test.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3fcf7a2c55ada291964b95fb67fc6b5ce1167c76 Binary files /dev/null and b/lib/python3.10/site-packages/colorama/tests/__pycache__/initialise_test.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama/tests/__pycache__/isatty_test.cpython-310.pyc b/lib/python3.10/site-packages/colorama/tests/__pycache__/isatty_test.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0157b6be5fbcc8e90a8badcb781a9344b5e619ef Binary files /dev/null and b/lib/python3.10/site-packages/colorama/tests/__pycache__/isatty_test.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama/tests/__pycache__/utils.cpython-310.pyc b/lib/python3.10/site-packages/colorama/tests/__pycache__/utils.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..03f5de5b0af0ede7633bdbd76461725ea6290352 Binary files /dev/null and b/lib/python3.10/site-packages/colorama/tests/__pycache__/utils.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama/tests/__pycache__/winterm_test.cpython-310.pyc b/lib/python3.10/site-packages/colorama/tests/__pycache__/winterm_test.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eb83b009eb9bbb22ee71a4caad7886e9792f5f8a Binary files /dev/null and b/lib/python3.10/site-packages/colorama/tests/__pycache__/winterm_test.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/colorama/tests/ansi_test.py b/lib/python3.10/site-packages/colorama/tests/ansi_test.py new file mode 100644 index 0000000000000000000000000000000000000000..0a20c80f882066e0e1323b0c7f61e22913c32e35 --- /dev/null +++ b/lib/python3.10/site-packages/colorama/tests/ansi_test.py @@ -0,0 +1,76 @@ +# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. +import sys +from unittest import TestCase, main + +from ..ansi import Back, Fore, Style +from ..ansitowin32 import AnsiToWin32 + +stdout_orig = sys.stdout +stderr_orig = sys.stderr + + +class AnsiTest(TestCase): + + def setUp(self): + # sanity check: stdout should be a file or StringIO object. + # It will only be AnsiToWin32 if init() has previously wrapped it + self.assertNotEqual(type(sys.stdout), AnsiToWin32) + self.assertNotEqual(type(sys.stderr), AnsiToWin32) + + def tearDown(self): + sys.stdout = stdout_orig + sys.stderr = stderr_orig + + + def testForeAttributes(self): + self.assertEqual(Fore.BLACK, '\033[30m') + self.assertEqual(Fore.RED, '\033[31m') + self.assertEqual(Fore.GREEN, '\033[32m') + self.assertEqual(Fore.YELLOW, '\033[33m') + self.assertEqual(Fore.BLUE, '\033[34m') + self.assertEqual(Fore.MAGENTA, '\033[35m') + self.assertEqual(Fore.CYAN, '\033[36m') + self.assertEqual(Fore.WHITE, '\033[37m') + self.assertEqual(Fore.RESET, '\033[39m') + + # Check the light, extended versions. + self.assertEqual(Fore.LIGHTBLACK_EX, '\033[90m') + self.assertEqual(Fore.LIGHTRED_EX, '\033[91m') + self.assertEqual(Fore.LIGHTGREEN_EX, '\033[92m') + self.assertEqual(Fore.LIGHTYELLOW_EX, '\033[93m') + self.assertEqual(Fore.LIGHTBLUE_EX, '\033[94m') + self.assertEqual(Fore.LIGHTMAGENTA_EX, '\033[95m') + self.assertEqual(Fore.LIGHTCYAN_EX, '\033[96m') + self.assertEqual(Fore.LIGHTWHITE_EX, '\033[97m') + + + def testBackAttributes(self): + self.assertEqual(Back.BLACK, '\033[40m') + self.assertEqual(Back.RED, '\033[41m') + self.assertEqual(Back.GREEN, '\033[42m') + self.assertEqual(Back.YELLOW, '\033[43m') + self.assertEqual(Back.BLUE, '\033[44m') + self.assertEqual(Back.MAGENTA, '\033[45m') + self.assertEqual(Back.CYAN, '\033[46m') + self.assertEqual(Back.WHITE, '\033[47m') + self.assertEqual(Back.RESET, '\033[49m') + + # Check the light, extended versions. + self.assertEqual(Back.LIGHTBLACK_EX, '\033[100m') + self.assertEqual(Back.LIGHTRED_EX, '\033[101m') + self.assertEqual(Back.LIGHTGREEN_EX, '\033[102m') + self.assertEqual(Back.LIGHTYELLOW_EX, '\033[103m') + self.assertEqual(Back.LIGHTBLUE_EX, '\033[104m') + self.assertEqual(Back.LIGHTMAGENTA_EX, '\033[105m') + self.assertEqual(Back.LIGHTCYAN_EX, '\033[106m') + self.assertEqual(Back.LIGHTWHITE_EX, '\033[107m') + + + def testStyleAttributes(self): + self.assertEqual(Style.DIM, '\033[2m') + self.assertEqual(Style.NORMAL, '\033[22m') + self.assertEqual(Style.BRIGHT, '\033[1m') + + +if __name__ == '__main__': + main() diff --git a/lib/python3.10/site-packages/colorama/tests/ansitowin32_test.py b/lib/python3.10/site-packages/colorama/tests/ansitowin32_test.py new file mode 100644 index 0000000000000000000000000000000000000000..91ca551f97b4576c680711e826a1855fb944c872 --- /dev/null +++ b/lib/python3.10/site-packages/colorama/tests/ansitowin32_test.py @@ -0,0 +1,294 @@ +# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. +from io import StringIO, TextIOWrapper +from unittest import TestCase, main +try: + from contextlib import ExitStack +except ImportError: + # python 2 + from contextlib2 import ExitStack + +try: + from unittest.mock import MagicMock, Mock, patch +except ImportError: + from mock import MagicMock, Mock, patch + +from ..ansitowin32 import AnsiToWin32, StreamWrapper +from ..win32 import ENABLE_VIRTUAL_TERMINAL_PROCESSING +from .utils import osname + + +class StreamWrapperTest(TestCase): + + def testIsAProxy(self): + mockStream = Mock() + wrapper = StreamWrapper(mockStream, None) + self.assertTrue( wrapper.random_attr is mockStream.random_attr ) + + def testDelegatesWrite(self): + mockStream = Mock() + mockConverter = Mock() + wrapper = StreamWrapper(mockStream, mockConverter) + wrapper.write('hello') + self.assertTrue(mockConverter.write.call_args, (('hello',), {})) + + def testDelegatesContext(self): + mockConverter = Mock() + s = StringIO() + with StreamWrapper(s, mockConverter) as fp: + fp.write(u'hello') + self.assertTrue(s.closed) + + def testProxyNoContextManager(self): + mockStream = MagicMock() + mockStream.__enter__.side_effect = AttributeError() + mockConverter = Mock() + with self.assertRaises(AttributeError) as excinfo: + with StreamWrapper(mockStream, mockConverter) as wrapper: + wrapper.write('hello') + + def test_closed_shouldnt_raise_on_closed_stream(self): + stream = StringIO() + stream.close() + wrapper = StreamWrapper(stream, None) + self.assertEqual(wrapper.closed, True) + + def test_closed_shouldnt_raise_on_detached_stream(self): + stream = TextIOWrapper(StringIO()) + stream.detach() + wrapper = StreamWrapper(stream, None) + self.assertEqual(wrapper.closed, True) + +class AnsiToWin32Test(TestCase): + + def testInit(self): + mockStdout = Mock() + auto = Mock() + stream = AnsiToWin32(mockStdout, autoreset=auto) + self.assertEqual(stream.wrapped, mockStdout) + self.assertEqual(stream.autoreset, auto) + + @patch('colorama.ansitowin32.winterm', None) + @patch('colorama.ansitowin32.winapi_test', lambda *_: True) + def testStripIsTrueOnWindows(self): + with osname('nt'): + mockStdout = Mock() + stream = AnsiToWin32(mockStdout) + self.assertTrue(stream.strip) + + def testStripIsFalseOffWindows(self): + with osname('posix'): + mockStdout = Mock(closed=False) + stream = AnsiToWin32(mockStdout) + self.assertFalse(stream.strip) + + def testWriteStripsAnsi(self): + mockStdout = Mock() + stream = AnsiToWin32(mockStdout) + stream.wrapped = Mock() + stream.write_and_convert = Mock() + stream.strip = True + + stream.write('abc') + + self.assertFalse(stream.wrapped.write.called) + self.assertEqual(stream.write_and_convert.call_args, (('abc',), {})) + + def testWriteDoesNotStripAnsi(self): + mockStdout = Mock() + stream = AnsiToWin32(mockStdout) + stream.wrapped = Mock() + stream.write_and_convert = Mock() + stream.strip = False + stream.convert = False + + stream.write('abc') + + self.assertFalse(stream.write_and_convert.called) + self.assertEqual(stream.wrapped.write.call_args, (('abc',), {})) + + def assert_autoresets(self, convert, autoreset=True): + stream = AnsiToWin32(Mock()) + stream.convert = convert + stream.reset_all = Mock() + stream.autoreset = autoreset + stream.winterm = Mock() + + stream.write('abc') + + self.assertEqual(stream.reset_all.called, autoreset) + + def testWriteAutoresets(self): + self.assert_autoresets(convert=True) + self.assert_autoresets(convert=False) + self.assert_autoresets(convert=True, autoreset=False) + self.assert_autoresets(convert=False, autoreset=False) + + def testWriteAndConvertWritesPlainText(self): + stream = AnsiToWin32(Mock()) + stream.write_and_convert( 'abc' ) + self.assertEqual( stream.wrapped.write.call_args, (('abc',), {}) ) + + def testWriteAndConvertStripsAllValidAnsi(self): + stream = AnsiToWin32(Mock()) + stream.call_win32 = Mock() + data = [ + 'abc\033[mdef', + 'abc\033[0mdef', + 'abc\033[2mdef', + 'abc\033[02mdef', + 'abc\033[002mdef', + 'abc\033[40mdef', + 'abc\033[040mdef', + 'abc\033[0;1mdef', + 'abc\033[40;50mdef', + 'abc\033[50;30;40mdef', + 'abc\033[Adef', + 'abc\033[0Gdef', + 'abc\033[1;20;128Hdef', + ] + for datum in data: + stream.wrapped.write.reset_mock() + stream.write_and_convert( datum ) + self.assertEqual( + [args[0] for args in stream.wrapped.write.call_args_list], + [ ('abc',), ('def',) ] + ) + + def testWriteAndConvertSkipsEmptySnippets(self): + stream = AnsiToWin32(Mock()) + stream.call_win32 = Mock() + stream.write_and_convert( '\033[40m\033[41m' ) + self.assertFalse( stream.wrapped.write.called ) + + def testWriteAndConvertCallsWin32WithParamsAndCommand(self): + stream = AnsiToWin32(Mock()) + stream.convert = True + stream.call_win32 = Mock() + stream.extract_params = Mock(return_value='params') + data = { + 'abc\033[adef': ('a', 'params'), + 'abc\033[;;bdef': ('b', 'params'), + 'abc\033[0cdef': ('c', 'params'), + 'abc\033[;;0;;Gdef': ('G', 'params'), + 'abc\033[1;20;128Hdef': ('H', 'params'), + } + for datum, expected in data.items(): + stream.call_win32.reset_mock() + stream.write_and_convert( datum ) + self.assertEqual( stream.call_win32.call_args[0], expected ) + + def test_reset_all_shouldnt_raise_on_closed_orig_stdout(self): + stream = StringIO() + converter = AnsiToWin32(stream) + stream.close() + + converter.reset_all() + + def test_wrap_shouldnt_raise_on_closed_orig_stdout(self): + stream = StringIO() + stream.close() + with \ + patch("colorama.ansitowin32.os.name", "nt"), \ + patch("colorama.ansitowin32.winapi_test", lambda: True): + converter = AnsiToWin32(stream) + self.assertTrue(converter.strip) + self.assertFalse(converter.convert) + + def test_wrap_shouldnt_raise_on_missing_closed_attr(self): + with \ + patch("colorama.ansitowin32.os.name", "nt"), \ + patch("colorama.ansitowin32.winapi_test", lambda: True): + converter = AnsiToWin32(object()) + self.assertTrue(converter.strip) + self.assertFalse(converter.convert) + + def testExtractParams(self): + stream = AnsiToWin32(Mock()) + data = { + '': (0,), + ';;': (0,), + '2': (2,), + ';;002;;': (2,), + '0;1': (0, 1), + ';;003;;456;;': (3, 456), + '11;22;33;44;55': (11, 22, 33, 44, 55), + } + for datum, expected in data.items(): + self.assertEqual(stream.extract_params('m', datum), expected) + + def testCallWin32UsesLookup(self): + listener = Mock() + stream = AnsiToWin32(listener) + stream.win32_calls = { + 1: (lambda *_, **__: listener(11),), + 2: (lambda *_, **__: listener(22),), + 3: (lambda *_, **__: listener(33),), + } + stream.call_win32('m', (3, 1, 99, 2)) + self.assertEqual( + [a[0][0] for a in listener.call_args_list], + [33, 11, 22] ) + + def test_osc_codes(self): + mockStdout = Mock() + stream = AnsiToWin32(mockStdout, convert=True) + with patch('colorama.ansitowin32.winterm') as winterm: + data = [ + '\033]0\x07', # missing arguments + '\033]0;foo\x08', # wrong OSC command + '\033]0;colorama_test_title\x07', # should work + '\033]1;colorama_test_title\x07', # wrong set command + '\033]2;colorama_test_title\x07', # should work + '\033]' + ';' * 64 + '\x08', # see issue #247 + ] + for code in data: + stream.write(code) + self.assertEqual(winterm.set_title.call_count, 2) + + def test_native_windows_ansi(self): + with ExitStack() as stack: + def p(a, b): + stack.enter_context(patch(a, b, create=True)) + # Pretend to be on Windows + p("colorama.ansitowin32.os.name", "nt") + p("colorama.ansitowin32.winapi_test", lambda: True) + p("colorama.win32.winapi_test", lambda: True) + p("colorama.winterm.win32.windll", "non-None") + p("colorama.winterm.get_osfhandle", lambda _: 1234) + + # Pretend that our mock stream has native ANSI support + p( + "colorama.winterm.win32.GetConsoleMode", + lambda _: ENABLE_VIRTUAL_TERMINAL_PROCESSING, + ) + SetConsoleMode = Mock() + p("colorama.winterm.win32.SetConsoleMode", SetConsoleMode) + + stdout = Mock() + stdout.closed = False + stdout.isatty.return_value = True + stdout.fileno.return_value = 1 + + # Our fake console says it has native vt support, so AnsiToWin32 should + # enable that support and do nothing else. + stream = AnsiToWin32(stdout) + SetConsoleMode.assert_called_with(1234, ENABLE_VIRTUAL_TERMINAL_PROCESSING) + self.assertFalse(stream.strip) + self.assertFalse(stream.convert) + self.assertFalse(stream.should_wrap()) + + # Now let's pretend we're on an old Windows console, that doesn't have + # native ANSI support. + p("colorama.winterm.win32.GetConsoleMode", lambda _: 0) + SetConsoleMode = Mock() + p("colorama.winterm.win32.SetConsoleMode", SetConsoleMode) + + stream = AnsiToWin32(stdout) + SetConsoleMode.assert_called_with(1234, ENABLE_VIRTUAL_TERMINAL_PROCESSING) + self.assertTrue(stream.strip) + self.assertTrue(stream.convert) + self.assertTrue(stream.should_wrap()) + + +if __name__ == '__main__': + main() diff --git a/lib/python3.10/site-packages/colorama/tests/initialise_test.py b/lib/python3.10/site-packages/colorama/tests/initialise_test.py new file mode 100644 index 0000000000000000000000000000000000000000..89f9b07511c8fee74686d9cc434bf66345a46d6d --- /dev/null +++ b/lib/python3.10/site-packages/colorama/tests/initialise_test.py @@ -0,0 +1,189 @@ +# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. +import sys +from unittest import TestCase, main, skipUnless + +try: + from unittest.mock import patch, Mock +except ImportError: + from mock import patch, Mock + +from ..ansitowin32 import StreamWrapper +from ..initialise import init, just_fix_windows_console, _wipe_internal_state_for_tests +from .utils import osname, replace_by + +orig_stdout = sys.stdout +orig_stderr = sys.stderr + + +class InitTest(TestCase): + + @skipUnless(sys.stdout.isatty(), "sys.stdout is not a tty") + def setUp(self): + # sanity check + self.assertNotWrapped() + + def tearDown(self): + _wipe_internal_state_for_tests() + sys.stdout = orig_stdout + sys.stderr = orig_stderr + + def assertWrapped(self): + self.assertIsNot(sys.stdout, orig_stdout, 'stdout should be wrapped') + self.assertIsNot(sys.stderr, orig_stderr, 'stderr should be wrapped') + self.assertTrue(isinstance(sys.stdout, StreamWrapper), + 'bad stdout wrapper') + self.assertTrue(isinstance(sys.stderr, StreamWrapper), + 'bad stderr wrapper') + + def assertNotWrapped(self): + self.assertIs(sys.stdout, orig_stdout, 'stdout should not be wrapped') + self.assertIs(sys.stderr, orig_stderr, 'stderr should not be wrapped') + + @patch('colorama.initialise.reset_all') + @patch('colorama.ansitowin32.winapi_test', lambda *_: True) + @patch('colorama.ansitowin32.enable_vt_processing', lambda *_: False) + def testInitWrapsOnWindows(self, _): + with osname("nt"): + init() + self.assertWrapped() + + @patch('colorama.initialise.reset_all') + @patch('colorama.ansitowin32.winapi_test', lambda *_: False) + def testInitDoesntWrapOnEmulatedWindows(self, _): + with osname("nt"): + init() + self.assertNotWrapped() + + def testInitDoesntWrapOnNonWindows(self): + with osname("posix"): + init() + self.assertNotWrapped() + + def testInitDoesntWrapIfNone(self): + with replace_by(None): + init() + # We can't use assertNotWrapped here because replace_by(None) + # changes stdout/stderr already. + self.assertIsNone(sys.stdout) + self.assertIsNone(sys.stderr) + + def testInitAutoresetOnWrapsOnAllPlatforms(self): + with osname("posix"): + init(autoreset=True) + self.assertWrapped() + + def testInitWrapOffDoesntWrapOnWindows(self): + with osname("nt"): + init(wrap=False) + self.assertNotWrapped() + + def testInitWrapOffIncompatibleWithAutoresetOn(self): + self.assertRaises(ValueError, lambda: init(autoreset=True, wrap=False)) + + @patch('colorama.win32.SetConsoleTextAttribute') + @patch('colorama.initialise.AnsiToWin32') + def testAutoResetPassedOn(self, mockATW32, _): + with osname("nt"): + init(autoreset=True) + self.assertEqual(len(mockATW32.call_args_list), 2) + self.assertEqual(mockATW32.call_args_list[1][1]['autoreset'], True) + self.assertEqual(mockATW32.call_args_list[0][1]['autoreset'], True) + + @patch('colorama.initialise.AnsiToWin32') + def testAutoResetChangeable(self, mockATW32): + with osname("nt"): + init() + + init(autoreset=True) + self.assertEqual(len(mockATW32.call_args_list), 4) + self.assertEqual(mockATW32.call_args_list[2][1]['autoreset'], True) + self.assertEqual(mockATW32.call_args_list[3][1]['autoreset'], True) + + init() + self.assertEqual(len(mockATW32.call_args_list), 6) + self.assertEqual( + mockATW32.call_args_list[4][1]['autoreset'], False) + self.assertEqual( + mockATW32.call_args_list[5][1]['autoreset'], False) + + + @patch('colorama.initialise.atexit.register') + def testAtexitRegisteredOnlyOnce(self, mockRegister): + init() + self.assertTrue(mockRegister.called) + mockRegister.reset_mock() + init() + self.assertFalse(mockRegister.called) + + +class JustFixWindowsConsoleTest(TestCase): + def _reset(self): + _wipe_internal_state_for_tests() + sys.stdout = orig_stdout + sys.stderr = orig_stderr + + def tearDown(self): + self._reset() + + @patch("colorama.ansitowin32.winapi_test", lambda: True) + def testJustFixWindowsConsole(self): + if sys.platform != "win32": + # just_fix_windows_console should be a no-op + just_fix_windows_console() + self.assertIs(sys.stdout, orig_stdout) + self.assertIs(sys.stderr, orig_stderr) + else: + def fake_std(): + # Emulate stdout=not a tty, stderr=tty + # to check that we handle both cases correctly + stdout = Mock() + stdout.closed = False + stdout.isatty.return_value = False + stdout.fileno.return_value = 1 + sys.stdout = stdout + + stderr = Mock() + stderr.closed = False + stderr.isatty.return_value = True + stderr.fileno.return_value = 2 + sys.stderr = stderr + + for native_ansi in [False, True]: + with patch( + 'colorama.ansitowin32.enable_vt_processing', + lambda *_: native_ansi + ): + self._reset() + fake_std() + + # Regular single-call test + prev_stdout = sys.stdout + prev_stderr = sys.stderr + just_fix_windows_console() + self.assertIs(sys.stdout, prev_stdout) + if native_ansi: + self.assertIs(sys.stderr, prev_stderr) + else: + self.assertIsNot(sys.stderr, prev_stderr) + + # second call without resetting is always a no-op + prev_stdout = sys.stdout + prev_stderr = sys.stderr + just_fix_windows_console() + self.assertIs(sys.stdout, prev_stdout) + self.assertIs(sys.stderr, prev_stderr) + + self._reset() + fake_std() + + # If init() runs first, just_fix_windows_console should be a no-op + init() + prev_stdout = sys.stdout + prev_stderr = sys.stderr + just_fix_windows_console() + self.assertIs(prev_stdout, sys.stdout) + self.assertIs(prev_stderr, sys.stderr) + + +if __name__ == '__main__': + main() diff --git a/lib/python3.10/site-packages/colorama/tests/isatty_test.py b/lib/python3.10/site-packages/colorama/tests/isatty_test.py new file mode 100644 index 0000000000000000000000000000000000000000..0f84e4befe550d4386d24264648abf1323e682ff --- /dev/null +++ b/lib/python3.10/site-packages/colorama/tests/isatty_test.py @@ -0,0 +1,57 @@ +# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. +import sys +from unittest import TestCase, main + +from ..ansitowin32 import StreamWrapper, AnsiToWin32 +from .utils import pycharm, replace_by, replace_original_by, StreamTTY, StreamNonTTY + + +def is_a_tty(stream): + return StreamWrapper(stream, None).isatty() + +class IsattyTest(TestCase): + + def test_TTY(self): + tty = StreamTTY() + self.assertTrue(is_a_tty(tty)) + with pycharm(): + self.assertTrue(is_a_tty(tty)) + + def test_nonTTY(self): + non_tty = StreamNonTTY() + self.assertFalse(is_a_tty(non_tty)) + with pycharm(): + self.assertFalse(is_a_tty(non_tty)) + + def test_withPycharm(self): + with pycharm(): + self.assertTrue(is_a_tty(sys.stderr)) + self.assertTrue(is_a_tty(sys.stdout)) + + def test_withPycharmTTYOverride(self): + tty = StreamTTY() + with pycharm(), replace_by(tty): + self.assertTrue(is_a_tty(tty)) + + def test_withPycharmNonTTYOverride(self): + non_tty = StreamNonTTY() + with pycharm(), replace_by(non_tty): + self.assertFalse(is_a_tty(non_tty)) + + def test_withPycharmNoneOverride(self): + with pycharm(): + with replace_by(None), replace_original_by(None): + self.assertFalse(is_a_tty(None)) + self.assertFalse(is_a_tty(StreamNonTTY())) + self.assertTrue(is_a_tty(StreamTTY())) + + def test_withPycharmStreamWrapped(self): + with pycharm(): + self.assertTrue(AnsiToWin32(StreamTTY()).stream.isatty()) + self.assertFalse(AnsiToWin32(StreamNonTTY()).stream.isatty()) + self.assertTrue(AnsiToWin32(sys.stdout).stream.isatty()) + self.assertTrue(AnsiToWin32(sys.stderr).stream.isatty()) + + +if __name__ == '__main__': + main() diff --git a/lib/python3.10/site-packages/colorama/tests/utils.py b/lib/python3.10/site-packages/colorama/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..472fafb4403efb9673d5cc724dafd9cf764aac5b --- /dev/null +++ b/lib/python3.10/site-packages/colorama/tests/utils.py @@ -0,0 +1,49 @@ +# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. +from contextlib import contextmanager +from io import StringIO +import sys +import os + + +class StreamTTY(StringIO): + def isatty(self): + return True + +class StreamNonTTY(StringIO): + def isatty(self): + return False + +@contextmanager +def osname(name): + orig = os.name + os.name = name + yield + os.name = orig + +@contextmanager +def replace_by(stream): + orig_stdout = sys.stdout + orig_stderr = sys.stderr + sys.stdout = stream + sys.stderr = stream + yield + sys.stdout = orig_stdout + sys.stderr = orig_stderr + +@contextmanager +def replace_original_by(stream): + orig_stdout = sys.__stdout__ + orig_stderr = sys.__stderr__ + sys.__stdout__ = stream + sys.__stderr__ = stream + yield + sys.__stdout__ = orig_stdout + sys.__stderr__ = orig_stderr + +@contextmanager +def pycharm(): + os.environ["PYCHARM_HOSTED"] = "1" + non_tty = StreamNonTTY() + with replace_by(non_tty), replace_original_by(non_tty): + yield + del os.environ["PYCHARM_HOSTED"] diff --git a/lib/python3.10/site-packages/colorama/tests/winterm_test.py b/lib/python3.10/site-packages/colorama/tests/winterm_test.py new file mode 100644 index 0000000000000000000000000000000000000000..d0955f9e608377940f0d548576964f2fcf3caf48 --- /dev/null +++ b/lib/python3.10/site-packages/colorama/tests/winterm_test.py @@ -0,0 +1,131 @@ +# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. +import sys +from unittest import TestCase, main, skipUnless + +try: + from unittest.mock import Mock, patch +except ImportError: + from mock import Mock, patch + +from ..winterm import WinColor, WinStyle, WinTerm + + +class WinTermTest(TestCase): + + @patch('colorama.winterm.win32') + def testInit(self, mockWin32): + mockAttr = Mock() + mockAttr.wAttributes = 7 + 6 * 16 + 8 + mockWin32.GetConsoleScreenBufferInfo.return_value = mockAttr + term = WinTerm() + self.assertEqual(term._fore, 7) + self.assertEqual(term._back, 6) + self.assertEqual(term._style, 8) + + @skipUnless(sys.platform.startswith("win"), "requires Windows") + def testGetAttrs(self): + term = WinTerm() + + term._fore = 0 + term._back = 0 + term._style = 0 + self.assertEqual(term.get_attrs(), 0) + + term._fore = WinColor.YELLOW + self.assertEqual(term.get_attrs(), WinColor.YELLOW) + + term._back = WinColor.MAGENTA + self.assertEqual( + term.get_attrs(), + WinColor.YELLOW + WinColor.MAGENTA * 16) + + term._style = WinStyle.BRIGHT + self.assertEqual( + term.get_attrs(), + WinColor.YELLOW + WinColor.MAGENTA * 16 + WinStyle.BRIGHT) + + @patch('colorama.winterm.win32') + def testResetAll(self, mockWin32): + mockAttr = Mock() + mockAttr.wAttributes = 1 + 2 * 16 + 8 + mockWin32.GetConsoleScreenBufferInfo.return_value = mockAttr + term = WinTerm() + + term.set_console = Mock() + term._fore = -1 + term._back = -1 + term._style = -1 + + term.reset_all() + + self.assertEqual(term._fore, 1) + self.assertEqual(term._back, 2) + self.assertEqual(term._style, 8) + self.assertEqual(term.set_console.called, True) + + @skipUnless(sys.platform.startswith("win"), "requires Windows") + def testFore(self): + term = WinTerm() + term.set_console = Mock() + term._fore = 0 + + term.fore(5) + + self.assertEqual(term._fore, 5) + self.assertEqual(term.set_console.called, True) + + @skipUnless(sys.platform.startswith("win"), "requires Windows") + def testBack(self): + term = WinTerm() + term.set_console = Mock() + term._back = 0 + + term.back(5) + + self.assertEqual(term._back, 5) + self.assertEqual(term.set_console.called, True) + + @skipUnless(sys.platform.startswith("win"), "requires Windows") + def testStyle(self): + term = WinTerm() + term.set_console = Mock() + term._style = 0 + + term.style(22) + + self.assertEqual(term._style, 22) + self.assertEqual(term.set_console.called, True) + + @patch('colorama.winterm.win32') + def testSetConsole(self, mockWin32): + mockAttr = Mock() + mockAttr.wAttributes = 0 + mockWin32.GetConsoleScreenBufferInfo.return_value = mockAttr + term = WinTerm() + term.windll = Mock() + + term.set_console() + + self.assertEqual( + mockWin32.SetConsoleTextAttribute.call_args, + ((mockWin32.STDOUT, term.get_attrs()), {}) + ) + + @patch('colorama.winterm.win32') + def testSetConsoleOnStderr(self, mockWin32): + mockAttr = Mock() + mockAttr.wAttributes = 0 + mockWin32.GetConsoleScreenBufferInfo.return_value = mockAttr + term = WinTerm() + term.windll = Mock() + + term.set_console(on_stderr=True) + + self.assertEqual( + mockWin32.SetConsoleTextAttribute.call_args, + ((mockWin32.STDERR, term.get_attrs()), {}) + ) + + +if __name__ == '__main__': + main() diff --git a/lib/python3.10/site-packages/comm/__pycache__/__init__.cpython-310.pyc b/lib/python3.10/site-packages/comm/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8ce1decd6fe1a5b3f8a905dbc64c3e76706ea6d3 Binary files /dev/null and b/lib/python3.10/site-packages/comm/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/comm/__pycache__/base_comm.cpython-310.pyc b/lib/python3.10/site-packages/comm/__pycache__/base_comm.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1e0b713a3b8b43d8cafaddbf072b6ba740c3e63c Binary files /dev/null and b/lib/python3.10/site-packages/comm/__pycache__/base_comm.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/__pycache__/__init__.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..06a62a83d672a929e28ca73633ac8caa32b8a8e6 Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/__pycache__/_version.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/__pycache__/_version.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..736d07b7321050b2d5558817c55ec9911a0466f3 Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/__pycache__/_version.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/__pycache__/array.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/__pycache__/array.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..08d3c0fe1a423a82fea58f509b085ea912278ac3 Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/__pycache__/array.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/__pycache__/chunk.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/__pycache__/chunk.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f17337d3d11c28b1e8838291db4ca5a34b7b7bf0 Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/__pycache__/chunk.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/__pycache__/convert.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/__pycache__/convert.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4a1315dfbd3effc7e5995e34c7584a1d337b20a7 Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/__pycache__/convert.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/__pycache__/dechunk.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/__pycache__/dechunk.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6e5246ddd798e7473f12d4aa562e85f80e5e90ea Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/__pycache__/dechunk.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/__pycache__/enum_util.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/__pycache__/enum_util.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5f0f217dd661ee9c66d6769d90f2ea1fb0dbb1ae Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/__pycache__/enum_util.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/__pycache__/typecheck.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/__pycache__/typecheck.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1b2d447f18983951fd1d593c215eb75512bbdca1 Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/__pycache__/typecheck.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/__pycache__/types.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/__pycache__/types.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e8f2c58fd5cbd4621ab8e254220e6a08be018b2a Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/__pycache__/types.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/util/__init__.py b/lib/python3.10/site-packages/contourpy/util/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..fe33fcef1e18d2a4b92287e434cf6b1257e4274f --- /dev/null +++ b/lib/python3.10/site-packages/contourpy/util/__init__.py @@ -0,0 +1,5 @@ +from __future__ import annotations + +from contourpy.util._build_config import build_config + +__all__ = ["build_config"] diff --git a/lib/python3.10/site-packages/contourpy/util/__pycache__/__init__.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/util/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..aad64170ff44deaf3fed4e3db2d6601ee457fcc5 Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/util/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/util/__pycache__/_build_config.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/util/__pycache__/_build_config.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..467c32f2f1622be5e09ed6acfbbda17f3c11312b Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/util/__pycache__/_build_config.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/util/__pycache__/bokeh_renderer.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/util/__pycache__/bokeh_renderer.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3988cb4d2cb59dfdf5026e4a0b3f281321ef8ddc Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/util/__pycache__/bokeh_renderer.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/util/__pycache__/bokeh_util.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/util/__pycache__/bokeh_util.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0dbec79c5ff2b1c1aa6cf4c61dab822408220af3 Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/util/__pycache__/bokeh_util.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/util/__pycache__/data.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/util/__pycache__/data.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2bfbb9374e00c994d9db6981a75c05d8b1426c3c Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/util/__pycache__/data.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/util/__pycache__/mpl_renderer.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/util/__pycache__/mpl_renderer.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..05efa38fa6e7c117a4817feebd085b04699c70a8 Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/util/__pycache__/mpl_renderer.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/util/__pycache__/mpl_util.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/util/__pycache__/mpl_util.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b006a4d2926c99fc96204e1258e8e1091163205d Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/util/__pycache__/mpl_util.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/util/__pycache__/renderer.cpython-310.pyc b/lib/python3.10/site-packages/contourpy/util/__pycache__/renderer.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..07ec5ce6c3aa3d5289da26add06ecdb8b634f9db Binary files /dev/null and b/lib/python3.10/site-packages/contourpy/util/__pycache__/renderer.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/contourpy/util/_build_config.py b/lib/python3.10/site-packages/contourpy/util/_build_config.py new file mode 100644 index 0000000000000000000000000000000000000000..1655c23e4ec46f28b987f857fccc76ca687c6ac8 --- /dev/null +++ b/lib/python3.10/site-packages/contourpy/util/_build_config.py @@ -0,0 +1,60 @@ +# _build_config.py.in is converted into _build_config.py during the meson build process. + +from __future__ import annotations + + +def build_config() -> dict[str, str]: + """ + Return a dictionary containing build configuration settings. + + All dictionary keys and values are strings, for example ``False`` is + returned as ``"False"``. + + .. versionadded:: 1.1.0 + """ + return dict( + # Python settings + python_version="3.10", + python_install_dir=r"/usr/local/lib/python3.10/site-packages/", + python_path=r"/tmp/build-env-dfa9bu3d/bin/python", + + # Package versions + contourpy_version="1.3.2", + meson_version="1.7.2", + mesonpy_version="0.17.1", + pybind11_version="2.13.6", + + # Misc meson settings + meson_backend="ninja", + build_dir=r"/project/.mesonpy-0roiogjz/lib/contourpy/util", + source_dir=r"/project/lib/contourpy/util", + cross_build="False", + + # Build options + build_options=r"-Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md -Dvsenv=True --native-file=/project/.mesonpy-0roiogjz/meson-python-native-file.ini", + buildtype="release", + cpp_std="c++17", + debug="False", + optimization="3", + vsenv="True", + b_ndebug="if-release", + b_vscrt="from_buildtype", + + # C++ compiler + compiler_name="gcc", + compiler_version="10.2.1", + linker_id="ld.bfd", + compile_command="c++", + + # Host machine + host_cpu="x86_64", + host_cpu_family="x86_64", + host_cpu_endian="little", + host_cpu_system="linux", + + # Build machine, same as host machine if not a cross_build + build_cpu="x86_64", + build_cpu_family="x86_64", + build_cpu_endian="little", + build_cpu_system="linux", + ) diff --git a/lib/python3.10/site-packages/contourpy/util/bokeh_renderer.py b/lib/python3.10/site-packages/contourpy/util/bokeh_renderer.py new file mode 100644 index 0000000000000000000000000000000000000000..6079ac3c755ca141d14d3155874eb68d41d0e504 --- /dev/null +++ b/lib/python3.10/site-packages/contourpy/util/bokeh_renderer.py @@ -0,0 +1,339 @@ +from __future__ import annotations + +import io +from typing import TYPE_CHECKING, Any + +from bokeh.io import export_png, export_svg, show +from bokeh.io.export import get_screenshot_as_png +from bokeh.layouts import gridplot +from bokeh.models.annotations.labels import Label +from bokeh.palettes import Category10 +from bokeh.plotting import figure +import numpy as np + +from contourpy.enum_util import as_fill_type, as_line_type +from contourpy.util.bokeh_util import filled_to_bokeh, lines_to_bokeh +from contourpy.util.renderer import Renderer + +if TYPE_CHECKING: + from bokeh.core.enums import OutputBackendType + from bokeh.models import GridPlot + from bokeh.palettes import Palette + from numpy.typing import ArrayLike + from selenium.webdriver.remote.webdriver import WebDriver + + from contourpy import FillType, LineType + from contourpy._contourpy import FillReturn, LineReturn + + +class BokehRenderer(Renderer): + """Utility renderer using Bokeh to render a grid of plots over the same (x, y) range. + + Args: + nrows (int, optional): Number of rows of plots, default ``1``. + ncols (int, optional): Number of columns of plots, default ``1``. + figsize (tuple(float, float), optional): Figure size in inches (assuming 100 dpi), default + ``(9, 9)``. + show_frame (bool, optional): Whether to show frame and axes ticks, default ``True``. + want_svg (bool, optional): Whether output is required in SVG format or not, default + ``False``. + + Warning: + :class:`~.BokehRenderer`, unlike :class:`~.MplRenderer`, needs to be told in advance if + output to SVG format will be required later, otherwise it will assume PNG output. + """ + _figures: list[figure] + _layout: GridPlot + _palette: Palette + _want_svg: bool + + def __init__( + self, + nrows: int = 1, + ncols: int = 1, + figsize: tuple[float, float] = (9, 9), + show_frame: bool = True, + want_svg: bool = False, + ) -> None: + self._want_svg = want_svg + self._palette = Category10[10] + + total_size = 100*np.asarray(figsize, dtype=int) # Assuming 100 dpi. + + nfigures = nrows*ncols + self._figures = [] + backend: OutputBackendType = "svg" if self._want_svg else "canvas" + for _ in range(nfigures): + fig = figure(output_backend=backend) + fig.xgrid.visible = False # type: ignore[attr-defined] + fig.ygrid.visible = False # type: ignore[attr-defined] + self._figures.append(fig) + if not show_frame: + fig.outline_line_color = None + fig.axis.visible = False # type: ignore[attr-defined] + + self._layout = gridplot( + self._figures, ncols=ncols, toolbar_location=None, # type: ignore[arg-type] + width=total_size[0] // ncols, height=total_size[1] // nrows) + + def _convert_color(self, color: str) -> str: + if isinstance(color, str) and color[0] == "C": + index = int(color[1:]) + color = self._palette[index] + return color + + def _get_figure(self, ax: figure | int) -> figure: + if isinstance(ax, int): + ax = self._figures[ax] + return ax + + def filled( + self, + filled: FillReturn, + fill_type: FillType | str, + ax: figure | int = 0, + color: str = "C0", + alpha: float = 0.7, + ) -> None: + """Plot filled contours on a single plot. + + Args: + filled (sequence of arrays): Filled contour data as returned by + :meth:`~.ContourGenerator.filled`. + fill_type (FillType or str): Type of :meth:`~.ContourGenerator.filled` data as returned + by :attr:`~.ContourGenerator.fill_type`, or a string equivalent. + ax (int or Bokeh Figure, optional): Which plot to use, default ``0``. + color (str, optional): Color to plot with. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``Category10`` palette. Default ``"C0"``. + alpha (float, optional): Opacity to plot with, default ``0.7``. + """ + fill_type = as_fill_type(fill_type) + fig = self._get_figure(ax) + color = self._convert_color(color) + xs, ys = filled_to_bokeh(filled, fill_type) + if len(xs) > 0: + fig.multi_polygons(xs=[xs], ys=[ys], color=color, fill_alpha=alpha, line_width=0) # type: ignore[arg-type] + + def grid( + self, + x: ArrayLike, + y: ArrayLike, + ax: figure | int = 0, + color: str = "black", + alpha: float = 0.1, + point_color: str | None = None, + quad_as_tri_alpha: float = 0, + ) -> None: + """Plot quad grid lines on a single plot. + + Args: + x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points. + y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points. + ax (int or Bokeh Figure, optional): Which plot to use, default ``0``. + color (str, optional): Color to plot grid lines, default ``"black"``. + alpha (float, optional): Opacity to plot lines with, default ``0.1``. + point_color (str, optional): Color to plot grid points or ``None`` if grid points + should not be plotted, default ``None``. + quad_as_tri_alpha (float, optional): Opacity to plot ``quad_as_tri`` grid, default + ``0``. + + Colors may be a string color or the letter ``"C"`` followed by an integer in the range + ``"C0"`` to ``"C9"`` to use a color from the ``Category10`` palette. + + Warning: + ``quad_as_tri_alpha > 0`` plots all quads as though they are unmasked. + """ + fig = self._get_figure(ax) + x, y = self._grid_as_2d(x, y) + xs = list(x) + list(x.T) + ys = list(y) + list(y.T) + kwargs = {"line_color": color, "alpha": alpha} + fig.multi_line(xs, ys, **kwargs) + if quad_as_tri_alpha > 0: + # Assumes no quad mask. + xmid = (0.25*(x[:-1, :-1] + x[1:, :-1] + x[:-1, 1:] + x[1:, 1:])).ravel() + ymid = (0.25*(y[:-1, :-1] + y[1:, :-1] + y[:-1, 1:] + y[1:, 1:])).ravel() + fig.multi_line( + list(np.stack((x[:-1, :-1].ravel(), xmid, x[1:, 1:].ravel()), axis=1)), + list(np.stack((y[:-1, :-1].ravel(), ymid, y[1:, 1:].ravel()), axis=1)), + **kwargs) + fig.multi_line( + list(np.stack((x[:-1, 1:].ravel(), xmid, x[1:, :-1].ravel()), axis=1)), + list(np.stack((y[:-1, 1:].ravel(), ymid, y[1:, :-1].ravel()), axis=1)), + **kwargs) + if point_color is not None: + fig.scatter( + x=x.ravel(), y=y.ravel(), fill_color=color, line_color=None, alpha=alpha, + marker="circle", size=8) + + def lines( + self, + lines: LineReturn, + line_type: LineType | str, + ax: figure | int = 0, + color: str = "C0", + alpha: float = 1.0, + linewidth: float = 1, + ) -> None: + """Plot contour lines on a single plot. + + Args: + lines (sequence of arrays): Contour line data as returned by + :meth:`~.ContourGenerator.lines`. + line_type (LineType or str): Type of :meth:`~.ContourGenerator.lines` data as returned + by :attr:`~.ContourGenerator.line_type`, or a string equivalent. + ax (int or Bokeh Figure, optional): Which plot to use, default ``0``. + color (str, optional): Color to plot lines. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``Category10`` palette. Default ``"C0"``. + alpha (float, optional): Opacity to plot lines with, default ``1.0``. + linewidth (float, optional): Width of lines, default ``1``. + + Note: + Assumes all lines are open line strips not closed line loops. + """ + line_type = as_line_type(line_type) + fig = self._get_figure(ax) + color = self._convert_color(color) + xs, ys = lines_to_bokeh(lines, line_type) + if xs is not None: + assert ys is not None + fig.line(xs, ys, line_color=color, line_alpha=alpha, line_width=linewidth) + + def mask( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike | np.ma.MaskedArray[Any, Any], + ax: figure | int = 0, + color: str = "black", + ) -> None: + """Plot masked out grid points as circles on a single plot. + + Args: + x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points. + y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points. + z (masked array of shape (ny, nx): z-values. + ax (int or Bokeh Figure, optional): Which plot to use, default ``0``. + color (str, optional): Circle color, default ``"black"``. + """ + mask = np.ma.getmask(z) # type: ignore[no-untyped-call] + if mask is np.ma.nomask: + return + fig = self._get_figure(ax) + color = self._convert_color(color) + x, y = self._grid_as_2d(x, y) + fig.scatter(x[mask], y[mask], fill_color=color, marker="circle", size=10) + + def save( + self, + filename: str, + transparent: bool = False, + *, + webdriver: WebDriver | None = None, + ) -> None: + """Save plots to SVG or PNG file. + + Args: + filename (str): Filename to save to. + transparent (bool, optional): Whether background should be transparent, default + ``False``. + webdriver (WebDriver, optional): Selenium WebDriver instance to use to create the image. + + .. versionadded:: 1.1.1 + + Warning: + To output to SVG file, ``want_svg=True`` must have been passed to the constructor. + """ + if transparent: + for fig in self._figures: + fig.background_fill_color = None + fig.border_fill_color = None + + if self._want_svg: + export_svg(self._layout, filename=filename, webdriver=webdriver) + else: + export_png(self._layout, filename=filename, webdriver=webdriver) + + def save_to_buffer(self, *, webdriver: WebDriver | None = None) -> io.BytesIO: + """Save plots to an ``io.BytesIO`` buffer. + + Args: + webdriver (WebDriver, optional): Selenium WebDriver instance to use to create the image. + + .. versionadded:: 1.1.1 + + Return: + BytesIO: PNG image buffer. + """ + image = get_screenshot_as_png(self._layout, driver=webdriver) + buffer = io.BytesIO() + image.save(buffer, "png") + return buffer + + def show(self) -> None: + """Show plots in web browser, in usual Bokeh manner. + """ + show(self._layout) + + def title(self, title: str, ax: figure | int = 0, color: str | None = None) -> None: + """Set the title of a single plot. + + Args: + title (str): Title text. + ax (int or Bokeh Figure, optional): Which plot to set the title of, default ``0``. + color (str, optional): Color to set title. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``Category10`` palette. Default ``None`` which is ``black``. + """ + fig = self._get_figure(ax) + fig.title = title + fig.title.align = "center" # type: ignore[attr-defined] + if color is not None: + fig.title.text_color = self._convert_color(color) # type: ignore[attr-defined] + + def z_values( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike, + ax: figure | int = 0, + color: str = "green", + fmt: str = ".1f", + quad_as_tri: bool = False, + ) -> None: + """Show ``z`` values on a single plot. + + Args: + x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points. + y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points. + z (array-like of shape (ny, nx): z-values. + ax (int or Bokeh Figure, optional): Which plot to use, default ``0``. + color (str, optional): Color of added text. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``Category10`` palette. Default ``"green"``. + fmt (str, optional): Format to display z-values, default ``".1f"``. + quad_as_tri (bool, optional): Whether to show z-values at the ``quad_as_tri`` centres + of quads. + + Warning: + ``quad_as_tri=True`` shows z-values for all quads, even if masked. + """ + fig = self._get_figure(ax) + color = self._convert_color(color) + x, y = self._grid_as_2d(x, y) + z = np.asarray(z) + ny, nx = z.shape + kwargs = {"text_color": color, "text_align": "center", "text_baseline": "middle"} + for j in range(ny): + for i in range(nx): + label = Label(x=x[j, i], y=y[j, i], text=f"{z[j, i]:{fmt}}", **kwargs) # type: ignore[arg-type] + fig.add_layout(label) + if quad_as_tri: + for j in range(ny-1): + for i in range(nx-1): + xx = np.mean(x[j:j+2, i:i+2]) + yy = np.mean(y[j:j+2, i:i+2]) + zz = np.mean(z[j:j+2, i:i+2]) + fig.add_layout(Label(x=xx, y=yy, text=f"{zz:{fmt}}", **kwargs)) # type: ignore[arg-type] diff --git a/lib/python3.10/site-packages/contourpy/util/bokeh_util.py b/lib/python3.10/site-packages/contourpy/util/bokeh_util.py new file mode 100644 index 0000000000000000000000000000000000000000..e75eb844536b26dfe90de08bb65328e5d2e5ba1c --- /dev/null +++ b/lib/python3.10/site-packages/contourpy/util/bokeh_util.py @@ -0,0 +1,74 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, cast + +from contourpy import FillType, LineType +from contourpy.array import offsets_from_codes +from contourpy.convert import convert_lines +from contourpy.dechunk import dechunk_lines + +if TYPE_CHECKING: + from contourpy._contourpy import ( + CoordinateArray, + FillReturn, + LineReturn, + LineReturn_ChunkCombinedNan, + ) + + +def filled_to_bokeh( + filled: FillReturn, + fill_type: FillType, +) -> tuple[list[list[CoordinateArray]], list[list[CoordinateArray]]]: + xs: list[list[CoordinateArray]] = [] + ys: list[list[CoordinateArray]] = [] + if fill_type in (FillType.OuterOffset, FillType.ChunkCombinedOffset, + FillType.OuterCode, FillType.ChunkCombinedCode): + have_codes = fill_type in (FillType.OuterCode, FillType.ChunkCombinedCode) + + for points, offsets in zip(*filled): + if points is None: + continue + if have_codes: + offsets = offsets_from_codes(offsets) + xs.append([]) # New outer with zero or more holes. + ys.append([]) + for i in range(len(offsets)-1): + xys = points[offsets[i]:offsets[i+1]] + xs[-1].append(xys[:, 0]) + ys[-1].append(xys[:, 1]) + elif fill_type in (FillType.ChunkCombinedCodeOffset, FillType.ChunkCombinedOffsetOffset): + for points, codes_or_offsets, outer_offsets in zip(*filled): + if points is None: + continue + for j in range(len(outer_offsets)-1): + if fill_type == FillType.ChunkCombinedCodeOffset: + codes = codes_or_offsets[outer_offsets[j]:outer_offsets[j+1]] + offsets = offsets_from_codes(codes) + outer_offsets[j] + else: + offsets = codes_or_offsets[outer_offsets[j]:outer_offsets[j+1]+1] + xs.append([]) # New outer with zero or more holes. + ys.append([]) + for k in range(len(offsets)-1): + xys = points[offsets[k]:offsets[k+1]] + xs[-1].append(xys[:, 0]) + ys[-1].append(xys[:, 1]) + else: + raise RuntimeError(f"Conversion of FillType {fill_type} to Bokeh is not implemented") + + return xs, ys + + +def lines_to_bokeh( + lines: LineReturn, + line_type: LineType, +) -> tuple[CoordinateArray | None, CoordinateArray | None]: + lines = convert_lines(lines, line_type, LineType.ChunkCombinedNan) + lines = dechunk_lines(lines, LineType.ChunkCombinedNan) + if TYPE_CHECKING: + lines = cast(LineReturn_ChunkCombinedNan, lines) + points = lines[0][0] + if points is None: + return None, None + else: + return points[:, 0], points[:, 1] diff --git a/lib/python3.10/site-packages/contourpy/util/data.py b/lib/python3.10/site-packages/contourpy/util/data.py new file mode 100644 index 0000000000000000000000000000000000000000..5fa75486958c8277430f149daf872e859de8e000 --- /dev/null +++ b/lib/python3.10/site-packages/contourpy/util/data.py @@ -0,0 +1,78 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import numpy as np + +if TYPE_CHECKING: + from contourpy._contourpy import CoordinateArray + + +def simple( + shape: tuple[int, int], want_mask: bool = False, +) -> tuple[CoordinateArray, CoordinateArray, CoordinateArray | np.ma.MaskedArray[Any, Any]]: + """Return simple test data consisting of the sum of two gaussians. + + Args: + shape (tuple(int, int)): 2D shape of data to return. + want_mask (bool, optional): Whether test data should be masked or not, default ``False``. + + Return: + Tuple of 3 arrays: ``x``, ``y``, ``z`` test data, ``z`` will be masked if + ``want_mask=True``. + """ + ny, nx = shape + x = np.arange(nx, dtype=np.float64) + y = np.arange(ny, dtype=np.float64) + x, y = np.meshgrid(x, y) + + xscale = nx - 1.0 + yscale = ny - 1.0 + + # z is sum of 2D gaussians. + amp = np.asarray([1.0, -1.0, 0.8, -0.9, 0.7]) + mid = np.asarray([[0.4, 0.2], [0.3, 0.8], [0.9, 0.75], [0.7, 0.3], [0.05, 0.7]]) + width = np.asarray([0.4, 0.2, 0.2, 0.2, 0.1]) + + z = np.zeros_like(x) + for i in range(len(amp)): + z += amp[i]*np.exp(-((x/xscale - mid[i, 0])**2 + (y/yscale - mid[i, 1])**2) / width[i]**2) + + if want_mask: + mask = np.logical_or( + ((x/xscale - 1.0)**2 / 0.2 + (y/yscale - 0.0)**2 / 0.1) < 1.0, + ((x/xscale - 0.2)**2 / 0.02 + (y/yscale - 0.45)**2 / 0.08) < 1.0, + ) + z = np.ma.array(z, mask=mask) # type: ignore[no-untyped-call] + + return x, y, z + + +def random( + shape: tuple[int, int], seed: int = 2187, mask_fraction: float = 0.0, +) -> tuple[CoordinateArray, CoordinateArray, CoordinateArray | np.ma.MaskedArray[Any, Any]]: + """Return random test data in the range 0 to 1. + + Args: + shape (tuple(int, int)): 2D shape of data to return. + seed (int, optional): Seed for random number generator, default 2187. + mask_fraction (float, optional): Fraction of elements to mask, default 0. + + Return: + Tuple of 3 arrays: ``x``, ``y``, ``z`` test data, ``z`` will be masked if + ``mask_fraction`` is greater than zero. + """ + ny, nx = shape + x = np.arange(nx, dtype=np.float64) + y = np.arange(ny, dtype=np.float64) + x, y = np.meshgrid(x, y) + + rng = np.random.default_rng(seed) + z = rng.uniform(size=shape) + + if mask_fraction > 0.0: + mask_fraction = min(mask_fraction, 0.99) + mask = rng.uniform(size=shape) < mask_fraction + z = np.ma.array(z, mask=mask) # type: ignore[no-untyped-call] + + return x, y, z diff --git a/lib/python3.10/site-packages/contourpy/util/mpl_renderer.py b/lib/python3.10/site-packages/contourpy/util/mpl_renderer.py new file mode 100644 index 0000000000000000000000000000000000000000..d648cadebff614b9da9b8a926012e6eb54c6aee4 --- /dev/null +++ b/lib/python3.10/site-packages/contourpy/util/mpl_renderer.py @@ -0,0 +1,535 @@ +from __future__ import annotations + +import io +from itertools import pairwise +from typing import TYPE_CHECKING, Any, cast + +import matplotlib.collections as mcollections +import matplotlib.pyplot as plt +import numpy as np + +from contourpy import FillType, LineType +from contourpy.convert import convert_filled, convert_lines +from contourpy.enum_util import as_fill_type, as_line_type +from contourpy.util.mpl_util import filled_to_mpl_paths, lines_to_mpl_paths +from contourpy.util.renderer import Renderer + +if TYPE_CHECKING: + from collections.abc import Sequence + + from matplotlib.axes import Axes + from matplotlib.figure import Figure + from numpy.typing import ArrayLike + + import contourpy._contourpy as cpy + + +class MplRenderer(Renderer): + """Utility renderer using Matplotlib to render a grid of plots over the same (x, y) range. + + Args: + nrows (int, optional): Number of rows of plots, default ``1``. + ncols (int, optional): Number of columns of plots, default ``1``. + figsize (tuple(float, float), optional): Figure size in inches, default ``(9, 9)``. + show_frame (bool, optional): Whether to show frame and axes ticks, default ``True``. + backend (str, optional): Matplotlib backend to use or ``None`` for default backend. + Default ``None``. + gridspec_kw (dict, optional): Gridspec keyword arguments to pass to ``plt.subplots``, + default None. + """ + _axes: Sequence[Axes] + _fig: Figure + _want_tight: bool + + def __init__( + self, + nrows: int = 1, + ncols: int = 1, + figsize: tuple[float, float] = (9, 9), + show_frame: bool = True, + backend: str | None = None, + gridspec_kw: dict[str, Any] | None = None, + ) -> None: + if backend is not None: + import matplotlib as mpl + mpl.use(backend) + + kwargs: dict[str, Any] = {"figsize": figsize, "squeeze": False, + "sharex": True, "sharey": True} + if gridspec_kw is not None: + kwargs["gridspec_kw"] = gridspec_kw + else: + kwargs["subplot_kw"] = {"aspect": "equal"} + + self._fig, axes = plt.subplots(nrows, ncols, **kwargs) + self._axes = axes.flatten() + if not show_frame: + for ax in self._axes: + ax.axis("off") + + self._want_tight = True + + def __del__(self) -> None: + if hasattr(self, "_fig"): + plt.close(self._fig) + + def _autoscale(self) -> None: + # Using axes._need_autoscale attribute if need to autoscale before rendering after adding + # lines/filled. Only want to autoscale once per axes regardless of how many lines/filled + # added. + for ax in self._axes: + if getattr(ax, "_need_autoscale", False): + ax.autoscale_view(tight=True) + ax._need_autoscale = False # type: ignore[attr-defined] + if self._want_tight and len(self._axes) > 1: + self._fig.tight_layout() + + def _get_ax(self, ax: Axes | int) -> Axes: + if isinstance(ax, int): + ax = self._axes[ax] + return ax + + def filled( + self, + filled: cpy.FillReturn, + fill_type: FillType | str, + ax: Axes | int = 0, + color: str = "C0", + alpha: float = 0.7, + ) -> None: + """Plot filled contours on a single Axes. + + Args: + filled (sequence of arrays): Filled contour data as returned by + :meth:`~.ContourGenerator.filled`. + fill_type (FillType or str): Type of :meth:`~.ContourGenerator.filled` data as returned + by :attr:`~.ContourGenerator.fill_type`, or string equivalent + ax (int or Maplotlib Axes, optional): Which axes to plot on, default ``0``. + color (str, optional): Color to plot with. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``tab10`` colormap. Default ``"C0"``. + alpha (float, optional): Opacity to plot with, default ``0.7``. + """ + fill_type = as_fill_type(fill_type) + ax = self._get_ax(ax) + paths = filled_to_mpl_paths(filled, fill_type) + collection = mcollections.PathCollection( + paths, facecolors=color, edgecolors="none", lw=0, alpha=alpha) + ax.add_collection(collection) + ax._need_autoscale = True # type: ignore[attr-defined] + + def grid( + self, + x: ArrayLike, + y: ArrayLike, + ax: Axes | int = 0, + color: str = "black", + alpha: float = 0.1, + point_color: str | None = None, + quad_as_tri_alpha: float = 0, + ) -> None: + """Plot quad grid lines on a single Axes. + + Args: + x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points. + y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points. + ax (int or Matplotlib Axes, optional): Which Axes to plot on, default ``0``. + color (str, optional): Color to plot grid lines, default ``"black"``. + alpha (float, optional): Opacity to plot lines with, default ``0.1``. + point_color (str, optional): Color to plot grid points or ``None`` if grid points + should not be plotted, default ``None``. + quad_as_tri_alpha (float, optional): Opacity to plot ``quad_as_tri`` grid, default 0. + + Colors may be a string color or the letter ``"C"`` followed by an integer in the range + ``"C0"`` to ``"C9"`` to use a color from the ``tab10`` colormap. + + Warning: + ``quad_as_tri_alpha > 0`` plots all quads as though they are unmasked. + """ + ax = self._get_ax(ax) + x, y = self._grid_as_2d(x, y) + kwargs: dict[str, Any] = {"color": color, "alpha": alpha} + ax.plot(x, y, x.T, y.T, **kwargs) + if quad_as_tri_alpha > 0: + # Assumes no quad mask. + xmid = 0.25*(x[:-1, :-1] + x[1:, :-1] + x[:-1, 1:] + x[1:, 1:]) + ymid = 0.25*(y[:-1, :-1] + y[1:, :-1] + y[:-1, 1:] + y[1:, 1:]) + kwargs["alpha"] = quad_as_tri_alpha + ax.plot( + np.stack((x[:-1, :-1], xmid, x[1:, 1:])).reshape((3, -1)), + np.stack((y[:-1, :-1], ymid, y[1:, 1:])).reshape((3, -1)), + np.stack((x[1:, :-1], xmid, x[:-1, 1:])).reshape((3, -1)), + np.stack((y[1:, :-1], ymid, y[:-1, 1:])).reshape((3, -1)), + **kwargs) + if point_color is not None: + ax.plot(x, y, color=point_color, alpha=alpha, marker="o", lw=0) + ax._need_autoscale = True # type: ignore[attr-defined] + + def lines( + self, + lines: cpy.LineReturn, + line_type: LineType | str, + ax: Axes | int = 0, + color: str = "C0", + alpha: float = 1.0, + linewidth: float = 1, + ) -> None: + """Plot contour lines on a single Axes. + + Args: + lines (sequence of arrays): Contour line data as returned by + :meth:`~.ContourGenerator.lines`. + line_type (LineType or str): Type of :meth:`~.ContourGenerator.lines` data as returned + by :attr:`~.ContourGenerator.line_type`, or string equivalent. + ax (int or Matplotlib Axes, optional): Which Axes to plot on, default ``0``. + color (str, optional): Color to plot lines. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``tab10`` colormap. Default ``"C0"``. + alpha (float, optional): Opacity to plot lines with, default ``1.0``. + linewidth (float, optional): Width of lines, default ``1``. + """ + line_type = as_line_type(line_type) + ax = self._get_ax(ax) + paths = lines_to_mpl_paths(lines, line_type) + collection = mcollections.PathCollection( + paths, facecolors="none", edgecolors=color, lw=linewidth, alpha=alpha) + ax.add_collection(collection) + ax._need_autoscale = True # type: ignore[attr-defined] + + def mask( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike | np.ma.MaskedArray[Any, Any], + ax: Axes | int = 0, + color: str = "black", + ) -> None: + """Plot masked out grid points as circles on a single Axes. + + Args: + x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points. + y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points. + z (masked array of shape (ny, nx): z-values. + ax (int or Matplotlib Axes, optional): Which Axes to plot on, default ``0``. + color (str, optional): Circle color, default ``"black"``. + """ + mask = np.ma.getmask(z) # type: ignore[no-untyped-call] + if mask is np.ma.nomask: + return + ax = self._get_ax(ax) + x, y = self._grid_as_2d(x, y) + ax.plot(x[mask], y[mask], "o", c=color) + + def save(self, filename: str, transparent: bool = False) -> None: + """Save plots to SVG or PNG file. + + Args: + filename (str): Filename to save to. + transparent (bool, optional): Whether background should be transparent, default + ``False``. + """ + self._autoscale() + self._fig.savefig(filename, transparent=transparent) + + def save_to_buffer(self) -> io.BytesIO: + """Save plots to an ``io.BytesIO`` buffer. + + Return: + BytesIO: PNG image buffer. + """ + self._autoscale() + buf = io.BytesIO() + self._fig.savefig(buf, format="png") + buf.seek(0) + return buf + + def show(self) -> None: + """Show plots in an interactive window, in the usual Matplotlib manner. + """ + self._autoscale() + plt.show() + + def title(self, title: str, ax: Axes | int = 0, color: str | None = None) -> None: + """Set the title of a single Axes. + + Args: + title (str): Title text. + ax (int or Matplotlib Axes, optional): Which Axes to set the title of, default ``0``. + color (str, optional): Color to set title. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``tab10`` colormap. Default is ``None`` which uses Matplotlib's default title color + that depends on the stylesheet in use. + """ + if color: + self._get_ax(ax).set_title(title, color=color) + else: + self._get_ax(ax).set_title(title) + + def z_values( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike, + ax: Axes | int = 0, + color: str = "green", + fmt: str = ".1f", + quad_as_tri: bool = False, + ) -> None: + """Show ``z`` values on a single Axes. + + Args: + x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points. + y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points. + z (array-like of shape (ny, nx): z-values. + ax (int or Matplotlib Axes, optional): Which Axes to plot on, default ``0``. + color (str, optional): Color of added text. May be a string color or the letter ``"C"`` + followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the + ``tab10`` colormap. Default ``"green"``. + fmt (str, optional): Format to display z-values, default ``".1f"``. + quad_as_tri (bool, optional): Whether to show z-values at the ``quad_as_tri`` centers + of quads. + + Warning: + ``quad_as_tri=True`` shows z-values for all quads, even if masked. + """ + ax = self._get_ax(ax) + x, y = self._grid_as_2d(x, y) + z = np.asarray(z) + ny, nx = z.shape + for j in range(ny): + for i in range(nx): + ax.text(x[j, i], y[j, i], f"{z[j, i]:{fmt}}", ha="center", va="center", + color=color, clip_on=True) + if quad_as_tri: + for j in range(ny-1): + for i in range(nx-1): + xx = np.mean(x[j:j+2, i:i+2], dtype=np.float64) + yy = np.mean(y[j:j+2, i:i+2], dtype=np.float64) + zz = np.mean(z[j:j+2, i:i+2]) + ax.text(xx, yy, f"{zz:{fmt}}", ha="center", va="center", color=color, + clip_on=True) + + +class MplTestRenderer(MplRenderer): + """Test renderer implemented using Matplotlib. + + No whitespace around plots and no spines/ticks displayed. + Uses Agg backend, so can only save to file/buffer, cannot call ``show()``. + """ + def __init__( + self, + nrows: int = 1, + ncols: int = 1, + figsize: tuple[float, float] = (9, 9), + ) -> None: + gridspec = { + "left": 0.01, + "right": 0.99, + "top": 0.99, + "bottom": 0.01, + "wspace": 0.01, + "hspace": 0.01, + } + super().__init__( + nrows, ncols, figsize, show_frame=True, backend="Agg", gridspec_kw=gridspec, + ) + + for ax in self._axes: + ax.set_xmargin(0.0) + ax.set_ymargin(0.0) + ax.set_xticks([]) + ax.set_yticks([]) + + self._want_tight = False + + +class MplDebugRenderer(MplRenderer): + """Debug renderer implemented using Matplotlib. + + Extends ``MplRenderer`` to add extra information to help in debugging such as markers, arrows, + text, etc. + """ + def __init__( + self, + nrows: int = 1, + ncols: int = 1, + figsize: tuple[float, float] = (9, 9), + show_frame: bool = True, + ) -> None: + super().__init__(nrows, ncols, figsize, show_frame) + + def _arrow( + self, + ax: Axes, + line_start: cpy.CoordinateArray, + line_end: cpy.CoordinateArray, + color: str, + alpha: float, + arrow_size: float, + ) -> None: + mid = 0.5*(line_start + line_end) + along = line_end - line_start + along /= np.sqrt(np.dot(along, along)) # Unit vector. + right = np.asarray((along[1], -along[0])) + arrow = np.stack(( + mid - (along*0.5 - right)*arrow_size, + mid + along*0.5*arrow_size, + mid - (along*0.5 + right)*arrow_size, + )) + ax.plot(arrow[:, 0], arrow[:, 1], "-", c=color, alpha=alpha) + + def filled( + self, + filled: cpy.FillReturn, + fill_type: FillType | str, + ax: Axes | int = 0, + color: str = "C1", + alpha: float = 0.7, + line_color: str = "C0", + line_alpha: float = 0.7, + point_color: str = "C0", + start_point_color: str = "red", + arrow_size: float = 0.1, + ) -> None: + fill_type = as_fill_type(fill_type) + super().filled(filled, fill_type, ax, color, alpha) + + if line_color is None and point_color is None: + return + + ax = self._get_ax(ax) + filled = convert_filled(filled, fill_type, FillType.ChunkCombinedOffset) + + # Lines. + if line_color is not None: + for points, offsets in zip(*filled): + if points is None: + continue + for start, end in pairwise(offsets): + xys = points[start:end] + ax.plot(xys[:, 0], xys[:, 1], c=line_color, alpha=line_alpha) + + if arrow_size > 0.0: + n = len(xys) + for i in range(n-1): + self._arrow(ax, xys[i], xys[i+1], line_color, line_alpha, arrow_size) + + # Points. + if point_color is not None: + for points, offsets in zip(*filled): + if points is None: + continue + mask = np.ones(offsets[-1], dtype=bool) + mask[offsets[1:]-1] = False # Exclude end points. + if start_point_color is not None: + start_indices = offsets[:-1] + mask[start_indices] = False # Exclude start points. + ax.plot( + points[:, 0][mask], points[:, 1][mask], "o", c=point_color, alpha=line_alpha) + + if start_point_color is not None: + ax.plot(points[:, 0][start_indices], points[:, 1][start_indices], "o", + c=start_point_color, alpha=line_alpha) + + def lines( + self, + lines: cpy.LineReturn, + line_type: LineType | str, + ax: Axes | int = 0, + color: str = "C0", + alpha: float = 1.0, + linewidth: float = 1, + point_color: str = "C0", + start_point_color: str = "red", + arrow_size: float = 0.1, + ) -> None: + line_type = as_line_type(line_type) + super().lines(lines, line_type, ax, color, alpha, linewidth) + + if arrow_size == 0.0 and point_color is None: + return + + ax = self._get_ax(ax) + separate_lines = convert_lines(lines, line_type, LineType.Separate) + if TYPE_CHECKING: + separate_lines = cast(cpy.LineReturn_Separate, separate_lines) + + if arrow_size > 0.0: + for line in separate_lines: + for i in range(len(line)-1): + self._arrow(ax, line[i], line[i+1], color, alpha, arrow_size) + + if point_color is not None: + for line in separate_lines: + start_index = 0 + end_index = len(line) + if start_point_color is not None: + ax.plot(line[0, 0], line[0, 1], "o", c=start_point_color, alpha=alpha) + start_index = 1 + if line[0][0] == line[-1][0] and line[0][1] == line[-1][1]: + end_index -= 1 + ax.plot(line[start_index:end_index, 0], line[start_index:end_index, 1], "o", + c=color, alpha=alpha) + + def point_numbers( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike, + ax: Axes | int = 0, + color: str = "red", + ) -> None: + ax = self._get_ax(ax) + x, y = self._grid_as_2d(x, y) + z = np.asarray(z) + ny, nx = z.shape + for j in range(ny): + for i in range(nx): + quad = i + j*nx + ax.text(x[j, i], y[j, i], str(quad), ha="right", va="top", color=color, + clip_on=True) + + def quad_numbers( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike, + ax: Axes | int = 0, + color: str = "blue", + ) -> None: + ax = self._get_ax(ax) + x, y = self._grid_as_2d(x, y) + z = np.asarray(z) + ny, nx = z.shape + for j in range(1, ny): + for i in range(1, nx): + quad = i + j*nx + xmid = x[j-1:j+1, i-1:i+1].mean() + ymid = y[j-1:j+1, i-1:i+1].mean() + ax.text(xmid, ymid, str(quad), ha="center", va="center", color=color, clip_on=True) + + def z_levels( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike, + lower_level: float, + upper_level: float | None = None, + ax: Axes | int = 0, + color: str = "green", + ) -> None: + ax = self._get_ax(ax) + x, y = self._grid_as_2d(x, y) + z = np.asarray(z) + ny, nx = z.shape + for j in range(ny): + for i in range(nx): + zz = z[j, i] + if upper_level is not None and zz > upper_level: + z_level = 2 + elif zz > lower_level: + z_level = 1 + else: + z_level = 0 + ax.text(x[j, i], y[j, i], str(z_level), ha="left", va="bottom", color=color, + clip_on=True) diff --git a/lib/python3.10/site-packages/contourpy/util/mpl_util.py b/lib/python3.10/site-packages/contourpy/util/mpl_util.py new file mode 100644 index 0000000000000000000000000000000000000000..d8587798c499a9ab898ee6cb54738be7e41bf7cf --- /dev/null +++ b/lib/python3.10/site-packages/contourpy/util/mpl_util.py @@ -0,0 +1,77 @@ +from __future__ import annotations + +from itertools import pairwise +from typing import TYPE_CHECKING, cast + +import matplotlib.path as mpath +import numpy as np + +from contourpy import FillType, LineType +from contourpy.array import codes_from_offsets + +if TYPE_CHECKING: + from contourpy._contourpy import FillReturn, LineReturn, LineReturn_Separate + + +def filled_to_mpl_paths(filled: FillReturn, fill_type: FillType) -> list[mpath.Path]: + if fill_type in (FillType.OuterCode, FillType.ChunkCombinedCode): + paths = [mpath.Path(points, codes) for points, codes in zip(*filled) if points is not None] + elif fill_type in (FillType.OuterOffset, FillType.ChunkCombinedOffset): + paths = [mpath.Path(points, codes_from_offsets(offsets)) + for points, offsets in zip(*filled) if points is not None] + elif fill_type == FillType.ChunkCombinedCodeOffset: + paths = [] + for points, codes, outer_offsets in zip(*filled): + if points is None: + continue + points = np.split(points, outer_offsets[1:-1]) + codes = np.split(codes, outer_offsets[1:-1]) + paths += [mpath.Path(p, c) for p, c in zip(points, codes)] + elif fill_type == FillType.ChunkCombinedOffsetOffset: + paths = [] + for points, offsets, outer_offsets in zip(*filled): + if points is None: + continue + for i in range(len(outer_offsets)-1): + offs = offsets[outer_offsets[i]:outer_offsets[i+1]+1] + pts = points[offs[0]:offs[-1]] + paths += [mpath.Path(pts, codes_from_offsets(offs - offs[0]))] + else: + raise RuntimeError(f"Conversion of FillType {fill_type} to MPL Paths is not implemented") + return paths + + +def lines_to_mpl_paths(lines: LineReturn, line_type: LineType) -> list[mpath.Path]: + if line_type == LineType.Separate: + if TYPE_CHECKING: + lines = cast(LineReturn_Separate, lines) + paths = [] + for line in lines: + # Drawing as Paths so that they can be closed correctly. + closed = line[0, 0] == line[-1, 0] and line[0, 1] == line[-1, 1] + paths.append(mpath.Path(line, closed=closed)) + elif line_type in (LineType.SeparateCode, LineType.ChunkCombinedCode): + paths = [mpath.Path(points, codes) for points, codes in zip(*lines) if points is not None] + elif line_type == LineType.ChunkCombinedOffset: + paths = [] + for points, offsets in zip(*lines): + if points is None: + continue + for i in range(len(offsets)-1): + line = points[offsets[i]:offsets[i+1]] + closed = line[0, 0] == line[-1, 0] and line[0, 1] == line[-1, 1] + paths.append(mpath.Path(line, closed=closed)) + elif line_type == LineType.ChunkCombinedNan: + paths = [] + for points in lines[0]: + if points is None: + continue + nan_offsets = np.nonzero(np.isnan(points[:, 0]))[0] + nan_offsets = np.concatenate([[-1], nan_offsets, [len(points)]]) + for s, e in pairwise(nan_offsets): + line = points[s+1:e] + closed = line[0, 0] == line[-1, 0] and line[0, 1] == line[-1, 1] + paths.append(mpath.Path(line, closed=closed)) + else: + raise RuntimeError(f"Conversion of LineType {line_type} to MPL Paths is not implemented") + return paths diff --git a/lib/python3.10/site-packages/contourpy/util/renderer.py b/lib/python3.10/site-packages/contourpy/util/renderer.py new file mode 100644 index 0000000000000000000000000000000000000000..716569f776c4df9197a36f40e9f0a5e176292114 --- /dev/null +++ b/lib/python3.10/site-packages/contourpy/util/renderer.py @@ -0,0 +1,166 @@ +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import TYPE_CHECKING, Any + +import numpy as np + +if TYPE_CHECKING: + import io + + from numpy.typing import ArrayLike + + from contourpy._contourpy import CoordinateArray, FillReturn, FillType, LineReturn, LineType + + +class Renderer(ABC): + """Abstract base class for renderers.""" + + def _grid_as_2d(self, x: ArrayLike, y: ArrayLike) -> tuple[CoordinateArray, CoordinateArray]: + x = np.asarray(x) + y = np.asarray(y) + if x.ndim == 1: + x, y = np.meshgrid(x, y) + return x, y + + @abstractmethod + def filled( + self, + filled: FillReturn, + fill_type: FillType | str, + ax: Any = 0, + color: str = "C0", + alpha: float = 0.7, + ) -> None: + pass + + @abstractmethod + def grid( + self, + x: ArrayLike, + y: ArrayLike, + ax: Any = 0, + color: str = "black", + alpha: float = 0.1, + point_color: str | None = None, + quad_as_tri_alpha: float = 0, + ) -> None: + pass + + @abstractmethod + def lines( + self, + lines: LineReturn, + line_type: LineType | str, + ax: Any = 0, + color: str = "C0", + alpha: float = 1.0, + linewidth: float = 1, + ) -> None: + pass + + @abstractmethod + def mask( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike | np.ma.MaskedArray[Any, Any], + ax: Any = 0, + color: str = "black", + ) -> None: + pass + + def multi_filled( + self, + multi_filled: list[FillReturn], + fill_type: FillType | str, + ax: Any = 0, + color: str | None = None, + **kwargs: Any, + ) -> None: + """Plot multiple sets of filled contours on a single axes. + + Args: + multi_filled (list of filled contour arrays): Multiple filled contour sets as returned + by :meth:`.ContourGenerator.multi_filled`. + fill_type (FillType or str): Type of filled data as returned by + :attr:`~.ContourGenerator.fill_type`, or string equivalent. + ax (int or Renderer-specific axes or figure object, optional): Which axes to plot on, + default ``0``. + color (str or None, optional): If a string color then this same color is used for all + filled contours. If ``None``, the default, then the filled contour sets use colors + from the ``tab10`` colormap in order, wrapping around to the beginning if more than + 10 sets of filled contours are rendered. + kwargs: All other keyword argument are passed on to + :meth:`.Renderer.filled` unchanged. + + .. versionadded:: 1.3.0 + """ + if color is not None: + kwargs["color"] = color + for i, filled in enumerate(multi_filled): + if color is None: + kwargs["color"] = f"C{i % 10}" + self.filled(filled, fill_type, ax, **kwargs) + + def multi_lines( + self, + multi_lines: list[LineReturn], + line_type: LineType | str, + ax: Any = 0, + color: str | None = None, + **kwargs: Any, + ) -> None: + """Plot multiple sets of contour lines on a single axes. + + Args: + multi_lines (list of contour line arrays): Multiple contour line sets as returned by + :meth:`.ContourGenerator.multi_lines`. + line_type (LineType or str): Type of line data as returned by + :attr:`~.ContourGenerator.line_type`, or string equivalent. + ax (int or Renderer-specific axes or figure object, optional): Which axes to plot on, + default ``0``. + color (str or None, optional): If a string color then this same color is used for all + lines. If ``None``, the default, then the line sets use colors from the ``tab10`` + colormap in order, wrapping around to the beginning if more than 10 sets of lines + are rendered. + kwargs: All other keyword argument are passed on to + :meth:`Renderer.lines` unchanged. + + .. versionadded:: 1.3.0 + """ + if color is not None: + kwargs["color"] = color + for i, lines in enumerate(multi_lines): + if color is None: + kwargs["color"] = f"C{i % 10}" + self.lines(lines, line_type, ax, **kwargs) + + @abstractmethod + def save(self, filename: str, transparent: bool = False) -> None: + pass + + @abstractmethod + def save_to_buffer(self) -> io.BytesIO: + pass + + @abstractmethod + def show(self) -> None: + pass + + @abstractmethod + def title(self, title: str, ax: Any = 0, color: str | None = None) -> None: + pass + + @abstractmethod + def z_values( + self, + x: ArrayLike, + y: ArrayLike, + z: ArrayLike, + ax: Any = 0, + color: str = "green", + fmt: str = ".1f", + quad_as_tri: bool = False, + ) -> None: + pass diff --git a/lib/python3.10/site-packages/cv2/data/__pycache__/__init__.cpython-310.pyc b/lib/python3.10/site-packages/cv2/data/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..444748a0a1096ad873c9cebb6b824f7f46284eb5 Binary files /dev/null and b/lib/python3.10/site-packages/cv2/data/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/python3.10/site-packages/cv2/gapi/core/cpu/__init__.pyi b/lib/python3.10/site-packages/cv2/gapi/core/cpu/__init__.pyi new file mode 100644 index 0000000000000000000000000000000000000000..b85ebb121e506c99a5bf55d46d4b61f31b62da80 --- /dev/null +++ b/lib/python3.10/site-packages/cv2/gapi/core/cpu/__init__.pyi @@ -0,0 +1,9 @@ +__all__: list[str] = [] + +import cv2 + + +# Functions +def kernels() -> cv2.GKernelPackage: ... + + diff --git a/lib/python3.10/site-packages/cv2/gapi/core/fluid/__init__.pyi b/lib/python3.10/site-packages/cv2/gapi/core/fluid/__init__.pyi new file mode 100644 index 0000000000000000000000000000000000000000..b85ebb121e506c99a5bf55d46d4b61f31b62da80 --- /dev/null +++ b/lib/python3.10/site-packages/cv2/gapi/core/fluid/__init__.pyi @@ -0,0 +1,9 @@ +__all__: list[str] = [] + +import cv2 + + +# Functions +def kernels() -> cv2.GKernelPackage: ... + + diff --git a/lib/python3.10/site-packages/cv2/gapi/core/ocl/__init__.pyi b/lib/python3.10/site-packages/cv2/gapi/core/ocl/__init__.pyi new file mode 100644 index 0000000000000000000000000000000000000000..b85ebb121e506c99a5bf55d46d4b61f31b62da80 --- /dev/null +++ b/lib/python3.10/site-packages/cv2/gapi/core/ocl/__init__.pyi @@ -0,0 +1,9 @@ +__all__: list[str] = [] + +import cv2 + + +# Functions +def kernels() -> cv2.GKernelPackage: ... + + diff --git a/lib/python3.10/site-packages/cv2/gapi/ie/detail/__init__.pyi b/lib/python3.10/site-packages/cv2/gapi/ie/detail/__init__.pyi new file mode 100644 index 0000000000000000000000000000000000000000..e9aa68c68a73a2a25a419d64f5781581931251ab --- /dev/null +++ b/lib/python3.10/site-packages/cv2/gapi/ie/detail/__init__.pyi @@ -0,0 +1,12 @@ +__all__: list[str] = [] + +ParamDesc_Kind_Load: int +PARAM_DESC_KIND_LOAD: int +ParamDesc_Kind_Import: int +PARAM_DESC_KIND_IMPORT: int +ParamDesc_Kind = int +"""One of [ParamDesc_Kind_Load, PARAM_DESC_KIND_LOAD, ParamDesc_Kind_Import, PARAM_DESC_KIND_IMPORT]""" + + +# Classes + diff --git a/lib/python3.10/site-packages/cv2/gapi/imgproc/fluid/__init__.pyi b/lib/python3.10/site-packages/cv2/gapi/imgproc/fluid/__init__.pyi new file mode 100644 index 0000000000000000000000000000000000000000..b85ebb121e506c99a5bf55d46d4b61f31b62da80 --- /dev/null +++ b/lib/python3.10/site-packages/cv2/gapi/imgproc/fluid/__init__.pyi @@ -0,0 +1,9 @@ +__all__: list[str] = [] + +import cv2 + + +# Functions +def kernels() -> cv2.GKernelPackage: ... + + diff --git a/lib/python3.10/site-packages/cv2/gapi/onnx/ep/__init__.pyi b/lib/python3.10/site-packages/cv2/gapi/onnx/ep/__init__.pyi new file mode 100644 index 0000000000000000000000000000000000000000..e32f039760ac0f095f7d1aa6112e6e1ac692fc85 --- /dev/null +++ b/lib/python3.10/site-packages/cv2/gapi/onnx/ep/__init__.pyi @@ -0,0 +1,63 @@ +__all__: list[str] = [] + +import cv2.typing +import typing as _typing + + +# Classes +class CoreML: + # Functions + def __init__(self) -> None: ... + + def cfgUseCPUOnly(self) -> CoreML: ... + + def cfgEnableOnSubgraph(self) -> CoreML: ... + + def cfgEnableOnlyNeuralEngine(self) -> CoreML: ... + + +class CUDA: + # Functions + @_typing.overload + def __init__(self) -> None: ... + @_typing.overload + def __init__(self, dev_id: int) -> None: ... + + +class TensorRT: + # Functions + @_typing.overload + def __init__(self) -> None: ... + @_typing.overload + def __init__(self, dev_id: int) -> None: ... + + +class OpenVINO: + # Functions + @_typing.overload + def __init__(self) -> None: ... + @_typing.overload + def __init__(self, dev_type: str) -> None: ... + @_typing.overload + def __init__(self, params: cv2.typing.map_string_and_string) -> None: ... + + def cfgCacheDir(self, dir: str) -> OpenVINO: ... + + def cfgNumThreads(self, nthreads: int) -> OpenVINO: ... + + def cfgEnableOpenCLThrottling(self) -> OpenVINO: ... + + def cfgEnableDynamicShapes(self) -> OpenVINO: ... + + +class DirectML: + # Functions + @_typing.overload + def __init__(self) -> None: ... + @_typing.overload + def __init__(self, device_id: int) -> None: ... + @_typing.overload + def __init__(self, adapter_name: str) -> None: ... + + + diff --git a/lib/python3.10/site-packages/cv2/gapi/ot/cpu/__init__.pyi b/lib/python3.10/site-packages/cv2/gapi/ot/cpu/__init__.pyi new file mode 100644 index 0000000000000000000000000000000000000000..b85ebb121e506c99a5bf55d46d4b61f31b62da80 --- /dev/null +++ b/lib/python3.10/site-packages/cv2/gapi/ot/cpu/__init__.pyi @@ -0,0 +1,9 @@ +__all__: list[str] = [] + +import cv2 + + +# Functions +def kernels() -> cv2.GKernelPackage: ... + + diff --git a/lib/python3.10/site-packages/dash/dcc/.gitkeep b/lib/python3.10/site-packages/dash/dcc/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/lib/python3.10/site-packages/dash/dcc/Checklist.py b/lib/python3.10/site-packages/dash/dcc/Checklist.py new file mode 100644 index 0000000000000000000000000000000000000000..32144231a0eb3b0d7a01c5a3977035d33e7997b7 --- /dev/null +++ b/lib/python3.10/site-packages/dash/dcc/Checklist.py @@ -0,0 +1,179 @@ +# AUTO GENERATED FILE - DO NOT EDIT + +import typing # noqa: F401 +from typing_extensions import TypedDict, NotRequired, Literal # noqa: F401 +from dash.development.base_component import Component, _explicitize_args + +ComponentType = typing.Union[ + str, + int, + float, + Component, + None, + typing.Sequence[typing.Union[str, int, float, Component, None]], +] + +NumberType = typing.Union[ + typing.SupportsFloat, typing.SupportsInt, typing.SupportsComplex +] + + +class Checklist(Component): + """A Checklist component. + Checklist is a component that encapsulates several checkboxes. + The values and labels of the checklist are specified in the `options` + property and the checked items are specified with the `value` property. + Each checkbox is rendered as an input with a surrounding label. + + Keyword arguments: + + - options (list of dicts; optional): + An array of options. + + `options` is a list of string | number | booleans | dict | list of + dicts with keys: + + - label (a list of or a singular dash component, string or number; required): + The option's label. + + - value (string | number | boolean; required): + The value of the option. This value corresponds to the items + specified in the `value` property. + + - disabled (boolean; optional): + If True, this option is disabled and cannot be selected. + + - title (string; optional): + The HTML 'title' attribute for the option. Allows for + information on hover. For more information on this attribute, + see + https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title. + + - value (list of string | number | booleans; optional): + The currently selected value. + + - inline (boolean; default False): + Indicates whether the options labels should be displayed inline + (True=horizontal) or in a block (False=vertical). + + - className (string; optional): + The class of the container (div). + + - inputStyle (dict; optional): + The style of the checkbox element. + + - inputClassName (string; default ''): + The class of the checkbox element. + + - labelStyle (dict; optional): + The style of the