mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
2987d93ba7
commit_hash:cf5070a543788fa57136adb1a4a7ea42f4490329
28 lines
680 B
Python
28 lines
680 B
Python
# ruff: noqa: F403, F405
|
|
from typing import Any, Dict
|
|
|
|
from pydivkit.core import Field, Ref
|
|
from pydivkit.div import *
|
|
from pydivkit.div import __all__ as __div_all__
|
|
|
|
|
|
def make_card(log_id: str, *divs: Div) -> DivData:
|
|
return DivData(
|
|
log_id=log_id,
|
|
states=[
|
|
DivDataState(state_id=state_id, div=div) for state_id, div in enumerate(divs)
|
|
],
|
|
)
|
|
|
|
|
|
def make_div(div: Div) -> Dict[str, Any]:
|
|
return {
|
|
"templates": {
|
|
tpl.template_name: tpl.template() for tpl in div.related_templates()
|
|
},
|
|
"card": make_card("card", div).dict(),
|
|
}
|
|
|
|
|
|
__all__ = ("Field", "Ref", "make_card", "make_div") + __div_all__
|