semvec/pypi-packages huggingface dataset:
verity 0.1
Simple way to validate/cast incoming JSON data.
License: MIT


Verity
======

QuickStart
----------

.. code-block:: python

   from datetime import datetime
   from verity import Type, field

   def parse_date(value):
       return datetime.strptime(value, '%Y-%m-%d').date()

   class Person(Type):
       name = field(str)
       birthdate = field(parse_date)


.. code-block:: python

   >>> data = {'name': 'Bob', 'birthdate': '1980-12-21'}
   >>> person = Person(data)
   >>> person.birthdate
   datetime.date(1980, 12, 21)

Types are nestable:

.. code-block:: python

   class Food(Type):
       name = field(str)
       energy = field(float)


   class Person(Type):
       name = field(str)
       birthdate = field(parse_date)
       favourite_food = field(Food)


.. code-block:: python

   >>> data = {'name': 'Bob', 'birthdate': '1980-12-21', 'favourite_food': {'name': 'Pizza', 'energy': '1200'}}
   >>> person = Person(**data)
   >>> person.favourite_food.name
   'Pizza'


Types can JSON-ify themselves

.. code-block:: python

   >>> person.__json__()
   {'name': 'Bob', 'birthdate': datetime.date(1980, 12, 21), 'favourite_food': Food()}

Though it's not recurive.

However, it can cooperate with ``json_default``:

.. code-block:: python

   >>> from verity import json
   >>> json.dumps(person)
   '{"birthdate": "1980-12-21", "favourite_food": {"energy": 1200.0, "name": "Pizza"}, "name": "Bob"}'
asyncloop 0.0.1.dev2
A Celery-like event loop with asyncio and no more dependencies
License: MIT
Requires Python: >=3.5
Keywords: asyncio celery event loop

asyncloop
=========
*A Celery-like event loop with `asyncio` and no dependencies*

It runs an ``asyncio`` event loop in a separate thread, drives native coroutines within the loop, and then returns the future in an asynchronous manner. 

Dependency
----------
It requires Python 3.5+.

Installation
------------

::

  $ git clone https://github.com/dgkim5360/asyncloop.git
  $ cd asyncloop
  asyncloop$ python setup.py install

Getting started
---------------

::

  import asyncio as aio

  from asyncloop import AsyncLoop


  # A simple job, which should be a native coroutine
  async def job_to_wait(sleep_sec):
      await aio.sleep(sleep_sec)
      return sleep_sec


  # A simple callback
  def callback(fut):
      if fut.cancelled():
          print('CANCELLED:', fut)
      elif fut.done():
          print('DONE:', fut)
	  print('RESULT:', fut.result()


  # AsyncLoop starts
  aloop = AsyncLoop()  # <AsyncLoop(Thread-##, initial)>
  aloop.start()  # <AsyncLoop(Thread-##, started ##########)>

  # Submit a job and be free to work on
  # it returns an AsyncJob object, a simple wrapper of concurrent.Future
  ajob = aloop.submit(job_to_wait(10), callback)
  ajob  # <AsyncJob at 0x####>

  # After 10 seconds the callback activated
  # DONE: <Future at 0x#### state=finished returned int>
  # RESULT: 10

  # Get a result
  ret = ajob.result()  # 10

  # You MUST stop the aloop before exit or destroy
  aloop.stop()  # <AsyncLoop(Thread-##, stopped ##########)>

So far, that's all.