本文整理汇总了Python中reviewboard.admin.checks.get_can_enable_syntax_highlighting函数的典型用法代码示例。如果您正苦于以下问题:Python get_can_enable_syntax_highlighting函数的具体用法?Python get_can_enable_syntax_highlighting怎么用?Python get_can_enable_syntax_highlighting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_can_enable_syntax_highlighting函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_enable_highlighting
def get_enable_highlighting(user):
if user.is_authenticated():
profile, profile_is_new = Profile.objects.get_or_create(user=user)
user_syntax_highlighting = profile.syntax_highlighting
else:
user_syntax_highlighting = True
siteconfig = SiteConfiguration.objects.get_current()
return (siteconfig.get('diffviewer_syntax_highlighting') and
user_syntax_highlighting and
get_can_enable_syntax_highlighting())
开发者ID:ballarin,项目名称:reviewboard,代码行数:11,代码来源:diffutils.py
示例2: get_enable_highlighting
def get_enable_highlighting(user):
user_syntax_highlighting = True
if user.is_authenticated():
try:
profile = user.get_profile()
user_syntax_highlighting = profile.syntax_highlighting
except Profile.DoesNotExist:
pass
siteconfig = SiteConfiguration.objects.get_current()
return (siteconfig.get('diffviewer_syntax_highlighting') and
user_syntax_highlighting and
get_can_enable_syntax_highlighting())
开发者ID:Catherine1,项目名称:reviewboard,代码行数:14,代码来源:diffutils.py
示例3: load
def load(self):
# TODO: Move this check into a dependencies module so we can catch it
# when the user starts up Review Board.
can_syntax_highlight, reason = get_can_enable_syntax_highlighting()
if not can_syntax_highlight:
self.disabled_fields['diffviewer_syntax_highlighting'] = True
self.disabled_reasons['diffviewer_syntax_highlighting'] = _(reason)
self.disabled_fields['diffviewer_syntax_highlighting_threshold'] = True
self.disabled_reasons['diffviewer_syntax_highlighting_threshold'] = _(reason)
super(DiffSettingsForm, self).load()
self.fields['include_space_patterns'].initial = \
', '.join(self.siteconfig.get('diffviewer_include_space_patterns'))
开发者ID:aaronmartin0303,项目名称:reviewboard,代码行数:14,代码来源:forms.py
示例4: check_dependencies
def check_dependencies(settings):
# Some of our checks require access to django.conf.settings, so
# tell Django about our settings.
#
from django.template.defaultfilters import striptags
from djblets.util.filesystem import is_exe_in_path
from reviewboard.admin import checks
dependency_error = settings.dependency_error
# Python 2.4
if sys.version_info[0] < 2 or \
(sys.version_info[0] == 2 and sys.version_info[1] < 4):
dependency_error('Python 2.4 or newer is required.')
# django-evolution
try:
imp.find_module('django_evolution')
except ImportError:
dependency_error("django_evolution is required.\n"
"http://code.google.com/p/django-evolution/")
# PIL
try:
imp.find_module('PIL')
except ImportError:
try:
imp.find_module('Image')
except ImportError:
dependency_error('The Python Imaging Library (Pillow or PIL) '
'is required.')
# ReCaptcha
try:
# For some reason, imp.find_module('recaptcha') doesn't always work.
import recaptcha
except ImportError:
dependency_error('The recaptcha python module is required.')
# The following checks are non-fatal warnings, since these dependencies are
# merely recommended, not required.
def dependency_warning(string):
sys.stderr.write('Warning: %s\n' % string)
global warnings_found
warnings_found += 1
try:
imp.find_module('subvertpy')
except ImportError:
try:
imp.find_module('pysvn')
except ImportError:
dependency_warning('Neither subvertpy nor pysvn found. '
'SVN integration will not work.')
try:
imp.find_module('P4')
subprocess.call(['p4', '-h'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
except ImportError:
dependency_warning('p4python (>=07.3) not found. Perforce integration '
'will not work.')
except OSError:
dependency_error('p4 command not found. Perforce integration will not '
'work.')
try:
imp.find_module('mercurial')
except ImportError:
dependency_warning('hg not found. Mercurial integration will not '
'work.')
try:
imp.find_module('bzrlib')
except ImportError:
dependency_warning('bzrlib not found. Bazaar integration will not '
'work.')
success, reason = checks.get_can_enable_syntax_highlighting()
if not success:
dependency_warning(striptags(reason))
if not is_exe_in_path('cvs'):
dependency_warning('cvs binary not found. CVS integration '
'will not work.')
if not is_exe_in_path('git'):
dependency_warning('git binary not found. Git integration '
'will not work.')
if not is_exe_in_path('mtn'):
dependency_warning('mtn binary not found. Monotone integration '
'will not work.')
# Django will print warnings/errors for database backend modules and flup
# if the configuration requires it.
if warnings_found:
#.........这里部分代码省略.........
开发者ID:salam0smy,项目名称:reviewboard,代码行数:101,代码来源:manage.py
示例5: load_site_config
def load_site_config():
"""
Loads any stored site configuration settings and populates the Django
settings object with any that need to be there.
"""
def apply_setting(settings_key, db_key, default=None):
db_value = siteconfig.settings.get(db_key)
if db_value:
setattr(settings, settings_key, db_value)
elif default:
setattr(settings, settings_key, default)
try:
siteconfig = SiteConfiguration.objects.get_current()
except SiteConfiguration.DoesNotExist:
raise ImproperlyConfigured, \
"The site configuration entry does not exist in the database. " \
"Re-run `./manage.py` syncdb to fix this."
except:
# We got something else. Likely, this doesn't exist yet and we're
# doing a syncdb or something, so silently ignore.
return
# Populate defaults if they weren't already set.
if not siteconfig.get_defaults():
siteconfig.add_defaults(defaults)
# The default value for DEFAULT_EMAIL_FROM ([email protected])
# is less than good, so use a better one if it's set to that or if
# we haven't yet set this value in siteconfig.
mail_default_from = \
siteconfig.settings.get('mail_default_from',
global_settings.DEFAULT_FROM_EMAIL)
if (not mail_default_from or
mail_default_from == global_settings.DEFAULT_FROM_EMAIL):
domain = siteconfig.site.domain.split(':')[0]
siteconfig.set('mail_default_from', '[email protected]' + domain)
# Populate the settings object with anything relevant from the siteconfig.
apply_django_settings(siteconfig, settings_map)
# Now for some more complicated stuff...
# Do some dependency checks and disable things if we don't support them.
if not get_can_enable_search()[0]:
siteconfig.set('search_enable', False)
if not get_can_enable_syntax_highlighting()[0]:
siteconfig.set('diffviewer_syntax_highlighting', False)
# Site administrator settings
apply_setting("ADMINS", None, (
(siteconfig.get("site_admin_name", ""),
siteconfig.get("site_admin_email", "")),
))
apply_setting("MANAGERS", None, settings.ADMINS)
# Explicitly base this off the MEDIA_URL
apply_setting("ADMIN_MEDIA_PREFIX", None, settings.MEDIA_URL + "admin/")
# Set the auth backends
auth_backend_map = dict(get_registered_auth_backends())
auth_backend_id = siteconfig.settings.get("auth_backend", "builtin")
builtin_backend_obj = auth_backend_map['builtin']
builtin_backend = "%s.%s" % (builtin_backend_obj.__module__,
builtin_backend_obj.__name__)
if auth_backend_id == "custom":
custom_backends = siteconfig.settings.get("auth_custom_backends")
if isinstance(custom_backends, basestring):
custom_backends = (custom_backends,)
elif isinstance(custom_backends, list):
custom_backends = tuple(custom_backends)
settings.AUTHENTICATION_BACKENDS = custom_backends
if builtin_backend not in custom_backends:
settings.AUTHENTICATION_BACKENDS += (builtin_backend,)
elif auth_backend_id != "builtin" and auth_backend_id in auth_backend_map:
backend = auth_backend_map[auth_backend_id]
settings.AUTHENTICATION_BACKENDS = \
("%s.%s" % (backend.__module__, backend.__name__),
builtin_backend)
else:
settings.AUTHENTICATION_BACKENDS = (builtin_backend,)
# Set the storage backend
storage_backend = siteconfig.settings.get('storage_backend', 'builtin')
#.........这里部分代码省略.........
开发者ID:Kamlani,项目名称:reviewboard,代码行数:101,代码来源:siteconfig.py
示例6: load_site_config
def load_site_config():
"""
Loads any stored site configuration settings and populates the Django
settings object with any that need to be there.
"""
def apply_setting(settings_key, db_key, default=None):
db_value = siteconfig.settings.get(db_key)
if db_value:
setattr(settings, settings_key, db_value)
elif default:
setattr(settings, settings_key, default)
def update_haystack_settings():
"""Updates the haystack settings with settings in site config."""
apply_setting("HAYSTACK_CONNECTIONS", None, {
'default': {
'ENGINE': settings.HAYSTACK_CONNECTIONS['default']['ENGINE'],
'PATH': (siteconfig.get('search_index_file') or
defaults['search_index_file']),
},
})
# Re-initialize Haystack's connection information to use the updated
# settings.
connections.connections_info = settings.HAYSTACK_CONNECTIONS
connections._connections = {}
try:
siteconfig = SiteConfiguration.objects.get_current()
except SiteConfiguration.DoesNotExist:
raise ImproperlyConfigured(
"The site configuration entry does not exist in the database. "
"Re-run `./manage.py` syncdb to fix this.")
except:
# We got something else. Likely, this doesn't exist yet and we're
# doing a syncdb or something, so silently ignore.
return
# Populate defaults if they weren't already set.
if not siteconfig.get_defaults():
siteconfig.add_defaults(defaults)
# The default value for DEFAULT_EMAIL_FROM ([email protected])
# is less than good, so use a better one if it's set to that or if
# we haven't yet set this value in siteconfig.
mail_default_from = \
siteconfig.settings.get('mail_default_from',
global_settings.DEFAULT_FROM_EMAIL)
if (not mail_default_from or
mail_default_from == global_settings.DEFAULT_FROM_EMAIL):
domain = siteconfig.site.domain.split(':')[0]
siteconfig.set('mail_default_from', '[email protected]' + domain)
# STATIC_* and MEDIA_* must be different paths, and differ in meaning.
# If site_static_* is empty or equal to media_static_*, we're probably
# migrating from an earlier Review Board install.
site_static_root = siteconfig.settings.get('site_static_root', '')
site_media_root = siteconfig.settings.get('site_media_root')
if site_static_root == '' or site_static_root == site_media_root:
siteconfig.set('site_static_root', settings.STATIC_ROOT)
site_static_url = siteconfig.settings.get('site_static_url', '')
site_media_url = siteconfig.settings.get('site_media_url')
if site_static_url == '' or site_static_url == site_media_url:
siteconfig.set('site_static_url', settings.STATIC_URL)
# Populate the settings object with anything relevant from the siteconfig.
apply_django_settings(siteconfig, settings_map)
# Now for some more complicated stuff...
update_haystack_settings()
# Do some dependency checks and disable things if we don't support them.
if not get_can_enable_syntax_highlighting()[0]:
siteconfig.set('diffviewer_syntax_highlighting', False)
# Site administrator settings
apply_setting("ADMINS", None, (
(siteconfig.get("site_admin_name", ""),
siteconfig.get("site_admin_email", "")),
))
apply_setting("MANAGERS", None, settings.ADMINS)
# Explicitly base this off the STATIC_URL
apply_setting("ADMIN_MEDIA_PREFIX", None, settings.STATIC_URL + "admin/")
# Set the auth backends
auth_backend_id = siteconfig.settings.get("auth_backend", "builtin")
builtin_backend_obj = get_registered_auth_backend('builtin')
builtin_backend = "%s.%s" % (builtin_backend_obj.__module__,
builtin_backend_obj.__name__)
if auth_backend_id == "custom":
custom_backends = siteconfig.settings.get("auth_custom_backends")
#.........这里部分代码省略.........
开发者ID:aaronmartin0303,项目名称:reviewboard,代码行数:101,代码来源:siteconfig.py
示例7: load_site_config
def load_site_config():
"""
Loads any stored site configuration settings and populates the Django
settings object with any that need to be there.
"""
def apply_setting(settings_key, db_key, default=None):
db_value = siteconfig.settings.get(db_key)
if db_value:
setattr(settings, settings_key, db_value)
elif default:
setattr(settings, settings_key, default)
try:
siteconfig = SiteConfiguration.objects.get_current()
except SiteConfiguration.DoesNotExist:
raise ImproperlyConfigured, \
"The site configuration entry does not exist in the database. " \
"Re-run `./manage.py` syncdb to fix this."
except:
# We got something else. Likely, this doesn't exist yet and we're
# doing a syncdb or something, so silently ignore.
return
# Populate defaults if they weren't already set.
if not siteconfig.get_defaults():
siteconfig.add_defaults(defaults)
# Populate the settings object with anything relevant from the siteconfig.
apply_django_settings(siteconfig, settings_map)
# Now for some more complicated stuff...
# Do some dependency checks and disable things if we don't support them.
if not get_can_enable_search()[0]:
siteconfig.set('search_enable', False)
if not get_can_enable_syntax_highlighting()[0]:
siteconfig.set('diffviewer_syntax_highlighting', False)
# Site administrator settings
apply_setting("ADMINS", None, (
(siteconfig.get("site_admin_name", ""),
siteconfig.get("site_admin_email", "")),
))
apply_setting("MANAGERS", None, settings.ADMINS)
# Explicitly base this off the MEDIA_URL
apply_setting("ADMIN_MEDIA_PREFIX", None, settings.MEDIA_URL + "admin/")
# Set the auth backends
auth_backend = siteconfig.settings.get("auth_backend", "builtin")
builtin_backend = auth_backend_map['builtin']
if auth_backend == "custom":
custom_backends = siteconfig.settings.get("auth_custom_backends")
if isinstance(custom_backends, basestring):
custom_backends = (custom_backends,)
elif isinstance(custom_backends, list):
custom_backends = tuple(custom_backends)
settings.AUTHENTICATION_BACKENDS = custom_backends
if builtin_backend not in custom_backends:
settings.AUTHENTICATION_BACKENDS += (builtin_backend,)
elif auth_backend != "builtin" and auth_backend in auth_backend_map:
settings.AUTHENTICATION_BACKENDS = \
(auth_backend_map[auth_backend], builtin_backend)
else:
settings.AUTHENTICATION_BACKENDS = (builtin_backend,)
开发者ID:Cka3o4Huk,项目名称:reviewboard,代码行数:78,代码来源:siteconfig.py
示例8: load_site_config
def load_site_config():
"""
Loads any stored site configuration settings and populates the Django
settings object with any that need to be there.
"""
def apply_setting(settings_key, db_key, default=None):
db_value = siteconfig.settings.get(db_key)
if db_value:
setattr(settings, settings_key, db_value)
elif default:
setattr(settings, settings_key, default)
def update_haystack_settings():
"""Updates the haystack settings with settings in site config."""
apply_setting("HAYSTACK_CONNECTIONS", None, {
'default': {
'ENGINE': settings.HAYSTACK_CONNECTIONS['default']['ENGINE'],
'PATH': (siteconfig.get('search_index_file') or
defaults['search_index_file']),
},
})
# Re-initialize Haystack's connection information to use the updated
# settings.
connections.connections_info = settings.HAYSTACK_CONNECTIONS
connections._connections = {}
# If siteconfig needs to be saved back to the DB, set dirty=true
dirty = False
try:
siteconfig = SiteConfiguration.objects.get_current()
except SiteConfiguration.DoesNotExist:
raise ImproperlyConfigured(
"The site configuration entry does not exist in the database. "
"Re-run `./manage.py` syncdb to fix this.")
except Exception as e:
# We got something else. Likely, this doesn't exist yet and we're
# doing a syncdb or something, so silently ignore.
logging.error('Could not load siteconfig: %s' % e)
return
# Populate defaults if they weren't already set.
if not siteconfig.get_defaults():
siteconfig.add_defaults(defaults)
# The default value for DEFAULT_EMAIL_FROM ([email protected])
# is less than good, so use a better one if it's set to that or if
# we haven't yet set this value in siteconfig.
mail_default_from = \
siteconfig.settings.get('mail_default_from',
global_settings.DEFAULT_FROM_EMAIL)
if (not mail_default_from or
mail_default_from == global_settings.DEFAULT_FROM_EMAIL):
domain = siteconfig.site.domain.split(':')[0]
siteconfig.set('mail_default_from', '[email protected]' + domain)
# STATIC_* and MEDIA_* must be different paths, and differ in meaning.
# If site_static_* is empty or equal to media_static_*, we're probably
# migrating from an earlier Review Board install.
site_static_root = siteconfig.settings.get('site_static_root', '')
site_media_root = siteconfig.settings.get('site_media_root')
if site_static_root == '' or site_static_root == site_media_root:
siteconfig.set('site_static_root', settings.STATIC_ROOT)
site_static_url = siteconfig.settings.get('site_static_url', '')
site_media_url = siteconfig.settings.get('site_media_url')
if site_static_url == '' or site_static_url == site_media_url:
siteconfig.set('site_static_url', settings.STATIC_URL)
# Populate the settings object with anything relevant from the siteconfig.
apply_django_settings(siteconfig, settings_map)
# Now for some more complicated stuff...
update_haystack_settings()
# Do some dependency checks and disable things if we don't support them.
if not get_can_enable_syntax_highlighting()[0]:
siteconfig.set('diffviewer_syntax_highlighting', False)
# Site administrator settings
apply_setting("ADMINS", None, (
(siteconfig.get("site_admin_name", ""),
siteconfig.get("site_admin_email", "")),
))
apply_setting("MANAGERS", None, settings.ADMINS)
# Explicitly base this off the STATIC_URL
apply_setting("ADMIN_MEDIA_PREFIX", None, settings.STATIC_URL + "admin/")
# Set the auth backends
auth_backend_id = siteconfig.settings.get("auth_backend", "builtin")
builtin_backend_obj = get_registered_auth_backend('builtin')
builtin_backend = "%s.%s" % (builtin_backend_obj.__module__,
builtin_backend_obj.__name__)
#.........这里部分代码省略.........
开发者ID:Greyhatno,项目名称:reviewboard,代码行数:101,代码来源:siteconfig.py
示例9: load_site_config
def load_site_config():
"""
Loads any stored site configuration settings and populates the Django
settings object with any that need to be there.
"""
def apply_setting(settings_key, db_key, default=None):
db_value = siteconfig.settings.get(db_key)
if db_value:
setattr(settings, settings_key, db_value)
elif default:
setattr(settings, settings_key, default)
try:
siteconfig = SiteConfiguration.objects.get_current()
except SiteConfiguration.DoesNotExist:
raise ImproperlyConfigured(
"The site configuration entry does not exist in the database. " "Re-run `./manage.py` syncdb to fix this."
)
except:
# We got something else. Likely, this doesn't exist yet and we're
# doing a syncdb or something, so silently ignore.
return
# Populate defaults if they weren't already set.
if not siteconfig.get_defaults():
siteconfig.add_defaults(defaults)
# The default value for DEFAULT_EMAIL_FROM ([email protected])
# is less than good, so use a better one if it's set to that or if
# we haven't yet set this value in siteconfig.
mail_default_from = siteconfig.settings.get("mail_default_from", global_settings.DEFAULT_FROM_EMAIL)
if not mail_default_from or mail_default_from == global_settings.DEFAULT_FROM_EMAIL:
domain = siteconfig.site.domain.split(":")[0]
siteconfig.set("mail_default_from", "[email protected]" + domain)
# STATIC_* and MEDIA_* must be different paths, and differ in meaning.
# If site_static_* is empty or equal to media_static_*, we're probably
# migrating from an earlier Review Board install.
site_static_root = siteconfig.settings.get("site_static_root", "")
site_media_root = siteconfig.settings.get("site_media_root")
if site_static_root == "" or site_static_root == site_media_root:
siteconfig.set("site_static_root", settings.STATIC_ROOT)
site_static_url = siteconfig.settings.get("site_static_url", "")
site_media_url = siteconfig.settings.get("site_media_url")
if site_static_url == "" or site_static_url == site_media_url:
siteconfig.set("site_static_url", settings.STATIC_URL)
# Populate the settings object with anything relevant from the siteconfig.
apply_django_settings(siteconfig, settings_map)
# Now for some more complicated stuff...
# Do some dependency checks and disable things if we don't support them.
if not get_can_enable_search()[0]:
siteconfig.set("search_enable", False)
if not get_can_enable_syntax_highlighting()[0]:
siteconfig.set("diffviewer_syntax_highlighting", False)
# Site administrator settings
apply_setting("ADMINS", None, ((siteconfig.get("site_admin_name", ""), siteconfig.get("site_admin_email", "")),))
apply_setting("MANAGERS", None, settings.ADMINS)
# Explicitly base this off the STATIC_URL
apply_setting("ADMIN_MEDIA_PREFIX", None, settings.STATIC_URL + "admin/")
# Set the auth backends
auth_backend_map = dict(get_registered_auth_backends())
auth_backend_id = siteconfig.settings.get("auth_backend", "builtin")
builtin_backend_obj = auth_backend_map["builtin"]
builtin_backend = "%s.%s" % (builtin_backend_obj.__module__, builtin_backend_obj.__name__)
if auth_backend_id == "custom":
custom_backends = siteconfig.settings.get("auth_custom_backends")
if isinstance(custom_backends, six.string_types):
custom_backends = (custom_backends,)
elif isinstance(custom_backends, list):
custom_backends = tuple(custom_backends)
settings.AUTHENTICATION_BACKENDS = custom_backends
if builtin_backend not in custom_backends:
settings.AUTHENTICATION_BACKENDS += (builtin_backend,)
elif auth_backend_id != "builtin" and auth_backend_id in auth_backend_map:
backend = auth_backend_map[auth_backend_id]
settings.AUTHENTICATION_BACKENDS = ("%s.%s" % (backend.__module__, backend.__name__), builtin_backend)
else:
settings.AUTHENTICATION_BACKENDS = (builtin_backend,)
# Set the storage backend
storage_backend = siteconfig.settings.get("storage_backend", "builtin")
#.........这里部分代码省略.........
开发者ID:rajasaur,项目名称:reviewboard,代码行数:101,代码来源:siteconfig.py
注:本文中的reviewboard.admin.checks.get_can_enable_syntax_highlighting函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论