+ @staticmethod
+ def calculate_charm_hash(zipped_file):
+ """Calculate the hash of charm files which ends with .charm
+
+ Args:
+ zipped_file (str): Existing charm package full path
+
+ Returns:
+ hex digest (str): The hash of the charm file
+ """
+ filehash = hashlib.sha256()
+ with open(zipped_file, mode="rb") as file:
+ contents = file.read()
+ filehash.update(contents)
+ return filehash.hexdigest()
+
+ @staticmethod
+ def compare_charm_hash(current_charm, target_charm):
+ """Compare the existing charm and the target charm if the charms
+ are given as zip files ends with .charm
+
+ Args:
+ current_charm (str): Existing charm package full path
+ target_charm (str): Target charm package full path
+
+ Returns:
+ True/False (bool): if charm has changed it returns True
+ """
+ return LcmBase.calculate_charm_hash(
+ current_charm
+ ) != LcmBase.calculate_charm_hash(target_charm)
+
+ @staticmethod
+ def compare_charmdir_hash(current_charm_dir, target_charm_dir):
+ """Compare the existing charm and the target charm if the charms
+ are given as directories
+
+ Args:
+ current_charm_dir (str): Existing charm package directory path
+ target_charm_dir (str): Target charm package directory path
+
+ Returns:
+ True/False (bool): if charm has changed it returns True
+ """
+ return checksumdir.dirhash(current_charm_dir) != checksumdir.dirhash(
+ target_charm_dir
+ )
+