Saravanan666/pypi-org huggingface dataset:
Package: aioexec
aioexecDescriptionAioexec is a simple, intuitive interface around theconcurrent.futurespackage and asyncio'sloop.run_in_executormethod. Aioexec is leightweight, no dependencies and ~100 LOC.Requirementsaioexec requires Python>= 3.7Installpip install aioexecorpipenv install aioexecUsageWithoutaioexecyou usually run an executor something like this:importaysnciofromconcurrent.futuresimportProcessPoolExecutor# ...loop=asyncio.get_event_loop()foo=awaitloop.run_in_executor(ProcessPoolExecutor(1),lambda:my_func(foo='baz'))Withaioexecyou would do the same like this:fromaioexecimportProcs# ...foo=awaitProcs(1).call(my_func,foo='baz')You can pass bothsyncandasyncfunctions to an executor:defmy_sync_func(foo):returnstuff(foo)asyncdefmy_async_func(foo):returnawaitstuff(foo)foo=awaitProcs(1).call(my_sync_func,foo='baz')foo=awaitProcs(1).call(my_async_func,foo='baz')You can call abatchof functions in the same executor like this:importasynciofromaioexecimportProcs,Call# ...my_values=awaitasyncio.gather(*Procs(3).batch(Call(my_func,foo='bar'),Call(my_func,foo='baz'),Call(my_func,foo='qux'),))This plays nicely with comprehensions:my_values=awaitasyncio.gather(*Procs(10).batch(Call(my_func,foo=i)foriinrange(0,10)))You can also spawn apoolin a context and make multiple different calls with the same executor:withProcs(10)aspool:value_a=awaitpool.call(my_func,foo='baz')value_b=awaitaio.gather(*pool.batch(Call(my_func,foo=i)foriinrange(0,10)))# etc...The examples from above work the same forThreads, e.g.:fromaioexecimportThreads# ...foo=awaitThreads(1).call(my_func,foo='baz')If necessary, you can pass an eventloopto the executors like this:foo=awaitThreads(1,my_loop).call(my_func,foo='baz')foo=awaitProcs(1,my_loop).call(my_func,foo='baz')Development / TestingClone the repo and install dev packages:pipenv install --devRun tests:pipenv run python make.py test
Package: aio-executor
aio-executorA concurrent.futures.Executor implementation that runs asynchronous tasks in an asyncio loop.Example usage:fromaio_executorimportAioExecutorasyncdefmy_async_function(arg):# ...withAioExecutor()asaioexec:# single invocationf=aioexec.submit(my_async_function,'foo')result=f.result()# multiple concurrent invocations using "map"results=aioexec.map(my_async_function,['foo','bar','baz'])As a convenience, arun_with_asynciodecorator is also provided. This
decorator runs the decorated async function in aAioExecutorinstance.The example below shows how to implement an async view function for the Flask
framework using this decorator:@app.route('/')@run_with_asyncioasyncdefindex():returnawaitget_random_quote()How to Installpip install aio-executor
Package: aio-exos
WORK IN PROGESSExtreme EXOS asyncio ClientThis repository contains an Extreme EXOS asyncio client, support for both
JSON-RPC and RESTCONF options.For reference on the EXOS JSON-RPC, refer tothis
document.For reference on the EXOS RESTCONF support, refer tothis
document.Device ConfigurationIn order to access the EXOS device via API you must enable the web server
feature using either http or https.enable web http
enable web https    # requires ssl configuration as well.JSON-RPC Usagefromaioexos.jsonrpcimportDevicedev=Device(host='myhostname',username='user',password='Random')show_one=awaitdev.cli('show switch')show_many=awaitdev.cli(['show switch','show version'])# get text instead of JSON/dictshow_text=awaitdev.cli('show switch',text=True)RESTCONF UsageThe RESTCONF API supports only JSON body at this time.  XML is not supported
even though the documentation states that it does.fromaioexos.restconfimportDevicedev=Device(host='myhostname',username='user',password='Random')# login step required for session authenticationawaitdev.login()# execute commands providing the restconf URL, supports all request methods# (GET, POST, etc.)res=awaitdev.get('/openconfig-system:system')# close connection when done with commandsawaitdev.aclose()
Package: aioexponent
aioexponentIf you have problems with the code in this repository, please file an issue or a pull-request. Thanks!Installationpip install aioexponentUsageUse to send push notifications to Exponent Experiences from a Python server.Full documentationon the API is available if you want to dive into the details.Here's an example on how to use this with retries and reporting viapyrollbar.fromaioexponentimportDeviceNotRegisteredErrorfromaioexponentimportPushClientfromaioexponentimportPushMessagefromaioexponentimportPushResponseErrorfromaioexponentimportPushServerErrorfromaiohttpimportClientError# Basic arguments. You should extend this function with the push features you# want to use, or simply pass in a `PushMessage` object.asyncdefsend_push_message(tokens,message,extra=None):client=PushClient()try:response=awaitclient.publish_multiple([PushMessage(to=token,body=message,data=extra)fortokenintokens])exceptPushServerErrorasexc:# Encountered some likely formatting/validation error.rollbar.report_exc_info(extra_data={'tokens':tokens,'message':message,'extra':extra'errors':exc.errors,'response_data':exc.response_data,})raiseexcept(ClientError)asexc:# Encountered some Connection or HTTP error - retry a few times in# case it is transient.rollbar.report_exc_info(extra_data={'tokens':tokens,'message':message,'extra':extra})raiseretry(exc=exc)try:# We got a response back, but we don't know whether it's an error yet.# This call raises errors so we can handle them with normal exception# flows.response.validate_response()exceptDeviceNotRegisteredError:# Mark the push token as inactivefromnotifications.modelsimportPushTokenPushToken.objects.filter(token=token).update(active=False)exceptPushResponseErrorasexc:# Encountered some other per-notification error.rollbar.report_exc_info(extra_data={'tokens':tokens,'message':message,'extra':extra,'push_response':exc.push_response._asdict(),})raiseretry(exc=exc)
Package: aioface
aiofaceaioface is a powerful and simple asynchronous framework for the Facebook Messenger API written in Python 3.7.Installation$pipinstallaiofaceExamplesEcho botfromaiofaceimportBot,Dispatcher,BaseStorage,FacebookRequestdispatcher=Dispatcher(BaseStorage())bot=Bot(webhook_token='your_webhook_token',page_token='your_page_token',dispatcher=dispatcher)@dispatcher.message_handler()asyncdefecho_handler(fb_request:FacebookRequest):awaitfb_request.send_message(message=fb_request.message_text)if__name__=='__main__':bot.run()
Package: aiofauna
title: AioFaunaAioFauna🚀 Introducing aiofauna: A full-stack framework built on top of Aiohttp, Pydantic and FaunaDB.🔥 Inspired by FastAPI focuses on Developer Experience, Productivity and Versatility.🌟 Features:✅ Supports Python 3.7+, comes with an opinionated ODM (Object Document Mapper) out of the box for FaunaDB that abstracts out complex FQL expressions into pythonic, fully typed asynchronous methods for all CRUD operations.✅ Powerful and Scalable: Being built on top of Aiohttp an asyncio based http server/client and FaunaDB an scalable serverless database for modern applications allows for powerful and seamless integrations.✅ Performant: As a framework built on top of Aiohttp it leverages the power of asyncio and the fastest pythonAPIClientbuilt on top of aiohttp with Lazy Loading and session sharing, plus the ubiquiness of FaunaDB to achieve high performance.✅ Automatic Swagger UI generation: Automatic generation of interactive Swagger UI documentation for instant testing of yourAPIServer, exposed at the/docspath.✅ SSE (Server Sent Events): Built-in support for SSE (Server Sent Events) for real-time streaming of data from FaunaDB to your application, syntactic sugar through the@ssedecorator.✅ Websockets: Built-in support for Websockets for real-time bidirectional communication between your application and the resources served by AioFaunaAPIServer, syntactic sugar through the@websocketdecorator.✅ Robust data validation: Utilizes the rich features of Pydantic for data validation and serialization.✅ OX: Thanks torichandaiohttpyou will get rich logging and error handling out of the box.✅ Auto-provisioning: Automatic management of indexes, unique indexes, and collections withFaunaModelODM.✅ Full JSON communication: Focus on your data, don't worry about the communication protocol. YourAPIServerwill receive and return JSON.✅ Inspired by fastapi, you will work with almost the same syntax and features like path operations, path parameters, query parameters, request body, status codes,/docsautomatic interactive API documentation, and decorated view functions and automatic serialization and deserialization of your data.💡 With aiofauna, you can build fast, scalable, and reliable modern applications, avoiding decision fatigue and focusing on what really matters, your data and your business logic.📚 Check out the aiofauna library, and start building your next-gen applications today! 🚀#Python #FaunaDB #Async #Pydantic #aiofauna⚙️ If you are using a synchronous framework check outFaudanticfor a similar experience with FaunaDB and Pydantic.📦PyPi📦Demo📦GitHub📦Documentation
Package: aiofb
aiofbA thin asynchronous Python wrapper for Facebook graph API.This library requires Python 3.5+InstallationUsing pip$pipinstallaiofbBasic usageExampleimportasyncioimportaiofb# initialize Graph APIfb=aiofb.GraphAPI(access_token='YOUR_ACCESS_TOKEN')# Get an event looploop=asyncio.get_event_loop()# Get resultsdata=loop.run_until_complete(fb.get('/{some-endpoint}'))History0.1.0 (2018-04-06)Packege created.0.1.1 (2018-05-17)Clean upFirst release on PyPI0.1.2 (2018-10-02)Return raw python data decoded from json response instead ofaiohttp.ClientResponseobject.0.1.3 (2019-01-11)Change default Messenger user profile fields to name,first_name,last_name and profile_pic
to reflect new Messenger API policy.0.1.3 (2019-02-10)Add method for taking Messebger thread control (messenger.take_thread_control(data, session=None)))
Package: aiofcm
aiofcmis a library designed specifically for sending messages such as push-notifications
to Android devices via Firebase Cloud Messaging platform. aiofcm provides an efficient client
through asynchronous XMPP protocol for use with Python’sasyncioframework.aiofcm requires Python 3.5 or later.PerformanceIn my testing aiofcm allows you to send on average 1k messages per second on a single core.FeaturesInternal connection pool which adapts to the current loadSending notification and/or data messagesAbility to set TTL (time to live) for messagesAbility to set priority for messagesAbility to set collapse-key for messagesInstallationUse pip to install:$ pip install aiofcmBasic Usagefromuuidimportuuid4fromaiofcmimportFCM,Message,PRIORITY_HIGHasyncdefrun():fcm=FCM(123456789000,'<API_KEY>')message=Message(device_token='<DEVICE_TOKEN>',notification={# optional"title":"Hello from Firebase","body":"This is notification","sound":"default"},data={"score":"3x1"},# optionalmessage_id=str(uuid4()),# optionaltime_to_live=3,# optionalpriority=PRIORITY_HIGH,# optional)awaitfcm.send_message(message)loop=asyncio.get_event_loop()loop.run_until_complete(run())Licenseaiofcm is developed and distributed under the Apache 2.0 license.
Package: aio-feedfinder2
This is an asynchronous Python library for finding links feeds on a website.It is based on the synchronous (requestsbased)feedfinder2, written byDan Foreman-Mackey, which is based onfeedfinder- originally
written byMark Pilgrimand subsequently maintained byAaron Swartzuntil his untimely death.UsageFeedfinder2 offers a single public function:find_feeds. You would use it
as following:import asyncio
from aio_feedfinder2 import find_feeds

loop = asyncio.get_event_loop()
task = asyncio.ensure_future(find_feeds("xkcd.com"))
feeds = loop.run_until_complete(future)Now,feedsis the list:['http://xkcd.com/atom.xml','http://xkcd.com/rss.xml']. There is some attempt made to rank feeds from
best candidate to worst but… well… you never know.Thisasynciovariant is ideally suited to find feeds on multiple domains/
sites in an asynchronous way:import asyncio
from aio_feedfinder2 import find_feeds

loop = asyncio.get_event_loop()
tasks = [find_feeds(url) for url in ["xkcd.com", "abstrusegoose.com"]]
feeds = loop.run_until_complete(asyncio.gather(*tasks))

>>> feeds
... [
...     ['http://xkcd.com/atom.xml', 'http://xkcd.com/rss.xml'],
...     ['http://abstrusegoose.com/feed.xml', 'http://abstrusegoose.com/atomfeed.xml']
... ]LicenseFeedfinder2 is licensed under the MIT license (see LICENSE).
Package: aiofiledol
aiofiledolaiofile (async filesys operations) with a simple (dict-like or list-like) interfaceTo install:pip install aiofiledolGet the bytes contents of the file k.>>>importos>>>fromaiofiledolimportAioFileBytesReader>>>filepath=__file__>>>dirpath=os.path.dirname(__file__)# path of the directory where I (the module file) am>>>s=AioFileBytesReader(dirpath,max_levels=0)>>>>>>####### Get the first 9 characters (as bytes) of this module #####################>>>t=awaits.aget(filepath)>>>t[:14]b'import asyncio'>>>>>>####### Test key validation #####################>>>awaits.aget('not_a_valid_key')# this key is not valid since not under the dirpath folderTraceback(mostrecentcalllast):...filesys.KeyValidationError:'Key not valid (usually because does not exist or access not permitted): not_a_valid_key'>>>>>>####### Test further exceptions (that should be wrapped in KeyError) #####################>>># this key is valid, since under dirpath, but the file itself doesn't exist (hopefully for this test)>>>non_existing_file=os.path.join(dirpath,'non_existing_file')>>>try:...awaits.aget(non_existing_file)...exceptKeyError:...print("KeyError (not FileNotFoundError) was raised.")KeyError(notFileNotFoundError)wasraised.Set the contents of filekto be some bytes.>>>fromaiofiledolimportAioFileBytesPersister>>>fromdol.filesysimportmk_tmp_dol_dir>>>importos>>>>>>rootdir=mk_tmp_dol_dir('test')>>>rpath=lambda*p:os.path.join(rootdir,*p)>>>s=AioFileBytesPersister(rootdir)>>>k=rpath('foo')>>>ifkins:...dels[k]# delete key if present...>>>n=len(s)# number of items in store>>>awaits.asetitem(k,b'bar')>>>assertlen(s)==n+1# there's one more item in store>>>assertkins>>>assert(awaits[k])==b'bar'
Package: aiofiles38
aiofilesis an Apache2 licensed library, written in Python, for handling local
disk files in asyncio applications.Ordinary local file IO is blocking, and cannot easily and portably made
asynchronous. This means doing file IO may interfere with asyncio applications,
which shouldn’t block the executing thread. aiofiles helps with this by
introducing asynchronous versions of files that support delegating operations to
a separate thread pool.asyncwithaiofiles.open('filename',mode='r')asf:contents=awaitf.read()print(contents)'My file contents'Asynchronous iteration is also supported.asyncwithaiofiles.open('filename')asf:asyncforlineinf:...Featuresa file API very similar to Python’s standard, blocking APIsupport for buffered and unbuffered binary files, and buffered text filessupport forasync/await(PEP 492) constructsInstallationTo install aiofiles, simply:$pipinstallaiofilesUsageFiles are opened using theaiofiles.open()coroutine, which in addition to
mirroring the builtinopenaccepts optionalloopandexecutorarguments. Ifloopis absent, the default loop will be used, as per the
set asyncio policy. Ifexecutoris not specified, the default event loop
executor will be used.In case of success, an asynchronous file object is returned with an
API identical to an ordinary file, except the following methods are coroutines
and delegate to an executor:closeflushisattyreadreadallread1readintoreadlinereadlinesseekseekabletelltruncatewritablewritewritelinesIn case of failure, one of the usual exceptions will be raised.Theaiofiles.osmodule contains executor-enabled coroutine versions of
several usefulosfunctions that deal with files:statsendfilerenameremovemkdirrmdirWriting tests for aiofilesReal file IO can be mocked by patchingaiofiles.threadpool.sync_openas desired. The return type also needs to be registered with theaiofiles.threadpool.wrapdispatcher:aiofiles.threadpool.wrap.register(mock.MagicMock)(lambda*args,**kwargs:threadpool.AsyncBufferedIOBase(*args,**kwargs))asyncdeftest_stuff():data='data'mock_file=mock.MagicMock()withmock.patch('aiofiles.threadpool.sync_open',return_value=mock_file)asmock_open:asyncwithaiofiles.open('filename','w')asf:awaitf.write(data)mock_file.write.assert_called_once_with(data)History0.4.0 (2018-08-11)Python 3.7 support.Removed Python 3.3/3.4 support. If you use these versions, stick to aiofiles 0.3.x.0.3.2 (2017-09-23)The LICENSE is now included in the sdist.#310.3.1 (2017-03-10)Introduced a changelog.aiofiles.os.sendfilewill now work if the standardosmodule contains asendfilefunction.ContributingContributions are very welcome. Tests can be run withtox, please ensure
the coverage at least stays the same before you submit a pull request.
Package: aiofilesearch
# 🤙 Aio File Search 😂 #hackyhollidays## AioHTTP + Preact + Parcel + WebsocketsSearch your local files through a Browser interfaceThis is just a demo project on how to integrate WS Streaming responsesinto a Preact Web App.## Install``` pip install aiofilesearch ```## Run``` fsearch ```* You need to have installed The silver search, and sublime if you wantto open results with it.## Interesting Parts- The front side uses preact + parcel bundler. So easy to start!- The backend part uses asyncio subprocess to launch the ag command and start searching- Results are streamded from the ag command to the websocket frontend.## Todo- Add configuration params## Screenshot![alt text](https://github.com/jordic/aiofsearch/raw/master/assets/screenshot.png "Screenshot")
Package: aiofiles-ext
aiofiles is an Apache2 licensed library, written in Python, for handling local
disk files in asyncio applications.Ordinary local file IO is blocking, and cannot easily and portably made
asynchronous. This means doing file IO may interfere with asyncio applications,
which shouldn’t block the executing thread. aiofiles helps with this by
introducing asynchronous versions of files that support delegating operations to
a separate thread pool.asyncwithaiofiles.open('filename',mode='r')asf:contents=awaitf.read()print(contents)'My file contents'Or, using the old syntax:f=yield fromaiofiles.open('filename',mode='r')try:contents=yield fromf.read()finally:yield fromf.close()print(contents)'My file contents'Featuresa file API very similar to Python’s standard, blocking APIsupport for buffered and unbuffered binary files, and buffered text filessupport for async/await (PEP 492) constructsInstallationTo install aiofiles, simply:$pipinstallaiofilesUsageFiles are opened using theaiofiles.open()coroutine, which in addition to
mirroring the builtinopenaccepts optionalloopandexecutorarguments. Ifloopis absent, the default loop will be used, as per the
set asyncio policy. Ifexecutoris not specified, the default event loop
executor will be used.In case of success, an asynchronous file object is returned with an
API identical to an ordinary file, except the following methods are coroutines
and delegate to an executor:closeflushisattyreadreadallread1readintoreadlinereadlinesseekseekabletelltruncatewritablewritewritelinesIn case of failure, one of the usual exceptions will be raised.Theaiofiles.osmodule contains executor-enabled coroutine versions of
several usefulosfunctions that deal with files:statsendfileLimitations and Differences from the Builtin File APIWhen using Python 3.5 or greater, aiofiles file objects can be used as
asynchronous context managers. Asynchronous iteration is also supported.asyncwithaiofiles.open('filename')asf:asyncforlineinf:...When using Python 3.3 or 3.4, be aware that the closing of a file may block,
and yielding from a coroutine while exiting from a context manager isn’t
possible, so aiofiles file objects can’t be used as (ordinary, non-async)
context managers. Use thetry/finallyconstruct from the introductory
section to ensure files are closed.When using Python 3.3 or 3.4, iteration is also unsupported. To iterate over a
file, callreadlinerepeatedly until an empty result is returned. Keep in
mindreadlinedoesn’t strip newline characters.f=yield fromaiofiles.open('filename')try:whileTrue:line=yield fromf.readline()ifnotline:breakline=line.strip()...finally:yield fromf.close()ContributingContributions are very welcome. Tests can be run withtox, please ensure
the coverage at least stays the same before you submit a pull request.
Package: aioflask
aioflaskFlask 2.x running on asyncio!Is there a purpose for this, now that Flask 2.0 is out with support for async
views? Yes! Flask's own support for async handlers is very limited, as the
application still runs inside a WSGI web server, which severely limits
scalability. With aioflask you get a true ASGI application, running in a 100%
async environment.WARNING: This is an experiment at this point. Not at all production ready!Quick startTo use async view functions and other handlers, use theaioflaskpackage
instead offlask.Theaioflask.Flaskclass is a subclass offlask.Flaskthat changes a few
minor things to help the application run properly under the asyncio loop. In
particular, it overrides the following aspects of the application instance:Theroute,before_request,before_first_request,after_request,teardown_request,teardown_appcontext,errorhandlerandcli.commanddecorators accept coroutines as well as regular functions. The handlers all
run inside an asyncio loop, so when using regular functions, care must be
taken to not block.The WSGI callable entry point is replaced with an ASGI equivalent.Therun()method uses uvicorn as web server.There are also changes outside of theFlaskclass:Theflask aioruncommand starts an ASGI application using the uvicorn web
server.Therender_template()andrender_template_string()functions are
asynchronous and must be awaited.The context managers for the Flask application and request contexts are
async.The test client and test CLI runner use coroutines.ExampleimportasynciofromaioflaskimportFlask,render_templateapp=Flask(__name__)@app.route('/')asyncdefindex():awaitasyncio.sleep(1)returnawaitrender_template('index.html')
Package: aioflock
aioflock: file lock support for asyncio (based on fcntl.flock)==================================.. image:: https://coveralls.io/repos/kolko/aioflock/badge.svg?branch=master&service=github:target: https://coveralls.io/github/kolko/aioflock?branch=master.. image:: https://travis-ci.org/kolko/aioflock.svg?branch=master:target: https://travis-ci.org/kolko/aioflockExample:.. code-block:: pythonfrom aioflock import LockFilenamelock = LockFilename('/tmp/test_lock')yield from lock.acquire()..inside lock..lock.release()With stategment:.. code-block:: pythonfrom aioflock import LockFilenamewith (yield from LockFilename('/tmp/test_lock')):..inside lock..Can use timeout:.. code-block:: pythonfrom aioflock import LockFilename, LockFilenameTimeouttry:with (yield from LockFilename('/tmp/test_lock')):with (yield from LockFilename('/tmp/test_lock', timeout=1)):...newer here...except LockFilenameTimeout:...here...