eric6/MicroPython/MicroPythonGraphWidget.py

changeset 8243
cc717c2ae956
parent 8218
7c09585bd960
child 8509
df6e76de4cd0
equal deleted inserted replaced
8242:aa713ac50c0d 8243:cc717c2ae956
10 from collections import deque 10 from collections import deque
11 import bisect 11 import bisect
12 import os 12 import os
13 import time 13 import time
14 import csv 14 import csv
15 import contextlib
15 16
16 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt 17 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt
17 from PyQt5.QtGui import QPainter 18 from PyQt5.QtGui import QPainter
18 from PyQt5.QtWidgets import ( 19 from PyQt5.QtWidgets import (
19 QWidget, QHBoxLayout, QVBoxLayout, QToolButton, QSizePolicy, QSpacerItem, 20 QWidget, QHBoxLayout, QVBoxLayout, QToolButton, QSizePolicy, QSpacerItem,
178 if line.startswith(b"(") and line.endswith(b")"): 179 if line.startswith(b"(") and line.endswith(b")"):
179 # it may be a tuple we are interested in 180 # it may be a tuple we are interested in
180 rawValues = [val.strip() for val in line[1:-1].split(b",")] 181 rawValues = [val.strip() for val in line[1:-1].split(b",")]
181 values = [] 182 values = []
182 for raw in rawValues: 183 for raw in rawValues:
183 try: 184 with contextlib.suppress(ValueError):
184 values.append(int(raw)) 185 values.append(int(raw))
185 # ok, it is an integer 186 # ok, it is an integer
186 continue 187 continue
187 except ValueError:
188 # test for a float
189 pass
190 try: 188 try:
191 values.append(float(raw)) 189 values.append(float(raw))
192 except ValueError: 190 except ValueError:
193 # it is not an int or float, ignore it 191 # it is not an int or float, ignore it
194 continue 192 continue

eric ide

mercurial