# 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
            shutil.rmtree(self.d_themes_path)
        if os.path.exists(self.output_path):
            emptytree(self.output_path)


class TestCliNewWiki(unittest.TestCase):
    def setUp(self):
        wiki_path = os.path.join(test_path, 'mywiki_for_others')
        config_file_tpl = os.path.join(base_path, 'simiki',
                                       'conf_templates', '_config.yml.in')
        self.config_file_dst = os.path.join(wiki_path, '_config.yml')

        shutil.copyfile(config_file_tpl, self.config_file_dst)

        self.args = deepcopy(INIT_ARGS)
        self.title = "hello/simiki"
        self.category = os.path.join('my目录', 'sub-category')
        self.source_path = os.path.join(wiki_path, "content")
        self.odir = os.path.join(wiki_path, "content", self.category)
        self.odir_root = os.path.dirname(self.odir)

        os.chdir(wiki_path)
        if os.path.exists(self.odir_root):
            shutil.rmtree(self.odir_root)

    def test_new_wiki_without_file(self):
        ofile = os.path.join(self.odir, "hello-slash-simiki.md")

        self.args.update({u'new': True, u'-t': self.title,
                          u'-c': self.category})

# 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

            shutil.rmtree(self.d_themes_path)
        if os.path.exists(self.output_path):
            emptytree(self.output_path)


class TestCliNewWiki(unittest.TestCase):
    def setUp(self):
        wiki_path = os.path.join(test_path, 'mywiki_for_others')
        config_file_tpl = os.path.join(base_path, 'simiki',
                                       'conf_templates', '_config.yml.in')
        self.config_file_dst = os.path.join(wiki_path, '_config.yml')

        shutil.copyfile(config_file_tpl, self.config_file_dst)

        self.args = deepcopy(INIT_ARGS)
        self.title = "hello/simiki"
        self.category = os.path.join('my目录', 'sub-category')
        self.source_path = os.path.join(wiki_path, "content")
        self.odir = os.path.join(wiki_path, "content", self.category)
        self.odir_root = os.path.dirname(self.odir)

        os.chdir(wiki_path)
        if os.path.exists(self.odir_root):
            shutil.rmtree(self.odir_root)

    def test_new_wiki_without_file(self):
        ofile = os.path.join(self.odir, "hello-slash-simiki.md")

        self.args.update({u'new': True, u'-t': self.title,
                          u'-c': self.category})

        cli.main(self.args)