Exemplo n.º 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
        }
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
     }
Exemplo n.º 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
     }
Exemplo n.º 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
        }
Exemplo n.º 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)
Exemplo n.º 8
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_unicode(os.path.normpath(filepath)))
     return self._uri_to_thumbpath(uri)
Exemplo n.º 9
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)
Exemplo n.º 10
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)
Exemplo n.º 11
0
 def add(self, path):
     if not preferences.prefs['store recent file info']:
         return
     uri = (portability.uri_prefix()
            + urllib.request.pathname2url(i18n.to_unicode(path)))
     self._manager.add_item(uri)