Ejemplo n.º 1
0
    def setUp(self):
        self.config_file = os.path.join(
            os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
            "simiki/conf_templates/_config.yml.in")

        configs = parse_configs(self.config_file)
        self.generator = PageGenerator(configs, ".", TEST_INPUT_FILE)
Ejemplo n.º 2
0
def main():
    args = docopt(__doc__, version="Simiki {}".format(__version__))
    target_path = os.getcwd()
    if args["-p"]:
        target_path = args["-p"]

    if args["init"]:
        logging_init(logging.DEBUG)
        default_config_file = os.path.join(os.path.dirname(__file__),
                                           "conf_templates",
                                           "_config.yml.in")
        isite = InitSite(default_config_file, target_path)
        isite.init_site()
        return

    config_file = os.path.join(os.getcwd(), "_config.yml")
    configs = parse_configs(config_file)
    level = logging.DEBUG if configs["debug"] else logging.INFO
    logging_init(level)

    if args["generate"]:
        gen = Generator(configs)
        gen.generate(args["--delete"])
    elif args["new"] and args["-t"]:
        pocw = param_of_create_wiki(args["-t"], args["-c"], args["-f"])
        create_new_wiki(configs["source"], *pocw)
    elif args["preview"]:
        preview(configs["destination"])
    else:
        # docopt itself will display the help info.
        pass

    logger.info("Done.")
Ejemplo n.º 3
0
def main():
    args = docopt(__doc__, version="Simiki {}".format(__version__))

    if args["init"]:
        logging_init(logging.DEBUG)
        default_config_file = osp.join(os.path.dirname(__file__), 
                                        "conf_templates/_config.yml.in")
        isite = InitSite(default_config_file)
        isite.init_site()
        sys.exit(1)

    config_file = osp.join(os.getcwd(), "_config.yml")
    configs = parse_configs(config_file)
    level = logging.DEBUG if configs["debug"] else logging.INFO
    logging_init(level)
    simiki = Simiki(configs)

    if args["generate"]:
        simiki.generate()
    elif args["new"] and args["-t"]:
        pocw = param_of_create_wiki(args["-t"], args["-c"], args["-f"])
        simiki.create_new_wiki(*pocw)
    elif args["preview"]:
        simiki.preview()
    else:
        # docopt itself will display the help info.
        pass

    logger.info("Done.")
Ejemplo n.º 4
0
def main():
    args = docopt(__doc__, version="Simiki {}".format(__version__))

    if args["init"]:
        logging_init(logging.DEBUG)
        default_config_file = osp.join(os.path.dirname(__file__),
                                       "conf_templates/_config.yml.in")
        isite = InitSite(default_config_file)
        isite.init_site()
        return

    config_file = osp.join(os.getcwd(), "_config.yml")
    configs = parse_configs(config_file)
    level = logging.DEBUG if configs["debug"] else logging.INFO
    logging_init(level)

    if args["generate"]:
        gen = Generator(configs)
        gen.generate(args["--delete"])
    elif args["new"] and args["-t"]:
        pocw = param_of_create_wiki(args["-t"], args["-c"], args["-f"])
        create_new_wiki(configs["source"], *pocw)
    elif args["preview"]:
        preview(configs["destination"])
    else:
        # docopt itself will display the help info.
        pass

    logger.info("Done.")
Ejemplo n.º 5
0
 def __init__(self, config_file):
     self.config_file = config_file
     if not check_path_exists(self.config_file):
         logging.error("{} not exists".format(self.config_file))
         sys.exit(1)
     self.configs = parse_configs(self.config_file)
     self.current_dir = os.getcwd()
Ejemplo n.º 6
0
    def setUp(self):
        self.config_file = osp.join(
            osp.dirname(osp.dirname(osp.abspath(__file__))),
            "simiki/conf_templates/_config.yml.in"
        )

        configs = parse_configs(self.config_file)
        self.generator = PageGenerator(configs, TESTS_ROOT, TEST_INPUT_FILE)
Ejemplo n.º 7
0
 def __init__(self, config_file):
     self.config_file = config_file
     if not check_path_exists(self.config_file):
         logging.error("{} not exists".format(self.config_file))
         sys.exit(1)
     try:
         self.configs = parse_configs(self.config_file)
     except Exception as e:
         logging.error(str(e))
     self.current_dir = os.getcwd()
Ejemplo n.º 8
0
 def __init__(self, config_file, target_path):
     self.config_file = config_file
     if not check_path_exists(self.config_file):
         logging.error("{} not exists".format(self.config_file))
         sys.exit(1)
     try:
         self.configs = parse_configs(self.config_file)
     except Exception as e:
         logging.error(str(e))
     self.source_path = os.path.dirname(__file__)
     self.target_path = target_path
