• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python __main__.main函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nikola.__main__.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了main函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_future_post

    def test_future_post(self):
        """ Ensure that the future post is not present in the index and sitemap."""
        index_path = os.path.join(self.target_dir, "output", "index.html")
        sitemap_path = os.path.join(self.target_dir, "output", "sitemap.xml")
        foo_path = os.path.join(self.target_dir, "output", "posts", "foo", "index.html")
        bar_path = os.path.join(self.target_dir, "output", "posts", "bar", "index.html")
        self.assertTrue(os.path.isfile(index_path))
        self.assertTrue(os.path.isfile(foo_path))
        self.assertTrue(os.path.isfile(bar_path))
        with io.open(index_path, "r", encoding="utf8") as inf:
            index_data = inf.read()
        with io.open(sitemap_path, "r", encoding="utf8") as inf:
            sitemap_data = inf.read()
        self.assertTrue('foo/' in index_data)
        self.assertFalse('bar/' in index_data)
        self.assertTrue('foo/' in sitemap_data)
        self.assertFalse('bar/' in sitemap_data)

        # Run deploy command to see if future post is deleted
        with cd(self.target_dir):
            __main__.main(["deploy"])

        self.assertTrue(os.path.isfile(index_path))
        self.assertTrue(os.path.isfile(foo_path))
        self.assertFalse(os.path.isfile(bar_path))
开发者ID:ishaq,项目名称:nikola,代码行数:25,代码来源:test_integration.py


示例2: test_check_links_fail

 def test_check_links_fail(self):
     with cd(self.target_dir):
         os.unlink(os.path.join("output", "archive.html"))
         try:
             __main__.main(['check', '-l'])
         except SystemExit as e:
             self.assertNotEqual(e.code, 0)
开发者ID:carriercomm,项目名称:nikola,代码行数:7,代码来源:test_integration.py


示例3: test_check_files_fail

 def test_check_files_fail(self):
     with cd(self.target_dir):
         with codecs.open(os.path.join("output", "foobar"), "wb+", "utf8") as outf:
             outf.write("foo")
         try:
             __main__.main(['check', '-f'])
         except SystemExit as e:
             self.assertNotEqual(e.code, 0)
开发者ID:carriercomm,项目名称:nikola,代码行数:8,代码来源:test_integration.py


示例4: build

 def build(self):
     """Build the site."""
     try:
         self.oldlocale = locale.getlocale()
         locale.setlocale(locale.LC_ALL, ("en_US", "utf8"))
     except:
         pytest.skip('no en_US locale!')
     else:
         with cd(self.target_dir):
             __main__.main(["build", "--invariant"])
     finally:
         try:
             locale.setlocale(locale.LC_ALL, self.oldlocale)
         except:
             pass
开发者ID:carriercomm,项目名称:nikola,代码行数:15,代码来源:test_integration.py


示例5: _execute

    def _execute(self, command, args):

        self.logger = get_logger(
            CommandGitHubDeploy.name, self.site.loghandlers
        )

        # Check if ghp-import is installed
        check_ghp_import_installed()

        # Build before deploying
        build = main(['build'])
        if build != 0:
            self.logger.error('Build failed, not deploying to GitHub')
            sys.exit(build)

        # Clean non-target files
        l = self._doitargs['cmds'].get_plugin('list')(config=self.config, **self._doitargs)
        only_on_output, _ = real_scan_files(l, self.site)
        for f in only_on_output:
            os.unlink(f)

        # Commit and push
        self._commit_and_push()

        return
开发者ID:Drooids,项目名称:nikola,代码行数:25,代码来源:github_deploy.py


示例6: _execute

    def _execute(self, options, args):
        """Run the deployment."""
        self.logger = get_logger(CommandGitHubDeploy.name, STDERR_HANDLER)

        # Check if ghp-import is installed
        check_ghp_import_installed()

        # Build before deploying
        build = main(['build'])
        if build != 0:
            self.logger.error('Build failed, not deploying to GitHub')
            return build

        # Clean non-target files
        only_on_output, _ = real_scan_files(self.site)
        for f in only_on_output:
            os.unlink(f)

        # Remove drafts and future posts if requested (Issue #2406)
        undeployed_posts = clean_before_deployment(self.site)
        if undeployed_posts:
            self.logger.notice("Deleted {0} posts due to DEPLOY_* settings".format(len(undeployed_posts)))

        # Commit and push
        self._commit_and_push(options['commit_message'])

        return
开发者ID:andredias,项目名称:nikola,代码行数:27,代码来源:github_deploy.py


