MCPcopy Create free account
hub / github.com/O365/python-o365 / RangeFormatFont

Class RangeFormatFont

O365/excel.py:156–275  ·  view source on GitHub ↗

A font format applied to a range

Source from the content-addressed store, hash-verified

154
155
156class RangeFormatFont:
157 """ A font format applied to a range """
158
159 def __init__(self, parent):
160 self.parent = parent
161 self._track_changes = TrackerSet(casing=parent._cc)
162 self._loaded = False
163
164 self._bold = False
165 self._color = '#000000' # default black
166 self._italic = False
167 self._name = 'Calibri'
168 self._size = 10
169 self._underline = 'None'
170
171 def _load_data(self):
172 """ Loads the data into this instance """
173 url = self.parent.build_url(self.parent._endpoints.get('format'))
174 response = self.parent.session.get(url)
175 if not response:
176 return False
177 data = response.json()
178
179 self._bold = data.get('bold', False)
180 self._color = data.get('color', '#000000') # default black
181 self._italic = data.get('italic', False)
182 self._name = data.get('name', 'Calibri') # default Calibri
183 self._size = data.get('size', 10) # default 10
184 self._underline = data.get('underline', 'None')
185
186 self._loaded = True
187 return True
188
189 def to_api_data(self, restrict_keys=None):
190 """ Returns a dict to communicate with the server
191
192 :param restrict_keys: a set of keys to restrict the returned data to
193 :rtype: dict
194 """
195 cc = self.parent._cc # alias
196 data = {
197 cc('bold'): self._bold,
198 cc('color'): self._color,
199 cc('italic'): self._italic,
200 cc('name'): self._name,
201 cc('size'): self._size,
202 cc('underline'): self._underline
203 }
204
205 if restrict_keys:
206 for key in list(data.keys()):
207 if key not in restrict_keys:
208 del data[key]
209 return data
210
211 @property
212 def bold(self):
213 if not self._loaded:

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected