python_perl_storable
NAME
python_perl_storable - распаковывает структуру из формата perl-storable
VERSION
0.1.0
DESCRIPTION
from python_perl_storable import freeze, thaw
class A:
def getX(self):
return self.x
storable_binary_string = freeze({'x': A(x=6), 's': "Здравствуй, Мир!"})
data = thaw(
storable_binary_string,
classes={'A::A': A},
iconv=lambda s: s.decode('windows-1251')
)
print(data) # -> {'x': <__main__.A instance at 0x7f7f532e1050>, 's': "Здравствуй, Мир!"}
print(data['x'].getX()) # -> 6
print(data['s']) # -> Здравствуй, Мир!
SYNOPSIS
В языке perl есть свой формат бинарных данных для упаковки любых структур: хешей, списков, объектов, регулярок, скаляров, файловых дескрипторов, ссылок, глобов и т.п. Он реализуется модулем https://metacpan.org/pod/Storable.
Данный формат довольно популярен и запакованные в бинарную строку данные различных проектов на perl хранятся во внешних хранилищах: mysql, memcached, tarantool и т.д.
Данный змеиный модуль предназначен для распаковки данных, полученных из таких хранилищ, в структуры python и для упаковки данных питона, чтобы поместить их в хранилище.
FUNCTIONS
thaw
ARGUMENTS
- storable - бинарная строка
- classes - словарь с классами. Необязательный параметр
- iconv - функция для конвертации строк не в utf8. Необязательный параметр
freeze
ARGUMENTS
- data - данные питона: строка, число, словарь, список, объект и т.д.
- magic - булево значение. Необязательно. Добавляет к выводу магическое число 'pst0'
RETURNS
Бинарная строка с данными в формате Perl Storable
SCRIPT
# Заморозить-раморозить:
$ echo '[123, "Хай!"]' | pypls freeze | pypls thaw
# Передавать замороженные данные в бинарном виде:
$ echo '[123, "Хай!"]' | pypls freeze -b | pypls thaw -b
# Передавать код в параметре:
$ pypls freeze --data '[123, "Хай!"]' | pypls thaw
# Добавить магическое число и обесцветить замероженную строку:
$ pypls freeze -m -s --data '[123, "Хай!"]' | pypls thaw
# Перекодировать строки (bytes останутся как есть):
$ pypls freeze --data '[123, "Хай!"]' -i cp1251 | pypls thaw -i cp1251
INSTALL
$ pip install python-perl-storable
REQUIREMENTS
- data-printer
- argparse
LICENSE
Copyright (C) Yaroslav O. Kosmina.
This library is free software; you can redistribute it and/or modify it under the same terms as Python itself.
AUTHOR
Yaroslav O. Kosmina darviarush@mail.ru
LICENSE
MIT License
Copyright (c) 2020 Yaroslav O. Kosmina
Metadata
Release files for python-perl-storable 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-perl-storable-0.1.0.tar.gz | 13.0 kB | Without provenance | Details for python-perl-storable-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_perl_storable-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for python_perl_storable-0.1.0-py3-none-any.whl |
Total release size: 25.6 kB
Release files / python-perl-storable-0.1.0.tar.gz
| Download URL | python-perl-storable-0.1.0.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
001637e8b96d5c0bdd74059417582b6c819ac0bbffdec12e43b7aefb43f9b6b3
|
|
BLAKE2b-256 checksum How to use checksums |
51a13da9327dc319a02c719469c2b10308c2dacd7794b71c2e2806f64f5521d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Release files / python_perl_storable-0.1.0-py3-none-any.whl
| Download URL | python_perl_storable-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
93d068df2df1088c7ece447302491eec8f0d0a484a67f3b84a00fa1914218317
|
|
BLAKE2b-256 checksum How to use checksums |
6093b67a5efdf67e863fcd27715a4111517b835dd2ef99e7cc0a276d057ba09c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Security for python-perl-storable 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.