{"id":20224978,"url":"https://github.com/adwaith-rajesh/object-bucket","last_synced_at":"2026-05-11T17:38:10.833Z","repository":{"id":57447600,"uuid":"333479261","full_name":"Adwaith-Rajesh/object-bucket","owner":"Adwaith-Rajesh","description":"A fun and easy way to store python objects.","archived":false,"fork":false,"pushed_at":"2021-06-15T10:42:02.000Z","size":63,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-14T12:05:26.729Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Adwaith-Rajesh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-27T15:49:59.000Z","updated_at":"2021-06-15T10:37:15.000Z","dependencies_parsed_at":"2022-09-15T22:12:17.945Z","dependency_job_id":null,"html_url":"https://github.com/Adwaith-Rajesh/object-bucket","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adwaith-Rajesh%2Fobject-bucket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adwaith-Rajesh%2Fobject-bucket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adwaith-Rajesh%2Fobject-bucket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Adwaith-Rajesh%2Fobject-bucket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Adwaith-Rajesh","download_url":"https://codeload.github.com/Adwaith-Rajesh/object-bucket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241663488,"owners_count":19999325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T07:10:14.689Z","updated_at":"2026-05-11T17:38:10.803Z","avatar_url":"https://github.com/Adwaith-Rajesh.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Testing](https://github.com/Adwaith-Rajesh/object-bucket/workflows/Testing/badge.svg)\n![Pypi-Upload](https://github.com/Adwaith-Rajesh/object-bucket/workflows/Pypi-Upload/badge.svg)\n# Object Bucket\nAn easy and fun way to store python objects.\n\n____\n\n## Table of contents\n  - [Description](#DESCRIPTION)\n  - [Installation](#INSTALLATION)\n  - [Usage](#USAGE)\n\n\n___\n## Description\nObject Bucket is a python package that allows you to store python objects permanently in a more user friendly way.\n\n___\n## Installation\n\nThe object-bucket package can be installed by using pip.\n```bash\npip install object-bucket\n```\n\n___\n## Usage\n\n  - ### Creating new bucket.\n  ```python\n  from object_bucket import Bucket\n\n  test_bucket = Bucket(\"name-of-the-bucket\")\n  ```\n  - Adding droplets to the bucket, droplets are considered as objects that you want to save permanently.\n\n  ```python\n  test_obj = [1, 2, 3, 4]\n  test_bucket.add_droplet(\"droplet-name\", test_obj)\n  ```\n  Trying to add a droplet with the same name will cause an error.\n\n  - Adding multiple droplets.\n  To add multiple droplets you have to have a dictionary that contains all the names and objects of the droplet.\n  To add the dictionary you can use the ```add_droplets``` method.\n  ```python\n  droplets = {\n        \"one\": 1,\n        \"two\": 2,\n        \"three\": [2, 3, 4]\n    }\n\n    test_bucket.add_droplets(droplets)\n  ```\n\n  - ### Modifying a droplet\n  ```python\n  new_obj = {1: \"a\"}\n  test_bucket.modify_droplet(\"droplet-name\", new_obj)\n  ```\n  Trying to modify a droplet that does not exists will cause an error.\n\n  - ### Saving a bucket\n  All the things mentioned above will not be added or saved permanently, to do so it is necessary to save the bucket.\n  ```python\n  test_bucket.save_bucket()\n  ```\n - ### Retrieving values from a bucket.\n ```python\n from object_bucket import Bucket\n test_bucket = Bucket(\"name-of-the-bucket\")\n a = test.bucker.get_droplet(\"droplet-name\")\n print(a)  # {1: \"a\"}\n\n ```\n Trying to get a droplet that does not exists will cause an error.\n\n - Get all the runtime droplets\n ```python\n drop1 = [1, 2, 3, 4]\n drop2 = \"Hello\"\n drop3 = {1: \"a\", 2: \"b\"}\n test_bucket.add_droplet(\"drop1\", drop1)\n test_bucket.add_droplet(\"drop2\", drop2)\n test_bucket.add_droplet(\"drop3\", drop3)\n\n # to get all the droplets\n a = test_bucket.get_all_droplets()\n print(a)\n\n # output\n {\"drop1\": [1, 2, 3, 4], \"drop2\": \"Hello\", \"drop3\": {1: \"a\", 2: \"b\"}}\n ```\n - Deleting a bucket\n To delete the bucket and to clear the runtime storage of all the droplets.\n ```python\n test_bucket.delete_bucket()\n ```\n  - You can also delete a bucket using ```remove_bucket``` function\n  ```python\n  from object_bucket import remove_bucket\n  remove_bucket(\"name-of_bucket_to_be_removed\")\n  ```\n\n ## Using the context manager.\n It might be a hastle to remember to save to bucket, so you can use the context manager to avoid using the ```save_bucket``` method.\n\n **Note**: Using ```Bucket().delete_bucket``` inside the context manager is useless as at the end the file will be saved automatically.\n\n ```python\n from object_bucket import Bucket\n\n with Bucket(\"name-of-the-bucket\") as b:\n   # code to execute\n   b.add_droplet(\"name\", 1)\n   # ...etc\n   b.delete_bucket()  # wont work as the file will be again saved,\n   # but the runtime contents will be cleared\n ```\n\n ## Some more stuff\n\n  - You can use the if statement to check whether a bucket is empty or not\n  ```python\n  from object_bucket import Bucket\n  t = Bucket(\"name\")\n  if t:\n    print(\"Hello\")  # -\u003e does not print anything as bucket is empty\n\n  t.add_droplet(\"demo\", 1)\n  if t:\n    print(\"Hello 2\")  # -\u003e prints \"hello 2\" as the bucket has at least one droplet\n  ```\n\n  - To get the number of droplets in a bucket you can use the ```len``` method\n  ```python\n  from object_bucket import Bucket\n  t = Bucket(\"name\")\n  print(len(t)) # -\u003e 0\n  t.add_droplet(\"demo\", [1, 2, 3])\n  print(len(t)) # -\u003e 1\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadwaith-rajesh%2Fobject-bucket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadwaith-rajesh%2Fobject-bucket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadwaith-rajesh%2Fobject-bucket/lists"}