semvec/pypi-packages huggingface dataset:
drf-nested-serializer 0.1.0
nested serializer for django-rest-framework
License: MIT
Keywords: drf restframework rest_framework django_rest_framework serializers def_nested_serializer

[![Build Status](https://travis-ci.org/insung151/drf-nested-serializer.svg?branch=master)](https://travis-ci.org/insung151/drf-nested-serializer)
[![Coverage Status](https://coveralls.io/repos/github/insung151/drf-nested-serializer/badge.svg?branch=master)](https://coveralls.io/github/insung151/drf-nested-serializer?branch=master)
# DRF Nested Serializer
Nested Serializer support for Django Rest Framework.

## Installation
```
pip install drf-nested-serializer
```

## Example
```python
class Goods(models.Model):
    name = models.CharField(max_length=10)
    category = models.CharField(max_length=20)

class GoodsImage(models.Model):
    goods = models.ForeignKey(
        Goods,
        related_name='goods_images',
        on_delete=models.CASCADE
    )
    image_key = models.CharField(max_length=10)



class GoodsSerializer(NestedModelSerializer):

    class Meta:
        model = Goods
        fields = '__all__'
        nested_fields = {'goods_images': 'goods'} # {related_name: field_name}
```

The above will allow to create the following queries


```
POST
{
    "name": "string",
    "category: "string",
    "goods_images": [
        {"image_key": "string"},
        {"image_key": "string"},
        {"image_key": "string"}
    ]
}
```
pycp2110 1.0.0
Silabs CP2110 USB HID to UART bridge library
License: MIT

# Silicon Labs cp2110 Python library

This library provides a Python interface to the [Silicon Labs CP2110](https://www.silabs.com/documents/public/data-sheets/CP2110.pdf) HID USB to UART bridge.

At this point in time this library presents only the parts of the [available API](https://www.silabs.com/documents/public/application-notes/AN434-CP2110-4-Interface-Specification.pdf) that are required for basic UART access.

#  cp2110 Installation

Install via pip: `python -m pip install cp2110`.

The cp2110 library depends on the [pyhidapi](https://github.com/apmorton/pyhidapi) Python module, which itself requires the `hidapi` shared library.  On Linux distributions, this is generally in the repositories (for instance, under Debian you can install either libhidapi-hidraw0 or libhidapi-libusb0 depending on which backend you want to use).

# Example usage

```
  import cp2110
  import time

  # This will raise an exception if a device is not found.  Called with no
  # parameters, this looks for the default (VID, PID) of the CP2110, which are
  # (0x10c4, 0xEA80).
  try:
    d = cp2110.CP2110Device()
  except:
    pass

  # In some cases the device maker will override the VID and/or PID at the
  # factory, so you'll need to pass parameters
  try:
    cp2110.CP2110Device(vid=0xDEAD, pid=0xBEEF)
  except:
    pass

  # You can also find a device by path.
  cp2110.CP2110Device(path='/dev/hidraw0')

  # If you want to avoid the exception or want to detect the presence of a
  # device without creating an object as a side-effect, use the
  # `cp2110.enumerate` function.  This has the same default values as the
  # `CP2110Device` constructor.
  usb_info = cp2110.enumerate()
  if usb_info:
    print(usb_info.as_dict())

  usb_info = cp2110.enumerate(vid=0xDEAD, pid=0xBEEF)
  if usb_info:
    print(usb_info.as_dict())

  # Fetch the current uart configuration.  This is the UART connection from the
  # CP2110 to the microcontroller (or whatever) it's wired up to.
  c = d.get_uart_config()

  # The UART settings are dictated by the device that embeds the CP2110.  It
  # may be configured correctly by default, or you may need to set manually.
  d.set_uart_config(UARTConfig(
    baud=38400,
    parity=cp2110.PARITY.NONE,
    flow_control=cp2110.FLOW_CONTROL.DISABLED,
    data_bits=cp2110.DATA_BITS.EIGHT,
    stop_bits=STOP_BITS.SHORT))

  # If you ever need to disable the UART, you can.
  d.disable_uart()

  # And you can clear any pending data in the on-chip I/O buffers.
  d.purge_fifos()  # The default is cp2110.FIFO.BOTH
  d.purge_fifos(cp2110.FIFO.TX)
  d.purge_fifos(cp2110.FIFO.RX)

  # Check if the UART is enabled.
  print(d.is_uart_enabled())

  # The UART in your device may need to be explicitly enabled, particularly if
  # you've already explicitly disabled it as in this example.
  d.enable_uart()

  # The write method accepts byte strings or arrays of ints.
  d.write(b'hello world')
  d.write([0x01, 0xff])

  # The default read size will return 63 bytes (at most), which is the maximum
  # supported by this chip.  Reads do not block.
  rv = d.read()

```