Example #1
0
    def test_humanize_size(self):
        """Test we can convert size values to human readable size."""
        values = [1023, 1024, 1048575, 1048576, 1604321.28]
        expected_result = [
            u'1023.0 bytes', u'1.0 KB', u'1024.0 KB', u'1.0 MB', u'1.5 MB']

        result = []
        for value in values:
            result.append(humanize_file_size(value))
        self.assertEqual(result, expected_result, )
Example #2
0
    def test_humanize_size(self):
        """Test we can convert size values to human readable size."""
        values = [1023, 1024, 1048575, 1048576, 1604321.28]
        expected_result = [
            u'1023.0 bytes', u'1.0 KB', u'1024.0 KB', u'1.0 MB', u'1.5 MB']

        result = []
        for value in values:
            result.append(humanize_file_size(value))
        self.assertEqual(result, expected_result, )
Example #3
0
            def progress_event(received, total):
                """Update progress.

                :param received: Data received so far.
                :type received: int

                :param total: Total expected data.
                :type total: int
                """
                # noinspection PyArgumentList
                QCoreApplication.processEvents()

                self.progress_dialog.adjustSize()

                human_received = humanize_file_size(received)
                human_total = humanize_file_size(total)

                label_text = tr("%s : %s of %s" % (self.prefix_text, human_received, human_total))

                self.progress_dialog.setLabelText(label_text)
                self.progress_dialog.setMaximum(total)
                self.progress_dialog.setValue(received)
Example #4
0
            def progress_event(received, total):
                """Update progress.

                :param received: Data received so far.
                :type received: int

                :param total: Total expected data.
                :type total: int
                """
                # noinspection PyArgumentList
                QCoreApplication.processEvents()

                self.progress_dialog.adjustSize()

                human_received = humanize_file_size(received)
                human_total = humanize_file_size(total)

                label_text = tr(
                    "%s : %s of %s" %
                    (self.prefix_text, human_received, human_total))

                self.progress_dialog.setLabelText(label_text)
                self.progress_dialog.setMaximum(total)
                self.progress_dialog.setValue(received)