Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/openpyxl/styles/proxy.py: 47%
28 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1# Copyright (c) 2010-2022 openpyxl
3from copy import copy
5from openpyxl.compat import deprecated
8class StyleProxy(object):
9 """
10 Proxy formatting objects so that they cannot be altered
11 """
13 __slots__ = ('__target')
15 def __init__(self, target):
16 self.__target = target
19 def __repr__(self):
20 return repr(self.__target)
23 def __getattr__(self, attr):
24 return getattr(self.__target, attr)
27 def __setattr__(self, attr, value):
28 if attr != "_StyleProxy__target":
29 raise AttributeError("Style objects are immutable and cannot be changed."
30 "Reassign the style with a copy")
31 super(StyleProxy, self).__setattr__(attr, value)
34 def __copy__(self):
35 """
36 Return a copy of the proxied object.
37 """
38 return copy(self.__target)
41 def __add__(self, other):
42 """
43 Add proxied object to another instance and return the combined object
44 """
45 return self.__target + other
48 @deprecated("Use copy(obj) or cell.obj = cell.obj + other")
49 def copy(self, **kw):
50 """Return a copy of the proxied object. Keyword args will be passed through"""
51 cp = copy(self.__target)
52 for k, v in kw.items():
53 setattr(cp, k, v)
54 return cp
57 def __eq__(self, other):
58 return self.__target == other
61 def __ne__(self, other):
62 return not self == other