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

Method __init__

O365/drive.py:228–269  ·  view source on GitHub ↗

Version of DriveItem :param parent: parent for this operation :type parent: DriveItem :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:

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

Source from the content-addressed store, hash-verified

226 }
227
228 def __init__(self, *, parent=None, con=None, **kwargs):
229 """ Version of DriveItem
230
231 :param parent: parent for this operation
232 :type parent: DriveItem
233 :param Connection con: connection to use if no parent specified
234 :param Protocol protocol: protocol to use if no parent specified
235 (kwargs)
236 :param str main_resource: use this resource instead of parent resource
237 (kwargs)
238 """
239 if parent and con:
240 raise ValueError('Need a parent or a connection but not both')
241 self.con = parent.con if parent else con
242 self._parent = parent if isinstance(parent, DriveItem) else None
243
244 protocol = parent.protocol if parent else kwargs.get('protocol')
245 # Choose the main_resource passed in kwargs over parent main_resource
246 main_resource = kwargs.pop('main_resource', None) or (
247 getattr(parent, 'main_resource', None) if parent else None)
248
249 resource_prefix = '/items/{item_id}'.format(
250 item_id=self._parent.object_id)
251 main_resource = '{}{}'.format(
252 main_resource or (protocol.default_resource if protocol else ''),
253 resource_prefix)
254 super().__init__(protocol=protocol, main_resource=main_resource)
255
256 cloud_data = kwargs.get(self._cloud_data_key, {})
257
258 self.driveitem_id = self._parent.object_id
259 self.object_id = cloud_data.get('id', '1.0')
260 self.name = self.object_id
261 modified = cloud_data.get(self._cc('lastModifiedDateTime'), None)
262 local_tz = self.protocol.timezone
263 self.modified = parse(modified).astimezone(
264 local_tz) if modified else None
265 self.size = cloud_data.get('size', 0)
266 modified_by = cloud_data.get(self._cc('lastModifiedBy'), {}).get('user',
267 None)
268 self.modified_by = Contact(con=self.con, protocol=self.protocol, **{
269 self._cloud_data_key: modified_by}) if modified_by else None
270
271 def __str__(self):
272 return self.__repr__()

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected