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

Method __init__

O365/sharepoint.py:75–120  ·  view source on GitHub ↗

A Sharepoint ListItem within a SharepointList :param parent: parent object :type parent: SharepointList :param Connection con: connection to use if no parent specified :param Protocol protocol: protocol to use if no parent specified (kwargs) :param

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

Source from the content-addressed store, hash-verified

73 'delete_list_item': '/items/{item_id}'}
74
75 def __init__(self, *, parent=None, con=None, **kwargs):
76 """ A Sharepoint ListItem within a SharepointList
77
78 :param parent: parent object
79 :type parent: SharepointList
80 :param Connection con: connection to use if no parent specified
81 :param Protocol protocol: protocol to use if no parent specified
82 (kwargs)
83 :param str main_resource: use this resource instead of parent resource
84 (kwargs)
85 """
86 if parent and con:
87 raise ValueError('Need a parent or a connection but not both')
88 self.con = parent.con if parent else con
89 self._parent = parent
90
91 # Choose the main_resource passed in kwargs over parent main_resource
92 main_resource = kwargs.pop('main_resource', None) or (
93 getattr(parent, 'main_resource', None) if parent else None)
94
95 super().__init__(
96 protocol=parent.protocol if parent else kwargs.get('protocol'),
97 main_resource=main_resource)
98
99 cloud_data = kwargs.get(self._cloud_data_key, {})
100
101 self._track_changes = TrackerSet(casing=self._cc)
102 self.object_id = cloud_data.get('id')
103 created = cloud_data.get(self._cc('createdDateTime'), None)
104 modified = cloud_data.get(self._cc('lastModifiedDateTime'), None)
105 local_tz = self.protocol.timezone
106 self.created = parse(created).astimezone(local_tz) if created else None
107 self.modified = parse(modified).astimezone(local_tz) if modified else None
108
109 created_by = cloud_data.get(self._cc('createdBy'), {}).get('user', None)
110 self.created_by = Contact(con=self.con, protocol=self.protocol,
111 **{self._cloud_data_key: created_by}) if created_by else None
112 modified_by = cloud_data.get(self._cc('lastModifiedBy'), {}).get('user', None)
113 self.modified_by = Contact(con=self.con, protocol=self.protocol,
114 **{self._cloud_data_key: modified_by}) if modified_by else None
115
116 self.web_url = cloud_data.get(self._cc('webUrl'), None)
117
118 self.content_type_id = cloud_data.get(self._cc('contentType'), {}).get('id', None)
119
120 self.fields = cloud_data.get(self._cc('fields'), None)
121
122 def __repr__(self):
123 return 'List Item: {}'.format(self.web_url)

Callers

nothing calls this directly

Calls 5

TrackerSetClass · 0.85
ContactClass · 0.85
_ccMethod · 0.80
__init__Method · 0.45
getMethod · 0.45

Tested by

no test coverage detected