Comments (4)
I'm not sure aliases make sense for custom fields, since you can already give them any name you want.
from mimesis.
Well, almost any. Most names allowed for aliases aren't allowed for custom fields (like emojis and stuff).
from mimesis.
That makes sense if everything is done statically in code.
In my case, things are not static. Here's an example of how I'm using your project:
fieldset = Fieldset()
# file represents an external data source
aliases = json.load(file)
# aliases = { "col 1": "positive_number_under_10"}
fieldset.aliases.update(aliases)
fieldset.register_handlers(
(
("positive_number_under_10", positive_number_under_10),
)
)
data: dict[str, list[Any]] = {}
# columns comes from a database schema
for col in columns:
data[col.name] = fieldset(col.name, i=rows_in_table)
Neither the aliases nor the columns are determined before runtime.
I cannot register the handlers with the column names as they are generally not valid python identifiers.
My (ugly) workaround currently is to make aliases
global and use it in the lookup.
But this seems like a needless workaround since it's just duplicating the aliases feature built into mimesis.
You can see in #1515, you can support aliases and custom handlers by moving a single line of code from _lookup_method to perform.
from mimesis.
I see. I'll merge your PR and release new version later this weekend. Thank you!
from mimesis.
Related Issues (20)
- Add support for additional locales
- Use better color scheme for docs
- Add please connected data support HOT 5
- Add croatian locale HOT 5
- Person date of birth HOT 5
- generic.pyi has incorrect attribute for providers.Cryptographic HOT 1
- Support for secondary addresses
- [Integration] Pytest plugin is outdated HOT 4
- Suppor Fieldset fixture for pytest plugin.
- Codecov reporting wrong coverage information. HOT 8
- factory_boy integration out of the box. HOT 1
- Support python < 3.10 HOT 1
- Remove inappropriate words from your random text selections HOT 3
- Tests that write to files fail in windows
- Duplicate/overwritten test
- 15.1.0: pytest fails onscanning units HOT 5
- Use Markdown for Readme
- Mimesis fails on FreeBSD HOT 1
- Location aware test data HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mimesis.