def __init__(self, **kwargs):
# these fields are required in every feed descriptor
self.required = ["name", "display_name",
"summary", "tech_data", "provider_url"]
self.optional = ["category", "icon", "version", "icon_small"]
self.noemptystrings = ["name", "display_name", "summary", "tech_data", "category"]
self.data = kwargs
# if they are present, set the icon fields of the data to hold
# the base64 encoded file data from their path
for icon_field in ["icon", "icon_small"]:
if icon_field in self.data and os.path.exists(self.data[icon_field]):
icon_path = self.data.pop(icon_field)
try:
self.data[icon_field] = base64.b64encode(open(icon_path, "rb").read())
except Exception, err:
raise CbIconError("Unknown error reading/encoding icon data: %s" % err)
评论列表
文章目录