Ejemplo n.º 9
0
 def __init__(self, config_file, target_path):
     self.config_file = config_file
     if not check_path_exists(self.config_file):
         logging.error("{} not exists".format(self.config_file))
         sys.exit(1)
     try:
         self.configs = parse_configs(self.config_file)
     except Exception as e:
         logging.error(str(e))
     self.source_path = os.path.dirname(__file__)
     self.target_path = target_path
Ejemplo n.º 10
0
 def test_configs_url(self):
     config_file = os.path.join(
         os.path.dirname(__file__),
         "configs",
         "test_url.yml"
     )
     self.expect_configs["url"] = "http://wiki.tankywoo.com"
     configs = parse_configs(config_file)
     self.assertEqual(
         configs,
         self.expect_configs
     )
Ejemplo n.º 11
0
def execute(args):
    logging_init(logging.DEBUG)

    target_path = os.getcwd()
    if args["-p"]:
        target_path = args["-p"]
    if not isinstance(target_path, unicode):
        target_path = unicode(target_path, "utf-8")

    if args["init"]:
        default_config_file = os.path.join(os.path.dirname(__file__),
                                           "conf_templates",
                                           "_config.yml.in")
        try:
            isite = InitSite(default_config_file, target_path)
            isite.init_site()
        except Exception as e:
            logging.exception("{0}\n{1}"
                              .format(str(e), traceback.format_exc()))
        return

    config_file = os.path.join(target_path, "_config.yml")
    try:
        configs = parse_configs(config_file)
    except (Exception, YAMLError) as e:
        logging.exception("{0}\n{1}".format(str(e), traceback.format_exc()))
        return
    level = logging.DEBUG if configs["debug"] else logging.INFO
    logging_init(level)

    if args["generate"]:
        if args["--ignore-root"]:
            configs.update({u"root": u"/"})
        gen = Generator(configs)
        gen.generate(args["--delete"])
    elif args["new"] and args["-t"]:
        pocw = param_of_create_wiki(args["-t"], args["-c"], args["-f"],
                                    configs["default_ext"])
        create_new_wiki(configs["source"], *pocw)
    elif args["preview"]:
        preview(configs["destination"])
    else:
        # docopt itself will display the help info.
        pass

    logger.info("Done.")
Ejemplo n.º 12
0
def execute(args):
    logging_init(logging.DEBUG)

    target_path = os.getcwd()
    if args["-p"]:
        target_path = args["-p"]
    if not isinstance(target_path, unicode):
        target_path = unicode(target_path, "utf-8")

    if args["init"]:
        default_config_file = os.path.join(os.path.dirname(__file__),
                                           "conf_templates", "_config.yml.in")
        try:
            isite = InitSite(default_config_file, target_path)
            isite.init_site()
        except Exception as e:
            logging.exception("{0}\n{1}".format(str(e),
                                                traceback.format_exc()))
        return

    config_file = os.path.join(target_path, "_config.yml")
    try:
        configs = parse_configs(config_file)
    except (Exception, YAMLError) as e:
        logging.exception("{0}\n{1}".format(str(e), traceback.format_exc()))
        return
    level = logging.DEBUG if configs["debug"] else logging.INFO
    logging_init(level)

    if args["generate"]:
        if args["--ignore-root"]:
            configs.update({u"root": u"/"})
        gen = Generator(configs)
        gen.generate(args["--delete"])
    elif args["new"] and args["-t"]:
        pocw = param_of_create_wiki(args["-t"], args["-c"], args["-f"],
                                    configs["default_ext"])
        create_new_wiki(configs["source"], *pocw)
    elif args["preview"]:
        preview(configs["destination"])
    else:
        # docopt itself will display the help info.
        pass

    logger.info("Done.")
Ejemplo n.º 13
0
 def test_parse_configs_not_exist(self):
     not_exist_config_file = os.path.join(self.config_file, "not_exist")
     self.assertRaises(Exception, lambda: parse_configs(not_exist_config_file))
Ejemplo n.º 14
0
 def test_parse_configs(self):
     configs = parse_configs(self.config_file)
     self.assertEqual(
         configs,
         self.expect_configs
     )
Ejemplo n.º 15
0
 def test_parse_configs_not_exist(self):
     not_exist_config_file = os.path.join(self.config_file, "not_exist")
     self.assertRaises(Exception,
                       lambda: parse_configs(not_exist_config_file))
Ejemplo n.º 16
0
 def test_parse_configs(self):
     configs = parse_configs(self.config_file)
     self.assertEqual(
         configs,
         self.expect_configs
     )
Ejemplo n.º 17
0
 def test_configs_url(self):
     config_file = os.path.join(os.path.dirname(__file__), "configs", "test_url.yml")
     self.expect_configs["url"] = "http://wiki.tankywoo.com"
     configs = parse_configs(config_file)
     self.assertEqual(configs, self.expect_configs)
Ejemplo n.º 18
0
 def __init__(self, config_file, target_path):
     self.config_file = config_file
     self.configs = parse_configs(self.config_file)
     self.source_path = os.path.dirname(__file__)
     self.target_path = target_path