Translate python objects to bytes.
Project description
Byte Converter
Installation
Install python with version >= 3.6 and pip.
Install package with
python3 -m pip install --upgrade byte-converter --user
Usage
Basic types
from byte_converter import to_bytes, read_bytes
int_bytes = to_bytes(int(input("Write a number: ")))
dict_bytes = to_bytes({"a": 13 * 2, "b": "asdf"})
Own object
from byte_converter import to_bytes, read_bytes
class User:
bc_ignore_attributes = ["this_attribute_will_be_ignored"] # you can use regex also
this_attribute_will_be_ignored = 13
def __init__(self, username, password):
self.username = username
self.password = password
user = User(input("username: "), input("password: "))
user_in_bytes = to_bytes(user)
user = read_bytes(user_in_bytes, parsable_classes=[User])
If you wan't to read objects, you must set a parsable_classes
argument for reading with a list of readable classes.
Ignore or whitelist attributes
Set the bc_ignore_attributes
attribute to a list of name of attributes, which will be ignored. (You can use regex).
Set the bc_whitelisted_attributes
attribute to a list of name of attributes. Only these attributes will be saved and all other attributes will be ignored, if you set this attribute to a list.
Parsable types
These types are parsable
NoneType
bool
int
float
str
list
dict
- Own objects (no built-in objects)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
byte_converter-0.1.2.tar.gz
(4.3 kB
view hashes)