Example #1
0
    def _get_text_data(self, filepath):
        """ Creates a tEXt dictionary for <filepath>. """
        mime = mimetypes.guess_type(filepath)[0] or "unknown/mime"
        uri = portability.uri_prefix() + pathname2url(
            i18n.to_utf8(os.path.normpath(filepath)))
        stat = os.stat(filepath)
        # MTime could be floating point number, so convert to long first to have a fixed point number
        mtime = str(long(stat.st_mtime))
        size = str(stat.st_size)
        try:
            img = Image.open(filepath)
            width = str(img.size[0])
            height = str(img.size[1])
        except IOError:
            width = height = 0

        return {
            'tEXt::Thumb::URI': uri,
            'tEXt::Thumb::MTime': mtime,
            'tEXt::Thumb::Size': size,
            'tEXt::Thumb::Mimetype': mime,
            'tEXt::Thumb::Image::Width': width,
            'tEXt::Thumb::Image::Height': height,
            'tEXt::Software': 'MComix %s' % constants.VERSION
        }
Example #2
0
 def remove(self, path):
     if not preferences.prefs['store recent file info']:
         return
     uri = portability.uri_prefix() + urllib.pathname2url(i18n.to_utf8(path))
     try:
         self._manager.remove_item(uri)
     except glib.GError:
         # Could not remove item
         pass
Example #3
0
 def remove(self, path):
     if not preferences.prefs['store recent file info']:
         return
     uri = portability.uri_prefix() + urllib.pathname2url(i18n.to_utf8(path))
     try:
         self._manager.remove_item(uri)
     except glib.GError:
         # Could not remove item
         pass
Example #4
0
 def _get_text_data(self, filepath):
     """ Creates a tEXt dictionary for <filepath>. """
     mime = mimetypes.guess_type(filepath)[0] or "unknown/mime"
     uri = portability.uri_prefix() + pathname2url(i18n.to_utf8(os.path.normpath(filepath)))
     stat = os.stat(filepath)
     # MTime could be floating point number, so convert to long first to have a fixed point number
     mtime = str(long(stat.st_mtime))
     size = str(stat.st_size)
     format, (width, height), providers = image_tools.get_image_info(filepath)
     return {
         'tEXt::Thumb::URI':           uri,
         'tEXt::Thumb::MTime':         mtime,
         'tEXt::Thumb::Size':          size,
         'tEXt::Thumb::Mimetype':      mime,
         'tEXt::Thumb::Image::Width':  str(width),
         'tEXt::Thumb::Image::Height': str(height),
         'tEXt::Software':             'MComix %s' % constants.VERSION
     }
Example #5
0
 def _get_text_data(self, filepath):
     """ Creates a tEXt dictionary for <filepath>. """
     mime = mimetypes.guess_type(filepath)[0] or "unknown/mime"
     uri = portability.uri_prefix() + pathname2url(i18n.to_utf8(os.path.normpath(filepath)))
     stat = os.stat(filepath)
     # MTime could be floating point number, so convert to long first to have a fixed point number
     mtime = str(long(stat.st_mtime))
     size = str(stat.st_size)
     format, width, height = image_tools.get_image_info(filepath)
     return {
         'tEXt::Thumb::URI':           uri,
         'tEXt::Thumb::MTime':         mtime,
         'tEXt::Thumb::Size':          size,
         'tEXt::Thumb::Mimetype':      mime,
         'tEXt::Thumb::Image::Width':  str(width),
         'tEXt::Thumb::Image::Height': str(height),
         'tEXt::Software':             'MComix %s' % constants.VERSION
     }
Example #6
0
    def _get_text_data(self, filepath):
        """ Creates a tEXt dictionary for <filepath>. """
        mime = mimetypes.guess_type(filepath)[0] or "unknown/mime"
        uri = portability.uri_prefix() + pathname2url(i18n.to_utf8(os.path.normpath(filepath)))
        stat = os.stat(filepath)
        # MTime could be floating point number, so convert to long first to have a fixed point number
        mtime = str(long(stat.st_mtime))
        size = str(stat.st_size)
        try:
            img = Image.open(filepath)
            width = str(img.size[0])
            height = str(img.size[1])
        except IOError:
            width = height = 0

        return {
            'tEXt::Thumb::URI':           uri,
            'tEXt::Thumb::MTime':         mtime,
            'tEXt::Thumb::Size':          size,
            'tEXt::Thumb::Mimetype':      mime,
            'tEXt::Thumb::Image::Width':  width,
            'tEXt::Thumb::Image::Height': height,
            'tEXt::Software':             'MComix %s' % constants.VERSION
        }
Example #7
0
 def _path_to_thumbpath(self, filepath):
     """ Converts <path> to an URI for the thumbnail in <dst_dir>. """
     uri = portability.uri_prefix() + pathname2url(i18n.to_utf8(os.path.normpath(filepath)))
     return self._uri_to_thumbpath(uri)
Example #8
0
 def add(self, path):
     if not preferences.prefs['store recent file info']:
         return
     uri = portability.uri_prefix() + urllib.pathname2url(i18n.to_utf8(path))
     self._manager.add_item(uri)
Example #9
0
 def _original_filename(self, filename):
     """ Map Unicode filename back to original archive name. """
     if filename in self.unicode_mapping:
         return self.unicode_mapping[filename]
     else:
         return i18n.to_utf8(filename)
Example #10
0
 def _original_filename(self, filename):
     """ Map Unicode filename back to original archive name. """
     if filename in self.unicode_mapping:
         return self.unicode_mapping[filename]
     else:
         return i18n.to_utf8(filename)
Example #11
0
 def _path_to_thumbpath(self, filepath):
     """ Converts <path> to an URI for the thumbnail in <dst_dir>. """
     uri = portability.uri_prefix() + pathname2url(
         i18n.to_utf8(os.path.normpath(filepath)))
     return self._uri_to_thumbpath(uri)
Example #12
0
 def remove(self, path):
     if not preferences.prefs['store recent file info']:
         return
     uri = portability.uri_prefix() + urllib.pathname2url(
         i18n.to_utf8(path))
     self._manager.remove_item(uri)