diff options
author | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
---|---|---|
committer | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
commit | 4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch) | |
tree | ee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/openpyxl/compat | |
parent | cc961e04ba734dd72309fb548a2f97d67d578813 (diff) | |
download | gn-ai-master.tar.gz |
Diffstat (limited to '.venv/lib/python3.12/site-packages/openpyxl/compat')
6 files changed, 187 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/openpyxl/compat/__init__.py b/.venv/lib/python3.12/site-packages/openpyxl/compat/__init__.py new file mode 100644 index 00000000..dac09096 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/openpyxl/compat/__init__.py @@ -0,0 +1,54 @@ +# Copyright (c) 2010-2024 openpyxl + +from .numbers import NUMERIC_TYPES +from .strings import safe_string + +import warnings +from functools import wraps +import inspect + + +class DummyCode: + + pass + + +# from https://github.com/tantale/deprecated/blob/master/deprecated/__init__.py +# with an enhancement to update docstrings of deprecated functions +string_types = (type(b''), type(u'')) +def deprecated(reason): + + if isinstance(reason, string_types): + + def decorator(func1): + + if inspect.isclass(func1): + fmt1 = "Call to deprecated class {name} ({reason})." + else: + fmt1 = "Call to deprecated function {name} ({reason})." + + @wraps(func1) + def new_func1(*args, **kwargs): + #warnings.simplefilter('default', DeprecationWarning) + warnings.warn( + fmt1.format(name=func1.__name__, reason=reason), + category=DeprecationWarning, + stacklevel=2 + ) + return func1(*args, **kwargs) + + # Enhance docstring with a deprecation note + deprecationNote = "\n\n.. note::\n Deprecated: " + reason + if new_func1.__doc__: + new_func1.__doc__ += deprecationNote + else: + new_func1.__doc__ = deprecationNote + return new_func1 + + return decorator + + elif inspect.isclass(reason) or inspect.isfunction(reason): + raise TypeError("Reason for deprecation must be supplied") + + else: + raise TypeError(repr(type(reason))) diff --git a/.venv/lib/python3.12/site-packages/openpyxl/compat/abc.py b/.venv/lib/python3.12/site-packages/openpyxl/compat/abc.py new file mode 100644 index 00000000..36a47f3f --- /dev/null +++ b/.venv/lib/python3.12/site-packages/openpyxl/compat/abc.py @@ -0,0 +1,8 @@ +# Copyright (c) 2010-2024 openpyxl + + +try: + from abc import ABC +except ImportError: + from abc import ABCMeta + ABC = ABCMeta('ABC', (object, ), {}) diff --git a/.venv/lib/python3.12/site-packages/openpyxl/compat/numbers.py b/.venv/lib/python3.12/site-packages/openpyxl/compat/numbers.py new file mode 100644 index 00000000..7d583451 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/openpyxl/compat/numbers.py @@ -0,0 +1,43 @@ +# Copyright (c) 2010-2024 openpyxl + +from decimal import Decimal + +NUMERIC_TYPES = (int, float, Decimal) + + +try: + import numpy + NUMPY = True +except ImportError: + NUMPY = False + + +if NUMPY: + NUMERIC_TYPES = NUMERIC_TYPES + (numpy.short, + numpy.ushort, + numpy.intc, + numpy.uintc, + numpy.int_, + numpy.uint, + numpy.longlong, + numpy.ulonglong, + numpy.half, + numpy.float16, + numpy.single, + numpy.double, + numpy.longdouble, + numpy.int8, + numpy.int16, + numpy.int32, + numpy.int64, + numpy.uint8, + numpy.uint16, + numpy.uint32, + numpy.uint64, + numpy.intp, + numpy.uintp, + numpy.float32, + numpy.float64, + numpy.bool_, + numpy.floating, + numpy.integer) diff --git a/.venv/lib/python3.12/site-packages/openpyxl/compat/product.py b/.venv/lib/python3.12/site-packages/openpyxl/compat/product.py new file mode 100644 index 00000000..68fdae9f --- /dev/null +++ b/.venv/lib/python3.12/site-packages/openpyxl/compat/product.py @@ -0,0 +1,17 @@ +# Copyright (c) 2010-2024 openpyxl + +""" +math.prod equivalent for < Python 3.8 +""" + +import functools +import operator + +def product(sequence): + return functools.reduce(operator.mul, sequence) + + +try: + from math import prod +except ImportError: + prod = product diff --git a/.venv/lib/python3.12/site-packages/openpyxl/compat/singleton.py b/.venv/lib/python3.12/site-packages/openpyxl/compat/singleton.py new file mode 100644 index 00000000..1fe6a908 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/openpyxl/compat/singleton.py @@ -0,0 +1,40 @@ +# Copyright (c) 2010-2024 openpyxl + +import weakref + + +class Singleton(type): + """ + Singleton metaclass + Based on Python Cookbook 3rd Edition Recipe 9.13 + Only one instance of a class can exist. Does not work with __slots__ + """ + + def __init__(self, *args, **kw): + super().__init__(*args, **kw) + self.__instance = None + + def __call__(self, *args, **kw): + if self.__instance is None: + self.__instance = super().__call__(*args, **kw) + return self.__instance + + +class Cached(type): + """ + Caching metaclass + Child classes will only create new instances of themselves if + one doesn't already exist. Does not work with __slots__ + """ + + def __init__(self, *args, **kw): + super().__init__(*args, **kw) + self.__cache = weakref.WeakValueDictionary() + + def __call__(self, *args): + if args in self.__cache: + return self.__cache[args] + + obj = super().__call__(*args) + self.__cache[args] = obj + return obj diff --git a/.venv/lib/python3.12/site-packages/openpyxl/compat/strings.py b/.venv/lib/python3.12/site-packages/openpyxl/compat/strings.py new file mode 100644 index 00000000..2cc9d60e --- /dev/null +++ b/.venv/lib/python3.12/site-packages/openpyxl/compat/strings.py @@ -0,0 +1,25 @@ +# Copyright (c) 2010-2024 openpyxl + +from datetime import datetime +from math import isnan, isinf +import sys + +VER = sys.version_info + +from .numbers import NUMERIC_TYPES + + +def safe_string(value): + """Safely and consistently format numeric values""" + if isinstance(value, NUMERIC_TYPES): + if isnan(value) or isinf(value): + value = "" + else: + value = "%.16g" % value + elif value is None: + value = "none" + elif isinstance(value, datetime): + value = value.isoformat() + elif not isinstance(value, str): + value = str(value) + return value |