bpylist2


Namebpylist2 JSON
Version 4.1.1 PyPI version JSON
download
home_page
SummaryParse and generate NSKeyedArchiver archives
upload_time2023-09-11 16:58:00
maintainer
docs_urlNone
authorJenia Varavva
requires_python>=3.7,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            bpylist2 |pypi version| |Build Status|
======================================

This is a fork of Marketcircle/bpylist. This one is hopefully more responsive to PRs.

Implementation of the `Apple's Binary
Plist <https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man5/plist.5.html>`__
and the NSKeyedArchiver format

Usage
-----

Binary Plists
~~~~~~~~~~~~~

For reading and writing plain PLists please use stdlib `plistlib` library.

KeyedArchives
~~~~~~~~~~~~~

``NSKeyedArchiver`` is an Apple proprietary serialization format for
Cocoa objects. ``bpylist2`` supports reading and writing
``NSKeyedArchiver`` compatible archives. The API is similar to the
binary plist API.

**Unarchiving an object**

.. code:: python

    from bpylist2 import archiver

    with open('my_archived_object', 'rb') as f:
        archiver.unarchive(f.read())

**Archiving an object**

.. code:: python

    from bpylist2 import archiver

    my_object = { 'foo':'bar', 'some_array': [1,2,3,4] }
    archiver.archive(my_object)

Custom objects
^^^^^^^^^^^^^^

If your archive includes classes that are not "standard" Cocoa classes
(``NSString``, ``NSNumber``, ``NSDate``, ``NSNull``, ``NSDictionary`` or
``NSArray``), you register a Python class that the Cocoa class maps to and
register it.

The simplest way to define a class is by providing a python dataclass, for
example you define a class with all the fields of the archived object:

.. code:: python

    @dataclasses.dataclass
    class MyClass(DataclassArchiver):
        int_field: int = 0
        str_field: str = ""
        float_field: float = -1.1
        list_field: list = dataclasses.field(default_factory=list)

Alternatively you can implement custom unarchiving code.  

The Python class needs to implement the ``encode_archive`` and
``decode_archive`` methods.

.. code:: python

    ## Define a Python Class

    from bpylist2 import archiver

    class MyClass:
        first_property = None
        second_property = None

        def __init__(self, first_property, second_property):
            self.first_property = first_property
            self.second_property = second_property

        def encode_archive(self, archive):
            archive.encode('first_property', self.first_property)
            archive.encode('second_property', self.second_property)

        def decode_archive(archive):
            first = archive.decode('first_property')
            second = archive.decode('second_property')
            return MyClass(first, second)

When the mapper class is defined, register it with unarchiver:

.. code:: python

    ## Register the class for the Cocoa class 'MyCocoaClass'

    archiver.update_class_map({ 'MyCocoaClass': FooArchive })

Implementation Note
-------------------

This package requires the version of `plistlib` included in the Python 3.8 
standard library.  In order to support Python 3.6 and 3.7, a copy of the 
Python 3.8 `plistlib <https://github.com/python/cpython/blob/e51dd9dad6590bf3a940723fbbaaf4f64a3c9228/Lib/plistlib.py>`__ 
is bundled with `bpylist2` (Specifically, commit `9054967 <https://github.com/python/cpython/commit/90549676e063c2c818cfc14213d3adb7edcc2bd5>`__).  
This version will only be used if `bpylist2` detects it is running on Python < 3.8.

How to publish a new version to PyPI
------------------------------------

