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() 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 execute(args): global config logging_init(logging.DEBUG) target_path = args['-p'] if args['-p'] else os.getcwdu() if args["init"]: init_site(target_path) return config_file = os.path.join(target_path, "_config.yml") try: config = parse_config(config_file) except (Exception, YAMLError) as e: # always in debug mode when parse config logging.exception("Parse config with error:") sys.exit(1) level = logging.DEBUG if config["debug"] else logging.INFO logging_init(level) # reload logger if args["generate"]: generator = Generator(target_path) generator.generate() elif args["new"]: create_new_wiki(args["-c"], args["-t"], args["-f"]) elif args["preview"]: args['--port'] = int(args['--port']) preview(config["destination"], config['root'], args["--host"], args["--port"]) else: # docopt itself will display the help info. pass
def execute(args): logging_init(logging.DEBUG) target_path = args['-p'].decode('utf-8') if args['-p'] else os.getcwdu() if args["init"]: default_config_file = os.path.join(os.path.dirname(__file__), "conf_templates", "_config.yml.in") try: init_site = InitSite(default_config_file, target_path) init_site.init_site() default_config = parse_config(default_config_file) install_theme(target_path, default_config["themes_dir"], default_config["theme"], default_config["destination"]) except Exception as e: logging.exception("Init site: {0}\n{1}" .format(unicode(e), traceback.format_exc())) sys.exit(1) else: config_file = os.path.join(target_path, "_config.yml") try: config = parse_config(config_file) except (Exception, YAMLError) as e: logging.exception("Parse config: {0}\n{1}" .format(unicode(e), traceback.format_exc())) sys.exit(1) level = logging.DEBUG if config["debug"] else logging.INFO logging_init(level) # reload logger if args["generate"]: if args["--ignore-root"]: config.update({u"root": u"/"}) generator = Generator(config) generator.generate(args["--delete"], args["--update-theme"]) elif args["new"]: pocw = param_of_create_wiki(args["-t"], args["-c"], args["-f"], config["default_ext"]) create_new_wiki(config["source"], *pocw) elif args["preview"]: preview(config["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 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 preview(self): default_path = self.configs["destination"] preview(default_path)