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)
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.")
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.")
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.")
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()
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)
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()
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
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 )
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.")
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.")
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))
def test_parse_configs(self): configs = parse_configs(self.config_file) self.assertEqual( configs, self.expect_configs )
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)
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