Introduction
Small framework to create entities and Builders with Metaprogramming features in Python.
Creating Builders
Metabuilder objective is to help to create Builders and instances or entities with validations easy and fast.
In order to create a new Builder just define a class extending from MetaBuilder class, and defining an stub class in any place you want. For eg.
from PyMetaBuilder import MetaBuilder
#Stub Class to create instances from
class Kite(object):
pass
class KiteBuilder(MetaBuilder):
pass
After that just initiate the superclass and start defining the properties you want KiteBuilder to have, for eg.
class KiteBuilder(MetaBuilder):
def __init__(self):
MetaBuilder.MetaBuilder.__init__(self)
self.defineKite()
def define_kite(self):
#define the model klass to get instances from
self.model(Kite)
self.property("design",one_of=["Indoor","Water Kite","Kythoon"])
self.property("line_material",type=str)
self.property("StringLength",type=int)
You can also define a property as a mandatory one, with the required method. In this way, when you set the builder with the respecting properties and try to get a new instance, the framework will check if the properties that you previously set as mandatory were set.
def define_kite(self):
#define the model klass to get instances from
self.model(Kite)
self.property("StringLength",type=int)
#code defining properties....
self.required("design")
Creating instances from a Builder
After you defined a builder and its properties, just set the parameters, if you want at this time and if they’re not mandatory and build an instance.
kiteBuilder=KiteBuilder() kiteBuilder.design="Indoor" kiteBuilder.StringLength=23 kite=kiteBuilder.build() #get a Kite instance
When you set a property that you previously defined, it’ll validate the value passed, given the fact that you have set it with validators, and will generate the appropriate exception when it fails.
Metadata
Release files for PyMetabuilder 0.2.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| PyMetabuilder-0.2.6.tar.gz | 7.5 kB | Without provenance | Details |
Release files / PyMetabuilder-0.2.6.tar.gz
| Download URL | PyMetabuilder-0.2.6.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c7adaab8f740cab4597ecac878d9b39300efd2840c0b3000b54c2767a80d9e09
|
|
BLAKE2b-256 checksum How to use checksums |
b5462fc9fe03fa8ba315672c4e1e3215b2dce7d36ac36ef9953f0ee5aedbcafd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for PyMetabuilder 0.2.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.