Verify that `path` has the qpimage series file format
192600
def verify(path):
        """"""
        valid = False
        try:
            h5 = h5py.File(path, mode="r")
            qpi0 = h5["qpi_0"]
        except (OSError, KeyError):
            pass
        else:
            if ("qpimage version" in qpi0.attrs and
                "phase" in qpi0 and
                "amplitude" in qpi0 and
                "bg_data" in qpi0["phase"] and
                    "bg_data" in qpi0["amplitude"]):
                valid = True
        return valid
117110
def _find_image_ext(path, number=None):
    """"""
    if number is not None:
        path = path.format(number)
    path = os.path.splitext(path)[0]
    for ext in _KNOWN_IMG_EXTS:
        this_path = '%s.%s' % (path, ext)
        if os.path.isfile(this_path):
            break
    else:
        ext = 'png'
    return ('%s.%s' % (path, ext), ext)
937249
def check_structure(filepath):
    """"""
    #http://stackoverflow.com/questions/1401527/how-do-i-programmatically-check-whether-an-image-png-jpeg-or-gif-is-corrupted/1401565#1401565
    
    # Check structure only for images (not supported for other types currently)
    if filepath.lower().endswith(tuple(img_filter)):
        try:
            #try:
            im = PIL.Image.open(filepath)
            #except IOError: # File format not supported by PIL, we skip the check_structure - ARG this is also raised if a supported image file is corrupted...
                #print("File: %s: DETECTNOPE" % filepath)
                #return None
            im.verify()
        # If an error occurred, the structure is corrupted
        except Exception as e:
            return str(e)
        # Else no exception, there's no corruption
        return False
    # Else the format does not currently support structure checking, we just return None to signal we didin't check
    else:
        return None
979741
def _HasOOOWrite(self, path):
    """"""
    # Check the sizes of each path before the current one.
    size = tf.io.gfile.stat(path).length
    old_size = self._finalized_sizes.get(path, None)
    if size != old_size:
      if old_size is None:
        logger.error('File %s created after file %s even though it\'s '
                         'lexicographically earlier', path, self._path)
      else:
        logger.error('File %s updated even though the current file is %s',
                         path, self._path)
      return True
    else:
      return False
1184590
def pickFilepath( self ):
        
        filepath = QFileDialog.getOpenFileName( self,
                                                'Select Image File',
                                                QDir.currentPath(),
                                                self.fileTypes())
        
        if type(filepath) == tuple:
            filepath = nativestring(filepath[0])
        
        if ( filepath ):
            self.setFilepath(filepath)
166684
def exists(self, relpath, rsc=None, useFilepath=None):
        
        path = self.find(relpath, rsc, useFilepath)
        if path.startswith(':'):
            return QtCore.QResource(path).isValid()
        else:
            return os.path.exists(path)
45851
def IsFileStatEntry(self, original_result):
    """"""
    return (original_result.pathspec.pathtype in [
        rdf_paths.PathSpec.PathType.OS, rdf_paths.PathSpec.PathType.TSK
    ])
1331126
def _ask_path(cls, editor):
        
        try:
            filter = cls.get_filter(editor.mimetypes[0])
        except IndexError:
            filter = _('All files (*)')
        return QtWidgets.QFileDialog.getSaveFileName(
            editor, _('Save file as'), cls.default_directory, filter)
766601
def pfx_path(path):
    
    if path[0] != os.path.sep: return os.path.sep + path
    else:                      return path
760690
def is_image(filename):
    """"""
    # note: isfile() also accepts symlinks
    return os.path.isfile(filename) and filename.lower().endswith(ImageExts)
513582
def image_path_from_index(self, index):
        
        assert self.image_set_index is not None, "Dataset not initialized"
        name = self.image_set_index[index]
        image_file = os.path.join(self.data_path, 'JPEGImages', name + self.extension)
        assert os.path.exists(image_file), 'Path does not exist: {}'.format(image_file)
        return image_file
334702
def is_file(self, path):
        """"""
        return (samefile(path, self.device_file) or
                samefile(path, self.loop_file) or
                any(samefile(path, mp) for mp in self.mount_paths) or
                sameuuid(path, self.id_uuid) or
                sameuuid(path, self.partition_uuid))
809347
def get_qpimage(self, idx=0):
        """"""
        if self._bgdata:
            # The user has explicitly chosen different background data
            # using `get_qpimage_raw`.
            qpi = super(SingleHdf5Qpimage, self).get_qpimage()
        else:
            # We can use the background data stored in the qpimage hdf5 file
            qpi = qpimage.QPImage(h5file=self.path,
                                  h5mode="r",
                                  h5dtype=self.as_type,
                                  ).copy()
            # Force meta data
            for key in self.meta_data:
                qpi[key] = self.meta_data[key]
            # set identifier
            qpi["identifier"] = self.get_identifier(idx)
        return qpi
740918
def get_image_tar(image_path):
    '''
    '''
    bot.debug('Generate file system tar...')   
    file_obj = Client.image.export(image_path=image_path)
    if file_obj is None:
        bot.error("Error generating tar, exiting.")
        sys.exit(1)
    tar = tarfile.open(file_obj)
    return file_obj, tar
275163
def check_path(self, path):
        
        path = os.path.abspath(path)
        if os.path.exists(path):
            return path
        else:
            utils.die("input file does not exists:\n  {}".format(path))
738927
def isfile(self, relpath):
    """"""
    if self.isignored(relpath):
      return False
    return self._isfile_raw(relpath)
694226
def preview(src_path):
  ''' 
  '''
  preview = embedded_preview(src_path)

  if not is_valid_preview(preview):
    preview = generator_preview(src_path)

  if not is_valid_preview(preview):
    preview = thumbnail_preview(src_path)

  # Ensure the preview is returned in the right format
  if is_valid_preview(preview):
    if mimetype(preview) in [ExportMimeType.PNG]:
      return [preview]

    if mimetype(preview) in [ExportMimeType.PDF]:
      return to_pngs(preview)

  return []