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


Python django.__file__方法代碼示例

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


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

示例1: handle

# 需要導入模塊: import django [as 別名]
# 或者: from django import __file__ [as 別名]
def handle(self, *args, **options):
        patches = []
        patches_dir = os.path.join(self.PROJECT_DIR, 'etc', 'patch_envs')

        if os.path.isdir(patches_dir):
            patches = os.listdir(patches_dir)

        import django
        envs_lib_dir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(django.__file__)), '..'))

        with lcd(envs_lib_dir):
            for patch in patches:
                self.display('Installing patch: %s' % patch, color='white')
                rc = self.local('patch -N -t -p0 -i ' + os.path.join(patches_dir, patch), raise_on_error=False)

                if rc == 0:
                    self.display('Patch %s was successfully installed\n\n' % patch, color='green')
                else:
                    self.display('Failed to install patch %s\n\n' % patch, color='yellow') 
開發者ID:erigones,項目名稱:esdc-ce,代碼行數:21,代碼來源:patch_envs.py

示例2: copy_plural_forms

# 需要導入模塊: import django [as 別名]
# 或者: from django import __file__ [as 別名]
def copy_plural_forms(self, msgs, locale):
        """
        Copies plural forms header contents from a Django catalog of locale to
        the msgs string, inserting it at the right place. msgs should be the
        contents of a newly created .po file.
        """
        django_dir = os.path.normpath(os.path.join(os.path.dirname(upath(django.__file__))))
        if self.domain == 'djangojs':
            domains = ('djangojs', 'django')
        else:
            domains = ('django',)
        for domain in domains:
            django_po = os.path.join(django_dir, 'conf', 'locale', locale, 'LC_MESSAGES', '%s.po' % domain)
            if os.path.exists(django_po):
                with io.open(django_po, 'r', encoding='utf-8') as fp:
                    m = plural_forms_re.search(fp.read())
                if m:
                    plural_form_line = force_str(m.group('value'))
                    if self.verbosity > 1:
                        self.stdout.write("copying plural forms: %s\n" % plural_form_line)
                    lines = []
                    found = False
                    for line in msgs.split('\n'):
                        if not found and (not line or plural_forms_re.search(line)):
                            line = '%s\n' % plural_form_line
                            found = True
                        lines.append(line)
                    msgs = '\n'.join(lines)
                    break
        return msgs 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:32,代碼來源:makemessages.py

示例3: get_subprocess_args

# 需要導入模塊: import django [as 別名]
# 或者: from django import __file__ [as 別名]
def get_subprocess_args(options):
    subprocess_args = [
        sys.executable, __file__, '--settings=%s' % options.settings
    ]
    if options.failfast:
        subprocess_args.append('--failfast')
    if options.verbosity:
        subprocess_args.append('--verbosity=%s' % options.verbosity)
    if not options.interactive:
        subprocess_args.append('--noinput')
    if options.tags:
        subprocess_args.append('--tag=%s' % options.tags)
    if options.exclude_tags:
        subprocess_args.append('--exclude_tag=%s' % options.exclude_tags)
    return subprocess_args 
開發者ID:ra-systems,項目名稱:django-ra-erp,代碼行數:17,代碼來源:runtests.py

示例4: copy_plural_forms

# 需要導入模塊: import django [as 別名]
# 或者: from django import __file__ [as 別名]
def copy_plural_forms(msgs, locale, domain, verbosity, stdout=sys.stdout):
    """
    Copies plural forms header contents from a Django catalog of locale to
    the msgs string, inserting it at the right place. msgs should be the
    contents of a newly created .po file.
    """
    django_dir = os.path.normpath(os.path.join(os.path.dirname(django.__file__)))
    if domain == 'djangojs':
        domains = ('djangojs', 'django')
    else:
        domains = ('django',)
    for domain in domains:
        django_po = os.path.join(django_dir, 'conf', 'locale', locale, 'LC_MESSAGES', '%s.po' % domain)
        if os.path.exists(django_po):
            with open(django_po, 'rU') as fp:
                m = plural_forms_re.search(fp.read())
            if m:
                if verbosity > 1:
                    stdout.write("copying plural forms: %s\n" % m.group('value'))
                lines = []
                seen = False
                for line in msgs.split('\n'):
                    if not line and not seen:
                        line = '%s\n' % m.group('value')
                        seen = True
                    lines.append(line)
                msgs = '\n'.join(lines)
                break
    return msgs 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:31,代碼來源:makemessages.py

示例5: copy_plural_forms

