      if not exists(directory):
          directory = get_folder(directory).path
  
      dir_scanned = sorted(os.scandir(directory), key=lambda x: x.name)
      for x in dir_scanned:
          if any([x.name.lower().endswith(ext) for ext in image_extensions]):
              if x.name in exclude_names:
                  if debug:
                      print("Already processed %s" % x.name)
                  continue
              else:
                  dir_contents.append(x.path)
 
</s> remove                     print("Already processed %s" % x.name)
 </s> add                     print("Already processed %s" % chkfile.name) </s> remove         directory = get_folder(directory).path
 </s> add         directory = get_folder(directory) </s> remove def get_image_paths(directory, exclude=[], debug=False):
    exclude_names = [basename(Path(x).stem[:-1] + Path(x).suffix) for x in exclude]
    dir_contents = []
 </s> add def get_image_paths(directory, exclude=list(), debug=False):
    """ Return a list of images that reside in a folder """
    image_extensions = [".jpg", ".jpeg", ".png", ".tif", ".tiff"]
    exclude_names = [basename(Path(x).stem[:-2] + Path(x).suffix) for x in exclude]
    dir_contents = list() </s> remove                 dir_contents.append(x.path)
 </s> add                 dir_contents.append(chkfile.path) </s> remove         self.read_alignments()
        is_have_alignments = self.have_alignments()
        for filename in tqdm(self.read_directory()):
            image = cv2.imread(filename)

            if is_have_alignments:
                if self.have_face(filename):
                    faces = self.get_faces_alignments(filename, image)
                else:
                    tqdm.write ('no alignment found for {}, skipping'.format(os.path.basename(filename)))
                    continue
            else:
                faces = self.get_faces(image)
 </s> add         """ Prepare the images for conversion """
        filename = ""
        for filename in tqdm(self.images.input_images):
            if not self.check_alignments(filename):
                continue
            image = Utils.cv2_read_write('read', filename)
            faces = self.faces.get_faces_alignments(filename, image)
            if not faces:
                continue

    for chkfile in dir_scanned:
        if any([chkfile.name.lower().endswith(ext) for ext in image_extensions]):
            if chkfile.name in exclude_names:
      if not exists(directory):
          directory = get_folder(directory).path
  
      dir_scanned = sorted(os.scandir(directory), key=lambda x: x.name)
    for chkfile in dir_scanned:
        if any([chkfile.name.lower().endswith(ext) for ext in image_extensions]):
            if chkfile.name in exclude_names:
    for chkfile in dir_scanned:
        if any([chkfile.name.lower().endswith(ext) for ext in image_extensions]):
            if chkfile.name in exclude_names:
    for chkfile in dir_scanned:
        if any([chkfile.name.lower().endswith(ext) for ext in image_extensions]):
            if chkfile.name in exclude_names:
                  if debug:
                      print("Already processed %s" % x.name)
                  continue
              else:
                  dir_contents.append(x.path)
keep keep keep keep replace replace replace keep keep keep keep keep
 cli/scripts Refactor (#367)

* Refactor for PEP 8 and split process function

* Remove backwards compatibility for skip frames

* Split optional functions into own class. Make functions more modular

* Conform scripts folder to PEP 8

* train.py - Fix write image bug. Make more modular

* extract.py - Make more modular, Put optional actions into own class

* cli.py - start PEP 8

* cli,py - Pep 8. Refactor and make modular. Bugfixes

* 1st round refactor. Completely untested and probably broken.

* convert.py: Extract alignments from frames if they don't exist

* BugFix: SkipExisting broken since face name refactor

* Extract.py tested

* Minor formatting

* convert.py + train.py amended not tested

* train.py - Semi-fix for hang on reaching target iteration. Now quits on preview mode
Make tensorflow / system warning less verbose

* 2nd pass refactor. Semi tested

bugfixes

* Remove obsolete code. imread/write to Utils

* rename inout.py to fsmedia.py

* Final bugfixes 
lib/utils.py