autodrive.interfaces
¶
Module Contents¶
Classes¶
Optional custom configuration for Autodrive’s authentication processes using |
|
A partial range used in requests to the Google Sheets API when the axis of the |
|
A complete Google Sheets range (indicating start and end row and column as |
|
The settings for the border of a single side of a cell. |
|
An RGBA color value. |
|
Underlying class for text/number formats. |
|
Provides parameters available in updating the text formatting of a cell. |
|
A Google Sheet Number Format, which the value of the cell (s) will be parsed |
Attributes¶
Filepath for the token json file. Default=”gdrive_token.json”. |
|
Filepath for the credentials json file. Default=”credentials.json” |
|
Corresponds to the Automatic |
|
Corresponds to the Number |
|
Corresponds to the Accounting |
|
Corresponds to the Percent |
|
Corresponds to the Scientific |
|
Corresponds to the Financial |
|
Corresponds to the Currency |
|
Corresponds to the Currency (rounded) |
|
Corresponds to the Date |
|
Corresponds to the Time |
|
Corresponds to the Date time |
|
Corresponds to the Duration |
- autodrive.interfaces.DEFAULT_TOKEN = gdrive_token.json¶
Filepath for the token json file. Default=”gdrive_token.json”.
- autodrive.interfaces.DEFAULT_CREDS = credentials.json¶
Filepath for the credentials json file. Default=”credentials.json”
- exception autodrive.interfaces.ParseRangeError(rng, msg_addon=None, *args)¶
Error raised when an invalid range string is passed to a FullRange.
- Parameters
rng (str) – The original range string.
msg_addon (str, optional) – An addendum to the error message. Defaults to None.
args (object) –
- class args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class autodrive.interfaces.AuthConfig(secrets_config=None, token_filepath=DEFAULT_TOKEN, creds_filepath=DEFAULT_CREDS)¶
Optional custom configuration for Autodrive’s authentication processes using your Google api credentials.
- Parameters
secrets_config (Dict[str, Any], optional) – The dictionary of configuration used by a google.oath2.credentials Credentials object. Generally only useful if for some reason you are reading in your own token file, defaults to None.
token_filepath (str | Path, optional) – The filepath to your gdrive_token json file. This doesn’t have to exist at time of authentication, and will be saved to this path when the authorization flow completes, defaults to DEFAULT_TOKEN, which is “gdrive_token.json” in your cwd.
creds_filepath (str | Path, optional) – The filepath to your api credentials json file. This file does need to exist at time of authentication, unless you pass a secrets_config dictionary, defaults to DEFAULT_CREDS, which is “credentials.json” from your cwd.
- property token_filepath(self)¶
- Returns
The Path to your token json file.
- Return type
Path
- property creds_filepath(self)¶
- Returns
The Path to your credentials json file.
- Return type
Path
- class autodrive.interfaces.HalfRange(start_idx=None, end_idx=None, *, tab_title=None, base0_idxs=False, column=False)¶
A partial range used in requests to the Google Sheets API when the axis of the range is obvious from context (such as when inserting rows or columns).
Note that HalfRange parses your inputs into Google Sheets API row/column indices, which are 0-based, so if you call
start_idx
orend_idx
expect them to be 1 lower than the value you passed.- Parameters
start_idx (str | int, optional) – The first column/row in the range, assumed to not be 0-based if it’s an integer (row), defaults to None.
end_idx (str | int, optional) – The last column/row in the range, assumed to not be 0-based if it’s an integer (row), defaults to None.
tab_title (str, optional) – The name of the tab this range resides in, defaults to None.
base0_idxs (bool, optional) – Set to True if you’d like to pass 0-based indices to start_idx and end_idx params, above, defaults to False.
column (bool, optional) – Set to True if this HalfRange is a column range and you supplied the column indexes as integers, defaults to False.
- class Mapping¶
- get(self, key, default=None)¶
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- keys(self)¶
D.keys() -> a set-like object providing a view on D’s keys
- items(self)¶
D.items() -> a set-like object providing a view on D’s items
- values(self)¶
D.values() -> an object providing a view on D’s values
- to_dict(self)¶
The Google Sheets api ranges are end-value exclusive, so this method will produce a dictionary with an endIndex value 1 higher than the FullRange’s attribute.
- Returns
Outputs the HalfRange as a dictionary of properties usable in generating an api request to affect the target range of cells.
- Return type
Dict[str, int]
- get(self, key, default=None)¶
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- keys(self)¶
D.keys() -> a set-like object providing a view on D’s keys
- items(self)¶
D.items() -> a set-like object providing a view on D’s items
- values(self)¶
D.values() -> an object providing a view on D’s values
- class autodrive.interfaces.FullRange(range_str=None, *, start_row=None, end_row=None, start_col=None, end_col=None, base0_idxs=False, tab_title=None)¶
A complete Google Sheets range (indicating start and end row and column as well as at least an end column, if not an end row).
Note that FullRange parses your inputs into Google Sheets API row/column indices, which are 0-based, so if you call
start_row
,end_row
,start_col
, orend_col
, expect them to be 1 lower than the value you passed.- Parameters
range_str (str, optional) – A range string (e.g. Sheet1!A1:B3, A1:B3, A1).
start_row (int, optional) – The first row in the range, assumed to not be 0-based, defaults to None.
end_row (int, optional) – The last row in the range, assumed to not be 0-based, defaults to None.
start_col (int | str, optional) – The first column in the range, assumed to not be 0-based if it’s an integer, defaults to None.
end_col (int | str, optional) – The last column in the range, assumed to not be 0-based if it’s an integer, defaults to None.
base0_idxs (bool, optional) – Set to True if you’d like to pass 0-based indices to start/end_row and start/end_col, defaults to False.
tab_title (str, optional) – The name of the tab this range resides in, defaults to None.
- class Mapping¶
- get(self, key, default=None)¶
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- keys(self)¶
D.keys() -> a set-like object providing a view on D’s keys
- items(self)¶
D.items() -> a set-like object providing a view on D’s items
- values(self)¶
D.values() -> an object providing a view on D’s values
- property col_range(self)¶
- Returns
The FullRange’s column range as a HalfRange.
- Return type
- to_dict(self)¶
The Google Sheets api ranges are end-value exclusive, so this method will produce a dictionary with endRowIndex and endColumnIndex values 1 higher than the FullRange’s attribute.
- Returns
Outputs the FullRange as a dictionary of properties usable in generating an api request to affect the target range of cells.
- Return type
Dict[str, int]
- get(self, key, default=None)¶
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- keys(self)¶
D.keys() -> a set-like object providing a view on D’s keys
- items(self)¶
D.items() -> a set-like object providing a view on D’s items
- values(self)¶
D.values() -> an object providing a view on D’s values
- class autodrive.interfaces.BorderFormat(side, color=None, style=None)¶
The settings for the border of a single side of a cell.
- Parameters
side (BorderSide) – The BorderSide to apply settings to.
color (Color, optional) – The color of the side of the border. Defaults to None, for a black border.
style (BorderStyle, optional) – The BorderStyle of the side of the border. Defaults to None, for the default border style.
- to_dict(self)¶
- Returns
Outputs the BorderFormat as a dictionary of properties usable in generating an api request to affect cell border properties.
- Return type
Dict[str, Any]
- class autodrive.interfaces.Color(red=0, green=0, blue=0, alpha=100)¶
An RGBA color value.
- Parameters
red (int | float, optional) – Either an integer from 0 to 255 (from which a float value will be calculated), or the float representation of same. defaults to 0.
green (int | float, optional) – Either an integer from 0 to 255 (from which a float value will be calculated), or the float representation of same. defaults to 0.
blue (int | float, optional) – Either an integer from 0 to 255 (from which a float value will be calculated), or the float representation of same. defaults to 0.
alpha (int, optional) – Either an integer from 0 to 100 (from which a float value will be calculated), or the float representation of same. defaults to 100.
- class Mapping¶
- get(self, key, default=None)¶
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- keys(self)¶
D.keys() -> a set-like object providing a view on D’s keys
- items(self)¶
D.items() -> a set-like object providing a view on D’s items
- values(self)¶
D.values() -> an object providing a view on D’s values
- to_dict(self)¶
- Returns
Outputs the Color as a dictionary of properties usable in generating an api request to affect the color of text or cell background.
- Return type
Dict[str, float]
- classmethod from_hex(cls, hex_code, alpha=100)¶
Instantiates a Color object from the supplied hex code.
- Parameters
hex_code (str) – A hexadecimal color code.
alpha (int | float, optional) – Optional alpha parameter (not included in hex codes). Defaults to 100.
- Returns
The new Color object.
- Return type
- get(self, key, default=None)¶
D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
- keys(self)¶
D.keys() -> a set-like object providing a view on D’s keys
- items(self)¶
D.items() -> a set-like object providing a view on D’s items
- values(self)¶
D.values() -> an object providing a view on D’s values
- class autodrive.interfaces.Format(format_key)¶
Underlying class for text/number formats.
- Parameters
format_key (str) – The format key as dictated by the Google Sheets api.
- property format_key(self)¶
- Returns
The format’s Google Sheets api key, used to generate the userEnteredFormat value.
- Return type
str
- to_dict(self)¶
- Returns
Outputs the Format as a dictionary of properties usable in generating an api request to affect the text/number format of one or more cells.
- Return type
Dict[str, Any]
- class autodrive.interfaces.TextFormat(*, font=None, color=None, font_size=None, bold=None, italic=None, underline=None, strikethrough=None)¶
Provides parameters available in updating the text formatting of a cell.
- Parameters
font (str, optional) – The name of a font to change to, defaults to None.
color (Color, optional) – The Color properties to apply to the text, defaults to None.
font_size (int, optional) – The size to apply to the text, defaults to None.
bold (bool, optional) – Whether to turn bold on (True) or off (False), defaults to None, for unchanged.
italic (bool, optional) – Whether to turn italic on (True) or off (False), defaults to None, for unchanged.
underline (bool, optional) – Whether to turn underline on (True) or off (False), defaults to None, for unchanged.
strikethrough (bool, optional) – Whether to turn strikethrough on (True) or off (False), defaults to None, for unchanged.
- property format_key(self)¶
- Returns
The format’s Google Sheets api key, used to generate the userEnteredFormat value.
- Return type
str
- to_dict(self)¶
- Returns
Outputs the Format as a dictionary of properties usable in generating an api request to affect the text/number format of one or more cells.
- Return type
Dict[str, Any]
- class autodrive.interfaces.NumericFormat(pattern='')¶
A Google Sheet Number Format, which the value of the cell (s) will be parsed into.
- Parameters
pattern (str, optional) – A pattern valid as a Google Sheet Number Format, defaults to “”, for automatic number format.
- property format_key(self)¶
- Returns
The format’s Google Sheets api key, used to generate the userEnteredFormat value.
- Return type
str
- to_dict(self)¶
- Returns
Outputs the Format as a dictionary of properties usable in generating an api request to affect the text/number format of one or more cells.
- Return type
Dict[str, Any]
- autodrive.interfaces.AutomaticFormat¶
Corresponds to the Automatic
1000.12
format.
- autodrive.interfaces.NumberFormat¶
Corresponds to the Number
1,000.12
format.
- autodrive.interfaces.AccountingFormat¶
Corresponds to the Accounting
$ (1,000.12)
format.
- autodrive.interfaces.PercentFormat¶
Corresponds to the Percent
10.12%
format.
- autodrive.interfaces.ScientificFormat¶
Corresponds to the Scientific
1.01E+03
format.
- autodrive.interfaces.FinancialFormat¶
Corresponds to the Financial
(1,000.12)
format.
- autodrive.interfaces.CurrencyFormat¶
Corresponds to the Currency
$1,000.12
format.
- autodrive.interfaces.CurRoundFormat¶
Corresponds to the Currency (rounded)
$1,000
format.
- autodrive.interfaces.DateFormat¶
Corresponds to the Date
9/26/2008
format.
- autodrive.interfaces.TimeFormat¶
Corresponds to the Time
3:59:00 PM
format.
- autodrive.interfaces.DatetimeFormat¶
Corresponds to the Date time
9/26/2008 15:59:00
format.
- autodrive.interfaces.DurationFormat¶
Corresponds to the Duration
24:01:00
format.