コード例 #1
0
ファイル: main_with_gui.py プロジェクト: lvps/peracotta
    def init_ui(self, window: QMainWindow, system_info):

        v_box = QVBoxLayout()
        button_style = "background-color: #006699; padding-left:20px; padding-right:20px; \
						padding-top:5px; padding-bottom:5px;"

        # proceed to the json - button
        json_button = QPushButton("Proceed to JSON")
        json_button.setStyleSheet(button_style)
        json_button.clicked.connect(
            lambda: self.display_plaintext_data(window, system_info))

        v_box.addSpacing(20)
        v_box.addWidget(json_button, alignment=Qt.AlignCenter)
        v_box.addSpacing(20)

        # if system_info is empty
        if not system_info:
            nothing_found = QLabel("Nothing was found.")
            v_box.addWidget(nothing_found, alignment=Qt.AlignCenter)

        for i, component in enumerate(system_info):
            if i == 0:
                prev_type = component["type"]
            else:
                prev_type = system_info[i - 1]["type"]

            if component["type"] != prev_type or i == 0:
                title = QLabel(component["type"].upper())
                # noinspection PyArgumentList
                title.setFont(QFont("futura", pointSize=16, italic=False))
                if i != 0:
                    v_box.addSpacing(10)
                v_box.addWidget(title, alignment=Qt.AlignCenter)

            for feature in component.items():
                if feature[0] != "type":
                    h_box = QHBoxLayout()

                    # the single dict entry is converted to a tuple
                    name = QLabel(str(feature[0]))
                    if feature[1] != "":
                        desc = QLabel(
                            str(
                                prettyprinter.print_feature(
                                    feature[0], feature[1])))
                    else:
                        desc = QLabel("missing feature")
                        name.setStyleSheet("color: yellow")
                        desc.setStyleSheet("color: yellow")

                    h_box.addWidget(name, alignment=Qt.AlignCenter)
                    h_box.addStretch()
                    h_box.addWidget(desc, alignment=Qt.AlignCenter)

                    v_box.addLayout(h_box)

            v_box.addSpacing(15)

        self.setLayout(v_box)
コード例 #2
0
def test_diagonal_inches():
    values = {
        17: "17 in.",
        21: "21 in.",
    }

    for value, expected in values.items():
        assert prettyprinter.print_feature("diagonal-inch", value) == expected
コード例 #3
0
ファイル: main_with_gui.py プロジェクト: mikeus9908/peracotta
    def list_data(key, value, parent):
        name = key
        if value != "":
            desc = str(prettyprinter.print_feature(key, value))
        else:
            desc = "missing feature"

        child_item = [QStandardItem(name), QStandardItem(desc)]
        parent.appendRow(child_item)
コード例 #4
0
def test_diameter():
    values = {
        10: "10 mm",
        100: "100 mm",
        1000: "1000 mm",
        20: "20 mm",
        200: "200 mm",
        2000: "2000 mm",
    }

    for value, expected in values.items():
        assert prettyprinter.print_feature("diameter-mm", value) == expected
コード例 #5
0
def test_frequency():
	values = {
		100: "100 Hz",
		1000: "1 kHz",
		2_000_000_000: "2 GHz",
		2_600_000_000: "2.6 GHz",
		2_660_000_000: "2.66 GHz",
		2_667_000_000: "2.667 GHz",
	}

	for value, expected in values.items():
		assert prettyprinter.print_feature('frequency-hertz', value) == expected
コード例 #6
0
def test_bytes():
    values = {
        10: "10 B",
        100: "100 B",
        1000: "1000 B",
        1024: "1 KiB",
        1024 * 1024: "1 MiB",
        27 * 1024 * 1024: "27 MiB",
        1024 * 1024 * 1024: "1 GiB",
        10 * 1024 * 1024 * 1024: "10 GiB",
        11 * 1024 * 1024 * 1024: "11 GiB",
        160 * 1024 * 1024 * 1024: "160 GiB",
        160.1 * 1024 * 1024 * 1024: "160.1 GiB",
        160.12 * 1024 * 1024 * 1024: "160.12 GiB",
        160.123 * 1024 * 1024 * 1024: "160.123 GiB",
        2 * 1024 * 1024 * 1024 * 1024: "2 TiB",
    }

    for value, expected in values.items():
        assert prettyprinter.print_feature("capacity-byte", value) == expected
コード例 #7
0
def test_hdd_bytes():
	values = {
		10: "10 B",
		100: "100 B",
		1000: "1 kB",
		1024: "1.024 kB",
		1000*1000: "1 MB",
		27*1000*1000: "27 MB",
		1000*1000*1000: "1 GB",
		10*1000*1000*1000: "10 GB",
		11*1000*1000*1000: "11 GB",
		160*1000*1000*1000: "160 GB",
		160.1*1000*1000*1000: "160.1 GB",
		160.12*1000*1000*1000: "160.12 GB",
		160.123*1000*1000*1000: "160.123 GB",
		2*1000*1000*1000*1000: "2 TB",
	}

	for value, expected in values.items():
		assert prettyprinter.print_feature('capacity-decibyte', value) == expected