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第三方库


热门话题
JAVAutil。整数java的扫描器键盘输入   java通知运行后立即崩溃   java如何在一个只能由类修改而不能由其实例修改的类中生成静态变量?   数据库Java字段猜测   返回值周围的java括号为什么?   java Android更新通讯录中的联系人   一个消费者正在读取数据   java是否可以通过编程方式为蓝牙配对设置pin?   java Spring引导和buildResponseEntity()   java为什么序列化可以在没有实现可序列化的情况下工作   Java同步无助于相互排斥   twitter Java Twitter4J未在推文下显示源标签   为什么Javasocket不支持中断处理?