# Path: confduino/exampallremove.py
# @entrypoint
# def remove_examples_all():
#     """remove arduino/examples/all directory.
# 
#     :rtype: None
# 
#     """
#     d = examples_all_dir()
#     if d.exists():
#         log.debug('remove %s', d)
#         d.rmtree()
#     else:
#         log.debug('nothing to remove: %s', d)
# 
# Path: confduino/examplist.py
# def examples_all_dir():
#     """return arduino/examples/all directory.
# 
#     :rtype: string
# 
#     """
#     x = examples_dir() / 'all'
#     return x
# 
# 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 lib_examples(lib):
#     """return library examples.
# 
#     EXAMPLE1,EXAMPLE2,..
# 
#     """
#     d = lib_examples_dir(lib)
#     if not d.exists():
#         return []
#     ls = d.dirs()
#     ls = [x.name for x in ls]
#     ls.sort()
#     return ls
# 
# def lib_example_dir(lib, example):
#     """return library example directory.
# 
#     $ARDUINO/libraries/$LIB/examples/$EXAMPLE
# 
#     """
#     return lib_examples_dir(lib) / example


from confduino.exampallremove import remove_examples_all
from confduino.examplist import examples_all_dir
from confduino.liblist import libraries, lib_examples, lib_example_dir
from entrypoint2 import entrypoint
import logging
import os

log = logging.getLogger(__name__)


@entrypoint
def create_examples_all():
    """create arduino/examples/all directory.

    :rtype: None

    """
    remove_examples_all()
    examples_all_dir().mkdir()

    for lib in libraries():

# Path: confduino/exampallremove.py
# @entrypoint
# def remove_examples_all():
#     """remove arduino/examples/all directory.
# 
#     :rtype: None
# 
#     """
#     d = examples_all_dir()
#     if d.exists():
#         log.debug('remove %s', d)
#         d.rmtree()
#     else:
#         log.debug('nothing to remove: %s', d)
# 
# Path: confduino/examplist.py
# def examples_all_dir():
#     """return arduino/examples/all directory.
# 
#     :rtype: string
# 
#     """
#     x = examples_dir() / 'all'
#     return x
# 
# 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 lib_examples(lib):
#     """return library examples.
# 
#     EXAMPLE1,EXAMPLE2,..
# 
#     """
#     d = lib_examples_dir(lib)
#     if not d.exists():
#         return []
#     ls = d.dirs()
#     ls = [x.name for x in ls]
#     ls.sort()
#     return ls
# 
# def lib_example_dir(lib, example):
#     """return library example directory.
# 
#     $ARDUINO/libraries/$LIB/examples/$EXAMPLE
# 
#     """
#     return lib_examples_dir(lib) / example


# Path: confduino/exampallcreate.py
from confduino.exampallremove import remove_examples_all
from confduino.examplist import examples_all_dir
from confduino.liblist import libraries, lib_examples, lib_example_dir
from entrypoint2 import entrypoint
import logging
import os


log = logging.getLogger(__name__)


@entrypoint
def create_examples_all():
    """create arduino/examples/all directory.

    :rtype: None

    """
    remove_examples_all()
    examples_all_dir().mkdir()

    for lib in libraries():

        maindir = examples_all_dir() / lib.upper()[0:1] / lib