当前位置: 首页>>代码示例>>Python>>正文


Python __main__.main函数代码示例

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


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


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