id
int32
0
252k
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
221,000
openstack/horizon
openstack_dashboard/usage/quotas.py
QuotaUsage.tally
def tally(self, name, value): """Adds to the "used" metric for the given quota.""" value = value or 0 # Protection against None. # Start at 0 if this is the first value. if 'used' not in self.usages[name]: self.usages[name]['used'] = 0 # Increment our usage and updat...
python
def tally(self, name, value): """Adds to the "used" metric for the given quota.""" value = value or 0 # Protection against None. # Start at 0 if this is the first value. if 'used' not in self.usages[name]: self.usages[name]['used'] = 0 # Increment our usage and updat...
[ "def", "tally", "(", "self", ",", "name", ",", "value", ")", ":", "value", "=", "value", "or", "0", "# Protection against None.", "# Start at 0 if this is the first value.", "if", "'used'", "not", "in", "self", ".", "usages", "[", "name", "]", ":", "self", "...
Adds to the "used" metric for the given quota.
[ "Adds", "to", "the", "used", "metric", "for", "the", "given", "quota", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/usage/quotas.py#L150-L158
221,001
openstack/horizon
openstack_dashboard/usage/quotas.py
QuotaUsage.update_available
def update_available(self, name): """Updates the "available" metric for the given quota.""" quota = self.usages.get(name, {}).get('quota', float('inf')) available = quota - self.usages[name]['used'] if available < 0: available = 0 self.usages[name]['available'] = avai...
python
def update_available(self, name): """Updates the "available" metric for the given quota.""" quota = self.usages.get(name, {}).get('quota', float('inf')) available = quota - self.usages[name]['used'] if available < 0: available = 0 self.usages[name]['available'] = avai...
[ "def", "update_available", "(", "self", ",", "name", ")", ":", "quota", "=", "self", ".", "usages", ".", "get", "(", "name", ",", "{", "}", ")", ".", "get", "(", "'quota'", ",", "float", "(", "'inf'", ")", ")", "available", "=", "quota", "-", "se...
Updates the "available" metric for the given quota.
[ "Updates", "the", "available", "metric", "for", "the", "given", "quota", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/usage/quotas.py#L160-L166
221,002
openstack/horizon
openstack_dashboard/dashboards/project/instances/views.py
process_non_api_filters
def process_non_api_filters(search_opts, non_api_filter_info): """Process filters by non-API fields There are cases where it is useful to provide a filter field which does not exist in a resource in a backend service. For example, nova server list provides 'image' field with image ID but 'image nam...
python
def process_non_api_filters(search_opts, non_api_filter_info): """Process filters by non-API fields There are cases where it is useful to provide a filter field which does not exist in a resource in a backend service. For example, nova server list provides 'image' field with image ID but 'image nam...
[ "def", "process_non_api_filters", "(", "search_opts", ",", "non_api_filter_info", ")", ":", "for", "fake_field", ",", "real_field", ",", "resources", "in", "non_api_filter_info", ":", "if", "not", "_swap_filter", "(", "resources", ",", "search_opts", ",", "fake_fiel...
Process filters by non-API fields There are cases where it is useful to provide a filter field which does not exist in a resource in a backend service. For example, nova server list provides 'image' field with image ID but 'image name' is more useful for GUI users. This function replaces fake field...
[ "Process", "filters", "by", "non", "-", "API", "fields" ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/dashboards/project/instances/views.py#L202-L221
221,003
openstack/horizon
horizon/utils/validators.py
validate_port_or_colon_separated_port_range
def validate_port_or_colon_separated_port_range(port_range): """Accepts a port number or a single-colon separated range.""" if port_range.count(':') > 1: raise ValidationError(_("One colon allowed in port range")) ports = port_range.split(':') for port in ports: validate_port_range(port)
python
def validate_port_or_colon_separated_port_range(port_range): """Accepts a port number or a single-colon separated range.""" if port_range.count(':') > 1: raise ValidationError(_("One colon allowed in port range")) ports = port_range.split(':') for port in ports: validate_port_range(port)
[ "def", "validate_port_or_colon_separated_port_range", "(", "port_range", ")", ":", "if", "port_range", ".", "count", "(", "':'", ")", ">", "1", ":", "raise", "ValidationError", "(", "_", "(", "\"One colon allowed in port range\"", ")", ")", "ports", "=", "port_ran...
Accepts a port number or a single-colon separated range.
[ "Accepts", "a", "port", "number", "or", "a", "single", "-", "colon", "separated", "range", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/validators.py#L58-L64
221,004
openstack/horizon
openstack_dashboard/utils/settings.py
import_submodules
def import_submodules(module): """Import all submodules and make them available in a dict.""" submodules = {} for loader, name, ispkg in pkgutil.iter_modules(module.__path__, module.__name__ + '.'): try: submodule = import_module(name) ...
python
def import_submodules(module): """Import all submodules and make them available in a dict.""" submodules = {} for loader, name, ispkg in pkgutil.iter_modules(module.__path__, module.__name__ + '.'): try: submodule = import_module(name) ...
[ "def", "import_submodules", "(", "module", ")", ":", "submodules", "=", "{", "}", "for", "loader", ",", "name", ",", "ispkg", "in", "pkgutil", ".", "iter_modules", "(", "module", ".", "__path__", ",", "module", ".", "__name__", "+", "'.'", ")", ":", "t...
Import all submodules and make them available in a dict.
[ "Import", "all", "submodules", "and", "make", "them", "available", "in", "a", "dict", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/utils/settings.py#L24-L38
221,005
openstack/horizon
openstack_dashboard/utils/settings.py
import_dashboard_config
def import_dashboard_config(modules): """Imports configuration from all the modules and merges it.""" config = collections.defaultdict(dict) for module in modules: for submodule in import_submodules(module).values(): if hasattr(submodule, 'DASHBOARD'): dashboard = submodu...
python
def import_dashboard_config(modules): """Imports configuration from all the modules and merges it.""" config = collections.defaultdict(dict) for module in modules: for submodule in import_submodules(module).values(): if hasattr(submodule, 'DASHBOARD'): dashboard = submodu...
[ "def", "import_dashboard_config", "(", "modules", ")", ":", "config", "=", "collections", ".", "defaultdict", "(", "dict", ")", "for", "module", "in", "modules", ":", "for", "submodule", "in", "import_submodules", "(", "module", ")", ".", "values", "(", ")",...
Imports configuration from all the modules and merges it.
[ "Imports", "configuration", "from", "all", "the", "modules", "and", "merges", "it", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/utils/settings.py#L41-L61
221,006
openstack/horizon
openstack_dashboard/utils/settings.py
get_xstatic_dirs
def get_xstatic_dirs(XSTATIC_MODULES, HORIZON_CONFIG): """Discover static file configuration of the xstatic modules. For each entry in the XSTATIC_MODULES list we determine the entry point files (which may come from the xstatic MAIN var) and then determine where in the Django static tree the xstatic pa...
python
def get_xstatic_dirs(XSTATIC_MODULES, HORIZON_CONFIG): """Discover static file configuration of the xstatic modules. For each entry in the XSTATIC_MODULES list we determine the entry point files (which may come from the xstatic MAIN var) and then determine where in the Django static tree the xstatic pa...
[ "def", "get_xstatic_dirs", "(", "XSTATIC_MODULES", ",", "HORIZON_CONFIG", ")", ":", "STATICFILES_DIRS", "=", "[", "]", "HORIZON_CONFIG", ".", "setdefault", "(", "'xstatic_lib_files'", ",", "[", "]", ")", "for", "module_name", ",", "files", "in", "XSTATIC_MODULES",...
Discover static file configuration of the xstatic modules. For each entry in the XSTATIC_MODULES list we determine the entry point files (which may come from the xstatic MAIN var) and then determine where in the Django static tree the xstatic package's contents should be placed. For jquery.bootstr...
[ "Discover", "static", "file", "configuration", "of", "the", "xstatic", "modules", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/utils/settings.py#L242-L293
221,007
openstack/horizon
openstack_dashboard/api/nova.py
upgrade_api
def upgrade_api(request, client, version): """Ugrade the nova API to the specified version if possible.""" min_ver, max_ver = api_versions._get_server_version_range(client) if min_ver <= api_versions.APIVersion(version) <= max_ver: client = _nova.novaclient(request, version) return client
python
def upgrade_api(request, client, version): """Ugrade the nova API to the specified version if possible.""" min_ver, max_ver = api_versions._get_server_version_range(client) if min_ver <= api_versions.APIVersion(version) <= max_ver: client = _nova.novaclient(request, version) return client
[ "def", "upgrade_api", "(", "request", ",", "client", ",", "version", ")", ":", "min_ver", ",", "max_ver", "=", "api_versions", ".", "_get_server_version_range", "(", "client", ")", "if", "min_ver", "<=", "api_versions", ".", "APIVersion", "(", "version", ")", ...
Ugrade the nova API to the specified version if possible.
[ "Ugrade", "the", "nova", "API", "to", "the", "specified", "version", "if", "possible", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/nova.py#L192-L198
221,008
openstack/horizon
openstack_dashboard/api/nova.py
add_tenant_to_flavor
def add_tenant_to_flavor(request, flavor, tenant): """Add a tenant to the given flavor access list.""" return _nova.novaclient(request).flavor_access.add_tenant_access( flavor=flavor, tenant=tenant)
python
def add_tenant_to_flavor(request, flavor, tenant): """Add a tenant to the given flavor access list.""" return _nova.novaclient(request).flavor_access.add_tenant_access( flavor=flavor, tenant=tenant)
[ "def", "add_tenant_to_flavor", "(", "request", ",", "flavor", ",", "tenant", ")", ":", "return", "_nova", ".", "novaclient", "(", "request", ")", ".", "flavor_access", ".", "add_tenant_access", "(", "flavor", "=", "flavor", ",", "tenant", "=", "tenant", ")" ...
Add a tenant to the given flavor access list.
[ "Add", "a", "tenant", "to", "the", "given", "flavor", "access", "list", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/nova.py#L336-L339
221,009
openstack/horizon
openstack_dashboard/api/nova.py
remove_tenant_from_flavor
def remove_tenant_from_flavor(request, flavor, tenant): """Remove a tenant from the given flavor access list.""" return _nova.novaclient(request).flavor_access.remove_tenant_access( flavor=flavor, tenant=tenant)
python
def remove_tenant_from_flavor(request, flavor, tenant): """Remove a tenant from the given flavor access list.""" return _nova.novaclient(request).flavor_access.remove_tenant_access( flavor=flavor, tenant=tenant)
[ "def", "remove_tenant_from_flavor", "(", "request", ",", "flavor", ",", "tenant", ")", ":", "return", "_nova", ".", "novaclient", "(", "request", ")", ".", "flavor_access", ".", "remove_tenant_access", "(", "flavor", "=", "flavor", ",", "tenant", "=", "tenant"...
Remove a tenant from the given flavor access list.
[ "Remove", "a", "tenant", "from", "the", "given", "flavor", "access", "list", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/nova.py#L343-L346
221,010
openstack/horizon
openstack_dashboard/api/nova.py
flavor_get_extras
def flavor_get_extras(request, flavor_id, raw=False, flavor=None): """Get flavor extra specs.""" if flavor is None: flavor = _nova.novaclient(request).flavors.get(flavor_id) extras = flavor.get_keys() if raw: return extras return [FlavorExtraSpec(flavor_id, key, value) for ...
python
def flavor_get_extras(request, flavor_id, raw=False, flavor=None): """Get flavor extra specs.""" if flavor is None: flavor = _nova.novaclient(request).flavors.get(flavor_id) extras = flavor.get_keys() if raw: return extras return [FlavorExtraSpec(flavor_id, key, value) for ...
[ "def", "flavor_get_extras", "(", "request", ",", "flavor_id", ",", "raw", "=", "False", ",", "flavor", "=", "None", ")", ":", "if", "flavor", "is", "None", ":", "flavor", "=", "_nova", ".", "novaclient", "(", "request", ")", ".", "flavors", ".", "get",...
Get flavor extra specs.
[ "Get", "flavor", "extra", "specs", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/nova.py#L350-L358
221,011
openstack/horizon
openstack_dashboard/api/nova.py
flavor_extra_delete
def flavor_extra_delete(request, flavor_id, keys): """Unset the flavor extra spec keys.""" flavor = _nova.novaclient(request).flavors.get(flavor_id) return flavor.unset_keys(keys)
python
def flavor_extra_delete(request, flavor_id, keys): """Unset the flavor extra spec keys.""" flavor = _nova.novaclient(request).flavors.get(flavor_id) return flavor.unset_keys(keys)
[ "def", "flavor_extra_delete", "(", "request", ",", "flavor_id", ",", "keys", ")", ":", "flavor", "=", "_nova", ".", "novaclient", "(", "request", ")", ".", "flavors", ".", "get", "(", "flavor_id", ")", "return", "flavor", ".", "unset_keys", "(", "keys", ...
Unset the flavor extra spec keys.
[ "Unset", "the", "flavor", "extra", "spec", "keys", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/nova.py#L362-L365
221,012
openstack/horizon
openstack_dashboard/api/nova.py
flavor_extra_set
def flavor_extra_set(request, flavor_id, metadata): """Set the flavor extra spec keys.""" flavor = _nova.novaclient(request).flavors.get(flavor_id) if (not metadata): # not a way to delete keys return None return flavor.set_keys(metadata)
python
def flavor_extra_set(request, flavor_id, metadata): """Set the flavor extra spec keys.""" flavor = _nova.novaclient(request).flavors.get(flavor_id) if (not metadata): # not a way to delete keys return None return flavor.set_keys(metadata)
[ "def", "flavor_extra_set", "(", "request", ",", "flavor_id", ",", "metadata", ")", ":", "flavor", "=", "_nova", ".", "novaclient", "(", "request", ")", ".", "flavors", ".", "get", "(", "flavor_id", ")", "if", "(", "not", "metadata", ")", ":", "# not a wa...
Set the flavor extra spec keys.
[ "Set", "the", "flavor", "extra", "spec", "keys", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/nova.py#L369-L374
221,013
openstack/horizon
openstack_dashboard/api/nova.py
server_console_output
def server_console_output(request, instance_id, tail_length=None): """Gets console output of an instance.""" nc = _nova.novaclient(request) return nc.servers.get_console_output(instance_id, length=tail_length)
python
def server_console_output(request, instance_id, tail_length=None): """Gets console output of an instance.""" nc = _nova.novaclient(request) return nc.servers.get_console_output(instance_id, length=tail_length)
[ "def", "server_console_output", "(", "request", ",", "instance_id", ",", "tail_length", "=", "None", ")", ":", "nc", "=", "_nova", ".", "novaclient", "(", "request", ")", "return", "nc", ".", "servers", ".", "get_console_output", "(", "instance_id", ",", "le...
Gets console output of an instance.
[ "Gets", "console", "output", "of", "an", "instance", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/nova.py#L533-L536
221,014
openstack/horizon
openstack_dashboard/api/nova.py
list_extensions
def list_extensions(request): """List all nova extensions, except the ones in the blacklist.""" blacklist = set(getattr(settings, 'OPENSTACK_NOVA_EXTENSIONS_BLACKLIST', [])) nova_api = _nova.novaclient(request) return tuple( extension for extension in nova_lis...
python
def list_extensions(request): """List all nova extensions, except the ones in the blacklist.""" blacklist = set(getattr(settings, 'OPENSTACK_NOVA_EXTENSIONS_BLACKLIST', [])) nova_api = _nova.novaclient(request) return tuple( extension for extension in nova_lis...
[ "def", "list_extensions", "(", "request", ")", ":", "blacklist", "=", "set", "(", "getattr", "(", "settings", ",", "'OPENSTACK_NOVA_EXTENSIONS_BLACKLIST'", ",", "[", "]", ")", ")", "nova_api", "=", "_nova", ".", "novaclient", "(", "request", ")", "return", "...
List all nova extensions, except the ones in the blacklist.
[ "List", "all", "nova", "extensions", "except", "the", "ones", "in", "the", "blacklist", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/nova.py#L1012-L1021
221,015
openstack/horizon
openstack_dashboard/api/nova.py
extension_supported
def extension_supported(extension_name, request): """Determine if nova supports a given extension name. Example values for the extension_name include AdminActions, ConsoleOutput, etc. """ for ext in list_extensions(request): if ext.name == extension_name: return True return ...
python
def extension_supported(extension_name, request): """Determine if nova supports a given extension name. Example values for the extension_name include AdminActions, ConsoleOutput, etc. """ for ext in list_extensions(request): if ext.name == extension_name: return True return ...
[ "def", "extension_supported", "(", "extension_name", ",", "request", ")", ":", "for", "ext", "in", "list_extensions", "(", "request", ")", ":", "if", "ext", ".", "name", "==", "extension_name", ":", "return", "True", "return", "False" ]
Determine if nova supports a given extension name. Example values for the extension_name include AdminActions, ConsoleOutput, etc.
[ "Determine", "if", "nova", "supports", "a", "given", "extension", "name", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/nova.py#L1026-L1035
221,016
openstack/horizon
openstack_dashboard/utils/futurist_utils.py
call_functions_parallel
def call_functions_parallel(*worker_defs): """Call specified functions in parallel. :param *worker_defs: Each positional argument can be either of a function to be called or a tuple which consists of a function, a list of positional arguments) and keyword arguments (optional). If you ne...
python
def call_functions_parallel(*worker_defs): """Call specified functions in parallel. :param *worker_defs: Each positional argument can be either of a function to be called or a tuple which consists of a function, a list of positional arguments) and keyword arguments (optional). If you ne...
[ "def", "call_functions_parallel", "(", "*", "worker_defs", ")", ":", "# TODO(amotoki): Needs to figure out what max_workers can be specified.", "# According to e0ne, the apache default configuration in devstack allows", "# only 10 threads. What happens if max_worker=11 is specified?", "max_work...
Call specified functions in parallel. :param *worker_defs: Each positional argument can be either of a function to be called or a tuple which consists of a function, a list of positional arguments) and keyword arguments (optional). If you need to pass arguments, you need to pass a tuple. ...
[ "Call", "specified", "functions", "in", "parallel", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/utils/futurist_utils.py#L18-L50
221,017
openstack/horizon
horizon/utils/secret_key.py
generate_key
def generate_key(key_length=64): """Secret key generator. The quality of randomness depends on operating system support, see http://docs.python.org/library/random.html#random.SystemRandom. """ if hasattr(random, 'SystemRandom'): logging.info('Generating a secure random key using SystemRando...
python
def generate_key(key_length=64): """Secret key generator. The quality of randomness depends on operating system support, see http://docs.python.org/library/random.html#random.SystemRandom. """ if hasattr(random, 'SystemRandom'): logging.info('Generating a secure random key using SystemRando...
[ "def", "generate_key", "(", "key_length", "=", "64", ")", ":", "if", "hasattr", "(", "random", ",", "'SystemRandom'", ")", ":", "logging", ".", "info", "(", "'Generating a secure random key using SystemRandom.'", ")", "choice", "=", "random", ".", "SystemRandom", ...
Secret key generator. The quality of randomness depends on operating system support, see http://docs.python.org/library/random.html#random.SystemRandom.
[ "Secret", "key", "generator", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/secret_key.py#L28-L43
221,018
openstack/horizon
horizon/utils/secret_key.py
generate_or_read_from_file
def generate_or_read_from_file(key_file='.secret_key', key_length=64): """Multiprocess-safe secret key file generator. Useful to replace the default (and thus unsafe) SECRET_KEY in settings.py upon first start. Save to use, i.e. when multiple Python interpreters serve the dashboard Django application (...
python
def generate_or_read_from_file(key_file='.secret_key', key_length=64): """Multiprocess-safe secret key file generator. Useful to replace the default (and thus unsafe) SECRET_KEY in settings.py upon first start. Save to use, i.e. when multiple Python interpreters serve the dashboard Django application (...
[ "def", "generate_or_read_from_file", "(", "key_file", "=", "'.secret_key'", ",", "key_length", "=", "64", ")", ":", "abspath", "=", "os", ".", "path", ".", "abspath", "(", "key_file", ")", "# check, if key_file already exists", "# if yes, then just read and return key",...
Multiprocess-safe secret key file generator. Useful to replace the default (and thus unsafe) SECRET_KEY in settings.py upon first start. Save to use, i.e. when multiple Python interpreters serve the dashboard Django application (e.g. in a mod_wsgi + daemonized environment). Also checks if file permiss...
[ "Multiprocess", "-", "safe", "secret", "key", "file", "generator", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/utils/secret_key.py#L56-L84
221,019
openstack/horizon
openstack_dashboard/api/rest/urls.py
register
def register(view): """Register API views to respond to a regex pattern. ``url_regex`` on a wrapped view class is used as the regex pattern. The view should be a standard Django class-based view implementing an as_view() method. The url_regex attribute of the view should be a standard Django URL re...
python
def register(view): """Register API views to respond to a regex pattern. ``url_regex`` on a wrapped view class is used as the regex pattern. The view should be a standard Django class-based view implementing an as_view() method. The url_regex attribute of the view should be a standard Django URL re...
[ "def", "register", "(", "view", ")", ":", "p", "=", "urls", ".", "url", "(", "view", ".", "url_regex", ",", "view", ".", "as_view", "(", ")", ")", "urlpatterns", ".", "append", "(", "p", ")", "return", "view" ]
Register API views to respond to a regex pattern. ``url_regex`` on a wrapped view class is used as the regex pattern. The view should be a standard Django class-based view implementing an as_view() method. The url_regex attribute of the view should be a standard Django URL regex pattern.
[ "Register", "API", "views", "to", "respond", "to", "a", "regex", "pattern", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/api/rest/urls.py#L22-L32
221,020
openstack/horizon
horizon/templatetags/shellfilter.py
shellfilter
def shellfilter(value): """Replace HTML chars for shell usage.""" replacements = {'\\': '\\\\', '`': '\\`', "'": "\\'", '"': '\\"'} for search, repl in replacements.items(): value = value.replace(search, repl) return safestring.mark_saf...
python
def shellfilter(value): """Replace HTML chars for shell usage.""" replacements = {'\\': '\\\\', '`': '\\`', "'": "\\'", '"': '\\"'} for search, repl in replacements.items(): value = value.replace(search, repl) return safestring.mark_saf...
[ "def", "shellfilter", "(", "value", ")", ":", "replacements", "=", "{", "'\\\\'", ":", "'\\\\\\\\'", ",", "'`'", ":", "'\\\\`'", ",", "\"'\"", ":", "\"\\\\'\"", ",", "'\"'", ":", "'\\\\\"'", "}", "for", "search", ",", "repl", "in", "replacements", ".", ...
Replace HTML chars for shell usage.
[ "Replace", "HTML", "chars", "for", "shell", "usage", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/templatetags/shellfilter.py#L22-L30
221,021
openstack/horizon
openstack_auth/views.py
websso
def websso(request): """Logs a user in using a token from Keystone's POST.""" referer = request.META.get('HTTP_REFERER', settings.OPENSTACK_KEYSTONE_URL) auth_url = utils.clean_up_auth_url(referer) token = request.POST.get('token') try: request.user = auth.authenticate(request=request, auth_...
python
def websso(request): """Logs a user in using a token from Keystone's POST.""" referer = request.META.get('HTTP_REFERER', settings.OPENSTACK_KEYSTONE_URL) auth_url = utils.clean_up_auth_url(referer) token = request.POST.get('token') try: request.user = auth.authenticate(request=request, auth_...
[ "def", "websso", "(", "request", ")", ":", "referer", "=", "request", ".", "META", ".", "get", "(", "'HTTP_REFERER'", ",", "settings", ".", "OPENSTACK_KEYSTONE_URL", ")", "auth_url", "=", "utils", ".", "clean_up_auth_url", "(", "referer", ")", "token", "=", ...
Logs a user in using a token from Keystone's POST.
[ "Logs", "a", "user", "in", "using", "a", "token", "from", "Keystone", "s", "POST", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/views.py#L159-L180
221,022
openstack/horizon
openstack_auth/views.py
logout
def logout(request, login_url=None, **kwargs): """Logs out the user if he is logged in. Then redirects to the log-in page. :param login_url: Once logged out, defines the URL where to redirect after login :param kwargs: see django.contrib.auth.views.logout_then_login extra parameters. ...
python
def logout(request, login_url=None, **kwargs): """Logs out the user if he is logged in. Then redirects to the log-in page. :param login_url: Once logged out, defines the URL where to redirect after login :param kwargs: see django.contrib.auth.views.logout_then_login extra parameters. ...
[ "def", "logout", "(", "request", ",", "login_url", "=", "None", ",", "*", "*", "kwargs", ")", ":", "msg", "=", "'Logging out user \"%(username)s\".'", "%", "{", "'username'", ":", "request", ".", "user", ".", "username", "}", "LOG", ".", "info", "(", "ms...
Logs out the user if he is logged in. Then redirects to the log-in page. :param login_url: Once logged out, defines the URL where to redirect after login :param kwargs: see django.contrib.auth.views.logout_then_login extra parameters.
[ "Logs", "out", "the", "user", "if", "he", "is", "logged", "in", ".", "Then", "redirects", "to", "the", "log", "-", "in", "page", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/views.py#L183-L206
221,023
openstack/horizon
openstack_auth/views.py
switch
def switch(request, tenant_id, redirect_field_name=auth.REDIRECT_FIELD_NAME): """Switches an authenticated user from one project to another.""" LOG.debug('Switching to tenant %s for user "%s".', tenant_id, request.user.username) endpoint, __ = utils.fix_auth_url_version_prefix(request.user.en...
python
def switch(request, tenant_id, redirect_field_name=auth.REDIRECT_FIELD_NAME): """Switches an authenticated user from one project to another.""" LOG.debug('Switching to tenant %s for user "%s".', tenant_id, request.user.username) endpoint, __ = utils.fix_auth_url_version_prefix(request.user.en...
[ "def", "switch", "(", "request", ",", "tenant_id", ",", "redirect_field_name", "=", "auth", ".", "REDIRECT_FIELD_NAME", ")", ":", "LOG", ".", "debug", "(", "'Switching to tenant %s for user \"%s\".'", ",", "tenant_id", ",", "request", ".", "user", ".", "username",...
Switches an authenticated user from one project to another.
[ "Switches", "an", "authenticated", "user", "from", "one", "project", "to", "another", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/views.py#L210-L257
221,024
openstack/horizon
openstack_auth/views.py
switch_region
def switch_region(request, region_name, redirect_field_name=auth.REDIRECT_FIELD_NAME): """Switches the user's region for all services except Identity service. The region will be switched if the given region is one of the regions available for the scoped project. Otherwise the region is no...
python
def switch_region(request, region_name, redirect_field_name=auth.REDIRECT_FIELD_NAME): """Switches the user's region for all services except Identity service. The region will be switched if the given region is one of the regions available for the scoped project. Otherwise the region is no...
[ "def", "switch_region", "(", "request", ",", "region_name", ",", "redirect_field_name", "=", "auth", ".", "REDIRECT_FIELD_NAME", ")", ":", "if", "region_name", "in", "request", ".", "user", ".", "available_services_regions", ":", "request", ".", "session", "[", ...
Switches the user's region for all services except Identity service. The region will be switched if the given region is one of the regions available for the scoped project. Otherwise the region is not switched.
[ "Switches", "the", "user", "s", "region", "for", "all", "services", "except", "Identity", "service", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/views.py#L261-L280
221,025
openstack/horizon
openstack_auth/views.py
switch_keystone_provider
def switch_keystone_provider(request, keystone_provider=None, redirect_field_name=auth.REDIRECT_FIELD_NAME): """Switches the user's keystone provider using K2K Federation If keystone_provider is given then we switch the user to the keystone provider using K2K federation. Otherw...
python
def switch_keystone_provider(request, keystone_provider=None, redirect_field_name=auth.REDIRECT_FIELD_NAME): """Switches the user's keystone provider using K2K Federation If keystone_provider is given then we switch the user to the keystone provider using K2K federation. Otherw...
[ "def", "switch_keystone_provider", "(", "request", ",", "keystone_provider", "=", "None", ",", "redirect_field_name", "=", "auth", ".", "REDIRECT_FIELD_NAME", ")", ":", "base_token", "=", "request", ".", "session", ".", "get", "(", "'k2k_base_unscoped_token'", ",", ...
Switches the user's keystone provider using K2K Federation If keystone_provider is given then we switch the user to the keystone provider using K2K federation. Otherwise if keystone_provider is None then we switch the user back to the Identity Provider Keystone which a non federated token auth will be ...
[ "Switches", "the", "user", "s", "keystone", "provider", "using", "K2K", "Federation" ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/views.py#L284-L353
221,026
openstack/horizon
horizon/tables/actions.py
LinkAction.get_link_url
def get_link_url(self, datum=None): """Returns the final URL based on the value of ``url``. If ``url`` is callable it will call the function. If not, it will then try to call ``reverse`` on ``url``. Failing that, it will simply return the value of ``url`` as-is. When called for...
python
def get_link_url(self, datum=None): """Returns the final URL based on the value of ``url``. If ``url`` is callable it will call the function. If not, it will then try to call ``reverse`` on ``url``. Failing that, it will simply return the value of ``url`` as-is. When called for...
[ "def", "get_link_url", "(", "self", ",", "datum", "=", "None", ")", ":", "if", "not", "self", ".", "url", ":", "raise", "NotImplementedError", "(", "'A LinkAction class must have a '", "'url attribute or define its own '", "'get_link_url method.'", ")", "if", "callabl...
Returns the final URL based on the value of ``url``. If ``url`` is callable it will call the function. If not, it will then try to call ``reverse`` on ``url``. Failing that, it will simply return the value of ``url`` as-is. When called for a row action, the current row data object will...
[ "Returns", "the", "final", "URL", "based", "on", "the", "value", "of", "url", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/actions.py#L388-L413
221,027
openstack/horizon
horizon/tables/actions.py
FilterAction.get_param_name
def get_param_name(self): """Returns the full query parameter name for this action. Defaults to ``{{ table.name }}__{{ action.name }}__{{ action.param_name }}``. """ return "__".join([self.table.name, self.name, self.param_name])
python
def get_param_name(self): """Returns the full query parameter name for this action. Defaults to ``{{ table.name }}__{{ action.name }}__{{ action.param_name }}``. """ return "__".join([self.table.name, self.name, self.param_name])
[ "def", "get_param_name", "(", "self", ")", ":", "return", "\"__\"", ".", "join", "(", "[", "self", ".", "table", ".", "name", ",", "self", ".", "name", ",", "self", ".", "param_name", "]", ")" ]
Returns the full query parameter name for this action. Defaults to ``{{ table.name }}__{{ action.name }}__{{ action.param_name }}``.
[ "Returns", "the", "full", "query", "parameter", "name", "for", "this", "action", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/actions.py#L492-L498
221,028
openstack/horizon
horizon/tables/actions.py
FilterAction.is_api_filter
def is_api_filter(self, filter_field): """Determine if agiven filter field should be used as an API filter.""" if self.filter_type == 'server': for choice in self.filter_choices: if (choice[0] == filter_field and len(choice) > 2 and choice[2]): ...
python
def is_api_filter(self, filter_field): """Determine if agiven filter field should be used as an API filter.""" if self.filter_type == 'server': for choice in self.filter_choices: if (choice[0] == filter_field and len(choice) > 2 and choice[2]): ...
[ "def", "is_api_filter", "(", "self", ",", "filter_field", ")", ":", "if", "self", ".", "filter_type", "==", "'server'", ":", "for", "choice", "in", "self", ".", "filter_choices", ":", "if", "(", "choice", "[", "0", "]", "==", "filter_field", "and", "len"...
Determine if agiven filter field should be used as an API filter.
[ "Determine", "if", "agiven", "filter", "field", "should", "be", "used", "as", "an", "API", "filter", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/actions.py#L534-L541
221,029
openstack/horizon
horizon/tables/actions.py
FilterAction.get_select_options
def get_select_options(self): """Provide the value, string, and help_text for the template to render. help_text is returned if applicable. """ if self.filter_choices: return [choice[:4] for choice in self.filter_choices # Display it If the fifth element i...
python
def get_select_options(self): """Provide the value, string, and help_text for the template to render. help_text is returned if applicable. """ if self.filter_choices: return [choice[:4] for choice in self.filter_choices # Display it If the fifth element i...
[ "def", "get_select_options", "(", "self", ")", ":", "if", "self", ".", "filter_choices", ":", "return", "[", "choice", "[", ":", "4", "]", "for", "choice", "in", "self", ".", "filter_choices", "# Display it If the fifth element is True or does not exist", "if", "l...
Provide the value, string, and help_text for the template to render. help_text is returned if applicable.
[ "Provide", "the", "value", "string", "and", "help_text", "for", "the", "template", "to", "render", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/actions.py#L543-L551
221,030
openstack/horizon
horizon/tables/actions.py
BatchAction._get_action_name
def _get_action_name(self, items=None, past=False): """Retreive action name based on the number of items and `past` flag. :param items: A list or tuple of items (or container with a __len__ method) to count the number of concerned items for which this method is call...
python
def _get_action_name(self, items=None, past=False): """Retreive action name based on the number of items and `past` flag. :param items: A list or tuple of items (or container with a __len__ method) to count the number of concerned items for which this method is call...
[ "def", "_get_action_name", "(", "self", ",", "items", "=", "None", ",", "past", "=", "False", ")", ":", "action_type", "=", "\"past\"", "if", "past", "else", "\"present\"", "if", "items", "is", "None", ":", "# Called without items parameter (by a single instance.)...
Retreive action name based on the number of items and `past` flag. :param items: A list or tuple of items (or container with a __len__ method) to count the number of concerned items for which this method is called. When this method is called for a single item (b...
[ "Retreive", "action", "name", "based", "on", "the", "number", "of", "items", "and", "past", "flag", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/actions.py#L697-L730
221,031
openstack/horizon
horizon/tables/actions.py
BatchAction.update
def update(self, request, datum): """Switches the action verbose name, if needed.""" if getattr(self, 'action_present', False): self.verbose_name = self._get_action_name() self.verbose_name_plural = self._get_action_name('plural')
python
def update(self, request, datum): """Switches the action verbose name, if needed.""" if getattr(self, 'action_present', False): self.verbose_name = self._get_action_name() self.verbose_name_plural = self._get_action_name('plural')
[ "def", "update", "(", "self", ",", "request", ",", "datum", ")", ":", "if", "getattr", "(", "self", ",", "'action_present'", ",", "False", ")", ":", "self", ".", "verbose_name", "=", "self", ".", "_get_action_name", "(", ")", "self", ".", "verbose_name_p...
Switches the action verbose name, if needed.
[ "Switches", "the", "action", "verbose", "name", "if", "needed", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/actions.py#L740-L744
221,032
openstack/horizon
horizon/tables/actions.py
BatchAction.get_default_attrs
def get_default_attrs(self): """Returns a list of the default HTML attributes for the action.""" attrs = super(BatchAction, self).get_default_attrs() attrs.update({'data-batch-action': 'true'}) return attrs
python
def get_default_attrs(self): """Returns a list of the default HTML attributes for the action.""" attrs = super(BatchAction, self).get_default_attrs() attrs.update({'data-batch-action': 'true'}) return attrs
[ "def", "get_default_attrs", "(", "self", ")", ":", "attrs", "=", "super", "(", "BatchAction", ",", "self", ")", ".", "get_default_attrs", "(", ")", "attrs", ".", "update", "(", "{", "'data-batch-action'", ":", "'true'", "}", ")", "return", "attrs" ]
Returns a list of the default HTML attributes for the action.
[ "Returns", "a", "list", "of", "the", "default", "HTML", "attributes", "for", "the", "action", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tables/actions.py#L752-L756
221,033
openstack/horizon
horizon/tabs/views.py
TabView.get_tabs
def get_tabs(self, request, **kwargs): """Returns the initialized tab group for this view.""" if self._tab_group is None: self._tab_group = self.tab_group_class(request, **kwargs) return self._tab_group
python
def get_tabs(self, request, **kwargs): """Returns the initialized tab group for this view.""" if self._tab_group is None: self._tab_group = self.tab_group_class(request, **kwargs) return self._tab_group
[ "def", "get_tabs", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_tab_group", "is", "None", ":", "self", ".", "_tab_group", "=", "self", ".", "tab_group_class", "(", "request", ",", "*", "*", "kwargs", ")", "retu...
Returns the initialized tab group for this view.
[ "Returns", "the", "initialized", "tab", "group", "for", "this", "view", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tabs/views.py#L40-L44
221,034
openstack/horizon
horizon/tabs/views.py
TabView.get_context_data
def get_context_data(self, **kwargs): """Adds the ``tab_group`` variable to the context data.""" context = super(TabView, self).get_context_data(**kwargs) try: tab_group = self.get_tabs(self.request, **kwargs) context["tab_group"] = tab_group # Make sure our d...
python
def get_context_data(self, **kwargs): """Adds the ``tab_group`` variable to the context data.""" context = super(TabView, self).get_context_data(**kwargs) try: tab_group = self.get_tabs(self.request, **kwargs) context["tab_group"] = tab_group # Make sure our d...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "TabView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "try", ":", "tab_group", "=", "self", ".", "get_tabs", "(", "...
Adds the ``tab_group`` variable to the context data.
[ "Adds", "the", "tab_group", "variable", "to", "the", "context", "data", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tabs/views.py#L46-L56
221,035
openstack/horizon
horizon/tabs/views.py
TabView.handle_tabbed_response
def handle_tabbed_response(self, tab_group, context): """Sends back an AJAX-appropriate response for the tab group if needed. Otherwise renders the response as normal. """ if self.request.is_ajax(): if tab_group.selected: return http.HttpResponse(tab_group.se...
python
def handle_tabbed_response(self, tab_group, context): """Sends back an AJAX-appropriate response for the tab group if needed. Otherwise renders the response as normal. """ if self.request.is_ajax(): if tab_group.selected: return http.HttpResponse(tab_group.se...
[ "def", "handle_tabbed_response", "(", "self", ",", "tab_group", ",", "context", ")", ":", "if", "self", ".", "request", ".", "is_ajax", "(", ")", ":", "if", "tab_group", ".", "selected", ":", "return", "http", ".", "HttpResponse", "(", "tab_group", ".", ...
Sends back an AJAX-appropriate response for the tab group if needed. Otherwise renders the response as normal.
[ "Sends", "back", "an", "AJAX", "-", "appropriate", "response", "for", "the", "tab", "group", "if", "needed", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tabs/views.py#L58-L68
221,036
openstack/horizon
horizon/tabs/views.py
TabbedTableView.load_tabs
def load_tabs(self): """Loads the tab group. It compiles the table instances for each table attached to any :class:`horizon.tabs.TableTab` instances on the tab group. This step is necessary before processing any tab or table actions. """ tab_group = self.get_tabs(self.re...
python
def load_tabs(self): """Loads the tab group. It compiles the table instances for each table attached to any :class:`horizon.tabs.TableTab` instances on the tab group. This step is necessary before processing any tab or table actions. """ tab_group = self.get_tabs(self.re...
[ "def", "load_tabs", "(", "self", ")", ":", "tab_group", "=", "self", ".", "get_tabs", "(", "self", ".", "request", ",", "*", "*", "self", ".", "kwargs", ")", "tabs", "=", "tab_group", ".", "get_tabs", "(", ")", "for", "tab", "in", "[", "t", "for", ...
Loads the tab group. It compiles the table instances for each table attached to any :class:`horizon.tabs.TableTab` instances on the tab group. This step is necessary before processing any tab or table actions.
[ "Loads", "the", "tab", "group", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tabs/views.py#L81-L94
221,037
openstack/horizon
horizon/tabs/views.py
TabbedTableView.handle_table
def handle_table(self, table_dict): """Loads the table data based on a given table_dict and handles them. For the given dict containing a ``DataTable`` and a ``TableTab`` instance, it loads the table data for that tab and calls the table's :meth:`~horizon.tables.DataTable.maybe_handle` ...
python
def handle_table(self, table_dict): """Loads the table data based on a given table_dict and handles them. For the given dict containing a ``DataTable`` and a ``TableTab`` instance, it loads the table data for that tab and calls the table's :meth:`~horizon.tables.DataTable.maybe_handle` ...
[ "def", "handle_table", "(", "self", ",", "table_dict", ")", ":", "table", "=", "table_dict", "[", "'table'", "]", "tab", "=", "table_dict", "[", "'tab'", "]", "tab", ".", "load_table_data", "(", ")", "table_name", "=", "table", ".", "_meta", ".", "name",...
Loads the table data based on a given table_dict and handles them. For the given dict containing a ``DataTable`` and a ``TableTab`` instance, it loads the table data for that tab and calls the table's :meth:`~horizon.tables.DataTable.maybe_handle` method. The return value will be the re...
[ "Loads", "the", "table", "data", "based", "on", "a", "given", "table_dict", "and", "handles", "them", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/horizon/tabs/views.py#L102-L117
221,038
openstack/horizon
openstack_dashboard/context_processors.py
openstack
def openstack(request): """Context processor necessary for OpenStack Dashboard functionality. The following variables are added to the request context: ``authorized_tenants`` A list of tenant objects which the current user has access to. ``regions`` A dictionary containing informatio...
python
def openstack(request): """Context processor necessary for OpenStack Dashboard functionality. The following variables are added to the request context: ``authorized_tenants`` A list of tenant objects which the current user has access to. ``regions`` A dictionary containing informatio...
[ "def", "openstack", "(", "request", ")", ":", "context", "=", "{", "}", "# Auth/Keystone context", "context", ".", "setdefault", "(", "'authorized_tenants'", ",", "[", "]", ")", "if", "request", ".", "user", ".", "is_authenticated", ":", "context", "[", "'au...
Context processor necessary for OpenStack Dashboard functionality. The following variables are added to the request context: ``authorized_tenants`` A list of tenant objects which the current user has access to. ``regions`` A dictionary containing information about region support, the cur...
[ "Context", "processor", "necessary", "for", "OpenStack", "Dashboard", "functionality", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_dashboard/context_processors.py#L30-L110
221,039
openstack/horizon
openstack_auth/utils.py
is_token_valid
def is_token_valid(token, margin=None): """Timezone-aware checking of the auth token's expiration timestamp. Returns ``True`` if the token has not yet expired, otherwise ``False``. :param token: The openstack_auth.user.Token instance to check :param margin: A time margin in seconds to subtract...
python
def is_token_valid(token, margin=None): """Timezone-aware checking of the auth token's expiration timestamp. Returns ``True`` if the token has not yet expired, otherwise ``False``. :param token: The openstack_auth.user.Token instance to check :param margin: A time margin in seconds to subtract...
[ "def", "is_token_valid", "(", "token", ",", "margin", "=", "None", ")", ":", "expiration", "=", "token", ".", "expires", "# In case we get an unparseable expiration timestamp, return False", "# so you can't have a \"forever\" token just by breaking the expires param.", "if", "exp...
Timezone-aware checking of the auth token's expiration timestamp. Returns ``True`` if the token has not yet expired, otherwise ``False``. :param token: The openstack_auth.user.Token instance to check :param margin: A time margin in seconds to subtract from the real token's validity. An exam...
[ "Timezone", "-", "aware", "checking", "of", "the", "auth", "token", "s", "expiration", "timestamp", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L75-L101
221,040
openstack/horizon
openstack_auth/utils.py
is_safe_url
def is_safe_url(url, host=None): """Return ``True`` if the url is a safe redirection. The safe redirection means that it doesn't point to a different host. Always returns ``False`` on an empty url. """ if not url: return False netloc = urlparse.urlparse(url)[1] return not netloc or ...
python
def is_safe_url(url, host=None): """Return ``True`` if the url is a safe redirection. The safe redirection means that it doesn't point to a different host. Always returns ``False`` on an empty url. """ if not url: return False netloc = urlparse.urlparse(url)[1] return not netloc or ...
[ "def", "is_safe_url", "(", "url", ",", "host", "=", "None", ")", ":", "if", "not", "url", ":", "return", "False", "netloc", "=", "urlparse", ".", "urlparse", "(", "url", ")", "[", "1", "]", "return", "not", "netloc", "or", "netloc", "==", "host" ]
Return ``True`` if the url is a safe redirection. The safe redirection means that it doesn't point to a different host. Always returns ``False`` on an empty url.
[ "Return", "True", "if", "the", "url", "is", "a", "safe", "redirection", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L107-L116
221,041
openstack/horizon
openstack_auth/utils.py
build_absolute_uri
def build_absolute_uri(request, relative_url): """Ensure absolute_uri are relative to WEBROOT.""" webroot = getattr(settings, 'WEBROOT', '') if webroot.endswith("/") and relative_url.startswith("/"): webroot = webroot[:-1] return request.build_absolute_uri(webroot + relative_url)
python
def build_absolute_uri(request, relative_url): """Ensure absolute_uri are relative to WEBROOT.""" webroot = getattr(settings, 'WEBROOT', '') if webroot.endswith("/") and relative_url.startswith("/"): webroot = webroot[:-1] return request.build_absolute_uri(webroot + relative_url)
[ "def", "build_absolute_uri", "(", "request", ",", "relative_url", ")", ":", "webroot", "=", "getattr", "(", "settings", ",", "'WEBROOT'", ",", "''", ")", "if", "webroot", ".", "endswith", "(", "\"/\"", ")", "and", "relative_url", ".", "startswith", "(", "\...
Ensure absolute_uri are relative to WEBROOT.
[ "Ensure", "absolute_uri", "are", "relative", "to", "WEBROOT", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L173-L179
221,042
openstack/horizon
openstack_auth/utils.py
get_websso_url
def get_websso_url(request, auth_url, websso_auth): """Return the keystone endpoint for initiating WebSSO. Generate the keystone WebSSO endpoint that will redirect the user to the login page of the federated identity provider. Based on the authentication type selected by the user in the login form...
python
def get_websso_url(request, auth_url, websso_auth): """Return the keystone endpoint for initiating WebSSO. Generate the keystone WebSSO endpoint that will redirect the user to the login page of the federated identity provider. Based on the authentication type selected by the user in the login form...
[ "def", "get_websso_url", "(", "request", ",", "auth_url", ",", "websso_auth", ")", ":", "origin", "=", "build_absolute_uri", "(", "request", ",", "'/auth/websso/'", ")", "idp_mapping", "=", "getattr", "(", "settings", ",", "'WEBSSO_IDP_MAPPING'", ",", "{", "}", ...
Return the keystone endpoint for initiating WebSSO. Generate the keystone WebSSO endpoint that will redirect the user to the login page of the federated identity provider. Based on the authentication type selected by the user in the login form, it will construct the keystone WebSSO endpoint. :par...
[ "Return", "the", "keystone", "endpoint", "for", "initiating", "WebSSO", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L182-L257
221,043
openstack/horizon
openstack_auth/utils.py
has_in_url_path
def has_in_url_path(url, subs): """Test if any of `subs` strings is present in the `url` path.""" scheme, netloc, path, query, fragment = urlparse.urlsplit(url) return any([sub in path for sub in subs])
python
def has_in_url_path(url, subs): """Test if any of `subs` strings is present in the `url` path.""" scheme, netloc, path, query, fragment = urlparse.urlsplit(url) return any([sub in path for sub in subs])
[ "def", "has_in_url_path", "(", "url", ",", "subs", ")", ":", "scheme", ",", "netloc", ",", "path", ",", "query", ",", "fragment", "=", "urlparse", ".", "urlsplit", "(", "url", ")", "return", "any", "(", "[", "sub", "in", "path", "for", "sub", "in", ...
Test if any of `subs` strings is present in the `url` path.
[ "Test", "if", "any", "of", "subs", "strings", "is", "present", "in", "the", "url", "path", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L260-L263
221,044
openstack/horizon
openstack_auth/utils.py
url_path_replace
def url_path_replace(url, old, new, count=None): """Return a copy of url with replaced path. Return a copy of url with all occurrences of old replaced by new in the url path. If the optional argument count is given, only the first count occurrences are replaced. """ args = [] scheme, netlo...
python
def url_path_replace(url, old, new, count=None): """Return a copy of url with replaced path. Return a copy of url with all occurrences of old replaced by new in the url path. If the optional argument count is given, only the first count occurrences are replaced. """ args = [] scheme, netlo...
[ "def", "url_path_replace", "(", "url", ",", "old", ",", "new", ",", "count", "=", "None", ")", ":", "args", "=", "[", "]", "scheme", ",", "netloc", ",", "path", ",", "query", ",", "fragment", "=", "urlparse", ".", "urlsplit", "(", "url", ")", "if",...
Return a copy of url with replaced path. Return a copy of url with all occurrences of old replaced by new in the url path. If the optional argument count is given, only the first count occurrences are replaced.
[ "Return", "a", "copy", "of", "url", "with", "replaced", "path", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L266-L278
221,045
openstack/horizon
openstack_auth/utils.py
_augment_url_with_version
def _augment_url_with_version(auth_url): """Optionally augment auth_url path with version suffix. Check if path component already contains version suffix and if it does not, append version suffix to the end of path, not erasing the previous path contents, since keystone web endpoint (like /identity) co...
python
def _augment_url_with_version(auth_url): """Optionally augment auth_url path with version suffix. Check if path component already contains version suffix and if it does not, append version suffix to the end of path, not erasing the previous path contents, since keystone web endpoint (like /identity) co...
[ "def", "_augment_url_with_version", "(", "auth_url", ")", ":", "if", "has_in_url_path", "(", "auth_url", ",", "[", "\"/v2.0\"", ",", "\"/v3\"", "]", ")", ":", "return", "auth_url", "if", "get_keystone_version", "(", ")", ">=", "3", ":", "return", "url_path_app...
Optionally augment auth_url path with version suffix. Check if path component already contains version suffix and if it does not, append version suffix to the end of path, not erasing the previous path contents, since keystone web endpoint (like /identity) could be there. Keystone version needs to be a...
[ "Optionally", "augment", "auth_url", "path", "with", "version", "suffix", "." ]
5601ea9477323e599d9b766fcac1f8be742935b2
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/utils.py#L287-L303
221,046
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
221,047
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
221,048
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
221,049
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
221,050
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
221,051
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
221,052
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
221,053
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
221,054
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
221,055
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
221,056
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
221,057
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
221,058
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
221,059
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
221,060
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
221,061
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
221,062
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
221,063
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
221,064
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
221,065
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
221,066
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
221,067
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
221,068
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
221,069
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
221,070
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
221,071
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
221,072
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
221,073
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
221,074
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
221,075
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
221,076
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
221,077
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
221,078
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
221,079
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
221,080
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
221,081
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
221,082
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
221,083
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
221,084
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
221,085
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
221,086
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
221,087
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
221,088
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
221,089
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
221,090
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
221,091
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
221,092
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
221,093
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
221,094
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
221,095
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
221,096
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
221,097
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
221,098
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
221,099
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