Ejemplo n.º 1
0
 def _partial_col_data_func(self, cell_layout, renderer, model, iterator):
     """ Column data function for partial size column """
     part_size = self._store.get_value(iterator, self.LIST_COL.PART_SIZE)
     if part_size != 0:
         size_str = humanize_size(part_size)
     else:
         size_str = _("Unknown")
     renderer.set_property("text", size_str)
Ejemplo n.º 2
0
    def _size_col_data_func(self, cell_layout, renderer, model, iterator):
        """ Data function for the size column.

        Invokes :func:`humanize_size` if the file size is known for
        a row and shows the result of the function call.
        """
        file_size = self._store.get_value(iterator, self.LIST_COL.FILE_SIZE)
        if file_size != 0:
            size_str = humanize_size(file_size)
        else:
            size_str = _("Unknown")
        renderer.set_property("text", size_str)
Ejemplo n.º 3
0
    def _set_status(self, time_remaining, download_speed=None):
        """ Status label setter function
        
        :param time_remaining: Time remaining in seconds (integer)
        :param download_speed: Current download speed in bytes per second.
        """
        text = ''
        if download_speed:
            # TRANSLATORS: This is the download rate in bytes, kilobytes
            # or megabytes per second (hence the trailing /s).
            text = _('Download rate: %s/s') % (humanize_size(download_speed))

        if time_remaining:
            if time_remaining < 5:
                text += '\n' + ('Less than 5 seconds remaining')
            else:
                eta_string = humanize_seconds(time_remaining)
                text += '\n' + ('About %s remaining') % (eta_string)

        self._status.set_markup(text)
Ejemplo n.º 4
0
 def test3_megabytes(self):
     for i in range(1024, 1024 * 5, 256):
         self.assertEquals(locale.format(_("%.1f MB"),
                                         float(i) / 1024),
                           humanize_size(1024 * i))
Ejemplo n.º 5
0
 def test2_kilobytes(self):
     for i in range(1, 1023, 256):
         self.assertEquals(locale.format(_("%.0f KB"), i),
                           humanize_size(i * 1024))
Ejemplo n.º 6
0
 def test1_less_than_1024_bytes(self):
     for i in range(1, 1023):
         self.assertEquals(_("1 KB"), humanize_size(i))
Ejemplo n.º 7
0
 def test0_null_bytes(self):
     self.assertEquals(_("0 KB"), humanize_size(0))