Beispiel #1
0
def remove_if_duplicate(img_path, img_hash_log):
    if img_path:
        img_hash = dupecheck.hash_image(img_path)
        if dupecheck.is_duplicate(img_hash_log, img_hash):
            os.remove(img_path)
        else:
            dupecheck.add_to_file(img_hash_log, img_hash)
Beispiel #2
0
 def remove_if_duplicate(self, img_path):
     if img_path:
         img_hash = dupecheck.hash_image(img_path)
         if dupecheck.is_duplicate(img_hash):
             os.remove(img_path)
             return True
         else:
             dupecheck.add_to_db(img_hash, self.thread_nb)
             return False
Beispiel #3
0
 def remove_if_duplicate(self, img_path):
     if img_path:
         img_hash = dupecheck.hash_image(img_path)
         if dupecheck.is_duplicate(self.img_hash_log, img_hash):
             os.remove(img_path)
             return True
         else:
             dupecheck.add_to_file(self.img_hash_log, img_hash)
             return False
Beispiel #4
0
 def remove_if_duplicate(self, img_path):
     if img_path:
         img_hash = dupecheck.hash_image(img_path)
         if dupecheck.is_duplicate(img_hash):
             os.remove(img_path)
             return True
         else:
             dupecheck.add_to_db(img_hash, self.thread_nb)
             return False
Beispiel #5
0
    def remove_if_duplicate(self, img_path):
        """
        Remove an image if it was already downloaded

        Returns:
            True if the image was removed, False otherwise
        """

        if img_path:
            img_hash = dupecheck.hash_image(img_path)
            if dupecheck.is_duplicate(img_hash):
                os.remove(img_path)
                return True
            else:
                dupecheck.add_to_db(img_hash, self.thread_nb)
                return False
Beispiel #6
0
dupecheck.add_to_file("hash_test_file.txt", "some_hash_to_write")

if 'some_hash_to_write' not in open("hash_test_file.txt").read():
    print("the string was not written to hash_test_file.txt")
    exit(1)

print('\x1b[6;30;42m' + 'OK' + '\x1b[0m')

print("--------------------------------------------------------")
print("Testing: dupecheck.is_duplicate                        -")
print("--------------------------------------------------------")

os.system("echo some_hash > hash_test_file.txt")

# Test when hash is in file
is_dupe = dupecheck.is_duplicate("hash_test_file.txt", "some_hash")
if not is_dupe:
    print("is_dupe should be True")
    exit(1)

# Test when hash is NOT in file
is_dupe = dupecheck.is_duplicate("hash_test_file.txt", "hash_not_in_file")
if is_dupe:
    print("is_dupe should be False")
    exit(1)

print('\x1b[6;30;42m' + 'OK' + '\x1b[0m')

print("--------------------------------------------------------")
print("Testing: dupecheck.hash_img_in_folder                  -")
print("--------------------------------------------------------")