# Path: confduino/liblist.py
# def libraries():
#     """return installed library names."""
#     ls = libraries_dir().dirs()
#     ls = [str(x.name) for x in ls]
#     ls.sort()
#     return ls
# 
# def libraries_dir():
#     """return library root path.
# 
#     $ARDUINO/libraries
# 
#     """
#     x = arduino_path() / 'libraries'
#     assert x.exists(), x
#     return x
# 
# Path: confduino/libremove.py
# @entrypoint
# def remove_lib(lib_name):
#     """remove library.
# 
#     :param lib_name: library name (e.g. 'PS2Keyboard')
#     :rtype: None
# 
#     """
#     targ_dlib = libraries_dir() / lib_name
#     log.debug('remove %s', targ_dlib)
#     targ_dlib.rmtree()


from confduino.liblist import libraries, libraries_dir
from confduino.libremove import remove_lib
from entrypoint2 import entrypoint
import psidialogs


@entrypoint
def gui():
    """remove libraries by GUI."""

    sel = psidialogs.multi_choice(libraries(),
                                  'select libraries to remove from %s!' % libraries_dir(),
                                  title='remove boards')
    print('%s selected' % sel)

    if sel:
        if psidialogs.ask_yes_no('Do you really want to remove selected libraries?\n' + '\n'.join(sel)):
            for x in sel:

# Path: confduino/liblist.py
# def libraries():
#     """return installed library names."""
#     ls = libraries_dir().dirs()
#     ls = [str(x.name) for x in ls]
#     ls.sort()
#     return ls
# 
# def libraries_dir():
#     """return library root path.
# 
#     $ARDUINO/libraries
# 
#     """
#     x = arduino_path() / 'libraries'
#     assert x.exists(), x
#     return x
# 
# Path: confduino/libremove.py
# @entrypoint
# def remove_lib(lib_name):
#     """remove library.
# 
#     :param lib_name: library name (e.g. 'PS2Keyboard')
#     :rtype: None
# 
#     """
#     targ_dlib = libraries_dir() / lib_name
#     log.debug('remove %s', targ_dlib)
#     targ_dlib.rmtree()


# Path: confduino/examples/remove_libraries.py
from confduino.liblist import libraries, libraries_dir
from confduino.libremove import remove_lib
from entrypoint2 import entrypoint
import psidialogs



@entrypoint
def gui():
    """remove libraries by GUI."""

    sel = psidialogs.multi_choice(libraries(),
                                  'select libraries to remove from %s!' % libraries_dir(),
                                  title='remove boards')
    print('%s selected' % sel)

    if sel:
        if psidialogs.ask_yes_no('Do you really want to remove selected libraries?\n' + '\n'.join(sel)):
            for x in sel:

                remove_lib(x)