Updated script that can be controled by Nodejs web app
This commit is contained in:
54
lib/python3.13/site-packages/openpyxl/compat/__init__.py
Normal file
54
lib/python3.13/site-packages/openpyxl/compat/__init__.py
Normal file
@ -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)))
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
8
lib/python3.13/site-packages/openpyxl/compat/abc.py
Normal file
8
lib/python3.13/site-packages/openpyxl/compat/abc.py
Normal file
@ -0,0 +1,8 @@
|
||||
# Copyright (c) 2010-2024 openpyxl
|
||||
|
||||
|
||||
try:
|
||||
from abc import ABC
|
||||
except ImportError:
|
||||
from abc import ABCMeta
|
||||
ABC = ABCMeta('ABC', (object, ), {})
|
43
lib/python3.13/site-packages/openpyxl/compat/numbers.py
Normal file
43
lib/python3.13/site-packages/openpyxl/compat/numbers.py
Normal file
@ -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)
|
17
lib/python3.13/site-packages/openpyxl/compat/product.py
Normal file
17
lib/python3.13/site-packages/openpyxl/compat/product.py
Normal file
@ -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
|
40
lib/python3.13/site-packages/openpyxl/compat/singleton.py
Normal file
40
lib/python3.13/site-packages/openpyxl/compat/singleton.py
Normal file
@ -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
|
25
lib/python3.13/site-packages/openpyxl/compat/strings.py
Normal file
25
lib/python3.13/site-packages/openpyxl/compat/strings.py
Normal file
@ -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
|
Reference in New Issue
Block a user