Skip to main content

Framework for converting data to be responsive

Project description

Welcome

build documentation GitHub

codecov CodeFactor CodeScene Code Health DeepSource

Requirements

  • Python installed (recommended: Python >= 3.10)
  • Installed nox with pip install nox

Quickstart (Usage)

For basic usage of the library please read the document (see documentation badge).

from responsive.data import make_responsive
from responsive.observer import OutputObserver

if __name__ == "__main__":
    subject = make_responsive(
        {
            "some_str": "string 1",
            "some_int": 1234567890,
            "some_list": [1, 2, 3, 4, 5, {"inner_str": "string 2"}],
            "some_dict": {"some_other_str": "string 3"},
        }
    )

    subject.add_observer(OutputObserver())

    # changing string field
    subject.some_str = "another string"
    # changing integer field
    subject.some_int = 9876543210
    # changing dictionary in a list
    subject.some_list[-1].inner_str = "just another string"
    # appending a value to a list field
    subject.some_list.append(6)
    # removing a value from a list field
    subject.some_list.remove(3)
    # change value by index
    subject.some_list[2] = 7
    # changing list field to another list
    subject.some_list = [5, 4, 3, 2, 1, 0]
    # changing string field of a nested dictionary
    subject.some_dict.some_other_str = "yet another string"
    # changing dictionary in total
    subject.some_dict = {"some_other_str": "string 4"}
    # changing string field of a nested dictionary (after replacement)
    subject.some_dict.some_other_str = "string 5"

The output looks like following:

subject with id 4371736816 has notified with () and {'id': 4371736816, 'context': <Context.DICTIONARY: 2>, 'name': 'some_str', 'old': 'string 1', 'new': 'another string', 'operation': <Operation.VALUE_CHANGED: 1>}
subject with id 4371736816 has notified with () and {'id': 4371736816, 'context': <Context.DICTIONARY: 2>, 'name': 'some_int', 'old': 1234567890, 'new': 9876543210, 'operation': <Operation.VALUE_CHANGED: 1>}
subject with id 4371736816 has notified with () and {'id': 4371739120, 'context': <Context.DICTIONARY: 2>, 'name': 'inner_str', 'old': 'string 2', 'new': 'just another string', 'operation': <Operation.VALUE_CHANGED: 1>}
subject with id 4371736816 has notified with () and {'id': 4371738496, 'context': <Context.LIST: 3>, 'new': 6, 'operation': <Operation.VALUE_ADDED: 2>}
subject with id 4371736816 has notified with () and {'id': 4371738496, 'context': <Context.LIST: 3>, 'old': 3, 'operation': <Operation.VALUE_REMOVED: 3>}
subject with id 4371736816 has notified with () and {'id': 4371738496, 'context': <Context.LIST: 3>, 'index': 2, 'old': 4, 'new': 7, 'operation': <Operation.VALUE_CHANGED: 1>}
subject with id 4371736816 has notified with () and {'id': 4371736816, 'context': <Context.DICTIONARY: 2>, 'name': 'some_list', 'old': [1, 2, 7, 5, {'inner_str': 'just another string'}, 6], 'new': [5, 4, 3, 2, 1, 0], 'operation': <Operation.VALUE_CHANGED: 1>}
subject with id 4371736816 has notified with () and {'id': 4371737344, 'context': <Context.DICTIONARY: 2>, 'name': 'some_other_str', 'old': 'string 3', 'new': 'yet another string', 'operation': <Operation.VALUE_CHANGED: 1>}
subject with id 4371736816 has notified with () and {'id': 4371736816, 'context': <Context.DICTIONARY: 2>, 'name': 'some_dict', 'old': {'some_other_str': 'yet another string'}, 'new': {'some_other_str': 'string 4'}, 'operation': <Operation.VALUE_CHANGED: 1>}
subject with id 4371736816 has notified with () and {'id': 4371738496, 'context': <Context.DICTIONARY: 2>, 'name': 'some_other_str', 'old': 'string 4', 'new': 'string 5', 'operation': <Operation.VALUE_CHANGED: 1>}

Quickstart (Build)

nox

Interesting Links

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

responsive-data-1.0.4.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

responsive_data-1.0.4-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file responsive-data-1.0.4.tar.gz.

File metadata

  • Download URL: responsive-data-1.0.4.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for responsive-data-1.0.4.tar.gz
Algorithm Hash digest
SHA256 04393240d993042379646be8b0449968d44cf494abbd60f395716eaea25400da
MD5 72c8bc2b8a20e205dc9c0729941b4c63
BLAKE2b-256 22b7278f50de1cd381811535ac75a7e41fa127b4361c988a2f6b35b6991683e8

See more details on using hashes here.

File details

Details for the file responsive_data-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: responsive_data-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for responsive_data-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0a3ab01faeab95465935a9f905fb37d7a0fdeb3b93657a39fa380d47ccab3d29
MD5 55a73e4656b0fffcd7db174c2032b27c
BLAKE2b-256 6ed7a052855640ab2b26d1782ce7e3d577e4620a5163f7348821313d7bb351fc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page