示例#1
0
    def test_check_file_signature_file_object(self):
        """Tests the check_file_signature_file_object function."""
        if not unittest.source:
            raise unittest.SkipTest("missing source")

        with open(unittest.source, "rb") as file_object:
            result = pylnk.check_file_signature_file_object(file_object)
            self.assertTrue(result)
    def __init__(self, file_io, source_description, jmp_info=None):
        self.file_io = file_io
        self.source_description = source_description
        self.jmp_info = jmp_info
        self.lnk_file = None

        if pylnk.check_file_signature_file_object(self.file_io):
            self.lnk_file = pylnk.file()
            self.lnk_file.open_file_object(self.file_io)
        else:
            message = "File object has invalid signature: {}".format(
                self.source_description)
            raise (LnkValidationError(message))

        target_data = self.lnk_file.get_link_target_identifier_data()
        self.target_data = TargetData(
            target_data,
            codepage=self.lnk_file.get_ascii_codepage().decode('ascii'))