rsundqvist / id-translation

Turn meaningless IDs into human-readable labels.
MIT License
0 stars 0 forks source link

Custom `Format` objects #245

Open rsundqvist opened 7 months ago

rsundqvist commented 7 months ago

Let users pass a callable (derive placeholders based on what has defaults?). How to distinguish from old-style formats in config?

E.g.

def my_format(id, name, is_nice=None) -> str:
    s = f"{id}:{name}"
    if is_nice is not None:
        s += f":{is_nice}"
    return s

Would be equivalent to Format("{id}:{name}[:{is_nice}]").

rsundqvist commented 7 months ago

Effect on complex formats (implicit joins with other tables)?

https://github.com/rsundqvist/id-translation/blob/master/tests/dvdrental/test_complex_format.py