# 需要導入模塊: import django [as 別名]
# 或者: from django import __file__ [as 別名]
def copy_plural_forms(msgs, locale, domain, verbosity):
    """
    Copies plural forms header contents from a Django catalog of locale to
    the msgs string, inserting it at the right place. msgs should be the
    contents of a newly created .po file.
    """
    import django
    django_dir = os.path.normpath(os.path.join(os.path.dirname(django.__file__)))
    if domain == 'djangojs':
        domains = ('djangojs', 'django')
    else:
        domains = ('django',)
    for domain in domains:
        django_po = os.path.join(django_dir, 'conf', 'locale', locale, 'LC_MESSAGES', '%s.po' % domain)
        if os.path.exists(django_po):
            m = plural_forms_re.search(open(django_po, 'rU').read())
            if m:
                if verbosity > 1:
                    sys.stderr.write("copying plural forms: %s\n" % m.group('value'))
                lines = []
                seen = False
                for line in msgs.split('\n'):
                    if not line and not seen:
                        line = '%s\n' % m.group('value')
                        seen = True
                    lines.append(line)
                msgs = '\n'.join(lines)
                break
    return msgs 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:31,代碼來源:makemessages.py

示例6: get_subprocess_args

# 需要導入模塊: import django [as 別名]
# 或者: from django import __file__ [as 別名]
def get_subprocess_args(options):
    subprocess_args = [
        sys.executable, upath(__file__), '--settings=%s' % options.settings
    ]
    if options.failfast:
        subprocess_args.append('--failfast')
    if options.verbosity:
        subprocess_args.append('--verbosity=%s' % options.verbosity)
    if not options.interactive:
        subprocess_args.append('--noinput')
    if options.tags:
        subprocess_args.append('--tag=%s' % options.tags)
    if options.exclude_tags:
        subprocess_args.append('--exclude_tag=%s' % options.exclude_tags)
    return subprocess_args 
開發者ID:denisenkom,項目名稱:django-sqlserver,代碼行數:17,代碼來源:runtests.py

示例7: _ext_backend_paths

# 需要導入模塊: import django [as 別名]
# 或者: from django import __file__ [as 別名]
def _ext_backend_paths(self):
        """
        Returns the paths for any external backend packages.
        """
        paths = []
        for backend in settings.DATABASES.values():
            package = backend['ENGINE'].split('.')[0]
            if package != 'django':
                backend_pkg = __import__(package)
                backend_dir = os.path.dirname(backend_pkg.__file__)
                paths.append(os.path.dirname(backend_dir))
        return paths 
開發者ID:nesdis,項目名稱:djongo,代碼行數:14,代碼來源:tests.py

示例8: run_test

# 需要導入模塊: import django [as 別名]
# 或者: from django import __file__ [as 別名]
def run_test(self, script, args, settings_file=None, apps=None):
        base_dir = os.path.dirname(self.test_dir)
        # The base dir for Django's tests is one level up.
        tests_dir = os.path.dirname(os.path.dirname(__file__))
        # The base dir for Django is one level above the test dir. We don't use
        # `import django` to figure that out, so we don't pick up a Django
        # from site-packages or similar.
        django_dir = os.path.dirname(tests_dir)
        ext_backend_base_dirs = self._ext_backend_paths()

        # Define a temporary environment for the subprocess
        test_environ = os.environ.copy()
        old_cwd = os.getcwd()

        # Set the test environment
        if settings_file:
            test_environ['DJANGO_SETTINGS_MODULE'] = settings_file
        elif 'DJANGO_SETTINGS_MODULE' in test_environ:
            del test_environ['DJANGO_SETTINGS_MODULE']
        python_path = [base_dir, django_dir, tests_dir]
        python_path.extend(ext_backend_base_dirs)
        test_environ['PYTHONPATH'] = os.pathsep.join(python_path)
        test_environ['PYTHONWARNINGS'] = ''

        # Move to the test directory and run
        os.chdir(self.test_dir)
        out, err = subprocess.Popen(
            [sys.executable, script] + args,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
            env=test_environ, universal_newlines=True,
        ).communicate()
        # Move back to the old working directory
        os.chdir(old_cwd)

        return out, err 
開發者ID:nesdis,項目名稱:djongo,代碼行數:37,代碼來源:tests.py

示例9: run_django_admin

# 需要導入模塊: import django [as 別名]
# 或者: from django import __file__ [as 別名]
def run_django_admin(self, args, settings_file=None):
        script_dir = os.path.abspath(os.path.join(os.path.dirname(django.__file__), 'bin'))
        return self.run_test(os.path.join(script_dir, 'django-admin.py'), args, settings_file) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:5,代碼來源:tests.py


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