src/eric7/MicroPython/IgnoredDevicesDialog.py

Thu, 07 Jul 2022 11:23:56 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 07 Jul 2022 11:23:56 +0200
branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
eric7/MicroPython/IgnoredDevicesDialog.py@54e42bc2437a
child 9221
bf71ee032bb4
permissions
-rw-r--r--

Reorganized the project structure to use the source layout in order to support up-to-date build systems with "pyproject.toml".

7592
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
3 # Copyright (c) 2020 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
7592
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to manage the list of ignored serial devices.
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
10 from PyQt6.QtWidgets import QDialog
7592
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from .Ui_IgnoredDevicesDialog import Ui_IgnoredDevicesDialog
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 class IgnoredDevicesDialog(QDialog, Ui_IgnoredDevicesDialog):
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 """
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 Class implementing a dialog to manage the list of ignored serial devices.
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 """
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 def __init__(self, deviceList, parent=None):
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 Constructor
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 @param deviceList list of ignored serial devices given by VID and PID
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 @type list of tuple of (int, int)
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 @param parent reference to the parent widget
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @type QWidget
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
28 super().__init__(parent)
7592
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 self.setupUi(self)
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 self.devicesEditWidget.setList([
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 "{0} ({1:04x}/{2:04x})".format(description, vid, pid)
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 for vid, pid, description in deviceList
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 ])
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.devicesEditWidget.setDefaultVisible(False)
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.devicesEditWidget.setAddVisible(False)
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 def getDevices(self):
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 Public method to get the list of ignored serial devices.
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 @return list of tuples containing the VID, PID and a description
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 of each ignored device
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 @rtype list of tuple of (int, int, str)
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 deviceList = []
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 textList = self.devicesEditWidget.getList()
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 for entry in textList:
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 description, vid_pid = entry.rsplit(None, 1)
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 vid, pid = vid_pid[1:-1].split("/", 1)
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 deviceList.append((int(vid, 16), int(pid, 16), description))
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
f79dc58bdf62 MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 return deviceList

eric ide

mercurial