repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
opennode/waldur-core
waldur_core/structure/views.py
ProjectViewSet.destroy
def destroy(self, request, *args, **kwargs): """ Deletion of a project is done through sending a **DELETE** request to the project instance URI. Please note, that if a project has connected instances, deletion request will fail with 409 response code. Valid request example (token is use...
python
def destroy(self, request, *args, **kwargs): """ Deletion of a project is done through sending a **DELETE** request to the project instance URI. Please note, that if a project has connected instances, deletion request will fail with 409 response code. Valid request example (token is use...
[ "def", "destroy", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "ProjectViewSet", ",", "self", ")", ".", "destroy", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Deletion of a project is done through sending a **DELETE** request to the project instance URI. Please note, that if a project has connected instances, deletion request will fail with 409 response code. Valid request example (token is user specific): .. code-block:: http DELETE /a...
[ "Deletion", "of", "a", "project", "is", "done", "through", "sending", "a", "**", "DELETE", "**", "request", "to", "the", "project", "instance", "URI", ".", "Please", "note", "that", "if", "a", "project", "has", "connected", "instances", "deletion", "request"...
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L311-L324
train
opennode/waldur-core
waldur_core/structure/views.py
ProjectViewSet.users
def users(self, request, uuid=None): """ A list of users connected to the project """ project = self.get_object() queryset = project.get_users() # we need to handle filtration manually because we want to filter only project users, not projects. filter_backend = filters.UserConcat...
python
def users(self, request, uuid=None): """ A list of users connected to the project """ project = self.get_object() queryset = project.get_users() # we need to handle filtration manually because we want to filter only project users, not projects. filter_backend = filters.UserConcat...
[ "def", "users", "(", "self", ",", "request", ",", "uuid", "=", "None", ")", ":", "project", "=", "self", ".", "get_object", "(", ")", "queryset", "=", "project", ".", "get_users", "(", ")", "# we need to handle filtration manually because we want to filter only pr...
A list of users connected to the project
[ "A", "list", "of", "users", "connected", "to", "the", "project" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L374-L383
train
opennode/waldur-core
waldur_core/structure/views.py
UserViewSet.list
def list(self, request, *args, **kwargs): """ User list is available to all authenticated users. To get a list, issue authenticated **GET** request against */api/users/*. User list supports several filters. All filters are set in HTTP query section. Field filters are listed belo...
python
def list(self, request, *args, **kwargs): """ User list is available to all authenticated users. To get a list, issue authenticated **GET** request against */api/users/*. User list supports several filters. All filters are set in HTTP query section. Field filters are listed belo...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "UserViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
User list is available to all authenticated users. To get a list, issue authenticated **GET** request against */api/users/*. User list supports several filters. All filters are set in HTTP query section. Field filters are listed below. All of the filters apart from ?organization are usi...
[ "User", "list", "is", "available", "to", "all", "authenticated", "users", ".", "To", "get", "a", "list", "issue", "authenticated", "**", "GET", "**", "request", "against", "*", "/", "api", "/", "users", "/", "*", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L417-L459
train
opennode/waldur-core
waldur_core/structure/views.py
UserViewSet.retrieve
def retrieve(self, request, *args, **kwargs): """ User fields can be updated by account owner or user with staff privilege (is_staff=True). Following user fields can be updated: - organization (deprecated, use `organization plugin <http://waldur_core-organization.readthedocs.o...
python
def retrieve(self, request, *args, **kwargs): """ User fields can be updated by account owner or user with staff privilege (is_staff=True). Following user fields can be updated: - organization (deprecated, use `organization plugin <http://waldur_core-organization.readthedocs.o...
[ "def", "retrieve", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "UserViewSet", ",", "self", ")", ".", "retrieve", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
User fields can be updated by account owner or user with staff privilege (is_staff=True). Following user fields can be updated: - organization (deprecated, use `organization plugin <http://waldur_core-organization.readthedocs.org/en/stable/>`_ instead) - full_name - native_nam...
[ "User", "fields", "can", "be", "updated", "by", "account", "owner", "or", "user", "with", "staff", "privilege", "(", "is_staff", "=", "True", ")", ".", "Following", "user", "fields", "can", "be", "updated", ":" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L461-L490
train
opennode/waldur-core
waldur_core/structure/views.py
UserViewSet.password
def password(self, request, uuid=None): """ To change a user password, submit a **POST** request to the user's RPC URL, specifying new password by staff user or account owner. Password is expected to be at least 7 symbols long and contain at least one number and at least one low...
python
def password(self, request, uuid=None): """ To change a user password, submit a **POST** request to the user's RPC URL, specifying new password by staff user or account owner. Password is expected to be at least 7 symbols long and contain at least one number and at least one low...
[ "def", "password", "(", "self", ",", "request", ",", "uuid", "=", "None", ")", ":", "user", "=", "self", ".", "get_object", "(", ")", "serializer", "=", "serializers", ".", "PasswordSerializer", "(", "data", "=", "request", ".", "data", ")", "serializer"...
To change a user password, submit a **POST** request to the user's RPC URL, specifying new password by staff user or account owner. Password is expected to be at least 7 symbols long and contain at least one number and at least one lower or upper case. Example of a valid request: ...
[ "To", "change", "a", "user", "password", "submit", "a", "**", "POST", "**", "request", "to", "the", "user", "s", "RPC", "URL", "specifying", "new", "password", "by", "staff", "user", "or", "account", "owner", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L493-L525
train
opennode/waldur-core
waldur_core/structure/views.py
ProjectPermissionViewSet.list
def list(self, request, *args, **kwargs): """ Project permissions expresses connection of user to a project. User may have either project manager or system administrator permission in the project. Use */api/project-permissions/* endpoint to maintain project permissions. Note tha...
python
def list(self, request, *args, **kwargs): """ Project permissions expresses connection of user to a project. User may have either project manager or system administrator permission in the project. Use */api/project-permissions/* endpoint to maintain project permissions. Note tha...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "ProjectPermissionViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Project permissions expresses connection of user to a project. User may have either project manager or system administrator permission in the project. Use */api/project-permissions/* endpoint to maintain project permissions. Note that project permissions can be viewed and modified only by custo...
[ "Project", "permissions", "expresses", "connection", "of", "user", "to", "a", "project", ".", "User", "may", "have", "either", "project", "manager", "or", "system", "administrator", "permission", "in", "the", "project", ".", "Use", "*", "/", "api", "/", "pro...
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L611-L638
train
opennode/waldur-core
waldur_core/structure/views.py
ProjectPermissionViewSet.destroy
def destroy(self, request, *args, **kwargs): """ To remove a user from a project, delete corresponding connection (**url** field). Successful deletion will return status code 204. .. code-block:: http DELETE /api/project-permissions/42/ HTTP/1.1 Authorization: T...
python
def destroy(self, request, *args, **kwargs): """ To remove a user from a project, delete corresponding connection (**url** field). Successful deletion will return status code 204. .. code-block:: http DELETE /api/project-permissions/42/ HTTP/1.1 Authorization: T...
[ "def", "destroy", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "ProjectPermissionViewSet", ",", "self", ")", ".", "destroy", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To remove a user from a project, delete corresponding connection (**url** field). Successful deletion will return status code 204. .. code-block:: http DELETE /api/project-permissions/42/ HTTP/1.1 Authorization: Token 95a688962bf68678fd4c8cec4d138ddd9493c93b Host: e...
[ "To", "remove", "a", "user", "from", "a", "project", "delete", "corresponding", "connection", "(", "**", "url", "**", "field", ")", ".", "Successful", "deletion", "will", "return", "status", "code", "204", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L640-L651
train
opennode/waldur-core
waldur_core/structure/views.py
CustomerPermissionViewSet.list
def list(self, request, *args, **kwargs): """ Each customer is associated with a group of users that represent customer owners. The link is maintained through **api/customer-permissions/** endpoint. To list all visible links, run a **GET** query against a list. Response will con...
python
def list(self, request, *args, **kwargs): """ Each customer is associated with a group of users that represent customer owners. The link is maintained through **api/customer-permissions/** endpoint. To list all visible links, run a **GET** query against a list. Response will con...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "CustomerPermissionViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Each customer is associated with a group of users that represent customer owners. The link is maintained through **api/customer-permissions/** endpoint. To list all visible links, run a **GET** query against a list. Response will contain a list of customer owners and their brief data. ...
[ "Each", "customer", "is", "associated", "with", "a", "group", "of", "users", "that", "represent", "customer", "owners", ".", "The", "link", "is", "maintained", "through", "**", "api", "/", "customer", "-", "permissions", "/", "**", "endpoint", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L689-L712
train
opennode/waldur-core
waldur_core/structure/views.py
CustomerPermissionViewSet.retrieve
def retrieve(self, request, *args, **kwargs): """ To remove a user from a customer owner group, delete corresponding connection (**url** field). Successful deletion will return status code 204. .. code-block:: http DELETE /api/customer-permissions/71/ HTTP/1.1 A...
python
def retrieve(self, request, *args, **kwargs): """ To remove a user from a customer owner group, delete corresponding connection (**url** field). Successful deletion will return status code 204. .. code-block:: http DELETE /api/customer-permissions/71/ HTTP/1.1 A...
[ "def", "retrieve", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "CustomerPermissionViewSet", ",", "self", ")", ".", "retrieve", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")...
To remove a user from a customer owner group, delete corresponding connection (**url** field). Successful deletion will return status code 204. .. code-block:: http DELETE /api/customer-permissions/71/ HTTP/1.1 Authorization: Token 95a688962bf68678fd4c8cec4d138ddd9493c93b ...
[ "To", "remove", "a", "user", "from", "a", "customer", "owner", "group", "delete", "corresponding", "connection", "(", "**", "url", "**", "field", ")", ".", "Successful", "deletion", "will", "return", "status", "code", "204", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L714-L725
train
opennode/waldur-core
waldur_core/structure/views.py
CreationTimeStatsView.list
def list(self, request, *args, **kwargs): """ Available request parameters: - ?type=type_of_statistics_objects (required. Have to be from the list: 'customer', 'project') - ?from=timestamp (default: now - 30 days, for example: 1415910025) - ?to=timestamp (default: now, for examp...
python
def list(self, request, *args, **kwargs): """ Available request parameters: - ?type=type_of_statistics_objects (required. Have to be from the list: 'customer', 'project') - ?from=timestamp (default: now - 30 days, for example: 1415910025) - ?to=timestamp (default: now, for examp...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "CreationTimeStatsView", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Available request parameters: - ?type=type_of_statistics_objects (required. Have to be from the list: 'customer', 'project') - ?from=timestamp (default: now - 30 days, for example: 1415910025) - ?to=timestamp (default: now, for example: 1415912625) - ?datapoints=how many data points hav...
[ "Available", "request", "parameters", ":" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L757-L780
train
opennode/waldur-core
waldur_core/structure/views.py
SshKeyViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of SSH keys, run **GET** against */api/keys/* as authenticated user. A new SSH key can be created by any active users. Example of a valid request: .. code-block:: http POST /api/keys/ HTTP/1.1 Content-...
python
def list(self, request, *args, **kwargs): """ To get a list of SSH keys, run **GET** against */api/keys/* as authenticated user. A new SSH key can be created by any active users. Example of a valid request: .. code-block:: http POST /api/keys/ HTTP/1.1 Content-...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "SshKeyViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To get a list of SSH keys, run **GET** against */api/keys/* as authenticated user. A new SSH key can be created by any active users. Example of a valid request: .. code-block:: http POST /api/keys/ HTTP/1.1 Content-Type: application/json Accept: application/json ...
[ "To", "get", "a", "list", "of", "SSH", "keys", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "keys", "/", "*", "as", "authenticated", "user", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L816-L839
train
opennode/waldur-core
waldur_core/structure/views.py
ServiceSettingsViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of service settings, run **GET** against */api/service-settings/* as an authenticated user. Only settings owned by this user or shared settings will be listed. Supported filters are: - ?name=<text> - partial matching u...
python
def list(self, request, *args, **kwargs): """ To get a list of service settings, run **GET** against */api/service-settings/* as an authenticated user. Only settings owned by this user or shared settings will be listed. Supported filters are: - ?name=<text> - partial matching u...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "ServiceSettingsViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To get a list of service settings, run **GET** against */api/service-settings/* as an authenticated user. Only settings owned by this user or shared settings will be listed. Supported filters are: - ?name=<text> - partial matching used for searching - ?type=<type> - choices: OpenStack,...
[ "To", "get", "a", "list", "of", "service", "settings", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "service", "-", "settings", "/", "*", "as", "an", "authenticated", "user", ".", "Only", "settings", "owned", "by", "this", "user", "or", ...
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L863-L875
train
opennode/waldur-core
waldur_core/structure/views.py
ServiceSettingsViewSet.can_user_update_settings
def can_user_update_settings(request, view, obj=None): """ Only staff can update shared settings, otherwise user has to be an owner of the settings.""" if obj is None: return # TODO [TM:3/21/17] clean it up after WAL-634. Clean up service settings update tests as well. if ob...
python
def can_user_update_settings(request, view, obj=None): """ Only staff can update shared settings, otherwise user has to be an owner of the settings.""" if obj is None: return # TODO [TM:3/21/17] clean it up after WAL-634. Clean up service settings update tests as well. if ob...
[ "def", "can_user_update_settings", "(", "request", ",", "view", ",", "obj", "=", "None", ")", ":", "if", "obj", "is", "None", ":", "return", "# TODO [TM:3/21/17] clean it up after WAL-634. Clean up service settings update tests as well.", "if", "obj", ".", "customer", "...
Only staff can update shared settings, otherwise user has to be an owner of the settings.
[ "Only", "staff", "can", "update", "shared", "settings", "otherwise", "user", "has", "to", "be", "an", "owner", "of", "the", "settings", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L877-L886
train
opennode/waldur-core
waldur_core/structure/views.py
ServiceSettingsViewSet.update
def update(self, request, *args, **kwargs): """ To update service settings, issue a **PUT** or **PATCH** to */api/service-settings/<uuid>/* as a customer owner. You are allowed to change name and credentials only. Example of a request: .. code-block:: http PATCH /a...
python
def update(self, request, *args, **kwargs): """ To update service settings, issue a **PUT** or **PATCH** to */api/service-settings/<uuid>/* as a customer owner. You are allowed to change name and credentials only. Example of a request: .. code-block:: http PATCH /a...
[ "def", "update", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "ServiceSettingsViewSet", ",", "self", ")", ".", "update", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To update service settings, issue a **PUT** or **PATCH** to */api/service-settings/<uuid>/* as a customer owner. You are allowed to change name and credentials only. Example of a request: .. code-block:: http PATCH /api/service-settings/9079705c17d64e6aa0af2e619b0e0702/ HTTP/1.1 ...
[ "To", "update", "service", "settings", "issue", "a", "**", "PUT", "**", "or", "**", "PATCH", "**", "to", "*", "/", "api", "/", "service", "-", "settings", "/", "<uuid", ">", "/", "*", "as", "a", "customer", "owner", ".", "You", "are", "allowed", "t...
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L888-L908
train
opennode/waldur-core
waldur_core/structure/views.py
ServiceSettingsViewSet.stats
def stats(self, request, uuid=None): """ This endpoint returns allocation of resources for current service setting. Answer is service-specific dictionary. Example output for OpenStack: * vcpu - maximum number of vCPUs (from hypervisors) * vcpu_quota - maximum number of vCPUs(fro...
python
def stats(self, request, uuid=None): """ This endpoint returns allocation of resources for current service setting. Answer is service-specific dictionary. Example output for OpenStack: * vcpu - maximum number of vCPUs (from hypervisors) * vcpu_quota - maximum number of vCPUs(fro...
[ "def", "stats", "(", "self", ",", "request", ",", "uuid", "=", "None", ")", ":", "service_settings", "=", "self", ".", "get_object", "(", ")", "backend", "=", "service_settings", ".", "get_backend", "(", ")", "try", ":", "stats", "=", "backend", ".", "...
This endpoint returns allocation of resources for current service setting. Answer is service-specific dictionary. Example output for OpenStack: * vcpu - maximum number of vCPUs (from hypervisors) * vcpu_quota - maximum number of vCPUs(from quotas) * vcpu_usage - current number of used v...
[ "This", "endpoint", "returns", "allocation", "of", "resources", "for", "current", "service", "setting", ".", "Answer", "is", "service", "-", "specific", "dictionary", ".", "Example", "output", "for", "OpenStack", ":" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L914-L952
train
opennode/waldur-core
waldur_core/structure/views.py
ResourceSummaryViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of supported resources' actions, run **OPTIONS** against */api/<resource_url>/* as an authenticated user. It is possible to filter and order by resource-specific fields, but this filters will be applied only to resource...
python
def list(self, request, *args, **kwargs): """ To get a list of supported resources' actions, run **OPTIONS** against */api/<resource_url>/* as an authenticated user. It is possible to filter and order by resource-specific fields, but this filters will be applied only to resource...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "ResourceSummaryViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To get a list of supported resources' actions, run **OPTIONS** against */api/<resource_url>/* as an authenticated user. It is possible to filter and order by resource-specific fields, but this filters will be applied only to resources that support such filtering. For example it is possible to s...
[ "To", "get", "a", "list", "of", "supported", "resources", "actions", "run", "**", "OPTIONS", "**", "against", "*", "/", "api", "/", "<resource_url", ">", "/", "*", "as", "an", "authenticated", "user", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L1029-L1128
train
opennode/waldur-core
waldur_core/structure/views.py
ResourceSummaryViewSet.count
def count(self, request): """ Count resources by type. Example output: .. code-block:: javascript { "Amazon.Instance": 0, "GitLab.Project": 3, "Azure.VirtualMachine": 0, "DigitalOcean.Droplet": 0, "Open...
python
def count(self, request): """ Count resources by type. Example output: .. code-block:: javascript { "Amazon.Instance": 0, "GitLab.Project": 3, "Azure.VirtualMachine": 0, "DigitalOcean.Droplet": 0, "Open...
[ "def", "count", "(", "self", ",", "request", ")", ":", "queryset", "=", "self", ".", "filter_queryset", "(", "self", ".", "get_queryset", "(", ")", ")", "return", "Response", "(", "{", "SupportedServices", ".", "get_name_for_model", "(", "qs", ".", "model"...
Count resources by type. Example output: .. code-block:: javascript { "Amazon.Instance": 0, "GitLab.Project": 3, "Azure.VirtualMachine": 0, "DigitalOcean.Droplet": 0, "OpenStack.Instance": 0, "GitLab.Gr...
[ "Count", "resources", "by", "type", ".", "Example", "output", ":" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L1131-L1148
train
opennode/waldur-core
waldur_core/structure/views.py
ServicesViewSet.list
def list(self, request, *args, **kwargs): """ Filter services by type ^^^^^^^^^^^^^^^^^^^^^^^ It is possible to filter services by their types. Example: /api/services/?service_type=DigitalOcean&service_type=OpenStack """ return super(ServicesViewSet, self).lis...
python
def list(self, request, *args, **kwargs): """ Filter services by type ^^^^^^^^^^^^^^^^^^^^^^^ It is possible to filter services by their types. Example: /api/services/?service_type=DigitalOcean&service_type=OpenStack """ return super(ServicesViewSet, self).lis...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "ServicesViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Filter services by type ^^^^^^^^^^^^^^^^^^^^^^^ It is possible to filter services by their types. Example: /api/services/?service_type=DigitalOcean&service_type=OpenStack
[ "Filter", "services", "by", "type", "^^^^^^^^^^^^^^^^^^^^^^^" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L1172-L1181
train
opennode/waldur-core
waldur_core/structure/views.py
BaseServiceViewSet.list
def list(self, request, *args, **kwargs): """ To list all services without regard to its type, run **GET** against */api/services/* as an authenticated user. To list services of specific type issue **GET** to specific endpoint from a list above as a customer owner. Individual endpoint u...
python
def list(self, request, *args, **kwargs): """ To list all services without regard to its type, run **GET** against */api/services/* as an authenticated user. To list services of specific type issue **GET** to specific endpoint from a list above as a customer owner. Individual endpoint u...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "BaseServiceViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To list all services without regard to its type, run **GET** against */api/services/* as an authenticated user. To list services of specific type issue **GET** to specific endpoint from a list above as a customer owner. Individual endpoint used for every service type. To create a service, issu...
[ "To", "list", "all", "services", "without", "regard", "to", "its", "type", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "services", "/", "*", "as", "an", "authenticated", "user", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L1369-L1413
train
opennode/waldur-core
waldur_core/structure/views.py
BaseServiceViewSet._require_staff_for_shared_settings
def _require_staff_for_shared_settings(request, view, obj=None): """ Allow to execute action only if service settings are not shared or user is staff """ if obj is None: return if obj.settings.shared and not request.user.is_staff: raise PermissionDenied(_('Only staff use...
python
def _require_staff_for_shared_settings(request, view, obj=None): """ Allow to execute action only if service settings are not shared or user is staff """ if obj is None: return if obj.settings.shared and not request.user.is_staff: raise PermissionDenied(_('Only staff use...
[ "def", "_require_staff_for_shared_settings", "(", "request", ",", "view", ",", "obj", "=", "None", ")", ":", "if", "obj", "is", "None", ":", "return", "if", "obj", ".", "settings", ".", "shared", "and", "not", "request", ".", "user", ".", "is_staff", ":"...
Allow to execute action only if service settings are not shared or user is staff
[ "Allow", "to", "execute", "action", "only", "if", "service", "settings", "are", "not", "shared", "or", "user", "is", "staff" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L1452-L1458
train
opennode/waldur-core
waldur_core/structure/views.py
BaseServiceViewSet.link
def link(self, request, uuid=None): """ To get a list of resources available for import, run **GET** against */<service_endpoint>/link/* as an authenticated user. Optionally project_uuid parameter can be supplied for services requiring it like OpenStack. To import (link with Wal...
python
def link(self, request, uuid=None): """ To get a list of resources available for import, run **GET** against */<service_endpoint>/link/* as an authenticated user. Optionally project_uuid parameter can be supplied for services requiring it like OpenStack. To import (link with Wal...
[ "def", "link", "(", "self", ",", "request", ",", "uuid", "=", "None", ")", ":", "service", "=", "self", ".", "get_object", "(", ")", "if", "self", ".", "request", ".", "method", "==", "'GET'", ":", "try", ":", "backend", "=", "self", ".", "get_back...
To get a list of resources available for import, run **GET** against */<service_endpoint>/link/* as an authenticated user. Optionally project_uuid parameter can be supplied for services requiring it like OpenStack. To import (link with Waldur) resource issue **POST** against the same endpoint w...
[ "To", "get", "a", "list", "of", "resources", "available", "for", "import", "run", "**", "GET", "**", "against", "*", "/", "<service_endpoint", ">", "/", "link", "/", "*", "as", "an", "authenticated", "user", ".", "Optionally", "project_uuid", "parameter", ...
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L1461-L1515
train
opennode/waldur-core
waldur_core/structure/views.py
BaseServiceViewSet.unlink
def unlink(self, request, uuid=None): """ Unlink all related resources, service project link and service itself. """ service = self.get_object() service.unlink_descendants() self.perform_destroy(service) return Response(status=status.HTTP_204_NO_CONTENT)
python
def unlink(self, request, uuid=None): """ Unlink all related resources, service project link and service itself. """ service = self.get_object() service.unlink_descendants() self.perform_destroy(service) return Response(status=status.HTTP_204_NO_CONTENT)
[ "def", "unlink", "(", "self", ",", "request", ",", "uuid", "=", "None", ")", ":", "service", "=", "self", ".", "get_object", "(", ")", "service", ".", "unlink_descendants", "(", ")", "self", ".", "perform_destroy", "(", "service", ")", "return", "Respons...
Unlink all related resources, service project link and service itself.
[ "Unlink", "all", "related", "resources", "service", "project", "link", "and", "service", "itself", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L1535-L1543
train
opennode/waldur-core
waldur_core/structure/views.py
BaseServiceProjectLinkViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of connections between a project and an service, run **GET** against service_project_link_url as authenticated user. Note that a user can only see connections of a project where a user has a role. If service has `available_for_...
python
def list(self, request, *args, **kwargs): """ To get a list of connections between a project and an service, run **GET** against service_project_link_url as authenticated user. Note that a user can only see connections of a project where a user has a role. If service has `available_for_...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "BaseServiceProjectLinkViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To get a list of connections between a project and an service, run **GET** against service_project_link_url as authenticated user. Note that a user can only see connections of a project where a user has a role. If service has `available_for_all` flag, project-service connections are created automatical...
[ "To", "get", "a", "list", "of", "connections", "between", "a", "project", "and", "an", "service", "run", "**", "GET", "**", "against", "service_project_link_url", "as", "authenticated", "user", ".", "Note", "that", "a", "user", "can", "only", "see", "connect...
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L1560-L1570
train
opennode/waldur-core
waldur_core/structure/views.py
BaseServiceProjectLinkViewSet.retrieve
def retrieve(self, request, *args, **kwargs): """ To remove a link, issue **DELETE** to URL of the corresponding connection as stuff user or customer owner. """ return super(BaseServiceProjectLinkViewSet, self).retrieve(request, *args, **kwargs)
python
def retrieve(self, request, *args, **kwargs): """ To remove a link, issue **DELETE** to URL of the corresponding connection as stuff user or customer owner. """ return super(BaseServiceProjectLinkViewSet, self).retrieve(request, *args, **kwargs)
[ "def", "retrieve", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "BaseServiceProjectLinkViewSet", ",", "self", ")", ".", "retrieve", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ...
To remove a link, issue **DELETE** to URL of the corresponding connection as stuff user or customer owner.
[ "To", "remove", "a", "link", "issue", "**", "DELETE", "**", "to", "URL", "of", "the", "corresponding", "connection", "as", "stuff", "user", "or", "customer", "owner", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/structure/views.py#L1572-L1576
train
opennode/waldur-core
waldur_core/quotas/fields.py
QuotaField.get_aggregator_quotas
def get_aggregator_quotas(self, quota): """ Fetch ancestors quotas that have the same name and are registered as aggregator quotas. """ ancestors = quota.scope.get_quota_ancestors() aggregator_quotas = [] for ancestor in ancestors: for ancestor_quota_field in ancestor.get_quo...
python
def get_aggregator_quotas(self, quota): """ Fetch ancestors quotas that have the same name and are registered as aggregator quotas. """ ancestors = quota.scope.get_quota_ancestors() aggregator_quotas = [] for ancestor in ancestors: for ancestor_quota_field in ancestor.get_quo...
[ "def", "get_aggregator_quotas", "(", "self", ",", "quota", ")", ":", "ancestors", "=", "quota", ".", "scope", ".", "get_quota_ancestors", "(", ")", "aggregator_quotas", "=", "[", "]", "for", "ancestor", "in", "ancestors", ":", "for", "ancestor_quota_field", "i...
Fetch ancestors quotas that have the same name and are registered as aggregator quotas.
[ "Fetch", "ancestors", "quotas", "that", "have", "the", "same", "name", "and", "are", "registered", "as", "aggregator", "quotas", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/quotas/fields.py#L122-L130
train
quora/qcore
qcore/events.py
EventHook.subscribe
def subscribe(self, handler): """Adds a new event handler.""" assert callable(handler), "Invalid handler %s" % handler self.handlers.append(handler)
python
def subscribe(self, handler): """Adds a new event handler.""" assert callable(handler), "Invalid handler %s" % handler self.handlers.append(handler)
[ "def", "subscribe", "(", "self", ",", "handler", ")", ":", "assert", "callable", "(", "handler", ")", ",", "\"Invalid handler %s\"", "%", "handler", "self", ".", "handlers", ".", "append", "(", "handler", ")" ]
Adds a new event handler.
[ "Adds", "a", "new", "event", "handler", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L46-L49
train
quora/qcore
qcore/events.py
EventHook.safe_trigger
def safe_trigger(self, *args): """*Safely* triggers the event by invoking all its handlers, even if few of them raise an exception. If a set of exceptions is raised during handler invocation sequence, this method rethrows the first one. :param args: the arguments to invoke even...
python
def safe_trigger(self, *args): """*Safely* triggers the event by invoking all its handlers, even if few of them raise an exception. If a set of exceptions is raised during handler invocation sequence, this method rethrows the first one. :param args: the arguments to invoke even...
[ "def", "safe_trigger", "(", "self", ",", "*", "args", ")", ":", "error", "=", "None", "# iterate over a copy of the original list because some event handlers", "# may mutate the list", "for", "handler", "in", "list", "(", "self", ".", "handlers", ")", ":", "try", ":...
*Safely* triggers the event by invoking all its handlers, even if few of them raise an exception. If a set of exceptions is raised during handler invocation sequence, this method rethrows the first one. :param args: the arguments to invoke event handlers with.
[ "*", "Safely", "*", "triggers", "the", "event", "by", "invoking", "all", "its", "handlers", "even", "if", "few", "of", "them", "raise", "an", "exception", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L55-L76
train
quora/qcore
qcore/events.py
EventHub.on
def on(self, event, handler): """Attaches the handler to the specified event. @param event: event to attach the handler to. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is passed, its name is used as event key. ...
python
def on(self, event, handler): """Attaches the handler to the specified event. @param event: event to attach the handler to. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is passed, its name is used as event key. ...
[ "def", "on", "(", "self", ",", "event", ",", "handler", ")", ":", "event_hook", "=", "self", ".", "get_or_create", "(", "event", ")", "event_hook", ".", "subscribe", "(", "handler", ")", "return", "self" ]
Attaches the handler to the specified event. @param event: event to attach the handler to. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is passed, its name is used as event key. @param handler: event handler. ...
[ "Attaches", "the", "handler", "to", "the", "specified", "event", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L217-L229
train
quora/qcore
qcore/events.py
EventHub.off
def off(self, event, handler): """Detaches the handler from the specified event. @param event: event to detach the handler to. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is passed, its name is used as event key. ...
python
def off(self, event, handler): """Detaches the handler from the specified event. @param event: event to detach the handler to. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is passed, its name is used as event key. ...
[ "def", "off", "(", "self", ",", "event", ",", "handler", ")", ":", "event_hook", "=", "self", ".", "get_or_create", "(", "event", ")", "event_hook", ".", "unsubscribe", "(", "handler", ")", "return", "self" ]
Detaches the handler from the specified event. @param event: event to detach the handler to. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is passed, its name is used as event key. @param handler: event handler. ...
[ "Detaches", "the", "handler", "from", "the", "specified", "event", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L231-L243
train
quora/qcore
qcore/events.py
EventHub.trigger
def trigger(self, event, *args): """Triggers the specified event by invoking EventHook.trigger under the hood. @param event: event to trigger. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is passed, its name is used ...
python
def trigger(self, event, *args): """Triggers the specified event by invoking EventHook.trigger under the hood. @param event: event to trigger. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is passed, its name is used ...
[ "def", "trigger", "(", "self", ",", "event", ",", "*", "args", ")", ":", "event_hook", "=", "self", ".", "get_or_create", "(", "event", ")", "event_hook", ".", "trigger", "(", "*", "args", ")", "return", "self" ]
Triggers the specified event by invoking EventHook.trigger under the hood. @param event: event to trigger. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is passed, its name is used as event key. @param args: event arg...
[ "Triggers", "the", "specified", "event", "by", "invoking", "EventHook", ".", "trigger", "under", "the", "hood", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L245-L257
train
quora/qcore
qcore/events.py
EventHub.safe_trigger
def safe_trigger(self, event, *args): """Safely triggers the specified event by invoking EventHook.safe_trigger under the hood. @param event: event to trigger. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is ...
python
def safe_trigger(self, event, *args): """Safely triggers the specified event by invoking EventHook.safe_trigger under the hood. @param event: event to trigger. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is ...
[ "def", "safe_trigger", "(", "self", ",", "event", ",", "*", "args", ")", ":", "event_hook", "=", "self", ".", "get_or_create", "(", "event", ")", "event_hook", ".", "safe_trigger", "(", "*", "args", ")", "return", "self" ]
Safely triggers the specified event by invoking EventHook.safe_trigger under the hood. @param event: event to trigger. Any object can be passed as event, but string is preferable. If qcore.EnumBase instance is passed, its name is used as event key. @p...
[ "Safely", "triggers", "the", "specified", "event", "by", "invoking", "EventHook", ".", "safe_trigger", "under", "the", "hood", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L259-L272
train
quora/qcore
qcore/events.py
EventHub.get_or_create
def get_or_create(self, event): """Gets or creates a new event hook for the specified event (key). This method treats qcore.EnumBase-typed event keys specially: enum_member.name is used as key instead of enum instance in case such a key is passed. Note that on/off/trigger/safe_...
python
def get_or_create(self, event): """Gets or creates a new event hook for the specified event (key). This method treats qcore.EnumBase-typed event keys specially: enum_member.name is used as key instead of enum instance in case such a key is passed. Note that on/off/trigger/safe_...
[ "def", "get_or_create", "(", "self", ",", "event", ")", ":", "if", "isinstance", "(", "event", ",", "EnumBase", ")", ":", "event", "=", "event", ".", "short_name", "return", "self", ".", "__dict__", ".", "setdefault", "(", "event", ",", "EventHook", "(",...
Gets or creates a new event hook for the specified event (key). This method treats qcore.EnumBase-typed event keys specially: enum_member.name is used as key instead of enum instance in case such a key is passed. Note that on/off/trigger/safe_trigger methods rely on this method, ...
[ "Gets", "or", "creates", "a", "new", "event", "hook", "for", "the", "specified", "event", "(", "key", ")", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/events.py#L274-L287
train
opennode/waldur-core
waldur_core/users/tasks.py
cancel_expired_invitations
def cancel_expired_invitations(invitations=None): """ Invitation lifetime must be specified in Waldur Core settings with parameter "INVITATION_LIFETIME". If invitation creation time is less than expiration time, the invitation will set as expired. """ expiration_date = timezone.now() - settings.WALD...
python
def cancel_expired_invitations(invitations=None): """ Invitation lifetime must be specified in Waldur Core settings with parameter "INVITATION_LIFETIME". If invitation creation time is less than expiration time, the invitation will set as expired. """ expiration_date = timezone.now() - settings.WALD...
[ "def", "cancel_expired_invitations", "(", "invitations", "=", "None", ")", ":", "expiration_date", "=", "timezone", ".", "now", "(", ")", "-", "settings", ".", "WALDUR_CORE", "[", "'INVITATION_LIFETIME'", "]", "if", "not", "invitations", ":", "invitations", "=",...
Invitation lifetime must be specified in Waldur Core settings with parameter "INVITATION_LIFETIME". If invitation creation time is less than expiration time, the invitation will set as expired.
[ "Invitation", "lifetime", "must", "be", "specified", "in", "Waldur", "Core", "settings", "with", "parameter", "INVITATION_LIFETIME", ".", "If", "invitation", "creation", "time", "is", "less", "than", "expiration", "time", "the", "invitation", "will", "set", "as", ...
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/users/tasks.py#L19-L28
train
tintinweb/ethereum-input-decoder
ethereum_input_decoder/decoder.py
FourByteDirectory.get_pseudo_abi_for_input
def get_pseudo_abi_for_input(s, timeout=None, proxies=None): """ Lookup sighash from 4bytes.directory, create a pseudo api and try to decode it with the parsed abi. May return multiple results as sighashes may collide. :param s: bytes input :return: pseudo abi for method ...
python
def get_pseudo_abi_for_input(s, timeout=None, proxies=None): """ Lookup sighash from 4bytes.directory, create a pseudo api and try to decode it with the parsed abi. May return multiple results as sighashes may collide. :param s: bytes input :return: pseudo abi for method ...
[ "def", "get_pseudo_abi_for_input", "(", "s", ",", "timeout", "=", "None", ",", "proxies", "=", "None", ")", ":", "sighash", "=", "Utils", ".", "bytes_to_str", "(", "s", "[", ":", "4", "]", ")", "for", "pseudo_abi", "in", "FourByteDirectory", ".", "get_ps...
Lookup sighash from 4bytes.directory, create a pseudo api and try to decode it with the parsed abi. May return multiple results as sighashes may collide. :param s: bytes input :return: pseudo abi for method
[ "Lookup", "sighash", "from", "4bytes", ".", "directory", "create", "a", "pseudo", "api", "and", "try", "to", "decode", "it", "with", "the", "parsed", "abi", ".", "May", "return", "multiple", "results", "as", "sighashes", "may", "collide", ".", ":", "param"...
aa96623e352fe096b6679cc3ea10ef62a260a711
https://github.com/tintinweb/ethereum-input-decoder/blob/aa96623e352fe096b6679cc3ea10ef62a260a711/ethereum_input_decoder/decoder.py#L70-L85
train
tintinweb/ethereum-input-decoder
ethereum_input_decoder/decoder.py
ContractAbi._prepare_abi
def _prepare_abi(self, jsonabi): """ Prepare the contract json abi for sighash lookups and fast access :param jsonabi: contracts abi in json format :return: """ self.signatures = {} for element_description in jsonabi: abi_e = AbiMethod(element_descrip...
python
def _prepare_abi(self, jsonabi): """ Prepare the contract json abi for sighash lookups and fast access :param jsonabi: contracts abi in json format :return: """ self.signatures = {} for element_description in jsonabi: abi_e = AbiMethod(element_descrip...
[ "def", "_prepare_abi", "(", "self", ",", "jsonabi", ")", ":", "self", ".", "signatures", "=", "{", "}", "for", "element_description", "in", "jsonabi", ":", "abi_e", "=", "AbiMethod", "(", "element_description", ")", "if", "abi_e", "[", "\"type\"", "]", "==...
Prepare the contract json abi for sighash lookups and fast access :param jsonabi: contracts abi in json format :return:
[ "Prepare", "the", "contract", "json", "abi", "for", "sighash", "lookups", "and", "fast", "access" ]
aa96623e352fe096b6679cc3ea10ef62a260a711
https://github.com/tintinweb/ethereum-input-decoder/blob/aa96623e352fe096b6679cc3ea10ef62a260a711/ethereum_input_decoder/decoder.py#L101-L125
train
tintinweb/ethereum-input-decoder
ethereum_input_decoder/decoder.py
ContractAbi.describe_constructor
def describe_constructor(self, s): """ Describe the input bytesequence (constructor arguments) s based on the loaded contract abi definition :param s: bytes constructor arguments :return: AbiMethod instance """ method = self.signatures.get(b"__constructor__") ...
python
def describe_constructor(self, s): """ Describe the input bytesequence (constructor arguments) s based on the loaded contract abi definition :param s: bytes constructor arguments :return: AbiMethod instance """ method = self.signatures.get(b"__constructor__") ...
[ "def", "describe_constructor", "(", "self", ",", "s", ")", ":", "method", "=", "self", ".", "signatures", ".", "get", "(", "b\"__constructor__\"", ")", "if", "not", "method", ":", "# constructor not available", "m", "=", "AbiMethod", "(", "{", "\"type\"", ":...
Describe the input bytesequence (constructor arguments) s based on the loaded contract abi definition :param s: bytes constructor arguments :return: AbiMethod instance
[ "Describe", "the", "input", "bytesequence", "(", "constructor", "arguments", ")", "s", "based", "on", "the", "loaded", "contract", "abi", "definition" ]
aa96623e352fe096b6679cc3ea10ef62a260a711
https://github.com/tintinweb/ethereum-input-decoder/blob/aa96623e352fe096b6679cc3ea10ef62a260a711/ethereum_input_decoder/decoder.py#L127-L153
train
tintinweb/ethereum-input-decoder
ethereum_input_decoder/decoder.py
ContractAbi.describe_input
def describe_input(self, s): """ Describe the input bytesequence s based on the loaded contract abi definition :param s: bytes input :return: AbiMethod instance """ signatures = self.signatures.items() for sighash, method in signatures: if sighash is...
python
def describe_input(self, s): """ Describe the input bytesequence s based on the loaded contract abi definition :param s: bytes input :return: AbiMethod instance """ signatures = self.signatures.items() for sighash, method in signatures: if sighash is...
[ "def", "describe_input", "(", "self", ",", "s", ")", ":", "signatures", "=", "self", ".", "signatures", ".", "items", "(", ")", "for", "sighash", ",", "method", "in", "signatures", ":", "if", "sighash", "is", "None", "or", "sighash", ".", "startswith", ...
Describe the input bytesequence s based on the loaded contract abi definition :param s: bytes input :return: AbiMethod instance
[ "Describe", "the", "input", "bytesequence", "s", "based", "on", "the", "loaded", "contract", "abi", "definition" ]
aa96623e352fe096b6679cc3ea10ef62a260a711
https://github.com/tintinweb/ethereum-input-decoder/blob/aa96623e352fe096b6679cc3ea10ef62a260a711/ethereum_input_decoder/decoder.py#L155-L197
train
tintinweb/ethereum-input-decoder
ethereum_input_decoder/decoder.py
AbiMethod.from_input_lookup
def from_input_lookup(s): """ Return a new AbiMethod object from an input stream :param s: binary input :return: new AbiMethod object matching the provided input stream """ for pseudo_abi in FourByteDirectory.get_pseudo_abi_for_input(s): method = AbiMethod(pse...
python
def from_input_lookup(s): """ Return a new AbiMethod object from an input stream :param s: binary input :return: new AbiMethod object matching the provided input stream """ for pseudo_abi in FourByteDirectory.get_pseudo_abi_for_input(s): method = AbiMethod(pse...
[ "def", "from_input_lookup", "(", "s", ")", ":", "for", "pseudo_abi", "in", "FourByteDirectory", ".", "get_pseudo_abi_for_input", "(", "s", ")", ":", "method", "=", "AbiMethod", "(", "pseudo_abi", ")", "types_def", "=", "pseudo_abi", "[", "\"inputs\"", "]", "ty...
Return a new AbiMethod object from an input stream :param s: binary input :return: new AbiMethod object matching the provided input stream
[ "Return", "a", "new", "AbiMethod", "object", "from", "an", "input", "stream", ":", "param", "s", ":", "binary", "input", ":", "return", ":", "new", "AbiMethod", "object", "matching", "the", "provided", "input", "stream" ]
aa96623e352fe096b6679cc3ea10ef62a260a711
https://github.com/tintinweb/ethereum-input-decoder/blob/aa96623e352fe096b6679cc3ea10ef62a260a711/ethereum_input_decoder/decoder.py#L213-L230
train
quora/qcore
qcore/asserts.py
assert_is
def assert_is(expected, actual, message=None, extra=None): """Raises an AssertionError if expected is not actual.""" assert expected is actual, _assert_fail_message( message, expected, actual, "is not", extra )
python
def assert_is(expected, actual, message=None, extra=None): """Raises an AssertionError if expected is not actual.""" assert expected is actual, _assert_fail_message( message, expected, actual, "is not", extra )
[ "def", "assert_is", "(", "expected", ",", "actual", ",", "message", "=", "None", ",", "extra", "=", "None", ")", ":", "assert", "expected", "is", "actual", ",", "_assert_fail_message", "(", "message", ",", "expected", ",", "actual", ",", "\"is not\"", ",",...
Raises an AssertionError if expected is not actual.
[ "Raises", "an", "AssertionError", "if", "expected", "is", "not", "actual", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L83-L87
train
quora/qcore
qcore/asserts.py
assert_is_not
def assert_is_not(expected, actual, message=None, extra=None): """Raises an AssertionError if expected is actual.""" assert expected is not actual, _assert_fail_message( message, expected, actual, "is", extra )
python
def assert_is_not(expected, actual, message=None, extra=None): """Raises an AssertionError if expected is actual.""" assert expected is not actual, _assert_fail_message( message, expected, actual, "is", extra )
[ "def", "assert_is_not", "(", "expected", ",", "actual", ",", "message", "=", "None", ",", "extra", "=", "None", ")", ":", "assert", "expected", "is", "not", "actual", ",", "_assert_fail_message", "(", "message", ",", "expected", ",", "actual", ",", "\"is\"...
Raises an AssertionError if expected is actual.
[ "Raises", "an", "AssertionError", "if", "expected", "is", "actual", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L90-L94
train
quora/qcore
qcore/asserts.py
assert_is_instance
def assert_is_instance(value, types, message=None, extra=None): """Raises an AssertionError if value is not an instance of type(s).""" assert isinstance(value, types), _assert_fail_message( message, value, types, "is not an instance of", extra )
python
def assert_is_instance(value, types, message=None, extra=None): """Raises an AssertionError if value is not an instance of type(s).""" assert isinstance(value, types), _assert_fail_message( message, value, types, "is not an instance of", extra )
[ "def", "assert_is_instance", "(", "value", ",", "types", ",", "message", "=", "None", ",", "extra", "=", "None", ")", ":", "assert", "isinstance", "(", "value", ",", "types", ")", ",", "_assert_fail_message", "(", "message", ",", "value", ",", "types", "...
Raises an AssertionError if value is not an instance of type(s).
[ "Raises", "an", "AssertionError", "if", "value", "is", "not", "an", "instance", "of", "type", "(", "s", ")", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L97-L101
train
quora/qcore
qcore/asserts.py
assert_eq
def assert_eq(expected, actual, message=None, tolerance=None, extra=None): """Raises an AssertionError if expected != actual. If tolerance is specified, raises an AssertionError if either - expected or actual isn't a number, or - the difference between expected and actual is larger than the tolerance. ...
python
def assert_eq(expected, actual, message=None, tolerance=None, extra=None): """Raises an AssertionError if expected != actual. If tolerance is specified, raises an AssertionError if either - expected or actual isn't a number, or - the difference between expected and actual is larger than the tolerance. ...
[ "def", "assert_eq", "(", "expected", ",", "actual", ",", "message", "=", "None", ",", "tolerance", "=", "None", ",", "extra", "=", "None", ")", ":", "if", "tolerance", "is", "None", ":", "assert", "expected", "==", "actual", ",", "_assert_fail_message", ...
Raises an AssertionError if expected != actual. If tolerance is specified, raises an AssertionError if either - expected or actual isn't a number, or - the difference between expected and actual is larger than the tolerance.
[ "Raises", "an", "AssertionError", "if", "expected", "!", "=", "actual", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L104-L130
train
quora/qcore
qcore/asserts.py
assert_dict_eq
def assert_dict_eq(expected, actual, number_tolerance=None, dict_path=[]): """Asserts that two dictionaries are equal, producing a custom message if they are not.""" assert_is_instance(expected, dict) assert_is_instance(actual, dict) expected_keys = set(expected.keys()) actual_keys = set(actual.key...
python
def assert_dict_eq(expected, actual, number_tolerance=None, dict_path=[]): """Asserts that two dictionaries are equal, producing a custom message if they are not.""" assert_is_instance(expected, dict) assert_is_instance(actual, dict) expected_keys = set(expected.keys()) actual_keys = set(actual.key...
[ "def", "assert_dict_eq", "(", "expected", ",", "actual", ",", "number_tolerance", "=", "None", ",", "dict_path", "=", "[", "]", ")", ":", "assert_is_instance", "(", "expected", ",", "dict", ")", "assert_is_instance", "(", "actual", ",", "dict", ")", "expecte...
Asserts that two dictionaries are equal, producing a custom message if they are not.
[ "Asserts", "that", "two", "dictionaries", "are", "equal", "producing", "a", "custom", "message", "if", "they", "are", "not", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L139-L187
train
quora/qcore
qcore/asserts.py
assert_gt
def assert_gt(left, right, message=None, extra=None): """Raises an AssertionError if left_hand <= right_hand.""" assert left > right, _assert_fail_message(message, left, right, "<=", extra)
python
def assert_gt(left, right, message=None, extra=None): """Raises an AssertionError if left_hand <= right_hand.""" assert left > right, _assert_fail_message(message, left, right, "<=", extra)
[ "def", "assert_gt", "(", "left", ",", "right", ",", "message", "=", "None", ",", "extra", "=", "None", ")", ":", "assert", "left", ">", "right", ",", "_assert_fail_message", "(", "message", ",", "left", ",", "right", ",", "\"<=\"", ",", "extra", ")" ]
Raises an AssertionError if left_hand <= right_hand.
[ "Raises", "an", "AssertionError", "if", "left_hand", "<", "=", "right_hand", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L219-L221
train
quora/qcore
qcore/asserts.py
assert_ge
def assert_ge(left, right, message=None, extra=None): """Raises an AssertionError if left_hand < right_hand.""" assert left >= right, _assert_fail_message(message, left, right, "<", extra)
python
def assert_ge(left, right, message=None, extra=None): """Raises an AssertionError if left_hand < right_hand.""" assert left >= right, _assert_fail_message(message, left, right, "<", extra)
[ "def", "assert_ge", "(", "left", ",", "right", ",", "message", "=", "None", ",", "extra", "=", "None", ")", ":", "assert", "left", ">=", "right", ",", "_assert_fail_message", "(", "message", ",", "left", ",", "right", ",", "\"<\"", ",", "extra", ")" ]
Raises an AssertionError if left_hand < right_hand.
[ "Raises", "an", "AssertionError", "if", "left_hand", "<", "right_hand", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L224-L226
train
quora/qcore
qcore/asserts.py
assert_lt
def assert_lt(left, right, message=None, extra=None): """Raises an AssertionError if left_hand >= right_hand.""" assert left < right, _assert_fail_message(message, left, right, ">=", extra)
python
def assert_lt(left, right, message=None, extra=None): """Raises an AssertionError if left_hand >= right_hand.""" assert left < right, _assert_fail_message(message, left, right, ">=", extra)
[ "def", "assert_lt", "(", "left", ",", "right", ",", "message", "=", "None", ",", "extra", "=", "None", ")", ":", "assert", "left", "<", "right", ",", "_assert_fail_message", "(", "message", ",", "left", ",", "right", ",", "\">=\"", ",", "extra", ")" ]
Raises an AssertionError if left_hand >= right_hand.
[ "Raises", "an", "AssertionError", "if", "left_hand", ">", "=", "right_hand", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L229-L231
train
quora/qcore
qcore/asserts.py
assert_le
def assert_le(left, right, message=None, extra=None): """Raises an AssertionError if left_hand > right_hand.""" assert left <= right, _assert_fail_message(message, left, right, ">", extra)
python
def assert_le(left, right, message=None, extra=None): """Raises an AssertionError if left_hand > right_hand.""" assert left <= right, _assert_fail_message(message, left, right, ">", extra)
[ "def", "assert_le", "(", "left", ",", "right", ",", "message", "=", "None", ",", "extra", "=", "None", ")", ":", "assert", "left", "<=", "right", ",", "_assert_fail_message", "(", "message", ",", "left", ",", "right", ",", "\">\"", ",", "extra", ")" ]
Raises an AssertionError if left_hand > right_hand.
[ "Raises", "an", "AssertionError", "if", "left_hand", ">", "right_hand", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L234-L236
train
quora/qcore
qcore/asserts.py
assert_in
def assert_in(obj, seq, message=None, extra=None): """Raises an AssertionError if obj is not in seq.""" assert obj in seq, _assert_fail_message(message, obj, seq, "is not in", extra)
python
def assert_in(obj, seq, message=None, extra=None): """Raises an AssertionError if obj is not in seq.""" assert obj in seq, _assert_fail_message(message, obj, seq, "is not in", extra)
[ "def", "assert_in", "(", "obj", ",", "seq", ",", "message", "=", "None", ",", "extra", "=", "None", ")", ":", "assert", "obj", "in", "seq", ",", "_assert_fail_message", "(", "message", ",", "obj", ",", "seq", ",", "\"is not in\"", ",", "extra", ")" ]
Raises an AssertionError if obj is not in seq.
[ "Raises", "an", "AssertionError", "if", "obj", "is", "not", "in", "seq", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L239-L241
train
quora/qcore
qcore/asserts.py
assert_not_in
def assert_not_in(obj, seq, message=None, extra=None): """Raises an AssertionError if obj is in iter.""" # for very long strings, provide a truncated error if isinstance(seq, six.string_types) and obj in seq and len(seq) > 200: index = seq.find(obj) start_index = index - 50 if start_...
python
def assert_not_in(obj, seq, message=None, extra=None): """Raises an AssertionError if obj is in iter.""" # for very long strings, provide a truncated error if isinstance(seq, six.string_types) and obj in seq and len(seq) > 200: index = seq.find(obj) start_index = index - 50 if start_...
[ "def", "assert_not_in", "(", "obj", ",", "seq", ",", "message", "=", "None", ",", "extra", "=", "None", ")", ":", "# for very long strings, provide a truncated error", "if", "isinstance", "(", "seq", ",", "six", ".", "string_types", ")", "and", "obj", "in", ...
Raises an AssertionError if obj is in iter.
[ "Raises", "an", "AssertionError", "if", "obj", "is", "in", "iter", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L244-L260
train
quora/qcore
qcore/asserts.py
assert_in_with_tolerance
def assert_in_with_tolerance(obj, seq, tolerance, message=None, extra=None): """Raises an AssertionError if obj is not in seq using assert_eq cmp.""" for i in seq: try: assert_eq(obj, i, tolerance=tolerance, message=message, extra=extra) return except AssertionError: ...
python
def assert_in_with_tolerance(obj, seq, tolerance, message=None, extra=None): """Raises an AssertionError if obj is not in seq using assert_eq cmp.""" for i in seq: try: assert_eq(obj, i, tolerance=tolerance, message=message, extra=extra) return except AssertionError: ...
[ "def", "assert_in_with_tolerance", "(", "obj", ",", "seq", ",", "tolerance", ",", "message", "=", "None", ",", "extra", "=", "None", ")", ":", "for", "i", "in", "seq", ":", "try", ":", "assert_eq", "(", "obj", ",", "i", ",", "tolerance", "=", "tolera...
Raises an AssertionError if obj is not in seq using assert_eq cmp.
[ "Raises", "an", "AssertionError", "if", "obj", "is", "not", "in", "seq", "using", "assert_eq", "cmp", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L263-L271
train
quora/qcore
qcore/asserts.py
assert_is_substring
def assert_is_substring(substring, subject, message=None, extra=None): """Raises an AssertionError if substring is not a substring of subject.""" assert ( (subject is not None) and (substring is not None) and (subject.find(substring) != -1) ), _assert_fail_message(message, substring,...
python
def assert_is_substring(substring, subject, message=None, extra=None): """Raises an AssertionError if substring is not a substring of subject.""" assert ( (subject is not None) and (substring is not None) and (subject.find(substring) != -1) ), _assert_fail_message(message, substring,...
[ "def", "assert_is_substring", "(", "substring", ",", "subject", ",", "message", "=", "None", ",", "extra", "=", "None", ")", ":", "assert", "(", "(", "subject", "is", "not", "None", ")", "and", "(", "substring", "is", "not", "None", ")", "and", "(", ...
Raises an AssertionError if substring is not a substring of subject.
[ "Raises", "an", "AssertionError", "if", "substring", "is", "not", "a", "substring", "of", "subject", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L274-L280
train
quora/qcore
qcore/asserts.py
assert_is_not_substring
def assert_is_not_substring(substring, subject, message=None, extra=None): """Raises an AssertionError if substring is a substring of subject.""" assert ( (subject is not None) and (substring is not None) and (subject.find(substring) == -1) ), _assert_fail_message(message, substring,...
python
def assert_is_not_substring(substring, subject, message=None, extra=None): """Raises an AssertionError if substring is a substring of subject.""" assert ( (subject is not None) and (substring is not None) and (subject.find(substring) == -1) ), _assert_fail_message(message, substring,...
[ "def", "assert_is_not_substring", "(", "substring", ",", "subject", ",", "message", "=", "None", ",", "extra", "=", "None", ")", ":", "assert", "(", "(", "subject", "is", "not", "None", ")", "and", "(", "substring", "is", "not", "None", ")", "and", "("...
Raises an AssertionError if substring is a substring of subject.
[ "Raises", "an", "AssertionError", "if", "substring", "is", "a", "substring", "of", "subject", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L283-L289
train
quora/qcore
qcore/asserts.py
assert_unordered_list_eq
def assert_unordered_list_eq(expected, actual, message=None): """Raises an AssertionError if the objects contained in expected are not equal to the objects contained in actual without regard to their order. This takes quadratic time in the umber of elements in actual; don't use it for very long lists....
python
def assert_unordered_list_eq(expected, actual, message=None): """Raises an AssertionError if the objects contained in expected are not equal to the objects contained in actual without regard to their order. This takes quadratic time in the umber of elements in actual; don't use it for very long lists....
[ "def", "assert_unordered_list_eq", "(", "expected", ",", "actual", ",", "message", "=", "None", ")", ":", "missing_in_actual", "=", "[", "]", "missing_in_expected", "=", "list", "(", "actual", ")", "for", "x", "in", "expected", ":", "try", ":", "missing_in_e...
Raises an AssertionError if the objects contained in expected are not equal to the objects contained in actual without regard to their order. This takes quadratic time in the umber of elements in actual; don't use it for very long lists.
[ "Raises", "an", "AssertionError", "if", "the", "objects", "contained", "in", "expected", "are", "not", "equal", "to", "the", "objects", "contained", "in", "actual", "without", "regard", "to", "their", "order", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/asserts.py#L292-L314
train
opennode/waldur-core
waldur_core/logging/elasticsearch_client.py
_execute_if_not_empty
def _execute_if_not_empty(func): """ Execute function only if one of input parameters is not empty """ def wrapper(*args, **kwargs): if any(args[1:]) or any(kwargs.items()): return func(*args, **kwargs) return wrapper
python
def _execute_if_not_empty(func): """ Execute function only if one of input parameters is not empty """ def wrapper(*args, **kwargs): if any(args[1:]) or any(kwargs.items()): return func(*args, **kwargs) return wrapper
[ "def", "_execute_if_not_empty", "(", "func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "any", "(", "args", "[", "1", ":", "]", ")", "or", "any", "(", "kwargs", ".", "items", "(", ")", ")", ":", "retu...
Execute function only if one of input parameters is not empty
[ "Execute", "function", "only", "if", "one", "of", "input", "parameters", "is", "not", "empty" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/elasticsearch_client.py#L89-L94
train
opennode/waldur-core
waldur_core/logging/elasticsearch_client.py
ElasticsearchClient.prepare_search_body
def prepare_search_body(self, should_terms=None, must_terms=None, must_not_terms=None, search_text='', start=None, end=None): """ Prepare body for elasticsearch query Search parameters ^^^^^^^^^^^^^^^^^ These parameters are dictionaries and have format: <term>: [<value 1>, <val...
python
def prepare_search_body(self, should_terms=None, must_terms=None, must_not_terms=None, search_text='', start=None, end=None): """ Prepare body for elasticsearch query Search parameters ^^^^^^^^^^^^^^^^^ These parameters are dictionaries and have format: <term>: [<value 1>, <val...
[ "def", "prepare_search_body", "(", "self", ",", "should_terms", "=", "None", ",", "must_terms", "=", "None", ",", "must_not_terms", "=", "None", ",", "search_text", "=", "''", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "self", ".", "...
Prepare body for elasticsearch query Search parameters ^^^^^^^^^^^^^^^^^ These parameters are dictionaries and have format: <term>: [<value 1>, <value 2> ...] should_terms: it resembles logical OR must_terms: it resembles logical AND must_not_terms: it resembles logical...
[ "Prepare", "body", "for", "elasticsearch", "query" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/elasticsearch_client.py#L227-L249
train
opennode/waldur-core
waldur_core/core/executors.py
BaseExecutor.execute
def execute(cls, instance, async=True, countdown=2, is_heavy_task=False, **kwargs): """ Execute high level-operation """ cls.pre_apply(instance, async=async, **kwargs) result = cls.apply_signature(instance, async=async, countdown=countdown, is_heavy_task=is_h...
python
def execute(cls, instance, async=True, countdown=2, is_heavy_task=False, **kwargs): """ Execute high level-operation """ cls.pre_apply(instance, async=async, **kwargs) result = cls.apply_signature(instance, async=async, countdown=countdown, is_heavy_task=is_h...
[ "def", "execute", "(", "cls", ",", "instance", ",", "async", "=", "True", ",", "countdown", "=", "2", ",", "is_heavy_task", "=", "False", ",", "*", "*", "kwargs", ")", ":", "cls", ".", "pre_apply", "(", "instance", ",", "async", "=", "async", ",", ...
Execute high level-operation
[ "Execute", "high", "level", "-", "operation" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/executors.py#L40-L46
train
opennode/waldur-core
waldur_core/core/executors.py
BaseExecutor.apply_signature
def apply_signature(cls, instance, async=True, countdown=None, is_heavy_task=False, **kwargs): """ Serialize input data and apply signature """ serialized_instance = utils.serialize_instance(instance) signature = cls.get_task_signature(instance, serialized_instance, **kwargs) link = cls...
python
def apply_signature(cls, instance, async=True, countdown=None, is_heavy_task=False, **kwargs): """ Serialize input data and apply signature """ serialized_instance = utils.serialize_instance(instance) signature = cls.get_task_signature(instance, serialized_instance, **kwargs) link = cls...
[ "def", "apply_signature", "(", "cls", ",", "instance", ",", "async", "=", "True", ",", "countdown", "=", "None", ",", "is_heavy_task", "=", "False", ",", "*", "*", "kwargs", ")", ":", "serialized_instance", "=", "utils", ".", "serialize_instance", "(", "in...
Serialize input data and apply signature
[ "Serialize", "input", "data", "and", "apply", "signature" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/executors.py#L59-L76
train
opennode/waldur-core
waldur_core/core/executors.py
BaseExecutor._apply_callback
def _apply_callback(cls, callback, result): """ Synchronously execute callback """ if not callback.immutable: callback.args = (result.id, ) + callback.args callback.apply()
python
def _apply_callback(cls, callback, result): """ Synchronously execute callback """ if not callback.immutable: callback.args = (result.id, ) + callback.args callback.apply()
[ "def", "_apply_callback", "(", "cls", ",", "callback", ",", "result", ")", ":", "if", "not", "callback", ".", "immutable", ":", "callback", ".", "args", "=", "(", "result", ".", "id", ",", ")", "+", "callback", ".", "args", "callback", ".", "apply", ...
Synchronously execute callback
[ "Synchronously", "execute", "callback" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/executors.py#L79-L83
train
opennode/waldur-core
waldur_core/core/schemas.py
get_entity_description
def get_entity_description(entity): """ Returns description in format: * entity human readable name * docstring """ try: entity_name = entity.__name__.strip('_') except AttributeError: # entity is a class instance entity_name = entity.__class__.__name__ label =...
python
def get_entity_description(entity): """ Returns description in format: * entity human readable name * docstring """ try: entity_name = entity.__name__.strip('_') except AttributeError: # entity is a class instance entity_name = entity.__class__.__name__ label =...
[ "def", "get_entity_description", "(", "entity", ")", ":", "try", ":", "entity_name", "=", "entity", ".", "__name__", ".", "strip", "(", "'_'", ")", "except", "AttributeError", ":", "# entity is a class instance", "entity_name", "=", "entity", ".", "__class__", "...
Returns description in format: * entity human readable name * docstring
[ "Returns", "description", "in", "format", ":", "*", "entity", "human", "readable", "name", "*", "docstring" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L37-L55
train
opennode/waldur-core
waldur_core/core/schemas.py
get_validators_description
def get_validators_description(view): """ Returns validators description in format: ### Validators: * validator1 name * validator1 docstring * validator2 name * validator2 docstring """ action = getattr(view, 'action', None) if action is None: return '' description...
python
def get_validators_description(view): """ Returns validators description in format: ### Validators: * validator1 name * validator1 docstring * validator2 name * validator2 docstring """ action = getattr(view, 'action', None) if action is None: return '' description...
[ "def", "get_validators_description", "(", "view", ")", ":", "action", "=", "getattr", "(", "view", ",", "'action'", ",", "None", ")", "if", "action", "is", "None", ":", "return", "''", "description", "=", "''", "validators", "=", "getattr", "(", "view", ...
Returns validators description in format: ### Validators: * validator1 name * validator1 docstring * validator2 name * validator2 docstring
[ "Returns", "validators", "description", "in", "format", ":", "###", "Validators", ":", "*", "validator1", "name", "*", "validator1", "docstring", "*", "validator2", "name", "*", "validator2", "docstring" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L58-L77
train
opennode/waldur-core
waldur_core/core/schemas.py
get_actions_permission_description
def get_actions_permission_description(view, method): """ Returns actions permissions description in format: * permission1 name * permission1 docstring * permission2 name * permission2 docstring """ action = getattr(view, 'action', None) if action is None: return '' if...
python
def get_actions_permission_description(view, method): """ Returns actions permissions description in format: * permission1 name * permission1 docstring * permission2 name * permission2 docstring """ action = getattr(view, 'action', None) if action is None: return '' if...
[ "def", "get_actions_permission_description", "(", "view", ",", "method", ")", ":", "action", "=", "getattr", "(", "view", ",", "'action'", ",", "None", ")", "if", "action", "is", "None", ":", "return", "''", "if", "hasattr", "(", "view", ",", "action", "...
Returns actions permissions description in format: * permission1 name * permission1 docstring * permission2 name * permission2 docstring
[ "Returns", "actions", "permissions", "description", "in", "format", ":", "*", "permission1", "name", "*", "permission1", "docstring", "*", "permission2", "name", "*", "permission2", "docstring" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L80-L106
train
opennode/waldur-core
waldur_core/core/schemas.py
get_permissions_description
def get_permissions_description(view, method): """ Returns permissions description in format: ### Permissions: * permission1 name * permission1 docstring * permission2 name * permission2 docstring """ if not hasattr(view, 'permission_classes'): return '' description = ...
python
def get_permissions_description(view, method): """ Returns permissions description in format: ### Permissions: * permission1 name * permission1 docstring * permission2 name * permission2 docstring """ if not hasattr(view, 'permission_classes'): return '' description = ...
[ "def", "get_permissions_description", "(", "view", ",", "method", ")", ":", "if", "not", "hasattr", "(", "view", ",", "'permission_classes'", ")", ":", "return", "''", "description", "=", "''", "for", "permission_class", "in", "view", ".", "permission_classes", ...
Returns permissions description in format: ### Permissions: * permission1 name * permission1 docstring * permission2 name * permission2 docstring
[ "Returns", "permissions", "description", "in", "format", ":", "###", "Permissions", ":", "*", "permission1", "name", "*", "permission1", "docstring", "*", "permission2", "name", "*", "permission2", "docstring" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L109-L131
train
opennode/waldur-core
waldur_core/core/schemas.py
get_validation_description
def get_validation_description(view, method): """ Returns validation description in format: ### Validation: validate method docstring * field1 name * field1 validation docstring * field2 name * field2 validation docstring """ if method not in ('PUT', 'PATCH', 'POST') or not has...
python
def get_validation_description(view, method): """ Returns validation description in format: ### Validation: validate method docstring * field1 name * field1 validation docstring * field2 name * field2 validation docstring """ if method not in ('PUT', 'PATCH', 'POST') or not has...
[ "def", "get_validation_description", "(", "view", ",", "method", ")", ":", "if", "method", "not", "in", "(", "'PUT'", ",", "'PATCH'", ",", "'POST'", ")", "or", "not", "hasattr", "(", "view", ",", "'get_serializer'", ")", ":", "return", "''", "serializer", ...
Returns validation description in format: ### Validation: validate method docstring * field1 name * field1 validation docstring * field2 name * field2 validation docstring
[ "Returns", "validation", "description", "in", "format", ":", "###", "Validation", ":", "validate", "method", "docstring", "*", "field1", "name", "*", "field1", "validation", "docstring", "*", "field2", "name", "*", "field2", "validation", "docstring" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L134-L163
train
opennode/waldur-core
waldur_core/core/schemas.py
get_field_type
def get_field_type(field): """ Returns field type/possible values. """ if isinstance(field, core_filters.MappedMultipleChoiceFilter): return ' | '.join(['"%s"' % f for f in sorted(field.mapped_to_model)]) if isinstance(field, OrderingFilter) or isinstance(field, ChoiceFilter): return...
python
def get_field_type(field): """ Returns field type/possible values. """ if isinstance(field, core_filters.MappedMultipleChoiceFilter): return ' | '.join(['"%s"' % f for f in sorted(field.mapped_to_model)]) if isinstance(field, OrderingFilter) or isinstance(field, ChoiceFilter): return...
[ "def", "get_field_type", "(", "field", ")", ":", "if", "isinstance", "(", "field", ",", "core_filters", ".", "MappedMultipleChoiceFilter", ")", ":", "return", "' | '", ".", "join", "(", "[", "'\"%s\"'", "%", "f", "for", "f", "in", "sorted", "(", "field", ...
Returns field type/possible values.
[ "Returns", "field", "type", "/", "possible", "values", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L185-L233
train
opennode/waldur-core
waldur_core/core/schemas.py
is_disabled_action
def is_disabled_action(view): """ Checks whether Link action is disabled. """ if not isinstance(view, core_views.ActionsViewSet): return False action = getattr(view, 'action', None) return action in view.disabled_actions if action is not None else False
python
def is_disabled_action(view): """ Checks whether Link action is disabled. """ if not isinstance(view, core_views.ActionsViewSet): return False action = getattr(view, 'action', None) return action in view.disabled_actions if action is not None else False
[ "def", "is_disabled_action", "(", "view", ")", ":", "if", "not", "isinstance", "(", "view", ",", "core_views", ".", "ActionsViewSet", ")", ":", "return", "False", "action", "=", "getattr", "(", "view", ",", "'action'", ",", "None", ")", "return", "action",...
Checks whether Link action is disabled.
[ "Checks", "whether", "Link", "action", "is", "disabled", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L236-L244
train
opennode/waldur-core
waldur_core/core/schemas.py
WaldurEndpointInspector.get_allowed_methods
def get_allowed_methods(self, callback): """ Return a list of the valid HTTP methods for this endpoint. """ if hasattr(callback, 'actions'): return [method.upper() for method in callback.actions.keys() if method != 'head'] return [ method for method in ...
python
def get_allowed_methods(self, callback): """ Return a list of the valid HTTP methods for this endpoint. """ if hasattr(callback, 'actions'): return [method.upper() for method in callback.actions.keys() if method != 'head'] return [ method for method in ...
[ "def", "get_allowed_methods", "(", "self", ",", "callback", ")", ":", "if", "hasattr", "(", "callback", ",", "'actions'", ")", ":", "return", "[", "method", ".", "upper", "(", ")", "for", "method", "in", "callback", ".", "actions", ".", "keys", "(", ")...
Return a list of the valid HTTP methods for this endpoint.
[ "Return", "a", "list", "of", "the", "valid", "HTTP", "methods", "for", "this", "endpoint", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L24-L34
train
opennode/waldur-core
waldur_core/core/schemas.py
WaldurSchemaGenerator.create_view
def create_view(self, callback, method, request=None): """ Given a callback, return an actual view instance. """ view = super(WaldurSchemaGenerator, self).create_view(callback, method, request) if is_disabled_action(view): view.exclude_from_schema = True retu...
python
def create_view(self, callback, method, request=None): """ Given a callback, return an actual view instance. """ view = super(WaldurSchemaGenerator, self).create_view(callback, method, request) if is_disabled_action(view): view.exclude_from_schema = True retu...
[ "def", "create_view", "(", "self", ",", "callback", ",", "method", ",", "request", "=", "None", ")", ":", "view", "=", "super", "(", "WaldurSchemaGenerator", ",", "self", ")", ".", "create_view", "(", "callback", ",", "method", ",", "request", ")", "if",...
Given a callback, return an actual view instance.
[ "Given", "a", "callback", "return", "an", "actual", "view", "instance", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L250-L258
train
opennode/waldur-core
waldur_core/core/schemas.py
WaldurSchemaGenerator.get_description
def get_description(self, path, method, view): """ Determine a link description. This will be based on the method docstring if one exists, or else the class docstring. """ description = super(WaldurSchemaGenerator, self).get_description(path, method, view) permi...
python
def get_description(self, path, method, view): """ Determine a link description. This will be based on the method docstring if one exists, or else the class docstring. """ description = super(WaldurSchemaGenerator, self).get_description(path, method, view) permi...
[ "def", "get_description", "(", "self", ",", "path", ",", "method", ",", "view", ")", ":", "description", "=", "super", "(", "WaldurSchemaGenerator", ",", "self", ")", ".", "get_description", "(", "path", ",", "method", ",", "view", ")", "permissions_descript...
Determine a link description. This will be based on the method docstring if one exists, or else the class docstring.
[ "Determine", "a", "link", "description", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L260-L282
train
opennode/waldur-core
waldur_core/core/schemas.py
WaldurSchemaGenerator.get_serializer_fields
def get_serializer_fields(self, path, method, view): """ Return a list of `coreapi.Field` instances corresponding to any request body input, as determined by the serializer class. """ if method not in ('PUT', 'PATCH', 'POST'): return [] if not hasattr(view, '...
python
def get_serializer_fields(self, path, method, view): """ Return a list of `coreapi.Field` instances corresponding to any request body input, as determined by the serializer class. """ if method not in ('PUT', 'PATCH', 'POST'): return [] if not hasattr(view, '...
[ "def", "get_serializer_fields", "(", "self", ",", "path", ",", "method", ",", "view", ")", ":", "if", "method", "not", "in", "(", "'PUT'", ",", "'PATCH'", ",", "'POST'", ")", ":", "return", "[", "]", "if", "not", "hasattr", "(", "view", ",", "'get_se...
Return a list of `coreapi.Field` instances corresponding to any request body input, as determined by the serializer class.
[ "Return", "a", "list", "of", "coreapi", ".", "Field", "instances", "corresponding", "to", "any", "request", "body", "input", "as", "determined", "by", "the", "serializer", "class", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/schemas.py#L315-L348
train
opennode/waldur-core
waldur_core/core/handlers.py
delete_error_message
def delete_error_message(sender, instance, name, source, target, **kwargs): """ Delete error message if instance state changed from erred """ if source != StateMixin.States.ERRED: return instance.error_message = '' instance.save(update_fields=['error_message'])
python
def delete_error_message(sender, instance, name, source, target, **kwargs): """ Delete error message if instance state changed from erred """ if source != StateMixin.States.ERRED: return instance.error_message = '' instance.save(update_fields=['error_message'])
[ "def", "delete_error_message", "(", "sender", ",", "instance", ",", "name", ",", "source", ",", "target", ",", "*", "*", "kwargs", ")", ":", "if", "source", "!=", "StateMixin", ".", "States", ".", "ERRED", ":", "return", "instance", ".", "error_message", ...
Delete error message if instance state changed from erred
[ "Delete", "error", "message", "if", "instance", "state", "changed", "from", "erred" ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/handlers.py#L31-L36
train
zeromake/aiosqlite3
setup.py
find_version
def find_version(*file_paths): """ read __init__.py """ file_path = os.path.join(*file_paths) with open(file_path, 'r') as version_file: line = version_file.readline() while line: if line.startswith('__version__'): version_match = re.search( ...
python
def find_version(*file_paths): """ read __init__.py """ file_path = os.path.join(*file_paths) with open(file_path, 'r') as version_file: line = version_file.readline() while line: if line.startswith('__version__'): version_match = re.search( ...
[ "def", "find_version", "(", "*", "file_paths", ")", ":", "file_path", "=", "os", ".", "path", ".", "join", "(", "*", "file_paths", ")", "with", "open", "(", "file_path", ",", "'r'", ")", "as", "version_file", ":", "line", "=", "version_file", ".", "rea...
read __init__.py
[ "read", "__init__", ".", "py" ]
1a74a062507e2df8f833a70885e69dca0ab3e7e7
https://github.com/zeromake/aiosqlite3/blob/1a74a062507e2df8f833a70885e69dca0ab3e7e7/setup.py#L25-L42
train
quora/qcore
qcore/debug.py
trace
def trace(enter=False, exit=True): """ This decorator prints entry and exit message when the decorated method is called, as well as call arguments, result and thrown exception (if any). :param enter: indicates whether entry message should be printed. :param exit: indicates whether exit message ...
python
def trace(enter=False, exit=True): """ This decorator prints entry and exit message when the decorated method is called, as well as call arguments, result and thrown exception (if any). :param enter: indicates whether entry message should be printed. :param exit: indicates whether exit message ...
[ "def", "trace", "(", "enter", "=", "False", ",", "exit", "=", "True", ")", ":", "def", "decorate", "(", "fn", ")", ":", "@", "inspection", ".", "wraps", "(", "fn", ")", "def", "new_fn", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "name...
This decorator prints entry and exit message when the decorated method is called, as well as call arguments, result and thrown exception (if any). :param enter: indicates whether entry message should be printed. :param exit: indicates whether exit message should be printed. :return: decorated funct...
[ "This", "decorator", "prints", "entry", "and", "exit", "message", "when", "the", "decorated", "method", "is", "called", "as", "well", "as", "call", "arguments", "result", "and", "thrown", "exception", "(", "if", "any", ")", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/debug.py#L33-L71
train
quora/qcore
qcore/enum.py
EnumType._make_value
def _make_value(self, value): """Instantiates an enum with an arbitrary value.""" member = self.__new__(self, value) member.__init__(value) return member
python
def _make_value(self, value): """Instantiates an enum with an arbitrary value.""" member = self.__new__(self, value) member.__init__(value) return member
[ "def", "_make_value", "(", "self", ",", "value", ")", ":", "member", "=", "self", ".", "__new__", "(", "self", ",", "value", ")", "member", ".", "__init__", "(", "value", ")", "return", "member" ]
Instantiates an enum with an arbitrary value.
[ "Instantiates", "an", "enum", "with", "an", "arbitrary", "value", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/enum.py#L89-L93
train
quora/qcore
qcore/enum.py
EnumBase.create
def create(cls, name, members): """Creates a new enum type based on this one (cls) and adds newly passed members to the newly created subclass of cls. This method helps to create enums having the same member values as values of other enum(s). :param name: name of the newly crea...
python
def create(cls, name, members): """Creates a new enum type based on this one (cls) and adds newly passed members to the newly created subclass of cls. This method helps to create enums having the same member values as values of other enum(s). :param name: name of the newly crea...
[ "def", "create", "(", "cls", ",", "name", ",", "members", ")", ":", "NewEnum", "=", "type", "(", "name", ",", "(", "cls", ",", ")", ",", "{", "}", ")", "if", "isinstance", "(", "members", ",", "dict", ")", ":", "members", "=", "members", ".", "...
Creates a new enum type based on this one (cls) and adds newly passed members to the newly created subclass of cls. This method helps to create enums having the same member values as values of other enum(s). :param name: name of the newly created type :param members: 1) a dict ...
[ "Creates", "a", "new", "enum", "type", "based", "on", "this", "one", "(", "cls", ")", "and", "adds", "newly", "passed", "members", "to", "the", "newly", "created", "subclass", "of", "cls", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/enum.py#L175-L214
train
quora/qcore
qcore/enum.py
Enum.parse
def parse(cls, value, default=_no_default): """Parses an enum member name or value into an enum member. Accepts the following types: - Members of this enum class. These are returned directly. - Integers. If there is an enum member with the integer as a value, that member is returned. ...
python
def parse(cls, value, default=_no_default): """Parses an enum member name or value into an enum member. Accepts the following types: - Members of this enum class. These are returned directly. - Integers. If there is an enum member with the integer as a value, that member is returned. ...
[ "def", "parse", "(", "cls", ",", "value", ",", "default", "=", "_no_default", ")", ":", "if", "isinstance", "(", "value", ",", "cls", ")", ":", "return", "value", "elif", "isinstance", "(", "value", ",", "six", ".", "integer_types", ")", "and", "not", ...
Parses an enum member name or value into an enum member. Accepts the following types: - Members of this enum class. These are returned directly. - Integers. If there is an enum member with the integer as a value, that member is returned. - Strings. If there is an enum member with the st...
[ "Parses", "an", "enum", "member", "name", "or", "value", "into", "an", "enum", "member", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/enum.py#L239-L272
train
quora/qcore
qcore/enum.py
Flags.parse
def parse(cls, value, default=_no_default): """Parses a flag integer or string into a Flags instance. Accepts the following types: - Members of this enum class. These are returned directly. - Integers. These are converted directly into a Flags instance with the given name. - Str...
python
def parse(cls, value, default=_no_default): """Parses a flag integer or string into a Flags instance. Accepts the following types: - Members of this enum class. These are returned directly. - Integers. These are converted directly into a Flags instance with the given name. - Str...
[ "def", "parse", "(", "cls", ",", "value", ",", "default", "=", "_no_default", ")", ":", "if", "isinstance", "(", "value", ",", "cls", ")", ":", "return", "value", "elif", "isinstance", "(", "value", ",", "int", ")", ":", "e", "=", "cls", ".", "_mak...
Parses a flag integer or string into a Flags instance. Accepts the following types: - Members of this enum class. These are returned directly. - Integers. These are converted directly into a Flags instance with the given name. - Strings. The function accepts a comma-delimited list of fl...
[ "Parses", "a", "flag", "integer", "or", "string", "into", "a", "Flags", "instance", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/enum.py#L300-L344
train
opennode/waldur-core
waldur_core/cost_tracking/views.py
PriceEstimateViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of price estimates, run **GET** against */api/price-estimates/* as authenticated user. You can filter price estimates by scope type, scope URL, customer UUID. `scope_type` is generic type of object for which price estimate is c...
python
def list(self, request, *args, **kwargs): """ To get a list of price estimates, run **GET** against */api/price-estimates/* as authenticated user. You can filter price estimates by scope type, scope URL, customer UUID. `scope_type` is generic type of object for which price estimate is c...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "PriceEstimateViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To get a list of price estimates, run **GET** against */api/price-estimates/* as authenticated user. You can filter price estimates by scope type, scope URL, customer UUID. `scope_type` is generic type of object for which price estimate is calculated. Currently there are following types: custom...
[ "To", "get", "a", "list", "of", "price", "estimates", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "price", "-", "estimates", "/", "*", "as", "authenticated", "user", ".", "You", "can", "filter", "price", "estimates", "by", "scope", "type...
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L40-L54
train
opennode/waldur-core
waldur_core/cost_tracking/views.py
PriceListItemViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of price list items, run **GET** against */api/price-list-items/* as an authenticated user. """ return super(PriceListItemViewSet, self).list(request, *args, **kwargs)
python
def list(self, request, *args, **kwargs): """ To get a list of price list items, run **GET** against */api/price-list-items/* as an authenticated user. """ return super(PriceListItemViewSet, self).list(request, *args, **kwargs)
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "PriceListItemViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To get a list of price list items, run **GET** against */api/price-list-items/* as an authenticated user.
[ "To", "get", "a", "list", "of", "price", "list", "items", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "price", "-", "list", "-", "items", "/", "*", "as", "an", "authenticated", "user", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L73-L77
train
opennode/waldur-core
waldur_core/cost_tracking/views.py
PriceListItemViewSet.create
def create(self, request, *args, **kwargs): """ Run **POST** request against */api/price-list-items/* to create new price list item. Customer owner and staff can create price items. Example of request: .. code-block:: http POST /api/price-list-items/ HTTP/1.1 ...
python
def create(self, request, *args, **kwargs): """ Run **POST** request against */api/price-list-items/* to create new price list item. Customer owner and staff can create price items. Example of request: .. code-block:: http POST /api/price-list-items/ HTTP/1.1 ...
[ "def", "create", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "PriceListItemViewSet", ",", "self", ")", ".", "create", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Run **POST** request against */api/price-list-items/* to create new price list item. Customer owner and staff can create price items. Example of request: .. code-block:: http POST /api/price-list-items/ HTTP/1.1 Content-Type: application/json Accept: applic...
[ "Run", "**", "POST", "**", "request", "against", "*", "/", "api", "/", "price", "-", "list", "-", "items", "/", "*", "to", "create", "new", "price", "list", "item", ".", "Customer", "owner", "and", "staff", "can", "create", "price", "items", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L79-L101
train
opennode/waldur-core
waldur_core/cost_tracking/views.py
PriceListItemViewSet.update
def update(self, request, *args, **kwargs): """ Run **PATCH** request against */api/price-list-items/<uuid>/* to update price list item. Only item_type, key value and units can be updated. Only customer owner and staff can update price items. """ return super(PriceListIte...
python
def update(self, request, *args, **kwargs): """ Run **PATCH** request against */api/price-list-items/<uuid>/* to update price list item. Only item_type, key value and units can be updated. Only customer owner and staff can update price items. """ return super(PriceListIte...
[ "def", "update", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "PriceListItemViewSet", ",", "self", ")", ".", "update", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Run **PATCH** request against */api/price-list-items/<uuid>/* to update price list item. Only item_type, key value and units can be updated. Only customer owner and staff can update price items.
[ "Run", "**", "PATCH", "**", "request", "against", "*", "/", "api", "/", "price", "-", "list", "-", "items", "/", "<uuid", ">", "/", "*", "to", "update", "price", "list", "item", ".", "Only", "item_type", "key", "value", "and", "units", "can", "be", ...
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L103-L109
train
opennode/waldur-core
waldur_core/cost_tracking/views.py
PriceListItemViewSet.destroy
def destroy(self, request, *args, **kwargs): """ Run **DELETE** request against */api/price-list-items/<uuid>/* to delete price list item. Only customer owner and staff can delete price items. """ return super(PriceListItemViewSet, self).destroy(request, *args, **kwargs)
python
def destroy(self, request, *args, **kwargs): """ Run **DELETE** request against */api/price-list-items/<uuid>/* to delete price list item. Only customer owner and staff can delete price items. """ return super(PriceListItemViewSet, self).destroy(request, *args, **kwargs)
[ "def", "destroy", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "PriceListItemViewSet", ",", "self", ")", ".", "destroy", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Run **DELETE** request against */api/price-list-items/<uuid>/* to delete price list item. Only customer owner and staff can delete price items.
[ "Run", "**", "DELETE", "**", "request", "against", "*", "/", "api", "/", "price", "-", "list", "-", "items", "/", "<uuid", ">", "/", "*", "to", "delete", "price", "list", "item", ".", "Only", "customer", "owner", "and", "staff", "can", "delete", "pri...
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L111-L116
train
opennode/waldur-core
waldur_core/cost_tracking/views.py
DefaultPriceListItemViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of default price list items, run **GET** against */api/default-price-list-items/* as authenticated user. Price lists can be filtered by: - ?key=<string> - ?item_type=<string> has to be from list of available i...
python
def list(self, request, *args, **kwargs): """ To get a list of default price list items, run **GET** against */api/default-price-list-items/* as authenticated user. Price lists can be filtered by: - ?key=<string> - ?item_type=<string> has to be from list of available i...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "DefaultPriceListItemViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To get a list of default price list items, run **GET** against */api/default-price-list-items/* as authenticated user. Price lists can be filtered by: - ?key=<string> - ?item_type=<string> has to be from list of available item_types (available options: 'flavor', 'storage', ...
[ "To", "get", "a", "list", "of", "default", "price", "list", "items", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "default", "-", "price", "-", "list", "-", "items", "/", "*", "as", "authenticated", "user", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L139-L150
train
opennode/waldur-core
waldur_core/cost_tracking/views.py
MergedPriceListItemViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of price list items, run **GET** against */api/merged-price-list-items/* as authenticated user. If service is not specified default price list items are displayed. Otherwise service specific price list items are display...
python
def list(self, request, *args, **kwargs): """ To get a list of price list items, run **GET** against */api/merged-price-list-items/* as authenticated user. If service is not specified default price list items are displayed. Otherwise service specific price list items are display...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "MergedPriceListItemViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To get a list of price list items, run **GET** against */api/merged-price-list-items/* as authenticated user. If service is not specified default price list items are displayed. Otherwise service specific price list items are displayed. In this case rendered object contains {"is_manuall...
[ "To", "get", "a", "list", "of", "price", "list", "items", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "merged", "-", "price", "-", "list", "-", "items", "/", "*", "as", "authenticated", "user", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/cost_tracking/views.py#L158-L173
train
deathbeds/importnb
src/importnb/remote.py
Remote
def Remote(path=None, loader=Notebook, **globals): """A remote notebook finder. Place a `*` into a url to generalize the finder. It returns a context manager """ class Remote(RemoteMixin, loader): ... return Remote(path=path, **globals)
python
def Remote(path=None, loader=Notebook, **globals): """A remote notebook finder. Place a `*` into a url to generalize the finder. It returns a context manager """ class Remote(RemoteMixin, loader): ... return Remote(path=path, **globals)
[ "def", "Remote", "(", "path", "=", "None", ",", "loader", "=", "Notebook", ",", "*", "*", "globals", ")", ":", "class", "Remote", "(", "RemoteMixin", ",", "loader", ")", ":", "...", "return", "Remote", "(", "path", "=", "path", ",", "*", "*", "glob...
A remote notebook finder. Place a `*` into a url to generalize the finder. It returns a context manager
[ "A", "remote", "notebook", "finder", ".", "Place", "a", "*", "into", "a", "url", "to", "generalize", "the", "finder", ".", "It", "returns", "a", "context", "manager" ]
ec870d1f8ab99fd5b363267f89787a3e442a779f
https://github.com/deathbeds/importnb/blob/ec870d1f8ab99fd5b363267f89787a3e442a779f/src/importnb/remote.py#L88-L96
train
opennode/waldur-core
waldur_core/core/permissions.py
ActionsPermission.get_permission_checks
def get_permission_checks(self, request, view): """ Get permission checks that will be executed for current action. """ if view.action is None: return [] # if permissions are defined for view directly - use them. if hasattr(view, view.action + '_permissions'):...
python
def get_permission_checks(self, request, view): """ Get permission checks that will be executed for current action. """ if view.action is None: return [] # if permissions are defined for view directly - use them. if hasattr(view, view.action + '_permissions'):...
[ "def", "get_permission_checks", "(", "self", ",", "request", ",", "view", ")", ":", "if", "view", ".", "action", "is", "None", ":", "return", "[", "]", "# if permissions are defined for view directly - use them.", "if", "hasattr", "(", "view", ",", "view", ".", ...
Get permission checks that will be executed for current action.
[ "Get", "permission", "checks", "that", "will", "be", "executed", "for", "current", "action", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/core/permissions.py#L61-L75
train
stepank/pyws
src/pyws/server.py
Server.add_function
def add_function(self, function): """ Registers the function to the server's default fixed function manager. """ #noinspection PyTypeChecker if not len(self.settings.FUNCTION_MANAGERS): raise ConfigurationError( 'Where have the default function manager...
python
def add_function(self, function): """ Registers the function to the server's default fixed function manager. """ #noinspection PyTypeChecker if not len(self.settings.FUNCTION_MANAGERS): raise ConfigurationError( 'Where have the default function manager...
[ "def", "add_function", "(", "self", ",", "function", ")", ":", "#noinspection PyTypeChecker", "if", "not", "len", "(", "self", ".", "settings", ".", "FUNCTION_MANAGERS", ")", ":", "raise", "ConfigurationError", "(", "'Where have the default function manager gone?!'", ...
Registers the function to the server's default fixed function manager.
[ "Registers", "the", "function", "to", "the", "server", "s", "default", "fixed", "function", "manager", "." ]
ff39133aabeb56bbb08d66286ac0cc8731eda7dd
https://github.com/stepank/pyws/blob/ff39133aabeb56bbb08d66286ac0cc8731eda7dd/src/pyws/server.py#L117-L125
train
opennode/waldur-core
waldur_core/logging/filters.py
format_raw_field
def format_raw_field(key): """ When ElasticSearch analyzes string, it breaks it into parts. In order make query for not-analyzed exact string values, we should use subfield instead. The index template for Elasticsearch 5.0 has been changed. The subfield for string multi-fields has changed from .raw...
python
def format_raw_field(key): """ When ElasticSearch analyzes string, it breaks it into parts. In order make query for not-analyzed exact string values, we should use subfield instead. The index template for Elasticsearch 5.0 has been changed. The subfield for string multi-fields has changed from .raw...
[ "def", "format_raw_field", "(", "key", ")", ":", "subfield", "=", "django_settings", ".", "WALDUR_CORE", ".", "get", "(", "'ELASTICSEARCH'", ",", "{", "}", ")", ".", "get", "(", "'raw_subfield'", ",", "'keyword'", ")", "return", "'%s.%s'", "%", "(", "camel...
When ElasticSearch analyzes string, it breaks it into parts. In order make query for not-analyzed exact string values, we should use subfield instead. The index template for Elasticsearch 5.0 has been changed. The subfield for string multi-fields has changed from .raw to .keyword Thus workaround for b...
[ "When", "ElasticSearch", "analyzes", "string", "it", "breaks", "it", "into", "parts", ".", "In", "order", "make", "query", "for", "not", "-", "analyzed", "exact", "string", "values", "we", "should", "use", "subfield", "instead", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/filters.py#L20-L32
train
quora/qcore
qcore/decorators.py
decorate
def decorate(decorator_cls, *args, **kwargs): """Creates a decorator function that applies the decorator_cls that was passed in.""" global _wrappers wrapper_cls = _wrappers.get(decorator_cls, None) if wrapper_cls is None: class PythonWrapper(decorator_cls): pass wrapper_cl...
python
def decorate(decorator_cls, *args, **kwargs): """Creates a decorator function that applies the decorator_cls that was passed in.""" global _wrappers wrapper_cls = _wrappers.get(decorator_cls, None) if wrapper_cls is None: class PythonWrapper(decorator_cls): pass wrapper_cl...
[ "def", "decorate", "(", "decorator_cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "global", "_wrappers", "wrapper_cls", "=", "_wrappers", ".", "get", "(", "decorator_cls", ",", "None", ")", "if", "wrapper_cls", "is", "None", ":", "class", "Py...
Creates a decorator function that applies the decorator_cls that was passed in.
[ "Creates", "a", "decorator", "function", "that", "applies", "the", "decorator_cls", "that", "was", "passed", "in", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L160-L179
train
quora/qcore
qcore/decorators.py
deprecated
def deprecated(replacement_description): """States that method is deprecated. :param replacement_description: Describes what must be used instead. :return: the original method with modified docstring. """ def decorate(fn_or_class): if isinstance(fn_or_class, type): pass # Can...
python
def deprecated(replacement_description): """States that method is deprecated. :param replacement_description: Describes what must be used instead. :return: the original method with modified docstring. """ def decorate(fn_or_class): if isinstance(fn_or_class, type): pass # Can...
[ "def", "deprecated", "(", "replacement_description", ")", ":", "def", "decorate", "(", "fn_or_class", ")", ":", "if", "isinstance", "(", "fn_or_class", ",", "type", ")", ":", "pass", "# Can't change __doc__ of type objects", "else", ":", "try", ":", "fn_or_class",...
States that method is deprecated. :param replacement_description: Describes what must be used instead. :return: the original method with modified docstring.
[ "States", "that", "method", "is", "deprecated", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L182-L203
train
quora/qcore
qcore/decorators.py
convert_result
def convert_result(converter): """Decorator that can convert the result of a function call.""" def decorate(fn): @inspection.wraps(fn) def new_fn(*args, **kwargs): return converter(fn(*args, **kwargs)) return new_fn return decorate
python
def convert_result(converter): """Decorator that can convert the result of a function call.""" def decorate(fn): @inspection.wraps(fn) def new_fn(*args, **kwargs): return converter(fn(*args, **kwargs)) return new_fn return decorate
[ "def", "convert_result", "(", "converter", ")", ":", "def", "decorate", "(", "fn", ")", ":", "@", "inspection", ".", "wraps", "(", "fn", ")", "def", "new_fn", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "converter", "(", "fn", "(...
Decorator that can convert the result of a function call.
[ "Decorator", "that", "can", "convert", "the", "result", "of", "a", "function", "call", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L206-L216
train
quora/qcore
qcore/decorators.py
retry
def retry(exception_cls, max_tries=10, sleep=0.05): """Decorator for retrying a function if it throws an exception. :param exception_cls: an exception type or a parenthesized tuple of exception types :param max_tries: maximum number of times this function can be executed. Must be at least 1. :param sle...
python
def retry(exception_cls, max_tries=10, sleep=0.05): """Decorator for retrying a function if it throws an exception. :param exception_cls: an exception type or a parenthesized tuple of exception types :param max_tries: maximum number of times this function can be executed. Must be at least 1. :param sle...
[ "def", "retry", "(", "exception_cls", ",", "max_tries", "=", "10", ",", "sleep", "=", "0.05", ")", ":", "assert", "max_tries", ">", "0", "def", "with_max_retries_call", "(", "delegate", ")", ":", "for", "i", "in", "xrange", "(", "0", ",", "max_tries", ...
Decorator for retrying a function if it throws an exception. :param exception_cls: an exception type or a parenthesized tuple of exception types :param max_tries: maximum number of times this function can be executed. Must be at least 1. :param sleep: number of seconds to sleep between function retries
[ "Decorator", "for", "retrying", "a", "function", "if", "it", "throws", "an", "exception", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L219-L274
train
quora/qcore
qcore/decorators.py
decorator_of_context_manager
def decorator_of_context_manager(ctxt): """Converts a context manager into a decorator. This decorator will run the decorated function in the context of the manager. :param ctxt: Context to run the function in. :return: Wrapper around the original function. """ def decorator_fn(*outer_ar...
python
def decorator_of_context_manager(ctxt): """Converts a context manager into a decorator. This decorator will run the decorated function in the context of the manager. :param ctxt: Context to run the function in. :return: Wrapper around the original function. """ def decorator_fn(*outer_ar...
[ "def", "decorator_of_context_manager", "(", "ctxt", ")", ":", "def", "decorator_fn", "(", "*", "outer_args", ",", "*", "*", "outer_kwargs", ")", ":", "def", "decorator", "(", "fn", ")", ":", "@", "functools", ".", "wraps", "(", "fn", ")", "def", "wrapper...
Converts a context manager into a decorator. This decorator will run the decorated function in the context of the manager. :param ctxt: Context to run the function in. :return: Wrapper around the original function.
[ "Converts", "a", "context", "manager", "into", "a", "decorator", "." ]
fa5cd438eea554db35fd29cbc8dfbde69f09961c
https://github.com/quora/qcore/blob/fa5cd438eea554db35fd29cbc8dfbde69f09961c/qcore/decorators.py#L277-L304
train
stepank/pyws
src/pyws/protocols/base.py
Protocol.get_error
def get_error(self, error): """ A helper function, gets standard information from the error. """ error_type = type(error) if error.error_type == ET_CLIENT: error_type_name = 'Client' else: error_type_name = 'Server' return { 'ty...
python
def get_error(self, error): """ A helper function, gets standard information from the error. """ error_type = type(error) if error.error_type == ET_CLIENT: error_type_name = 'Client' else: error_type_name = 'Server' return { 'ty...
[ "def", "get_error", "(", "self", ",", "error", ")", ":", "error_type", "=", "type", "(", "error", ")", "if", "error", ".", "error_type", "==", "ET_CLIENT", ":", "error_type_name", "=", "'Client'", "else", ":", "error_type_name", "=", "'Server'", "return", ...
A helper function, gets standard information from the error.
[ "A", "helper", "function", "gets", "standard", "information", "from", "the", "error", "." ]
ff39133aabeb56bbb08d66286ac0cc8731eda7dd
https://github.com/stepank/pyws/blob/ff39133aabeb56bbb08d66286ac0cc8731eda7dd/src/pyws/protocols/base.py#L66-L81
train
opennode/waldur-core
waldur_core/quotas/models.py
QuotaModelMixin.validate_quota_change
def validate_quota_change(self, quota_deltas, raise_exception=False): """ Get error messages about object and his ancestor quotas that will be exceeded if quota_delta will be added. raise_exception - if True QuotaExceededException will be raised if validation fails quota_deltas - dictio...
python
def validate_quota_change(self, quota_deltas, raise_exception=False): """ Get error messages about object and his ancestor quotas that will be exceeded if quota_delta will be added. raise_exception - if True QuotaExceededException will be raised if validation fails quota_deltas - dictio...
[ "def", "validate_quota_change", "(", "self", ",", "quota_deltas", ",", "raise_exception", "=", "False", ")", ":", "errors", "=", "[", "]", "for", "name", ",", "delta", "in", "six", ".", "iteritems", "(", "quota_deltas", ")", ":", "quota", "=", "self", "....
Get error messages about object and his ancestor quotas that will be exceeded if quota_delta will be added. raise_exception - if True QuotaExceededException will be raised if validation fails quota_deltas - dictionary of quotas deltas, example: { 'ram': 1024, 'storage': ...
[ "Get", "error", "messages", "about", "object", "and", "his", "ancestor", "quotas", "that", "will", "be", "exceeded", "if", "quota_delta", "will", "be", "added", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/quotas/models.py#L186-L211
train
opennode/waldur-core
waldur_core/quotas/models.py
QuotaModelMixin.get_sum_of_quotas_as_dict
def get_sum_of_quotas_as_dict(cls, scopes, quota_names=None, fields=['usage', 'limit']): """ Return dictionary with sum of all scopes' quotas. Dictionary format: { 'quota_name1': 'sum of limits for quotas with such quota_name1', 'quota_name1_usage': 'sum of usage...
python
def get_sum_of_quotas_as_dict(cls, scopes, quota_names=None, fields=['usage', 'limit']): """ Return dictionary with sum of all scopes' quotas. Dictionary format: { 'quota_name1': 'sum of limits for quotas with such quota_name1', 'quota_name1_usage': 'sum of usage...
[ "def", "get_sum_of_quotas_as_dict", "(", "cls", ",", "scopes", ",", "quota_names", "=", "None", ",", "fields", "=", "[", "'usage'", ",", "'limit'", "]", ")", ":", "if", "not", "scopes", ":", "return", "{", "}", "if", "quota_names", "is", "None", ":", "...
Return dictionary with sum of all scopes' quotas. Dictionary format: { 'quota_name1': 'sum of limits for quotas with such quota_name1', 'quota_name1_usage': 'sum of usages for quotas with such quota_name1', ... } All `scopes` have to be instances of t...
[ "Return", "dictionary", "with", "sum", "of", "all", "scopes", "quotas", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/quotas/models.py#L220-L270
train
opennode/waldur-core
waldur_core/logging/views.py
EventViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of events - run **GET** against */api/events/* as authenticated user. Note that a user can only see events connected to objects she is allowed to see. Sorting is supported in ascending and descending order by specifying a field...
python
def list(self, request, *args, **kwargs): """ To get a list of events - run **GET** against */api/events/* as authenticated user. Note that a user can only see events connected to objects she is allowed to see. Sorting is supported in ascending and descending order by specifying a field...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "queryset", "=", "self", ".", "filter_queryset", "(", "self", ".", "get_queryset", "(", ")", ")", "page", "=", "self", ".", "paginate_querys...
To get a list of events - run **GET** against */api/events/* as authenticated user. Note that a user can only see events connected to objects she is allowed to see. Sorting is supported in ascending and descending order by specifying a field to an **?o=** parameter. By default events are sorted...
[ "To", "get", "a", "list", "of", "events", "-", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "events", "/", "*", "as", "authenticated", "user", ".", "Note", "that", "a", "user", "can", "only", "see", "events", "connected", "to", "objects...
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L23-L60
train
opennode/waldur-core
waldur_core/logging/views.py
EventViewSet.count
def count(self, request, *args, **kwargs): """ To get a count of events - run **GET** against */api/events/count/* as authenticated user. Endpoint support same filters as events list. Response example: .. code-block:: javascript {"count": 12321} """ ...
python
def count(self, request, *args, **kwargs): """ To get a count of events - run **GET** against */api/events/count/* as authenticated user. Endpoint support same filters as events list. Response example: .. code-block:: javascript {"count": 12321} """ ...
[ "def", "count", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "queryset", "=", "self", ".", "filter_queryset", "(", "self", ".", "get_queryset", "(", ")", ")", "return", "response", ".", "Response", "(...
To get a count of events - run **GET** against */api/events/count/* as authenticated user. Endpoint support same filters as events list. Response example: .. code-block:: javascript {"count": 12321}
[ "To", "get", "a", "count", "of", "events", "-", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "events", "/", "count", "/", "*", "as", "authenticated", "user", ".", "Endpoint", "support", "same", "filters", "as", "events", "list", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L78-L91
train
opennode/waldur-core
waldur_core/logging/views.py
EventViewSet.count_history
def count_history(self, request, *args, **kwargs): """ To get a historical data of events amount - run **GET** against */api/events/count/history/*. Endpoint support same filters as events list. More about historical data - read at section *Historical data*. Response example: ...
python
def count_history(self, request, *args, **kwargs): """ To get a historical data of events amount - run **GET** against */api/events/count/history/*. Endpoint support same filters as events list. More about historical data - read at section *Historical data*. Response example: ...
[ "def", "count_history", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "queryset", "=", "self", ".", "filter_queryset", "(", "self", ".", "get_queryset", "(", ")", ")", "mapped", "=", "{", "'start'", ":", "request", ...
To get a historical data of events amount - run **GET** against */api/events/count/history/*. Endpoint support same filters as events list. More about historical data - read at section *Historical data*. Response example: .. code-block:: javascript [ { ...
[ "To", "get", "a", "historical", "data", "of", "events", "amount", "-", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "events", "/", "count", "/", "history", "/", "*", ".", "Endpoint", "support", "same", "filters", "as", "events", "list", ...
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L94-L129
train
opennode/waldur-core
waldur_core/logging/views.py
EventViewSet.scope_types
def scope_types(self, request, *args, **kwargs): """ Returns a list of scope types acceptable by events filter. """ return response.Response(utils.get_scope_types_mapping().keys())
python
def scope_types(self, request, *args, **kwargs): """ Returns a list of scope types acceptable by events filter. """ return response.Response(utils.get_scope_types_mapping().keys())
[ "def", "scope_types", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "response", ".", "Response", "(", "utils", ".", "get_scope_types_mapping", "(", ")", ".", "keys", "(", ")", ")" ]
Returns a list of scope types acceptable by events filter.
[ "Returns", "a", "list", "of", "scope", "types", "acceptable", "by", "events", "filter", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L132-L134
train
opennode/waldur-core
waldur_core/logging/views.py
AlertViewSet.list
def list(self, request, *args, **kwargs): """ To get a list of alerts, run **GET** against */api/alerts/* as authenticated user. Alert severity field can take one of this values: "Error", "Warning", "Info", "Debug". Field scope will contain link to object that cause alert. Conte...
python
def list(self, request, *args, **kwargs): """ To get a list of alerts, run **GET** against */api/alerts/* as authenticated user. Alert severity field can take one of this values: "Error", "Warning", "Info", "Debug". Field scope will contain link to object that cause alert. Conte...
[ "def", "list", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "AlertViewSet", ",", "self", ")", ".", "list", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
To get a list of alerts, run **GET** against */api/alerts/* as authenticated user. Alert severity field can take one of this values: "Error", "Warning", "Info", "Debug". Field scope will contain link to object that cause alert. Context - dictionary that contains information about all related to...
[ "To", "get", "a", "list", "of", "alerts", "run", "**", "GET", "**", "against", "*", "/", "api", "/", "alerts", "/", "*", "as", "authenticated", "user", "." ]
d6c17a9592bb6c49c33567542eef8d099605a46a
https://github.com/opennode/waldur-core/blob/d6c17a9592bb6c49c33567542eef8d099605a46a/waldur_core/logging/views.py#L161-L230
train