示例7: setUpClass

 def setUpClass(self):
     self.metadata_option = "ADDITIONAL_METADATA"
     script_root = os.path.dirname(__file__)
     test_dir = os.path.join(script_root, "data", "test_config")
     nikola.main(["--conf=" + os.path.join(test_dir, "conf.py")])
     self.simple_config = nikola.config
     nikola.main(["--conf=" + os.path.join(test_dir, "prod.py")])
     self.complex_config = nikola.config
     nikola.main(["--conf=" + os.path.join(test_dir, "config.with+illegal(module)name.characters.py")])
     self.complex_filename_config = nikola.config
     self.check_base_equality(self.complex_filename_config)
开发者ID:ishaq,项目名称:nikola,代码行数:11,代码来源:test_config.py


示例8: _execute

    def _execute(self, command, args):

        self.logger = get_logger(
            CommandGitHubDeploy.name, self.site.loghandlers
        )
        self._source_branch = self.site.config.get(
            'GITHUB_SOURCE_BRANCH', 'master'
        )
        self._deploy_branch = self.site.config.get(
            'GITHUB_DEPLOY_BRANCH', 'gh-pages'
        )
        self._remote_name = self.site.config.get(
            'GITHUB_REMOTE_NAME', 'origin'
        )
        self._pull_before_commit = self.site.config.get(
            'GITHUB_PULL_BEFORE_COMMIT', False
        )

        self._ensure_git_repo()

        self._exit_if_output_committed()

        if not self._prompt_continue():
            return

        build = main(['build'])
        if build != 0:
            self.logger.error('Build failed, not deploying to GitHub')
            sys.exit(build)

        only_on_output, _ = real_scan_files(self.site)
        for f in only_on_output:
            os.unlink(f)

        self._checkout_deploy_branch()

        self._copy_output()

        self._commit_and_push()

        return
开发者ID:AN6U5,项目名称:nikola,代码行数:41,代码来源:github_deploy.py


示例9: _execute

    def _execute(self, command, args):
        """Run the deployment."""
        self.logger = get_logger(CommandGitHubDeploy.name, STDERR_HANDLER)

        # Check if ghp-import is installed
        check_ghp_import_installed()

        # Build before deploying
        build = main(['build'])
        if build != 0:
            self.logger.error('Build failed, not deploying to GitHub')
            return build

        # Clean non-target files
        only_on_output, _ = real_scan_files(self.site)
        for f in only_on_output:
            os.unlink(f)

        # Commit and push
        self._commit_and_push()

        return
开发者ID:GetsDrawn,项目名称:nikola,代码行数:22,代码来源:github_deploy.py


示例10: _execute

    def _execute(self, command, args):

        self.logger = get_logger(CommandGitHubDeploy.name, self.site.loghandlers)

        # Check if ghp-import is installed
        check_ghp_import_installed()

        # Build before deploying
        build = main(["build"])
        if build != 0:
            self.logger.error("Build failed, not deploying to GitHub")
            return build

        # Clean non-target files
        only_on_output, _ = real_scan_files(self.site)
        for f in only_on_output:
            os.unlink(f)

        # Commit and push
        self._commit_and_push()

        return
开发者ID:habilain,项目名称:nikola,代码行数:22,代码来源:github_deploy.py


示例11: test_check_files

 def test_check_files(self):
     with cd(self.target_dir):
         try:
             __main__.main(['check', '-f'])
         except SystemExit as e:
             self.assertEqual(e.code, 0)
开发者ID:carriercomm,项目名称:nikola,代码行数:6,代码来源:test_integration.py


示例12: _run_command

 def _run_command(self, args=[]):
     from nikola.__main__ import main
     with self._captured_output() as out:
         main(['plugin', '-u', PLUGIN_URL] + args)
         out.seek(0)
         return out.read()
开发者ID:punchagan,项目名称:talks,代码行数:6,代码来源:test_command_plugin.py


示例13: _run_command

 def _run_command(self, args=[]):
     from nikola.__main__ import main
     return main(args)
开发者ID:getnikola,项目名称:plugins,代码行数:3,代码来源:test_command_tags.py


示例14: test_subdir_run

    def test_subdir_run(self):
        """Check whether build works from posts/"""

        with cd(os.path.join(self.target_dir, 'posts')):
            result = __main__.main(['build'])
            self.assertEquals(result, 0)
开发者ID:carriercomm,项目名称:nikola,代码行数:6,代码来源:test_integration.py


示例15: test_check_files

 def test_check_files(self):
     with cd(self.target_dir):
         self.assertIsNone(__main__.main(['check', '-f']))
开发者ID:habi,项目名称:nikola,代码行数:3,代码来源:test_integration.py


示例16: setUpClass

 def setUpClass():
     from nikola.__main__ import main
     main(['install_plugin', 'microdata'])
     LOGGER.notice('--- TESTS FOR ItemScope')
     LOGGER.level = logbook.WARNING
开发者ID:michaeljoseph,项目名称:nikola-plugins,代码行数:5,代码来源:test_microdata.py



注:本文中的nikola.__main__.main函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python post.get_meta函数代码示例发布时间:2022-05-27
下一篇:
Python image_reader.ImageReader类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap