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@Override   使用BuffereImage加载映像时java高ram使用率   java For循环混乱,为什么不是循环?   java Android网格视图字符串对齐问题   java如何将方法与比较类型的附加功能进行比较?   在Java Swing中放置JSepator后的间隙大小   java如何避免并发访问我的网站中的支付链接   java如何从现有的Unix服务器连接到FTP服务器?   Spring中的java用户相关bean定义   带有scribesjava库的wordpress Woocommerce REST API返回消费者密钥参数缺失错误消息   java我可以自动检测特定设备连接的串行端口吗?   Javafx棋盘游戏   java使用JTextPane显示HTML,支持SVG吗?   SpringBoot如何在java中将映射转换为实体对象?   如何使用java代码对xls文件进行密码保护   Java JPA(EclipseLink)如何在持久化实际实体之前接收下一个生成的值?   Javaservlet启动外部进程