def get_network_driver(name, prepend=True):
if name == "<STR_LIT>":<EOL><INDENT>return MockDriver<EOL><DEDENT>if not (isinstance(name, py23_compat.string_types) and len(name) > <NUM_LIT:0>):<EOL><INDENT>raise ModuleImportError("<STR_LIT>")<EOL><DEDENT>name = name.lower()<EOL>module_install_name = name.replace("<STR_LIT:->", "<STR_LIT>")<EOL>community_install_name = "<STR_LIT>".format(name=module_install_name)<EOL>custom_install_name = "<STR_LIT>".format(name=module_install_name)<EOL>if "<STR_LIT>" not in module_install_name and prepend is True:<EOL><INDENT>module_install_name = "<STR_LIT>".format(name=module_install_name)<EOL><DEDENT>for module_name in [<EOL>custom_install_name,<EOL>module_install_name,<EOL>community_install_name,<EOL>]:<EOL><INDENT>try:<EOL><INDENT>module = importlib.import_module(module_name)<EOL>break<EOL><DEDENT>except ImportError as e:<EOL><INDENT>message = py23_compat.text_type(e)<EOL>if "<STR_LIT>" in message:<EOL><INDENT>failed_module = message.split()[-<NUM_LIT:1>]<EOL>if failed_module.replace("<STR_LIT:'>", "<STR_LIT>") in module_name:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>raise e<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ModuleImportError(<EOL>'<STR_LIT>'.format(<EOL>install_name=name<EOL>)<EOL>)<EOL><DEDENT>for name, obj in inspect.getmembers(module):<EOL><INDENT>if inspect.isclass(obj) and issubclass(obj, NetworkDriver):<EOL><INDENT>return obj<EOL><DEDENT><DEDENT>raise ModuleImportError(<EOL>'<STR_LIT>'.format(<EOL>install_name=module_install_name<EOL>)<EOL>)<EOL>
Searches for a class derived form the base NAPALM class NetworkDriver in a specific library.
The library name must repect the following pattern: napalm_[DEVICE_OS].
NAPALM community supports a list of devices and provides the corresponding libraries; for
full reference please refer to the `Supported Network Operation Systems`_ paragraph on
`Read the Docs`_.

.. _`Supported Network Operation Systems`: \
http://napalm.readthedocs.io/en/latest/#supported-network-operating-systems
.. _`Read the Docs`: \
http://napalm.readthedocs.io/

:param name:         the name of the device operating system or the name of the library.
:return:                    the first class derived from NetworkDriver, found in the library.
:raise ModuleImportError:   when the library is not installed or a derived class from \
NetworkDriver was not found.

Example::

.. code-block:: python

    >>> get_network_driver('junos')
    <class 'napalm.junos.junos.JunOSDriver'>
    >>> get_network_driver('IOS-XR')
    <class 'napalm.iosxr.iosxr.IOSXRDriver'>
    >>> get_network_driver('napalm.eos')
    <class 'napalm.eos.eos.EOSDriver'>
    >>> get_network_driver('wrong')
    napalm.base.exceptions.ModuleImportError: Cannot import "napalm_wrong". Is the library \
    installed?