当前位置: 首页>>代码示例>>Python>>正文


Python HashList.to_dict方法代码示例

本文整理汇总了Python中cybox.common.HashList.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python HashList.to_dict方法的具体用法?Python HashList.to_dict怎么用?Python HashList.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cybox.common.HashList的用法示例。


在下文中一共展示了HashList.to_dict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: File

# 需要导入模块: from cybox.common import HashList [as 别名]
# 或者: from cybox.common.HashList import to_dict [as 别名]
class File(DefinedObject):
    _XSI_TYPE = "FileObjectType"
    
    def __init__(self):
        self.is_packed = None
        self.file_name = None
        self.file_path = None
        self.device_path = None
        self.full_path = None
        self.file_extension = None
        self.size_in_bytes = None
        self.magic_number = None
        self.file_format = None
        self.hashes = None

        # Not supported yet:
        # - Digital_Signatures
        # - Modified_Time
        # - Accessed_Time
        # - Created_Time
        # - File_Attributes_List
        # - Permissions
        # - User_Owner
        # - Packer_List
        # - Peak_Entropy
        # - Sym_Links
        # - Extracted_Features
        # - Byte Runs

    @property
    def file_name(self):
        return self._file_name

    @file_name.setter
    def file_name(self, value):
        if value is not None and not isinstance(value, String):
            value = String(value)
        self._file_name = value

    @property
    def file_path(self):
        return self._file_path

    @file_path.setter
    def file_path(self, value):
        if value is not None and not isinstance(value, FilePath):
            value = FilePath(value)
        self._file_path = value

    def add_hash(self, hash_):
        if not self.hashes:
            self.hashes = HashList()
        self.hashes.add(hash_)

    def to_obj(self):
        file_obj = file_binding.FileObjectType()
        file_obj.set_anyAttributes_({'xsi:type' : 'FileObj:FileObjectType'})

        if self.is_packed is not None:
            file_obj.set_is_packed(self.is_packed)
        if self.file_name is not None:
            file_obj.set_File_Name(self.file_name.to_obj())
        if self.file_path is not None:
            file_obj.set_File_Path(self.file_path.to_obj())
        if self.device_path is not None:
            file_obj.set_Device_Path(self.device_path.to_obj())
        if self.full_path is not None:
            file_obj.set_Full_Path(self.full_path.to_obj())
        if self.file_extension is not None:
            file_obj.set_File_Extension(self.file_extension.to_obj())
        if self.size_in_bytes is not None:
            file_obj.set_Size_In_Bytes(self.size_in_bytes.to_obj())
        if self.magic_number is not None:
            file_obj.set_Magic_Number(self.magic_number.to_obj())
        if self.file_format is not None:
            file_obj.set_File_Format(self.file_format.to_obj())
        if self.hashes is not None:
            file_obj.set_Hashes(self.hashes.to_obj())

        return file_obj

    def to_dict(self):
        file_dict = {}

        if self.is_packed is not None:
            file_dict['is_packed'] = self.is_packed,
        if self.file_name is not None:
            file_dict['file_name'] = self.file_name.to_dict()
        if self.file_path is not None:
            file_dict['file_path'] = self.file_path.to_dict()
        if self.device_path is not None:
            file_dict['device_path'] = self.device_path.to_dict()
        if self.full_path is not None:
            file_dict['full_path'] = self.full_path.to_dict()
        if self.file_extension is not None:
            file_dict['file_extension'] = self.file_extension.to_dict()
        if self.size_in_bytes is not None:
            file_dict['size_in_bytes'] = self.size_in_bytes.to_dict()
        if self.magic_number is not None:
            file_dict['magic_number'] = self.magic_number.to_dict()
#.........这里部分代码省略.........
开发者ID:2xyo,项目名称:python-cybox,代码行数:103,代码来源:file_object.py


注:本文中的cybox.common.HashList.to_dict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。