# Path: simiki/cli.py
# def init_site(target_path):
# def create_new_wiki(category, title, filename):
# def preview_site(host, port, dest, root, do_watch):
# def method_proxy(cls_instance, method_name, *args, **kwargs):
#     def __init__(self, target_path):
#     def generate(self, include_draft=False):
#     def generate_tags(self):
#     def generate_feed(self, pages, feed_fn):
#     def generate_catalog(self, pages):
#     def generate_pages(self):
#     def generate_multiple_pages(self, md_files):
#     def generate_single_page(self, generator, md_file):
#     def _generate_callback(self, result):
#     def install_theme(self):
#     def copy_attach(self):
# def unicode_docopt(args):
# def main(args=None):
# class Generator(object):
# 
# Path: simiki/utils.py
# def copytree(src, dst, symlinks=False, ignore=None):
#     """Copy from source directory to destination"""
# 
#     if not os.path.exists(dst):
#         os.makedirs(dst)
#     for item in os.listdir(src):
#         s = os.path.join(src, item)
#         d = os.path.join(dst, item)
#         if os.path.isdir(s):
#             copytree(s, d, symlinks, ignore)
#         else:
#             shutil.copy2(s, d)
# 
# def emptytree(directory, exclude_list=None):
#     """Delete all the files and dirs under specified directory"""
# 
#     if not isinstance(directory, unicode):
#         directory = unicode(directory, 'utf-8')
#     if not exclude_list:
#         exclude_list = []
#     for p in os.listdir(directory):
#         if p in exclude_list:
#             continue
#         fp = os.path.join(directory, p)
#         if os.path.isdir(fp):
#             try:
#                 shutil.rmtree(fp)
#                 logger.debug("Delete directory %s", fp)
#             except OSError as e:
#                 logger.error("Unable to delete directory %s: %s",
#                              fp, unicode(e))
#         elif os.path.isfile(fp):
#             try:
#                 logging.debug("Delete file %s", fp)
#                 os.remove(fp)
#             except OSError as e:
#                 logger.error("Unable to delete file %s: %s", fp, unicode(e))
#         else:
#             logger.error("Unable to delete %s, unknown filetype", fp)
# 
# Path: simiki/config.py
# def get_default_config():
#     return _post_process(_set_default_config())


import os
import os.path
import shutil
import unittest
import io
from copy import deepcopy
from simiki import cli
from simiki.utils import copytree, emptytree
from simiki.config import get_default_config
        self.dirs = [
            self.default_config['source'],
            self.default_config['destination'],
            self.default_config['themes_dir'],
            os.path.join(self.default_config['themes_dir'],
                         self.default_config['theme']),
        ]

    def test_init(self):
        os.chdir(test_path)
        self.args.update({u'init': True, u'-p': self.target_path})
        cli.main(self.args)
        for f in self.files:
            self.assertTrue(os.path.isfile(os.path.join(self.target_path, f)))

        for d in self.dirs:
            self.assertTrue(os.path.isdir(os.path.join(self.target_path, d)))

    def tearDown(self):
        if os.path.exists(self.target_path):
            shutil.rmtree(self.target_path)


class TestCliGenerate(unittest.TestCase):
    def setUp(self):
        self.args = deepcopy(INIT_ARGS)
        self.wiki_path = os.path.join(test_path, "mywiki_for_cli")
        self.output_path = os.path.join(self.wiki_path, "output")

        if os.path.exists(self.output_path):

# Path: simiki/cli.py
# def init_site(target_path):
# def create_new_wiki(category, title, filename):
# def preview_site(host, port, dest, root, do_watch):
# def method_proxy(cls_instance, method_name, *args, **kwargs):
#     def __init__(self, target_path):
#     def generate(self, include_draft=False):
#     def generate_tags(self):
#     def generate_feed(self, pages, feed_fn):
#     def generate_catalog(self, pages):
#     def generate_pages(self):
#     def generate_multiple_pages(self, md_files):
#     def generate_single_page(self, generator, md_file):
#     def _generate_callback(self, result):
#     def install_theme(self):
#     def copy_attach(self):
# def unicode_docopt(args):
# def main(args=None):
# class Generator(object):
# 
# Path: simiki/utils.py
# def copytree(src, dst, symlinks=False, ignore=None):
#     """Copy from source directory to destination"""
# 
#     if not os.path.exists(dst):
#         os.makedirs(dst)
#     for item in os.listdir(src):
#         s = os.path.join(src, item)
#         d = os.path.join(dst, item)
#         if os.path.isdir(s):
#             copytree(s, d, symlinks, ignore)
#         else:
#             shutil.copy2(s, d)
# 
# def emptytree(directory, exclude_list=None):
#     """Delete all the files and dirs under specified directory"""
# 
#     if not isinstance(directory, unicode):
#         directory = unicode(directory, 'utf-8')
#     if not exclude_list:
#         exclude_list = []
#     for p in os.listdir(directory):
#         if p in exclude_list:
#             continue
#         fp = os.path.join(directory, p)
#         if os.path.isdir(fp):
#             try:
#                 shutil.rmtree(fp)
#                 logger.debug("Delete directory %s", fp)
#             except OSError as e:
#                 logger.error("Unable to delete directory %s: %s",
#                              fp, unicode(e))
#         elif os.path.isfile(fp):
#             try:
#                 logging.debug("Delete file %s", fp)
#                 os.remove(fp)
#             except OSError as e:
#                 logger.error("Unable to delete file %s: %s", fp, unicode(e))
#         else:
#             logger.error("Unable to delete %s, unknown filetype", fp)
# 
# Path: simiki/config.py
# def get_default_config():
#     return _post_process(_set_default_config())


# Path: tests/test_cli.py
import os
import os.path
import shutil
import unittest
import io
from copy import deepcopy
from simiki import cli
from simiki.utils import copytree, emptytree
from simiki.config import get_default_config

        self.dirs = [
            self.default_config['source'],
            self.default_config['destination'],
            self.default_config['themes_dir'],
            os.path.join(self.default_config['themes_dir'],
                         self.default_config['theme']),
        ]

    def test_init(self):
        os.chdir(test_path)
        self.args.update({u'init': True, u'-p': self.target_path})
        cli.main(self.args)
        for f in self.files:
            self.assertTrue(os.path.isfile(os.path.join(self.target_path, f)))

        for d in self.dirs:
            self.assertTrue(os.path.isdir(os.path.join(self.target_path, d)))

    def tearDown(self):
        if os.path.exists(self.target_path):
            shutil.rmtree(self.target_path)


class TestCliGenerate(unittest.TestCase):
    def setUp(self):
        self.args = deepcopy(INIT_ARGS)
        self.wiki_path = os.path.join(test_path, "mywiki_for_cli")
        self.output_path = os.path.join(self.wiki_path, "output")

        if os.path.exists(self.output_path):

            emptytree(self.output_path)