Immutable builder, carbon copy of lann/builder package in GoLang.
Project description
Untouched
https://pypi.org/project/untouched/
https://github.com/DAMACANER/untouched
Carbon copy of https://github.com/lann/builder for making a Python NoSQL query builder.
Installing:
poetry add untouched
Example:
from untouched.builder import Builder, get_struct, T
from untouched.registry import Registry
from typing import Optional
NameDBField: str = "name"
AgeDBField: str = "age"
class UserQueryBuilder(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) -> 'UserQueryBuilder':
"""
Creates a new UserBuilder with the 'name' attribute set to the provided value.
"""
return self.set_value(NameDBField, val)
def age(self, val: int) -> 'UserQueryBuilder':
"""
Creates a new UserBuilder with the 'age' attribute set to the provided value.
"""
return self.set_value(AgeDBField, 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
registry = Registry()
registry.register(UserQueryBuilder(), User())
user_builder = UserQueryBuilder().name("caner").age(25)
print(user_builder.get_builder_map())
# Output:
#
# {'age': 25, 'name': 'caner'}
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file untouched-0.2.7.tar.gz.
File metadata
- Download URL: untouched-0.2.7.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1165c1830bfbfb305a352a8e22a37fcaab3e3ba56e6f5e8eca70d24dd3caba45
|
|
| MD5 |
e6e7c1cf6f08f1243320b0ed2440c63c
|
|
| BLAKE2b-256 |
d5289efed299c502c5f38b5d5d31e0ffc72c35b1a6e9db3493022a94ef5efc9f
|
File details
Details for the file untouched-0.2.7-py3-none-any.whl.
File metadata
- Download URL: untouched-0.2.7-py3-none-any.whl
- Upload date:
- Size: 4.7 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
573dbcbb673b437033fbfb8929520f1267b6f4a29f19556a3aa034f99b8c3810
|
|
| MD5 |
d1fdde2154197072ea571414572d34ea
|
|
| BLAKE2b-256 |
544e61777107cc5cd13afe88548de00f89a5f1690f6ac1b7ce3d03fa1b1f6229
|