feed.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:cbapi-python 作者: carbonblack 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号