def test_non_empty_file_checksum(self): # Used a NamedTemporaryFile since it's deleted when the file is closed. with tempfile.NamedTemporaryFile() as temp_file: temp_file.write(b"foo") temp_file.flush() self.assertEqual(utils.file_checksum(temp_file.name), "acbd18db4cc2f85cedef654fccc4a4d8")
def test_non_empty_file_checksum(self): # Used a NamedTemporaryFile since it's deleted when the file is closed. with tempfile.NamedTemporaryFile() as temp_file: temp_file.write(b'foo') temp_file.flush() self.assertEqual(utils.file_checksum(temp_file.name), 'acbd18db4cc2f85cedef654fccc4a4d8')
def _get_image(self, path): if not os.path.exists(path): return stat = os.stat(path) created_at = datetime.fromtimestamp( stat.st_mtime).isoformat() Image = collections.namedtuple( 'Image', 'id, name, checksum, created_at, size' ) (dir_path, filename) = os.path.split(path) (name, extension) = os.path.splitext(filename) checksum = plugin_utils.file_checksum(path) return Image( id='file://%s' % path, name=name, checksum=checksum, created_at=created_at, size=stat.st_size )
def test_empty_file_checksum(self): # Used a NamedTemporaryFile since it's deleted when the file is closed. with tempfile.NamedTemporaryFile() as empty_temp_file: self.assertEqual(utils.file_checksum(empty_temp_file.name), 'd41d8cd98f00b204e9800998ecf8427e')
def _files_changed(self, filepath1, filepath2): return (plugin_utils.file_checksum(filepath1) != plugin_utils.file_checksum(filepath2))
def _image_changed(self, name, filename): image = utils.find_resource(self.app.client_manager.image.images, name) return image.checksum != plugin_utils.file_checksum(filename)
def _files_changed(self, filepath1, filepath2): return plugin_utils.file_checksum(filepath1) != plugin_utils.file_checksum(filepath2)
def _image_changed(self, image, filename): return image.checksum != plugin_utils.file_checksum(filename)