A Sharepoint site List :param parent: parent object :type parent: Sharepoint :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
(self, *, parent=None, con=None, **kwargs)
| 409 | list_constructor = SharepointList |
| 410 | |
| 411 | def __init__(self, *, parent=None, con=None, **kwargs): |
| 412 | """ A Sharepoint site List |
| 413 | |
| 414 | :param parent: parent object |
| 415 | :type parent: Sharepoint |
| 416 | :param Connection con: connection to use if no parent specified |
| 417 | :param Protocol protocol: protocol to use if no parent specified |
| 418 | (kwargs) |
| 419 | :param str main_resource: use this resource instead of parent resource |
| 420 | (kwargs) |
| 421 | """ |
| 422 | if parent and con: |
| 423 | raise ValueError('Need a parent or a connection but not both') |
| 424 | self.con = parent.con if parent else con |
| 425 | |
| 426 | cloud_data = kwargs.get(self._cloud_data_key, {}) |
| 427 | |
| 428 | self.object_id = cloud_data.get('id') |
| 429 | |
| 430 | # Choose the main_resource passed in kwargs over parent main_resource |
| 431 | main_resource = kwargs.pop('main_resource', None) or ( |
| 432 | getattr(parent, 'main_resource', None) if parent else None) |
| 433 | |
| 434 | # prefix with the current known site |
| 435 | resource_prefix = 'sites/{site_id}'.format(site_id=self.object_id) |
| 436 | main_resource = (resource_prefix if isinstance(parent, Site) |
| 437 | else '{}{}'.format(main_resource, resource_prefix)) |
| 438 | |
| 439 | super().__init__( |
| 440 | protocol=parent.protocol if parent else kwargs.get('protocol'), |
| 441 | main_resource=main_resource) |
| 442 | |
| 443 | self.root = 'root' in cloud_data # True or False |
| 444 | # Fallback to manual site |
| 445 | self.name = cloud_data.get(self._cc('name'), kwargs.get('name', '')) |
| 446 | self.display_name = cloud_data.get(self._cc('displayName'), '') |
| 447 | if not self.name: |
| 448 | self.name = self.display_name |
| 449 | self.description = cloud_data.get(self._cc('description'), '') |
| 450 | self.web_url = cloud_data.get(self._cc('webUrl')) |
| 451 | |
| 452 | created = cloud_data.get(self._cc('createdDateTime'), None) |
| 453 | modified = cloud_data.get(self._cc('lastModifiedDateTime'), None) |
| 454 | local_tz = self.protocol.timezone |
| 455 | self.created = parse(created).astimezone(local_tz) if created else None |
| 456 | self.modified = parse(modified).astimezone( |
| 457 | local_tz) if modified else None |
| 458 | |
| 459 | # site storage to access Drives and DriveItems |
| 460 | self.site_storage = Storage(parent=self, |
| 461 | main_resource='/sites/{id}'.format( |
| 462 | id=self.object_id)) |
| 463 | |
| 464 | def __str__(self): |
| 465 | return self.__repr__() |