當前位置: 首頁>>代碼示例>>Python>>正文


Python environ.Env方法代碼示例

本文整理匯總了Python中environ.Env方法的典型用法代碼示例。如果您正苦於以下問題:Python environ.Env方法的具體用法?Python environ.Env怎麽用?Python environ.Env使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在environ的用法示例。


在下文中一共展示了environ.Env方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_watchedforks

# 需要導入模塊: import environ [as 別名]
# 或者: from environ import Env [as 別名]
def create_watchedforks(apps, schema_editor):

        env = environ.Env()

        WatchedPullRequest = apps.get_model('pr_watch', 'WatchedPullRequest')
        WatchedFork = apps.get_model('pr_watch', 'WatchedFork')

        if WatchedPullRequest.objects.count() == 0:
            # This Ocim instance isn't used yet to watch PRs, so we should keep that feature disabled, therefore
            # we don't create any fork to watch
            return

        # To make all PR keep working, we try to use the old "watched fork name" and "watched organization" defined in
        # the .env file if they are still there (this will be the case when migrating instances which had PRs watcher).
        # After WATCH_FORK and WATCH_ORGANIZATION are removed from .env, we fall back to other sensible defaults
        fork_name = env("WATCH_FORK", default=getattr(settings, 'DEFAULT_FORK', None) or 'edx/edx-platform')
        organization = env("WATCH_ORGANIZATION", default='edx')
        default_fork = WatchedFork.objects.create(
            enabled=True,
            fork=fork_name,
            organization=organization,
        )
        for pr in WatchedPullRequest.objects.all():
            pr.watched_fork = default_fork
            pr.save() 
開發者ID:open-craft,項目名稱:opencraft,代碼行數:27,代碼來源:0004_auto_20171108_1805.py


注:本文中的environ.Env方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。