Beispiel #1
0
    def understand(image_file):
        """Seems like the static method wastes a lot of effort here; it's not possible to
        just read the first few bytes; instead understand() reads the entire first data
        item in the file; an entire binary image.  This data is then read again in the
        _start() method and again in the detectorbase constructor.
        """

        try:
            with FormatPYunspecified.open_file(image_file, "rb") as fh:
                if six.PY3:
                    data = pickle.load(fh, encoding="bytes")  # lgtm
                    # the '# lgtm' comment disables an lgtm false positive and
                    # can be removed once we move to Python 3 only
                    data = {
                        key.decode("ascii"): value
                        for key, value in data.items()
                    }
                else:
                    data = pickle.load(fh)
        except IOError:
            return False

        if "OSC_START" not in data or "OSC_RANGE" not in data:
            return True

        return data["OSC_RANGE"] <= 0
  def understand(image_file):
    """Seems like the static method wastes a lot of effort here; it's not possible to
    just read the first few bytes; instead understand() reads the entire first data
    item in the file; an entire binary image.  This data is then read again in the
    _start() method and again in the detectorbase constructor.
    """

    try:
      stream = FormatPYunspecified.open_file(image_file, 'rb')
      import cPickle as pickle
      data = pickle.load(stream)
    except IOError,e:
      return False
    def understand(image_file):
        """Seems like the static method wastes a lot of effort here; it's not possible to
    just read the first few bytes; instead understand() reads the entire first data
    item in the file; an entire binary image.  This data is then read again in the
    _start() method and again in the detectorbase constructor.
    """

        try:
            stream = FormatPYunspecified.open_file(image_file, 'rb')
            import cPickle as pickle
            data = pickle.load(stream)
        except IOError, e:
            return False
Beispiel #4
0
    def understand(image_file):
        """Seems like the static method wastes a lot of effort here; it's not possible to
        just read the first few bytes; instead understand() reads the entire first data
        item in the file; an entire binary image.  This data is then read again in the
        _start() method and again in the detectorbase constructor.
        """

        try:
            with FormatPYunspecified.open_file(image_file, "rb") as fh:
                data = image_dict_to_unicode(pickle.load(fh, encoding="bytes"))
        except OSError:
            return False

        if "OSC_START" not in data or "OSC_RANGE" not in data:
            return True

        return data["OSC_RANGE"] <= 0