Metadata-Version: 2.1
Name: chronous
Version: 1.2.1
Summary: Library for Event-Driven architecture using asyncio.
Home-page: https://github.com/Lapis0875/Chronous
Author: Lapis0875
Author-email: lapis0875@kakao.com
License: MIT
Keywords: Event-Driven architecture,EDD,async,asynchronous,asyncio
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Requires-Dist: colorama (>=0.4.3)
Requires-Dist: colorlog (>=4.2.1)

===============
Chronous
===============
|py_ver| |issues|

|pypi_ver| |pypi_license| |pypi_package| |pypi_status|

|discord|

**Chronous** is a asynchronous python library designed to make asynchronous event-driven architectures on discord.py

.. |py_ver| image:: https://img.shields.io/pypi/pyversions/chronous?label=Python%20Version&logo=python&logoColor=yellow
   :target: https://python.org
.. |issues| image:: https://img.shields.io/github/issues/Lapis0875/Chronous?logo=github&logoColor=white
    :target: https://github.com/Lapis0875/Chronous/issues
.. |pypi_ver| image:: https://img.shields.io/pypi/v/chronous?logo=pypi&logoColor=blue
    :target: https://pypi.org/project/chronous/
.. |pypi_license| image:: https://img.shields.io/pypi/l/chronous?logo=pypi&logoColor=blue
    :target: https://github.com/Lapis0875/Chronous/blob/master/LICENSE
.. |pypi_package| image:: https://img.shields.io/pypi/format/chronous?label=package&logo=pypi
   :target: https://pypi.org/project/chronous/
.. |pypi_status| image:: https://img.shields.io/pypi/status/chronous?color=blue&logo=pypi&logoColor=blue
    :target: https://pypi.org/project/chronous/
.. |discord| image:: https://img.shields.io/discord/622434051365535745?color=blue&label=Discord&logo=Discord&logoColor=White
   :target: https://discord.gg/taVq6rw

[Example]

.. code-block:: python

  import asyncio
  from typing import NoReturn
  import datetime
  from chronous.Architecture import BaseArchitecture
  from chronous.events import EventContext, Setup, Init, Start, Close

  class SampleArchitecture(BaseArchitecture):

    def __init__(self) -> None:
      super(SampleArchitecture, self).__init__(name="sample")

      # Registering events
      self.register_event(event=Setup())
      self.register_event(event=Init())
      self.register_event(event=Start())
      self.register_event(event=Close())

    def run(self) -> None:
      # Registering default lifecycle events
      # Start process.
      print("Starting process...")
      asyncio.run(self.process())

    async def process(self) -> NoReturn:
      await self.dispatch("setup")
      await self.dispatch("init")
      print('='*20)
      await self.dispatch("start", datetime.datetime.now())
      index: int = 0
      while index < 10:
        print("Looping!")
        index += 1
      await self.dispatch("close")
      print('='*20)


  sample = SampleArchitecture()

  # Multiple listener sample
  @sample.listen()
  async def setup(ec: EventContext):
    print("{e.name} phase - listener 1".format(e=ec.event))


  @sample.listen()
  async def setup(ec: EventContext):
    print("{e.name} phase - listener 2".format(e=ec.event))


  # EventContext  sample
  @sample.listen()
  async def init(ec: EventContext):
    print("Initialization phase")
    print("Event : {e}".format(e=ec.event))


  # Additional arguments sample
  @sample.listen()
  async def start(ec: EventContext, time: datetime):
    print("Starting process...")
    print("Starting at : {time}".format(time=time))


  # Exception sample
  @sample.listen()
  async def close(ec: EventContext):
    print("Closing process...")
    print(f"Make an error : {1/0}")

  sample.run()



