Example #1
0
 def get_fsize(page):
     path = self.get_path_to_page(page)
     try:
         fsize = 0 if path is None else os.stat(path).st_size
     except OSError:
         fsize = 0
     return tools.format_byte_size(fsize)
Example #2
0
    def fetch_comments(self):
        '''Load all comments in the archive.'''

        for num in range(1,
          self._edit_dialog.file_handler.get_number_of_comments() + 1):

            path = self._edit_dialog.file_handler.get_comment_name(num)
            size = tools.format_byte_size(os.stat(path).st_size)
            self._liststore.append([os.path.basename(path), size, path])
Example #3
0
    def fetch_comments(self):
        """Load all comments in the archive."""

        for num in xrange(1,
          self._edit_dialog.file_handler.get_number_of_comments() + 1):

            path = self._edit_dialog.file_handler.get_comment_name(num)
            size = tools.format_byte_size(os.stat(path).st_size)
            self._liststore.append([os.path.basename(path), size, path])
Example #4
0
    def get_page_filesize(self, page=None, double=False):
        """Return the filesize of the <page>, or the filesize of the
        currently viewed page if <page> is None. If <double> is True, return
        a tuple (s, s') where s is the filesize of <page> (or the current
        page) and s' is the filesize of the page after.
        """
        if not self.page_is_available():
            return

        if page is None:
            page = self.get_current_page()

        first_path = self.get_path_to_page(page)
        if first_path == None:
            return

        if double:
            second_path = self.get_path_to_page(page + 1)
            if second_path != None:
                try:
                    first = tools.format_byte_size(os.stat(first_path).st_size)
                except OSError:
                    first = u''
                try:
                    second = tools.format_byte_size(os.stat(second_path).st_size)
                except OSError:
                    second = u''
            else:
                return
            return first, second

        try:
            size = tools.format_byte_size(os.stat(first_path).st_size)
        except OSError:
            size = u''

        return size
    def _preview_thumbnail_finished(self, filepath, pixbuf):
        """ Called when the thumbnailer has finished creating
        the thumbnail for <filepath>. """

        if self._destroyed:
            return

        current_path = self.filechooser.get_preview_filename()
        if current_path and current_path.decode('utf-8') == filepath:

            if pixbuf is None:
                self._preview_image.clear()
                self._namelabel.set_text('')
                self._sizelabel.set_text('')

            else:
                pixbuf = image_tools.add_border(pixbuf, 1)
                self._preview_image.set_from_pixbuf(pixbuf)
                self._namelabel.set_text(os.path.basename(filepath))
                self._sizelabel.set_text(tools.format_byte_size(
                    os.stat(filepath).st_size))
Example #6
0
    def _preview_thumbnail_finished(self, filepath, pixbuf):
        """ Called when the thumbnailer has finished creating
        the thumbnail for <filepath>. """

        if self._destroyed:
            return

        current_path = self.filechooser.get_preview_filename()
        if current_path and current_path.decode('utf-8') == filepath:

            if pixbuf is None:
                self._preview_image.clear()
                self._namelabel.set_text('')
                self._sizelabel.set_text('')

            else:
                pixbuf = image_tools.add_border(pixbuf, 1)
                self._preview_image.set_from_pixbuf(pixbuf)
                self._namelabel.set_text(os.path.basename(filepath))
                self._sizelabel.set_text(
                    tools.format_byte_size(os.stat(filepath).st_size))
Example #7
0
 def _update_page_secondary_info(self, page, location):
     secondary_info = [
         (_('Location'), i18n.to_unicode(os.path.dirname(location))),
     ]
     try:
         stats = os.stat(location)
     except OSError as e:
         page.set_secondary_info(secondary_info)
         return
     if _has_pwd:
         uid = pwd.getpwuid(stats.st_uid)[0]
     else:
         uid = str(stats.st_uid)
     secondary_info.extend((
         (_('Size'), tools.format_byte_size(stats.st_size)),
         (_('Accessed'), time.strftime('%Y-%m-%d, %H:%M:%S',
         time.localtime(stats.st_atime))),
         (_('Modified'), time.strftime('%Y-%m-%d, %H:%M:%S',
         time.localtime(stats.st_mtime))),
         (_('Permissions'), oct(stat.S_IMODE(stats.st_mode))),
         (_('Owner'), uid)
     ))
     page.set_secondary_info(secondary_info)
Example #8
0
 def add_extra_file(self, path):
     '''Add an extra imported file (at <path>) to the list.'''
     size = tools.format_byte_size(os.stat(path).st_size)
     self._liststore.append([os.path.basename(path), size, path])
Example #9
0
 def add_extra_file(self, path):
     """Add an extra imported file (at <path>) to the list."""
     size = tools.format_byte_size(os.stat(path).st_size)
     self._liststore.append([os.path.basename(path), size, path])