So I am running into an error with the latest docker build from alpine. alpine:3.14.0 was released about a day ago and was trying to install libressl and libressl-dev and both seem to fail with the error below. My work around at the moment was to build using the alpine:3.12.0 as 3.12.0 seems to not have libretls installed. Although I would like to know how to fix this. I tried to remove libretls but that didn't work (error also below). …
我正在开发一个使用大量 xml 的项目,并且想使用 pydantic 来建模对象。在本例中,我简化了 xml,但包含了一个示例对象。
<ns:SomeType name="NameType" shortDescription="some data">
<ns:Bar
thingOne="alpha"
thingTwo="beta"
thingThree="foobar"/>
</ns:SomeType>
Run Code Online (Sandbox Code Playgroud)
代码
from pydantic import BaseModel
from typing import Optional, List
from xml.etree import ElementTree as ET
class Bar(BaseModel):
thing_one: str
thing_two: str
thing_three: str
class SomeType(BaseModel):
name: str
short_description: str
bar: Optional[Bar]
def main():
with open("path/to/file.xml") as fp:
source = fp.read()
root = ET.fromstring(source)
some_type_list = []
for child in root:
st = SomeType(
name=child.attrib["name"],
short_description=child.attrib["shortDescription"],
)
for sub in child:
st.bar = Bar(
thing_one=sub.attrib["thingOne"], …Run Code Online (Sandbox Code Playgroud)