Bases: object
A data descriptor that sets and returns values.
Bases: object
Mixin to initialize required global variables to use ApiAttribute.
Bases: dict
Super class of all api resources.
Inherits and behaves as a python dictionary to handle api resources. Save clean copy of metadata in self.metadata as a dictionary. Provides changed metadata elements to efficiently update api resources.
Returns changed metadata elements to update api resources efficiently.
Returns: | dict – changed metadata elements. |
---|
Update metadata and mark all of them to be clean.
Bases: pydrive.apiattr.ApiAttributeMixin, pydrive.apiattr.ApiResource
Abstract class of all api list resources.
Inherits ApiResource and builds iterator to list any API resource.
Get list of API resources.
If ‘maxResults’ is not specified, it will automatically iterate through every resources available. Otherwise, it will make API call once and update ‘pageToken’.
Returns: | list – list of API resources. |
---|
Resets current iteration
Helper function which actually makes API call.
Should be overwritten.
Raises : | NotImplementedError |
---|
Make API call to list resources and return them.
Auto updates ‘pageToken’ everytime it makes API call and raises StopIteration when it reached the end of iteration.
Returns: | list – list of API resources. |
---|---|
Raises : | StopIteration |
Bases: exceptions.Exception
Base error for authentication/authorization errors.
Bases: exceptions.IOError
Error trying to read credentials file.
Bases: pydrive.auth.AuthError
User rejected authentication.
Bases: pydrive.auth.AuthError
General authentication error.
Bases: pydrive.auth.AuthError
Access token refresh error.
Decorator to check if the auth is valid and loads auth if not.
Decorator to check if it requires OAuth2 flow request.
Bases: pydrive.apiattr.ApiAttributeMixin, object
Wrapper class for oauth2client library in google-api-python-client.
Loads all settings and credentials from one ‘settings.yaml’ file and performs common OAuth2.0 related functionality such as authentication and authorization.
Authenticate and authorize from user by creating local webserver and retrieving authentication code.
This function is not for webserver application. It creates local webserver for user from standalone application.
Parameters: |
|
---|---|
Returns: | str – code returned from local webserver |
Raises : | AuthenticationRejected, AuthenticationError |
Authenticate and authorize from user by printing authentication url retrieving authentication code from command-line.
Returns: | str – code returned from commandline. |
---|
Authenticate, authorize, and build service.
Parameters: | code (str.) – Code for authentication. |
---|---|
Raises : | AuthenticationError |
Authenticates given authentication code back from user.
Parameters: | code (str.) – Code for authentication. |
---|---|
Raises : | AuthenticationError |
Authorizes and builds service.
Raises : | AuthenticationError |
---|
Creates authentication url where user visits to grant access.
Returns: | str – Authentication url. |
---|
Gets Flow object from client configuration.
Raises : | InvalidConfigError |
---|
Loads client configuration according to specified backend.
If you have any specific backend to load client configuration from in mind, don’t use this function and use the corresponding function you want.
Parameters: | backend (str.) – backend to load client configuration from. |
---|---|
Raises : | InvalidConfigError |
Loads client configuration file downloaded from APIs console.
Loads client config file from path in settings if not specified.
Parameters: | client_config_file (str.) – path of client config file to read. |
---|---|
Raises : | InvalidConfigError |
Loads client configuration from settings file.
Raises : | InvalidConfigError |
---|
Loads credentials or create empty credentials if it doesn’t exist.
Parameters: | backend (str.) – target backend to save credential to. |
---|---|
Raises : | InvalidConfigError |
Loads credentials or create empty credentials if it doesn’t exist.
Loads credentials file from path in settings if not specified.
Parameters: | credentials_file (str.) – path of credentials file to read. |
---|---|
Raises : | InvalidConfigError, InvalidCredentialsError |
Refreshes the access_token.
Raises : | RefreshError |
---|
Saves credentials according to specified backend.
If you have any specific credentials backend in mind, don’t use this function and use the corresponding function you want.
Parameters: | backend (str.) – backend to save credentials. |
---|---|
Raises : | InvalidConfigError |
Saves credentials to the file in JSON format.
Parameters: | credentials_file (str.) – destination to save file to. |
---|---|
Raises : | InvalidConfigError, InvalidCredentialsError |
Checks if access token doesn’t exist or is expired.
Returns: | bool – True if access token doesn’t exist or is expired. |
---|
Bases: pydrive.apiattr.ApiAttributeMixin, object
Main Google Drive class.
Create an instance of GoogleDriveFile with auth of this instance.
This method would not upload a file to GoogleDrive.
Parameters: | metadata (dict.) – file resource to initialize GoogleDriveFile with. |
---|---|
Returns: | pydrive.files.GoogleDriveFile – initialized with auth of this instance. |
Create an instance of GoogleDriveFileList with auth of this instance.
This method will not fetch from Files.List().
Parameters: | param (dict.) – parameter to be sent to Files.List(). |
---|---|
Returns: | pydrive.files.GoogleDriveFileList – initialized with auth of this instance. |
Bases: exceptions.RuntimeError
Error trying to access metadata of file that is not uploaded.
Bases: exceptions.IOError
Error while making any API requests.
Bases: exceptions.RuntimeError
Error trying to download file that is not downloadable.
Decorator to check if the file has metadata and fetches it if not.
Raises : | ApiRequestError, FileNotUploadedError |
---|
Bases: pydrive.apiattr.ApiResourceList
Google Drive FileList instance.
Equivalent to Files.list() in Drive APIs.
Overwritten method which actually makes API call to list files.
Returns: | list – list of pydrive.files.GoogleDriveFile. |
---|
Bases: pydrive.apiattr.ApiAttributeMixin, pydrive.apiattr.ApiResource
Google Drive File instance.
Inherits ApiResource which inherits dict. Can access and modify metadata like dictionary.
Download file’s metadata from id using Files.get().
Raises : | ApiRequestError, FileNotUploadedError |
---|
Download file’s content from download_url.
Raises : | ApiRequestError, FileNotUploadedError, FileNotDownloadableError |
---|
Save content of this file as a local file.
Parameters: | filename (str.) – name of the file to write to. |
---|---|
Raises : | ApiRequestError, FileNotUploadedError, FileNotDownloadableError |
Get content of this file as a string.
Returns: | str – utf-8 decoded content of the file |
---|---|
Raises : | ApiRequestError, FileNotUploadedError, FileNotDownloadableError |
Set content of this file from a file.
Opens the file specified by this method. Will be read, uploaded, and closed by Upload() method. Sets metadata ‘title’ and ‘mimeType’ automatically if not specified.
Parameters: | filename (str.) – name of the file to be uploaded. |
---|
Set content of this file to be a string.
Creates io.BytesIO instance of utf-8 encoded string. Sets mimeType to be ‘text/plain’ if not specified.
Parameters: | content (str.) – content of the file in string. |
---|
Upload/update file by choosing the most efficient method.
Parameters: | param (dict.) – additional parameter to upload file. |
---|---|
Raises : | ApiRequestError |
Bases: exceptions.IOError
Error while loading/saving settings
Bases: exceptions.IOError
Error trying to read client configuration.
Loads settings file in yaml format given file name.
Parameters: | filename (str.) – path for settings file. ‘settings.yaml’ by default. |
---|---|
Raises : | SettingsError |
Validates if current settings is valid.
Parameters: | data (dict.) – dictionary containing all settings. |
---|---|
Raises : | InvalidConfigError |