# Path: simiki/config.py
# def get_default_config():
#     return _post_process(_set_default_config())
# 
# Path: simiki/initiator.py
# class Initiator(object):
#     conf_template_dn = "conf_templates"
#     config_fn = "_config.yml"
#     fabfile_fn = "fabfile.py"
#     demo_fn = "gettingstarted.md"
#     dockerfile_fn = "Dockerfile"
# 
#     def __init__(self, config_file, target_path):
#         self.config_file = config_file
#         self.config = parse_config(self.config_file)
#         self.source_path = os.path.dirname(__file__)
#         self.target_path = target_path
# 
#     @staticmethod
#     def get_file(src, dst):
#         if os.path.exists(dst):
#             logging.warning("{0} exists".format(dst))
#             return
# 
#         # Create parent directory
#         dst_directory = os.path.dirname(dst)
#         if not os.path.exists(dst_directory):
#             mkdir_p(dst_directory)
#             logging.info("Creating directory: {0}".format(dst_directory))
# 
#         shutil.copyfile(src, dst)
#         logging.info("Creating file: {0}".format(dst))
# 
#     def get_config_file(self):
#         dst_config_file = os.path.join(self.target_path, self.config_fn)
#         self.get_file(self.config_file, dst_config_file)
# 
#     def get_fabfile(self):
#         src_fabfile = os.path.join(
#             self.source_path,
#             self.conf_template_dn,
#             self.fabfile_fn
#         )
#         dst_fabfile = os.path.join(self.target_path, self.fabfile_fn)
#         self.get_file(src_fabfile, dst_fabfile)
# 
#     def get_dockerfile(self):
#         src_dockerfile = os.path.join(
#             self.source_path,
#             self.conf_template_dn,
#             self.dockerfile_fn
#         )
#         dst_dockerfile = os.path.join(self.target_path, self.dockerfile_fn)
#         self.get_file(src_dockerfile, dst_dockerfile)
# 
#     def get_demo_page(self):
#         nohidden_dir = listdir_nohidden(
#             os.path.join(self.target_path, self.config['source']))
#         # If there is file/directory under content, do not create first page
#         if next(nohidden_dir, False):
#             return
# 
#         src_demo = os.path.join(self.source_path, self.conf_template_dn,
#                                 self.demo_fn)
#         dst_demo = os.path.join(self.target_path, "content", "intro",
#                                 self.demo_fn)
#         self.get_file(src_demo, dst_demo)
# 
#     def get_default_theme(self, theme_path):
#         default_theme_name = self.config['theme']
#         src_theme = os.path.join(self.source_path, self.config['themes_dir'],
#                                  default_theme_name)
#         dst_theme = os.path.join(theme_path, default_theme_name)
#         if os.path.exists(dst_theme):
#             logging.warning('{0} exists'.format(dst_theme))
#         else:
#             copytree(src_theme, dst_theme)
#             logging.info("Copying default theme '{0}' to: {1}"
#                          .format(default_theme_name, theme_path))
# 
#     def init(self, ask=False, **kwargs):
#         content_path = os.path.join(self.target_path, self.config["source"])
#         output_path = os.path.join(self.target_path,
#                                    self.config["destination"])
#         theme_path = os.path.join(self.target_path, self.config['themes_dir'])
#         for path in (content_path, output_path, theme_path):
#             if os.path.exists(path):
#                 logging.warning("{0} exists".format(path))
#             else:
#                 mkdir_p(path)
#                 logging.info("Creating directory: {0}".format(path))
# 
#         self.get_config_file()
#         self.get_fabfile()
#         self.get_demo_page()
#         self.get_default_theme(theme_path)
# 
#         if ask is True:
#             try:
#                 _ans = raw_input('Create Dockerfile? (y/N) ')
#                 if _ans.lower() in yes_answer:
#                     self.get_dockerfile()
#             except (KeyboardInterrupt, SystemExit):
#                 print()  # newline with Ctrl-C
#         elif ask is False and kwargs.get('dockerfile', False):
#             self.get_dockerfile()


import os
import os.path
import unittest
import shutil
from simiki.config import get_default_config
from simiki.initiator import Initiator
            "fabfile.py",
            os.path.join(self.default_config['source'], "intro",
                         "gettingstarted.md"),
        ]
        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_target_exist(self):
        """ test Initiator target path exist
        """

        i = Initiator(self.config_file, self.target_path)
        i.init(ask=False)

        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 test_target_invalid(self):
        """ test Initiator target path invalid, raise OSError
        """

        target_error = "/foo/bar/why/not"

