コード例 #1
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.")
コード例 #2
0
ファイル: cli.py プロジェクト: duoduo369/simiki
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.")
コード例 #3
0
ファイル: cli.py プロジェクト: hihihippp/simiki
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.")
コード例 #4
0
ファイル: cli.py プロジェクト: noname007/simiki
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
コード例 #5
0
ファイル: test_log.py プロジェクト: Aden404/simiki
 def setUp(self):
     logging.disable(logging.NOTSET)
     self.stream = StringIO()
     self.logger = logging.getLogger()
     self.handler = logging.StreamHandler(self.stream)
     for handler in self.logger.handlers:
         # exclude nosetest capture handler
         if not isinstance(handler,
                           nose.plugins.logcapture.MyMemoryHandler):
             self.logger.removeHandler(handler)
     logging_init(level=logging.DEBUG, handler=self.handler)
コード例 #6
0
ファイル: test_log.py プロジェクト: zrinthect/simiki
 def setUp(self):
     logging.disable(logging.NOTSET)
     self.stream = StringIO()
     self.logger = logging.getLogger()
     self.handler = logging.StreamHandler(self.stream)
     for handler in self.logger.handlers:
         # exclude nosetest capture handler
         if not isinstance(handler,
                           nose.plugins.logcapture.MyMemoryHandler):
             self.logger.removeHandler(handler)
     logging_init(level=logging.DEBUG, handler=self.handler)
コード例 #7
0
ファイル: cli.py プロジェクト: diguage/simiki
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.")
コード例 #8
0
ファイル: cli.py プロジェクト: 8dspaces/simiki
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.")
コード例 #9
0
ファイル: cli.py プロジェクト: sushimuyu/simiki
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.")
コード例 #10
0
ファイル: cli.py プロジェクト: Aden404/simiki
def main(args=None):
    global config

    if not args:
        args = docopt(__doc__, version="Simiki {0}".format(__version__))
    unicode_docopt(args)

    logging_init(logging.DEBUG)

    target_path = args['-p'] if args['-p'] else getcwdu()

    if args["init"]:
        init_site(target_path)
    else:
        config_file = os.path.join(target_path, "_config.yml")
        try:
            config = parse_config(config_file)
        except (Exception, YAMLError):
            # 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"] or args["g"]:
            generator = Generator(target_path)
            generator.generate(include_draft=args['--draft'])
        elif args["new"] or args["n"]:
            create_new_wiki(args["-c"], args["-t"], args["-f"])
        elif args["preview"] or args["p"]:
            args['--port'] = int(args['--port'])
            preview_site(args['--host'], args['--port'], config['destination'],
                         config['root'], args['-w'])
        elif args["update"]:
            update_builtin(themes_dir=config['themes_dir'])
        else:
            # docopt itself will display the help info.
            pass

    logger.info("Done.")
コード例 #11
0
ファイル: cli.py プロジェクト: ferstar/simiki
def main(args=None):
    global config

    if not args:
        args = docopt(__doc__, version="Simiki {0}".format(__version__))
    unicode_docopt(args)

    logging_init(logging.DEBUG)

    target_path = args['-p'] if args['-p'] else getcwdu()

    if args["init"]:
        init_site(target_path)
    else:
        config_file = os.path.join(target_path, "_config.yml")
        try:
            config = parse_config(config_file)
        except (Exception, YAMLError):
            # 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"] or args["g"]:
            generator = Generator(target_path)
            generator.generate()
        elif args["new"] or args["n"]:
            create_new_wiki(args["-c"], args["-t"], args["-f"])
        elif args["preview"] or args["p"]:
            args['--port'] = int(args['--port'])
            preview_site(args['--host'], args['--port'], config['destination'],
                         config['root'], args['-w'])
        elif args["update"]:
            update_builtin()
        else:
            # docopt itself will display the help info.
            pass

    logger.info("Done.")
コード例 #12
0
    def init_site(self):
        content_path = osp.join(self.current_dir, self.configs["source"])
        output_path = osp.join(self.current_dir, self.configs["destination"])
        theme_path = osp.join(self.current_dir, "themes")
        for path in (content_path, output_path, theme_path):
            if osp.exists(path):
                logging.warning("{} exists".format(path))
            else:
                os.mkdir(path)
                logging.info("Creating directory: {}".format(path))

        self.get_config_file()
        self.get_fabfile()
        self.get_first_page()
        self.get_default_theme(theme_path)

if __name__ == "__main__":
    logging_init(logging.DEBUG)
    BASE_DIR = os.getcwd()
    if len(sys.argv) == 1:
        config_file = osp.join(BASE_DIR, "_config.yml")
    elif len(sys.argv) == 2:
        config_file = osp.join(BASE_DIR, sys.argv[1])
    else:
        logging.error("Usage: `python -m simiki.configs [config.yml]'")
        sys.exit(1)

    i = InitSite(config_file)
    i.init_site()
コード例 #13
0
ファイル: test_log.py プロジェクト: 8dspaces/simiki
 def setUp(self):
     self.stream = StringIO()
     self.handler = logging.StreamHandler(self.stream)
     logging_init(level=logging.DEBUG, handler=self.handler)
     self.logger = logging.getLogger()
コード例 #14
0
 def setUp(self):
     self.stream = StringIO()
     self.handler = logging.StreamHandler(self.stream)
     logging_init(level=logging.DEBUG, handler=self.handler)
     self.logger = logging.getLogger()