google-api-client-python的aiohttp包装器

gaggle的Python项目详细描述


嘎嘎声

基于aiohttp的google api客户端。

google api python客户端需求是因为这个库使用它来 利用prepare+execute模式发现服务并准备请求 在googleapiclient.httprequest中实现。

用法

json

importasyncioimportaiohttpfromgaggleimportClientasyncdefmain():asyncwithaiohttp.ClientSession()assession:drive=Client(session=session,token=access_token,# the following are optional and only required if the access_token is expired and can be refreshedrefresh_token=refresh_token,client_id=client_id,client_secret=client_secret).drive('v3')resp=awaitdrive.files.list(q="parents in 'root'")# resp is an instance of aiohttp.ClientResponseifresp.status==200:data=awaitresp.json()files=data.get('files',[])forobjinfiles:print(obj)if__name__=="__main__":loop=asyncio.get_event_loop()loop.run_until_complete(main())

结果如下:

{'kind': 'drive#file', 'id': '...', 'name': 'test.csv', 'mimeType': 'text/csv'}
{'kind': 'drive#file', 'id': '...', 'name': 'Test Folder', 'mimeType': 'application/vnd.google-apps.folder'}
{'kind': 'drive#file', 'id': '...', 'name': 'spreadsheet.xlsx', 'mimeType': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'}
{'kind': 'drive#file', 'id': '...', 'name': 'spreadsheet', 'mimeType': 'application/vnd.google-apps.spreadsheet'}

安装

$ pip install gaggle

测试和开发

我提供了一个方便的makefile,使这些事情变得相当简单。

$ make setup
$ make test

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JAVA Tictoe Minimax算法不断引发异常   java弹性时间计算器字符串开关   java从表单post操作中检索值   java Selenium webdriver无法在youtube上找到元素   java如何自动填写XFA(PDF)表单?   java为什么我的秒表程序不能运行?   raspberry pi禁用java中的其他声音   java如何配置web。xml,glassfishweb。JSF的xml文件?   使用浏览器运行自动测试时出现java错误。如何运行它?   java如何阻止Swing程序在每次向JTextArea添加文本时调整组件的大小   javajavax。注射注射无效   java如何改进Solaris服务器配置   java如何在elasticsearch后端脱机时处理Hibernate搜索启动   java TCPsocket的延迟很差,除非持续流式传输