PyDrive
-------
*PyDrive* is a wrapper library of
`google-api-python-client <https://code.google.com/p/google-api-python-client/>`_
that simplifies many common Google Drive API tasks.
Project Info
------------
- Homepage: `https://pypi.python.org/pypi/PyDrive <https://pypi.python.org/pypi/PyDrive>`_
- Documentation: `Official documentation on GitHub pages <https://googledrive.github.io/PyDrive/docs/build/html/index.html>`_
- Github: `https://github.com/googledrive/PyDrive <https://github.com/googledrive/PyDrive>`_
Features of PyDrive
-------------------
- Simplifies OAuth2.0 into just few lines with flexible settings.
- Wraps `Google Drive API <https://developers.google.com/drive/>`_ into
classes of each resource to make your program more object-oriented.
- Helps common operations else than API calls, such as content fetching
and pagination control.
How to install
--------------
You can install PyDrive with regular ``pip`` command.
::
$ pip install PyDrive
To install the current development version from GitHub, use:
::
$ pip install git+https://github.com/googledrive/PyDrive.git#egg=PyDrive
OAuth made easy
---------------
Download *client\_secrets.json* from Google API Console and OAuth2.0 is
done in two lines. You can customize behavior of OAuth2 in one settings
file *settings.yaml*.
.. code:: python
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gauth = GoogleAuth()
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)
File management made easy
-------------------------
Upload/update the file with one method. PyDrive will do it in the most
efficient way.
.. code:: python
file1 = drive.CreateFile({'title': 'Hello.txt'})
file1.SetContentString('Hello')
file1.Upload() # Files.insert()
file1['title'] = 'HelloWorld.txt' # Change title of the file
file1.Upload() # Files.patch()
content = file1.GetContentString() # 'Hello'
file1.SetContentString(content+' World!') # 'Hello World!'
file1.Upload() # Files.update()
file2 = drive.CreateFile()
file2.SetContentFile('hello.png')
file2.Upload()
print('Created file %s with mimeType %s' % (file2['title'],
file2['mimeType']))
# Created file hello.png with mimeType image/png
file3 = drive.CreateFile({'id': file2['id']})
print('Downloading file %s from Google Drive' % file3['title']) # 'hello.png'
file3.GetContentFile('world.png') # Save Drive file as a local file
# or download Google Docs files in an export format provided.
# downloading a docs document as an html file:
docsfile.GetContentFile('test.html', mimetype='text/html')
File listing pagination made easy
---------------------------------
*PyDrive* handles file listing pagination for you.
.. code:: python
# Auto-iterate through all files that matches this query
file_list = drive.ListFile({'q': "'root' in parents"}).GetList()
for file1 in file_list:
print('title: %s, id: %s' % (file1['title'], file1['id']))
# Paginate file lists by specifying number of max results
for file_list in drive.ListFile({'maxResults': 10}):
print 'Received %s files from Files.list()' % len(file_list) # <= 10
for file1 in file_list:
print('title: %s, id: %s' % (file1['title'], file1['id']))
Concurrent access made easy
---------------------------
All calls made are thread-safe. The underlying implementation in the
google-api-client library
`is not thread-safe <https://developers.google.com/api-client-library/python/guide/thread_safety>`_,
which means that every request has to re-authenticate an http object. You
can avoid this overhead by
creating your own http object for each thread and re-use it for every call.
This can be done as follows:
.. code:: python
# Create httplib.Http() object.
http = drive.auth.Get_Http_Object()
# Create file object to upload.
file_obj = drive.CreateFile()
file_obj['title'] = "file name"
# Upload the file and pass the http object into the call to Upload.
file_obj.Upload(param={"http": http})
You can specify the http-object in every access method which takes a *param*
parameter.
Raw data
{
"_id": null,
"home_page": "https://github.com/googledrive/PyDrive",
"name": "PyDrive",
"maintainer": null,
"docs_url": "https://pythonhosted.org/PyDrive/",
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Robin Nabel",
"author_email": "rnabel@ucdavis.edu",
"download_url": "https://files.pythonhosted.org/packages/52/e0/0e64788e5dd58ce2d6934549676243dc69d982f198524be9b99e9c2a4fd5/PyDrive-1.3.1.tar.gz",
"platform": "UNKNOWN",
"description": "PyDrive\n-------\n\n*PyDrive* is a wrapper library of\n`google-api-python-client <https://code.google.com/p/google-api-python-client/>`_\nthat simplifies many common Google Drive API tasks.\n\nProject Info\n------------\n\n- Homepage: `https://pypi.python.org/pypi/PyDrive <https://pypi.python.org/pypi/PyDrive>`_\n- Documentation: `Official documentation on GitHub pages <https://googledrive.github.io/PyDrive/docs/build/html/index.html>`_\n- Github: `https://github.com/googledrive/PyDrive <https://github.com/googledrive/PyDrive>`_\n\nFeatures of PyDrive\n-------------------\n\n- Simplifies OAuth2.0 into just few lines with flexible settings.\n- Wraps `Google Drive API <https://developers.google.com/drive/>`_ into\n classes of each resource to make your program more object-oriented.\n- Helps common operations else than API calls, such as content fetching\n and pagination control.\n\nHow to install\n--------------\n\nYou can install PyDrive with regular ``pip`` command.\n\n::\n\n $ pip install PyDrive\n\nTo install the current development version from GitHub, use:\n\n::\n\n $ pip install git+https://github.com/googledrive/PyDrive.git#egg=PyDrive\n\nOAuth made easy\n---------------\n\nDownload *client\\_secrets.json* from Google API Console and OAuth2.0 is\ndone in two lines. You can customize behavior of OAuth2 in one settings\nfile *settings.yaml*.\n\n.. code:: python\n\n\n from pydrive.auth import GoogleAuth\n from pydrive.drive import GoogleDrive\n\n gauth = GoogleAuth()\n gauth.LocalWebserverAuth()\n\n drive = GoogleDrive(gauth)\n\nFile management made easy\n-------------------------\n\nUpload/update the file with one method. PyDrive will do it in the most\nefficient way.\n\n.. code:: python\n\n file1 = drive.CreateFile({'title': 'Hello.txt'})\n file1.SetContentString('Hello')\n file1.Upload() # Files.insert()\n\n file1['title'] = 'HelloWorld.txt' # Change title of the file\n file1.Upload() # Files.patch()\n\n content = file1.GetContentString() # 'Hello'\n file1.SetContentString(content+' World!') # 'Hello World!'\n file1.Upload() # Files.update()\n\n file2 = drive.CreateFile()\n file2.SetContentFile('hello.png')\n file2.Upload()\n print('Created file %s with mimeType %s' % (file2['title'],\n file2['mimeType']))\n # Created file hello.png with mimeType image/png\n\n file3 = drive.CreateFile({'id': file2['id']})\n print('Downloading file %s from Google Drive' % file3['title']) # 'hello.png'\n file3.GetContentFile('world.png') # Save Drive file as a local file\n\n # or download Google Docs files in an export format provided.\n # downloading a docs document as an html file:\n docsfile.GetContentFile('test.html', mimetype='text/html')\n\nFile listing pagination made easy\n---------------------------------\n\n*PyDrive* handles file listing pagination for you.\n\n.. code:: python\n\n # Auto-iterate through all files that matches this query\n file_list = drive.ListFile({'q': \"'root' in parents\"}).GetList()\n for file1 in file_list:\n print('title: %s, id: %s' % (file1['title'], file1['id']))\n\n # Paginate file lists by specifying number of max results\n for file_list in drive.ListFile({'maxResults': 10}):\n print 'Received %s files from Files.list()' % len(file_list) # <= 10\n for file1 in file_list:\n print('title: %s, id: %s' % (file1['title'], file1['id']))\n\nConcurrent access made easy\n---------------------------\n\nAll calls made are thread-safe. The underlying implementation in the\ngoogle-api-client library\n`is not thread-safe <https://developers.google.com/api-client-library/python/guide/thread_safety>`_,\nwhich means that every request has to re-authenticate an http object. You\ncan avoid this overhead by\ncreating your own http object for each thread and re-use it for every call.\n\nThis can be done as follows:\n\n.. code:: python\n\n # Create httplib.Http() object.\n http = drive.auth.Get_Http_Object()\n\n # Create file object to upload.\n file_obj = drive.CreateFile()\n file_obj['title'] = \"file name\"\n\n # Upload the file and pass the http object into the call to Upload.\n file_obj.Upload(param={\"http\": http})\n\nYou can specify the http-object in every access method which takes a *param*\nparameter.",
"bugtrack_url": null,
"license": "LICENSE",
"summary": "Google Drive API made easy.",
"version": "1.3.1",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "b85a3e7e5963320a43778f35d68e9972",
"sha256": "5b94e971430722eb5c40a090f21df46b32e51399d747c1511796f63f902d1095"
},
"downloads": -1,
"filename": "PyDrive-1.3.1-py2-none-any.whl",
"has_sig": false,
"md5_digest": "b85a3e7e5963320a43778f35d68e9972",
"packagetype": "bdist_wheel",
"python_version": "2.7",
"requires_python": null,
"size": 25683,
"upload_time": "2016-10-24T20:48:39",
"upload_time_iso_8601": "2016-10-24T20:48:39.976841Z",
"url": "https://files.pythonhosted.org/packages/6b/2d/c8e052ba51099faee0bfe71d84f35bb1576e6910483cad46b840a122ca6c/PyDrive-1.3.1-py2-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "99c51a87c22edaed718b1bc8d00058e9",
"sha256": "83890dcc2278081c6e3f6a8da1f8083e25de0bcc8eb7c91374908c5549a20787"
},
"downloads": -1,
"filename": "PyDrive-1.3.1.tar.gz",
"has_sig": false,
"md5_digest": "99c51a87c22edaed718b1bc8d00058e9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 987445,
"upload_time": "2016-10-24T20:48:23",
"upload_time_iso_8601": "2016-10-24T20:48:23.530936Z",
"url": "https://files.pythonhosted.org/packages/52/e0/0e64788e5dd58ce2d6934549676243dc69d982f198524be9b99e9c2a4fd5/PyDrive-1.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2016-10-24 20:48:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "googledrive",
"github_project": "PyDrive",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "pydrive"
}