Skip to main content

Immutable builder, carbon copy of lann/builder package in GoLang.

Project description

builder

https://pypi.org/project/immutable-builder/

Carbon copy of https://github.com/lann/builder for making a Python NoSQL query builder.

Installing:

poetry add immutable-builder 

Example:

from i
from pprint import pprint
from typing import Optional

class UserBuilder(Builder):
        """
        The UserBuilder class inherits from Builder and provides specific methods to set the 'name' and 'age' attributes.
        """

        def __init__(self):
            super().__init__()

        def name(self, val: str) -> 'UserBuilder':
            """
            Creates a new UserBuilder with the 'name' attribute set to the provided value.
            """
            return self.set_value("name", val)

        def age(self, val: int) -> 'UserBuilder':
            """
            Creates a new UserBuilder with the 'age' attribute set to the provided value.
            """
            return self.set_value("age", val)


class User:
        """
        The User class represents the structure that the UserBuilder will build.
        """

        def __init__(self, name: Optional[str] = None, age: Optional[int] = None):
            self.name = name
            self.age = age


    # Register the untouched-struct pair
registry.register(UserBuilder(), User())
user_builder = UserBuilder().name("caner").age(25).name("caner2")  # Build a user
user = get_struct(user_builder)  # Convert the untouched to a struct
pprint(user.__dict__)  # Print the user struct's attributes

# Output:
# 
# {'age': 25, 'name': 'caner2'}

Thanks a lot to Lann for the original builder package, this is wonderful.

Not a perfect copy of the library, yet it works! Which is, what python is right? It is fast enough, and it works.

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

untouched-0.1.3.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

untouched-0.1.3-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file untouched-0.1.3.tar.gz.

File metadata

  • Download URL: untouched-0.1.3.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.3 Linux/6.3.5-201.fsync.fc37.x86_64

File hashes

Hashes for untouched-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d665c507c49eea386fbc3824771adabcdb281196bf28eb31deae16b9dcaa874c
MD5 9fa9743d83af37fa2b6942432b7cb019
BLAKE2b-256 8c7a1b46aac8482a8cd747358c0106022973479007280f170340a43d06363081

See more details on using hashes here.

File details

Details for the file untouched-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: untouched-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.3 Linux/6.3.5-201.fsync.fc37.x86_64

File hashes

Hashes for untouched-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 973d1c0e5afce2ebfc8627a1a71fccd997b4ef264ec469bc65c77e7323de1959
MD5 20ef0eb2255e332dda5cdf448af77855
BLAKE2b-256 4e899e69f5e34db7e76e93f65e089470a6ea16e154227f530e0f89db1fd0508f

See more details on using hashes here.

Supported by

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