RubyMarshal
Read and write Ruby-marshalled data. Only basics Ruby data types can be read and written:
float,bool,int,str(mapped torubymarshal.classes.RubyStringif dumped with instance variables),nil(mapped toNonein Python),array(mapped tolist),hash(mapped todict),- symbols and other classes are mapped to specific Python classes.
Installation
pip install rubymarshal
Usage
from rubymarshal.reader import loads, load
from rubymarshal.writer import writes, write
with open('my_file', 'rb') as fd:
content = load(fd)
with open('my_file', 'wb') as fd:
write(fd, my_object)
loads(b"\x04\bi\xfe\x00\xff")
writes(-256)
You can map Ruby types to Python ones:
from rubymarshal.reader import loads
from rubymarshal.classes import RubyObject
class DomainError(RubyObject):
ruby_class_name = "Math::DomainError"
class_mapping = {"Math::DomainError": DomainError}
loads(b'\x04\x08c\x16Math::DomainError', class_mapping=class_mapping)
You can use Ruby's symbols:
from rubymarshal.reader import loads
from rubymarshal.writer import writes
from rubymarshal.classes import Symbol
x = Symbol("test")
dump = writes(Symbol("test"))
y = loads(dump)
assert y is x
Infos
Code is on github: https://github.com/d9pouces/RubyMarshal Documentation is on readthedocs: http://rubymarshal.readthedocs.org/en/latest/ Tests are on travis-ci: https://travis-ci.org/d9pouces/RubyMarshal
Metadata
Release files for rubymarshal 1.2.1
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 | |
|---|---|---|---|---|
| rubymarshal-1.2.1.tar.gz | 12.5 kB | Without provenance | Details |
Release files / rubymarshal-1.2.1.tar.gz
| Download URL | rubymarshal-1.2.1.tar.gz |
|---|---|
| Size | 12.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
63d9e465dcbc74a802a8cb7ca8165cf67307ca4b88fde2a40eb97df31f560b37
|
|
BLAKE2b-256 checksum How to use checksums |
87e34109eb7a79a0db203837abce33206c72e59786c3bf008ec3b4f891aa8e43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1
|
Security for rubymarshal 1.2.1
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.