def get_spec_from_release_file(content):
"""Provide specification object describing the component of the distribution
"""
# RegExp to pull a single line "tag: value" pair from a deb822 file
re_deb822_single_line_tag = re.compile("""
^(?P<tag>[a-zA-Z][^:]*):[\ ]+ # Tag - begins at start of line
(?P<val>\S.*)$ # Value - after colon to the end of the line
""", flags=re.VERBOSE + re.MULTILINE)
# Split before PGP signature if present
content = content.split("-----BEGIN PGP SIGNATURE-----")[0]
# Parse the content for tags and values into a dictionary
release = {
match.group("tag"): match.group("val")
for match in re_deb822_single_line_tag.finditer(content)
}
# TODO: redo with conversions of components and architectures in into lists
# and date in machine-readable presentation
return DebianReleaseSpec(**{
a.name: release.get(a.name.title(), None)
for a in attr.fields(DebianReleaseSpec)
})
评论列表
文章目录