def run(self): search = Search(self.src_path, self.dst_path, self.src_regex, self.dst_regex) imagelist = search.find_images() artistlist = search.find_artists() if len(imagelist) == 0 and len(artistlist) == 0: print("Error: Nothing found neither in source or destination.") print("Maybe you have supplied the paths in the wrong order?") print("It should be source path first and destination path second.") exit(1) for artist in artistlist: sepparator = "--------------------------------------------" artiststring = "%s\nChecking artist with id: %s" % (sepparator, artist.id) imagestring = "" for image in imagelist: if artist.id == image.artist_id: imgpath = image.path.encode("utf-8") artistpath = artist.path.encode("utf-8") image.copy(artist.path) # assemble string for status about copying tempstring = "\n\tCopying image" copystring = "\n\t%s\n\tto\n\t%s" % (imgpath, artistpath) tempstring = tempstring + copystring imagestring = imagestring + tempstring if imagestring != "": print(artiststring + imagestring) print("Finished! Have a nice day.")
def run(self): search = Search(self.src_path, self.dst_path, self.src_regex, self.dst_regex) imagelist = search.find_images() artistlist = search.find_artists() if len(imagelist) == 0 and len(artistlist) == 0: print("Error: Nothing found neither in source or destination.") print("Maybe you have supplied the paths in the wrong order?") print( "It should be source path first and destination path second.") exit(1) for artist in artistlist: sepparator = "--------------------------------------------" artiststring = "%s\nChecking artist with id: %s" % (sepparator, artist.id) imagestring = "" for image in imagelist: if artist.id == image.artist_id: imgpath = image.path.encode("utf-8") artistpath = artist.path.encode("utf-8") image.copy(artist.path) # assemble string for status about copying tempstring = "\n\tCopying image" copystring = "\n\t%s\n\tto\n\t%s" % (imgpath, artistpath) tempstring = tempstring + copystring imagestring = imagestring + tempstring if imagestring != "": print(artiststring + imagestring) print("Finished! Have a nice day.")
def test_find_artists(): """Test search of artists.""" src_regex = re.compile("(?<=^\()\d*(?=\))") dst_regex = re.compile("(?<=\()\d*(?=\)$)") search = Search("./test/testsource", "./test/testdestination", src_regex, dst_regex) artistlist = search.find_artists() assert len(artistlist) == 2 for artist in artistlist: assert artist.id in ("206921", "814837")