<commit_before>from collections import OrderedDict
from importlib import import_module
from . import Device


def getDeviceClass(name):
    """Return a device class given its name.

    The class must have been defined already, or it must be importable from ``acq4.devices.name``.
    """
    devClasses = getDeviceClasses()

    # If we don't recognize the class name, try importing from builtin devices
    # Note: eventually it would be nice if all device classes can be safely/cheaply
    # imported at startup, rather than dynamically importing them.
    if name not in devClasses:
        try:
            import_module('acq4.devices.' + name)
            devClasses = getDeviceClasses()
        except ImportError:
            pass

    try:
        return devClasses[name]<commit_msg>show errors when device import fails<commit_after>from collections import OrderedDict
from importlib import import_module
from . import Device


def getDeviceClass(name):
    """Return a device class given its name.

    The class must have been defined already, or it must be importable from ``acq4.devices.name``.
    """
    devClasses = getDeviceClasses()

    # If we don't recognize the class name, try importing from builtin devices
    # Note: eventually it would be nice if all device classes can be safely/cheaply
    # imported at startup, rather than dynamically importing them.
    if name not in devClasses:
        try:
            import_module('acq4.devices.' + name)
            devClasses = getDeviceClasses()
        except ImportError as exc:
            print("Warning: error importing device class %s: %s" % (name, str(exc)))

    try:
        return devClasses[name]
{'fraction_non_alphanumeric': 0.06777645659928656, 'fraction_numerical': 0.0023781212841854932, 'mean_word_length': 2.997624703087886, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1273304', 'n_tokens_mistral': 437, 'n_tokens_neox': 419, 'n_words': 184}