Helper class for (de)serialization of objects using Apache Avro
Project description
AvroObject’s documentation!
Links
Examples
AvroObject
class avro_object.AvroObject(data, schema=None)
Helper class for AVRO objects
-
Parameters
-
data (JSON as string*, Dict object, Filename/URL as string with JSON content, *Avro as bytes with binary serialized content) – (un)serialized data
-
schema (JSON as string*, Dict object, *Filename/URL as string with JSON content) – Avro schema
-
property data()
-
Returns
Native unserialized data
-
Return type
dict
property json()
-
Returns
JSON serialized data
-
Return type
str
property last_error()
-
Returns
Last error message
-
Return type
str
property ok()
-
Returns
Avro Object successfull creation
-
Return type
bool
property origin()
-
Returns
Source of data (str, file, URL, Avro binary)
-
Return type
str
property schema_origin()
-
Returns
Source of schema (str, file, URL)
-
Return type
str
to_avro()
-
Returns
AVRO bytes serialized data (when schema is informed)
-
Return type
bytes
to_json()
-
Returns
JSON serialized data
-
Return type
str
AvroTools
class avro_object.AvroTools()
Tools for AvroObject
classmethod add_fetch_method(method)
Add custom fetch method
-
Parameters
method – (str source) -> (bool Success, str JSON/Error, str origin name)
-
Returns
Success
-
Return type
bool
static create_schema(data: dict, name: str, namespace: str = 'namespace.test', doc: str = None)
Create schema from object (incomplete)
-
Parameters
-
data – source object
-
name – Name of schema
-
namespace – Namespace of schema
-
doc – Documentation
-
-
Returns
Schema
-
Return type
dict
classmethod fetch_json(source: str)
Load JSON string from various medium and returns as string
-
Parameters
source – string JSON, file name, URL, another registered source by add_fetch_method
-
Return type
tuple (bool Success, str JSON or error message, origin)
static fetch_json_file(source: str)
Try to parse json from file
-
Parameters
source – str with file name
-
Returns
(bool Success, str JSON or Error, origin)
static fetch_json_url(source: str)
Try to parse json from url
-
Parameters
source – str with URL
-
Returns
(bool Success, str JSON or Error, origin)
classmethod reset_fetch_methods()
Resets default fetch methods (File, URL and string)
Author
©2019, Guionardo Furlan
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file avro-object-furlan-0.9.1.tar.gz
.
File metadata
- Download URL: avro-object-furlan-0.9.1.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36a59f7a22947bd103bd765c6ed7b831f08500620bcd7f8ad0d61c75bcad1e50 |
|
MD5 | 811f584794c4b9fad43638b9f0c67d4d |
|
BLAKE2b-256 | c8d466f2e9bffbecc4349daf7d44085f46a1a4eaff393ffb4bc6455400cfbc9c |
File details
Details for the file avro_object_furlan-0.9.1-py3-none-any.whl
.
File metadata
- Download URL: avro_object_furlan-0.9.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | abd2165ac5eea1933c92d7d440da2a855d9b3099a1317a3a444b9ab5ceea952e |
|
MD5 | d9444a3a269925553751d7ea57bcb5b2 |
|
BLAKE2b-256 | 084a3c7197c2324cc1621e9565dbf3d832bea47de120a3ec4ddf3520aa770d4a |