semvec/pypi-packages huggingface dataset:
eventTracker 0.0.5
Testing installation of Package
License: MIT

# Event Tracker 

<b>Library for tracking events from the server side.</b>

<b>This event tracker reports events to a Kinesis Firehose stream.</b> 
<b>Please make sure a DeliveryStreamName is set as value for the environment variable</b> <b>ANALYTICS_DELIVERY_STREAM_NAME</b>


<b>Use pip to install:</b>

<b>pip install -U @viewlift/event-tracker-pip`</b>

# Usage
<b>To save the signup event of the user, Send the following params -</b>

<b>event - Original event passed to the signup lambda event</b>

<b>customEvent - {

    eventName: 'SIGNUP',

    eventType: 'IDENTITY',

    userId,

    site

}</b>

<b>context - Context object of the signup lambda</b>

<b>eventType in customEvent can be any of the following values: 'IDENTITY', 'SUBSCRIPTION', 'USER', 'BILLING'. To use a new value, Add it to the validation file in the package).</b>

<b>Send clientEmail param in customEvent if the request is from Viewlift Tools.</b>

<b>Call the function</b>

<b>eventTracker.saveUserEvents(event,customEvent,context)</b>
santic-validation 0.0.5
Sanic pydantic validation
License: MIT

Sanic Pydantic Validation
=========================

.. start-badges

.. list-table::
    :widths: 15 85
    :stub-columns: 1
    
    * - Build
      - | |Tox|
    * - Package
      - | |PyPI| |PyPI version| |Code style black|

.. |Tox| image:: https://github.com/weiztech/santic-validation/actions/workflows/python-package.yml/badge.svg?branch=main
   :target: https://github.com/weiztech/santic-validation/actions/workflows/python-package.yml
.. |PyPI| image:: https://img.shields.io/pypi/v/santic-validation.svg
   :target: https://pypi.python.org/pypi/santic-validation/
.. |PyPI version| image:: https://img.shields.io/pypi/pyversions/santic-validation.svg
   :target: https://pypi.python.org/pypi/santic-validation/
.. |Code style black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/ambv/black

.. end-badges

Tools for help developers working with Sanic and Pydantic.

Features
--------

- validate_schema
- async_validate_by_method
- SanticModel
- `MethodType` Field

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

::

 pip install santic-validation


Usage
------------

::

 from typing import Optional
 from pydantic import BaseModel, Field
 from santic_validation import (
     validate_schema,
     async_validate_by_method,
     SanticModel,
     MethodType,
 )
 
 
 class QueryAddressSchema(BaseModel):
    location: str


 def address_number(value: str):
    return f"Number: {value}"


 def make_address(value: str):
    return f"Address: {value}"


 class AddressSchema(SanticModel):
    number: MethodType[int] = Field(method=address_number)
    address: MethodType[str] = Field(method=make_address)

    @property
    def address_method_params(self):
        query: QueryAddressSchema = self._context.get("query")
        return {"value": f"{self.address} ({query.location})"}

    @property
    def number_method_params(self):
        query: QueryAddressSchema = self._context.get("query")
        return {"value": f"{self.number} ({query.location})"}


 class PlanetSchema(BaseModel):
    name: Optional[str]
    category: int


 sanic_app = Sanic(name="TestingApp")


 def query_category_(category_id):
     return Model.get(id=category_id)


 @sanic_app.route("/post", methods=["POST"])
 @validate_schema(body=BodySchema, query=QuerySchema)
 async def post_handler(request, body, query):

     # validate to make sure category exists
     # if exists, change the body.category value
     async_validate_by_method(
         body,
         {
             "category": {
                 "method": query_category,
                 "params": {"category_id": body.category},
             }
         },
         exceptions=(DoesNotExists,),
     )

     return Text("hello world")
 
 
 @sanic_app.route("/post_address", methods=["POST"])
 @validate_schema(
    body=AddressSchema,
    query=QueryAddressSchema,
    method_replace_value=True,
 )
 async def post_address(request, body, query):
     return json(
         {
             "body": body.dict(),
             "query": query.dict(),
         }
     )