INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Deletes a Column by its id or name :param id_or_name: the id or name of the column :return bool: Success or Failure
def delete_column(self, id_or_name): """ Deletes a Column by its id or name :param id_or_name: the id or name of the column :return bool: Success or Failure """ url = self.build_url(self._endpoints.get('delete_column').format(id=quote(id_or_name))) return bool(sel...
Adds a column to the table :param str name: the name of the column :param int index: the index at which the column should be added. Defaults to 0. :param list values: a two dimension array of values to add to the column
def add_column(self, name, *, index=0, values=None): """ Adds a column to the table :param str name: the name of the column :param int index: the index at which the column should be added. Defaults to 0. :param list values: a two dimension array of values to add to the column ...
Return the rows of this table :param int top: specify n rows to retrieve :param int skip: specify n rows to skip :rtype: TableRow
def get_rows(self, *, top=None, skip=None): """ Return the rows of this table :param int top: specify n rows to retrieve :param int skip: specify n rows to skip :rtype: TableRow """ url = self.build_url(self._endpoints.get('get_rows')) params = {} ...
Returns a Row instance at an index
def get_row(self, index): """ Returns a Row instance at an index """ url = self.build_url(self._endpoints.get('get_row').format(id=index)) response = self.session.get(url) if not response: return None return self.row_constructor(parent=self, **{self._cloud_data_key: r...
Returns a table row by it's index :param int index: the zero-indexed position of the row in the table
def get_row_at_index(self, index): """ Returns a table row by it's index :param int index: the zero-indexed position of the row in the table """ if index is None: return None url = self.build_url(self._endpoints.get('get_row_index')) response = self.s...
Deletes a Row by it's index :param int index: the index of the row. zero indexed :return bool: Success or Failure
def delete_row(self, index): """ Deletes a Row by it's index :param int index: the index of the row. zero indexed :return bool: Success or Failure """ url = self.build_url(self._endpoints.get('delete_row').format(id=index)) return bool(self.session.post(url))
Add rows to this table. Multiple rows can be added at once. This request might occasionally receive a 504 HTTP error. The appropriate response to this error is to repeat the request. :param list values: Optional. a 1 or 2 dimensional array of values to add :param int index: Opt...
def add_rows(self, values=None, index=None): """ Add rows to this table. Multiple rows can be added at once. This request might occasionally receive a 504 HTTP error. The appropriate response to this error is to repeat the request. :param list values: Optional. a 1 or 2...
Updates this table :param str name: the name of the table :param bool show_headers: whether or not to show the headers :param bool show_totals: whether or not to show the totals :param str style: the style of the table :return: Success or Failure
def update(self, *, name=None, show_headers=None, show_totals=None, style=None): """ Updates this table :param str name: the name of the table :param bool show_headers: whether or not to show the headers :param bool show_totals: whether or not to show the totals :param st...
Returns a Range based on the endpoint name
def _get_range(self, endpoint_name): """ Returns a Range based on the endpoint name """ url = self.build_url(self._endpoints.get(endpoint_name)) response = self.session.get(url) if not response: return None data = response.json() return self.range_constructor...
Returns this table worksheet
def get_worksheet(self): """ Returns this table worksheet """ url = self.build_url('') q = self.q().select('name').expand('worksheet') response = self.session.get(url, params=q.as_params()) if not response: return None data = response.json() ws = data...
Changes the name, position or visibility of this worksheet
def update(self, *, name=None, position=None, visibility=None): """ Changes the name, position or visibility of this worksheet """ if name is None and position is None and visibility is None: raise ValueError('Provide at least one parameter to update') data = {} if name: ...
Returns a collection of this worksheet tables
def get_tables(self): """ Returns a collection of this worksheet tables""" url = self.build_url(self._endpoints.get('get_tables')) response = self.session.get(url) if not response: return [] data = response.json() return [self.table_constructor(parent=self...
Retrieves a Table by id or name :param str id_or_name: The id or name of the column :return: a Table instance
def get_table(self, id_or_name): """ Retrieves a Table by id or name :param str id_or_name: The id or name of the column :return: a Table instance """ url = self.build_url(self._endpoints.get('get_table').format(id=id_or_name)) response = self.session.get(url) ...
Adds a table to this worksheet :param str address: a range address eg: 'A1:D4' :param bool has_headers: if the range address includes headers or not :return: a Table instance
def add_table(self, address, has_headers): """ Adds a table to this worksheet :param str address: a range address eg: 'A1:D4' :param bool has_headers: if the range address includes headers or not :return: a Table instance """ if address is None: return...
Returns a Range instance from whitin this worksheet :param str address: Optional, the range address you want :return: a Range instance
def get_range(self, address=None): """ Returns a Range instance from whitin this worksheet :param str address: Optional, the range address you want :return: a Range instance """ url = self.build_url(self._endpoints.get('get_range')) if address is not None: ...
Gets the range object containing the single cell based on row and column numbers.
def get_cell(self, row, column): """ Gets the range object containing the single cell based on row and column numbers. """ url = self.build_url(self._endpoints.get('get_cell').format(row=row, column=column)) response = self.session.get(url) if not response: return None ...
Adds a new name to the collection of the given scope using the user's locale for the formula :param str name: the name of this range :param str reference: the reference for this range or formula :param str comment: a comment to describe this named range :param bool is_formula: True if th...
def add_named_range(self, name, reference, comment='', is_formula=False): """ Adds a new name to the collection of the given scope using the user's locale for the formula :param str name: the name of this range :param str reference: the reference for this range or formula :param ...
Retrieves a Named range by it's name
def get_named_range(self, name): """ Retrieves a Named range by it's name """ url = self.build_url(self._endpoints.get('get_named_range').format(name=name)) response = self.session.get(url) if not response: return None return self.named_range_constructor(parent=self, ...
Returns a collection of this workbook worksheets
def get_worksheets(self): """ Returns a collection of this workbook worksheets""" url = self.build_url(self._endpoints.get('get_worksheets')) response = self.session.get(url) if not response: return [] data = response.json() return [self.worksheet_construc...
Gets a specific worksheet by id or name
def get_worksheet(self, id_or_name): """ Gets a specific worksheet by id or name """ url = self.build_url(self._endpoints.get('get_worksheet').format(id=quote(id_or_name))) response = self.session.get(url) if not response: return None return self.worksheet_constructor...
Adds a new worksheet
def add_worksheet(self, name=None): """ Adds a new worksheet """ url = self.build_url(self._endpoints.get('get_worksheets')) response = self.session.post(url, data={'name': name} if name else None) if not response: return None data = response.json() return sel...
Deletes a worksheet by it's id
def delete_worksheet(self, worksheet_id): """ Deletes a worksheet by it's id """ url = self.build_url(self._endpoints.get('get_worksheet').format(id=quote(worksheet_id))) return bool(self.session.delete(url))
Invokes an Excel Function
def invoke_function(self, function_name, **function_params): """ Invokes an Excel Function """ url = self.build_url(self._endpoints.get('function').format(function_name)) response = self.session.post(url, data=function_params) if not response: return None data = respo...
Returns the list of named ranges for this Workbook
def get_named_ranges(self): """ Returns the list of named ranges for this Workbook """ url = self.build_url(self._endpoints.get('get_names')) response = self.session.get(url) if not response: return [] data = response.json() return [self.named_range_construct...
Returns a dict to communicate with the server :rtype: dict
def to_api_data(self): """ Returns a dict to communicate with the server :rtype: dict """ data = {} # recurrence pattern if self.__interval and isinstance(self.__interval, int): recurrence_pattern = data[self._cc('pattern')] = {} recurrence_patter...
Clears this event recurrence
def _clear_pattern(self): """ Clears this event recurrence """ # pattern group self.__interval = None self.__days_of_week = set() self.__first_day_of_week = None self.__day_of_month = None self.__month = None self.__index = 'first' # range group ...
Set the range of recurrence :param date start: Start date of repetition :param date end: End date of repetition :param int occurrences: no of occurrences
def set_range(self, start=None, end=None, occurrences=None): """ Set the range of recurrence :param date start: Start date of repetition :param date end: End date of repetition :param int occurrences: no of occurrences """ if start is None: if self.__start_da...
Set to repeat every x no. of days :param int interval: no. of days to repeat at :keyword date start: Start date of repetition (kwargs) :keyword date end: End date of repetition (kwargs) :keyword int occurrences: no of occurrences (kwargs)
def set_daily(self, interval, **kwargs): """ Set to repeat every x no. of days :param int interval: no. of days to repeat at :keyword date start: Start date of repetition (kwargs) :keyword date end: End date of repetition (kwargs) :keyword int occurrences: no of occurrences (kwa...
Set to repeat every week on specified days for every x no. of days :param int interval: no. of days to repeat at :param str first_day_of_week: starting day for a week :param list[str] days_of_week: list of days of the week to repeat :keyword date start: Start date of repetition (kwargs)...
def set_weekly(self, interval, *, days_of_week, first_day_of_week, **kwargs): """ Set to repeat every week on specified days for every x no. of days :param int interval: no. of days to repeat at :param str first_day_of_week: starting day for a week :param list[str] da...
Set to repeat every month on specified days for every x no. of days :param int interval: no. of days to repeat at :param int day_of_month: repeat day of a month :param list[str] days_of_week: list of days of the week to repeat :param index: index :keyword date start: Start date ...
def set_monthly(self, interval, *, day_of_month=None, days_of_week=None, index=None, **kwargs): """ Set to repeat every month on specified days for every x no. of days :param int interval: no. of days to repeat at :param int day_of_month: repeat day of a month :param...
Set to repeat every month on specified days for every x no. of days :param int interval: no. of days to repeat at :param int month: month to repeat :param int day_of_month: repeat day of a month :param list[str] days_of_week: list of days of the week to repeat :param index: inde...
def set_yearly(self, interval, month, *, day_of_month=None, days_of_week=None, index=None, **kwargs): """ Set to repeat every month on specified days for every x no. of days :param int interval: no. of days to repeat at :param int month: month to repeat :param int day...
Add attendees to the parent event :param attendees: list of attendees to add :type attendees: str or tuple(str, str) or Attendee or list[str] or list[tuple(str,str)] or list[Attendee]
def add(self, attendees): """ Add attendees to the parent event :param attendees: list of attendees to add :type attendees: str or tuple(str, str) or Attendee or list[str] or list[tuple(str,str)] or list[Attendee] """ if attendees: if isinstance(attendees, s...
Remove the provided attendees from the event :param attendees: list of attendees to add :type attendees: str or tuple(str, str) or Attendee or list[str] or list[tuple(str,str)] or list[Attendee]
def remove(self, attendees): """ Remove the provided attendees from the event :param attendees: list of attendees to add :type attendees: str or tuple(str, str) or Attendee or list[str] or list[tuple(str,str)] or list[Attendee] """ if isinstance(attendees, (list, tuple)...
Returns a dict to communicate with the server :rtype: dict
def to_api_data(self): """ Returns a dict to communicate with the server :rtype: dict """ data = [] for attendee in self.__attendees: if attendee.address: att_data = { self._cc('emailAddress'): { self._cc('a...
Returns a dict to communicate with the server :param restrict_keys: a set of keys to restrict the returned data to :rtype: dict
def to_api_data(self, restrict_keys=None): """ Returns a dict to communicate with the server :param restrict_keys: a set of keys to restrict the returned data to :rtype: dict """ cc = self._cc # alias data = { cc('subject'): self.__subject, cc('b...
Returns all the occurrences of a seriesMaster event for a specified time range. :type start: datetime :param start: the start of the time range :type end: datetime :param end: the end of the time range :param int limit: ax no. of events to get. Over 999 uses batch. :type ...
def get_occurrences(self, start, end, *, limit=None, query=None, order_by=None, batch=None): """ Returns all the occurrences of a seriesMaster event for a specified time range. :type start: datetime :param start: the start of the time range :type end: datetime :param end:...
Create a new event or update an existing one by checking what values have changed and update them on the server :return: Success / Failure :rtype: bool
def save(self): """ Create a new event or update an existing one by checking what values have changed and update them on the server :return: Success / Failure :rtype: bool """ if self.object_id: # update event if not self._track_changes: ...
Decline the event :param str comment: comment to add :param bool send_response: whether or not to send response back :return: Success / Failure :rtype: bool
def decline_event(self, comment=None, *, send_response=True): """ Decline the event :param str comment: comment to add :param bool send_response: whether or not to send response back :return: Success / Failure :rtype: bool """ if not self.object_id: r...
Parse the body html and returns the body text using bs4 :return: body text :rtype: str
def get_body_text(self): """ Parse the body html and returns the body text using bs4 :return: body text :rtype: str """ if self.body_type != 'HTML': return self.body try: soup = bs(self.body, 'html.parser') except RuntimeError: ...
Updates this calendar. Only name and color can be changed. :return: Success / Failure :rtype: bool
def update(self): """ Updates this calendar. Only name and color can be changed. :return: Success / Failure :rtype: bool """ if not self.calendar_id: return False url = self.build_url(self._endpoints.get('calendar')) data = { self._cc('...
Get events from the this Calendar :param int limit: max no. of events to get. Over 999 uses batch. :param query: applies a OData filter to the request :type query: Query or str :param order_by: orders the result set based on this condition :type order_by: Query or str :p...
def get_events(self, limit=25, *, query=None, order_by=None, batch=None, download_attachments=False, include_recurring=True): """ Get events from the this Calendar :param int limit: max no. of events to get. Over 999 uses batch. :param query: applies a OData filter to the req...
Returns a new (unsaved) Event object :rtype: Event
def new_event(self, subject=None): """ Returns a new (unsaved) Event object :rtype: Event """ return self.event_constructor(parent=self, subject=subject, calendar_id=self.calendar_id)
Returns an Event instance by it's id :param param: an event_id or a Query instance :return: event for the specified info :rtype: Event
def get_event(self, param): """ Returns an Event instance by it's id :param param: an event_id or a Query instance :return: event for the specified info :rtype: Event """ if param is None: return None if isinstance(param, str): url = self...
Creates a new calendar :param str calendar_name: name of the new calendar :return: a new Calendar instance :rtype: Calendar
def new_calendar(self, calendar_name): """ Creates a new calendar :param str calendar_name: name of the new calendar :return: a new Calendar instance :rtype: Calendar """ if not calendar_name: return None url = self.build_url(self._endpoints.get('roo...
Returns a calendar by it's id or name :param str calendar_id: the calendar id to be retrieved. :param str calendar_name: the calendar name to be retrieved. :return: calendar for the given info :rtype: Calendar
def get_calendar(self, calendar_id=None, calendar_name=None): """ Returns a calendar by it's id or name :param str calendar_id: the calendar id to be retrieved. :param str calendar_name: the calendar name to be retrieved. :return: calendar for the given info :rtype: Calendar ...
Returns the default calendar for the current user :rtype: Calendar
def get_default_calendar(self): """ Returns the default calendar for the current user :rtype: Calendar """ url = self.build_url(self._endpoints.get('default_calendar')) response = self.con.get(url) if not response: return None data = response.json(...
Get events from the default Calendar :param int limit: max no. of events to get. Over 999 uses batch. :param query: applies a OData filter to the request :type query: Query or str :param order_by: orders the result set based on this condition :type order_by: Query or str ...
def get_events(self, limit=25, *, query=None, order_by=None, batch=None, download_attachments=False, include_recurring=True): """ Get events from the default Calendar :param int limit: max no. of events to get. Over 999 uses batch. :param query: applies a OData filter to the ...
Returns the expiration datetime :return datetime: The datetime this token expires
def expiration_datetime(self): """ Returns the expiration datetime :return datetime: The datetime this token expires """ expires_at = self.get('expires_at') if expires_at is None: # consider it is expired return dt.datetime.now() - dt.timedelta(sec...
Setter to convert any token dict into Token instance
def token(self, value): """ Setter to convert any token dict into Token instance """ if value and not isinstance(value, Token): value = Token(value) self._token = value
Retrieves the token from the File System :return dict or None: The token if exists, None otherwise
def get_token(self): """ Retrieves the token from the File System :return dict or None: The token if exists, None otherwise """ token = None if self.token_path.exists(): with self.token_path.open('r') as token_file: token = self.token_construct...
Saves the token dict in the specified file :return bool: Success / Failure
def save_token(self): """ Saves the token dict in the specified file :return bool: Success / Failure """ if self.token is None: raise ValueError('You have to set the "token" first.') try: if not self.token_path.parent.exists(): sel...
Deletes the token file :return bool: Success / Failure
def delete_token(self): """ Deletes the token file :return bool: Success / Failure """ if self.token_path.exists(): self.token_path.unlink() return True return False
Retrieves the token from the store :return dict or None: The token if exists, None otherwise
def get_token(self): """ Retrieves the token from the store :return dict or None: The token if exists, None otherwise """ token = None try: doc = self.doc_ref.get() except Exception as e: log.error('Token (collection: {}, doc_id: {}) ' ...
Saves the token dict in the store :return bool: Success / Failure
def save_token(self): """ Saves the token dict in the store :return bool: Success / Failure """ if self.token is None: raise ValueError('You have to set the "token" first.') try: # set token will overwrite previous data self.doc_ref.se...
Deletes the token from the store :return bool: Success / Failure
def delete_token(self): """ Deletes the token from the store :return bool: Success / Failure """ try: self.doc_ref.delete() except Exception as e: log.error('Could not delete the token (key: {}): {}'.format(self.doc_id, str(e))) return ...
Checks if the token exists :return bool: True if it exists on the store
def check_token(self): """ Checks if the token exists :return bool: True if it exists on the store """ try: doc = self.doc_ref.get() except Exception as e: log.error('Token (collection: {}, doc_id: {}) ' 'could not be retrieve...
Checks whether the library has the authentication and that is not expired :return: True if authenticated, False otherwise
def is_authenticated(self): """ Checks whether the library has the authentication and that is not expired :return: True if authenticated, False otherwise """ token = self.con.token_backend.token if not token: token = self.con.token_backend.get_token() ...
Performs the oauth authentication flow resulting in a stored token It uses the credentials passed on instantiation :param list[str] scopes: list of protocol user scopes to be converted by the protocol or scope helpers :param kwargs: other configurations to be passed to the Con...
def authenticate(self, *, scopes, **kwargs): """ Performs the oauth authentication flow resulting in a stored token It uses the credentials passed on instantiation :param list[str] scopes: list of protocol user scopes to be converted by the protocol or scope helpers :param kwar...
Creates a new message to be sent or stored :param str resource: Custom resource to be used in this message (Defaults to parent main_resource) :return: New empty message :rtype: Message
def new_message(self, resource=None): """ Creates a new message to be sent or stored :param str resource: Custom resource to be used in this message (Defaults to parent main_resource) :return: New empty message :rtype: Message """ return Message(parent=self, mai...
Get an instance to the specified address book for the specified account resource :param str resource: Custom resource to be used in this address book (Defaults to parent main_resource) :param str address_book: Choose from 'Personal' or 'GAL' (Global Address List) :retu...
def address_book(self, *, resource=None, address_book='personal'): """ Get an instance to the specified address book for the specified account resource :param str resource: Custom resource to be used in this address book (Defaults to parent main_resource) :param str address_boo...
Get an instance to handle file storage (OneDrive / Sharepoint) for the specified account resource :param str resource: Custom resource to be used in this drive object (Defaults to parent main_resource) :return: a representation of OneDrive File Storage :rtype: Storage :...
def storage(self, *, resource=None): """ Get an instance to handle file storage (OneDrive / Sharepoint) for the specified account resource :param str resource: Custom resource to be used in this drive object (Defaults to parent main_resource) :return: a representation of OneDri...
Get an instance to read information from Microsoft planner
def planner(self, *, resource=''): """ Get an instance to read information from Microsoft planner """ if not isinstance(self.protocol, MSGraphProtocol): # TODO: Custom protocol accessing OneDrive/Sharepoint Api fails here raise RuntimeError( 'planner api only wor...
Get an instance to read information from Sharepoint sites for the specified account resource :param str resource: Custom resource to be used in this sharepoint object (Defaults to parent main_resource) :return: a representation of Sharepoint Sites :rtype: Sharepoint :ra...
def sharepoint(self, *, resource=''): """ Get an instance to read information from Sharepoint sites for the specified account resource :param str resource: Custom resource to be used in this sharepoint object (Defaults to parent main_resource) :return: a representation of Share...
Downloads this file to the local drive. Can download the file in chunks with multiple requests to the server. :param to_path: a path to store the downloaded file :type to_path: str or Path :param str name: the name you want the stored file to have. :param int chunk_size: number ...
def download(self, to_path=None, name=None, chunk_size='auto', convert_to_pdf=False): """ Downloads this file to the local drive. Can download the file in chunks with multiple requests to the server. :param to_path: a path to store the downloaded file :type to_path: str...
Checks the api endpoint to check if the async job progress
def _request_status(self): """ Checks the api endpoint to check if the async job progress """ if self.item_id: return True response = self.con.get(self.monitor_url) if not response: return False data = response.json() self.status = data.get('sta...
Checks the api endpoint in a loop :param delay: number of seconds to wait between api calls. Note Connection 'requests_delay' also apply. :return: tuple of status and percentage complete :rtype: tuple(str, float)
def check_status(self, delay=0): """ Checks the api endpoint in a loop :param delay: number of seconds to wait between api calls. Note Connection 'requests_delay' also apply. :return: tuple of status and percentage complete :rtype: tuple(str, float) """ if not s...
Restores this DriveItem Version. You can not restore the current version (last one). :return: Success / Failure :rtype: bool
def restore(self): """ Restores this DriveItem Version. You can not restore the current version (last one). :return: Success / Failure :rtype: bool """ url = self.build_url( self._endpoints.get('restore').format(id=self.object_id)) response = self.co...
Downloads this version. You can not download the current version (last one). :return: Success / Failure :rtype: bool
def download(self, to_path=None, name=None, chunk_size='auto', convert_to_pdf=False): """ Downloads this version. You can not download the current version (last one). :return: Success / Failure :rtype: bool """ return super().download(to_path=to_path, na...
Updates the roles of this permission :return: Success / Failure :rtype: bool
def update_roles(self, roles='view'): """ Updates the roles of this permission :return: Success / Failure :rtype: bool """ if not self.object_id: return False url = self.build_url(self._endpoints.get('permission').format( driveitem_id=self.drivei...
the parent of this DriveItem :return: Parent of this item :rtype: Drive or drive.Folder
def get_parent(self): """ the parent of this DriveItem :return: Parent of this item :rtype: Drive or drive.Folder """ if self._parent and self._parent.object_id == self.parent_id: return self._parent else: if self.parent_id: return...
Returns this Item Thumbnails. Thumbnails are not supported on SharePoint Server 2016. :param size: request only the specified size: ej: "small", Custom 300x400 px: "c300x400", Crop: "c300x400_Crop" :return: Thumbnail Data :rtype: dict
def get_thumbnails(self, size=None): """ Returns this Item Thumbnails. Thumbnails are not supported on SharePoint Server 2016. :param size: request only the specified size: ej: "small", Custom 300x400 px: "c300x400", Crop: "c300x400_Crop" :return: Thumbnail Data :rtype:...
Updates this item :param kwargs: all the properties to be updated. only name and description are allowed at the moment. :return: Success / Failure :rtype: bool
def update(self, **kwargs): """ Updates this item :param kwargs: all the properties to be updated. only name and description are allowed at the moment. :return: Success / Failure :rtype: bool """ if not self.object_id: return False url = sel...
Moves this item to the Recycle Bin :return: Success / Failure :rtype: bool
def delete(self): """ Moves this item to the Recycle Bin :return: Success / Failure :rtype: bool """ if not self.object_id: return False url = self.build_url( self._endpoints.get('item').format(id=self.object_id)) response = self.con.de...
Moves this DriveItem to another Folder. Can't move between different Drives. :param target: a Folder, Drive item or Item Id string. If it's a drive the item will be moved to the root folder. :type target: drive.Folder or DriveItem or str :return: Success / Failure :rtyp...
def move(self, target): """ Moves this DriveItem to another Folder. Can't move between different Drives. :param target: a Folder, Drive item or Item Id string. If it's a drive the item will be moved to the root folder. :type target: drive.Folder or DriveItem or str :ret...
Asynchronously creates a copy of this DriveItem and all it's child elements. :param target: target location to move to. If it's a drive the item will be moved to the root folder. :type target: drive.Folder or Drive :param name: a new name for the copy. :rtype: CopyOpera...
def copy(self, target=None, name=None): """ Asynchronously creates a copy of this DriveItem and all it's child elements. :param target: target location to move to. If it's a drive the item will be moved to the root folder. :type target: drive.Folder or Drive :param name...
Returns a list of available versions for this item :return: list of versions :rtype: list[DriveItemVersion]
def get_versions(self): """ Returns a list of available versions for this item :return: list of versions :rtype: list[DriveItemVersion] """ if not self.object_id: return [] url = self.build_url( self._endpoints.get('versions').format(id=self.obje...
Returns a version for specified id :return: a version object of specified id :rtype: DriveItemVersion
def get_version(self, version_id): """ Returns a version for specified id :return: a version object of specified id :rtype: DriveItemVersion """ if not self.object_id: return None url = self.build_url( self._endpoints.get('version').format(id=sel...
Creates or returns a link you can share with others :param str share_type: 'view' to allow only view access, 'edit' to allow editions, and 'embed' to allow the DriveItem to be embedded :param str share_scope: 'anonymous': anyone with the link can access. 'organization' Only o...
def share_with_link(self, share_type='view', share_scope='anonymous'): """ Creates or returns a link you can share with others :param str share_type: 'view' to allow only view access, 'edit' to allow editions, and 'embed' to allow the DriveItem to be embedded :param str share_...
Sends an invitation to access or edit this DriveItem :param recipients: a string or Contact or a list of the former representing recipients of this invitation :type recipients: list[str] or list[Contact] or str or Contact :param bool require_sign_in: if True the recipients inv...
def share_with_invite(self, recipients, require_sign_in=True, send_email=True, message=None, share_type='view'): """ Sends an invitation to access or edit this DriveItem :param recipients: a string or Contact or a list of the former representing recipients of this inv...
Returns a list of DriveItemPermissions with the permissions granted for this DriveItem. :return: List of Permissions :rtype: list[DriveItemPermission]
def get_permissions(self): """ Returns a list of DriveItemPermissions with the permissions granted for this DriveItem. :return: List of Permissions :rtype: list[DriveItemPermission] """ if not self.object_id: return [] url = self.build_url( ...
Creates a Child Folder :param str name: the name of the new child folder :param str description: the description of the new child folder :return: newly created folder :rtype: drive.Folder
def create_child_folder(self, name, description=None): """ Creates a Child Folder :param str name: the name of the new child folder :param str description: the description of the new child folder :return: newly created folder :rtype: drive.Folder """ if not self...
This will download each file and folder sequentially. Caution when downloading big folder structures :param drive.Folder to_folder: folder where to store the contents
def download_contents(self, to_folder=None): """ This will download each file and folder sequentially. Caution when downloading big folder structures :param drive.Folder to_folder: folder where to store the contents """ to_folder = to_folder or Path() if not to_folder.ex...
Uploads a file :param item: path to the item you want to upload :type item: str or Path :param chunk_size: Only applies if file is bigger than 4MB. Chunk size for uploads. Must be a multiple of 327.680 bytes :return: uploaded file :rtype: DriveItem
def upload_file(self, item, chunk_size=DEFAULT_UPLOAD_CHUNK_SIZE): """ Uploads a file :param item: path to the item you want to upload :type item: str or Path :param chunk_size: Only applies if file is bigger than 4MB. Chunk size for uploads. Must be a multiple of 327.680 bytes...
Returns a collection of drive items
def _base_get_list(self, url, limit=None, *, query=None, order_by=None, batch=None): """ Returns a collection of drive items """ if limit is None or limit > self.protocol.max_top_value: batch = self.protocol.max_top_value params = {'$top': batch if batch else...
Returns a collection of drive items from the root folder :param int limit: max no. of items to get. Over 999 uses batch. :param query: applies a OData filter to the request :type query: Query or str :param order_by: orders the result set based on this condition :type order_by: Q...
def get_items(self, limit=None, *, query=None, order_by=None, batch=None): """ Returns a collection of drive items from the root folder :param int limit: max no. of items to get. Over 999 uses batch. :param query: applies a OData filter to the request :type query: Query or str :...
Returns a DriveItem by it's Id :return: one item :rtype: DriveItem
def get_item(self, item_id): """ Returns a DriveItem by it's Id :return: one item :rtype: DriveItem """ if self.object_id: # reference the current drive_id url = self.build_url( self._endpoints.get('get_item').format(id=self.object_id, ...
Returns the specified Special Folder :return: a special Folder :rtype: drive.Folder
def get_special_folder(self, name): """ Returns the specified Special Folder :return: a special Folder :rtype: drive.Folder """ name = name if \ isinstance(name, OneDriveWellKnowFolderNames) \ else OneDriveWellKnowFolderNames(name.lower()) name =...
Updates this drive with data from the server :return: Success / Failure :rtype: bool
def refresh(self): """ Updates this drive with data from the server :return: Success / Failure :rtype: bool """ if self.object_id is None: url = self.build_url(self._endpoints.get('default_drive')) else: url = self.build_url( self...
Returns a Drive instance :param request_drive: True will make an api call to retrieve the drive data :return: default One Drive :rtype: Drive
def get_default_drive(self, request_drive=False): """ Returns a Drive instance :param request_drive: True will make an api call to retrieve the drive data :return: default One Drive :rtype: Drive """ if request_drive is False: return Drive(con=self.c...
Returns a Drive instance :param drive_id: the drive_id to be retrieved :return: Drive for the id :rtype: Drive
def get_drive(self, drive_id): """ Returns a Drive instance :param drive_id: the drive_id to be retrieved :return: Drive for the id :rtype: Drive """ if not drive_id: return None url = self.build_url( self._endpoints.get('get_drive').form...
Returns a collection of drives
def get_drives(self): """ Returns a collection of drives""" url = self.build_url(self._endpoints.get('list_drives')) response = self.con.get(url) if not response: return [] data = response.json() # Everything received from cloud must be passed as self._clo...
Given a ParsedNodePatch, add the new information to the node.
def patch(self, patch): """Given a ParsedNodePatch, add the new information to the node.""" # explicitly pick out the parts to update so we don't inadvertently # step on the model name or anything self._contents.update({ 'patch_path': patch.original_file_path, 'de...
Build the forward and backward edges on the given list of ParsedNodes and return them as two separate dictionaries, each mapping unique IDs to lists of edges.
def build_edges(nodes): """Build the forward and backward edges on the given list of ParsedNodes and return them as two separate dictionaries, each mapping unique IDs to lists of edges. """ backward_edges = {} # pre-populate the forward edge dict for simplicity forward_edges = {node.unique_i...
Convert the parsed manifest to a nested dict structure that we can safely serialize to JSON.
def serialize(self): """Convert the parsed manifest to a nested dict structure that we can safely serialize to JSON. """ forward_edges, backward_edges = build_edges(self.nodes.values()) return { 'nodes': {k: v.serialize() for k, v in self.nodes.items()}, ...
Find a macro in the graph by its name and package name, or None for any package.
def find_macro_by_name(self, name, package): """Find a macro in the graph by its name and package name, or None for any package. """ return self._find_by_name(name, package, 'macros', [NodeType.Macro])
Find any valid target for "ref()" in the graph by its name and package name, or None for any package.
def find_refable_by_name(self, name, package): """Find any valid target for "ref()" in the graph by its name and package name, or None for any package. """ return self._find_by_name(name, package, 'nodes', NodeType.refable())
Find any valid target for "source()" in the graph by its name and package name, or None for any package.
def find_source_by_name(self, source_name, table_name, package): """Find any valid target for "source()" in the graph by its name and package name, or None for any package. """ name = '{}.{}'.format(source_name, table_name) return self._find_by_name(name, package, 'nodes', [NodeT...
Given a subgraph of the manifest, and a predicate, filter the subgraph using that predicate. Generates a list of nodes.
def _filter_subgraph(self, subgraph, predicate): """ Given a subgraph of the manifest, and a predicate, filter the subgraph using that predicate. Generates a list of nodes. """ to_return = [] for unique_id, item in subgraph.items(): if predicate(item): ...
Given a schema and table, find matching models, and return their unique_ids. A schema and table may have more than one match if the relation matches both a source and a seed, for instance.
def get_unique_ids_for_schema_and_table(self, schema, table): """ Given a schema and table, find matching models, and return their unique_ids. A schema and table may have more than one match if the relation matches both a source and a seed, for instance. """ def predicate...
Add the given dict of new nodes to the manifest.
def add_nodes(self, new_nodes): """Add the given dict of new nodes to the manifest.""" for unique_id, node in new_nodes.items(): if unique_id in self.nodes: raise_duplicate_resource_name(node, self.nodes[unique_id]) self.nodes[unique_id] = node