MCPcopy Index your code
hub / github.com/O365/python-o365 / __init__

Method __init__

O365/sharepoint.py:193–257  ·  view source on GitHub ↗

A Sharepoint site List :param parent: parent object :type parent: Site :param Connection con: connection to use if no parent specified :param Protocol protocol: protocol to use if no parent specified (kwargs) :param str main_resource: use this resou

(self, *, parent=None, con=None, **kwargs)

Source from the content-addressed store, hash-verified

191 list_column_constructor = SharepointListColumn
192
193 def __init__(self, *, parent=None, con=None, **kwargs):
194 """ A Sharepoint site List
195
196 :param parent: parent object
197 :type parent: Site
198 :param Connection con: connection to use if no parent specified
199 :param Protocol protocol: protocol to use if no parent specified
200 (kwargs)
201 :param str main_resource: use this resource instead of parent resource
202 (kwargs)
203 """
204 if parent and con:
205 raise ValueError('Need a parent or a connection but not both')
206 self.con = parent.con if parent else con
207
208 cloud_data = kwargs.get(self._cloud_data_key, {})
209
210 self.object_id = cloud_data.get('id')
211
212 # Choose the main_resource passed in kwargs over parent main_resource
213 main_resource = kwargs.pop('main_resource', None) or (
214 getattr(parent, 'main_resource', None) if parent else None)
215
216 # prefix with the current known list
217 resource_prefix = '/lists/{list_id}'.format(list_id=self.object_id)
218 main_resource = '{}{}'.format(main_resource, resource_prefix)
219
220 super().__init__(
221 protocol=parent.protocol if parent else kwargs.get('protocol'),
222 main_resource=main_resource)
223
224 self.name = cloud_data.get(self._cc('name'), '')
225 self.display_name = cloud_data.get(self._cc('displayName'), '')
226 if not self.name:
227 self.name = self.display_name
228 self.description = cloud_data.get(self._cc('description'), '')
229 self.web_url = cloud_data.get(self._cc('webUrl'))
230
231 created = cloud_data.get(self._cc('createdDateTime'), None)
232 modified = cloud_data.get(self._cc('lastModifiedDateTime'), None)
233 local_tz = self.protocol.timezone
234 self.created = parse(created).astimezone(local_tz) if created else None
235 self.modified = parse(modified).astimezone(
236 local_tz) if modified else None
237
238 created_by = cloud_data.get(self._cc('createdBy'), {}).get('user', None)
239 self.created_by = (Contact(con=self.con, protocol=self.protocol,
240 **{self._cloud_data_key: created_by})
241 if created_by else None)
242 modified_by = cloud_data.get(self._cc('lastModifiedBy'), {}).get('user',
243 None)
244 self.modified_by = (Contact(con=self.con, protocol=self.protocol,
245 **{self._cloud_data_key: modified_by})
246 if modified_by else None)
247
248 # list info
249 lst_info = cloud_data.get('list', {})
250 self.content_types_enabled = lst_info.get(

Callers

nothing calls this directly

Calls 5

get_list_columnsMethod · 0.95
ContactClass · 0.85
_ccMethod · 0.80
getMethod · 0.45
__init__Method · 0.45

Tested by

no test coverage detected