# Path: simiki/config.py
# def get_default_config():
#     return _post_process(_set_default_config())
# 
# Path: simiki/initiator.py
# class Initiator(object):
#     conf_template_dn = "conf_templates"
#     config_fn = "_config.yml"
#     fabfile_fn = "fabfile.py"
#     demo_fn = "gettingstarted.md"
#     dockerfile_fn = "Dockerfile"
# 
#     def __init__(self, config_file, target_path):
#         self.config_file = config_file
#         self.config = parse_config(self.config_file)
#         self.source_path = os.path.dirname(__file__)
#         self.target_path = target_path
# 
#     @staticmethod
#     def get_file(src, dst):
#         if os.path.exists(dst):
#             logging.warning("{0} exists".format(dst))
#             return
# 
#         # Create parent directory
#         dst_directory = os.path.dirname(dst)
#         if not os.path.exists(dst_directory):
#             mkdir_p(dst_directory)
#             logging.info("Creating directory: {0}".format(dst_directory))
# 
#         shutil.copyfile(src, dst)
#         logging.info("Creating file: {0}".format(dst))
# 
#     def get_config_file(self):
#         dst_config_file = os.path.join(self.target_path, self.config_fn)
#         self.get_file(self.config_file, dst_config_file)
# 
#     def get_fabfile(self):
#         src_fabfile = os.path.join(
#             self.source_path,
#             self.conf_template_dn,
#             self.fabfile_fn
#         )
#         dst_fabfile = os.path.join(self.target_path, self.fabfile_fn)
#         self.get_file(src_fabfile, dst_fabfile)
# 
#     def get_dockerfile(self):
#         src_dockerfile = os.path.join(
#             self.source_path,
#             self.conf_template_dn,
#             self.dockerfile_fn
#         )
#         dst_dockerfile = os.path.join(self.target_path, self.dockerfile_fn)
#         self.get_file(src_dockerfile, dst_dockerfile)
# 
#     def get_demo_page(self):
#         nohidden_dir = listdir_nohidden(
#             os.path.join(self.target_path, self.config['source']))
#         # If there is file/directory under content, do not create first page
#         if next(nohidden_dir, False):
#             return
# 
#         src_demo = os.path.join(self.source_path, self.conf_template_dn,
#                                 self.demo_fn)
#         dst_demo = os.path.join(self.target_path, "content", "intro",
#                                 self.demo_fn)
#         self.get_file(src_demo, dst_demo)
# 
#     def get_default_theme(self, theme_path):
#         default_theme_name = self.config['theme']
#         src_theme = os.path.join(self.source_path, self.config['themes_dir'],
#                                  default_theme_name)
#         dst_theme = os.path.join(theme_path, default_theme_name)
#         if os.path.exists(dst_theme):
#             logging.warning('{0} exists'.format(dst_theme))
#         else:
#             copytree(src_theme, dst_theme)
#             logging.info("Copying default theme '{0}' to: {1}"
#                          .format(default_theme_name, theme_path))
# 
#     def init(self, ask=False, **kwargs):
#         content_path = os.path.join(self.target_path, self.config["source"])
#         output_path = os.path.join(self.target_path,
#                                    self.config["destination"])
#         theme_path = os.path.join(self.target_path, self.config['themes_dir'])
#         for path in (content_path, output_path, theme_path):
#             if os.path.exists(path):
#                 logging.warning("{0} exists".format(path))
#             else:
#                 mkdir_p(path)
#                 logging.info("Creating directory: {0}".format(path))
# 
#         self.get_config_file()
#         self.get_fabfile()
#         self.get_demo_page()
#         self.get_default_theme(theme_path)
# 
#         if ask is True:
#             try:
#                 _ans = raw_input('Create Dockerfile? (y/N) ')
#                 if _ans.lower() in yes_answer:
#                     self.get_dockerfile()
#             except (KeyboardInterrupt, SystemExit):
#                 print()  # newline with Ctrl-C
#         elif ask is False and kwargs.get('dockerfile', False):
#             self.get_dockerfile()


# Path: tests/test_initiator.py
import os
import os.path
import unittest
import shutil
from simiki.config import get_default_config
from simiki.initiator import Initiator

            "fabfile.py",
            os.path.join(self.default_config['source'], "intro",
                         "gettingstarted.md"),
        ]
        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_target_exist(self):
        """ test Initiator target path exist
        """

        i = Initiator(self.config_file, self.target_path)
        i.init(ask=False)

        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 test_target_invalid(self):
        """ test Initiator target path invalid, raise OSError
        """

        target_error = "/foo/bar/why/not"

        i = Initiator(self.config_file, target_error)