You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found https://pydantic-xml.readthedocs.io/en/latest/, which allows us to define a data struct (a class) in Python, then read and validate XML into it. This seems like an easy way to load in various XML config files for the CLI.
From the docs:
The following model fields binding:
classProduct(BaseXmlModel):
status: Literal['running', 'development'] =attr() # extracted from the 'status' attributelaunched: Optional[int] =attr() # extracted from the 'launched' attributetitle: str# extracted from the element textclassCompany(BaseXmlModel):
trade_name: str=attr(name='trade-name') # extracted from the 'trade-name' attributewebsite: HttpUrl=element() # extracted from the 'website' element textproducts: List[Product] =element(tag='product') # extracted from the 'website' element
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
I found https://pydantic-xml.readthedocs.io/en/latest/, which allows us to define a data struct (a class) in Python, then read and validate XML into it. This seems like an easy way to load in various XML config files for the CLI.
From the docs:
The following model fields binding:
defines the XML document:
All reactions