Updated script that can be controled by Nodejs web app

This commit is contained in:
mac OS
2024-11-25 12:24:18 +07:00
parent c440eda1f4
commit 8b0ab2bd3a
8662 changed files with 1803808 additions and 34 deletions

View 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)))

View 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, ), {})

View 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)

View 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

View 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

View 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