.. code-block:: bash

    $ pip install twine wheel
    $ python setup.py sdist bdist_wheel
    $ twine upload dist/*

License
-------

MIT License

Copyright (c) 2017 Marketcircle Inc.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

.. |pypi version| image:: https://img.shields.io/pypi/v/bpylist2.svg
   :target: https://pypi.org/project/bpylist2/
.. |Build Status| image:: https://travis-ci.org/parabolala/bpylist2.svg?branch=master
   :target: https://travis-ci.org/parabolala/bpylist2

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "bpylist2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Jenia Varavva",
    "author_email": "fuzzy.parabola@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ca/34/eb90ff6be953f6e4df08d4e8c0b761bea144242b6d711e922113411cc631/bpylist2-4.1.1.tar.gz",
    "platform": null,
    "description": "bpylist2 |pypi version| |Build Status|\n======================================\n\nThis is a fork of Marketcircle/bpylist. This one is hopefully more responsive to PRs.\n\nImplementation of the `Apple's Binary\nPlist <https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man5/plist.5.html>`__\nand the NSKeyedArchiver format\n\nUsage\n-----\n\nBinary Plists\n~~~~~~~~~~~~~\n\nFor reading and writing plain PLists please use stdlib `plistlib` library.\n\nKeyedArchives\n~~~~~~~~~~~~~\n\n``NSKeyedArchiver`` is an Apple proprietary serialization format for\nCocoa objects. ``bpylist2`` supports reading and writing\n``NSKeyedArchiver`` compatible archives. The API is similar to the\nbinary plist API.\n\n**Unarchiving an object**\n\n.. code:: python\n\n    from bpylist2 import archiver\n\n    with open('my_archived_object', 'rb') as f:\n        archiver.unarchive(f.read())\n\n**Archiving an object**\n\n.. code:: python\n\n    from bpylist2 import archiver\n\n    my_object = { 'foo':'bar', 'some_array': [1,2,3,4] }\n    archiver.archive(my_object)\n\nCustom objects\n^^^^^^^^^^^^^^\n\nIf your archive includes classes that are not \"standard\" Cocoa classes\n(``NSString``, ``NSNumber``, ``NSDate``, ``NSNull``, ``NSDictionary`` or\n``NSArray``), you register a Python class that the Cocoa class maps to and\nregister it.\n\nThe simplest way to define a class is by providing a python dataclass, for\nexample you define a class with all the fields of the archived object:\n\n.. code:: python\n\n    @dataclasses.dataclass\n    class MyClass(DataclassArchiver):\n        int_field: int = 0\n        str_field: str = \"\"\n        float_field: float = -1.1\n        list_field: list = dataclasses.field(default_factory=list)\n\nAlternatively you can implement custom unarchiving code.  \n\nThe Python class needs to implement the ``encode_archive`` and\n``decode_archive`` methods.\n\n.. code:: python\n\n    ## Define a Python Class\n\n    from bpylist2 import archiver\n\n    class MyClass:\n        first_property = None\n        second_property = None\n\n        def __init__(self, first_property, second_property):\n            self.first_property = first_property\n            self.second_property = second_property\n\n        def encode_archive(self, archive):\n            archive.encode('first_property', self.first_property)\n            archive.encode('second_property', self.second_property)\n\n        def decode_archive(archive):\n            first = archive.decode('first_property')\n            second = archive.decode('second_property')\n            return MyClass(first, second)\n\nWhen the mapper class is defined, register it with unarchiver:\n\n.. code:: python\n\n    ## Register the class for the Cocoa class 'MyCocoaClass'\n\n    archiver.update_class_map({ 'MyCocoaClass': FooArchive })\n\nImplementation Note\n-------------------\n\nThis package requires the version of `plistlib` included in the Python 3.8 \nstandard library.  In order to support Python 3.6 and 3.7, a copy of the \nPython 3.8 `plistlib <https://github.com/python/cpython/blob/e51dd9dad6590bf3a940723fbbaaf4f64a3c9228/Lib/plistlib.py>`__ \nis bundled with `bpylist2` (Specifically, commit `9054967 <https://github.com/python/cpython/commit/90549676e063c2c818cfc14213d3adb7edcc2bd5>`__).  \nThis version will only be used if `bpylist2` detects it is running on Python < 3.8.\n\nHow to publish a new version to PyPI\n------------------------------------\n\n.. code-block:: bash\n\n    $ pip install twine wheel\n    $ python setup.py sdist bdist_wheel\n    $ twine upload dist/*\n\nLicense\n-------\n\nMIT License\n\nCopyright (c) 2017 Marketcircle Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n.. |pypi version| image:: https://img.shields.io/pypi/v/bpylist2.svg\n   :target: https://pypi.org/project/bpylist2/\n.. |Build Status| image:: https://travis-ci.org/parabolala/bpylist2.svg?branch=master\n   :target: https://travis-ci.org/parabolala/bpylist2\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Parse and generate NSKeyedArchiver archives",
    "version": "4.1.1",
    "project_urls": {
        "homepage": "https://github.com/parabolala/bpylist2"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8be5b552c94fc965153c9dcad4b64202e5170d4918716bc082d4fa6c6230579c",
                "md5": "5fcf1b10c63ae8ab5a898ff5b34adab0",
                "sha256": "4862eab78d9d908d532393208b6771cebc8debef99ab851b54a0a0e28e2bec6b"
            },
            "downloads": -1,
            "filename": "bpylist2-4.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5fcf1b10c63ae8ab5a898ff5b34adab0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 16596,
            "upload_time": "2023-09-11T16:57:59",
            "upload_time_iso_8601": "2023-09-11T16:57:59.526160Z",
            "url": "https://files.pythonhosted.org/packages/8b/e5/b552c94fc965153c9dcad4b64202e5170d4918716bc082d4fa6c6230579c/bpylist2-4.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca34eb90ff6be953f6e4df08d4e8c0b761bea144242b6d711e922113411cc631",
                "md5": "6f284eb91f997cfa0df3b4401aadf49e",
                "sha256": "0cc63284aee42f5c7e0ec87f8f59cdd35aaed05ad12d866b1868ea0c0caaafe1"
            },
            "downloads": -1,
            "filename": "bpylist2-4.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6f284eb91f997cfa0df3b4401aadf49e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 18000,
            "upload_time": "2023-09-11T16:58:00",
            "upload_time_iso_8601": "2023-09-11T16:58:00.758605Z",
            "url": "https://files.pythonhosted.org/packages/ca/34/eb90ff6be953f6e4df08d4e8c0b761bea144242b6d711e922113411cc631/bpylist2-4.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-11 16:58:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "parabolala",
    "github_project": "bpylist2",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "appveyor": true,
    "tox": true,
    "lcname": "bpylist2"
}
        
Elapsed time: 0.11472s