repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
openstack/horizon | openstack_auth/utils.py | fix_auth_url_version_prefix | def fix_auth_url_version_prefix(auth_url):
"""Fix up the auth url if an invalid or no version prefix was given.
People still give a v2 auth_url even when they specify that they want v3
authentication. Fix the URL to say v3 in this case and add version if it is
missing entirely. This should be smarter a... | python | def fix_auth_url_version_prefix(auth_url):
"""Fix up the auth url if an invalid or no version prefix was given.
People still give a v2 auth_url even when they specify that they want v3
authentication. Fix the URL to say v3 in this case and add version if it is
missing entirely. This should be smarter a... | [
"def",
"fix_auth_url_version_prefix",
"(",
"auth_url",
")",
":",
"auth_url",
"=",
"_augment_url_with_version",
"(",
"auth_url",
")",
"url_fixed",
"=",
"False",
"if",
"get_keystone_version",
"(",
")",
">=",
"3",
"and",
"has_in_url_path",
"(",
"auth_url",
",",
"[",
... | Fix up the auth url if an invalid or no version prefix was given.
People still give a v2 auth_url even when they specify that they want v3
authentication. Fix the URL to say v3 in this case and add version if it is
missing entirely. This should be smarter and use discovery. | [
"Fix",
"up",
"the",
"auth",
"url",
"if",
"an",
"invalid",
"or",
"no",
"version",
"prefix",
"was",
"given",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L306-L320 | train |
openstack/horizon | openstack_auth/utils.py | clean_up_auth_url | def clean_up_auth_url(auth_url):
"""Clean up the auth url to extract the exact Keystone URL"""
# NOTE(mnaser): This drops the query and fragment because we're only
# trying to extract the Keystone URL.
scheme, netloc, path, query, fragment = urlparse.urlsplit(auth_url)
return urlparse... | python | def clean_up_auth_url(auth_url):
"""Clean up the auth url to extract the exact Keystone URL"""
# NOTE(mnaser): This drops the query and fragment because we're only
# trying to extract the Keystone URL.
scheme, netloc, path, query, fragment = urlparse.urlsplit(auth_url)
return urlparse... | [
"def",
"clean_up_auth_url",
"(",
"auth_url",
")",
":",
"# NOTE(mnaser): This drops the query and fragment because we're only",
"# trying to extract the Keystone URL.",
"scheme",
",",
"netloc",
",",
"path",
",",
"query",
",",
"fragment",
"=",
"urlparse",
".",
"ur... | Clean up the auth url to extract the exact Keystone URL | [
"Clean",
"up",
"the",
"auth",
"url",
"to",
"extract",
"the",
"exact",
"Keystone",
"URL"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L323-L330 | train |
openstack/horizon | openstack_auth/utils.py | default_services_region | def default_services_region(service_catalog, request=None,
ks_endpoint=None):
"""Return the default service region.
Order of precedence:
1. 'services_region' cookie value
2. Matching endpoint in DEFAULT_SERVICE_REGIONS
3. '*' key in DEFAULT_SERVICE_REGIONS
4. First v... | python | def default_services_region(service_catalog, request=None,
ks_endpoint=None):
"""Return the default service region.
Order of precedence:
1. 'services_region' cookie value
2. Matching endpoint in DEFAULT_SERVICE_REGIONS
3. '*' key in DEFAULT_SERVICE_REGIONS
4. First v... | [
"def",
"default_services_region",
"(",
"service_catalog",
",",
"request",
"=",
"None",
",",
"ks_endpoint",
"=",
"None",
")",
":",
"if",
"service_catalog",
":",
"available_regions",
"=",
"[",
"get_endpoint_region",
"(",
"endpoint",
")",
"for",
"service",
"in",
"s... | Return the default service region.
Order of precedence:
1. 'services_region' cookie value
2. Matching endpoint in DEFAULT_SERVICE_REGIONS
3. '*' key in DEFAULT_SERVICE_REGIONS
4. First valid region from catalog
In each case the value must also be present in available_regions or
we move to ... | [
"Return",
"the",
"default",
"service",
"region",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L370-L416 | train |
openstack/horizon | openstack_auth/utils.py | set_response_cookie | def set_response_cookie(response, cookie_name, cookie_value):
"""Common function for setting the cookie in the response.
Provides a common policy of setting cookies for last used project
and region, can be reused in other locations.
This method will set the cookie to expire in 365 days.
"""
no... | python | def set_response_cookie(response, cookie_name, cookie_value):
"""Common function for setting the cookie in the response.
Provides a common policy of setting cookies for last used project
and region, can be reused in other locations.
This method will set the cookie to expire in 365 days.
"""
no... | [
"def",
"set_response_cookie",
"(",
"response",
",",
"cookie_name",
",",
"cookie_value",
")",
":",
"now",
"=",
"timezone",
".",
"now",
"(",
")",
"expire_date",
"=",
"now",
"+",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"365",
")",
"response",
".",
"... | Common function for setting the cookie in the response.
Provides a common policy of setting cookies for last used project
and region, can be reused in other locations.
This method will set the cookie to expire in 365 days. | [
"Common",
"function",
"for",
"setting",
"the",
"cookie",
"in",
"the",
"response",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L419-L429 | train |
openstack/horizon | openstack_auth/utils.py | get_client_ip | def get_client_ip(request):
"""Return client ip address using SECURE_PROXY_ADDR_HEADER variable.
If not present or not defined on settings then REMOTE_ADDR is used.
:param request: Django http request object.
:type request: django.http.HttpRequest
:returns: Possible client ip address
:rtype: ... | python | def get_client_ip(request):
"""Return client ip address using SECURE_PROXY_ADDR_HEADER variable.
If not present or not defined on settings then REMOTE_ADDR is used.
:param request: Django http request object.
:type request: django.http.HttpRequest
:returns: Possible client ip address
:rtype: ... | [
"def",
"get_client_ip",
"(",
"request",
")",
":",
"_SECURE_PROXY_ADDR_HEADER",
"=",
"getattr",
"(",
"settings",
",",
"'SECURE_PROXY_ADDR_HEADER'",
",",
"False",
")",
"if",
"_SECURE_PROXY_ADDR_HEADER",
":",
"return",
"request",
".",
"META",
".",
"get",
"(",
"_SECUR... | Return client ip address using SECURE_PROXY_ADDR_HEADER variable.
If not present or not defined on settings then REMOTE_ADDR is used.
:param request: Django http request object.
:type request: django.http.HttpRequest
:returns: Possible client ip address
:rtype: string | [
"Return",
"client",
"ip",
"address",
"using",
"SECURE_PROXY_ADDR_HEADER",
"variable",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L499-L518 | train |
openstack/horizon | openstack_auth/utils.py | store_initial_k2k_session | def store_initial_k2k_session(auth_url, request, scoped_auth_ref,
unscoped_auth_ref):
"""Stores session variables if there are k2k service providers
This stores variables related to Keystone2Keystone federation. This
function gets skipped if there are no Keystone service provi... | python | def store_initial_k2k_session(auth_url, request, scoped_auth_ref,
unscoped_auth_ref):
"""Stores session variables if there are k2k service providers
This stores variables related to Keystone2Keystone federation. This
function gets skipped if there are no Keystone service provi... | [
"def",
"store_initial_k2k_session",
"(",
"auth_url",
",",
"request",
",",
"scoped_auth_ref",
",",
"unscoped_auth_ref",
")",
":",
"keystone_provider_id",
"=",
"request",
".",
"session",
".",
"get",
"(",
"'keystone_provider_id'",
",",
"None",
")",
"if",
"keystone_prov... | Stores session variables if there are k2k service providers
This stores variables related to Keystone2Keystone federation. This
function gets skipped if there are no Keystone service providers.
An unscoped token to the identity provider keystone gets stored
so that it can be used to do federated login ... | [
"Stores",
"session",
"variables",
"if",
"there",
"are",
"k2k",
"service",
"providers"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L521-L569 | train |
openstack/horizon | openstack_dashboard/utils/filters.py | get_int_or_uuid | def get_int_or_uuid(value):
"""Check if a value is valid as UUID or an integer.
This method is mainly used to convert floating IP id to the
appropriate type. For floating IP id, integer is used in Nova's
original implementation, but UUID is used in Neutron based one.
"""
try:
uuid.UUID(... | python | def get_int_or_uuid(value):
"""Check if a value is valid as UUID or an integer.
This method is mainly used to convert floating IP id to the
appropriate type. For floating IP id, integer is used in Nova's
original implementation, but UUID is used in Neutron based one.
"""
try:
uuid.UUID(... | [
"def",
"get_int_or_uuid",
"(",
"value",
")",
":",
"try",
":",
"uuid",
".",
"UUID",
"(",
"value",
")",
"return",
"value",
"except",
"(",
"ValueError",
",",
"AttributeError",
")",
":",
"return",
"int",
"(",
"value",
")"
] | Check if a value is valid as UUID or an integer.
This method is mainly used to convert floating IP id to the
appropriate type. For floating IP id, integer is used in Nova's
original implementation, but UUID is used in Neutron based one. | [
"Check",
"if",
"a",
"value",
"is",
"valid",
"as",
"UUID",
"or",
"an",
"integer",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/utils/filters.py#L18-L29 | train |
openstack/horizon | openstack_dashboard/utils/filters.py | get_display_label | def get_display_label(choices, status):
"""Get a display label for resource status.
This method is used in places where a resource's status or
admin state labels need to assigned before they are sent to the
view template.
"""
for (value, label) in choices:
if value == (status or '').lo... | python | def get_display_label(choices, status):
"""Get a display label for resource status.
This method is used in places where a resource's status or
admin state labels need to assigned before they are sent to the
view template.
"""
for (value, label) in choices:
if value == (status or '').lo... | [
"def",
"get_display_label",
"(",
"choices",
",",
"status",
")",
":",
"for",
"(",
"value",
",",
"label",
")",
"in",
"choices",
":",
"if",
"value",
"==",
"(",
"status",
"or",
"''",
")",
".",
"lower",
"(",
")",
":",
"display_label",
"=",
"label",
"break... | Get a display label for resource status.
This method is used in places where a resource's status or
admin state labels need to assigned before they are sent to the
view template. | [
"Get",
"a",
"display",
"label",
"for",
"resource",
"status",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/utils/filters.py#L32-L47 | train |
openstack/horizon | openstack_auth/backend.py | KeystoneBackend.get_user | def get_user(self, user_id):
"""Returns the current user from the session data.
If authenticated, this return the user object based on the user ID
and session data.
.. note::
This required monkey-patching the ``contrib.auth`` middleware
to make the ``request`` obje... | python | def get_user(self, user_id):
"""Returns the current user from the session data.
If authenticated, this return the user object based on the user ID
and session data.
.. note::
This required monkey-patching the ``contrib.auth`` middleware
to make the ``request`` obje... | [
"def",
"get_user",
"(",
"self",
",",
"user_id",
")",
":",
"if",
"(",
"hasattr",
"(",
"self",
",",
"'request'",
")",
"and",
"user_id",
"==",
"self",
".",
"request",
".",
"session",
"[",
"\"user_id\"",
"]",
")",
":",
"token",
"=",
"self",
".",
"request... | Returns the current user from the session data.
If authenticated, this return the user object based on the user ID
and session data.
.. note::
This required monkey-patching the ``contrib.auth`` middleware
to make the ``request`` object available to the auth backend class. | [
"Returns",
"the",
"current",
"user",
"from",
"the",
"session",
"data",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/backend.py#L66-L87 | train |
openstack/horizon | openstack_auth/backend.py | KeystoneBackend.get_all_permissions | def get_all_permissions(self, user, obj=None):
"""Returns a set of permission strings that the user has.
This permission available to the user is derived from the user's
Keystone "roles".
The permissions are returned as ``"openstack.{{ role.name }}"``.
"""
if user.is_an... | python | def get_all_permissions(self, user, obj=None):
"""Returns a set of permission strings that the user has.
This permission available to the user is derived from the user's
Keystone "roles".
The permissions are returned as ``"openstack.{{ role.name }}"``.
"""
if user.is_an... | [
"def",
"get_all_permissions",
"(",
"self",
",",
"user",
",",
"obj",
"=",
"None",
")",
":",
"if",
"user",
".",
"is_anonymous",
"or",
"obj",
"is",
"not",
"None",
":",
"return",
"set",
"(",
")",
"# TODO(gabrielhurley): Integrate policy-driven RBAC",
"# ... | Returns a set of permission strings that the user has.
This permission available to the user is derived from the user's
Keystone "roles".
The permissions are returned as ``"openstack.{{ role.name }}"``. | [
"Returns",
"a",
"set",
"of",
"permission",
"strings",
"that",
"the",
"user",
"has",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/backend.py#L240-L267 | train |
openstack/horizon | openstack_auth/backend.py | KeystoneBackend.has_perm | def has_perm(self, user, perm, obj=None):
"""Returns True if the given user has the specified permission."""
if not user.is_active:
return False
return perm in self.get_all_permissions(user, obj) | python | def has_perm(self, user, perm, obj=None):
"""Returns True if the given user has the specified permission."""
if not user.is_active:
return False
return perm in self.get_all_permissions(user, obj) | [
"def",
"has_perm",
"(",
"self",
",",
"user",
",",
"perm",
",",
"obj",
"=",
"None",
")",
":",
"if",
"not",
"user",
".",
"is_active",
":",
"return",
"False",
"return",
"perm",
"in",
"self",
".",
"get_all_permissions",
"(",
"user",
",",
"obj",
")"
] | Returns True if the given user has the specified permission. | [
"Returns",
"True",
"if",
"the",
"given",
"user",
"has",
"the",
"specified",
"permission",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/backend.py#L269-L273 | train |
openstack/horizon | horizon/exceptions.py | handle | def handle(request, message=None, redirect=None, ignore=False,
escalate=False, log_level=None, force_log=None):
"""Centralized error handling for Horizon.
Because Horizon consumes so many different APIs with completely
different ``Exception`` types, it's necessary to have a centralized
place... | python | def handle(request, message=None, redirect=None, ignore=False,
escalate=False, log_level=None, force_log=None):
"""Centralized error handling for Horizon.
Because Horizon consumes so many different APIs with completely
different ``Exception`` types, it's necessary to have a centralized
place... | [
"def",
"handle",
"(",
"request",
",",
"message",
"=",
"None",
",",
"redirect",
"=",
"None",
",",
"ignore",
"=",
"False",
",",
"escalate",
"=",
"False",
",",
"log_level",
"=",
"None",
",",
"force_log",
"=",
"None",
")",
":",
"exc_type",
",",
"exc_value"... | Centralized error handling for Horizon.
Because Horizon consumes so many different APIs with completely
different ``Exception`` types, it's necessary to have a centralized
place for handling exceptions which may be raised.
Exceptions are roughly divided into 3 types:
#. ``UNAUTHORIZED``: Errors r... | [
"Centralized",
"error",
"handling",
"for",
"Horizon",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/exceptions.py#L265-L348 | train |
openstack/horizon | openstack_dashboard/utils/config.py | load_config | def load_config(files=None, root_path=None, local_path=None):
"""Load the configuration from specified files."""
config = cfg.ConfigOpts()
config.register_opts([
cfg.Opt('root_path', default=root_path),
cfg.Opt('local_path', default=local_path),
])
# XXX register actual config group... | python | def load_config(files=None, root_path=None, local_path=None):
"""Load the configuration from specified files."""
config = cfg.ConfigOpts()
config.register_opts([
cfg.Opt('root_path', default=root_path),
cfg.Opt('local_path', default=local_path),
])
# XXX register actual config group... | [
"def",
"load_config",
"(",
"files",
"=",
"None",
",",
"root_path",
"=",
"None",
",",
"local_path",
"=",
"None",
")",
":",
"config",
"=",
"cfg",
".",
"ConfigOpts",
"(",
")",
"config",
".",
"register_opts",
"(",
"[",
"cfg",
".",
"Opt",
"(",
"'root_path'"... | Load the configuration from specified files. | [
"Load",
"the",
"configuration",
"from",
"specified",
"files",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/utils/config.py#L26-L38 | train |
openstack/horizon | openstack_dashboard/dashboards/identity/projects/tabs.py | UsersTab._update_user_roles_names_from_roles_id | def _update_user_roles_names_from_roles_id(self, user, users_roles,
roles_list):
"""Add roles names to user.roles, based on users_roles.
:param user: user to update
:param users_roles: list of roles ID
:param roles_list: list of roles obtai... | python | def _update_user_roles_names_from_roles_id(self, user, users_roles,
roles_list):
"""Add roles names to user.roles, based on users_roles.
:param user: user to update
:param users_roles: list of roles ID
:param roles_list: list of roles obtai... | [
"def",
"_update_user_roles_names_from_roles_id",
"(",
"self",
",",
"user",
",",
"users_roles",
",",
"roles_list",
")",
":",
"user_roles_names",
"=",
"[",
"role",
".",
"name",
"for",
"role",
"in",
"roles_list",
"if",
"role",
".",
"id",
"in",
"users_roles",
"]",... | Add roles names to user.roles, based on users_roles.
:param user: user to update
:param users_roles: list of roles ID
:param roles_list: list of roles obtained with keystone | [
"Add",
"roles",
"names",
"to",
"user",
".",
"roles",
"based",
"on",
"users_roles",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/identity/projects/tabs.py#L76-L87 | train |
openstack/horizon | openstack_dashboard/dashboards/identity/projects/tabs.py | UsersTab._get_users_from_project | def _get_users_from_project(self, project_id, roles, project_users):
"""Update with users which have role on project NOT through a group.
:param project_id: ID of the project
:param roles: list of roles from keystone
:param project_users: list to be updated with the users found
... | python | def _get_users_from_project(self, project_id, roles, project_users):
"""Update with users which have role on project NOT through a group.
:param project_id: ID of the project
:param roles: list of roles from keystone
:param project_users: list to be updated with the users found
... | [
"def",
"_get_users_from_project",
"(",
"self",
",",
"project_id",
",",
"roles",
",",
"project_users",
")",
":",
"# For keystone.user_list project_id is not passed as argument because",
"# it is ignored when using admin credentials",
"# Get all users (to be able to find user name)",
"us... | Update with users which have role on project NOT through a group.
:param project_id: ID of the project
:param roles: list of roles from keystone
:param project_users: list to be updated with the users found | [
"Update",
"with",
"users",
"which",
"have",
"role",
"on",
"project",
"NOT",
"through",
"a",
"group",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/identity/projects/tabs.py#L89-L122 | train |
openstack/horizon | openstack_dashboard/dashboards/identity/projects/tabs.py | UsersTab._get_users_from_groups | def _get_users_from_groups(self, project_id, roles, project_users):
"""Update with users which have role on project through a group.
:param project_id: ID of the project
:param roles: list of roles from keystone
:param project_users: list to be updated with the users found
"""
... | python | def _get_users_from_groups(self, project_id, roles, project_users):
"""Update with users which have role on project through a group.
:param project_id: ID of the project
:param roles: list of roles from keystone
:param project_users: list to be updated with the users found
"""
... | [
"def",
"_get_users_from_groups",
"(",
"self",
",",
"project_id",
",",
"roles",
",",
"project_users",
")",
":",
"# For keystone.group_list project_id is not passed as argument because",
"# it is ignored when using admin credentials",
"# Get all groups (to be able to find group name)",
"... | Update with users which have role on project through a group.
:param project_id: ID of the project
:param roles: list of roles from keystone
:param project_users: list to be updated with the users found | [
"Update",
"with",
"users",
"which",
"have",
"role",
"on",
"project",
"through",
"a",
"group",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/identity/projects/tabs.py#L124-L162 | train |
openstack/horizon | openstack_dashboard/dashboards/identity/projects/tabs.py | UsersTab.get_userstable_data | def get_userstable_data(self):
"""Get users with roles on the project.
Roles can be applied directly on the project or through a group.
"""
project_users = {}
project = self.tab_group.kwargs['project']
try:
# Get all global roles once to avoid multiple reque... | python | def get_userstable_data(self):
"""Get users with roles on the project.
Roles can be applied directly on the project or through a group.
"""
project_users = {}
project = self.tab_group.kwargs['project']
try:
# Get all global roles once to avoid multiple reque... | [
"def",
"get_userstable_data",
"(",
"self",
")",
":",
"project_users",
"=",
"{",
"}",
"project",
"=",
"self",
".",
"tab_group",
".",
"kwargs",
"[",
"'project'",
"]",
"try",
":",
"# Get all global roles once to avoid multiple requests.",
"roles",
"=",
"api",
".",
... | Get users with roles on the project.
Roles can be applied directly on the project or through a group. | [
"Get",
"users",
"with",
"roles",
"on",
"the",
"project",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/identity/projects/tabs.py#L164-L193 | train |
openstack/horizon | openstack_dashboard/api/swift.py | _objectify | def _objectify(items, container_name):
"""Splits a listing of objects into their appropriate wrapper classes."""
objects = []
# Deal with objects and object pseudo-folders first, save subdirs for later
for item in items:
if item.get("subdir", None) is not None:
object_cls = PseudoFo... | python | def _objectify(items, container_name):
"""Splits a listing of objects into their appropriate wrapper classes."""
objects = []
# Deal with objects and object pseudo-folders first, save subdirs for later
for item in items:
if item.get("subdir", None) is not None:
object_cls = PseudoFo... | [
"def",
"_objectify",
"(",
"items",
",",
"container_name",
")",
":",
"objects",
"=",
"[",
"]",
"# Deal with objects and object pseudo-folders first, save subdirs for later",
"for",
"item",
"in",
"items",
":",
"if",
"item",
".",
"get",
"(",
"\"subdir\"",
",",
"None",
... | Splits a listing of objects into their appropriate wrapper classes. | [
"Splits",
"a",
"listing",
"of",
"objects",
"into",
"their",
"appropriate",
"wrapper",
"classes",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/swift.py#L91-L104 | train |
openstack/horizon | openstack_dashboard/utils/config_types.py | Literal.validate | def validate(self, result, spec): # noqa Yes, it's too complex.
"""Validate that the result has the correct structure."""
if spec is None:
# None matches anything.
return
if isinstance(spec, dict):
if not isinstance(result, dict):
raise ValueE... | python | def validate(self, result, spec): # noqa Yes, it's too complex.
"""Validate that the result has the correct structure."""
if spec is None:
# None matches anything.
return
if isinstance(spec, dict):
if not isinstance(result, dict):
raise ValueE... | [
"def",
"validate",
"(",
"self",
",",
"result",
",",
"spec",
")",
":",
"# noqa Yes, it's too complex.",
"if",
"spec",
"is",
"None",
":",
"# None matches anything.",
"return",
"if",
"isinstance",
"(",
"spec",
",",
"dict",
")",
":",
"if",
"not",
"isinstance",
"... | Validate that the result has the correct structure. | [
"Validate",
"that",
"the",
"result",
"has",
"the",
"correct",
"structure",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/utils/config_types.py#L117-L154 | train |
openstack/horizon | openstack_dashboard/utils/config_types.py | Literal.update | def update(self, result, spec):
"""Replace elements with results of calling callables."""
if isinstance(spec, dict):
if spec:
spec_value = next(iter(spec.values()))
for key, value in result.items():
result[key] = self.update(value, spec_val... | python | def update(self, result, spec):
"""Replace elements with results of calling callables."""
if isinstance(spec, dict):
if spec:
spec_value = next(iter(spec.values()))
for key, value in result.items():
result[key] = self.update(value, spec_val... | [
"def",
"update",
"(",
"self",
",",
"result",
",",
"spec",
")",
":",
"if",
"isinstance",
"(",
"spec",
",",
"dict",
")",
":",
"if",
"spec",
":",
"spec_value",
"=",
"next",
"(",
"iter",
"(",
"spec",
".",
"values",
"(",
")",
")",
")",
"for",
"key",
... | Replace elements with results of calling callables. | [
"Replace",
"elements",
"with",
"results",
"of",
"calling",
"callables",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/utils/config_types.py#L156-L172 | train |
openstack/horizon | openstack_dashboard/dashboards/project/images/utils.py | get_available_images | def get_available_images(request, project_id=None, images_cache=None):
"""Returns a list of available images
Returns a list of images that are public, shared, community or owned by
the given project_id. If project_id is not specified, only public and
community images are returned.
:param images_ca... | python | def get_available_images(request, project_id=None, images_cache=None):
"""Returns a list of available images
Returns a list of images that are public, shared, community or owned by
the given project_id. If project_id is not specified, only public and
community images are returned.
:param images_ca... | [
"def",
"get_available_images",
"(",
"request",
",",
"project_id",
"=",
"None",
",",
"images_cache",
"=",
"None",
")",
":",
"if",
"images_cache",
"is",
"None",
":",
"images_cache",
"=",
"{",
"}",
"public_images",
"=",
"images_cache",
".",
"get",
"(",
"'public... | Returns a list of available images
Returns a list of images that are public, shared, community or owned by
the given project_id. If project_id is not specified, only public and
community images are returned.
:param images_cache: An optional dict-like object in which to
cache public and per-project... | [
"Returns",
"a",
"list",
"of",
"available",
"images"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/images/utils.py#L21-L104 | train |
openstack/horizon | openstack_dashboard/dashboards/project/images/utils.py | image_field_data | def image_field_data(request, include_empty_option=False):
"""Returns a list of tuples of all images.
Generates a sorted list of images available. And returns a list of
(id, name) tuples.
:param request: django http request object
:param include_empty_option: flag to include a empty tuple in the f... | python | def image_field_data(request, include_empty_option=False):
"""Returns a list of tuples of all images.
Generates a sorted list of images available. And returns a list of
(id, name) tuples.
:param request: django http request object
:param include_empty_option: flag to include a empty tuple in the f... | [
"def",
"image_field_data",
"(",
"request",
",",
"include_empty_option",
"=",
"False",
")",
":",
"try",
":",
"images",
"=",
"get_available_images",
"(",
"request",
",",
"request",
".",
"user",
".",
"project_id",
")",
"except",
"Exception",
":",
"exceptions",
".... | Returns a list of tuples of all images.
Generates a sorted list of images available. And returns a list of
(id, name) tuples.
:param request: django http request object
:param include_empty_option: flag to include a empty tuple in the front of
the list
:return: list of (id, name) tuples | [
"Returns",
"a",
"list",
"of",
"tuples",
"of",
"all",
"images",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/images/utils.py#L107-L133 | train |
openstack/horizon | horizon/templatetags/horizon.py | horizon_main_nav | def horizon_main_nav(context):
"""Generates top-level dashboard navigation entries."""
if 'request' not in context:
return {}
current_dashboard = context['request'].horizon.get('dashboard', None)
dashboards = []
for dash in Horizon.get_dashboards():
if dash.can_access(context):
... | python | def horizon_main_nav(context):
"""Generates top-level dashboard navigation entries."""
if 'request' not in context:
return {}
current_dashboard = context['request'].horizon.get('dashboard', None)
dashboards = []
for dash in Horizon.get_dashboards():
if dash.can_access(context):
... | [
"def",
"horizon_main_nav",
"(",
"context",
")",
":",
"if",
"'request'",
"not",
"in",
"context",
":",
"return",
"{",
"}",
"current_dashboard",
"=",
"context",
"[",
"'request'",
"]",
".",
"horizon",
".",
"get",
"(",
"'dashboard'",
",",
"None",
")",
"dashboar... | Generates top-level dashboard navigation entries. | [
"Generates",
"top",
"-",
"level",
"dashboard",
"navigation",
"entries",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/templatetags/horizon.py#L95-L110 | train |
openstack/horizon | horizon/templatetags/horizon.py | horizon_dashboard_nav | def horizon_dashboard_nav(context):
"""Generates sub-navigation entries for the current dashboard."""
if 'request' not in context:
return {}
dashboard = context['request'].horizon['dashboard']
panel_groups = dashboard.get_panel_groups()
non_empty_groups = []
for group in panel_groups.va... | python | def horizon_dashboard_nav(context):
"""Generates sub-navigation entries for the current dashboard."""
if 'request' not in context:
return {}
dashboard = context['request'].horizon['dashboard']
panel_groups = dashboard.get_panel_groups()
non_empty_groups = []
for group in panel_groups.va... | [
"def",
"horizon_dashboard_nav",
"(",
"context",
")",
":",
"if",
"'request'",
"not",
"in",
"context",
":",
"return",
"{",
"}",
"dashboard",
"=",
"context",
"[",
"'request'",
"]",
".",
"horizon",
"[",
"'dashboard'",
"]",
"panel_groups",
"=",
"dashboard",
".",
... | Generates sub-navigation entries for the current dashboard. | [
"Generates",
"sub",
"-",
"navigation",
"entries",
"for",
"the",
"current",
"dashboard",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/templatetags/horizon.py#L114-L140 | train |
openstack/horizon | horizon/templatetags/horizon.py | jstemplate | def jstemplate(parser, token):
"""Templatetag to handle any of the Mustache-based templates.
Replaces ``[[[`` and ``]]]`` with ``{{{`` and ``}}}``,
``[[`` and ``]]`` with ``{{`` and ``}}`` and
``[%`` and ``%]`` with ``{%`` and ``%}`` to avoid conflicts
with Django's template engine when using any ... | python | def jstemplate(parser, token):
"""Templatetag to handle any of the Mustache-based templates.
Replaces ``[[[`` and ``]]]`` with ``{{{`` and ``}}}``,
``[[`` and ``]]`` with ``{{`` and ``}}`` and
``[%`` and ``%]`` with ``{%`` and ``%}`` to avoid conflicts
with Django's template engine when using any ... | [
"def",
"jstemplate",
"(",
"parser",
",",
"token",
")",
":",
"nodelist",
"=",
"parser",
".",
"parse",
"(",
"(",
"'endjstemplate'",
",",
")",
")",
"parser",
".",
"delete_first_token",
"(",
")",
"return",
"JSTemplateNode",
"(",
"nodelist",
")"
] | Templatetag to handle any of the Mustache-based templates.
Replaces ``[[[`` and ``]]]`` with ``{{{`` and ``}}}``,
``[[`` and ``]]`` with ``{{`` and ``}}`` and
``[%`` and ``%]`` with ``{%`` and ``%}`` to avoid conflicts
with Django's template engine when using any of the Mustache-based
templating l... | [
"Templatetag",
"to",
"handle",
"any",
"of",
"the",
"Mustache",
"-",
"based",
"templates",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/templatetags/horizon.py#L188-L199 | train |
openstack/horizon | horizon/templatetags/horizon.py | minifyspace | def minifyspace(parser, token):
"""Removes whitespace including tab and newline characters.
Do not use this if you are using a <pre> tag.
Example usage::
{% minifyspace %}
<p>
<a title="foo"
href="foo/">
Foo
</a>
... | python | def minifyspace(parser, token):
"""Removes whitespace including tab and newline characters.
Do not use this if you are using a <pre> tag.
Example usage::
{% minifyspace %}
<p>
<a title="foo"
href="foo/">
Foo
</a>
... | [
"def",
"minifyspace",
"(",
"parser",
",",
"token",
")",
":",
"nodelist",
"=",
"parser",
".",
"parse",
"(",
"(",
"'endminifyspace'",
",",
")",
")",
"parser",
".",
"delete_first_token",
"(",
")",
"return",
"MinifiedNode",
"(",
"nodelist",
")"
] | Removes whitespace including tab and newline characters.
Do not use this if you are using a <pre> tag.
Example usage::
{% minifyspace %}
<p>
<a title="foo"
href="foo/">
Foo
</a>
</p>
{% endminifysp... | [
"Removes",
"whitespace",
"including",
"tab",
"and",
"newline",
"characters",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/templatetags/horizon.py#L220-L243 | train |
openstack/horizon | horizon/notifications.py | process_message_notification | def process_message_notification(request, messages_path):
"""Process all the msg file found in the message directory"""
if not messages_path:
return
global _MESSAGES_CACHE
global _MESSAGES_MTIME
# NOTE (lhcheng): Cache the processed messages to avoid parsing
# the files every time. Che... | python | def process_message_notification(request, messages_path):
"""Process all the msg file found in the message directory"""
if not messages_path:
return
global _MESSAGES_CACHE
global _MESSAGES_MTIME
# NOTE (lhcheng): Cache the processed messages to avoid parsing
# the files every time. Che... | [
"def",
"process_message_notification",
"(",
"request",
",",
"messages_path",
")",
":",
"if",
"not",
"messages_path",
":",
"return",
"global",
"_MESSAGES_CACHE",
"global",
"_MESSAGES_MTIME",
"# NOTE (lhcheng): Cache the processed messages to avoid parsing",
"# the files every time... | Process all the msg file found in the message directory | [
"Process",
"all",
"the",
"msg",
"file",
"found",
"in",
"the",
"message",
"directory"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/notifications.py#L132-L149 | train |
openstack/horizon | horizon/notifications.py | JSONMessage.load | def load(self):
"""Read and parse the message file."""
try:
self._read()
self._parse()
except Exception as exc:
self.failed = True
params = {'path': self._path, 'exception': exc}
if self.fail_silently:
LOG.warning("Erro... | python | def load(self):
"""Read and parse the message file."""
try:
self._read()
self._parse()
except Exception as exc:
self.failed = True
params = {'path': self._path, 'exception': exc}
if self.fail_silently:
LOG.warning("Erro... | [
"def",
"load",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_read",
"(",
")",
"self",
".",
"_parse",
"(",
")",
"except",
"Exception",
"as",
"exc",
":",
"self",
".",
"failed",
"=",
"True",
"params",
"=",
"{",
"'path'",
":",
"self",
".",
"_path... | Read and parse the message file. | [
"Read",
"and",
"parse",
"the",
"message",
"file",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/notifications.py#L85-L100 | train |
openstack/horizon | horizon/tables/views.py | MultiTableMixin.handle_server_filter | def handle_server_filter(self, request, table=None):
"""Update the table server filter information in the session.
Returns True if the filter has been changed.
"""
if not table:
table = self.get_table()
filter_info = self.get_server_filter_info(request, table)
... | python | def handle_server_filter(self, request, table=None):
"""Update the table server filter information in the session.
Returns True if the filter has been changed.
"""
if not table:
table = self.get_table()
filter_info = self.get_server_filter_info(request, table)
... | [
"def",
"handle_server_filter",
"(",
"self",
",",
"request",
",",
"table",
"=",
"None",
")",
":",
"if",
"not",
"table",
":",
"table",
"=",
"self",
".",
"get_table",
"(",
")",
"filter_info",
"=",
"self",
".",
"get_server_filter_info",
"(",
"request",
",",
... | Update the table server filter information in the session.
Returns True if the filter has been changed. | [
"Update",
"the",
"table",
"server",
"filter",
"information",
"in",
"the",
"session",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/views.py#L160-L173 | train |
openstack/horizon | horizon/tables/views.py | MultiTableMixin.update_server_filter_action | def update_server_filter_action(self, request, table=None):
"""Update the table server side filter action.
It is done based on the current filter. The filter info may be stored
in the session and this will restore it.
"""
if not table:
table = self.get_table()
... | python | def update_server_filter_action(self, request, table=None):
"""Update the table server side filter action.
It is done based on the current filter. The filter info may be stored
in the session and this will restore it.
"""
if not table:
table = self.get_table()
... | [
"def",
"update_server_filter_action",
"(",
"self",
",",
"request",
",",
"table",
"=",
"None",
")",
":",
"if",
"not",
"table",
":",
"table",
"=",
"self",
".",
"get_table",
"(",
")",
"filter_info",
"=",
"self",
".",
"get_server_filter_info",
"(",
"request",
... | Update the table server side filter action.
It is done based on the current filter. The filter info may be stored
in the session and this will restore it. | [
"Update",
"the",
"table",
"server",
"side",
"filter",
"action",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/views.py#L175-L188 | train |
openstack/horizon | horizon/tables/views.py | DataTableView.get_filters | def get_filters(self, filters=None, filters_map=None):
"""Converts a string given by the user into a valid api filter value.
:filters: Default filter values.
{'filter1': filter_value, 'filter2': filter_value}
:filters_map: mapping between user input and valid api filter values.
... | python | def get_filters(self, filters=None, filters_map=None):
"""Converts a string given by the user into a valid api filter value.
:filters: Default filter values.
{'filter1': filter_value, 'filter2': filter_value}
:filters_map: mapping between user input and valid api filter values.
... | [
"def",
"get_filters",
"(",
"self",
",",
"filters",
"=",
"None",
",",
"filters_map",
"=",
"None",
")",
":",
"filters",
"=",
"filters",
"or",
"{",
"}",
"filters_map",
"=",
"filters_map",
"or",
"{",
"}",
"filter_action",
"=",
"self",
".",
"table",
".",
"_... | Converts a string given by the user into a valid api filter value.
:filters: Default filter values.
{'filter1': filter_value, 'filter2': filter_value}
:filters_map: mapping between user input and valid api filter values.
{'filter_name':{_("true_value"):True, _("false_value"):Fal... | [
"Converts",
"a",
"string",
"given",
"by",
"the",
"user",
"into",
"a",
"valid",
"api",
"filter",
"value",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/views.py#L290-L314 | train |
openstack/horizon | openstack_dashboard/dashboards/project/networks/workflows.py | CreateNetwork._setup_subnet_parameters | def _setup_subnet_parameters(self, params, data, is_create=True):
"""Setup subnet parameters
This methods setups subnet parameters which are available
in both create and update.
"""
is_update = not is_create
params['enable_dhcp'] = data['enable_dhcp']
if int(data... | python | def _setup_subnet_parameters(self, params, data, is_create=True):
"""Setup subnet parameters
This methods setups subnet parameters which are available
in both create and update.
"""
is_update = not is_create
params['enable_dhcp'] = data['enable_dhcp']
if int(data... | [
"def",
"_setup_subnet_parameters",
"(",
"self",
",",
"params",
",",
"data",
",",
"is_create",
"=",
"True",
")",
":",
"is_update",
"=",
"not",
"is_create",
"params",
"[",
"'enable_dhcp'",
"]",
"=",
"data",
"[",
"'enable_dhcp'",
"]",
"if",
"int",
"(",
"data"... | Setup subnet parameters
This methods setups subnet parameters which are available
in both create and update. | [
"Setup",
"subnet",
"parameters"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/networks/workflows.py#L498-L528 | train |
openstack/horizon | openstack_dashboard/dashboards/project/networks/workflows.py | CreateNetwork._delete_network | def _delete_network(self, request, network):
"""Delete the created network when subnet creation failed."""
try:
api.neutron.network_delete(request, network.id)
LOG.debug('Delete the created network %s '
'due to subnet creation failure.', network.id)
... | python | def _delete_network(self, request, network):
"""Delete the created network when subnet creation failed."""
try:
api.neutron.network_delete(request, network.id)
LOG.debug('Delete the created network %s '
'due to subnet creation failure.', network.id)
... | [
"def",
"_delete_network",
"(",
"self",
",",
"request",
",",
"network",
")",
":",
"try",
":",
"api",
".",
"neutron",
".",
"network_delete",
"(",
"request",
",",
"network",
".",
"id",
")",
"LOG",
".",
"debug",
"(",
"'Delete the created network %s '",
"'due to ... | Delete the created network when subnet creation failed. | [
"Delete",
"the",
"created",
"network",
"when",
"subnet",
"creation",
"failed",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/networks/workflows.py#L578-L594 | train |
openstack/horizon | horizon/templatetags/bootstrap.py | bs_progress_bar | def bs_progress_bar(*args, **kwargs):
"""A Standard Bootstrap Progress Bar.
http://getbootstrap.com/components/#progress
param args (Array of Numbers: 0-100): Percent of Progress Bars
param context (String): Adds 'progress-bar-{context} to the class attribute
param contexts (Array of Strings): Cyc... | python | def bs_progress_bar(*args, **kwargs):
"""A Standard Bootstrap Progress Bar.
http://getbootstrap.com/components/#progress
param args (Array of Numbers: 0-100): Percent of Progress Bars
param context (String): Adds 'progress-bar-{context} to the class attribute
param contexts (Array of Strings): Cyc... | [
"def",
"bs_progress_bar",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"bars",
"=",
"[",
"]",
"contexts",
"=",
"kwargs",
".",
"get",
"(",
"'contexts'",
",",
"[",
"''",
",",
"'success'",
",",
"'info'",
",",
"'warning'",
",",
"'danger'",
"]",
... | A Standard Bootstrap Progress Bar.
http://getbootstrap.com/components/#progress
param args (Array of Numbers: 0-100): Percent of Progress Bars
param context (String): Adds 'progress-bar-{context} to the class attribute
param contexts (Array of Strings): Cycles through contexts for stacked bars
par... | [
"A",
"Standard",
"Bootstrap",
"Progress",
"Bar",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/templatetags/bootstrap.py#L25-L59 | train |
openstack/horizon | horizon/utils/filters.py | timesince_or_never | def timesince_or_never(dt, default=None):
"""Call the Django ``timesince`` filter or a given default string.
It returns the string *default* if *dt* is not a valid ``date``
or ``datetime`` object.
When *default* is None, "Never" is returned.
"""
if default is None:
default = _("Never")
... | python | def timesince_or_never(dt, default=None):
"""Call the Django ``timesince`` filter or a given default string.
It returns the string *default* if *dt* is not a valid ``date``
or ``datetime`` object.
When *default* is None, "Never" is returned.
"""
if default is None:
default = _("Never")
... | [
"def",
"timesince_or_never",
"(",
"dt",
",",
"default",
"=",
"None",
")",
":",
"if",
"default",
"is",
"None",
":",
"default",
"=",
"_",
"(",
"\"Never\"",
")",
"if",
"isinstance",
"(",
"dt",
",",
"datetime",
".",
"date",
")",
":",
"return",
"timesince",... | Call the Django ``timesince`` filter or a given default string.
It returns the string *default* if *dt* is not a valid ``date``
or ``datetime`` object.
When *default* is None, "Never" is returned. | [
"Call",
"the",
"Django",
"timesince",
"filter",
"or",
"a",
"given",
"default",
"string",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/filters.py#L42-L55 | train |
openstack/horizon | openstack_auth/plugin/k2k.py | K2KAuthPlugin.get_plugin | def get_plugin(self, service_provider=None, auth_url=None, plugins=None,
**kwargs):
"""Authenticate using keystone to keystone federation.
This plugin uses other v3 plugins to authenticate a user to a
identity provider in order to authenticate the user to a service
pr... | python | def get_plugin(self, service_provider=None, auth_url=None, plugins=None,
**kwargs):
"""Authenticate using keystone to keystone federation.
This plugin uses other v3 plugins to authenticate a user to a
identity provider in order to authenticate the user to a service
pr... | [
"def",
"get_plugin",
"(",
"self",
",",
"service_provider",
"=",
"None",
",",
"auth_url",
"=",
"None",
",",
"plugins",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Avoid mutable default arg for plugins",
"plugins",
"=",
"plugins",
"or",
"[",
"]",
"# ser... | Authenticate using keystone to keystone federation.
This plugin uses other v3 plugins to authenticate a user to a
identity provider in order to authenticate the user to a service
provider
:param service_provider: service provider ID
:param auth_url: Keystone auth url
:p... | [
"Authenticate",
"using",
"keystone",
"to",
"keystone",
"federation",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/plugin/k2k.py#L31-L91 | train |
openstack/horizon | openstack_auth/plugin/k2k.py | K2KAuthPlugin.get_access_info | def get_access_info(self, unscoped_auth):
"""Get the access info object
We attempt to get the auth ref. If it fails and if the K2K auth plugin
was being used then we will prepend a message saying that the error was
on the service provider side.
:param: unscoped_auth: Keystone au... | python | def get_access_info(self, unscoped_auth):
"""Get the access info object
We attempt to get the auth ref. If it fails and if the K2K auth plugin
was being used then we will prepend a message saying that the error was
on the service provider side.
:param: unscoped_auth: Keystone au... | [
"def",
"get_access_info",
"(",
"self",
",",
"unscoped_auth",
")",
":",
"try",
":",
"unscoped_auth_ref",
"=",
"base",
".",
"BasePlugin",
".",
"get_access_info",
"(",
"self",
",",
"unscoped_auth",
")",
"except",
"exceptions",
".",
"KeystoneAuthException",
"as",
"e... | Get the access info object
We attempt to get the auth ref. If it fails and if the K2K auth plugin
was being used then we will prepend a message saying that the error was
on the service provider side.
:param: unscoped_auth: Keystone auth plugin for unscoped user
:returns: keyston... | [
"Get",
"the",
"access",
"info",
"object"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/plugin/k2k.py#L93-L108 | train |
openstack/horizon | openstack_auth/user.py | User.is_token_expired | def is_token_expired(self, margin=None):
"""Determine if the token is expired.
:returns:
``True`` if the token is expired, ``False`` if not, and
``None`` if there is no token set.
:param margin:
A security time margin in seconds before real expiration.
... | python | def is_token_expired(self, margin=None):
"""Determine if the token is expired.
:returns:
``True`` if the token is expired, ``False`` if not, and
``None`` if there is no token set.
:param margin:
A security time margin in seconds before real expiration.
... | [
"def",
"is_token_expired",
"(",
"self",
",",
"margin",
"=",
"None",
")",
":",
"if",
"self",
".",
"token",
"is",
"None",
":",
"return",
"None",
"return",
"not",
"utils",
".",
"is_token_valid",
"(",
"self",
".",
"token",
",",
"margin",
")"
] | Determine if the token is expired.
:returns:
``True`` if the token is expired, ``False`` if not, and
``None`` if there is no token set.
:param margin:
A security time margin in seconds before real expiration.
Will return ``True`` if the token expires in less t... | [
"Determine",
"if",
"the",
"token",
"is",
"expired",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/user.py#L245-L262 | train |
openstack/horizon | openstack_auth/user.py | User.is_superuser | def is_superuser(self):
"""Evaluates whether this user has admin privileges.
:returns: ``True`` or ``False``.
"""
admin_roles = utils.get_admin_roles()
user_roles = {role['name'].lower() for role in self.roles}
return not admin_roles.isdisjoint(user_roles) | python | def is_superuser(self):
"""Evaluates whether this user has admin privileges.
:returns: ``True`` or ``False``.
"""
admin_roles = utils.get_admin_roles()
user_roles = {role['name'].lower() for role in self.roles}
return not admin_roles.isdisjoint(user_roles) | [
"def",
"is_superuser",
"(",
"self",
")",
":",
"admin_roles",
"=",
"utils",
".",
"get_admin_roles",
"(",
")",
"user_roles",
"=",
"{",
"role",
"[",
"'name'",
"]",
".",
"lower",
"(",
")",
"for",
"role",
"in",
"self",
".",
"roles",
"}",
"return",
"not",
... | Evaluates whether this user has admin privileges.
:returns: ``True`` or ``False``. | [
"Evaluates",
"whether",
"this",
"user",
"has",
"admin",
"privileges",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/user.py#L282-L289 | train |
openstack/horizon | openstack_auth/user.py | User.authorized_tenants | def authorized_tenants(self):
"""Returns a memoized list of tenants this user may access."""
if self.is_authenticated and self._authorized_tenants is None:
endpoint = self.endpoint
try:
self._authorized_tenants = utils.get_project_list(
user_id... | python | def authorized_tenants(self):
"""Returns a memoized list of tenants this user may access."""
if self.is_authenticated and self._authorized_tenants is None:
endpoint = self.endpoint
try:
self._authorized_tenants = utils.get_project_list(
user_id... | [
"def",
"authorized_tenants",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_authenticated",
"and",
"self",
".",
"_authorized_tenants",
"is",
"None",
":",
"endpoint",
"=",
"self",
".",
"endpoint",
"try",
":",
"self",
".",
"_authorized_tenants",
"=",
"utils",
"... | Returns a memoized list of tenants this user may access. | [
"Returns",
"a",
"memoized",
"list",
"of",
"tenants",
"this",
"user",
"may",
"access",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/user.py#L292-L305 | train |
openstack/horizon | openstack_auth/user.py | User.available_services_regions | def available_services_regions(self):
"""Returns list of unique region name values in service catalog."""
regions = []
if self.service_catalog:
for service in self.service_catalog:
service_type = service.get('type')
if service_type is None or service_t... | python | def available_services_regions(self):
"""Returns list of unique region name values in service catalog."""
regions = []
if self.service_catalog:
for service in self.service_catalog:
service_type = service.get('type')
if service_type is None or service_t... | [
"def",
"available_services_regions",
"(",
"self",
")",
":",
"regions",
"=",
"[",
"]",
"if",
"self",
".",
"service_catalog",
":",
"for",
"service",
"in",
"self",
".",
"service_catalog",
":",
"service_type",
"=",
"service",
".",
"get",
"(",
"'type'",
")",
"i... | Returns list of unique region name values in service catalog. | [
"Returns",
"list",
"of",
"unique",
"region",
"name",
"values",
"in",
"service",
"catalog",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/user.py#L320-L332 | train |
openstack/horizon | openstack_auth/user.py | User.has_a_matching_perm | def has_a_matching_perm(self, perm_list, obj=None):
"""Returns True if the user has one of the specified permissions.
If object is passed, it checks if the user has any of the required
perms for this object.
"""
# If there are no permissions to check, just return true
if... | python | def has_a_matching_perm(self, perm_list, obj=None):
"""Returns True if the user has one of the specified permissions.
If object is passed, it checks if the user has any of the required
perms for this object.
"""
# If there are no permissions to check, just return true
if... | [
"def",
"has_a_matching_perm",
"(",
"self",
",",
"perm_list",
",",
"obj",
"=",
"None",
")",
":",
"# If there are no permissions to check, just return true",
"if",
"not",
"perm_list",
":",
"return",
"True",
"# Check that user has at least one of the required permissions.",
"for... | Returns True if the user has one of the specified permissions.
If object is passed, it checks if the user has any of the required
perms for this object. | [
"Returns",
"True",
"if",
"the",
"user",
"has",
"one",
"of",
"the",
"specified",
"permissions",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/user.py#L344-L357 | train |
openstack/horizon | openstack_auth/user.py | User.has_perms | def has_perms(self, perm_list, obj=None):
"""Returns True if the user has all of the specified permissions.
Tuples in the list will possess the required permissions if
the user has a permissions matching one of the elements of
that tuple
"""
# If there are no permissions... | python | def has_perms(self, perm_list, obj=None):
"""Returns True if the user has all of the specified permissions.
Tuples in the list will possess the required permissions if
the user has a permissions matching one of the elements of
that tuple
"""
# If there are no permissions... | [
"def",
"has_perms",
"(",
"self",
",",
"perm_list",
",",
"obj",
"=",
"None",
")",
":",
"# If there are no permissions to check, just return true",
"if",
"not",
"perm_list",
":",
"return",
"True",
"for",
"perm",
"in",
"perm_list",
":",
"if",
"isinstance",
"(",
"pe... | Returns True if the user has all of the specified permissions.
Tuples in the list will possess the required permissions if
the user has a permissions matching one of the elements of
that tuple | [
"Returns",
"True",
"if",
"the",
"user",
"has",
"all",
"of",
"the",
"specified",
"permissions",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/user.py#L371-L390 | train |
openstack/horizon | openstack_auth/user.py | User.time_until_expiration | def time_until_expiration(self):
"""Returns the number of remaining days until user's password expires.
Calculates the number days until the user must change their password,
once the password expires the user will not able to log in until an
admin changes its password.
"""
... | python | def time_until_expiration(self):
"""Returns the number of remaining days until user's password expires.
Calculates the number days until the user must change their password,
once the password expires the user will not able to log in until an
admin changes its password.
"""
... | [
"def",
"time_until_expiration",
"(",
"self",
")",
":",
"if",
"self",
".",
"password_expires_at",
"is",
"not",
"None",
":",
"expiration_date",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"self",
".",
"password_expires_at",
",",
"\"%Y-%m-%dT%H:%M:%S.%f\"... | Returns the number of remaining days until user's password expires.
Calculates the number days until the user must change their password,
once the password expires the user will not able to log in until an
admin changes its password. | [
"Returns",
"the",
"number",
"of",
"remaining",
"days",
"until",
"user",
"s",
"password",
"expires",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/user.py#L392-L402 | train |
openstack/horizon | openstack_dashboard/contrib/developer/profiler/middleware.py | ProfilerMiddleware.clear_profiling_cookies | def clear_profiling_cookies(request, response):
"""Expire any cookie that initiated profiling request."""
if 'profile_page' in request.COOKIES:
path = request.path
response.set_cookie('profile_page', max_age=0, path=path) | python | def clear_profiling_cookies(request, response):
"""Expire any cookie that initiated profiling request."""
if 'profile_page' in request.COOKIES:
path = request.path
response.set_cookie('profile_page', max_age=0, path=path) | [
"def",
"clear_profiling_cookies",
"(",
"request",
",",
"response",
")",
":",
"if",
"'profile_page'",
"in",
"request",
".",
"COOKIES",
":",
"path",
"=",
"request",
".",
"path",
"response",
".",
"set_cookie",
"(",
"'profile_page'",
",",
"max_age",
"=",
"0",
",... | Expire any cookie that initiated profiling request. | [
"Expire",
"any",
"cookie",
"that",
"initiated",
"profiling",
"request",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/contrib/developer/profiler/middleware.py#L137-L141 | train |
openstack/horizon | horizon/views.py | PageTitleMixin.render_context_with_title | def render_context_with_title(self, context):
"""Render a page title and insert it into the context.
This function takes in a context dict and uses it to render the
page_title variable. It then appends this title to the context using
the 'page_title' key. If there is already a page_titl... | python | def render_context_with_title(self, context):
"""Render a page title and insert it into the context.
This function takes in a context dict and uses it to render the
page_title variable. It then appends this title to the context using
the 'page_title' key. If there is already a page_titl... | [
"def",
"render_context_with_title",
"(",
"self",
",",
"context",
")",
":",
"if",
"\"page_title\"",
"not",
"in",
"context",
":",
"con",
"=",
"template",
".",
"Context",
"(",
"context",
")",
"# NOTE(sambetts): Use force_text to ensure lazy translations",
"# are handled co... | Render a page title and insert it into the context.
This function takes in a context dict and uses it to render the
page_title variable. It then appends this title to the context using
the 'page_title' key. If there is already a page_title key defined in
context received then this funct... | [
"Render",
"a",
"page",
"title",
"and",
"insert",
"it",
"into",
"the",
"context",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/views.py#L45-L60 | train |
openstack/horizon | openstack_auth/policy.py | check | def check(actions, request, target=None):
"""Check user permission.
Check if the user has permission to the action according
to policy setting.
:param actions: list of scope and action to do policy checks on,
the composition of which is (scope, action). Multiple actions
are treated as ... | python | def check(actions, request, target=None):
"""Check user permission.
Check if the user has permission to the action according
to policy setting.
:param actions: list of scope and action to do policy checks on,
the composition of which is (scope, action). Multiple actions
are treated as ... | [
"def",
"check",
"(",
"actions",
",",
"request",
",",
"target",
"=",
"None",
")",
":",
"if",
"target",
"is",
"None",
":",
"target",
"=",
"{",
"}",
"user",
"=",
"auth_utils",
".",
"get_user",
"(",
"request",
")",
"# Several service policy engines default to a ... | Check user permission.
Check if the user has permission to the action according
to policy setting.
:param actions: list of scope and action to do policy checks on,
the composition of which is (scope, action). Multiple actions
are treated as a logical AND.
* scope: service type man... | [
"Check",
"user",
"permission",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/policy.py#L86-L186 | train |
openstack/horizon | horizon/utils/functions.py | logout_with_message | def logout_with_message(request, msg, redirect=True, status='success'):
"""Send HttpResponseRedirect to LOGOUT_URL.
`msg` is a message displayed on the login page after the logout, to explain
the logout reason.
"""
logout(request)
if redirect:
response = http.HttpResponseRedirect(
... | python | def logout_with_message(request, msg, redirect=True, status='success'):
"""Send HttpResponseRedirect to LOGOUT_URL.
`msg` is a message displayed on the login page after the logout, to explain
the logout reason.
"""
logout(request)
if redirect:
response = http.HttpResponseRedirect(
... | [
"def",
"logout_with_message",
"(",
"request",
",",
"msg",
",",
"redirect",
"=",
"True",
",",
"status",
"=",
"'success'",
")",
":",
"logout",
"(",
"request",
")",
"if",
"redirect",
":",
"response",
"=",
"http",
".",
"HttpResponseRedirect",
"(",
"'%s?next=%s'"... | Send HttpResponseRedirect to LOGOUT_URL.
`msg` is a message displayed on the login page after the logout, to explain
the logout reason. | [
"Send",
"HttpResponseRedirect",
"to",
"LOGOUT_URL",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/functions.py#L54-L67 | train |
openstack/horizon | horizon/utils/functions.py | save_config_value | def save_config_value(request, response, key, value):
"""Sets value of key `key` to `value` in both session and cookies."""
request.session[key] = value
response.set_cookie(key, value, expires=one_year_from_now())
return response | python | def save_config_value(request, response, key, value):
"""Sets value of key `key` to `value` in both session and cookies."""
request.session[key] = value
response.set_cookie(key, value, expires=one_year_from_now())
return response | [
"def",
"save_config_value",
"(",
"request",
",",
"response",
",",
"key",
",",
"value",
")",
":",
"request",
".",
"session",
"[",
"key",
"]",
"=",
"value",
"response",
".",
"set_cookie",
"(",
"key",
",",
"value",
",",
"expires",
"=",
"one_year_from_now",
... | Sets value of key `key` to `value` in both session and cookies. | [
"Sets",
"value",
"of",
"key",
"key",
"to",
"value",
"in",
"both",
"session",
"and",
"cookies",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/functions.py#L96-L100 | train |
openstack/horizon | horizon/utils/functions.py | next_key | def next_key(tuple_of_tuples, key):
"""Returns the key which comes after the given key.
It processes a tuple of 2-element tuples and returns the key which comes
after the given key.
"""
for i, t in enumerate(tuple_of_tuples):
if t[0] == key:
try:
return tuple_of_... | python | def next_key(tuple_of_tuples, key):
"""Returns the key which comes after the given key.
It processes a tuple of 2-element tuples and returns the key which comes
after the given key.
"""
for i, t in enumerate(tuple_of_tuples):
if t[0] == key:
try:
return tuple_of_... | [
"def",
"next_key",
"(",
"tuple_of_tuples",
",",
"key",
")",
":",
"for",
"i",
",",
"t",
"in",
"enumerate",
"(",
"tuple_of_tuples",
")",
":",
"if",
"t",
"[",
"0",
"]",
"==",
"key",
":",
"try",
":",
"return",
"tuple_of_tuples",
"[",
"i",
"+",
"1",
"]"... | Returns the key which comes after the given key.
It processes a tuple of 2-element tuples and returns the key which comes
after the given key. | [
"Returns",
"the",
"key",
"which",
"comes",
"after",
"the",
"given",
"key",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/functions.py#L151-L162 | train |
openstack/horizon | horizon/utils/functions.py | previous_key | def previous_key(tuple_of_tuples, key):
"""Returns the key which comes before the give key.
It Processes a tuple of 2-element tuples and returns the key which comes
before the given key.
"""
for i, t in enumerate(tuple_of_tuples):
if t[0] == key:
try:
return tupl... | python | def previous_key(tuple_of_tuples, key):
"""Returns the key which comes before the give key.
It Processes a tuple of 2-element tuples and returns the key which comes
before the given key.
"""
for i, t in enumerate(tuple_of_tuples):
if t[0] == key:
try:
return tupl... | [
"def",
"previous_key",
"(",
"tuple_of_tuples",
",",
"key",
")",
":",
"for",
"i",
",",
"t",
"in",
"enumerate",
"(",
"tuple_of_tuples",
")",
":",
"if",
"t",
"[",
"0",
"]",
"==",
"key",
":",
"try",
":",
"return",
"tuple_of_tuples",
"[",
"i",
"-",
"1",
... | Returns the key which comes before the give key.
It Processes a tuple of 2-element tuples and returns the key which comes
before the given key. | [
"Returns",
"the",
"key",
"which",
"comes",
"before",
"the",
"give",
"key",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/functions.py#L165-L176 | train |
openstack/horizon | horizon/utils/functions.py | format_value | def format_value(value):
"""Returns the given value rounded to one decimal place if deciaml.
Returns the integer if an integer is given.
"""
value = decimal.Decimal(str(value))
if int(value) == value:
return int(value)
# On Python 3, an explicit cast to float is required
return flo... | python | def format_value(value):
"""Returns the given value rounded to one decimal place if deciaml.
Returns the integer if an integer is given.
"""
value = decimal.Decimal(str(value))
if int(value) == value:
return int(value)
# On Python 3, an explicit cast to float is required
return flo... | [
"def",
"format_value",
"(",
"value",
")",
":",
"value",
"=",
"decimal",
".",
"Decimal",
"(",
"str",
"(",
"value",
")",
")",
"if",
"int",
"(",
"value",
")",
"==",
"value",
":",
"return",
"int",
"(",
"value",
")",
"# On Python 3, an explicit cast to float is... | Returns the given value rounded to one decimal place if deciaml.
Returns the integer if an integer is given. | [
"Returns",
"the",
"given",
"value",
"rounded",
"to",
"one",
"decimal",
"place",
"if",
"deciaml",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/functions.py#L179-L189 | train |
openstack/horizon | horizon/middleware/base.py | HorizonMiddleware.process_exception | def process_exception(self, request, exception):
"""Catches internal Horizon exception classes.
Exception classes such as NotAuthorized, NotFound and Http302
are caught and handles them gracefully.
"""
if isinstance(exception, (exceptions.NotAuthorized,
... | python | def process_exception(self, request, exception):
"""Catches internal Horizon exception classes.
Exception classes such as NotAuthorized, NotFound and Http302
are caught and handles them gracefully.
"""
if isinstance(exception, (exceptions.NotAuthorized,
... | [
"def",
"process_exception",
"(",
"self",
",",
"request",
",",
"exception",
")",
":",
"if",
"isinstance",
"(",
"exception",
",",
"(",
"exceptions",
".",
"NotAuthorized",
",",
"exceptions",
".",
"NotAuthenticated",
")",
")",
":",
"auth_url",
"=",
"settings",
"... | Catches internal Horizon exception classes.
Exception classes such as NotAuthorized, NotFound and Http302
are caught and handles them gracefully. | [
"Catches",
"internal",
"Horizon",
"exception",
"classes",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/middleware/base.py#L123-L159 | train |
openstack/horizon | horizon/middleware/base.py | HorizonMiddleware._process_response | def _process_response(self, request, response):
"""Convert HttpResponseRedirect to HttpResponse if request is via ajax.
This is to allow ajax request to redirect url.
"""
if request.is_ajax() and hasattr(request, 'horizon'):
queued_msgs = request.horizon['async_messages']
... | python | def _process_response(self, request, response):
"""Convert HttpResponseRedirect to HttpResponse if request is via ajax.
This is to allow ajax request to redirect url.
"""
if request.is_ajax() and hasattr(request, 'horizon'):
queued_msgs = request.horizon['async_messages']
... | [
"def",
"_process_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"request",
".",
"is_ajax",
"(",
")",
"and",
"hasattr",
"(",
"request",
",",
"'horizon'",
")",
":",
"queued_msgs",
"=",
"request",
".",
"horizon",
"[",
"'async_message... | Convert HttpResponseRedirect to HttpResponse if request is via ajax.
This is to allow ajax request to redirect url. | [
"Convert",
"HttpResponseRedirect",
"to",
"HttpResponse",
"if",
"request",
"is",
"via",
"ajax",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/middleware/base.py#L166-L214 | train |
openstack/horizon | openstack_dashboard/utils/identity.py | get_domain_id_for_operation | def get_domain_id_for_operation(request):
"""Get the ID of the domain in which the current operation should happen.
If the user has a domain context set, use that, otherwise use the user's
effective domain.
"""
domain_context = request.session.get('domain_context')
if domain_context:
r... | python | def get_domain_id_for_operation(request):
"""Get the ID of the domain in which the current operation should happen.
If the user has a domain context set, use that, otherwise use the user's
effective domain.
"""
domain_context = request.session.get('domain_context')
if domain_context:
r... | [
"def",
"get_domain_id_for_operation",
"(",
"request",
")",
":",
"domain_context",
"=",
"request",
".",
"session",
".",
"get",
"(",
"'domain_context'",
")",
"if",
"domain_context",
":",
"return",
"domain_context",
"return",
"api",
".",
"keystone",
".",
"get_effecti... | Get the ID of the domain in which the current operation should happen.
If the user has a domain context set, use that, otherwise use the user's
effective domain. | [
"Get",
"the",
"ID",
"of",
"the",
"domain",
"in",
"which",
"the",
"current",
"operation",
"should",
"happen",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/utils/identity.py#L18-L28 | train |
openstack/horizon | openstack_dashboard/management/commands/migrate_settings.py | get_module_path | def get_module_path(module_name):
"""Gets the module path without importing anything.
Avoids conflicts with package dependencies.
(taken from http://github.com/sitkatech/pypatch)
"""
path = sys.path
for name in module_name.split('.'):
file_pointer, path, desc = imp.find_module(name, pat... | python | def get_module_path(module_name):
"""Gets the module path without importing anything.
Avoids conflicts with package dependencies.
(taken from http://github.com/sitkatech/pypatch)
"""
path = sys.path
for name in module_name.split('.'):
file_pointer, path, desc = imp.find_module(name, pat... | [
"def",
"get_module_path",
"(",
"module_name",
")",
":",
"path",
"=",
"sys",
".",
"path",
"for",
"name",
"in",
"module_name",
".",
"split",
"(",
"'.'",
")",
":",
"file_pointer",
",",
"path",
",",
"desc",
"=",
"imp",
".",
"find_module",
"(",
"name",
",",... | Gets the module path without importing anything.
Avoids conflicts with package dependencies.
(taken from http://github.com/sitkatech/pypatch) | [
"Gets",
"the",
"module",
"path",
"without",
"importing",
"anything",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/management/commands/migrate_settings.py#L31-L44 | train |
openstack/horizon | openstack_dashboard/management/commands/migrate_settings.py | Command.gendiff | def gendiff(self, force=False):
"""Generate a diff between self.local_settings and the example file.
"""
with DirContext(self.local_settings_dir) as dircontext:
if not os.path.exists(self.local_settings_diff) or force:
with open(self.local_settings_example, 'r') as ... | python | def gendiff(self, force=False):
"""Generate a diff between self.local_settings and the example file.
"""
with DirContext(self.local_settings_dir) as dircontext:
if not os.path.exists(self.local_settings_diff) or force:
with open(self.local_settings_example, 'r') as ... | [
"def",
"gendiff",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"with",
"DirContext",
"(",
"self",
".",
"local_settings_dir",
")",
"as",
"dircontext",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"local_settings_diff",
")",
... | Generate a diff between self.local_settings and the example file. | [
"Generate",
"a",
"diff",
"between",
"self",
".",
"local_settings",
"and",
"the",
"example",
"file",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/management/commands/migrate_settings.py#L120-L162 | train |
openstack/horizon | openstack_dashboard/management/commands/migrate_settings.py | Command.patch | def patch(self, force=False):
"""Patch local_settings.py.example with local_settings.diff.
The patch application generates the local_settings.py file (the
local_settings.py.example remains unchanged).
http://github.com/sitkatech/pypatch fails if the
local_settings.py.example fi... | python | def patch(self, force=False):
"""Patch local_settings.py.example with local_settings.diff.
The patch application generates the local_settings.py file (the
local_settings.py.example remains unchanged).
http://github.com/sitkatech/pypatch fails if the
local_settings.py.example fi... | [
"def",
"patch",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"with",
"DirContext",
"(",
"self",
".",
"local_settings_dir",
")",
"as",
"dircontext",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"local_settings_diff",
")",
":",
"i... | Patch local_settings.py.example with local_settings.diff.
The patch application generates the local_settings.py file (the
local_settings.py.example remains unchanged).
http://github.com/sitkatech/pypatch fails if the
local_settings.py.example file is not 100% identical to the one used ... | [
"Patch",
"local_settings",
".",
"py",
".",
"example",
"with",
"local_settings",
".",
"diff",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/management/commands/migrate_settings.py#L164-L220 | train |
openstack/horizon | openstack_dashboard/policy.py | check | def check(actions, request, target=None):
"""Wrapper of the configurable policy method."""
policy_check = utils_settings.import_setting("POLICY_CHECK_FUNCTION")
if policy_check:
return policy_check(actions, request, target)
return True | python | def check(actions, request, target=None):
"""Wrapper of the configurable policy method."""
policy_check = utils_settings.import_setting("POLICY_CHECK_FUNCTION")
if policy_check:
return policy_check(actions, request, target)
return True | [
"def",
"check",
"(",
"actions",
",",
"request",
",",
"target",
"=",
"None",
")",
":",
"policy_check",
"=",
"utils_settings",
".",
"import_setting",
"(",
"\"POLICY_CHECK_FUNCTION\"",
")",
"if",
"policy_check",
":",
"return",
"policy_check",
"(",
"actions",
",",
... | Wrapper of the configurable policy method. | [
"Wrapper",
"of",
"the",
"configurable",
"policy",
"method",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/policy.py#L18-L26 | train |
openstack/horizon | openstack_dashboard/api/_nova.py | get_auth_params_from_request | def get_auth_params_from_request(request):
"""Extracts properties needed by novaclient call from the request object.
These will be used to memoize the calls to novaclient.
"""
return (
request.user.username,
request.user.token.id,
request.user.tenant_id,
request.user.tok... | python | def get_auth_params_from_request(request):
"""Extracts properties needed by novaclient call from the request object.
These will be used to memoize the calls to novaclient.
"""
return (
request.user.username,
request.user.token.id,
request.user.tenant_id,
request.user.tok... | [
"def",
"get_auth_params_from_request",
"(",
"request",
")",
":",
"return",
"(",
"request",
".",
"user",
".",
"username",
",",
"request",
".",
"user",
".",
"token",
".",
"id",
",",
"request",
".",
"user",
".",
"tenant_id",
",",
"request",
".",
"user",
"."... | Extracts properties needed by novaclient call from the request object.
These will be used to memoize the calls to novaclient. | [
"Extracts",
"properties",
"needed",
"by",
"novaclient",
"call",
"from",
"the",
"request",
"object",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/_nova.py#L99-L111 | train |
openstack/horizon | openstack_dashboard/dashboards/project/network_topology/utils.py | get_context | def get_context(request, context=None):
"""Returns common context data for network topology views."""
if context is None:
context = {}
network_config = getattr(settings, 'OPENSTACK_NEUTRON_NETWORK', {})
context['launch_instance_allowed'] = policy.check(
(("compute", "os_compute_api:ser... | python | def get_context(request, context=None):
"""Returns common context data for network topology views."""
if context is None:
context = {}
network_config = getattr(settings, 'OPENSTACK_NEUTRON_NETWORK', {})
context['launch_instance_allowed'] = policy.check(
(("compute", "os_compute_api:ser... | [
"def",
"get_context",
"(",
"request",
",",
"context",
"=",
"None",
")",
":",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"{",
"}",
"network_config",
"=",
"getattr",
"(",
"settings",
",",
"'OPENSTACK_NEUTRON_NETWORK'",
",",
"{",
"}",
")",
"context",... | Returns common context data for network topology views. | [
"Returns",
"common",
"context",
"data",
"for",
"network",
"topology",
"views",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/network_topology/utils.py#L26-L50 | train |
openstack/horizon | openstack_dashboard/dashboards/identity/users/role_assignments/tables.py | RoleAssignmentsTable.get_object_id | def get_object_id(self, datum):
"""Identifier of the role assignment."""
# Role assignment doesn't have identifier so one will be created
# from the identifier of scope, user and role. This will guaranty the
# unicity.
scope_id = ""
if "project" in datum.scope:
... | python | def get_object_id(self, datum):
"""Identifier of the role assignment."""
# Role assignment doesn't have identifier so one will be created
# from the identifier of scope, user and role. This will guaranty the
# unicity.
scope_id = ""
if "project" in datum.scope:
... | [
"def",
"get_object_id",
"(",
"self",
",",
"datum",
")",
":",
"# Role assignment doesn't have identifier so one will be created",
"# from the identifier of scope, user and role. This will guaranty the",
"# unicity.",
"scope_id",
"=",
"\"\"",
"if",
"\"project\"",
"in",
"datum",
"."... | Identifier of the role assignment. | [
"Identifier",
"of",
"the",
"role",
"assignment",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/identity/users/role_assignments/tables.py#L85-L103 | train |
openstack/horizon | openstack_dashboard/api/base.py | get_url_for_service | def get_url_for_service(service, region, endpoint_type):
if 'type' not in service:
return None
identity_version = get_version_from_service(service)
service_endpoints = service.get('endpoints', [])
available_endpoints = [endpoint for endpoint in service_endpoints
if re... | python | def get_url_for_service(service, region, endpoint_type):
if 'type' not in service:
return None
identity_version = get_version_from_service(service)
service_endpoints = service.get('endpoints', [])
available_endpoints = [endpoint for endpoint in service_endpoints
if re... | [
"def",
"get_url_for_service",
"(",
"service",
",",
"region",
",",
"endpoint_type",
")",
":",
"if",
"'type'",
"not",
"in",
"service",
":",
"return",
"None",
"identity_version",
"=",
"get_version_from_service",
"(",
"service",
")",
"service_endpoints",
"=",
"service... | if we are dealing with the identity service and there is no endpoint
in the current region, it is okay to use the first endpoint for any
identity service endpoints and we can assume that it is global | [
"if",
"we",
"are",
"dealing",
"with",
"the",
"identity",
"service",
"and",
"there",
"is",
"no",
"endpoint",
"in",
"the",
"current",
"region",
"it",
"is",
"okay",
"to",
"use",
"the",
"first",
"endpoint",
"for",
"any",
"identity",
"service",
"endpoints",
"an... | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/base.py#L295-L323 | train |
openstack/horizon | horizon/utils/units.py | is_larger | def is_larger(unit_1, unit_2):
"""Returns a boolean indicating whether unit_1 is larger than unit_2.
E.g:
>>> is_larger('KB', 'B')
True
>>> is_larger('min', 'day')
False
"""
unit_1 = functions.value_for_key(INFORMATION_UNITS, unit_1)
unit_2 = functions.value_for_key(INFORMATION_UNI... | python | def is_larger(unit_1, unit_2):
"""Returns a boolean indicating whether unit_1 is larger than unit_2.
E.g:
>>> is_larger('KB', 'B')
True
>>> is_larger('min', 'day')
False
"""
unit_1 = functions.value_for_key(INFORMATION_UNITS, unit_1)
unit_2 = functions.value_for_key(INFORMATION_UNI... | [
"def",
"is_larger",
"(",
"unit_1",
",",
"unit_2",
")",
":",
"unit_1",
"=",
"functions",
".",
"value_for_key",
"(",
"INFORMATION_UNITS",
",",
"unit_1",
")",
"unit_2",
"=",
"functions",
".",
"value_for_key",
"(",
"INFORMATION_UNITS",
",",
"unit_2",
")",
"return"... | Returns a boolean indicating whether unit_1 is larger than unit_2.
E.g:
>>> is_larger('KB', 'B')
True
>>> is_larger('min', 'day')
False | [
"Returns",
"a",
"boolean",
"indicating",
"whether",
"unit_1",
"is",
"larger",
"than",
"unit_2",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/units.py#L40-L53 | train |
openstack/horizon | horizon/utils/units.py | convert | def convert(value, source_unit, target_unit, fmt=False):
"""Converts value from source_unit to target_unit.
Returns a tuple containing the converted value and target_unit.
Having fmt set to True causes the value to be formatted to 1 decimal digit
if it's a decimal or be formatted as integer if it's an ... | python | def convert(value, source_unit, target_unit, fmt=False):
"""Converts value from source_unit to target_unit.
Returns a tuple containing the converted value and target_unit.
Having fmt set to True causes the value to be formatted to 1 decimal digit
if it's a decimal or be formatted as integer if it's an ... | [
"def",
"convert",
"(",
"value",
",",
"source_unit",
",",
"target_unit",
",",
"fmt",
"=",
"False",
")",
":",
"orig_target_unit",
"=",
"target_unit",
"source_unit",
"=",
"functions",
".",
"value_for_key",
"(",
"INFORMATION_UNITS",
",",
"source_unit",
")",
"target_... | Converts value from source_unit to target_unit.
Returns a tuple containing the converted value and target_unit.
Having fmt set to True causes the value to be formatted to 1 decimal digit
if it's a decimal or be formatted as integer if it's an integer.
E.g:
>>> convert(2, 'hr', 'min')
(120.0, ... | [
"Converts",
"value",
"from",
"source_unit",
"to",
"target_unit",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/units.py#L56-L79 | train |
openstack/horizon | horizon/utils/units.py | normalize | def normalize(value, unit):
"""Converts the value so that it belongs to some expected range.
Returns the new value and new unit.
E.g:
>>> normalize(1024, 'KB')
(1, 'MB')
>>> normalize(90, 'min')
(1.5, 'hr')
>>> normalize(1.0, 'object')
(1, 'object')
"""
if value < 0:
... | python | def normalize(value, unit):
"""Converts the value so that it belongs to some expected range.
Returns the new value and new unit.
E.g:
>>> normalize(1024, 'KB')
(1, 'MB')
>>> normalize(90, 'min')
(1.5, 'hr')
>>> normalize(1.0, 'object')
(1, 'object')
"""
if value < 0:
... | [
"def",
"normalize",
"(",
"value",
",",
"unit",
")",
":",
"if",
"value",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'Negative value: %s %s.'",
"%",
"(",
"value",
",",
"unit",
")",
")",
"if",
"unit",
"in",
"functions",
".",
"get_keys",
"(",
"INFORMATION_U... | Converts the value so that it belongs to some expected range.
Returns the new value and new unit.
E.g:
>>> normalize(1024, 'KB')
(1, 'MB')
>>> normalize(90, 'min')
(1.5, 'hr')
>>> normalize(1.0, 'object')
(1, 'object') | [
"Converts",
"the",
"value",
"so",
"that",
"it",
"belongs",
"to",
"some",
"expected",
"range",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/units.py#L82-L105 | train |
openstack/horizon | openstack_dashboard/api/rest/utils.py | ajax | def ajax(authenticated=True, data_required=False,
json_encoder=json.JSONEncoder):
"""Decorator to allow the wrappered view to exist in an AJAX environment.
Provide a decorator to wrap a view method so that it may exist in an
entirely AJAX environment:
- data decoded from JSON as input and dat... | python | def ajax(authenticated=True, data_required=False,
json_encoder=json.JSONEncoder):
"""Decorator to allow the wrappered view to exist in an AJAX environment.
Provide a decorator to wrap a view method so that it may exist in an
entirely AJAX environment:
- data decoded from JSON as input and dat... | [
"def",
"ajax",
"(",
"authenticated",
"=",
"True",
",",
"data_required",
"=",
"False",
",",
"json_encoder",
"=",
"json",
".",
"JSONEncoder",
")",
":",
"def",
"decorator",
"(",
"function",
",",
"authenticated",
"=",
"authenticated",
",",
"data_required",
"=",
... | Decorator to allow the wrappered view to exist in an AJAX environment.
Provide a decorator to wrap a view method so that it may exist in an
entirely AJAX environment:
- data decoded from JSON as input and data coded as JSON as output
- result status is coded in the HTTP status code; any non-2xx respon... | [
"Decorator",
"to",
"allow",
"the",
"wrappered",
"view",
"to",
"exist",
"in",
"an",
"AJAX",
"environment",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/rest/utils.py#L76-L149 | train |
openstack/horizon | openstack_dashboard/api/rest/utils.py | parse_filters_kwargs | def parse_filters_kwargs(request, client_keywords=None):
"""Extract REST filter parameters from the request GET args.
Client processes some keywords separately from filters and takes
them as separate inputs. This will ignore those keys to avoid
potential conflicts.
"""
filters = {}
kwargs =... | python | def parse_filters_kwargs(request, client_keywords=None):
"""Extract REST filter parameters from the request GET args.
Client processes some keywords separately from filters and takes
them as separate inputs. This will ignore those keys to avoid
potential conflicts.
"""
filters = {}
kwargs =... | [
"def",
"parse_filters_kwargs",
"(",
"request",
",",
"client_keywords",
"=",
"None",
")",
":",
"filters",
"=",
"{",
"}",
"kwargs",
"=",
"{",
"}",
"client_keywords",
"=",
"client_keywords",
"or",
"{",
"}",
"for",
"param",
"in",
"request",
".",
"GET",
":",
... | Extract REST filter parameters from the request GET args.
Client processes some keywords separately from filters and takes
them as separate inputs. This will ignore those keys to avoid
potential conflicts. | [
"Extract",
"REST",
"filter",
"parameters",
"from",
"the",
"request",
"GET",
"args",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/rest/utils.py#L159-L175 | train |
openstack/horizon | openstack_dashboard/api/rest/utils.py | post2data | def post2data(func):
"""Decorator to restore original form values along with their types.
The sole purpose of this decorator is to restore original form values
along with their types stored on client-side under key $$originalJSON.
This in turn prevents the loss of field types when they are passed with
... | python | def post2data(func):
"""Decorator to restore original form values along with their types.
The sole purpose of this decorator is to restore original form values
along with their types stored on client-side under key $$originalJSON.
This in turn prevents the loss of field types when they are passed with
... | [
"def",
"post2data",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"self",
",",
"request",
")",
":",
"request",
".",
"DATA",
"=",
"request",
".",
"POST",
"if",
"'$$originalJSON'",
"in",
"request",
".",
"POST",
":",
"request",
".",
"DATA",
"=",
"jsonutil... | Decorator to restore original form values along with their types.
The sole purpose of this decorator is to restore original form values
along with their types stored on client-side under key $$originalJSON.
This in turn prevents the loss of field types when they are passed with
header 'Content-Type: mu... | [
"Decorator",
"to",
"restore",
"original",
"form",
"values",
"along",
"with",
"their",
"types",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/rest/utils.py#L178-L194 | train |
openstack/horizon | horizon/workflows/views.py | WorkflowView.get_workflow | def get_workflow(self):
"""Returns the instantiated workflow class."""
extra_context = self.get_initial()
entry_point = self.request.GET.get("step", None)
workflow = self.workflow_class(self.request,
context_seed=extra_context,
... | python | def get_workflow(self):
"""Returns the instantiated workflow class."""
extra_context = self.get_initial()
entry_point = self.request.GET.get("step", None)
workflow = self.workflow_class(self.request,
context_seed=extra_context,
... | [
"def",
"get_workflow",
"(",
"self",
")",
":",
"extra_context",
"=",
"self",
".",
"get_initial",
"(",
")",
"entry_point",
"=",
"self",
".",
"request",
".",
"GET",
".",
"get",
"(",
"\"step\"",
",",
"None",
")",
"workflow",
"=",
"self",
".",
"workflow_class... | Returns the instantiated workflow class. | [
"Returns",
"the",
"instantiated",
"workflow",
"class",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/workflows/views.py#L76-L83 | train |
openstack/horizon | horizon/workflows/views.py | WorkflowView.get_context_data | def get_context_data(self, **kwargs):
"""Returns the template context, including the workflow class.
This method should be overridden in subclasses to provide additional
context data to the template.
"""
context = super(WorkflowView, self).get_context_data(**kwargs)
work... | python | def get_context_data(self, **kwargs):
"""Returns the template context, including the workflow class.
This method should be overridden in subclasses to provide additional
context data to the template.
"""
context = super(WorkflowView, self).get_context_data(**kwargs)
work... | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"super",
"(",
"WorkflowView",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"workflow",
"=",
"self",
".",
"get_workflow",
"(",
")",
"w... | Returns the template context, including the workflow class.
This method should be overridden in subclasses to provide additional
context data to the template. | [
"Returns",
"the",
"template",
"context",
"including",
"the",
"workflow",
"class",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/workflows/views.py#L85-L103 | train |
openstack/horizon | horizon/workflows/views.py | WorkflowView.get_layout | def get_layout(self):
"""Returns classes for the workflow element in template.
The returned classes are determied based on
the workflow characteristics.
"""
if self.request.is_ajax():
layout = ['modal', ]
else:
layout = ['static_page', ]
... | python | def get_layout(self):
"""Returns classes for the workflow element in template.
The returned classes are determied based on
the workflow characteristics.
"""
if self.request.is_ajax():
layout = ['modal', ]
else:
layout = ['static_page', ]
... | [
"def",
"get_layout",
"(",
"self",
")",
":",
"if",
"self",
".",
"request",
".",
"is_ajax",
"(",
")",
":",
"layout",
"=",
"[",
"'modal'",
",",
"]",
"else",
":",
"layout",
"=",
"[",
"'static_page'",
",",
"]",
"if",
"self",
".",
"workflow_class",
".",
... | Returns classes for the workflow element in template.
The returned classes are determied based on
the workflow characteristics. | [
"Returns",
"classes",
"for",
"the",
"workflow",
"element",
"in",
"template",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/workflows/views.py#L105-L119 | train |
openstack/horizon | horizon/workflows/views.py | WorkflowView.get_template_names | def get_template_names(self):
"""Returns the template name to use for this request."""
if self.request.is_ajax():
template = self.ajax_template_name
else:
template = self.template_name
return template | python | def get_template_names(self):
"""Returns the template name to use for this request."""
if self.request.is_ajax():
template = self.ajax_template_name
else:
template = self.template_name
return template | [
"def",
"get_template_names",
"(",
"self",
")",
":",
"if",
"self",
".",
"request",
".",
"is_ajax",
"(",
")",
":",
"template",
"=",
"self",
".",
"ajax_template_name",
"else",
":",
"template",
"=",
"self",
".",
"template_name",
"return",
"template"
] | Returns the template name to use for this request. | [
"Returns",
"the",
"template",
"name",
"to",
"use",
"for",
"this",
"request",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/workflows/views.py#L121-L127 | train |
openstack/horizon | horizon/workflows/views.py | WorkflowView.get | def get(self, request, *args, **kwargs):
"""Handler for HTTP GET requests."""
try:
context = self.get_context_data(**kwargs)
except exceptions.NotAvailable:
exceptions.handle(request)
self.set_workflow_step_errors(context)
return self.render_to_response(co... | python | def get(self, request, *args, **kwargs):
"""Handler for HTTP GET requests."""
try:
context = self.get_context_data(**kwargs)
except exceptions.NotAvailable:
exceptions.handle(request)
self.set_workflow_step_errors(context)
return self.render_to_response(co... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"context",
"=",
"self",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"except",
"exceptions",
".",
"NotAvailable",
":",
"exceptions",
... | Handler for HTTP GET requests. | [
"Handler",
"for",
"HTTP",
"GET",
"requests",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/workflows/views.py#L144-L151 | train |
openstack/horizon | horizon/workflows/views.py | WorkflowView.validate_steps | def validate_steps(self, request, workflow, start, end):
"""Validates the workflow steps from ``start`` to ``end``, inclusive.
Returns a dict describing the validation state of the workflow.
"""
errors = {}
for step in workflow.steps[start:end + 1]:
if not step.actio... | python | def validate_steps(self, request, workflow, start, end):
"""Validates the workflow steps from ``start`` to ``end``, inclusive.
Returns a dict describing the validation state of the workflow.
"""
errors = {}
for step in workflow.steps[start:end + 1]:
if not step.actio... | [
"def",
"validate_steps",
"(",
"self",
",",
"request",
",",
"workflow",
",",
"start",
",",
"end",
")",
":",
"errors",
"=",
"{",
"}",
"for",
"step",
"in",
"workflow",
".",
"steps",
"[",
"start",
":",
"end",
"+",
"1",
"]",
":",
"if",
"not",
"step",
... | Validates the workflow steps from ``start`` to ``end``, inclusive.
Returns a dict describing the validation state of the workflow. | [
"Validates",
"the",
"workflow",
"steps",
"from",
"start",
"to",
"end",
"inclusive",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/workflows/views.py#L153-L168 | train |
openstack/horizon | horizon/workflows/views.py | WorkflowView.post | def post(self, request, *args, **kwargs):
"""Handler for HTTP POST requests."""
context = self.get_context_data(**kwargs)
workflow = context[self.context_object_name]
try:
# Check for the VALIDATE_STEP* headers, if they are present
# and valid integers, return val... | python | def post(self, request, *args, **kwargs):
"""Handler for HTTP POST requests."""
context = self.get_context_data(**kwargs)
workflow = context[self.context_object_name]
try:
# Check for the VALIDATE_STEP* headers, if they are present
# and valid integers, return val... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"self",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"workflow",
"=",
"context",
"[",
"self",
".",
"context_object_name",
"]",
... | Handler for HTTP POST requests. | [
"Handler",
"for",
"HTTP",
"POST",
"requests",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/workflows/views.py#L170-L219 | train |
openstack/horizon | horizon/templatetags/angular.py | update_angular_template_hash | def update_angular_template_hash(sender, **kwargs):
"""Listen for compress events.
If the angular templates have been re-compressed, also clear them
from the Django cache backend. This is important to allow
deployers to change a template file, re-compress, and not
accidentally serve the old Django... | python | def update_angular_template_hash(sender, **kwargs):
"""Listen for compress events.
If the angular templates have been re-compressed, also clear them
from the Django cache backend. This is important to allow
deployers to change a template file, re-compress, and not
accidentally serve the old Django... | [
"def",
"update_angular_template_hash",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"kwargs",
"[",
"'context'",
"]",
"# context the compressor is working with",
"compressed",
"=",
"context",
"[",
"'compressed'",
"]",
"# the compressed content",
"c... | Listen for compress events.
If the angular templates have been re-compressed, also clear them
from the Django cache backend. This is important to allow
deployers to change a template file, re-compress, and not
accidentally serve the old Django cached version of that content
to clients. | [
"Listen",
"for",
"compress",
"events",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/templatetags/angular.py#L28-L55 | train |
openstack/horizon | horizon/templatetags/angular.py | angular_templates | def angular_templates(context):
"""Generate a dictionary of template contents for all static HTML templates.
If the template has been overridden by a theme, load the
override contents instead of the original HTML file.
One use for this is to pre-populate the angular template cache.
Args:
c... | python | def angular_templates(context):
"""Generate a dictionary of template contents for all static HTML templates.
If the template has been overridden by a theme, load the
override contents instead of the original HTML file.
One use for this is to pre-populate the angular template cache.
Args:
c... | [
"def",
"angular_templates",
"(",
"context",
")",
":",
"template_paths",
"=",
"context",
"[",
"'HORIZON_CONFIG'",
"]",
"[",
"'external_templates'",
"]",
"all_theme_static_files",
"=",
"context",
"[",
"'HORIZON_CONFIG'",
"]",
"[",
"'theme_static_files'",
"]",
"this_them... | Generate a dictionary of template contents for all static HTML templates.
If the template has been overridden by a theme, load the
override contents instead of the original HTML file.
One use for this is to pre-populate the angular template cache.
Args:
context: the context of the current Djan... | [
"Generate",
"a",
"dictionary",
"of",
"template",
"contents",
"for",
"all",
"static",
"HTML",
"templates",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/templatetags/angular.py#L81-L135 | train |
openstack/horizon | openstack_dashboard/api/microversions.py | get_microversion_for_features | def get_microversion_for_features(service, features, wrapper_class,
min_ver, max_ver):
"""Retrieves that highest known functional microversion for features"""
feature_versions = get_requested_versions(service, features)
if not feature_versions:
return None
for ... | python | def get_microversion_for_features(service, features, wrapper_class,
min_ver, max_ver):
"""Retrieves that highest known functional microversion for features"""
feature_versions = get_requested_versions(service, features)
if not feature_versions:
return None
for ... | [
"def",
"get_microversion_for_features",
"(",
"service",
",",
"features",
",",
"wrapper_class",
",",
"min_ver",
",",
"max_ver",
")",
":",
"feature_versions",
"=",
"get_requested_versions",
"(",
"service",
",",
"features",
")",
"if",
"not",
"feature_versions",
":",
... | Retrieves that highest known functional microversion for features | [
"Retrieves",
"that",
"highest",
"known",
"functional",
"microversion",
"for",
"features"
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/microversions.py#L85-L96 | train |
openstack/horizon | horizon/base.py | Registry._register | def _register(self, cls):
"""Registers the given class.
If the specified class is already registered then it is ignored.
"""
if not inspect.isclass(cls):
raise ValueError('Only classes may be registered.')
elif not issubclass(cls, self._registerable_class):
... | python | def _register(self, cls):
"""Registers the given class.
If the specified class is already registered then it is ignored.
"""
if not inspect.isclass(cls):
raise ValueError('Only classes may be registered.')
elif not issubclass(cls, self._registerable_class):
... | [
"def",
"_register",
"(",
"self",
",",
"cls",
")",
":",
"if",
"not",
"inspect",
".",
"isclass",
"(",
"cls",
")",
":",
"raise",
"ValueError",
"(",
"'Only classes may be registered.'",
")",
"elif",
"not",
"issubclass",
"(",
"cls",
",",
"self",
".",
"_register... | Registers the given class.
If the specified class is already registered then it is ignored. | [
"Registers",
"the",
"given",
"class",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L185-L200 | train |
openstack/horizon | horizon/base.py | Registry._unregister | def _unregister(self, cls):
"""Unregisters the given class.
If the specified class isn't registered, ``NotRegistered`` will
be raised.
"""
if not issubclass(cls, self._registerable_class):
raise ValueError('Only %s classes or subclasses may be '
... | python | def _unregister(self, cls):
"""Unregisters the given class.
If the specified class isn't registered, ``NotRegistered`` will
be raised.
"""
if not issubclass(cls, self._registerable_class):
raise ValueError('Only %s classes or subclasses may be '
... | [
"def",
"_unregister",
"(",
"self",
",",
"cls",
")",
":",
"if",
"not",
"issubclass",
"(",
"cls",
",",
"self",
".",
"_registerable_class",
")",
":",
"raise",
"ValueError",
"(",
"'Only %s classes or subclasses may be '",
"'unregistered.'",
"%",
"self",
".",
"_regis... | Unregisters the given class.
If the specified class isn't registered, ``NotRegistered`` will
be raised. | [
"Unregisters",
"the",
"given",
"class",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L202-L217 | train |
openstack/horizon | horizon/base.py | Panel.get_absolute_url | def get_absolute_url(self):
"""Returns the default URL for this panel.
The default URL is defined as the URL pattern with ``name="index"`` in
the URLconf for this panel.
"""
try:
return reverse('horizon:%s:%s:%s' % (self._registered_with.slug,
... | python | def get_absolute_url(self):
"""Returns the default URL for this panel.
The default URL is defined as the URL pattern with ``name="index"`` in
the URLconf for this panel.
"""
try:
return reverse('horizon:%s:%s:%s' % (self._registered_with.slug,
... | [
"def",
"get_absolute_url",
"(",
"self",
")",
":",
"try",
":",
"return",
"reverse",
"(",
"'horizon:%s:%s:%s'",
"%",
"(",
"self",
".",
"_registered_with",
".",
"slug",
",",
"self",
".",
"slug",
",",
"self",
".",
"index_url_name",
")",
")",
"except",
"Excepti... | Returns the default URL for this panel.
The default URL is defined as the URL pattern with ``name="index"`` in
the URLconf for this panel. | [
"Returns",
"the",
"default",
"URL",
"for",
"this",
"panel",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L312-L327 | train |
openstack/horizon | horizon/base.py | Dashboard.get_panels | def get_panels(self):
"""Returns the Panel instances registered with this dashboard in order.
Panel grouping information is not included.
"""
all_panels = []
panel_groups = self.get_panel_groups()
for panel_group in panel_groups.values():
all_panels.extend(pa... | python | def get_panels(self):
"""Returns the Panel instances registered with this dashboard in order.
Panel grouping information is not included.
"""
all_panels = []
panel_groups = self.get_panel_groups()
for panel_group in panel_groups.values():
all_panels.extend(pa... | [
"def",
"get_panels",
"(",
"self",
")",
":",
"all_panels",
"=",
"[",
"]",
"panel_groups",
"=",
"self",
".",
"get_panel_groups",
"(",
")",
"for",
"panel_group",
"in",
"panel_groups",
".",
"values",
"(",
")",
":",
"all_panels",
".",
"extend",
"(",
"panel_grou... | Returns the Panel instances registered with this dashboard in order.
Panel grouping information is not included. | [
"Returns",
"the",
"Panel",
"instances",
"registered",
"with",
"this",
"dashboard",
"in",
"order",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L492-L501 | train |
openstack/horizon | horizon/base.py | Dashboard.get_absolute_url | def get_absolute_url(self):
"""Returns the default URL for this dashboard.
The default URL is defined as the URL pattern with ``name="index"``
in the URLconf for the :class:`~horizon.Panel` specified by
:attr:`~horizon.Dashboard.default_panel`.
"""
try:
retur... | python | def get_absolute_url(self):
"""Returns the default URL for this dashboard.
The default URL is defined as the URL pattern with ``name="index"``
in the URLconf for the :class:`~horizon.Panel` specified by
:attr:`~horizon.Dashboard.default_panel`.
"""
try:
retur... | [
"def",
"get_absolute_url",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_registered",
"(",
"self",
".",
"default_panel",
")",
".",
"get_absolute_url",
"(",
")",
"except",
"Exception",
":",
"# Logging here since this will often be called in a template",
... | Returns the default URL for this dashboard.
The default URL is defined as the URL pattern with ``name="index"``
in the URLconf for the :class:`~horizon.Panel` specified by
:attr:`~horizon.Dashboard.default_panel`. | [
"Returns",
"the",
"default",
"URL",
"for",
"this",
"dashboard",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L531-L544 | train |
openstack/horizon | horizon/base.py | Dashboard._autodiscover | def _autodiscover(self):
"""Discovers panels to register from the current dashboard module."""
if getattr(self, "_autodiscover_complete", False):
return
panels_to_discover = []
panel_groups = []
# If we have a flat iterable of panel names, wrap it again so
# ... | python | def _autodiscover(self):
"""Discovers panels to register from the current dashboard module."""
if getattr(self, "_autodiscover_complete", False):
return
panels_to_discover = []
panel_groups = []
# If we have a flat iterable of panel names, wrap it again so
# ... | [
"def",
"_autodiscover",
"(",
"self",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"\"_autodiscover_complete\"",
",",
"False",
")",
":",
"return",
"panels_to_discover",
"=",
"[",
"]",
"panel_groups",
"=",
"[",
"]",
"# If we have a flat iterable of panel names, wrap i... | Discovers panels to register from the current dashboard module. | [
"Discovers",
"panels",
"to",
"register",
"from",
"the",
"current",
"dashboard",
"module",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L578-L625 | train |
openstack/horizon | horizon/base.py | Dashboard.allowed | def allowed(self, context):
"""Checks for role based access for this dashboard.
Checks for access to any panels in the dashboard and of the
dashboard itself.
This method should be overridden to return the result of
any policy checks required for the user to access this dashboar... | python | def allowed(self, context):
"""Checks for role based access for this dashboard.
Checks for access to any panels in the dashboard and of the
dashboard itself.
This method should be overridden to return the result of
any policy checks required for the user to access this dashboar... | [
"def",
"allowed",
"(",
"self",
",",
"context",
")",
":",
"# if the dashboard has policy rules, honor those above individual",
"# panels",
"if",
"not",
"self",
".",
"_can_access",
"(",
"context",
"[",
"'request'",
"]",
")",
":",
"return",
"False",
"# check if access is... | Checks for role based access for this dashboard.
Checks for access to any panels in the dashboard and of the
dashboard itself.
This method should be overridden to return the result of
any policy checks required for the user to access this dashboard
when more complex checks are ... | [
"Checks",
"for",
"role",
"based",
"access",
"for",
"this",
"dashboard",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L651-L673 | train |
openstack/horizon | horizon/base.py | Site.get_user_home | def get_user_home(self, user):
"""Returns the default URL for a particular user.
This method can be used to customize where a user is sent when
they log in, etc. By default it returns the value of
:meth:`get_absolute_url`.
An alternative function can be supplied to customize th... | python | def get_user_home(self, user):
"""Returns the default URL for a particular user.
This method can be used to customize where a user is sent when
they log in, etc. By default it returns the value of
:meth:`get_absolute_url`.
An alternative function can be supplied to customize th... | [
"def",
"get_user_home",
"(",
"self",
",",
"user",
")",
":",
"user_home",
"=",
"self",
".",
"_conf",
"[",
"'user_home'",
"]",
"if",
"user_home",
":",
"if",
"callable",
"(",
"user_home",
")",
":",
"return",
"user_home",
"(",
"user",
")",
"elif",
"isinstanc... | Returns the default URL for a particular user.
This method can be used to customize where a user is sent when
they log in, etc. By default it returns the value of
:meth:`get_absolute_url`.
An alternative function can be supplied to customize this behavior
by specifying a either... | [
"Returns",
"the",
"default",
"URL",
"for",
"a",
"particular",
"user",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L793-L829 | train |
openstack/horizon | horizon/base.py | Site._lazy_urls | def _lazy_urls(self):
"""Lazy loading for URL patterns.
This method avoids problems associated with attempting to evaluate
the URLconf before the settings module has been loaded.
"""
def url_patterns():
return self._urls()[0]
return LazyURLPattern(url_patter... | python | def _lazy_urls(self):
"""Lazy loading for URL patterns.
This method avoids problems associated with attempting to evaluate
the URLconf before the settings module has been loaded.
"""
def url_patterns():
return self._urls()[0]
return LazyURLPattern(url_patter... | [
"def",
"_lazy_urls",
"(",
"self",
")",
":",
"def",
"url_patterns",
"(",
")",
":",
"return",
"self",
".",
"_urls",
"(",
")",
"[",
"0",
"]",
"return",
"LazyURLPattern",
"(",
"url_patterns",
")",
",",
"self",
".",
"namespace",
",",
"self",
".",
"slug"
] | Lazy loading for URL patterns.
This method avoids problems associated with attempting to evaluate
the URLconf before the settings module has been loaded. | [
"Lazy",
"loading",
"for",
"URL",
"patterns",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L842-L851 | train |
openstack/horizon | horizon/base.py | Site._urls | def _urls(self):
"""Constructs the URLconf for Horizon from registered Dashboards."""
urlpatterns = self._get_default_urlpatterns()
self._autodiscover()
# Discover each dashboard's panels.
for dash in self._registry.values():
dash._autodiscover()
# Load the ... | python | def _urls(self):
"""Constructs the URLconf for Horizon from registered Dashboards."""
urlpatterns = self._get_default_urlpatterns()
self._autodiscover()
# Discover each dashboard's panels.
for dash in self._registry.values():
dash._autodiscover()
# Load the ... | [
"def",
"_urls",
"(",
"self",
")",
":",
"urlpatterns",
"=",
"self",
".",
"_get_default_urlpatterns",
"(",
")",
"self",
".",
"_autodiscover",
"(",
")",
"# Discover each dashboard's panels.",
"for",
"dash",
"in",
"self",
".",
"_registry",
".",
"values",
"(",
")",... | Constructs the URLconf for Horizon from registered Dashboards. | [
"Constructs",
"the",
"URLconf",
"for",
"Horizon",
"from",
"registered",
"Dashboards",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L853-L886 | train |
openstack/horizon | horizon/base.py | Site._autodiscover | def _autodiscover(self):
"""Discovers modules to register from ``settings.INSTALLED_APPS``.
This makes sure that the appropriate modules get imported to register
themselves with Horizon.
"""
if not getattr(self, '_registerable_class', None):
raise ImproperlyConfigure... | python | def _autodiscover(self):
"""Discovers modules to register from ``settings.INSTALLED_APPS``.
This makes sure that the appropriate modules get imported to register
themselves with Horizon.
"""
if not getattr(self, '_registerable_class', None):
raise ImproperlyConfigure... | [
"def",
"_autodiscover",
"(",
"self",
")",
":",
"if",
"not",
"getattr",
"(",
"self",
",",
"'_registerable_class'",
",",
"None",
")",
":",
"raise",
"ImproperlyConfigured",
"(",
"'You must set a '",
"'\"_registerable_class\" property '",
"'in order to use autodiscovery.'",
... | Discovers modules to register from ``settings.INSTALLED_APPS``.
This makes sure that the appropriate modules get imported to register
themselves with Horizon. | [
"Discovers",
"modules",
"to",
"register",
"from",
"settings",
".",
"INSTALLED_APPS",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L888-L908 | train |
openstack/horizon | horizon/base.py | Site._load_panel_customization | def _load_panel_customization(self):
"""Applies the plugin-based panel configurations.
This method parses the panel customization from the ``HORIZON_CONFIG``
and make changes to the dashboard accordingly.
It supports adding, removing and setting default panels on the
dashboard.... | python | def _load_panel_customization(self):
"""Applies the plugin-based panel configurations.
This method parses the panel customization from the ``HORIZON_CONFIG``
and make changes to the dashboard accordingly.
It supports adding, removing and setting default panels on the
dashboard.... | [
"def",
"_load_panel_customization",
"(",
"self",
")",
":",
"panel_customization",
"=",
"self",
".",
"_conf",
".",
"get",
"(",
"\"panel_customization\"",
",",
"[",
"]",
")",
"# Process all the panel groups first so that they exist before panels",
"# are added to them and Dashb... | Applies the plugin-based panel configurations.
This method parses the panel customization from the ``HORIZON_CONFIG``
and make changes to the dashboard accordingly.
It supports adding, removing and setting default panels on the
dashboard. It also support registering a panel group. | [
"Applies",
"the",
"plugin",
"-",
"based",
"panel",
"configurations",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L910-L935 | train |
openstack/horizon | horizon/base.py | Site._process_panel_configuration | def _process_panel_configuration(self, config):
"""Add, remove and set default panels on the dashboard."""
try:
dashboard = config.get('PANEL_DASHBOARD')
if not dashboard:
LOG.warning("Skipping %s because it doesn't have "
"PANEL_DASHBO... | python | def _process_panel_configuration(self, config):
"""Add, remove and set default panels on the dashboard."""
try:
dashboard = config.get('PANEL_DASHBOARD')
if not dashboard:
LOG.warning("Skipping %s because it doesn't have "
"PANEL_DASHBO... | [
"def",
"_process_panel_configuration",
"(",
"self",
",",
"config",
")",
":",
"try",
":",
"dashboard",
"=",
"config",
".",
"get",
"(",
"'PANEL_DASHBOARD'",
")",
"if",
"not",
"dashboard",
":",
"LOG",
".",
"warning",
"(",
"\"Skipping %s because it doesn't have \"",
... | Add, remove and set default panels on the dashboard. | [
"Add",
"remove",
"and",
"set",
"default",
"panels",
"on",
"the",
"dashboard",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L937-L988 | train |
openstack/horizon | horizon/base.py | Site._process_panel_group_configuration | def _process_panel_group_configuration(self, config):
"""Adds a panel group to the dashboard."""
panel_group_slug = config.get('PANEL_GROUP')
try:
dashboard = config.get('PANEL_GROUP_DASHBOARD')
if not dashboard:
LOG.warning("Skipping %s because it doesn't... | python | def _process_panel_group_configuration(self, config):
"""Adds a panel group to the dashboard."""
panel_group_slug = config.get('PANEL_GROUP')
try:
dashboard = config.get('PANEL_GROUP_DASHBOARD')
if not dashboard:
LOG.warning("Skipping %s because it doesn't... | [
"def",
"_process_panel_group_configuration",
"(",
"self",
",",
"config",
")",
":",
"panel_group_slug",
"=",
"config",
".",
"get",
"(",
"'PANEL_GROUP'",
")",
"try",
":",
"dashboard",
"=",
"config",
".",
"get",
"(",
"'PANEL_GROUP_DASHBOARD'",
")",
"if",
"not",
"... | Adds a panel group to the dashboard. | [
"Adds",
"a",
"panel",
"group",
"to",
"the",
"dashboard",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/base.py#L990-L1022 | train |
openstack/horizon | horizon/tables/base.py | Row.load_cells | def load_cells(self, datum=None):
"""Load the row's data and initialize all the cells in the row.
It also set the appropriate row properties which require
the row's data to be determined.
The row's data is provided either at initialization or as an
argument to this function.
... | python | def load_cells(self, datum=None):
"""Load the row's data and initialize all the cells in the row.
It also set the appropriate row properties which require
the row's data to be determined.
The row's data is provided either at initialization or as an
argument to this function.
... | [
"def",
"load_cells",
"(",
"self",
",",
"datum",
"=",
"None",
")",
":",
"# Compile all the cells on instantiation.",
"table",
"=",
"self",
".",
"table",
"if",
"datum",
":",
"self",
".",
"datum",
"=",
"datum",
"else",
":",
"datum",
"=",
"self",
".",
"datum",... | Load the row's data and initialize all the cells in the row.
It also set the appropriate row properties which require
the row's data to be determined.
The row's data is provided either at initialization or as an
argument to this function.
This function is called automatically ... | [
"Load",
"the",
"row",
"s",
"data",
"and",
"initialize",
"all",
"the",
"cells",
"in",
"the",
"row",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/base.py#L595-L645 | train |
openstack/horizon | horizon/tables/base.py | Cell.get_data | def get_data(self, datum, column, row):
"""Fetches the data to be displayed in this cell."""
table = row.table
if column.auto == "multi_select":
data = ""
if row.can_be_selected(datum):
widget = ThemableCheckboxInput(check_test=lambda value: False)
... | python | def get_data(self, datum, column, row):
"""Fetches the data to be displayed in this cell."""
table = row.table
if column.auto == "multi_select":
data = ""
if row.can_be_selected(datum):
widget = ThemableCheckboxInput(check_test=lambda value: False)
... | [
"def",
"get_data",
"(",
"self",
",",
"datum",
",",
"column",
",",
"row",
")",
":",
"table",
"=",
"row",
".",
"table",
"if",
"column",
".",
"auto",
"==",
"\"multi_select\"",
":",
"data",
"=",
"\"\"",
"if",
"row",
".",
"can_be_selected",
"(",
"datum",
... | Fetches the data to be displayed in this cell. | [
"Fetches",
"the",
"data",
"to",
"be",
"displayed",
"in",
"this",
"cell",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/base.py#L743-L789 | train |
openstack/horizon | horizon/tables/base.py | Cell.value | def value(self):
"""Returns a formatted version of the data for final output.
This takes into consideration the
:attr:`~horizon.tables.Column.link`` and
:attr:`~horizon.tables.Column.empty_value`
attributes.
"""
try:
data = self.column.get_data(self.d... | python | def value(self):
"""Returns a formatted version of the data for final output.
This takes into consideration the
:attr:`~horizon.tables.Column.link`` and
:attr:`~horizon.tables.Column.empty_value`
attributes.
"""
try:
data = self.column.get_data(self.d... | [
"def",
"value",
"(",
"self",
")",
":",
"try",
":",
"data",
"=",
"self",
".",
"column",
".",
"get_data",
"(",
"self",
".",
"datum",
")",
"if",
"data",
"is",
"None",
":",
"if",
"callable",
"(",
"self",
".",
"column",
".",
"empty_value",
")",
":",
"... | Returns a formatted version of the data for final output.
This takes into consideration the
:attr:`~horizon.tables.Column.link`` and
:attr:`~horizon.tables.Column.empty_value`
attributes. | [
"Returns",
"a",
"formatted",
"version",
"of",
"the",
"data",
"for",
"final",
"output",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/base.py#L802-L831 | train |
openstack/horizon | horizon/tables/base.py | Cell.status | def status(self):
"""Gets the status for the column based on the cell's data."""
# Deal with status column mechanics based in this cell's data
if hasattr(self, '_status'):
# pylint: disable=access-member-before-definition
return self._status
if self.column.status... | python | def status(self):
"""Gets the status for the column based on the cell's data."""
# Deal with status column mechanics based in this cell's data
if hasattr(self, '_status'):
# pylint: disable=access-member-before-definition
return self._status
if self.column.status... | [
"def",
"status",
"(",
"self",
")",
":",
"# Deal with status column mechanics based in this cell's data",
"if",
"hasattr",
"(",
"self",
",",
"'_status'",
")",
":",
"# pylint: disable=access-member-before-definition",
"return",
"self",
".",
"_status",
"if",
"self",
".",
"... | Gets the status for the column based on the cell's data. | [
"Gets",
"the",
"status",
"for",
"the",
"column",
"based",
"on",
"the",
"cell",
"s",
"data",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/base.py#L843-L860 | train |
openstack/horizon | horizon/tables/base.py | Cell.get_default_classes | def get_default_classes(self):
"""Returns a flattened string of the cell's CSS classes."""
if not self.url:
self.column.classes = [cls for cls in self.column.classes
if cls != "anchor"]
column_class_string = self.column.get_final_attrs().get('class'... | python | def get_default_classes(self):
"""Returns a flattened string of the cell's CSS classes."""
if not self.url:
self.column.classes = [cls for cls in self.column.classes
if cls != "anchor"]
column_class_string = self.column.get_final_attrs().get('class'... | [
"def",
"get_default_classes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"url",
":",
"self",
".",
"column",
".",
"classes",
"=",
"[",
"cls",
"for",
"cls",
"in",
"self",
".",
"column",
".",
"classes",
"if",
"cls",
"!=",
"\"anchor\"",
"]",
"colum... | Returns a flattened string of the cell's CSS classes. | [
"Returns",
"a",
"flattened",
"string",
"of",
"the",
"cell",
"s",
"CSS",
"classes",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/base.py#L871-L884 | train |
openstack/horizon | horizon/tables/base.py | Cell.update_allowed | def update_allowed(self):
"""Determines whether update of given cell is allowed.
Calls allowed action of defined UpdateAction of the Column.
"""
return self.update_action.allowed(self.column.table.request,
self.datum,
... | python | def update_allowed(self):
"""Determines whether update of given cell is allowed.
Calls allowed action of defined UpdateAction of the Column.
"""
return self.update_action.allowed(self.column.table.request,
self.datum,
... | [
"def",
"update_allowed",
"(",
"self",
")",
":",
"return",
"self",
".",
"update_action",
".",
"allowed",
"(",
"self",
".",
"column",
".",
"table",
".",
"request",
",",
"self",
".",
"datum",
",",
"self",
")"
] | Determines whether update of given cell is allowed.
Calls allowed action of defined UpdateAction of the Column. | [
"Determines",
"whether",
"update",
"of",
"given",
"cell",
"is",
"allowed",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/base.py#L899-L906 | train |
openstack/horizon | openstack_dashboard/dashboards/project/instances/console.py | get_console | def get_console(request, console_type, instance):
"""Get a tuple of console url and console type."""
if console_type == 'AUTO':
check_consoles = CONSOLES
else:
try:
check_consoles = {console_type: CONSOLES[console_type]}
except KeyError:
msg = _('Console type ... | python | def get_console(request, console_type, instance):
"""Get a tuple of console url and console type."""
if console_type == 'AUTO':
check_consoles = CONSOLES
else:
try:
check_consoles = {console_type: CONSOLES[console_type]}
except KeyError:
msg = _('Console type ... | [
"def",
"get_console",
"(",
"request",
",",
"console_type",
",",
"instance",
")",
":",
"if",
"console_type",
"==",
"'AUTO'",
":",
"check_consoles",
"=",
"CONSOLES",
"else",
":",
"try",
":",
"check_consoles",
"=",
"{",
"console_type",
":",
"CONSOLES",
"[",
"co... | Get a tuple of console url and console type. | [
"Get",
"a",
"tuple",
"of",
"console",
"url",
"and",
"console",
"type",
"."
] | 5601ea9477323e599d9b766fcac1f8be742935b2 | https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/instances/console.py#L34-L72 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.