Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
BaseAccess.can_copy_related
(self, obj)
can_copy_related() should only be used to check if the user have access to related many to many credentials in when copying the object. It does not check if the user has permission for any other related objects. Therefore, when checking if the user can copy an object, it should always b...
can_copy_related() should only be used to check if the user have access to related many to many credentials in when copying the object. It does not check if the user has permission for any other related objects. Therefore, when checking if the user can copy an object, it should always b...
def can_copy_related(self, obj): """ can_copy_related() should only be used to check if the user have access to related many to many credentials in when copying the object. It does not check if the user has permission for any other related objects. Therefore, when checking if the user ...
[ "def", "can_copy_related", "(", "self", ",", "obj", ")", ":", "return", "True" ]
[ 274, 4 ]
[ 281, 19 ]
python
en
['en', 'error', 'th']
False
BaseAccess.check_related
(self, field, Model, data, role_field='admin_role', obj=None, mandatory=False)
Check permission for related field, in scenarios: - creating a new resource, user must have permission if resource is specified in `data` - editing an existing resource, user must have permission to resource in `data`, as well as existing related resource on `obj` ...
Check permission for related field, in scenarios: - creating a new resource, user must have permission if resource is specified in `data` - editing an existing resource, user must have permission to resource in `data`, as well as existing related resource on `obj`
def check_related(self, field, Model, data, role_field='admin_role', obj=None, mandatory=False): """ Check permission for related field, in scenarios: - creating a new resource, user must have permission if resource is specified in `data` - editing an existing resource, user...
[ "def", "check_related", "(", "self", ",", "field", ",", "Model", ",", "data", ",", "role_field", "=", "'admin_role'", ",", "obj", "=", "None", ",", "mandatory", "=", "False", ")", ":", "new", "=", "None", "changed", "=", "True", "if", "data", "and", ...
[ 292, 4 ]
[ 340, 19 ]
python
en
['en', 'error', 'th']
False
UserAccess.user_organizations
(u)
Returns all organizations that count `u` as a member
Returns all organizations that count `u` as a member
def user_organizations(u): """ Returns all organizations that count `u` as a member """ return Organization.accessible_objects(u, 'member_role')
[ "def", "user_organizations", "(", "u", ")", ":", "return", "Organization", ".", "accessible_objects", "(", "u", ",", "'member_role'", ")" ]
[ 634, 4 ]
[ 638, 64 ]
python
en
['en', 'error', 'th']
False
UserAccess.is_all_org_admin
(self, u)
returns True if `u` is member of any organization that is not also an organization that `self.user` admins
returns True if `u` is member of any organization that is not also an organization that `self.user` admins
def is_all_org_admin(self, u): """ returns True if `u` is member of any organization that is not also an organization that `self.user` admins """ return not self.user_organizations(u).exclude(pk__in=Organization.accessible_pk_qs(self.user, 'admin_role')).exists()
[ "def", "is_all_org_admin", "(", "self", ",", "u", ")", ":", "return", "not", "self", ".", "user_organizations", "(", "u", ")", ".", "exclude", "(", "pk__in", "=", "Organization", ".", "accessible_pk_qs", "(", "self", ".", "user", ",", "'admin_role'", ")", ...
[ 640, 4 ]
[ 645, 125 ]
python
en
['en', 'error', 'th']
False
TeamAccess.can_attach
(self, obj, sub_obj, relationship, *args, **kwargs)
Reverse obj and sub_obj, defer to RoleAccess if this is an assignment of a resource role to the team.
Reverse obj and sub_obj, defer to RoleAccess if this is an assignment of a resource role to the team.
def can_attach(self, obj, sub_obj, relationship, *args, **kwargs): """Reverse obj and sub_obj, defer to RoleAccess if this is an assignment of a resource role to the team.""" # MANAGE_ORGANIZATION_AUTH setting checked in RoleAccess if isinstance(sub_obj, Role): if sub_obj.con...
[ "def", "can_attach", "(", "self", ",", "obj", ",", "sub_obj", ",", "relationship", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# MANAGE_ORGANIZATION_AUTH setting checked in RoleAccess", "if", "isinstance", "(", "sub_obj", ",", "Role", ")", ":", "if",...
[ 1295, 4 ]
[ 1314, 94 ]
python
en
['en', 'en', 'en']
True
JobTemplateAccess.can_add
(self, data)
a user can create a job template if - they are a superuser - an org admin of any org that the project is a member - if they are a project_admin for any org that project is a member of - if they have user or team based permissions tying the project to the inventory so...
a user can create a job template if - they are a superuser - an org admin of any org that the project is a member - if they are a project_admin for any org that project is a member of - if they have user or team based permissions tying the project to the inventory so...
def can_add(self, data): """ a user can create a job template if - they are a superuser - an org admin of any org that the project is a member - if they are a project_admin for any org that project is a member of - if they have user or team based permissions t...
[ "def", "can_add", "(", "self", ",", "data", ")", ":", "if", "not", "data", ":", "# So the browseable API will work", "return", "Project", ".", "accessible_objects", "(", "self", ".", "user", ",", "'use_role'", ")", ".", "exists", "(", ")", "# if reference_obj ...
[ 1502, 4 ]
[ 1551, 24 ]
python
en
['en', 'error', 'th']
False
JobTemplateAccess.can_copy_related
(self, obj)
Check if we have access to all the credentials related to Job Templates. Does not verify the user's permission for any other related fields (projects, inventories, etc).
Check if we have access to all the credentials related to Job Templates. Does not verify the user's permission for any other related fields (projects, inventories, etc).
def can_copy_related(self, obj): """ Check if we have access to all the credentials related to Job Templates. Does not verify the user's permission for any other related fields (projects, inventories, etc). """ # obj.credentials.all() is accessible ONLY when object is saved (has...
[ "def", "can_copy_related", "(", "self", ",", "obj", ")", ":", "# obj.credentials.all() is accessible ONLY when object is saved (has valid id)", "credential_manager", "=", "getattr", "(", "obj", ",", "'credentials'", ",", "None", ")", "if", "getattr", "(", "obj", ",", ...
[ 1554, 4 ]
[ 1565, 28 ]
python
en
['en', 'error', 'th']
False
JobTemplateAccess.changes_are_non_sensitive
(self, obj, data)
Return true if the changes being made are considered nonsensitive, and thus can be made by a job template administrator which may not have access to the any inventory, project, or credentials associated with the template.
Return true if the changes being made are considered nonsensitive, and thus can be made by a job template administrator which may not have access to the any inventory, project, or credentials associated with the template.
def changes_are_non_sensitive(self, obj, data): """ Return true if the changes being made are considered nonsensitive, and thus can be made by a job template administrator which may not have access to the any inventory, project, or credentials associated with the template. """ ...
[ "def", "changes_are_non_sensitive", "(", "self", ",", "obj", ",", "data", ")", ":", "allowed_fields", "=", "[", "'name'", ",", "'description'", ",", "'forks'", ",", "'limit'", ",", "'verbosity'", ",", "'extra_vars'", ",", "'job_tags'", ",", "'force_handlers'", ...
[ 1605, 4 ]
[ 1648, 19 ]
python
en
['en', 'error', 'th']
False
SystemJobTemplateAccess.can_start
(self, obj, validate_license=True)
Only a superuser can start a job from a SystemJobTemplate
Only a superuser can start a job from a SystemJobTemplate
def can_start(self, obj, validate_license=True): '''Only a superuser can start a job from a SystemJobTemplate''' return False
[ "def", "can_start", "(", "self", ",", "obj", ",", "validate_license", "=", "True", ")", ":", "return", "False" ]
[ 1800, 4 ]
[ 1802, 20 ]
python
en
['en', 'en', 'en']
True
WorkflowJobTemplateAccess.can_add
(self, data)
a user can create a job template if they are a superuser, an org admin of any org that the project is a member, or if they have user or team based permissions tying the project to the inventory source for the given action as well as the 'create' deploy permission. Users who are ...
a user can create a job template if they are a superuser, an org admin of any org that the project is a member, or if they have user or team based permissions tying the project to the inventory source for the given action as well as the 'create' deploy permission. Users who are ...
def can_add(self, data): """ a user can create a job template if they are a superuser, an org admin of any org that the project is a member, or if they have user or team based permissions tying the project to the inventory source for the given action as well as the 'create' deplo...
[ "def", "can_add", "(", "self", ",", "data", ")", ":", "if", "not", "data", ":", "# So the browseable API will work", "return", "Organization", ".", "accessible_objects", "(", "self", ".", "user", ",", "'workflow_admin_role'", ")", ".", "exists", "(", ")", "if"...
[ 2033, 4 ]
[ 2051, 9 ]
python
en
['en', 'error', 'th']
False
Command.get_handler
(self, *args, **options)
Returns the static files serving handler wrapping the default handler, if static files should be served. Otherwise just returns the default handler.
Returns the static files serving handler wrapping the default handler, if static files should be served. Otherwise just returns the default handler.
def get_handler(self, *args, **options): """ Returns the static files serving handler wrapping the default handler, if static files should be served. Otherwise just returns the default handler. """ handler = super(Command, self).get_handler(*args, **options) use_s...
[ "def", "get_handler", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "handler", "=", "super", "(", "Command", ",", "self", ")", ".", "get_handler", "(", "*", "args", ",", "*", "*", "options", ")", "use_static_handler", "=", "optio...
[ 20, 4 ]
[ 31, 22 ]
python
en
['en', 'error', 'th']
False
AnalyticsTestCase.assertTableState
( self, table: Type[BaseCount], arg_keys: List[str], arg_values: List[List[object]] )
Assert that the state of a *Count table is what it should be. Example usage: self.assertTableState(RealmCount, ['property', 'subgroup', 'realm'], [['p1', 4], ['p2', 10, self.alt_realm]]) table -- A *Count table. arg_keys -- List of columns of <tabl...
Assert that the state of a *Count table is what it should be.
def assertTableState( self, table: Type[BaseCount], arg_keys: List[str], arg_values: List[List[object]] ) -> None: """Assert that the state of a *Count table is what it should be. Example usage: self.assertTableState(RealmCount, ['property', 'subgroup', 'realm'], ...
[ "def", "assertTableState", "(", "self", ",", "table", ":", "Type", "[", "BaseCount", "]", ",", "arg_keys", ":", "List", "[", "str", "]", ",", "arg_values", ":", "List", "[", "List", "[", "object", "]", "]", ")", "->", "None", ":", "defaults", "=", ...
[ 177, 4 ]
[ 222, 64 ]
python
en
['en', 'en', 'en']
True
detect_lines
(diffstr)
Take a diff string and return a dict of files with line numbers changed
Take a diff string and return a dict of files with line numbers changed
def detect_lines(diffstr): """Take a diff string and return a dict of files with line numbers changed""" resultant_lines = {} # diffstr is already decoded io = StringIO(diffstr) udiff = unidiff.PatchSet(io) for file in udiff: target_lines = [] # if file.path in TARGET_FILES: ...
[ "def", "detect_lines", "(", "diffstr", ")", ":", "resultant_lines", "=", "{", "}", "# diffstr is already decoded", "io", "=", "StringIO", "(", "diffstr", ")", "udiff", "=", "unidiff", ".", "PatchSet", "(", "io", ")", "for", "file", "in", "udiff", ":", "tar...
[ 90, 0 ]
[ 104, 26 ]
python
en
['en', 'en', 'en']
True
check_git_remote_exists
(url, version, tags_valid=False, commits_valid=False)
Check if the remote exists and has the branch version. If tags_valid is True query tags as well as branches
Check if the remote exists and has the branch version. If tags_valid is True query tags as well as branches
def check_git_remote_exists(url, version, tags_valid=False, commits_valid=False): """ Check if the remote exists and has the branch version. If tags_valid is True query tags as well as branches """ # Check for tags first as they take priority. # From Cloudbees Support: # >the way git plugin handle...
[ "def", "check_git_remote_exists", "(", "url", ",", "version", ",", "tags_valid", "=", "False", ",", "commits_valid", "=", "False", ")", ":", "# Check for tags first as they take priority.", "# From Cloudbees Support:", "# >the way git plugin handles this conflict, a tag/sha1 is ...
[ 107, 0 ]
[ 174, 59 ]
python
en
['en', 'en', 'en']
True
wait_for_read
(sock, timeout=None)
Waits for reading to be available on a given socket. Returns True if the socket is readable, or False if the timeout expired.
Waits for reading to be available on a given socket. Returns True if the socket is readable, or False if the timeout expired.
def wait_for_read(sock, timeout=None): """Waits for reading to be available on a given socket. Returns True if the socket is readable, or False if the timeout expired. """ return wait_for_socket(sock, read=True, timeout=timeout)
[ "def", "wait_for_read", "(", "sock", ",", "timeout", "=", "None", ")", ":", "return", "wait_for_socket", "(", "sock", ",", "read", "=", "True", ",", "timeout", "=", "timeout", ")" ]
[ 141, 0 ]
[ 145, 60 ]
python
en
['en', 'en', 'en']
True
wait_for_write
(sock, timeout=None)
Waits for writing to be available on a given socket. Returns True if the socket is readable, or False if the timeout expired.
Waits for writing to be available on a given socket. Returns True if the socket is readable, or False if the timeout expired.
def wait_for_write(sock, timeout=None): """Waits for writing to be available on a given socket. Returns True if the socket is readable, or False if the timeout expired. """ return wait_for_socket(sock, write=True, timeout=timeout)
[ "def", "wait_for_write", "(", "sock", ",", "timeout", "=", "None", ")", ":", "return", "wait_for_socket", "(", "sock", ",", "write", "=", "True", ",", "timeout", "=", "timeout", ")" ]
[ 148, 0 ]
[ 152, 61 ]
python
en
['en', 'en', 'en']
True
BaseNormalizingFlow.__init__
(self, params, n_dims, validate_args=False, name='BaseNormalizingFlow')
Initializes the normalizing flows, checking for a valid parameter size :param params: The batched parameters, shape (?, get_param_size(n_dims)) :param n_dims: The dimension of the distribution that is being transformed
Initializes the normalizing flows, checking for a valid parameter size :param params: The batched parameters, shape (?, get_param_size(n_dims)) :param n_dims: The dimension of the distribution that is being transformed
def __init__(self, params, n_dims, validate_args=False, name='BaseNormalizingFlow'): """ Initializes the normalizing flows, checking for a valid parameter size :param params: The batched parameters, shape (?, get_param_size(n_dims)) :param n_dims: The dimension of the distribution that i...
[ "def", "__init__", "(", "self", ",", "params", ",", "n_dims", ",", "validate_args", "=", "False", ",", "name", "=", "'BaseNormalizingFlow'", ")", ":", "super", "(", "BaseNormalizingFlow", ",", "self", ")", ".", "__init__", "(", "validate_args", "=", "validat...
[ 4, 4 ]
[ 13, 37 ]
python
en
['en', 'error', 'th']
False
BaseNormalizingFlow.get_param_size
(n_dims)
Returns the size of the parameter space for this normalizing flow as an int
Returns the size of the parameter space for this normalizing flow as an int
def get_param_size(n_dims): """ Returns the size of the parameter space for this normalizing flow as an int """ raise NotImplementedError()
[ "def", "get_param_size", "(", "n_dims", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 16, 4 ]
[ 20, 35 ]
python
en
['en', 'error', 'th']
False
BaseNormalizingFlow._ildj
(self, y)
:param y: shape (batch_size, n_dims) :return: the inverse log det jacobian, shape (batch_size, 1)
:param y: shape (batch_size, n_dims) :return: the inverse log det jacobian, shape (batch_size, 1)
def _ildj(self, y): """ :param y: shape (batch_size, n_dims) :return: the inverse log det jacobian, shape (batch_size, 1) """ raise NotImplementedError()
[ "def", "_ildj", "(", "self", ",", "y", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 22, 4 ]
[ 27, 35 ]
python
en
['en', 'error', 'th']
False
BaseNormalizingFlow._inverse_log_det_jacobian
(self, y)
Adapts the shape of the ildj to the dimension For n_dims > 1 we use MultivariateNormalDistribution, which has the output shape (batch_size, ) for it's pdf instead of (batch_size, 1) for the UnivariateNormalDistribution -> Remove one dimension from the ildj
Adapts the shape of the ildj to the dimension For n_dims > 1 we use MultivariateNormalDistribution, which has the output shape (batch_size, ) for it's pdf instead of (batch_size, 1) for the UnivariateNormalDistribution -> Remove one dimension from the ildj
def _inverse_log_det_jacobian(self, y): """ Adapts the shape of the ildj to the dimension For n_dims > 1 we use MultivariateNormalDistribution, which has the output shape (batch_size, ) for it's pdf instead of (batch_size, 1) for the UnivariateNormalDistribution -> Remove one dim...
[ "def", "_inverse_log_det_jacobian", "(", "self", ",", "y", ")", ":", "if", "self", ".", "n_dims", "==", "1", ":", "return", "self", ".", "_ildj", "(", "y", ")", "else", ":", "return", "tf", ".", "squeeze", "(", "self", ".", "_ildj", "(", "y", ")", ...
[ 29, 4 ]
[ 39, 52 ]
python
en
['en', 'error', 'th']
False
BaseNormalizingFlow._handle_input_dimensionality
(z)
If rank(z) is 1, increase rank to 2 We want tensors of shape (?, N_DIMS)
If rank(z) is 1, increase rank to 2 We want tensors of shape (?, N_DIMS)
def _handle_input_dimensionality(z): """ If rank(z) is 1, increase rank to 2 We want tensors of shape (?, N_DIMS) """ return tf.cond(tf.equal(tf.rank(z), tf.rank([0.])), lambda: tf.expand_dims(z, 1), lambda: z)
[ "def", "_handle_input_dimensionality", "(", "z", ")", ":", "return", "tf", ".", "cond", "(", "tf", ".", "equal", "(", "tf", ".", "rank", "(", "z", ")", ",", "tf", ".", "rank", "(", "[", "0.", "]", ")", ")", ",", "lambda", ":", "tf", ".", "expan...
[ 42, 4 ]
[ 47, 100 ]
python
en
['en', 'error', 'th']
False
register_handler
(handler)
Install application-specific FITS image handler. :param handler: Handler object.
Install application-specific FITS image handler.
def register_handler(handler): """ Install application-specific FITS image handler. :param handler: Handler object. """ global _handler _handler = handler
[ "def", "register_handler", "(", "handler", ")", ":", "global", "_handler", "_handler", "=", "handler" ]
[ 16, 0 ]
[ 23, 22 ]
python
en
['en', 'error', 'th']
False
was_installed_by_pip
(pkg)
Checks whether pkg was installed by pip This is used not to display the upgrade message when pip is in fact installed by system package manager, such as dnf on Fedora.
Checks whether pkg was installed by pip
def was_installed_by_pip(pkg): # type: (str) -> bool """Checks whether pkg was installed by pip This is used not to display the upgrade message when pip is in fact installed by system package manager, such as dnf on Fedora. """ dist = get_distribution(pkg) if not dist: return False ...
[ "def", "was_installed_by_pip", "(", "pkg", ")", ":", "# type: (str) -> bool", "dist", "=", "get_distribution", "(", "pkg", ")", "if", "not", "dist", ":", "return", "False", "return", "\"pip\"", "==", "get_installer", "(", "dist", ")" ]
[ 100, 0 ]
[ 110, 39 ]
python
en
['en', 'en', 'en']
True
pip_self_version_check
(session, options)
Check for an update for pip. Limit the frequency of checks to once per week. State is stored either in the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix of the pip script path.
Check for an update for pip.
def pip_self_version_check(session, options): # type: (PipSession, optparse.Values) -> None """Check for an update for pip. Limit the frequency of checks to once per week. State is stored either in the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix of the pip script path. ...
[ "def", "pip_self_version_check", "(", "session", ",", "options", ")", ":", "# type: (PipSession, optparse.Values) -> None", "installed_version", "=", "get_installed_version", "(", "\"pip\"", ")", "if", "not", "installed_version", ":", "return", "pip_version", "=", "packag...
[ 113, 0 ]
[ 196, 9 ]
python
en
['en', 'en', 'en']
True
Field.__init__
(self, feat, index)
Initializes on the feature object and the integer index of the field within the feature.
Initializes on the feature object and the integer index of the field within the feature.
def __init__(self, feat, index): """ Initializes on the feature object and the integer index of the field within the feature. """ # Setting the feature pointer and index. self._feat = feat self._index = index # Getting the pointer for this field. ...
[ "def", "__init__", "(", "self", ",", "feat", ",", "index", ")", ":", "# Setting the feature pointer and index.", "self", ".", "_feat", "=", "feat", "self", ".", "_index", "=", "index", "# Getting the pointer for this field.", "fld_ptr", "=", "capi", ".", "get_feat...
[ 19, 4 ]
[ 40, 31 ]
python
en
['en', 'error', 'th']
False
Field.__str__
(self)
Returns the string representation of the Field.
Returns the string representation of the Field.
def __str__(self): "Returns the string representation of the Field." return str(self.value).strip()
[ "def", "__str__", "(", "self", ")", ":", "return", "str", "(", "self", ".", "value", ")", ".", "strip", "(", ")" ]
[ 42, 4 ]
[ 44, 38 ]
python
en
['en', 'en', 'en']
True
Field.as_double
(self)
Retrieves the Field's value as a double (float).
Retrieves the Field's value as a double (float).
def as_double(self): "Retrieves the Field's value as a double (float)." return capi.get_field_as_double(self._feat.ptr, self._index)
[ "def", "as_double", "(", "self", ")", ":", "return", "capi", ".", "get_field_as_double", "(", "self", ".", "_feat", ".", "ptr", ",", "self", ".", "_index", ")" ]
[ 47, 4 ]
[ 49, 68 ]
python
en
['en', 'en', 'en']
True
Field.as_int
(self, is_64=False)
Retrieves the Field's value as an integer.
Retrieves the Field's value as an integer.
def as_int(self, is_64=False): "Retrieves the Field's value as an integer." if is_64: return capi.get_field_as_integer64(self._feat.ptr, self._index) else: return capi.get_field_as_integer(self._feat.ptr, self._index)
[ "def", "as_int", "(", "self", ",", "is_64", "=", "False", ")", ":", "if", "is_64", ":", "return", "capi", ".", "get_field_as_integer64", "(", "self", ".", "_feat", ".", "ptr", ",", "self", ".", "_index", ")", "else", ":", "return", "capi", ".", "get_...
[ 51, 4 ]
[ 56, 73 ]
python
en
['en', 'en', 'en']
True
Field.as_string
(self)
Retrieves the Field's value as a string.
Retrieves the Field's value as a string.
def as_string(self): "Retrieves the Field's value as a string." string = capi.get_field_as_string(self._feat.ptr, self._index) return force_text(string, encoding=self._feat.encoding, strings_only=True)
[ "def", "as_string", "(", "self", ")", ":", "string", "=", "capi", ".", "get_field_as_string", "(", "self", ".", "_feat", ".", "ptr", ",", "self", ".", "_index", ")", "return", "force_text", "(", "string", ",", "encoding", "=", "self", ".", "_feat", "."...
[ 58, 4 ]
[ 61, 82 ]
python
en
['en', 'sk', 'en']
True
Field.as_datetime
(self)
Retrieves the Field's value as a tuple of date & time components.
Retrieves the Field's value as a tuple of date & time components.
def as_datetime(self): "Retrieves the Field's value as a tuple of date & time components." yy, mm, dd, hh, mn, ss, tz = [c_int() for i in range(7)] status = capi.get_field_as_datetime( self._feat.ptr, self._index, byref(yy), byref(mm), byref(dd), byref(hh), byref(mn), byr...
[ "def", "as_datetime", "(", "self", ")", ":", "yy", ",", "mm", ",", "dd", ",", "hh", ",", "mn", ",", "ss", ",", "tz", "=", "[", "c_int", "(", ")", "for", "i", "in", "range", "(", "7", ")", "]", "status", "=", "capi", ".", "get_field_as_datetime"...
[ 63, 4 ]
[ 72, 93 ]
python
en
['en', 'en', 'en']
True
Field.name
(self)
Returns the name of this Field.
Returns the name of this Field.
def name(self): "Returns the name of this Field." name = capi.get_field_name(self.ptr) return force_text(name, encoding=self._feat.encoding, strings_only=True)
[ "def", "name", "(", "self", ")", ":", "name", "=", "capi", ".", "get_field_name", "(", "self", ".", "ptr", ")", "return", "force_text", "(", "name", ",", "encoding", "=", "self", ".", "_feat", ".", "encoding", ",", "strings_only", "=", "True", ")" ]
[ 76, 4 ]
[ 79, 80 ]
python
en
['en', 'en', 'en']
True
Field.precision
(self)
Returns the precision of this Field.
Returns the precision of this Field.
def precision(self): "Returns the precision of this Field." return capi.get_field_precision(self.ptr)
[ "def", "precision", "(", "self", ")", ":", "return", "capi", ".", "get_field_precision", "(", "self", ".", "ptr", ")" ]
[ 82, 4 ]
[ 84, 49 ]
python
en
['en', 'en', 'en']
True
Field.type
(self)
Returns the OGR type of this Field.
Returns the OGR type of this Field.
def type(self): "Returns the OGR type of this Field." return capi.get_field_type(self.ptr)
[ "def", "type", "(", "self", ")", ":", "return", "capi", ".", "get_field_type", "(", "self", ".", "ptr", ")" ]
[ 87, 4 ]
[ 89, 44 ]
python
en
['en', 'en', 'en']
True
Field.type_name
(self)
Return the OGR field type name for this Field.
Return the OGR field type name for this Field.
def type_name(self): "Return the OGR field type name for this Field." return capi.get_field_type_name(self.type)
[ "def", "type_name", "(", "self", ")", ":", "return", "capi", ".", "get_field_type_name", "(", "self", ".", "type", ")" ]
[ 92, 4 ]
[ 94, 50 ]
python
en
['en', 'en', 'en']
True
Field.value
(self)
Returns the value of this Field.
Returns the value of this Field.
def value(self): "Returns the value of this Field." # Default is to get the field as a string. return self.as_string()
[ "def", "value", "(", "self", ")", ":", "# Default is to get the field as a string.", "return", "self", ".", "as_string", "(", ")" ]
[ 97, 4 ]
[ 100, 31 ]
python
en
['en', 'en', 'en']
True
Field.width
(self)
Returns the width of this Field.
Returns the width of this Field.
def width(self): "Returns the width of this Field." return capi.get_field_width(self.ptr)
[ "def", "width", "(", "self", ")", ":", "return", "capi", ".", "get_field_width", "(", "self", ".", "ptr", ")" ]
[ 103, 4 ]
[ 105, 45 ]
python
en
['en', 'en', 'en']
True
OFTInteger.value
(self)
Returns an integer contained in this field.
Returns an integer contained in this field.
def value(self): "Returns an integer contained in this field." if self._double: # If this is really from an OFTReal field with no precision, # read as a double and cast as Python int (to prevent overflow). return int(self.as_double()) else: return ...
[ "def", "value", "(", "self", ")", ":", "if", "self", ".", "_double", ":", "# If this is really from an OFTReal field with no precision,", "# read as a double and cast as Python int (to prevent overflow).", "return", "int", "(", "self", ".", "as_double", "(", ")", ")", "el...
[ 114, 4 ]
[ 121, 43 ]
python
en
['en', 'en', 'en']
True
OFTInteger.type
(self)
GDAL uses OFTReals to represent OFTIntegers in created shapefiles -- forcing the type here since the underlying field type may actually be OFTReal.
GDAL uses OFTReals to represent OFTIntegers in created shapefiles -- forcing the type here since the underlying field type may actually be OFTReal.
def type(self): """ GDAL uses OFTReals to represent OFTIntegers in created shapefiles -- forcing the type here since the underlying field type may actually be OFTReal. """ return 0
[ "def", "type", "(", "self", ")", ":", "return", "0" ]
[ 124, 4 ]
[ 130, 16 ]
python
en
['en', 'error', 'th']
False
OFTReal.value
(self)
Returns a float contained in this field.
Returns a float contained in this field.
def value(self): "Returns a float contained in this field." return self.as_double()
[ "def", "value", "(", "self", ")", ":", "return", "self", ".", "as_double", "(", ")" ]
[ 135, 4 ]
[ 137, 31 ]
python
en
['en', 'en', 'en']
True
OFTDate.value
(self)
Returns a Python `date` object for the OFTDate field.
Returns a Python `date` object for the OFTDate field.
def value(self): "Returns a Python `date` object for the OFTDate field." try: yy, mm, dd, hh, mn, ss, tz = self.as_datetime() return date(yy.value, mm.value, dd.value) except (ValueError, GDALException): return None
[ "def", "value", "(", "self", ")", ":", "try", ":", "yy", ",", "mm", ",", "dd", ",", "hh", ",", "mn", ",", "ss", ",", "tz", "=", "self", ".", "as_datetime", "(", ")", "return", "date", "(", "yy", ".", "value", ",", "mm", ".", "value", ",", "...
[ 156, 4 ]
[ 162, 23 ]
python
en
['en', 'en', 'en']
True
OFTDateTime.value
(self)
Returns a Python `datetime` object for this OFTDateTime field.
Returns a Python `datetime` object for this OFTDateTime field.
def value(self): "Returns a Python `datetime` object for this OFTDateTime field." # TODO: Adapt timezone information. # See http://lists.osgeo.org/pipermail/gdal-dev/2006-February/007990.html # The `tz` variable has values of: 0=unknown, 1=localtime (ambiguous), # 100=GMT, 104...
[ "def", "value", "(", "self", ")", ":", "# TODO: Adapt timezone information.", "# See http://lists.osgeo.org/pipermail/gdal-dev/2006-February/007990.html", "# The `tz` variable has values of: 0=unknown, 1=localtime (ambiguous),", "# 100=GMT, 104=GMT+1, 80=GMT-5, etc.", "try", ":", "yy", ...
[ 167, 4 ]
[ 177, 23 ]
python
en
['en', 'en', 'en']
True
OFTTime.value
(self)
Returns a Python `time` object for this OFTTime field.
Returns a Python `time` object for this OFTTime field.
def value(self): "Returns a Python `time` object for this OFTTime field." try: yy, mm, dd, hh, mn, ss, tz = self.as_datetime() return time(hh.value, mn.value, ss.value) except (ValueError, GDALException): return None
[ "def", "value", "(", "self", ")", ":", "try", ":", "yy", ",", "mm", ",", "dd", ",", "hh", ",", "mn", ",", "ss", ",", "tz", "=", "self", ".", "as_datetime", "(", ")", "return", "time", "(", "hh", ".", "value", ",", "mn", ".", "value", ",", "...
[ 182, 4 ]
[ 188, 23 ]
python
en
['en', 'en', 'en']
True
BaseAdapter.send
(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None)
Sends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. :param stream: (optional) Whether to stream the request content. :param timeout: (optional) How long to wait for the server to send data before giving up...
Sends PreparedRequest object. Returns Response object.
def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None): """Sends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. :param stream: (optional) Whether to stream the request co...
[ "def", "send", "(", "self", ",", "request", ",", "stream", "=", "False", ",", "timeout", "=", "None", ",", "verify", "=", "True", ",", "cert", "=", "None", ",", "proxies", "=", "None", ")", ":", "raise", "NotImplementedError" ]
[ 60, 4 ]
[ 76, 33 ]
python
en
['en', 'lb', 'en']
True
BaseAdapter.close
(self)
Cleans up adapter specific items.
Cleans up adapter specific items.
def close(self): """Cleans up adapter specific items.""" raise NotImplementedError
[ "def", "close", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 78, 4 ]
[ 80, 33 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.init_poolmanager
(self, connections, maxsize, block=DEFAULT_POOLBLOCK, **pool_kwargs)
Initializes a urllib3 PoolManager. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param connections: The number of urllib3 connection pools to cache. :param maxsize: The ma...
Initializes a urllib3 PoolManager.
def init_poolmanager(self, connections, maxsize, block=DEFAULT_POOLBLOCK, **pool_kwargs): """Initializes a urllib3 PoolManager. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. ...
[ "def", "init_poolmanager", "(", "self", ",", "connections", ",", "maxsize", ",", "block", "=", "DEFAULT_POOLBLOCK", ",", "*", "*", "pool_kwargs", ")", ":", "# save these values for pickling", "self", ".", "_pool_connections", "=", "connections", "self", ".", "_poo...
[ 145, 4 ]
[ 163, 79 ]
python
en
['en', 'en', 'it']
True
HTTPAdapter.proxy_manager_for
(self, proxy, **proxy_kwargs)
Return urllib3 ProxyManager for the given proxy. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param proxy: The proxy to return a urllib3 ProxyManager for. :param proxy_kw...
Return urllib3 ProxyManager for the given proxy.
def proxy_manager_for(self, proxy, **proxy_kwargs): """Return urllib3 ProxyManager for the given proxy. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param proxy: The prox...
[ "def", "proxy_manager_for", "(", "self", ",", "proxy", ",", "*", "*", "proxy_kwargs", ")", ":", "if", "proxy", "in", "self", ".", "proxy_manager", ":", "manager", "=", "self", ".", "proxy_manager", "[", "proxy", "]", "elif", "proxy", ".", "lower", "(", ...
[ 165, 4 ]
[ 200, 22 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.cert_verify
(self, conn, url, verify, cert)
Verify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param conn: The urllib3 connection object associated with the cert. :param url: The requested URL. :...
Verify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
def cert_verify(self, conn, url, verify, cert): """Verify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param conn: The urllib3 connection object associated with...
[ "def", "cert_verify", "(", "self", ",", "conn", ",", "url", ",", "verify", ",", "cert", ")", ":", "if", "url", ".", "lower", "(", ")", ".", "startswith", "(", "'https'", ")", "and", "verify", ":", "cert_loc", "=", "None", "# Allow self-specified cert loc...
[ 202, 4 ]
[ 252, 71 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.build_response
(self, req, resp)
Builds a :class:`Response <requests.Response>` object from a urllib3 response. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>` :param req: The :class:`PreparedRequest <PreparedRequest>` used ...
Builds a :class:`Response <requests.Response>` object from a urllib3 response. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`
def build_response(self, req, resp): """Builds a :class:`Response <requests.Response>` object from a urllib3 response. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>` :param req: The ...
[ "def", "build_response", "(", "self", ",", "req", ",", "resp", ")", ":", "response", "=", "Response", "(", ")", "# Fallback to None if there's no status_code, for whatever reason.", "response", ".", "status_code", "=", "getattr", "(", "resp", ",", "'status'", ",", ...
[ 254, 4 ]
[ 289, 23 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.get_connection
(self, url, proxies=None)
Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param url: The URL to connect to. :param proxies: (optional) A Requests-style dictionary of p...
Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
def get_connection(self, url, proxies=None): """Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. :param url: The URL to connect to. :pa...
[ "def", "get_connection", "(", "self", ",", "url", ",", "proxies", "=", "None", ")", ":", "proxy", "=", "select_proxy", "(", "url", ",", "proxies", ")", "if", "proxy", ":", "proxy", "=", "prepend_scheme_if_needed", "(", "proxy", ",", "'http'", ")", "proxy...
[ 291, 4 ]
[ 316, 19 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.close
(self)
Disposes of any internal state. Currently, this closes the PoolManager and any active ProxyManager, which closes any pooled connections.
Disposes of any internal state.
def close(self): """Disposes of any internal state. Currently, this closes the PoolManager and any active ProxyManager, which closes any pooled connections. """ self.poolmanager.clear() for proxy in self.proxy_manager.values(): proxy.clear()
[ "def", "close", "(", "self", ")", ":", "self", ".", "poolmanager", ".", "clear", "(", ")", "for", "proxy", "in", "self", ".", "proxy_manager", ".", "values", "(", ")", ":", "proxy", ".", "clear", "(", ")" ]
[ 318, 4 ]
[ 326, 25 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.request_url
(self, request, proxies)
Obtain the url to use when making the final request. If the message is being sent through a HTTP proxy, the full URL has to be used. Otherwise, we should only use the path portion of the URL. This should not be called from user code, and is only exposed for use when subclassing the ...
Obtain the url to use when making the final request.
def request_url(self, request, proxies): """Obtain the url to use when making the final request. If the message is being sent through a HTTP proxy, the full URL has to be used. Otherwise, we should only use the path portion of the URL. This should not be called from user code, and is o...
[ "def", "request_url", "(", "self", ",", "request", ",", "proxies", ")", ":", "proxy", "=", "select_proxy", "(", "request", ".", "url", ",", "proxies", ")", "scheme", "=", "urlparse", "(", "request", ".", "url", ")", ".", "scheme", "is_proxied_http_request"...
[ 328, 4 ]
[ 355, 18 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.add_headers
(self, request, **kwargs)
Add any headers needed by the connection. As of v2.0 this does nothing by default, but is left for overriding by users that subclass the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. This should not be called from user code, and is only exposed for use when subclassing the ...
Add any headers needed by the connection. As of v2.0 this does nothing by default, but is left for overriding by users that subclass the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
def add_headers(self, request, **kwargs): """Add any headers needed by the connection. As of v2.0 this does nothing by default, but is left for overriding by users that subclass the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`. This should not be called from user code, and is on...
[ "def", "add_headers", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "pass" ]
[ 357, 4 ]
[ 369, 12 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.proxy_headers
(self, proxy)
Returns a dictionary of the headers to add to any request sent through a proxy. This works with urllib3 magic to ensure that they are correctly sent to the proxy, rather than in a tunnelled request if CONNECT is being used. This should not be called from user code, and is only exposed f...
Returns a dictionary of the headers to add to any request sent through a proxy. This works with urllib3 magic to ensure that they are correctly sent to the proxy, rather than in a tunnelled request if CONNECT is being used.
def proxy_headers(self, proxy): """Returns a dictionary of the headers to add to any request sent through a proxy. This works with urllib3 magic to ensure that they are correctly sent to the proxy, rather than in a tunnelled request if CONNECT is being used. This should not be c...
[ "def", "proxy_headers", "(", "self", ",", "proxy", ")", ":", "headers", "=", "{", "}", "username", ",", "password", "=", "get_auth_from_url", "(", "proxy", ")", "if", "username", ":", "headers", "[", "'Proxy-Authorization'", "]", "=", "_basic_auth_str", "(",...
[ 371, 4 ]
[ 391, 22 ]
python
en
['en', 'en', 'en']
True
HTTPAdapter.send
(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None)
Sends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. :param stream: (optional) Whether to stream the request content. :param timeout: (optional) How long to wait for the server to send data before giving up...
Sends PreparedRequest object. Returns Response object.
def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None): """Sends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. :param stream: (optional) Whether to stream the request content. ...
[ "def", "send", "(", "self", ",", "request", ",", "stream", "=", "False", ",", "timeout", "=", "None", ",", "verify", "=", "True", ",", "cert", "=", "None", ",", "proxies", "=", "None", ")", ":", "try", ":", "conn", "=", "self", ".", "get_connection...
[ 393, 4 ]
[ 532, 49 ]
python
en
['en', 'lb', 'en']
True
enabled
()
Allow selection of distutils by environment variable.
Allow selection of distutils by environment variable.
def enabled(): """ Allow selection of distutils by environment variable. """ which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'stdlib') return which == 'local'
[ "def", "enabled", "(", ")", ":", "which", "=", "os", ".", "environ", ".", "get", "(", "'SETUPTOOLS_USE_DISTUTILS'", ",", "'stdlib'", ")", "return", "which", "==", "'local'" ]
[ 35, 0 ]
[ 40, 27 ]
python
en
['en', 'error', 'th']
False
do_override
()
Ensure that the local copy of distutils is preferred over stdlib. See https://github.com/pypa/setuptools/issues/417#issuecomment-392298401 for more motivation.
Ensure that the local copy of distutils is preferred over stdlib.
def do_override(): """ Ensure that the local copy of distutils is preferred over stdlib. See https://github.com/pypa/setuptools/issues/417#issuecomment-392298401 for more motivation. """ if enabled(): warn_distutils_present() ensure_local_distutils()
[ "def", "do_override", "(", ")", ":", "if", "enabled", "(", ")", ":", "warn_distutils_present", "(", ")", "ensure_local_distutils", "(", ")" ]
[ 54, 0 ]
[ 63, 32 ]
python
en
['en', 'error', 'th']
False
DistutilsMetaFinder.spec_for_pip
(self)
Ensure stdlib distutils when running under pip. See pypa/pip#8761 for rationale.
Ensure stdlib distutils when running under pip. See pypa/pip#8761 for rationale.
def spec_for_pip(self): """ Ensure stdlib distutils when running under pip. See pypa/pip#8761 for rationale. """ if self.pip_imported_during_build(): return clear_distutils() self.spec_for_distutils = lambda: None
[ "def", "spec_for_pip", "(", "self", ")", ":", "if", "self", ".", "pip_imported_during_build", "(", ")", ":", "return", "clear_distutils", "(", ")", "self", ".", "spec_for_distutils", "=", "lambda", ":", "None" ]
[ 89, 4 ]
[ 97, 46 ]
python
en
['en', 'error', 'th']
False
DistutilsMetaFinder.pip_imported_during_build
()
Detect if pip is being imported in a build script. Ref #2355.
Detect if pip is being imported in a build script. Ref #2355.
def pip_imported_during_build(): """ Detect if pip is being imported in a build script. Ref #2355. """ import traceback return any( frame.f_globals['__file__'].endswith('setup.py') for frame, line in traceback.walk_stack(None) )
[ "def", "pip_imported_during_build", "(", ")", ":", "import", "traceback", "return", "any", "(", "frame", ".", "f_globals", "[", "'__file__'", "]", ".", "endswith", "(", "'setup.py'", ")", "for", "frame", ",", "line", "in", "traceback", ".", "walk_stack", "("...
[ 100, 4 ]
[ 108, 9 ]
python
en
['en', 'error', 'th']
False
rotate_3d_point
(point)
Rotate 3d point around the center of the field. Args: points: [x, y, z] point. Returns: The rotated points.
Rotate 3d point around the center of the field.
def rotate_3d_point(point): """Rotate 3d point around the center of the field. Args: points: [x, y, z] point. Returns: The rotated points. """ # This assumes the center of the field is the origin: (0, 0) return np.array([-point[0], -point[1], point[2]])
[ "def", "rotate_3d_point", "(", "point", ")", ":", "# This assumes the center of the field is the origin: (0, 0)", "return", "np", ".", "array", "(", "[", "-", "point", "[", "0", "]", ",", "-", "point", "[", "1", "]", ",", "point", "[", "2", "]", "]", ")" ]
[ 32, 0 ]
[ 42, 51 ]
python
en
['en', 'en', 'en']
True
rotate_points
(points)
Rotate the points around the center of the field. Args: points: Numpy array holding one or several points. Returns: The rotated points.
Rotate the points around the center of the field.
def rotate_points(points): """Rotate the points around the center of the field. Args: points: Numpy array holding one or several points. Returns: The rotated points. """ # This assumes the center of the field is the origin: (0, 0) return -points
[ "def", "rotate_points", "(", "points", ")", ":", "# This assumes the center of the field is the origin: (0, 0)", "return", "-", "points" ]
[ 45, 0 ]
[ 55, 16 ]
python
en
['en', 'en', 'en']
True
rotate_sticky_actions
(sticky_actions_state, config)
Rotate the sticky bits of directional actions. This is used to make a policy believe it is playing from left to right although it is actually playing from right to left. Args: sticky_actions_state: Array of bits corresponding to the active actions. config: config used by the environment Returns: ...
Rotate the sticky bits of directional actions.
def rotate_sticky_actions(sticky_actions_state, config): """Rotate the sticky bits of directional actions. This is used to make a policy believe it is playing from left to right although it is actually playing from right to left. Args: sticky_actions_state: Array of bits corresponding to the active action...
[ "def", "rotate_sticky_actions", "(", "sticky_actions_state", ",", "config", ")", ":", "sticky_actions", "=", "football_action_set", ".", "get_sticky_actions", "(", "config", ")", "assert", "len", "(", "sticky_actions", ")", "==", "len", "(", "sticky_actions_state", ...
[ 58, 0 ]
[ 81, 31 ]
python
en
['en', 'en', 'en']
True
flip_team_observation
(observation, result, config, from_team, to_team)
Rotates team-specific observations.
Rotates team-specific observations.
def flip_team_observation(observation, result, config, from_team, to_team): """Rotates team-specific observations.""" result['{}_team'.format(to_team)] = rotate_points( observation['{}_team'.format(from_team)]) result['{}_team_direction'.format(to_team)] = rotate_points( observation['{}_team_direction...
[ "def", "flip_team_observation", "(", "observation", ",", "result", ",", "config", ",", "from_team", ",", "to_team", ")", ":", "result", "[", "'{}_team'", ".", "format", "(", "to_team", ")", "]", "=", "rotate_points", "(", "observation", "[", "'{}_team'", "."...
[ 84, 0 ]
[ 107, 5 ]
python
en
['en', 'en', 'en']
True
flip_observation
(observation, config)
Observation corresponding to the field rotated by 180 degrees.
Observation corresponding to the field rotated by 180 degrees.
def flip_observation(observation, config): """Observation corresponding to the field rotated by 180 degrees.""" flipped_observation = {} flipped_observation['ball'] = rotate_3d_point(observation['ball']) flipped_observation['ball_direction'] = rotate_3d_point( observation['ball_direction']) flipped_obse...
[ "def", "flip_observation", "(", "observation", ",", "config", ")", ":", "flipped_observation", "=", "{", "}", "flipped_observation", "[", "'ball'", "]", "=", "rotate_3d_point", "(", "observation", "[", "'ball'", "]", ")", "flipped_observation", "[", "'ball_directi...
[ 110, 0 ]
[ 129, 28 ]
python
en
['en', 'en', 'en']
True
flip_single_action
(action, config)
Actions corresponding to the field rotated by 180 degrees.
Actions corresponding to the field rotated by 180 degrees.
def flip_single_action(action, config): """Actions corresponding to the field rotated by 180 degrees.""" action = football_action_set.named_action_from_action_set( football_action_set.get_action_set(config), action) if action == football_action_set.action_left: return football_action_set.action_right ...
[ "def", "flip_single_action", "(", "action", ",", "config", ")", ":", "action", "=", "football_action_set", ".", "named_action_from_action_set", "(", "football_action_set", ".", "get_action_set", "(", "config", ")", ",", "action", ")", "if", "action", "==", "footba...
[ 132, 0 ]
[ 152, 15 ]
python
en
['en', 'en', 'en']
True
do_block
(parser, token)
Define a block that can be overridden by child templates.
Define a block that can be overridden by child templates.
def do_block(parser, token): """ Define a block that can be overridden by child templates. """ # token.split_contents() isn't useful here because this tag doesn't accept variable as arguments bits = token.contents.split() if len(bits) != 2: raise TemplateSyntaxError("'%s' tag takes only ...
[ "def", "do_block", "(", "parser", ",", "token", ")", ":", "# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments", "bits", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "len", "(", "bits", ")", "!=", "2", ":"...
[ 237, 0 ]
[ 262, 42 ]
python
en
['en', 'error', 'th']
False
construct_relative_path
(current_template_name, relative_name)
Convert a relative path (starting with './' or '../') to the full template name based on the current_template_name.
Convert a relative path (starting with './' or '../') to the full template name based on the current_template_name.
def construct_relative_path(current_template_name, relative_name): """ Convert a relative path (starting with './' or '../') to the full template name based on the current_template_name. """ if not any(relative_name.startswith(x) for x in ["'./", "'../", '"./', '"../']): # relative_name is a...
[ "def", "construct_relative_path", "(", "current_template_name", ",", "relative_name", ")", ":", "if", "not", "any", "(", "relative_name", ".", "startswith", "(", "x", ")", "for", "x", "in", "[", "\"'./\"", ",", "\"'../\"", ",", "'\"./'", ",", "'\"../'", "]",...
[ 265, 0 ]
[ 292, 28 ]
python
en
['en', 'error', 'th']
False
do_extends
(parser, token)
Signal that this template extends a parent template. This tag may be used in two ways: ``{% extends "base" %}`` (with quotes) uses the literal value "base" as the name of the parent template to extend, or ``{% extends variable %}`` uses the value of ``variable`` as either the name of the parent te...
Signal that this template extends a parent template.
def do_extends(parser, token): """ Signal that this template extends a parent template. This tag may be used in two ways: ``{% extends "base" %}`` (with quotes) uses the literal value "base" as the name of the parent template to extend, or ``{% extends variable %}`` uses the value of ``variable`` a...
[ "def", "do_extends", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "!=", "2", ":", "raise", "TemplateSyntaxError", "(", "\"'%s' takes one argument\"", "%", "bits", "[", "0", "...
[ 296, 0 ]
[ 314, 45 ]
python
en
['en', 'error', 'th']
False
do_include
(parser, token)
Loads a template and renders it with the current context. You can pass additional context using keyword arguments. Example:: {% include "foo/some_include" %} {% include "foo/some_include" with bar="BAZZ!" baz="BING!" %} Use the ``only`` argument to exclude the current context when re...
Loads a template and renders it with the current context. You can pass additional context using keyword arguments.
def do_include(parser, token): """ Loads a template and renders it with the current context. You can pass additional context using keyword arguments. Example:: {% include "foo/some_include" %} {% include "foo/some_include" with bar="BAZZ!" baz="BING!" %} Use the ``only`` argument ...
[ "def", "do_include", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "<", "2", ":", "raise", "TemplateSyntaxError", "(", "\"%r tag takes at least one argument: the name of the template to...
[ 318, 0 ]
[ 362, 57 ]
python
en
['en', 'error', 'th']
False
ExtendsNode.find_template
(self, template_name, context)
This is a wrapper around engine.find_template(). A history is kept in the render_context attribute between successive extends calls and passed as the skip argument. This enables extends to work recursively without extending the same template twice.
This is a wrapper around engine.find_template(). A history is kept in the render_context attribute between successive extends calls and passed as the skip argument. This enables extends to work recursively without extending the same template twice.
def find_template(self, template_name, context): """ This is a wrapper around engine.find_template(). A history is kept in the render_context attribute between successive extends calls and passed as the skip argument. This enables extends to work recursively without extending the...
[ "def", "find_template", "(", "self", ",", "template_name", ",", "context", ")", ":", "# RemovedInDjango20Warning: If any non-recursive loaders are installed", "# do a direct template lookup. If the same template name appears twice,", "# raise an exception to avoid system recursion.", "for"...
[ 102, 4 ]
[ 133, 23 ]
python
en
['en', 'error', 'th']
False
IncludeNode.render
(self, context)
Render the specified template and context. Cache the template object in render_context to avoid reparsing and loading when used in a for loop.
Render the specified template and context. Cache the template object in render_context to avoid reparsing and loading when used in a for loop.
def render(self, context): """ Render the specified template and context. Cache the template object in render_context to avoid reparsing and loading when used in a for loop. """ try: template = self.template.resolve(context) # Does this quack like ...
[ "def", "render", "(", "self", ",", "context", ")", ":", "try", ":", "template", "=", "self", ".", "template", ".", "resolve", "(", "context", ")", "# Does this quack like a Template?", "if", "not", "callable", "(", "getattr", "(", "template", ",", "'render'"...
[ 188, 4 ]
[ 233, 21 ]
python
en
['en', 'error', 'th']
False
is_mm_32_format
(msg_string: Optional[str])
Missed message strings are formatted with a little "mm" prefix followed by a randomly generated 32-character string.
Missed message strings are formatted with a little "mm" prefix followed by a randomly generated 32-character string.
def is_mm_32_format(msg_string: Optional[str]) -> bool: """ Missed message strings are formatted with a little "mm" prefix followed by a randomly generated 32-character string. """ return msg_string is not None and msg_string.startswith("mm") and len(msg_string) == 34
[ "def", "is_mm_32_format", "(", "msg_string", ":", "Optional", "[", "str", "]", ")", "->", "bool", ":", "return", "msg_string", "is", "not", "None", "and", "msg_string", ".", "startswith", "(", "\"mm\"", ")", "and", "len", "(", "msg_string", ")", "==", "3...
[ 120, 0 ]
[ 125, 91 ]
python
en
['en', 'error', 'th']
False
set_language
(request)
Redirect to a given url while setting the chosen language in the session or cookie. The url and the language code need to be specified in the request parameters. Since this view changes how the user will see the rest of the site, it must only be accessed as a POST request. If called as a GET reque...
Redirect to a given url while setting the chosen language in the session or cookie. The url and the language code need to be specified in the request parameters.
def set_language(request): """ Redirect to a given url while setting the chosen language in the session or cookie. The url and the language code need to be specified in the request parameters. Since this view changes how the user will see the rest of the site, it must only be accessed as a POST...
[ "def", "set_language", "(", "request", ")", ":", "next", "=", "request", ".", "POST", ".", "get", "(", "'next'", ",", "request", ".", "GET", ".", "get", "(", "'next'", ")", ")", "if", "(", "(", "next", "or", "not", "request", ".", "is_ajax", "(", ...
[ 27, 0 ]
[ 63, 19 ]
python
en
['en', 'error', 'th']
False
get_formats
()
Returns all formats strings required for i18n to work
Returns all formats strings required for i18n to work
def get_formats(): """ Returns all formats strings required for i18n to work """ FORMAT_SETTINGS = ( 'DATE_FORMAT', 'DATETIME_FORMAT', 'TIME_FORMAT', 'YEAR_MONTH_FORMAT', 'MONTH_DAY_FORMAT', 'SHORT_DATE_FORMAT', 'SHORT_DATETIME_FORMAT', 'FIRST_DAY_OF_WEEK', 'DECIMAL_SEPARATOR', ...
[ "def", "get_formats", "(", ")", ":", "FORMAT_SETTINGS", "=", "(", "'DATE_FORMAT'", ",", "'DATETIME_FORMAT'", ",", "'TIME_FORMAT'", ",", "'YEAR_MONTH_FORMAT'", ",", "'MONTH_DAY_FORMAT'", ",", "'SHORT_DATE_FORMAT'", ",", "'SHORT_DATETIME_FORMAT'", ",", "'FIRST_DAY_OF_WEEK'"...
[ 66, 0 ]
[ 86, 18 ]
python
en
['en', 'error', 'th']
False
null_javascript_catalog
(request, domain=None, packages=None)
Returns "identity" versions of the JavaScript i18n functions -- i.e., versions that don't actually do anything.
Returns "identity" versions of the JavaScript i18n functions -- i.e., versions that don't actually do anything.
def null_javascript_catalog(request, domain=None, packages=None): """ Returns "identity" versions of the JavaScript i18n functions -- i.e., versions that don't actually do anything. """ return render_javascript_catalog()
[ "def", "null_javascript_catalog", "(", "request", ",", "domain", "=", "None", ",", "packages", "=", "None", ")", ":", "return", "render_javascript_catalog", "(", ")" ]
[ 275, 0 ]
[ 280, 38 ]
python
en
['en', 'error', 'th']
False
javascript_catalog
(request, domain='djangojs', packages=None)
Returns the selected language catalog as a javascript library. Receives the list of packages to check for translations in the packages parameter either from an infodict or as a +-delimited string from the request. Default is 'django.conf'. Additionally you can override the gettext domain for this...
Returns the selected language catalog as a javascript library.
def javascript_catalog(request, domain='djangojs', packages=None): """ Returns the selected language catalog as a javascript library. Receives the list of packages to check for translations in the packages parameter either from an infodict or as a +-delimited string from the request. Default is 'dj...
[ "def", "javascript_catalog", "(", "request", ",", "domain", "=", "'djangojs'", ",", "packages", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"The javascript_catalog() view is deprecated in favor of the \"", "\"JavaScriptCatalog view.\"", ",", "RemovedInDjango20War...
[ 283, 0 ]
[ 303, 53 ]
python
en
['en', 'error', 'th']
False
json_catalog
(request, domain='djangojs', packages=None)
Return the selected language catalog as a JSON object. Receives the same parameters as javascript_catalog(), but returns a response with a JSON object of the following format: { "catalog": { # Translations catalog }, "formats": { ...
Return the selected language catalog as a JSON object.
def json_catalog(request, domain='djangojs', packages=None): """ Return the selected language catalog as a JSON object. Receives the same parameters as javascript_catalog(), but returns a response with a JSON object of the following format: { "catalog": { # Translat...
[ "def", "json_catalog", "(", "request", ",", "domain", "=", "'djangojs'", ",", "packages", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"The json_catalog() view is deprecated in favor of the \"", "\"JSONCatalog view.\"", ",", "RemovedInDjango20Warning", ",", "s...
[ 306, 0 ]
[ 335, 34 ]
python
en
['en', 'error', 'th']
False
ModuleMock.prepare
(self)
:raise self.prepare_exc:
:raise self.prepare_exc:
def prepare(self): """ :raise self.prepare_exc: """ self.log.info("Preparing mock") self.was_prepare = True self.check_iterations = int(self.settings.get('check_iterations', "2")) self.postproc_exc = self.get_exc("postproc") self.check_exc = self.get_exc("...
[ "def", "prepare", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Preparing mock\"", ")", "self", ".", "was_prepare", "=", "True", "self", ".", "check_iterations", "=", "int", "(", "self", ".", "settings", ".", "get", "(", "'check_iterati...
[ 160, 4 ]
[ 182, 34 ]
python
en
['en', 'error', 'th']
False
ModuleMock.startup
(self)
:raise self.startup_exc:
:raise self.startup_exc:
def startup(self): """ :raise self.startup_exc: """ self.log.info("Startup mock") self.was_startup = True if self.startup_exc: raise self.startup_exc
[ "def", "startup", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Startup mock\"", ")", "self", ".", "was_startup", "=", "True", "if", "self", ".", "startup_exc", ":", "raise", "self", ".", "startup_exc" ]
[ 184, 4 ]
[ 191, 34 ]
python
en
['en', 'error', 'th']
False
ModuleMock.check
(self)
:return: :raise self.check_exc:
:return: :raise self.check_exc:
def check(self): """ :return: :raise self.check_exc: """ self.was_check = True self.log.info("Checks remaining: %s", self.check_iterations) self.check_iterations -= 1 if not self.check_iterations: if self.check_exc: raise self.check_exc...
[ "def", "check", "(", "self", ")", ":", "self", ".", "was_check", "=", "True", "self", ".", "log", ".", "info", "(", "\"Checks remaining: %s\"", ",", "self", ".", "check_iterations", ")", "self", ".", "check_iterations", "-=", "1", "if", "not", "self", "....
[ 193, 4 ]
[ 205, 20 ]
python
en
['en', 'error', 'th']
False
ModuleMock.shutdown
(self)
:raise self.shutdown_exc:
:raise self.shutdown_exc:
def shutdown(self): """ :raise self.shutdown_exc: """ self.log.info("Shutdown mock") self.was_shutdown = True if self.shutdown_exc: raise self.shutdown_exc
[ "def", "shutdown", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Shutdown mock\"", ")", "self", ".", "was_shutdown", "=", "True", "if", "self", ".", "shutdown_exc", ":", "raise", "self", ".", "shutdown_exc" ]
[ 207, 4 ]
[ 214, 35 ]
python
en
['en', 'error', 'th']
False
ModuleMock.post_process
(self)
:raise self.postproc_exc:
:raise self.postproc_exc:
def post_process(self): """ :raise self.postproc_exc: """ self.log.info("Postproc mock") self.was_postproc = True if self.postproc_exc: raise self.postproc_exc
[ "def", "post_process", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Postproc mock\"", ")", "self", ".", "was_postproc", "=", "True", "if", "self", ".", "postproc_exc", ":", "raise", "self", ".", "postproc_exc" ]
[ 216, 4 ]
[ 223, 35 ]
python
en
['en', 'error', 'th']
False
ModuleMock.get_exc
(self, param)
:type param: str :return:
:type param: str :return:
def get_exc(self, param): """ :type param: str :return: """ name = self.settings.get(param, "") if name: cls = load_class(name) return cls() return None
[ "def", "get_exc", "(", "self", ",", "param", ")", ":", "name", "=", "self", ".", "settings", ".", "get", "(", "param", ",", "\"\"", ")", "if", "name", ":", "cls", "=", "load_class", "(", "name", ")", "return", "cls", "(", ")", "return", "None" ]
[ 225, 4 ]
[ 234, 19 ]
python
en
['en', 'error', 'th']
False
ModuleMock.resource_files
(self)
:return:
:return:
def resource_files(self): """ :return: """ self.execution.get('files', [], force_set=True).append(__file__) return [__file__]
[ "def", "resource_files", "(", "self", ")", ":", "self", ".", "execution", ".", "get", "(", "'files'", ",", "[", "]", ",", "force_set", "=", "True", ")", ".", "append", "(", "__file__", ")", "return", "[", "__file__", "]" ]
[ 236, 4 ]
[ 241, 25 ]
python
en
['en', 'error', 'th']
False
MockReader._read
(self, final_pass=False)
Emulating read samples :type final_pass: bool :return:
Emulating read samples
def _read(self, final_pass=False): """ Emulating read samples :type final_pass: bool :return: """ while self.data: yield self.data.pop(0)
[ "def", "_read", "(", "self", ",", "final_pass", "=", "False", ")", ":", "while", "self", ".", "data", ":", "yield", "self", ".", "data", ".", "pop", "(", "0", ")" ]
[ 265, 4 ]
[ 273, 34 ]
python
en
['en', 'error', 'th']
False
MockReader.aggregated_second
(self, data)
Store and assert aggregate sequence :type data: dict :raise AssertionError:
Store and assert aggregate sequence
def aggregated_second(self, data): """ Store and assert aggregate sequence :type data: dict :raise AssertionError: """ if self.results: if self.results[-1]["ts"] >= data["ts"]: raise AssertionError("TS sequence wrong: %s>=%s" % (self.results[-...
[ "def", "aggregated_second", "(", "self", ",", "data", ")", ":", "if", "self", ".", "results", ":", "if", "self", ".", "results", "[", "-", "1", "]", "[", "\"ts\"", "]", ">=", "data", "[", "\"ts\"", "]", ":", "raise", "AssertionError", "(", "\"TS sequ...
[ 275, 4 ]
[ 285, 33 ]
python
en
['en', 'error', 'th']
False
BZMock.__init__
(self, obj=None)
:type obj: bzt.bza.BZAObject
:type obj: bzt.bza.BZAObject
def __init__(self, obj=None): """ :type obj: bzt.bza.BZAObject """ super(BZMock, self).__init__() locs = [{'id': 'aws', 'sandbox': False, 'title': 'AWS'}, {'id': 'us-east-1', 'sandbox': False, 'title': 'East'}, {'id': 'us-west', 'sandbox': False, '...
[ "def", "__init__", "(", "self", ",", "obj", "=", "None", ")", ":", "super", "(", "BZMock", ",", "self", ")", ".", "__init__", "(", ")", "locs", "=", "[", "{", "'id'", ":", "'aws'", ",", "'sandbox'", ":", "False", ",", "'title'", ":", "'AWS'", "}"...
[ 352, 4 ]
[ 388, 27 ]
python
en
['en', 'error', 'th']
False
BZMock._request_mock
(self, method, url, **kwargs)
:param method: :param url: :param kwargs: :rtype: requests.Response
:param method: :param url: :param kwargs: :rtype: requests.Response
def _request_mock(self, method, url, **kwargs): """ :param method: :param url: :param kwargs: :rtype: requests.Response """ # TODO: make it simplier, mocking and replacing requests.request of BZAObject if method == 'GET': resp = self.mock_get[u...
[ "def", "_request_mock", "(", "self", ",", "method", ",", "url", ",", "*", "*", "kwargs", ")", ":", "# TODO: make it simplier, mocking and replacing requests.request of BZAObject", "if", "method", "==", "'GET'", ":", "resp", "=", "self", ".", "mock_get", "[", "url"...
[ 394, 4 ]
[ 423, 23 ]
python
en
['en', 'error', 'th']
False
do_widget_post_save_actions
(send_request: SendMessageRequest)
This code works with the web app; mobile and other clients should also start supporting this soon.
This code works with the web app; mobile and other clients should also start supporting this soon.
def do_widget_post_save_actions(send_request: SendMessageRequest) -> None: """ This code works with the web app; mobile and other clients should also start supporting this soon. """ message_content = send_request.message.content sender_id = send_request.message.sender_id message_id = send_re...
[ "def", "do_widget_post_save_actions", "(", "send_request", ":", "SendMessageRequest", ")", "->", "None", ":", "message_content", "=", "send_request", ".", "message", ".", "content", "sender_id", "=", "send_request", ".", "message", ".", "sender_id", "message_id", "=...
[ 46, 0 ]
[ 78, 75 ]
python
en
['en', 'error', 'th']
False
test_job_survey_password_redaction
(job_with_survey)
Tests the Job model's funciton to redact passwords from extra_vars - used when displaying job information
Tests the Job model's funciton to redact passwords from extra_vars - used when displaying job information
def test_job_survey_password_redaction(job_with_survey): """Tests the Job model's funciton to redact passwords from extra_vars - used when displaying job information""" assert json.loads(job_with_survey.display_extra_vars()) == {'submitter_email': 'foobar@redhat.com', 'secret_key': '$encrypted$', 'SSN': '$e...
[ "def", "test_job_survey_password_redaction", "(", "job_with_survey", ")", ":", "assert", "json", ".", "loads", "(", "job_with_survey", ".", "display_extra_vars", "(", ")", ")", "==", "{", "'submitter_email'", ":", "'foobar@redhat.com'", ",", "'secret_key'", ":", "'$...
[ 94, 0 ]
[ 97, 154 ]
python
en
['en', 'en', 'en']
True
test_survey_passwords_not_in_extra_vars
()
Tests that survey passwords not included in extra_vars are not included when displaying job information
Tests that survey passwords not included in extra_vars are not included when displaying job information
def test_survey_passwords_not_in_extra_vars(): """Tests that survey passwords not included in extra_vars are not included when displaying job information""" job = Job( name="test-survey-not-in", extra_vars=json.dumps({'submitter_email': 'foobar@redhat.com'}), survey_passwords={'secre...
[ "def", "test_survey_passwords_not_in_extra_vars", "(", ")", ":", "job", "=", "Job", "(", "name", "=", "\"test-survey-not-in\"", ",", "extra_vars", "=", "json", ".", "dumps", "(", "{", "'submitter_email'", ":", "'foobar@redhat.com'", "}", ")", ",", "survey_password...
[ 101, 0 ]
[ 111, 5 ]
python
en
['en', 'en', 'en']
True
always_want
(msg_type: str)
This function is used as a helper in fetch_initial_state_data, when the user passes in None for event_types, and we want to fetch info for every event type. Defining this at module level makes it easier to mock.
This function is used as a helper in fetch_initial_state_data, when the user passes in None for event_types, and we want to fetch info for every event type. Defining this at module level makes it easier to mock.
def always_want(msg_type: str) -> bool: """ This function is used as a helper in fetch_initial_state_data, when the user passes in None for event_types, and we want to fetch info for every event type. Defining this at module level makes it easier to mock. """ return True
[ "def", "always_want", "(", "msg_type", ":", "str", ")", "->", "bool", ":", "return", "True" ]
[ 86, 0 ]
[ 94, 15 ]
python
en
['en', 'error', 'th']
False
fetch_initial_state_data
( user_profile: Optional[UserProfile], *, realm: Optional[Realm] = None, event_types: Optional[Iterable[str]] = None, queue_id: Optional[str] = "", client_gravatar: bool = False, user_avatar_url_field_optional: bool = False, slim_presence: bool = False, include_subscribers: bool = Tr...
When `event_types` is None, fetches the core data powering the web app's `page_params` and `/api/v1/register` (for mobile/terminal apps). Can also fetch a subset as determined by `event_types`. The user_profile=None code path is used for logged-out public access to streams with is_web_public=True. ...
When `event_types` is None, fetches the core data powering the web app's `page_params` and `/api/v1/register` (for mobile/terminal apps). Can also fetch a subset as determined by `event_types`.
def fetch_initial_state_data( user_profile: Optional[UserProfile], *, realm: Optional[Realm] = None, event_types: Optional[Iterable[str]] = None, queue_id: Optional[str] = "", client_gravatar: bool = False, user_avatar_url_field_optional: bool = False, slim_presence: bool = False, in...
[ "def", "fetch_initial_state_data", "(", "user_profile", ":", "Optional", "[", "UserProfile", "]", ",", "*", ",", "realm", ":", "Optional", "[", "Realm", "]", "=", "None", ",", "event_types", ":", "Optional", "[", "Iterable", "[", "str", "]", "]", "=", "N...
[ 97, 0 ]
[ 531, 16 ]
python
en
['en', 'en', 'en']
True
post_process_state
( user_profile: Optional[UserProfile], ret: Dict[str, Any], notification_settings_null: bool )
NOTE: Below is an example of post-processing initial state data AFTER we apply events. For large payloads like `unread_msgs`, it's helpful to have an intermediate data structure that is easy to manipulate with O(1)-type operations as we apply events. Then, only at the end, we put it in the f...
NOTE:
def post_process_state( user_profile: Optional[UserProfile], ret: Dict[str, Any], notification_settings_null: bool ) -> None: """ NOTE: Below is an example of post-processing initial state data AFTER we apply events. For large payloads like `unread_msgs`, it's helpful to have an intermediate d...
[ "def", "post_process_state", "(", "user_profile", ":", "Optional", "[", "UserProfile", "]", ",", "ret", ":", "Dict", "[", "str", ",", "Any", "]", ",", "notification_settings_null", ":", "bool", ")", "->", "None", ":", "if", "\"raw_unread_msgs\"", "in", "ret"...
[ 1229, 0 ]
[ 1289, 13 ]
python
en
['en', 'error', 'th']
False
reverse_gfk
(content_object, request)
Computes a reverse for a GenericForeignKey field. Returns a dictionary of the form { '<type>': reverse(<type detail>) } for example { 'organization': '/api/v2/organizations/1/' }
Computes a reverse for a GenericForeignKey field.
def reverse_gfk(content_object, request): """ Computes a reverse for a GenericForeignKey field. Returns a dictionary of the form { '<type>': reverse(<type detail>) } for example { 'organization': '/api/v2/organizations/1/' } """ if content_object is None or not hasattr(content_o...
[ "def", "reverse_gfk", "(", "content_object", ",", "request", ")", ":", "if", "content_object", "is", "None", "or", "not", "hasattr", "(", "content_object", ",", "'get_absolute_url'", ")", ":", "return", "{", "}", "return", "{", "camelcase_to_underscore", "(", ...
[ 180, 0 ]
[ 192, 121 ]
python
en
['en', 'error', 'th']
False
BaseSerializer.filter_field_metadata
(self, fields, method)
Filter field metadata based on the request method. This it intended to be extended by subclasses.
Filter field metadata based on the request method. This it intended to be extended by subclasses.
def filter_field_metadata(self, fields, method): """ Filter field metadata based on the request method. This it intended to be extended by subclasses. """ return fields
[ "def", "filter_field_metadata", "(", "self", ",", "fields", ",", "method", ")", ":", "return", "fields" ]
[ 370, 4 ]
[ 375, 21 ]
python
en
['en', 'error', 'th']
False
BaseSerializer._obj_capability_dict
(self, obj)
Returns the user_capabilities dictionary for a single item If inside of a list view, it runs the prefetching algorithm for the entire current page, saves it into context
Returns the user_capabilities dictionary for a single item If inside of a list view, it runs the prefetching algorithm for the entire current page, saves it into context
def _obj_capability_dict(self, obj): """ Returns the user_capabilities dictionary for a single item If inside of a list view, it runs the prefetching algorithm for the entire current page, saves it into context """ view = self.context.get('view', None) parent_obj ...
[ "def", "_obj_capability_dict", "(", "self", ",", "obj", ")", ":", "view", "=", "self", ".", "context", ".", "get", "(", "'view'", ",", "None", ")", "parent_obj", "=", "None", "if", "view", "and", "hasattr", "(", "view", ",", "'parent_model'", ")", "and...
[ 465, 4 ]
[ 495, 21 ]
python
en
['en', 'error', 'th']
False
is_class_or_instance
(obj, cls)
returns True is obj is an instance of cls or is cls itself
returns True is obj is an instance of cls or is cls itself
def is_class_or_instance(obj, cls): """returns True is obj is an instance of cls or is cls itself""" return isinstance(obj, cls) or obj is cls
[ "def", "is_class_or_instance", "(", "obj", ",", "cls", ")", ":", "return", "isinstance", "(", "obj", ",", "cls", ")", "or", "obj", "is", "cls" ]
[ 129, 0 ]
[ 131, 45 ]
python
en
['en', 'en', 'en']
True
filter_by_class
(*item_class_tuples)
takes an arbitrary number of (item, class) tuples and returns a list consisting of each item if it's an instance of the class, the item if it's a (class, dict()) tuple, the class itself if item is truthy but not an instance of the class or (class, dict()) tuple, or None if item is falsy in the same order as...
takes an arbitrary number of (item, class) tuples and returns a list consisting of each item if it's an instance of the class, the item if it's a (class, dict()) tuple, the class itself if item is truthy but not an instance of the class or (class, dict()) tuple, or None if item is falsy in the same order as...
def filter_by_class(*item_class_tuples): """takes an arbitrary number of (item, class) tuples and returns a list consisting of each item if it's an instance of the class, the item if it's a (class, dict()) tuple, the class itself if item is truthy but not an instance of the class or (class, dict()) tupl...
[ "def", "filter_by_class", "(", "*", "item_class_tuples", ")", ":", "results", "=", "[", "]", "for", "item", ",", "cls", "in", "item_class_tuples", ":", "if", "item", ":", "was_tuple", "=", "False", "if", "isinstance", "(", "item", ",", "tuple", ")", ":",...
[ 134, 0 ]
[ 163, 18 ]
python
en
['en', 'en', 'en']
True
poll_until
(function, interval=5, timeout=0)
Polls `function` every `interval` seconds until it returns a non-falsey value. If this does not occur within the provided `timeout`, a WaitUntilTimeout is raised. Each attempt will log the time that has elapsed since the original request.
Polls `function` every `interval` seconds until it returns a non-falsey value. If this does not occur within the provided `timeout`, a WaitUntilTimeout is raised.
def poll_until(function, interval=5, timeout=0): """Polls `function` every `interval` seconds until it returns a non-falsey value. If this does not occur within the provided `timeout`, a WaitUntilTimeout is raised. Each attempt will log the time that has elapsed since the original request. """ ...
[ "def", "poll_until", "(", "function", ",", "interval", "=", "5", ",", "timeout", "=", "0", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "while", "True", ":", "elapsed", "=", "time", ".", "time", "(", ")", "-", "start_time", "log", "....
[ 209, 0 ]
[ 233, 37 ]
python
en
['en', 'en', 'en']
True
random_ipv4
()
Generates a random ipv4 address;; useful for testing.
Generates a random ipv4 address;; useful for testing.
def random_ipv4(): """Generates a random ipv4 address;; useful for testing.""" return ".".join(str(random.randint(1, 255)) for i in range(4))
[ "def", "random_ipv4", "(", ")", ":", "return", "\".\"", ".", "join", "(", "str", "(", "random", ".", "randint", "(", "1", ",", "255", ")", ")", "for", "i", "in", "range", "(", "4", ")", ")" ]
[ 250, 0 ]
[ 252, 66 ]
python
en
['en', 'cy', 'en']
True