autodrive._view
¶
Module Contents¶
Classes¶
Formatting objects contain methods for adding various update format requests |
|
Contains methods for generating format requests that update cell properties. |
|
Contains methods for generating format requests that update grid properties. |
|
Contains methods for generating format requests that update the properties of |
|
Abstract base class for the different ways of viewing a Google Sheet. |
|
Base class for Tab and Range. |
Attributes¶
- autodrive._view.T¶
- autodrive._view.FC¶
- autodrive._view.FG¶
- autodrive._view.FT¶
- exception autodrive._view.NoConnectionError(vtype, *args)¶
Error thrown when attempting to connect via a SheetsConnection that does not exist.
Initialize self. See help(type(self)) for accurate signature.
- Parameters
vtype (Type[GSheetView]) –
args (object) –
- class args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception autodrive._view.OutputError¶
Error thrown when something goes wrong when attempting to write values to a file.
Initialize self. See help(type(self)) for accurate signature.
- class args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class autodrive._view.Formatting(parent)¶
Formatting objects contain methods for adding various update format requests to their parent Component.
- Parameters
parent (Component[Any, Any, Any]) – A Component object.
- add_request(self, request)¶
Adds the passed request to the Formatting object’s parent component.
- Parameters
request (Dict[str, Any]) – An api-ready request.
- Return type
None
- ensure_full_range(self, rng=None)¶
Convenience method for ensuring that all requests generated by this Formatting object have a FullRange attached to them, if one isn’t manually supplied.
- class autodrive._view.CellFormatting(parent)¶
Contains methods for generating format requests that update cell properties.
- Parameters
parent (Component[Any, Any, Any]) – A Component object.
- add_request(self, request)¶
Adds the passed request to the Formatting object’s parent component.
- Parameters
request (Dict[str, Any]) – An api-ready request.
- Return type
None
- ensure_full_range(self, rng=None)¶
Convenience method for ensuring that all requests generated by this Formatting object have a FullRange attached to them, if one isn’t manually supplied.
- class autodrive._view.GridFormatting(parent)¶
Contains methods for generating format requests that update grid properties.
- Parameters
parent (Component[Any, Any, Any]) – A Component object.
- add_request(self, request)¶
Adds the passed request to the Formatting object’s parent component.
- Parameters
request (Dict[str, Any]) – An api-ready request.
- Return type
None
- ensure_full_range(self, rng=None)¶
Convenience method for ensuring that all requests generated by this Formatting object have a FullRange attached to them, if one isn’t manually supplied.
- class autodrive._view.TextFormatting(parent)¶
Contains methods for generating format requests that update the properties of text in one or more cells.
- Parameters
parent (Component[Any, Any, Any]) – A Component object.
- add_request(self, request)¶
Adds the passed request to the Formatting object’s parent component.
- Parameters
request (Dict[str, Any]) – An api-ready request.
- Return type
None
- ensure_full_range(self, rng=None)¶
Convenience method for ensuring that all requests generated by this Formatting object have a FullRange attached to them, if one isn’t manually supplied.
- class autodrive._view.GSheetView(gsheet_id, *, auth_config=None, sheets_conn=None, autoconnect=True)¶
Abstract base class for the different ways of viewing a Google Sheet.
- Parameters
gsheet_id (str) – The id string of the target Google Sheet that the View is attached to.
auth_config (AuthConfig, optional) – Optional custom AuthConfig, defaults to None.
sheets_conn (SheetsConnection, optional) – Optional manually created SheetsConnection, defaults to None.
autoconnect (bool, optional) – If you want to instantiate a View without immediately checking your authentication credentials and connection to the Google Sheets api, set this to False, defaults to True.
- property requests(self)¶
- Returns
The list of current (uncommitted) requests.
- Return type
List[Dict[str, Any]]
- property conn(self)¶
- Returns
The view’s SheetsConnection.
- Return type
- Raises
NoConnectionError – If the view’s connection is null.
- property auth(self)¶
- Returns
The view’s AuthConfig.
- Return type
- Raises
NoConnectionError – If the view’s auth config is null.
- property gsheet_id(self)¶
- Returns
The id of the Google Sheet this view is connected to.
- Return type
str
- commit(self)¶
Commits the amassed requests on this view, sending them to the Sheets api as a batch update request.
- Returns
The response from the api.
- Return type
Dict[str, Any]
- Raises
NoConnectionError – If the view’s SheetsConnection is null.
- ensure_full_range(self, backup, rng=None)¶
Convenience method for ensuring that a range argument that could be None or a string is always a FullRange.
- Parameters
rng (FullRange | str, optional) – A manually generated FullRange or valid FullRange string, defaults to None.
backup (autodrive.interfaces.FullRange) –
- Returns
The passed FullRange, or the backup FullRange.
- Return type
- static gen_alpha_keys(num)¶
Generates a list of characters from the Latin alphabet a la gsheet/excel headers.
- Parameters
num (int) – The desired length of the list.
- Returns
A list containing as many letters and letter combos as desired. Can be used to generate sets up to 676 in length.
- Return type
List[str]
- class autodrive._view.Component(*, gsheet_range, gsheet_id, tab_id, grid_formatting, text_formatting, cell_formatting, auth_config=None, sheets_conn=None, autoconnect=True)¶
Base class for Tab and Range.
- Parameters
gsheet_id (str) – The id string of the target Google Sheet that the View is attached to.
auth_config (AuthConfig, optional) – Optional custom AuthConfig, defaults to None.
sheets_conn (SheetsConnection, optional) – Optional manually created SheetsConnection, defaults to None.
autoconnect (bool, optional) – If you want to instantiate a View without immediately checking your authentication credentials and connection to the Google Sheets api, set this to False, defaults to True.
gsheet_range (autodrive.interfaces.FullRange) –
tab_id (int) –
grid_formatting (Type[FG]) –
text_formatting (Type[FT]) –
cell_formatting (Type[FC]) –
- property tab_id(self)¶
- Returns
The id of the linked tab.
- Return type
int
- property range_str(self)¶
str: The string representation of the range specified by this Component.
- Return type
str
- property range(self)¶
- Returns
The FullRange representation of the range specified by this Component.
- Return type
- property format_grid(self)¶
- Returns
The GridFormatting subclass associated with this Component type.
- Return type
FG
- property format_text(self)¶
- Returns
The TextFormatting subclass associated with this Component type.
- Return type
FT
- property format_cell(self)¶
- Returns
The CellFormatting subclass associated with this Component type.
- Return type
FC
- property values(self)¶
- Returns
The fetched data values in this Component’s cells.
- Return type
List[List[Any]]
- property formats(self)¶
- Returns
The fetched formatting properties of this Component’s cells.
- Return type
List[List[Dict[str, Any]]]
- property data_shape(self)¶
- Returns
The row length and column width of this Component’s data.
- Return type
Tuple[int, int]
- to_csv(self, p, header=None)¶
Saves values to a csv file.
- Parameters
p (str | Path) – The path-like for the file to save the data to.
header (Sequence[Any], optional) – A header row. If supplied, must be the same number of columns as the data values. Defaults to None.
- Return type
None
- to_json(self, p, header=0)¶
Saves values to a json file, with one json per line.
- Parameters
p (str | Path) – The path-like for the file to save the data to.
header (Sequence[Any] | int) – A header row or the index of a row in the values data to use as the header row. The header will be used as the keys for the json-formatted dictionaries. Defaults to 0, using the first row as the header.
- Return type
None
- property requests(self)¶
- Returns
The list of current (uncommitted) requests.
- Return type
List[Dict[str, Any]]
- property conn(self)¶
- Returns
The view’s SheetsConnection.
- Return type
- Raises
NoConnectionError – If the view’s connection is null.
- property auth(self)¶
- Returns
The view’s AuthConfig.
- Return type
- Raises
NoConnectionError – If the view’s auth config is null.
- property gsheet_id(self)¶
- Returns
The id of the Google Sheet this view is connected to.
- Return type
str
- commit(self)¶
Commits the amassed requests on this view, sending them to the Sheets api as a batch update request.
- Returns
The response from the api.
- Return type
Dict[str, Any]
- Raises
NoConnectionError – If the view’s SheetsConnection is null.
- ensure_full_range(self, backup, rng=None)¶
Convenience method for ensuring that a range argument that could be None or a string is always a FullRange.
- Parameters
rng (FullRange | str, optional) – A manually generated FullRange or valid FullRange string, defaults to None.
backup (autodrive.interfaces.FullRange) –
- Returns
The passed FullRange, or the backup FullRange.
- Return type
- static gen_alpha_keys(num)¶
Generates a list of characters from the Latin alphabet a la gsheet/excel headers.
- Parameters
num (int) – The desired length of the list.
- Returns
A list containing as many letters and letter combos as desired. Can be used to generate sets up to 676 in length.
- Return type
List[str]