text stringlengths 81 112k |
|---|
Re-download folder data
Inbox Folder will be unable to download its own data (no folder_id)
:param bool update_parent_if_changed: updates self.parent with new
parent Folder if changed
:return: Refreshed or Not
:rtype: bool
def refresh_folder(self, update_parent_if_changed=Fals... |
Get the parent folder from attribute self.parent or
getting it from the cloud
:return: Parent Folder
:rtype: mailbox.Folder or None
def get_parent_folder(self):
""" Get the parent folder from attribute self.parent or
getting it from the cloud
:return: Parent Folder
... |
Change this folder name
:param str name: new name to change to
:param bool update_folder_data: whether or not to re-fetch the data
:return: Updated or Not
:rtype: bool
def update_folder_name(self, name, update_folder_data=True):
""" Change this folder name
:param str n... |
Copy this folder and it's contents to into another folder
:param to_folder: the destination Folder/folder_id to copy into
:type to_folder: mailbox.Folder or str
:return: The new folder after copying
:rtype: mailbox.Folder or None
def copy_folder(self, to_folder):
""" Copy this ... |
Move this folder to another folder
:param to_folder: the destination Folder/folder_id to move into
:type to_folder: mailbox.Folder or str
:param bool update_parent_if_changed: updates self.parent with the
new parent Folder if changed
:return: The new folder after copying
... |
Creates a new draft message under this folder
:return: new Message
:rtype: Message
def new_message(self):
""" Creates a new draft message under this folder
:return: new Message
:rtype: Message
"""
draft_message = self.message_constructor(parent=self, is_draft=... |
Deletes a stored message
:param message: message/message_id to delete
:type message: Message or str
:return: Success / Failure
:rtype: bool
def delete_message(self, message):
""" Deletes a stored message
:param message: message/message_id to delete
:type messag... |
Shortcut to get Inbox Folder instance
:rtype: mailbox.Folder
def inbox_folder(self):
""" Shortcut to get Inbox Folder instance
:rtype: mailbox.Folder
"""
return self.folder_constructor(parent=self, name='Inbox',
folder_id=OutlookWellKnowF... |
Shortcut to get Junk Folder instance
:rtype: mailbox.Folder
def junk_folder(self):
""" Shortcut to get Junk Folder instance
:rtype: mailbox.Folder
"""
return self.folder_constructor(parent=self, name='Junk',
folder_id=OutlookWellKnowFolde... |
Shortcut to get DeletedItems Folder instance
:rtype: mailbox.Folder
def deleted_folder(self):
""" Shortcut to get DeletedItems Folder instance
:rtype: mailbox.Folder
"""
return self.folder_constructor(parent=self, name='DeletedItems',
fol... |
Shortcut to get Drafts Folder instance
:rtype: mailbox.Folder
def drafts_folder(self):
""" Shortcut to get Drafts Folder instance
:rtype: mailbox.Folder
"""
return self.folder_constructor(parent=self, name='Drafts',
folder_id=OutlookWellK... |
Shortcut to get SentItems Folder instance
:rtype: mailbox.Folder
def sent_folder(self):
""" Shortcut to get SentItems Folder instance
:rtype: mailbox.Folder
"""
return self.folder_constructor(parent=self, name='SentItems',
folder_id=Outlo... |
Shortcut to get Outbox Folder instance
:rtype: mailbox.Folder
def outbox_folder(self):
""" Shortcut to get Outbox Folder instance
:rtype: mailbox.Folder
"""
return self.folder_constructor(parent=self, name='Outbox',
folder_id=OutlookWellK... |
Request a new session id
def create_session(self):
""" Request a new session id """
url = self.build_url(self._endpoints.get('create_session'))
response = self.con.post(url, data={'persistChanges': self.persist})
if not response:
raise RuntimeError('Could not create session... |
Close the current session
def close_session(self):
""" Close the current session """
if self.session_id:
url = self.build_url(self._endpoints.get('close_session'))
response = self.con.post(url, headers={'workbook-session-id': self.session_id})
return bool(response)
... |
If session is in use, prepares the request headers and
checks if the session is expired.
def prepare_request(self, kwargs):
""" If session is in use, prepares the request headers and
checks if the session is expired.
"""
if self.session_id is not None:
actual = dt.... |
Loads the data into this instance
def _load_data(self):
""" Loads the data into this instance """
url = self.parent.build_url(self.parent._endpoints.get('format'))
response = self.parent.session.get(url)
if not response:
return False
data = response.json()
s... |
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 dat... |
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 dat... |
Updates this range format
def update(self):
""" Updates this range format """
if self._track_changes:
data = self.to_api_data(restrict_keys=self._track_changes)
if data:
response = self.session.patch(self.build_url(''), data=data)
if not response:... |
Loads the data related to the fill color
def _load_background_color(self):
""" Loads the data related to the fill color """
url = self.build_url(self._endpoints.get('fill'))
response = self.session.get(url)
if not response:
return None
data = response.json()
... |
Changes the width of the columns of the current range
to achieve the best fit, based on the current data in the columns
def auto_fit_columns(self):
""" Changes the width of the columns of the current range
to achieve the best fit, based on the current data in the columns
"""
u... |
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 dat... |
Helper that returns another range
def _get_range(self, endpoint, *args, method='GET', **kwargs):
""" Helper that returns another range"""
if args:
url = self.build_url(self._endpoints.get(endpoint).format(*args))
else:
url = self.build_url(self._endpoints.get(endpoint))
... |
Gets an object which represents a range that's offset from the specified range.
The dimension of the returned range will match this range.
If the resulting range is forced outside the bounds of the worksheet grid,
an exception will be thrown.
:param int row_offset: The number of rows... |
Clear range values, format, fill, border, etc.
:param str apply_to: Optional. Determines the type of clear action.
The possible values are: all, formats, contents.
def clear(self, apply_to='all'):
"""
Clear range values, format, fill, border, etc.
:param str apply_to: Optional.... |
Deletes the cells associated with the range.
:param str shift: Optional. Specifies which way to shift the cells.
The possible values are: up, left.
def delete(self, shift='up'):
"""
Deletes the cells associated with the range.
:param str shift: Optional. Specifies which way to ... |
Merge the range cells into one region in the worksheet.
:param bool across: Optional. Set True to merge cells in each row of the
specified range as separate merged cells.
def merge(self, across=False):
"""
Merge the range cells into one region in the worksheet.
:param bool acro... |
Update this range
def update(self):
""" Update this range """
if not self._track_changes:
return True # there's nothing to update
data = self.to_api_data(restrict_keys=self._track_changes)
response = self.session.patch(self.build_url(''), data=data)
if not respons... |
Returns a RangeFormat instance with the format of this range
def get_format(self):
""" Returns a RangeFormat instance with the format of this range """
url = self.build_url(self._endpoints.get('get_format'))
response = self.session.get(url)
if not response:
return None
... |
Updates this named range
:param bool visible: Specifies whether the object is visible or not
:param str comment: Represents the comment associated with this name
:return: Success or Failure
def update(self, *, visible=None, comment=None):
"""
Updates this named range
:pa... |
Updates this row
def update(self, values):
""" Updates this row """
response = self.session.patch(self.build_url(''), data={'values': values})
if not response:
return False
data = response.json()
self.values = data.get('values', self.values)
return True |
Apply the given filter criteria on the given column.
:param str criteria: the criteria to apply
criteria example:
{
"color": "string",
"criterion1": "string",
"criterion2": "string",
"dynamicCriteria": "string",
"filterOn": "string",
"i... |
Returns the filter applie to this column
def get_filter(self):
""" Returns the filter applie to this column """
q = self.q().select('name').expand('filter')
response = self.session.get(self.build_url(''), params=q.as_params())
if not response:
return None
data = resp... |
Return the columns of this table
:param int top: specify n columns to retrieve
:param int skip: specify n columns to skip
def get_columns(self, *, top=None, skip=None):
"""
Return the columns of this table
:param int top: specify n columns to retrieve
:param int skip: sp... |
Gets a column from this table by id or name
:param id_or_name: the id or name of the column
:return: WorkBookTableColumn
def get_column(self, id_or_name):
"""
Gets a column from this table by id or name
:param id_or_name: the id or name of the column
:return: WorkBookTab... |
Returns a table column by it's index
:param int index: the zero-indexed position of the column in the table
def get_column_at_index(self, index):
"""
Returns a table column by it's index
:param int index: the zero-indexed position of the column in the table
"""
if index ... |
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 Failur... |
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):
"""
Ad... |
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 s... |
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(par... |
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:
... |
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
""... |
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... |
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, s... |
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.... |
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 = resp... |
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 ... |
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()
... |
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
"""
... |
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... |
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 w... |
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))
respo... |
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... |
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... |
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 = respon... |
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
... |
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.jso... |
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:
retur... |
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 = respon... |
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_p... |
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 = 'f... |
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 ... |
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 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)... |
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 ... |
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... |
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 at... |
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
:pa... |
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 = {
... |
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 dat... |
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 ... |
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 s... |
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 ... |
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.b... |
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:
... |
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... |
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 ... |
Gets a list of calendars
To use query an order_by check the OData specification here:
http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/
part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions
-complete.html
:param int limit: max no. of calendars to ge... |
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 inst... |
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):
""" Re... |
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)
... |
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
... |
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:
... |
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.exis... |
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.')
... |
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... |
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:
... |
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... |
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('... |
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
"""... |
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... |
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
... |
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... |
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
:... |
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.