# Path: mu/interface/panes.py
# CHARTS = True
# 
# Path: mu/logic.py
# class Device:
#     """
#     Device object, containing both information about the connected device,
#     the port it's connected through and the mode it works with.
#     """
# 
#     def __init__(
#         self,
#         vid,
#         pid,
#         port,
#         serial_number,
#         manufacturer,
#         long_mode_name,
#         short_mode_name,
#         board_name=None,
#     ):
#         self.vid = vid
#         self.pid = pid
#         self.port = port
#         self.serial_number = serial_number
#         self.manufacturer = manufacturer
#         self.long_mode_name = long_mode_name
#         self.short_mode_name = short_mode_name
#         self.board_name = board_name
# 
#     @property
#     def name(self):
#         """
#         Returns the device name.
#         """
#         if self.board_name:
#             return self.board_name
#         else:
#             return _("{} compatible").format(self.long_mode_name)
# 
#     def __eq__(self, other):
#         """
#         Equality on devices. Comparison on vid, pid, and serial_number,
#         and most importantly also matches on which port the device is
#         connected to. That is, if two identical devices are connected
#         to separate ports they are considered different.
#         """
#         return (
#             isinstance(other, self.__class__)
#             and self.pid == other.pid
#             and self.vid == other.vid
#             and self.port == other.port
#             and self.serial_number == other.serial_number
#         )
# 
#     def __ne__(self, other):
#         """
#         Inequality of devices is the negation of equality
#         """
#         return not self.__eq__(other)
# 
#     def __lt__(self, other):
#         """
#         Alphabetical ordering according to device name
#         """
#         return self.name < other.name
# 
#     def __gt__(self, other):
#         """
#         Alphabetical ordering according to device name
#         """
#         return self.name > other.name
# 
#     def __le__(self, other):
#         """
#         Alphabetical ordering according to device name
#         """
#         return self.name <= other.name
# 
#     def __ge__(self, other):
#         """
#         Alphabetical ordering according to device name
#         """
#         return self.name >= other.name
# 
#     def __str__(self):
#         """
#         String representation of devices includes name, port, and VID/PID
#         """
#         s = "{} on {} (VID: 0x{:04X}, PID: 0x{:04X})"
#         return s.format(self.name, self.port, self.vid, self.pid)
# 
#     def __hash__(self):
#         """
#         Hash is the hash of the string representation, includes the same
#         elements in the hash as in equality testing.
#         """
#         return hash(str(self))


import os
import ctypes
import logging
from subprocess import check_output
from mu.modes.base import MicroPythonMode
from mu.modes.api import ADAFRUIT_APIS, SHARED_APIS
from mu.interface.panes import CHARTS
from mu.logic import Device
from adafruit_board_toolkit import circuitpython_serial
            wd = super().workspace_dir()
            if self.connected:
                m = _("Could not find an attached CircuitPython device.")
                info = _(
                    "Python files for CircuitPython devices"
                    " are stored on the device. Therefore, to edit"
                    " these files you need to have the device plugged in."
                    " Until you plug in a device, Mu will use the"
                    " directory found here:\n\n"
                    " {}\n\n...to store your code."
                )
                self.view.show_message(m, info.format(wd))
                self.connected = False
            return wd

    def compatible_board(self, port):
        """Use adafruit_board_toolkit to find out whether a board is running
        CircuitPython. The toolkit sees if the CDC Interface name is appropriate.
        """

        pid = port.productIdentifier()
        vid = port.vendorIdentifier()
        manufacturer = port.manufacturer()
        serial_number = port.serialNumber()
        port_name = self.port_path(port.portName())

        # Find all the CircuitPython REPL comports,
        # and see if any of their device names match the one passed in.
        for comport in circuitpython_serial.repl_comports():
            if comport.device == port_name:

# Path: mu/interface/panes.py
# CHARTS = True
# 
# Path: mu/logic.py
# class Device:
#     """
#     Device object, containing both information about the connected device,
#     the port it's connected through and the mode it works with.
#     """
# 
#     def __init__(
#         self,
#         vid,
#         pid,
#         port,
#         serial_number,
#         manufacturer,
#         long_mode_name,
#         short_mode_name,
#         board_name=None,
#     ):
#         self.vid = vid
#         self.pid = pid
#         self.port = port
#         self.serial_number = serial_number
#         self.manufacturer = manufacturer
#         self.long_mode_name = long_mode_name
#         self.short_mode_name = short_mode_name
#         self.board_name = board_name
# 
#     @property
#     def name(self):
#         """
#         Returns the device name.
#         """
#         if self.board_name:
#             return self.board_name
#         else:
#             return _("{} compatible").format(self.long_mode_name)
# 
#     def __eq__(self, other):
#         """
#         Equality on devices. Comparison on vid, pid, and serial_number,
#         and most importantly also matches on which port the device is
#         connected to. That is, if two identical devices are connected
#         to separate ports they are considered different.
#         """
#         return (
#             isinstance(other, self.__class__)
#             and self.pid == other.pid
#             and self.vid == other.vid
#             and self.port == other.port
#             and self.serial_number == other.serial_number
#         )
# 
#     def __ne__(self, other):
#         """
#         Inequality of devices is the negation of equality
#         """
#         return not self.__eq__(other)
# 
#     def __lt__(self, other):
#         """
#         Alphabetical ordering according to device name
#         """
#         return self.name < other.name
# 
#     def __gt__(self, other):
#         """
#         Alphabetical ordering according to device name
#         """
#         return self.name > other.name
# 
#     def __le__(self, other):
#         """
#         Alphabetical ordering according to device name
#         """
#         return self.name <= other.name
# 
#     def __ge__(self, other):
#         """
#         Alphabetical ordering according to device name
#         """
#         return self.name >= other.name
# 
#     def __str__(self):
#         """
#         String representation of devices includes name, port, and VID/PID
#         """
#         s = "{} on {} (VID: 0x{:04X}, PID: 0x{:04X})"
#         return s.format(self.name, self.port, self.vid, self.pid)
# 
#     def __hash__(self):
#         """
#         Hash is the hash of the string representation, includes the same
#         elements in the hash as in equality testing.
#         """
#         return hash(str(self))


# Path: mu/modes/circuitpython.py
import os
import ctypes
import logging
from subprocess import check_output
from mu.modes.base import MicroPythonMode
from mu.modes.api import ADAFRUIT_APIS, SHARED_APIS
from mu.interface.panes import CHARTS
from mu.logic import Device
from adafruit_board_toolkit import circuitpython_serial

            wd = super().workspace_dir()
            if self.connected:
                m = _("Could not find an attached CircuitPython device.")
                info = _(
                    "Python files for CircuitPython devices"
                    " are stored on the device. Therefore, to edit"
                    " these files you need to have the device plugged in."
                    " Until you plug in a device, Mu will use the"
                    " directory found here:\n\n"
                    " {}\n\n...to store your code."
                )
                self.view.show_message(m, info.format(wd))
                self.connected = False
            return wd

    def compatible_board(self, port):
        """Use adafruit_board_toolkit to find out whether a board is running
        CircuitPython. The toolkit sees if the CDC Interface name is appropriate.
        """

        pid = port.productIdentifier()
        vid = port.vendorIdentifier()
        manufacturer = port.manufacturer()
        serial_number = port.serialNumber()
        port_name = self.port_path(port.portName())

        # Find all the CircuitPython REPL comports,
        # and see if any of their device names match the one passed in.
        for comport in circuitpython_serial.repl_comports():
            if comport.device == port_name:

                return Device(