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
OpenAPIArgumentsTest.get_standardized_argument_type
(self, t: Any)
Given a type from the typing module such as List[str] or Union[str, int], convert it into a corresponding Python type. Unions are mapped to a canonical choice among the options. E.g. typing.Union[typing.List[typing.Dict[str, typing.Any]], NoneType] needs to be mapped to list.
Given a type from the typing module such as List[str] or Union[str, int], convert it into a corresponding Python type. Unions are mapped to a canonical choice among the options. E.g. typing.Union[typing.List[typing.Dict[str, typing.Any]], NoneType] needs to be mapped to list.
def get_standardized_argument_type(self, t: Any) -> Union[type, Tuple[type, object]]: """Given a type from the typing module such as List[str] or Union[str, int], convert it into a corresponding Python type. Unions are mapped to a canonical choice among the options. E.g. typing.Union[typ...
[ "def", "get_standardized_argument_type", "(", "self", ",", "t", ":", "Any", ")", "->", "Union", "[", "type", ",", "Tuple", "[", "type", ",", "object", "]", "]", ":", "origin", "=", "getattr", "(", "t", ",", "\"__origin__\"", ",", "None", ")", "if", "...
[ 360, 4 ]
[ 390, 56 ]
python
en
['en', 'en', 'en']
True
OpenAPIArgumentsTest.render_openapi_type_exception
( self, function: Callable[..., HttpResponse], openapi_params: Set[Tuple[str, Union[type, Tuple[type, object]]]], function_params: Set[Tuple[str, Union[type, Tuple[type, object]]]], diff: Set[Tuple[str, Union[type, Tuple[type, object]]]], )
Print a *VERY* clear and verbose error message for when the types (between the OpenAPI documentation and the function declaration) don't match.
Print a *VERY* clear and verbose error message for when the types (between the OpenAPI documentation and the function declaration) don't match.
def render_openapi_type_exception( self, function: Callable[..., HttpResponse], openapi_params: Set[Tuple[str, Union[type, Tuple[type, object]]]], function_params: Set[Tuple[str, Union[type, Tuple[type, object]]]], diff: Set[Tuple[str, Union[type, Tuple[type, object]]]], ) ->...
[ "def", "render_openapi_type_exception", "(", "self", ",", "function", ":", "Callable", "[", "...", ",", "HttpResponse", "]", ",", "openapi_params", ":", "Set", "[", "Tuple", "[", "str", ",", "Union", "[", "type", ",", "Tuple", "[", "type", ",", "object", ...
[ 392, 4 ]
[ 423, 33 ]
python
en
['en', 'en', 'en']
True
OpenAPIArgumentsTest.check_argument_types
( self, function: Callable[..., HttpResponse], openapi_parameters: List[Dict[str, Any]] )
We construct for both the OpenAPI data and the function's definition a set of tuples of the form (var_name, type) and then compare those sets to see if the OpenAPI data defines a different type than that actually accepted by the function. Otherwise, we print out the exact differences for conveni...
We construct for both the OpenAPI data and the function's definition a set of tuples of the form (var_name, type) and then compare those sets to see if the OpenAPI data defines a different type than that actually accepted by the function. Otherwise, we print out the exact differences for conveni...
def check_argument_types( self, function: Callable[..., HttpResponse], openapi_parameters: List[Dict[str, Any]] ) -> None: """We construct for both the OpenAPI data and the function's definition a set of tuples of the form (var_name, type) and then compare those sets to see if the Op...
[ "def", "check_argument_types", "(", "self", ",", "function", ":", "Callable", "[", "...", ",", "HttpResponse", "]", ",", "openapi_parameters", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ")", "->", "None", ":", "openapi_params", ":", "Set...
[ 425, 4 ]
[ 515, 95 ]
python
en
['en', 'en', 'en']
True
OpenAPIArgumentsTest.test_openapi_arguments
(self)
This end-to-end API documentation test compares the arguments defined in the actual code using @has_request_variables and REQ(), with the arguments declared in our API documentation for every API endpoint in Zulip. First, we import the fancy-Django version of zproject/urls.py by...
This end-to-end API documentation test compares the arguments defined in the actual code using @has_request_variables and REQ(), with the arguments declared in our API documentation for every API endpoint in Zulip.
def test_openapi_arguments(self) -> None: """This end-to-end API documentation test compares the arguments defined in the actual code using @has_request_variables and REQ(), with the arguments declared in our API documentation for every API endpoint in Zulip. First, we import th...
[ "def", "test_openapi_arguments", "(", "self", ")", "->", "None", ":", "from", "zproject", "import", "urls", "as", "urlconf", "# We loop through all the API patterns, looking in particular", "# for those using the rest_dispatch decorator; we then parse", "# its mapping of (HTTP_METHOD...
[ 517, 4 ]
[ 643, 55 ]
python
en
['en', 'en', 'en']
True
OpenAPIAttributesTest.test_attributes
(self)
Checks: * All endpoints have `operationId` and `tag` attributes. * All example responses match their schema. * That no opaque object exists.
Checks: * All endpoints have `operationId` and `tag` attributes. * All example responses match their schema. * That no opaque object exists.
def test_attributes(self) -> None: """ Checks: * All endpoints have `operationId` and `tag` attributes. * All example responses match their schema. * That no opaque object exists. """ EXCLUDE = ["/real-time"] VALID_TAGS = [ "users", ...
[ "def", "test_attributes", "(", "self", ")", "->", "None", ":", "EXCLUDE", "=", "[", "\"/real-time\"", "]", "VALID_TAGS", "=", "[", "\"users\"", ",", "\"server_and_organizations\"", ",", "\"authentication\"", ",", "\"real_time_events\"", ",", "\"streams\"", ",", "\...
[ 991, 4 ]
[ 1034, 21 ]
python
en
['en', 'error', 'th']
False
OpenAPIRegexTest.test_regex
(self)
Calls a few documented and undocumented endpoints and checks whether they find a match or not.
Calls a few documented and undocumented endpoints and checks whether they find a match or not.
def test_regex(self) -> None: """ Calls a few documented and undocumented endpoints and checks whether they find a match or not. """ # Some of the undocumentd endpoints which are very similar to # some of the documented endpoints. assert find_openapi_endpoint("/u...
[ "def", "test_regex", "(", "self", ")", "->", "None", ":", "# Some of the undocumentd endpoints which are very similar to", "# some of the documented endpoints.", "assert", "find_openapi_endpoint", "(", "\"/users/me/presence\"", ")", "is", "None", "assert", "find_openapi_endpoint"...
[ 1038, 4 ]
[ 1060, 97 ]
python
en
['en', 'error', 'th']
False
OpenAPIRequestValidatorTest.test_validator
(self)
Test to make sure the request validator works properly The tests cover both cases such as catching valid requests marked as invalid and making sure invalid requests are markded properly
Test to make sure the request validator works properly The tests cover both cases such as catching valid requests marked as invalid and making sure invalid requests are markded properly
def test_validator(self) -> None: """ Test to make sure the request validator works properly The tests cover both cases such as catching valid requests marked as invalid and making sure invalid requests are markded properly """ # `/users/me/subscriptions` doesn't require ...
[ "def", "test_validator", "(", "self", ")", "->", "None", ":", "# `/users/me/subscriptions` doesn't require any parameters", "validate_request", "(", "\"/users/me/subscriptions\"", ",", "\"get\"", ",", "{", "}", ",", "{", "}", ",", "False", ",", "\"200\"", ")", "with...
[ 1064, 4 ]
[ 1081, 9 ]
python
en
['en', 'error', 'th']
False
make_context
(context, request=None, **kwargs)
Create a suitable Context from a plain dict and optionally an HttpRequest.
Create a suitable Context from a plain dict and optionally an HttpRequest.
def make_context(context, request=None, **kwargs): """ Create a suitable Context from a plain dict and optionally an HttpRequest. """ if context is not None and not isinstance(context, dict): raise TypeError('context must be a dict rather than %s.' % context.__class__.__name__) if request is...
[ "def", "make_context", "(", "context", ",", "request", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "context", "is", "not", "None", "and", "not", "isinstance", "(", "context", ",", "dict", ")", ":", "raise", "TypeError", "(", "'context must be a...
[ 281, 0 ]
[ 296, 18 ]
python
en
['en', 'error', 'th']
False
BaseContext.__setitem__
(self, key, value)
Set a variable in the current context
Set a variable in the current context
def __setitem__(self, key, value): "Set a variable in the current context" self.dicts[-1][key] = value
[ "def", "__setitem__", "(", "self", ",", "key", ",", "value", ")", ":", "self", ".", "dicts", "[", "-", "1", "]", "[", "key", "]", "=", "value" ]
[ 65, 4 ]
[ 67, 35 ]
python
en
['en', 'en', 'en']
True
BaseContext.set_upward
(self, key, value)
Set a variable in one of the higher contexts if it exists there, otherwise in the current context.
Set a variable in one of the higher contexts if it exists there, otherwise in the current context.
def set_upward(self, key, value): """ Set a variable in one of the higher contexts if it exists there, otherwise in the current context. """ context = self.dicts[-1] for d in reversed(self.dicts): if key in d.keys(): context = d ...
[ "def", "set_upward", "(", "self", ",", "key", ",", "value", ")", ":", "context", "=", "self", ".", "dicts", "[", "-", "1", "]", "for", "d", "in", "reversed", "(", "self", ".", "dicts", ")", ":", "if", "key", "in", "d", ".", "keys", "(", ")", ...
[ 69, 4 ]
[ 79, 28 ]
python
en
['en', 'error', 'th']
False
BaseContext.__getitem__
(self, key)
Get a variable's value, starting at the current context and going upward
Get a variable's value, starting at the current context and going upward
def __getitem__(self, key): "Get a variable's value, starting at the current context and going upward" for d in reversed(self.dicts): if key in d: return d[key] raise KeyError(key)
[ "def", "__getitem__", "(", "self", ",", "key", ")", ":", "for", "d", "in", "reversed", "(", "self", ".", "dicts", ")", ":", "if", "key", "in", "d", ":", "return", "d", "[", "key", "]", "raise", "KeyError", "(", "key", ")" ]
[ 81, 4 ]
[ 86, 27 ]
python
en
['en', 'en', 'en']
True
BaseContext.__delitem__
(self, key)
Delete a variable from the current context
Delete a variable from the current context
def __delitem__(self, key): "Delete a variable from the current context" del self.dicts[-1][key]
[ "def", "__delitem__", "(", "self", ",", "key", ")", ":", "del", "self", ".", "dicts", "[", "-", "1", "]", "[", "key", "]" ]
[ 88, 4 ]
[ 90, 31 ]
python
en
['en', 'en', 'en']
True
BaseContext.new
(self, values=None)
Returns a new context with the same properties, but with only the values given in 'values' stored.
Returns a new context with the same properties, but with only the values given in 'values' stored.
def new(self, values=None): """ Returns a new context with the same properties, but with only the values given in 'values' stored. """ new_context = copy(self) new_context._reset_dicts(values) return new_context
[ "def", "new", "(", "self", ",", "values", "=", "None", ")", ":", "new_context", "=", "copy", "(", "self", ")", "new_context", ".", "_reset_dicts", "(", "values", ")", "return", "new_context" ]
[ 118, 4 ]
[ 125, 26 ]
python
en
['en', 'error', 'th']
False
BaseContext.flatten
(self)
Returns self.dicts as one dictionary
Returns self.dicts as one dictionary
def flatten(self): """ Returns self.dicts as one dictionary """ flat = {} for d in self.dicts: flat.update(d) return flat
[ "def", "flatten", "(", "self", ")", ":", "flat", "=", "{", "}", "for", "d", "in", "self", ".", "dicts", ":", "flat", ".", "update", "(", "d", ")", "return", "flat" ]
[ 127, 4 ]
[ 134, 19 ]
python
en
['en', 'error', 'th']
False
BaseContext.__eq__
(self, other)
Compares two contexts by comparing theirs 'dicts' attributes.
Compares two contexts by comparing theirs 'dicts' attributes.
def __eq__(self, other): """ Compares two contexts by comparing theirs 'dicts' attributes. """ if isinstance(other, BaseContext): # because dictionaries can be put in different order # we have to flatten them like in templates return self.flatten() == ...
[ "def", "__eq__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "BaseContext", ")", ":", "# because dictionaries can be put in different order", "# we have to flatten them like in templates", "return", "self", ".", "flatten", "(", ")", "==...
[ 136, 4 ]
[ 146, 20 ]
python
en
['en', 'error', 'th']
False
Context.update
(self, other_dict)
Pushes other_dict to the stack of dictionaries in the Context
Pushes other_dict to the stack of dictionaries in the Context
def update(self, other_dict): "Pushes other_dict to the stack of dictionaries in the Context" if not hasattr(other_dict, '__getitem__'): raise TypeError('other_dict must be a mapping (dictionary-like) object.') if isinstance(other_dict, BaseContext): other_dict = other_di...
[ "def", "update", "(", "self", ",", "other_dict", ")", ":", "if", "not", "hasattr", "(", "other_dict", ",", "'__getitem__'", ")", ":", "raise", "TypeError", "(", "'other_dict must be a mapping (dictionary-like) object.'", ")", "if", "isinstance", "(", "other_dict", ...
[ 177, 4 ]
[ 183, 44 ]
python
en
['en', 'en', 'en']
True
parse_color_string
(color_string)
Parses a string a user typed into a tuple of 3 integers representing the red, green and blue channels respectively. May raise a ValueError if the string cannot be parsed. The colour string must be a CSS 3 or 6 digit hex code without the '#' prefix.
Parses a string a user typed into a tuple of 3 integers representing the red, green and blue channels respectively.
def parse_color_string(color_string): """ Parses a string a user typed into a tuple of 3 integers representing the red, green and blue channels respectively. May raise a ValueError if the string cannot be parsed. The colour string must be a CSS 3 or 6 digit hex code without the '#' prefix. """...
[ "def", "parse_color_string", "(", "color_string", ")", ":", "if", "len", "(", "color_string", ")", "==", "3", ":", "r", "=", "int", "(", "color_string", "[", "0", "]", ",", "16", ")", "*", "17", "g", "=", "int", "(", "color_string", "[", "1", "]", ...
[ 47, 0 ]
[ 67, 18 ]
python
en
['en', 'error', 'th']
False
Widget.format_value
(self, value)
Return a value as it should appear when rendered in a template.
Return a value as it should appear when rendered in a template.
def format_value(self, value): """ Return a value as it should appear when rendered in a template. """ if value == '' or value is None: return None if self.is_localized: return formats.localize_input(value) return force_text(value)
[ "def", "format_value", "(", "self", ",", "value", ")", ":", "if", "value", "==", "''", "or", "value", "is", "None", ":", "return", "None", "if", "self", ".", "is_localized", ":", "return", "formats", ".", "localize_input", "(", "value", ")", "return", ...
[ 193, 4 ]
[ 201, 32 ]
python
en
['en', 'error', 'th']
False
Widget.render
(self, name, value, attrs=None, renderer=None)
Returns this Widget rendered as HTML, as a Unicode string.
Returns this Widget rendered as HTML, as a Unicode string.
def render(self, name, value, attrs=None, renderer=None): """ Returns this Widget rendered as HTML, as a Unicode string. """ context = self.get_context(name, value, attrs) return self._render(self.template_name, context, renderer)
[ "def", "render", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ",", "renderer", "=", "None", ")", ":", "context", "=", "self", ".", "get_context", "(", "name", ",", "value", ",", "attrs", ")", "return", "self", ".", "_render", ...
[ 215, 4 ]
[ 220, 66 ]
python
en
['en', 'error', 'th']
False
Widget.build_attrs
(self, base_attrs, extra_attrs=None)
Helper function for building an attribute dictionary.
Helper function for building an attribute dictionary.
def build_attrs(self, base_attrs, extra_attrs=None): "Helper function for building an attribute dictionary." attrs = base_attrs.copy() if extra_attrs is not None: attrs.update(extra_attrs) return attrs
[ "def", "build_attrs", "(", "self", ",", "base_attrs", ",", "extra_attrs", "=", "None", ")", ":", "attrs", "=", "base_attrs", ".", "copy", "(", ")", "if", "extra_attrs", "is", "not", "None", ":", "attrs", ".", "update", "(", "extra_attrs", ")", "return", ...
[ 227, 4 ]
[ 232, 20 ]
python
en
['en', 'en', 'en']
True
Widget.value_from_datadict
(self, data, files, name)
Given a dictionary of data and this widget's name, returns the value of this widget. Returns None if it's not provided.
Given a dictionary of data and this widget's name, returns the value of this widget. Returns None if it's not provided.
def value_from_datadict(self, data, files, name): """ Given a dictionary of data and this widget's name, returns the value of this widget. Returns None if it's not provided. """ return data.get(name)
[ "def", "value_from_datadict", "(", "self", ",", "data", ",", "files", ",", "name", ")", ":", "return", "data", ".", "get", "(", "name", ")" ]
[ 234, 4 ]
[ 239, 29 ]
python
en
['en', 'error', 'th']
False
Widget.id_for_label
(self, id_)
Returns the HTML ID attribute of this Widget for use by a <label>, given the ID of the field. Returns None if no ID is available. This hook is necessary because some widgets have multiple HTML elements and, thus, multiple IDs. In that case, this method should return an ID value...
Returns the HTML ID attribute of this Widget for use by a <label>, given the ID of the field. Returns None if no ID is available.
def id_for_label(self, id_): """ Returns the HTML ID attribute of this Widget for use by a <label>, given the ID of the field. Returns None if no ID is available. This hook is necessary because some widgets have multiple HTML elements and, thus, multiple IDs. In that case, this ...
[ "def", "id_for_label", "(", "self", ",", "id_", ")", ":", "return", "id_" ]
[ 244, 4 ]
[ 254, 18 ]
python
en
['en', 'error', 'th']
False
FileInput.format_value
(self, value)
File input never renders a value.
File input never renders a value.
def format_value(self, value): """File input never renders a value.""" return
[ "def", "format_value", "(", "self", ",", "value", ")", ":", "return" ]
[ 360, 4 ]
[ 362, 14 ]
python
en
['hu', 'en', 'en']
True
FileInput.value_from_datadict
(self, data, files, name)
File widgets take data from FILES, not POST
File widgets take data from FILES, not POST
def value_from_datadict(self, data, files, name): "File widgets take data from FILES, not POST" return files.get(name)
[ "def", "value_from_datadict", "(", "self", ",", "data", ",", "files", ",", "name", ")", ":", "return", "files", ".", "get", "(", "name", ")" ]
[ 364, 4 ]
[ 366, 30 ]
python
en
['en', 'en', 'en']
True
ClearableFileInput.clear_checkbox_name
(self, name)
Given the name of the file input, return the name of the clear checkbox input.
Given the name of the file input, return the name of the clear checkbox input.
def clear_checkbox_name(self, name): """ Given the name of the file input, return the name of the clear checkbox input. """ return name + '-clear'
[ "def", "clear_checkbox_name", "(", "self", ",", "name", ")", ":", "return", "name", "+", "'-clear'" ]
[ 381, 4 ]
[ 386, 30 ]
python
en
['en', 'error', 'th']
False
ClearableFileInput.clear_checkbox_id
(self, name)
Given the name of the clear checkbox input, return the HTML id for it.
Given the name of the clear checkbox input, return the HTML id for it.
def clear_checkbox_id(self, name): """ Given the name of the clear checkbox input, return the HTML id for it. """ return name + '_id'
[ "def", "clear_checkbox_id", "(", "self", ",", "name", ")", ":", "return", "name", "+", "'_id'" ]
[ 388, 4 ]
[ 392, 27 ]
python
en
['en', 'error', 'th']
False
ClearableFileInput.is_initial
(self, value)
Return whether value is considered to be initial value.
Return whether value is considered to be initial value.
def is_initial(self, value): """ Return whether value is considered to be initial value. """ return bool(value and getattr(value, 'url', False))
[ "def", "is_initial", "(", "self", ",", "value", ")", ":", "return", "bool", "(", "value", "and", "getattr", "(", "value", ",", "'url'", ",", "False", ")", ")" ]
[ 394, 4 ]
[ 398, 59 ]
python
en
['en', 'error', 'th']
False
ClearableFileInput.format_value
(self, value)
Return the file object if it has a defined url attribute.
Return the file object if it has a defined url attribute.
def format_value(self, value): """ Return the file object if it has a defined url attribute. """ if self.is_initial(value): return value
[ "def", "format_value", "(", "self", ",", "value", ")", ":", "if", "self", ".", "is_initial", "(", "value", ")", ":", "return", "value" ]
[ 400, 4 ]
[ 405, 24 ]
python
en
['en', 'error', 'th']
False
CheckboxInput.format_value
(self, value)
Only return the 'value' attribute if value isn't empty.
Only return the 'value' attribute if value isn't empty.
def format_value(self, value): """Only return the 'value' attribute if value isn't empty.""" if value is True or value is False or value is None or value == '': return return force_text(value)
[ "def", "format_value", "(", "self", ",", "value", ")", ":", "if", "value", "is", "True", "or", "value", "is", "False", "or", "value", "is", "None", "or", "value", "==", "''", ":", "return", "return", "force_text", "(", "value", ")" ]
[ 498, 4 ]
[ 502, 32 ]
python
en
['en', 'en', 'en']
True
ChoiceWidget.subwidgets
(self, name, value, attrs=None)
Yield all "subwidgets" of this widget. Used to enable iterating options from a BoundField for choice widgets.
Yield all "subwidgets" of this widget. Used to enable iterating options from a BoundField for choice widgets.
def subwidgets(self, name, value, attrs=None): """ Yield all "subwidgets" of this widget. Used to enable iterating options from a BoundField for choice widgets. """ value = self.format_value(value) for option in self.options(name, value, attrs): yield option
[ "def", "subwidgets", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ")", ":", "value", "=", "self", ".", "format_value", "(", "value", ")", "for", "option", "in", "self", ".", "options", "(", "name", ",", "value", ",", "attrs", ...
[ 552, 4 ]
[ 559, 24 ]
python
en
['en', 'error', 'th']
False
ChoiceWidget.options
(self, name, value, attrs=None)
Yield a flat list of options for this widgets.
Yield a flat list of options for this widgets.
def options(self, name, value, attrs=None): """Yield a flat list of options for this widgets.""" for group in self.optgroups(name, value, attrs): for option in group[1]: yield option
[ "def", "options", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ")", ":", "for", "group", "in", "self", ".", "optgroups", "(", "name", ",", "value", ",", "attrs", ")", ":", "for", "option", "in", "group", "[", "1", "]", ":", ...
[ 561, 4 ]
[ 565, 28 ]
python
en
['en', 'en', 'en']
True
ChoiceWidget.optgroups
(self, name, value, attrs=None)
Return a list of optgroups for this widget.
Return a list of optgroups for this widget.
def optgroups(self, name, value, attrs=None): """Return a list of optgroups for this widget.""" default = (None, [], 0) groups = [default] has_selected = False for option_value, option_label in chain(self.choices): if option_value is None: option_valu...
[ "def", "optgroups", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "None", ")", ":", "default", "=", "(", "None", ",", "[", "]", ",", "0", ")", "groups", "=", "[", "default", "]", "has_selected", "=", "False", "for", "option_value", ","...
[ 567, 4 ]
[ 602, 21 ]
python
en
['en', 'en', 'en']
True
ChoiceWidget.id_for_label
(self, id_, index='0')
Use an incremented id for each option where the main widget references the zero index.
Use an incremented id for each option where the main widget references the zero index.
def id_for_label(self, id_, index='0'): """ Use an incremented id for each option where the main widget references the zero index. """ if id_ and self.add_id_index: id_ = '%s_%s' % (id_, index) return id_
[ "def", "id_for_label", "(", "self", ",", "id_", ",", "index", "=", "'0'", ")", ":", "if", "id_", "and", "self", ".", "add_id_index", ":", "id_", "=", "'%s_%s'", "%", "(", "id_", ",", "index", ")", "return", "id_" ]
[ 630, 4 ]
[ 637, 18 ]
python
en
['en', 'error', 'th']
False
ChoiceWidget.format_value
(self, value)
Return selected values as a list.
Return selected values as a list.
def format_value(self, value): """Return selected values as a list.""" if not isinstance(value, (tuple, list)): value = [value] return [force_text(v) if v is not None else '' for v in value]
[ "def", "format_value", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "(", "tuple", ",", "list", ")", ")", ":", "value", "=", "[", "value", "]", "return", "[", "force_text", "(", "v", ")", "if", "v", "is", "not...
[ 648, 4 ]
[ 652, 70 ]
python
en
['en', 'en', 'en']
True
Select._choice_has_empty_value
(choice)
Return True if the choice's value is empty string or None.
Return True if the choice's value is empty string or None.
def _choice_has_empty_value(choice): """Return True if the choice's value is empty string or None.""" value, _ = choice return ( (isinstance(value, six.string_types) and not bool(value)) or value is None )
[ "def", "_choice_has_empty_value", "(", "choice", ")", ":", "value", ",", "_", "=", "choice", "return", "(", "(", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", "and", "not", "bool", "(", "value", ")", ")", "or", "value", "is", "None"...
[ 670, 4 ]
[ 676, 9 ]
python
en
['en', 'en', 'en']
True
Select.use_required_attribute
(self, initial)
Don't render 'required' if the first <option> has a value, as that's invalid HTML.
Don't render 'required' if the first <option> has a value, as that's invalid HTML.
def use_required_attribute(self, initial): """ Don't render 'required' if the first <option> has a value, as that's invalid HTML. """ use_required_attribute = super(Select, self).use_required_attribute(initial) # 'required' is always okay for <select multiple>. if...
[ "def", "use_required_attribute", "(", "self", ",", "initial", ")", ":", "use_required_attribute", "=", "super", "(", "Select", ",", "self", ")", ".", "use_required_attribute", "(", "initial", ")", "# 'required' is always okay for <select multiple>.", "if", "self", "."...
[ 678, 4 ]
[ 689, 113 ]
python
en
['en', 'error', 'th']
False
CheckboxSelectMultiple.id_for_label
(self, id_, index=None)
Don't include for="field_0" in <label> because clicking such a label would toggle the first checkbox.
Don't include for="field_0" in <label> because clicking such a label would toggle the first checkbox.
def id_for_label(self, id_, index=None): """" Don't include for="field_0" in <label> because clicking such a label would toggle the first checkbox. """ if index is None: return '' return super(CheckboxSelectMultiple, self).id_for_label(id_, index)
[ "def", "id_for_label", "(", "self", ",", "id_", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "return", "''", "return", "super", "(", "CheckboxSelectMultiple", ",", "self", ")", ".", "id_for_label", "(", "id_", ",", "index", ")...
[ 760, 4 ]
[ 767, 75 ]
python
en
['en', 'error', 'th']
False
MultiWidget.decompress
(self, value)
Returns a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty.
Returns a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty.
def decompress(self, value): """ Returns a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty. """ raise NotImplementedError('Subclasses must implement this method.')
[ "def", "decompress", "(", "self", ",", "value", ")", ":", "raise", "NotImplementedError", "(", "'Subclasses must implement this method.'", ")" ]
[ 835, 4 ]
[ 841, 75 ]
python
en
['en', 'error', 'th']
False
MultiWidget._get_media
(self)
Media for a multiwidget is the combination of all media of the subwidgets
Media for a multiwidget is the combination of all media of the subwidgets
def _get_media(self): "Media for a multiwidget is the combination of all media of the subwidgets" media = Media() for w in self.widgets: media = media + w.media return media
[ "def", "_get_media", "(", "self", ")", ":", "media", "=", "Media", "(", ")", "for", "w", "in", "self", ".", "widgets", ":", "media", "=", "media", "+", "w", ".", "media", "return", "media" ]
[ 843, 4 ]
[ 848, 20 ]
python
en
['en', 'en', 'en']
True
SelectDateWidget.format_value
(self, value)
Return a dict containing the year, month, and day of the current value. Use dict instead of a datetime to allow invalid dates such as February 31 to display correctly.
Return a dict containing the year, month, and day of the current value. Use dict instead of a datetime to allow invalid dates such as February 31 to display correctly.
def format_value(self, value): """ Return a dict containing the year, month, and day of the current value. Use dict instead of a datetime to allow invalid dates such as February 31 to display correctly. """ year, month, day = None, None, None if isinstance(value, ...
[ "def", "format_value", "(", "self", ",", "value", ")", ":", "year", ",", "month", ",", "day", "=", "None", ",", "None", ",", "None", "if", "isinstance", "(", "value", ",", "(", "datetime", ".", "date", ",", "datetime", ".", "datetime", ")", ")", ":...
[ 984, 4 ]
[ 1004, 57 ]
python
en
['en', 'error', 'th']
False
TestManagement.test_init_project
(self)
test the creation of a TraP project
test the creation of a TraP project
def test_init_project(self): """ test the creation of a TraP project """ # forced target, target needs to exist namespace = argparse.Namespace() namespace.name = project_name os.mkdir(self.target) namespace.target = self.target tkp.management.init_...
[ "def", "test_init_project", "(", "self", ")", ":", "# forced target, target needs to exist", "namespace", "=", "argparse", ".", "Namespace", "(", ")", "namespace", ".", "name", "=", "project_name", "os", ".", "mkdir", "(", "self", ".", "target", ")", "namespace"...
[ 26, 4 ]
[ 49, 59 ]
python
en
['en', 'error', 'th']
False
TestManagement.test_init_job
(self)
test the creation of a TraP job
test the creation of a TraP job
def test_init_job(self): """ test the creation of a TraP job """ os.chdir(self.parent) namespace = argparse.Namespace() namespace.name = project_name namespace.target = None tkp.management.init_project(namespace) os.chdir(self.target) # te...
[ "def", "test_init_job", "(", "self", ")", ":", "os", ".", "chdir", "(", "self", ".", "parent", ")", "namespace", "=", "argparse", ".", "Namespace", "(", ")", "namespace", ".", "name", "=", "project_name", "namespace", ".", "target", "=", "None", "tkp", ...
[ 51, 4 ]
[ 68, 36 ]
python
en
['en', 'error', 'th']
False
TestManagement.test_run_job
(self)
Tests init and running of job as well as argument parsing.
Tests init and running of job as well as argument parsing.
def test_run_job(self): """ Tests init and running of job as well as argument parsing. """ # Better as two separate tests? os.chdir(self.parent) init_project_args = tkp.management.get_parser().parse_args(['initproject', ...
[ "def", "test_run_job", "(", "self", ")", ":", "# Better as two separate tests?", "os", ".", "chdir", "(", "self", ".", "parent", ")", "init_project_args", "=", "tkp", ".", "management", ".", "get_parser", "(", ")", ".", "parse_args", "(", "[", "'initproject'",...
[ 70, 4 ]
[ 93, 57 ]
python
en
['en', 'error', 'th']
False
eval
(expression, _dict={}, **kw)
Evaluates an image expression. :param expression: A string containing a Python-style expression. :param options: Values to add to the evaluation context. You can either use a dictionary, or one or more keyword arguments. :return: The evaluated expression. This ...
Evaluates an image expression.
def eval(expression, _dict={}, **kw): """ Evaluates an image expression. :param expression: A string containing a Python-style expression. :param options: Values to add to the evaluation context. You can either use a dictionary, or one or more keyword arguments....
[ "def", "eval", "(", "expression", ",", "_dict", "=", "{", "}", ",", "*", "*", "kw", ")", ":", "# build execution namespace", "args", "=", "ops", ".", "copy", "(", ")", "args", ".", "update", "(", "_dict", ")", "args", ".", "update", "(", "kw", ")",...
[ 227, 0 ]
[ 252, 18 ]
python
en
['en', 'error', 'th']
False
calculate_pool_reward
(height: uint32)
Returns the pool reward at a certain block height. The pool earns 7/8 of the reward in each block. If the farmer is solo farming, they act as the pool, and therefore earn the entire block reward. These halving events will not be hit at the exact times (3 years, etc), due to fluctuations in difficulty. ...
Returns the pool reward at a certain block height. The pool earns 7/8 of the reward in each block. If the farmer is solo farming, they act as the pool, and therefore earn the entire block reward. These halving events will not be hit at the exact times (3 years, etc), due to fluctuations in difficulty. ...
def calculate_pool_reward(height: uint32) -> uint64: """ Returns the pool reward at a certain block height. The pool earns 7/8 of the reward in each block. If the farmer is solo farming, they act as the pool, and therefore earn the entire block reward. These halving events will not be hit at the exact t...
[ "def", "calculate_pool_reward", "(", "height", ":", "uint32", ")", "->", "uint64", ":", "if", "height", "==", "0", ":", "return", "uint64", "(", "int", "(", "(", "7", "/", "8", ")", "*", "300000", "*", "_mojo_per_kale", ")", ")", "elif", "height", "<...
[ 7, 0 ]
[ 27, 60 ]
python
en
['en', 'error', 'th']
False
calculate_base_farmer_reward
(height: uint32)
Returns the base farmer reward at a certain block height. The base fee reward is 1/8 of total block reward Returns the coinbase reward at a certain block height. These halving events will not be hit at the exact times (3 years, etc), due to fluctuations in difficulty. They will likely come early, if t...
Returns the base farmer reward at a certain block height. The base fee reward is 1/8 of total block reward
def calculate_base_farmer_reward(height: uint32) -> uint64: """ Returns the base farmer reward at a certain block height. The base fee reward is 1/8 of total block reward Returns the coinbase reward at a certain block height. These halving events will not be hit at the exact times (3 years, etc), d...
[ "def", "calculate_base_farmer_reward", "(", "height", ":", "uint32", ")", "->", "uint64", ":", "if", "height", "==", "0", ":", "return", "uint64", "(", "int", "(", "(", "1", "/", "8", ")", "*", "300000", "*", "_mojo_per_kale", ")", ")", "elif", "height...
[ 30, 0 ]
[ 50, 60 ]
python
en
['en', 'error', 'th']
False
dump
(o, f, encoder=None)
Writes out dict as toml to a file Args: o: Object to dump into toml f: File descriptor where the toml should be stored encoder: The ``TomlEncoder`` to use for constructing the output string Returns: String containing the toml corresponding to dictionary Raises: Typ...
Writes out dict as toml to a file
def dump(o, f, encoder=None): """Writes out dict as toml to a file Args: o: Object to dump into toml f: File descriptor where the toml should be stored encoder: The ``TomlEncoder`` to use for constructing the output string Returns: String containing the toml corresponding t...
[ "def", "dump", "(", "o", ",", "f", ",", "encoder", "=", "None", ")", ":", "if", "not", "f", ".", "write", ":", "raise", "TypeError", "(", "\"You can only dump an object to a file descriptor\"", ")", "d", "=", "dumps", "(", "o", ",", "encoder", "=", "enco...
[ 11, 0 ]
[ 30, 12 ]
python
en
['en', 'en', 'en']
True
dumps
(o, encoder=None)
Stringifies input dict as toml Args: o: Object to dump into toml encoder: The ``TomlEncoder`` to use for constructing the output string Returns: String containing the toml corresponding to dict Examples: ```python >>> import toml >>> output = { ... ...
Stringifies input dict as toml
def dumps(o, encoder=None): """Stringifies input dict as toml Args: o: Object to dump into toml encoder: The ``TomlEncoder`` to use for constructing the output string Returns: String containing the toml corresponding to dict Examples: ```python >>> import toml ...
[ "def", "dumps", "(", "o", ",", "encoder", "=", "None", ")", ":", "retval", "=", "\"\"", "if", "encoder", "is", "None", ":", "encoder", "=", "TomlEncoder", "(", "o", ".", "__class__", ")", "addtoretval", ",", "sections", "=", "encoder", ".", "dump_secti...
[ 33, 0 ]
[ 82, 17 ]
python
en
['en', 'en', 'en']
True
TomlEncoder.dump_inline_table
(self, section)
Preserve inline table in its compact syntax instead of expanding into subsection. https://github.com/toml-lang/toml#user-content-inline-table
Preserve inline table in its compact syntax instead of expanding into subsection.
def dump_inline_table(self, section): """Preserve inline table in its compact syntax instead of expanding into subsection. https://github.com/toml-lang/toml#user-content-inline-table """ retval = "" if isinstance(section, dict): val_list = [] for ...
[ "def", "dump_inline_table", "(", "self", ",", "section", ")", ":", "retval", "=", "\"\"", "if", "isinstance", "(", "section", ",", "dict", ")", ":", "val_list", "=", "[", "]", "for", "k", ",", "v", "in", "section", ".", "items", "(", ")", ":", "val...
[ 156, 4 ]
[ 171, 52 ]
python
en
['en', 'en', 'en']
True
API.__init__
(self, base_url: Optional[str] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, use_cache: Optional[bool] = False, request_rate: Optional[int] = None, bearer_token: Optional[str] = None, ...
Twitch API :param base_url: API URL :param client_id: Twitch Client ID :param use_cache: Use local API cache :param bearer_token: Twitch bearer token :param handle_rate_limit: Handle rate limits by sleeping :param cache_duration: Local cache duration
Twitch API :param base_url: API URL :param client_id: Twitch Client ID :param use_cache: Use local API cache :param bearer_token: Twitch bearer token :param handle_rate_limit: Handle rate limits by sleeping :param cache_duration: Local cache duration
def __init__(self, base_url: Optional[str] = None, client_id: Optional[str] = None, client_secret: Optional[str] = None, use_cache: Optional[bool] = False, request_rate: Optional[int] = None, bearer_token: Optional[str...
[ "def", "__init__", "(", "self", ",", "base_url", ":", "Optional", "[", "str", "]", "=", "None", ",", "client_id", ":", "Optional", "[", "str", "]", "=", "None", ",", "client_secret", ":", "Optional", "[", "str", "]", "=", "None", ",", "use_cache", ":...
[ 12, 4 ]
[ 42, 38 ]
python
en
['en', 'error', 'th']
False
Command.set_options
(self, **options)
Set instance variables based on an options dict
Set instance variables based on an options dict
def set_options(self, **options): """ Set instance variables based on an options dict """ self.interactive = options['interactive'] self.verbosity = options['verbosity'] self.symlink = options['link'] self.clear = options['clear'] self.dry_run = options['d...
[ "def", "set_options", "(", "self", ",", "*", "*", "options", ")", ":", "self", ".", "interactive", "=", "options", "[", "'interactive'", "]", "self", ".", "verbosity", "=", "options", "[", "'verbosity'", "]", "self", ".", "symlink", "=", "options", "[", ...
[ 80, 4 ]
[ 93, 51 ]
python
en
['en', 'error', 'th']
False
Command.collect
(self)
Perform the bulk of the work of collectstatic. Split off from handle() to facilitate testing.
Perform the bulk of the work of collectstatic.
def collect(self): """ Perform the bulk of the work of collectstatic. Split off from handle() to facilitate testing. """ if self.symlink and not self.local: raise CommandError("Can't symlink to a remote destination.") if self.clear: self.clear_di...
[ "def", "collect", "(", "self", ")", ":", "if", "self", ".", "symlink", "and", "not", "self", ".", "local", ":", "raise", "CommandError", "(", "\"Can't symlink to a remote destination.\"", ")", "if", "self", ".", "clear", ":", "self", ".", "clear_dir", "(", ...
[ 95, 4 ]
[ 156, 9 ]
python
en
['en', 'error', 'th']
False
Command.log
(self, msg, level=2)
Small log helper
Small log helper
def log(self, msg, level=2): """ Small log helper """ if self.verbosity >= level: self.stdout.write(msg)
[ "def", "log", "(", "self", ",", "msg", ",", "level", "=", "2", ")", ":", "if", "self", ".", "verbosity", ">=", "level", ":", "self", ".", "stdout", ".", "write", "(", "msg", ")" ]
[ 218, 4 ]
[ 223, 34 ]
python
en
['en', 'error', 'th']
False
Command.clear_dir
(self, path)
Deletes the given relative path using the destination storage backend.
Deletes the given relative path using the destination storage backend.
def clear_dir(self, path): """ Deletes the given relative path using the destination storage backend. """ if not self.storage.exists(path): return dirs, files = self.storage.listdir(path) for f in files: fpath = os.path.join(path, f) i...
[ "def", "clear_dir", "(", "self", ",", "path", ")", ":", "if", "not", "self", ".", "storage", ".", "exists", "(", "path", ")", ":", "return", "dirs", ",", "files", "=", "self", ".", "storage", ".", "listdir", "(", "path", ")", "for", "f", "in", "f...
[ 228, 4 ]
[ 253, 49 ]
python
en
['en', 'error', 'th']
False
Command.delete_file
(self, path, prefixed_path, source_storage)
Checks if the target file should be deleted if it already exists
Checks if the target file should be deleted if it already exists
def delete_file(self, path, prefixed_path, source_storage): """ Checks if the target file should be deleted if it already exists """ if self.storage.exists(prefixed_path): try: # When was the target file modified last time? target_last_modified...
[ "def", "delete_file", "(", "self", ",", "path", ",", "prefixed_path", ",", "source_storage", ")", ":", "if", "self", ".", "storage", ".", "exists", "(", "prefixed_path", ")", ":", "try", ":", "# When was the target file modified last time?", "target_last_modified", ...
[ 255, 4 ]
[ 304, 19 ]
python
en
['en', 'error', 'th']
False
Command.link_file
(self, path, prefixed_path, source_storage)
Attempt to link ``path``
Attempt to link ``path``
def link_file(self, path, prefixed_path, source_storage): """ Attempt to link ``path`` """ # Skip this file if it was already copied earlier if prefixed_path in self.symlinked_files: return self.log("Skipping '%s' (already linked earlier)" % path) # Delete the...
[ "def", "link_file", "(", "self", ",", "path", ",", "prefixed_path", ",", "source_storage", ")", ":", "# Skip this file if it was already copied earlier", "if", "prefixed_path", "in", "self", ".", "symlinked_files", ":", "return", "self", ".", "log", "(", "\"Skipping...
[ 306, 4 ]
[ 343, 54 ]
python
en
['en', 'error', 'th']
False
Command.copy_file
(self, path, prefixed_path, source_storage)
Attempt to copy ``path`` with storage
Attempt to copy ``path`` with storage
def copy_file(self, path, prefixed_path, source_storage): """ Attempt to copy ``path`` with storage """ # Skip this file if it was already copied earlier if prefixed_path in self.copied_files: return self.log("Skipping '%s' (already copied earlier)" % path) # ...
[ "def", "copy_file", "(", "self", ",", "path", ",", "prefixed_path", ",", "source_storage", ")", ":", "# Skip this file if it was already copied earlier", "if", "prefixed_path", "in", "self", ".", "copied_files", ":", "return", "self", ".", "log", "(", "\"Skipping '%...
[ 345, 4 ]
[ 364, 47 ]
python
en
['en', 'error', 'th']
False
check_password
(password, encoded, setter=None, preferred='default')
Returns a boolean of whether the raw password matches the three part encoded digest. If setter is specified, it'll be called when you need to regenerate the password.
Returns a boolean of whether the raw password matches the three part encoded digest.
def check_password(password, encoded, setter=None, preferred='default'): """ Returns a boolean of whether the raw password matches the three part encoded digest. If setter is specified, it'll be called when you need to regenerate the password. """ if password is None or not is_password_usab...
[ "def", "check_password", "(", "password", ",", "encoded", ",", "setter", "=", "None", ",", "preferred", "=", "'default'", ")", ":", "if", "password", "is", "None", "or", "not", "is_password_usable", "(", "encoded", ")", ":", "return", "False", "preferred", ...
[ 35, 0 ]
[ 62, 21 ]
python
en
['en', 'error', 'th']
False
make_password
(password, salt=None, hasher='default')
Turn a plain-text password into a hash for database storage Same as encode() but generates a new random salt. If password is None then a concatenation of UNUSABLE_PASSWORD_PREFIX and a random string will be returned which disallows logins. Additional random string reduces chances of gaining ac...
Turn a plain-text password into a hash for database storage
def make_password(password, salt=None, hasher='default'): """ Turn a plain-text password into a hash for database storage Same as encode() but generates a new random salt. If password is None then a concatenation of UNUSABLE_PASSWORD_PREFIX and a random string will be returned which disallows l...
[ "def", "make_password", "(", "password", ",", "salt", "=", "None", ",", "hasher", "=", "'default'", ")", ":", "if", "password", "is", "None", ":", "return", "UNUSABLE_PASSWORD_PREFIX", "+", "get_random_string", "(", "UNUSABLE_PASSWORD_SUFFIX_LENGTH", ")", "hasher"...
[ 65, 0 ]
[ 83, 40 ]
python
en
['en', 'error', 'th']
False
get_hasher
(algorithm='default')
Returns an instance of a loaded password hasher. If algorithm is 'default', the default hasher will be returned. This function will also lazy import hashers specified in your settings file if needed.
Returns an instance of a loaded password hasher.
def get_hasher(algorithm='default'): """ Returns an instance of a loaded password hasher. If algorithm is 'default', the default hasher will be returned. This function will also lazy import hashers specified in your settings file if needed. """ if hasattr(algorithm, 'algorithm'): re...
[ "def", "get_hasher", "(", "algorithm", "=", "'default'", ")", ":", "if", "hasattr", "(", "algorithm", ",", "'algorithm'", ")", ":", "return", "algorithm", "elif", "algorithm", "==", "'default'", ":", "return", "get_hashers", "(", ")", "[", "0", "]", "else"...
[ 111, 0 ]
[ 132, 52 ]
python
en
['en', 'error', 'th']
False
identify_hasher
(encoded)
Returns an instance of a loaded password hasher. Identifies hasher algorithm by examining encoded hash, and calls get_hasher() to return hasher. Raises ValueError if algorithm cannot be identified, or if hasher is not loaded.
Returns an instance of a loaded password hasher.
def identify_hasher(encoded): """ Returns an instance of a loaded password hasher. Identifies hasher algorithm by examining encoded hash, and calls get_hasher() to return hasher. Raises ValueError if algorithm cannot be identified, or if hasher is not loaded. """ # Ancient versions of Djang...
[ "def", "identify_hasher", "(", "encoded", ")", ":", "# Ancient versions of Django created plain MD5 passwords and accepted", "# MD5 passwords with an empty salt.", "if", "(", "(", "len", "(", "encoded", ")", "==", "32", "and", "'$'", "not", "in", "encoded", ")", "or", ...
[ 135, 0 ]
[ 153, 32 ]
python
en
['en', 'error', 'th']
False
mask_hash
(hash, show=6, char="*")
Returns the given hash, with only the first ``show`` number shown. The rest are masked with ``char`` for security reasons.
Returns the given hash, with only the first ``show`` number shown. The rest are masked with ``char`` for security reasons.
def mask_hash(hash, show=6, char="*"): """ Returns the given hash, with only the first ``show`` number shown. The rest are masked with ``char`` for security reasons. """ masked = hash[:show] masked += char * len(hash[show:]) return masked
[ "def", "mask_hash", "(", "hash", ",", "show", "=", "6", ",", "char", "=", "\"*\"", ")", ":", "masked", "=", "hash", "[", ":", "show", "]", "masked", "+=", "char", "*", "len", "(", "hash", "[", "show", ":", "]", ")", "return", "masked" ]
[ 156, 0 ]
[ 163, 17 ]
python
en
['en', 'error', 'th']
False
BasePasswordHasher.salt
(self)
Generates a cryptographically secure nonce salt in ASCII
Generates a cryptographically secure nonce salt in ASCII
def salt(self): """ Generates a cryptographically secure nonce salt in ASCII """ return get_random_string()
[ "def", "salt", "(", "self", ")", ":", "return", "get_random_string", "(", ")" ]
[ 193, 4 ]
[ 197, 34 ]
python
en
['en', 'error', 'th']
False
BasePasswordHasher.verify
(self, password, encoded)
Checks if the given password is correct
Checks if the given password is correct
def verify(self, password, encoded): """ Checks if the given password is correct """ raise NotImplementedError('subclasses of BasePasswordHasher must provide a verify() method')
[ "def", "verify", "(", "self", ",", "password", ",", "encoded", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BasePasswordHasher must provide a verify() method'", ")" ]
[ 199, 4 ]
[ 203, 100 ]
python
en
['en', 'error', 'th']
False
BasePasswordHasher.encode
(self, password, salt)
Creates an encoded database value The result is normally formatted as "algorithm$salt$hash" and must be fewer than 128 characters.
Creates an encoded database value
def encode(self, password, salt): """ Creates an encoded database value The result is normally formatted as "algorithm$salt$hash" and must be fewer than 128 characters. """ raise NotImplementedError('subclasses of BasePasswordHasher must provide an encode() method')
[ "def", "encode", "(", "self", ",", "password", ",", "salt", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BasePasswordHasher must provide an encode() method'", ")" ]
[ 205, 4 ]
[ 212, 101 ]
python
en
['en', 'error', 'th']
False
BasePasswordHasher.safe_summary
(self, encoded)
Returns a summary of safe values The result is a dictionary and will be used where the password field must be displayed to construct a safe representation of the password.
Returns a summary of safe values
def safe_summary(self, encoded): """ Returns a summary of safe values The result is a dictionary and will be used where the password field must be displayed to construct a safe representation of the password. """ raise NotImplementedError('subclasses of BasePasswordHashe...
[ "def", "safe_summary", "(", "self", ",", "encoded", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of BasePasswordHasher must provide a safe_summary() method'", ")" ]
[ 214, 4 ]
[ 221, 106 ]
python
en
['en', 'error', 'th']
False
BasePasswordHasher.harden_runtime
(self, password, encoded)
Bridge the runtime gap between the work factor supplied in `encoded` and the work factor suggested by this hasher. Taking PBKDF2 as an example, if `encoded` contains 20000 iterations and `self.iterations` is 30000, this method should run password through another 10000 iteration...
Bridge the runtime gap between the work factor supplied in `encoded` and the work factor suggested by this hasher.
def harden_runtime(self, password, encoded): """ Bridge the runtime gap between the work factor supplied in `encoded` and the work factor suggested by this hasher. Taking PBKDF2 as an example, if `encoded` contains 20000 iterations and `self.iterations` is 30000, this method sho...
[ "def", "harden_runtime", "(", "self", ",", "password", ",", "encoded", ")", ":", "warnings", ".", "warn", "(", "'subclasses of BasePasswordHasher should provide a harden_runtime() method'", ")" ]
[ 226, 4 ]
[ 237, 98 ]
python
en
['en', 'error', 'th']
False
Argon2PasswordHasher._decode
(self, encoded)
Split an encoded hash and return: ( algorithm, variety, version, time_cost, memory_cost, parallelism, salt, data, ).
Split an encoded hash and return: ( algorithm, variety, version, time_cost, memory_cost, parallelism, salt, data, ).
def _decode(self, encoded): """ Split an encoded hash and return: ( algorithm, variety, version, time_cost, memory_cost, parallelism, salt, data, ). """ bits = encoded.split('$') if len(bits) == 5: # Argon2 < 1.3 algorithm, ...
[ "def", "_decode", "(", "self", ",", "encoded", ")", ":", "bits", "=", "encoded", ".", "split", "(", "'$'", ")", "if", "len", "(", "bits", ")", "==", "5", ":", "# Argon2 < 1.3", "algorithm", ",", "variety", ",", "raw_params", ",", "salt", ",", "data",...
[ 372, 4 ]
[ 397, 9 ]
python
en
['en', 'error', 'th']
False
load_ms_cache_data
()
Load cached data from a pickle file on disk. Should really only need to be called once, on startup. :returns: None
Load cached data from a pickle file on disk. Should really only need to be called once, on startup.
def load_ms_cache_data(): """ Load cached data from a pickle file on disk. Should really only need to be called once, on startup. :returns: None """ if os.path.isfile(os.path.join(PICKLE_STORAGE, 'metasmokeCacheData.p')): data = load_pickle('metasmokeCacheData.p') MetasmokeCache._ca...
[ "def", "load_ms_cache_data", "(", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "os", ".", "path", ".", "join", "(", "PICKLE_STORAGE", ",", "'metasmokeCacheData.p'", ")", ")", ":", "data", "=", "load_pickle", "(", "'metasmokeCacheData.p'", ")", "M...
[ 102, 0 ]
[ 111, 51 ]
python
en
['en', 'error', 'th']
False
update_dataset_process_end_ts
(dataset_id)
Update dataset start-of-processing timestamp.
Update dataset start-of-processing timestamp.
def update_dataset_process_end_ts(dataset_id): """Update dataset start-of-processing timestamp. """ args = {'dataset_id': dataset_id, 'end': datetime.now()} tkp.db.execute(update_dataset_process_end_ts_query, args, commit=True) return dataset_id
[ "def", "update_dataset_process_end_ts", "(", "dataset_id", ")", ":", "args", "=", "{", "'dataset_id'", ":", "dataset_id", ",", "'end'", ":", "datetime", ".", "now", "(", ")", "}", "tkp", ".", "db", ".", "execute", "(", "update_dataset_process_end_ts_query", ",...
[ 51, 0 ]
[ 57, 21 ]
python
en
['en', 'jv', 'en']
True
insert_dataset
(description)
Insert dataset with description as given by argument.
Insert dataset with description as given by argument.
def insert_dataset(description): """ Insert dataset with description as given by argument. """ db = tkp.db.Database() dataset = alchemy_insert_dataset(db.session, description) db.session.add(dataset) db.session.commit() dataset_id = dataset.id return dataset_id
[ "def", "insert_dataset", "(", "description", ")", ":", "db", "=", "tkp", ".", "db", ".", "Database", "(", ")", "dataset", "=", "alchemy_insert_dataset", "(", "db", ".", "session", ",", "description", ")", "db", ".", "session", ".", "add", "(", "dataset",...
[ 60, 0 ]
[ 69, 21 ]
python
en
['en', 'error', 'th']
False
insert_monitor_positions
(dataset_id, positions)
Add entries to the ``monitor`` table. Args: dataset_id (int): Positions will only be monitored when processing this dataset. positions (list of tuples): List of (RA, decl) tuples in decimal degrees.
Add entries to the ``monitor`` table.
def insert_monitor_positions(dataset_id, positions): """ Add entries to the ``monitor`` table. Args: dataset_id (int): Positions will only be monitored when processing this dataset. positions (list of tuples): List of (RA, decl) tuples in decimal degrees. """ monitor_entries = ...
[ "def", "insert_monitor_positions", "(", "dataset_id", ",", "positions", ")", ":", "monitor_entries", "=", "[", "(", "dataset_id", ",", "p", "[", "0", "]", ",", "p", "[", "1", "]", ")", "for", "p", "in", "positions", "]", "insertion_query", "=", "\"\"\"\\...
[ 72, 0 ]
[ 102, 45 ]
python
en
['en', 'error', 'th']
False
insert_extracted_sources
(image_id, results, extract_type='blind', ff_runcat_ids=None, ff_monitor_ids=None)
Insert all detections from sourcefinder into the extractedsource table. Besides the source properties from sourcefinder, we calculate additional attributes that are increase performance in other tasks. The strict sequence from results (the sourcefinder detections) is given below. Note the units b...
Insert all detections from sourcefinder into the extractedsource table.
def insert_extracted_sources(image_id, results, extract_type='blind', ff_runcat_ids=None, ff_monitor_ids=None): """ Insert all detections from sourcefinder into the extractedsource table. Besides the source properties from sourcefinder, we calculate additional attributes th...
[ "def", "insert_extracted_sources", "(", "image_id", ",", "results", ",", "extract_type", "=", "'blind'", ",", "ff_runcat_ids", "=", "None", ",", "ff_monitor_ids", "=", "None", ")", ":", "if", "not", "len", "(", "results", ")", ":", "logger", ".", "debug", ...
[ 105, 0 ]
[ 281, 65 ]
python
en
['en', 'error', 'th']
False
lightcurve
(xtrsrcid)
Obtain a light curve for a specific extractedsource Args: xtrsrcid (int): the source identifier that corresponds to a point on the light curve. Note that the point does not have to be the start (first) point of the light curve. Returns: (tuple): a list of tuples, ...
Obtain a light curve for a specific extractedsource
def lightcurve(xtrsrcid): """ Obtain a light curve for a specific extractedsource Args: xtrsrcid (int): the source identifier that corresponds to a point on the light curve. Note that the point does not have to be the start (first) point of the light curve. Returns: ...
[ "def", "lightcurve", "(", "xtrsrcid", ")", ":", "args", "=", "{", "'xtrsrc'", ":", "xtrsrcid", "}", "cursor", "=", "tkp", ".", "db", ".", "execute", "(", "lightcurve_query", ",", "args", ")", "return", "cursor", ".", "fetchall", "(", ")" ]
[ 284, 0 ]
[ 306, 28 ]
python
en
['en', 'error', 'th']
False
frequency_bands
(dataset_id)
Return a list of distinct bands present in the dataset.
Return a list of distinct bands present in the dataset.
def frequency_bands(dataset_id): """Return a list of distinct bands present in the dataset.""" query = """\ SELECT DISTINCT(band) FROM image WHERE dataset = %s """ cursor = tkp.db.execute(query, (dataset_id,)) bands = zip(*cursor.fetchall())[0] return bands
[ "def", "frequency_bands", "(", "dataset_id", ")", ":", "query", "=", "\"\"\"\\\n SELECT DISTINCT(band)\n FROM image\n WHERE dataset = %s\n \"\"\"", "cursor", "=", "tkp", ".", "db", ".", "execute", "(", "query", ",", "(", "dataset_id", ",", ")", ")", "ba...
[ 309, 0 ]
[ 318, 16 ]
python
en
['en', 'en', 'en']
True
runcat_entries
(dataset_id)
Returns: (tuple): a list of dictionarys representing rows in runningcatalog, for all sources belonging to this dataset Column 'id' is returned with the key 'runcat' Currently only returns 3 columns: [{'runcat,'xtrsrc','datapoints'}]
Returns: (tuple): a list of dictionarys representing rows in runningcatalog, for all sources belonging to this dataset
def runcat_entries(dataset_id): """ Returns: (tuple): a list of dictionarys representing rows in runningcatalog, for all sources belonging to this dataset Column 'id' is returned with the key 'runcat' Currently only returns 3 columns: [{'runcat,'xtrsrc','datapoints'}] ...
[ "def", "runcat_entries", "(", "dataset_id", ")", ":", "return", "columns_from_table", "(", "'runningcatalog'", ",", "keywords", "=", "[", "'id'", ",", "'xtrsrc'", ",", "'datapoints'", "]", ",", "alias", "=", "{", "'id'", ":", "'runcat'", "}", ",", "where", ...
[ 321, 0 ]
[ 335, 60 ]
python
en
['en', 'error', 'th']
False
_get_blocks_at_height
( blocks: BlockchainInterface, prev_b: BlockRecord, target_height: uint32, max_num_blocks: uint32 = uint32(1), )
Return a consecutive list of BlockRecords starting at target_height, returning a maximum of max_num_blocks. Assumes all block records are present. Does a slot linear search, if the blocks are not in the path of the peak. Can only fetch ancestors of prev_b. Args: blocks: dict from header hash t...
Return a consecutive list of BlockRecords starting at target_height, returning a maximum of max_num_blocks. Assumes all block records are present. Does a slot linear search, if the blocks are not in the path of the peak. Can only fetch ancestors of prev_b.
def _get_blocks_at_height( blocks: BlockchainInterface, prev_b: BlockRecord, target_height: uint32, max_num_blocks: uint32 = uint32(1), ) -> List[BlockRecord]: """ Return a consecutive list of BlockRecords starting at target_height, returning a maximum of max_num_blocks. Assumes all block re...
[ "def", "_get_blocks_at_height", "(", "blocks", ":", "BlockchainInterface", ",", "prev_b", ":", "BlockRecord", ",", "target_height", ":", "uint32", ",", "max_num_blocks", ":", "uint32", "=", "uint32", "(", "1", ")", ",", ")", "->", "List", "[", "BlockRecord", ...
[ 10, 0 ]
[ 48, 40 ]
python
en
['en', 'error', 'th']
False
_get_second_to_last_transaction_block_in_previous_epoch
( constants: ConsensusConstants, blocks: BlockchainInterface, last_b: BlockRecord, )
Retrieves the second to last transaction block in the previous epoch. Args: constants: consensus constants being used for this chain blocks: dict from header hash to block of all relevant blocks last_b: last-block in the current epoch, or last block we have seen, if potentially finishi...
Retrieves the second to last transaction block in the previous epoch.
def _get_second_to_last_transaction_block_in_previous_epoch( constants: ConsensusConstants, blocks: BlockchainInterface, last_b: BlockRecord, ) -> BlockRecord: """ Retrieves the second to last transaction block in the previous epoch. Args: constants: consensus constants being used for t...
[ "def", "_get_second_to_last_transaction_block_in_previous_epoch", "(", "constants", ":", "ConsensusConstants", ",", "blocks", ":", "BlockchainInterface", ",", "last_b", ":", "BlockRecord", ",", ")", "->", "BlockRecord", ":", "# This height is guaranteed to be in the next epoch ...
[ 51, 0 ]
[ 131, 17 ]
python
en
['en', 'error', 'th']
False
can_finish_sub_and_full_epoch
( constants: ConsensusConstants, blocks: BlockchainInterface, height: uint32, prev_header_hash: Optional[bytes32], deficit: uint8, block_at_height_included_ses: bool, )
Returns a bool tuple first bool is true if the next sub-slot after height will form part of a new sub-epoch. Therefore block height is the last block, and height + 1 is in a new sub-epoch. second bool is true if the next sub-slot after height will form part of a new sub-epoch and epoch. Therefore, ...
Returns a bool tuple first bool is true if the next sub-slot after height will form part of a new sub-epoch. Therefore block height is the last block, and height + 1 is in a new sub-epoch. second bool is true if the next sub-slot after height will form part of a new sub-epoch and epoch. Therefore, ...
def can_finish_sub_and_full_epoch( constants: ConsensusConstants, blocks: BlockchainInterface, height: uint32, prev_header_hash: Optional[bytes32], deficit: uint8, block_at_height_included_ses: bool, ) -> Tuple[bool, bool]: """ Returns a bool tuple first bool is true if the next sub-...
[ "def", "can_finish_sub_and_full_epoch", "(", "constants", ":", "ConsensusConstants", ",", "blocks", ":", "BlockchainInterface", ",", "height", ":", "uint32", ",", "prev_header_hash", ":", "Optional", "[", "bytes32", "]", ",", "deficit", ":", "uint8", ",", "block_a...
[ 138, 0 ]
[ 188, 76 ]
python
en
['en', 'error', 'th']
False
_get_next_sub_slot_iters
( constants: ConsensusConstants, blocks: BlockchainInterface, prev_header_hash: bytes32, height: uint32, curr_sub_slot_iters: uint64, deficit: uint8, block_at_height_included_ses: bool, new_slot: bool, signage_point_total_iters: uint128, skip_epoch_check=False, )
Returns the slot iterations required for the next block after the one at height, where new_slot is true iff the next block will be in the next slot. WARNING: assumes that the block at height is not the first block in a sub-epoch. Args: constants: consensus constants being used for this chain ...
Returns the slot iterations required for the next block after the one at height, where new_slot is true iff the next block will be in the next slot. WARNING: assumes that the block at height is not the first block in a sub-epoch.
def _get_next_sub_slot_iters( constants: ConsensusConstants, blocks: BlockchainInterface, prev_header_hash: bytes32, height: uint32, curr_sub_slot_iters: uint64, deficit: uint8, block_at_height_included_ses: bool, new_slot: bool, signage_point_total_iters: uint128, skip_epoch_che...
[ "def", "_get_next_sub_slot_iters", "(", "constants", ":", "ConsensusConstants", ",", "blocks", ":", "BlockchainInterface", ",", "prev_header_hash", ":", "bytes32", ",", "height", ":", "uint32", ",", "curr_sub_slot_iters", ":", "uint64", ",", "deficit", ":", "uint8",...
[ 191, 0 ]
[ 267, 18 ]
python
en
['en', 'error', 'th']
False
_get_next_difficulty
( constants: ConsensusConstants, blocks: BlockchainInterface, prev_header_hash: bytes32, height: uint32, current_difficulty: uint64, deficit: uint8, block_at_height_included_ses: bool, new_slot: bool, signage_point_total_iters: uint128, skip_epoch_check=False, )
Returns the difficulty of the next block that extends onto block. Used to calculate the number of iterations. WARNING: assumes that the block at height is not the first block in a sub-epoch. Args: constants: consensus constants being used for this chain blocks: dictionary from header h...
Returns the difficulty of the next block that extends onto block. Used to calculate the number of iterations. WARNING: assumes that the block at height is not the first block in a sub-epoch.
def _get_next_difficulty( constants: ConsensusConstants, blocks: BlockchainInterface, prev_header_hash: bytes32, height: uint32, current_difficulty: uint64, deficit: uint8, block_at_height_included_ses: bool, new_slot: bool, signage_point_total_iters: uint128, skip_epoch_check=Fa...
[ "def", "_get_next_difficulty", "(", "constants", ":", "ConsensusConstants", ",", "blocks", ":", "BlockchainInterface", ",", "prev_header_hash", ":", "bytes32", ",", "height", ":", "uint32", ",", "current_difficulty", ":", "uint64", ",", "deficit", ":", "uint8", ",...
[ 270, 0 ]
[ 351, 33 ]
python
en
['en', 'error', 'th']
False
get_next_sub_slot_iters_and_difficulty
( constants: ConsensusConstants, is_first_in_sub_slot: bool, prev_b: Optional[BlockRecord], blocks: BlockchainInterface, )
Retrieves the current sub_slot iters and difficulty of the next block after prev_b. Args: constants: consensus constants being used for this chain is_first_in_sub_slot: Whether the next block is the first in the sub slot prev_b: the previous block (last block in the epoch) bloc...
Retrieves the current sub_slot iters and difficulty of the next block after prev_b.
def get_next_sub_slot_iters_and_difficulty( constants: ConsensusConstants, is_first_in_sub_slot: bool, prev_b: Optional[BlockRecord], blocks: BlockchainInterface, ) -> Tuple[uint64, uint64]: """ Retrieves the current sub_slot iters and difficulty of the next block after prev_b. Args: ...
[ "def", "get_next_sub_slot_iters_and_difficulty", "(", "constants", ":", "ConsensusConstants", ",", "is_first_in_sub_slot", ":", "bool", ",", "prev_b", ":", "Optional", "[", "BlockRecord", "]", ",", "blocks", ":", "BlockchainInterface", ",", ")", "->", "Tuple", "[", ...
[ 354, 0 ]
[ 409, 37 ]
python
en
['en', 'error', 'th']
False
TreeWalker.__init__
(self, tree)
Creates a TreeWalker :arg tree: the tree to walk
Creates a TreeWalker
def __init__(self, tree): """Creates a TreeWalker :arg tree: the tree to walk """ self.tree = tree
[ "def", "__init__", "(", "self", ",", "tree", ")", ":", "self", ".", "tree", "=", "tree" ]
[ 26, 4 ]
[ 32, 24 ]
python
en
['en', 'et', 'en']
True
TreeWalker.error
(self, msg)
Generates an error token with the given message :arg msg: the error message :returns: SerializeError token
Generates an error token with the given message
def error(self, msg): """Generates an error token with the given message :arg msg: the error message :returns: SerializeError token """ return {"type": "SerializeError", "data": msg}
[ "def", "error", "(", "self", ",", "msg", ")", ":", "return", "{", "\"type\"", ":", "\"SerializeError\"", ",", "\"data\"", ":", "msg", "}" ]
[ 37, 4 ]
[ 45, 54 ]
python
en
['en', 'en', 'en']
True
TreeWalker.emptyTag
(self, namespace, name, attrs, hasChildren=False)
Generates an EmptyTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :arg attrs: the attributes of the element as a dict :arg hasChildren: whether or not to yield a SerializationError because this tag shouldn't have ch...
Generates an EmptyTag token
def emptyTag(self, namespace, name, attrs, hasChildren=False): """Generates an EmptyTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :arg attrs: the attributes of the element as a dict :arg hasChildren: whether or not to...
[ "def", "emptyTag", "(", "self", ",", "namespace", ",", "name", ",", "attrs", ",", "hasChildren", "=", "False", ")", ":", "yield", "{", "\"type\"", ":", "\"EmptyTag\"", ",", "\"name\"", ":", "name", ",", "\"namespace\"", ":", "namespace", ",", "\"data\"", ...
[ 47, 4 ]
[ 66, 57 ]
python
de
['en', 'de', 'nl']
False
TreeWalker.startTag
(self, namespace, name, attrs)
Generates a StartTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :arg attrs: the attributes of the element as a dict :returns: StartTag token
Generates a StartTag token
def startTag(self, namespace, name, attrs): """Generates a StartTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :arg attrs: the attributes of the element as a dict :returns: StartTag token """ return {"...
[ "def", "startTag", "(", "self", ",", "namespace", ",", "name", ",", "attrs", ")", ":", "return", "{", "\"type\"", ":", "\"StartTag\"", ",", "\"name\"", ":", "name", ",", "\"namespace\"", ":", "namespace", ",", "\"data\"", ":", "attrs", "}" ]
[ 68, 4 ]
[ 83, 30 ]
python
en
['en', 'de', 'en']
True
TreeWalker.endTag
(self, namespace, name)
Generates an EndTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :returns: EndTag token
Generates an EndTag token
def endTag(self, namespace, name): """Generates an EndTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :returns: EndTag token """ return {"type": "EndTag", "name": name, "namespace...
[ "def", "endTag", "(", "self", ",", "namespace", ",", "name", ")", ":", "return", "{", "\"type\"", ":", "\"EndTag\"", ",", "\"name\"", ":", "name", ",", "\"namespace\"", ":", "namespace", "}" ]
[ 85, 4 ]
[ 97, 39 ]
python
en
['en', 'en', 'nl']
True
TreeWalker.text
(self, data)
Generates SpaceCharacters and Characters tokens Depending on what's in the data, this generates one or more ``SpaceCharacters`` and ``Characters`` tokens. For example: >>> from html5lib.treewalkers.base import TreeWalker >>> # Give it an empty tree just so it instantia...
Generates SpaceCharacters and Characters tokens
def text(self, data): """Generates SpaceCharacters and Characters tokens Depending on what's in the data, this generates one or more ``SpaceCharacters`` and ``Characters`` tokens. For example: >>> from html5lib.treewalkers.base import TreeWalker >>> # Give it a...
[ "def", "text", "(", "self", ",", "data", ")", ":", "data", "=", "data", "middle", "=", "data", ".", "lstrip", "(", "spaceCharacters", ")", "left", "=", "data", "[", ":", "len", "(", "data", ")", "-", "len", "(", "middle", ")", "]", "if", "left", ...
[ 99, 4 ]
[ 135, 60 ]
python
en
['en', 'en', 'en']
True
TreeWalker.comment
(self, data)
Generates a Comment token :arg data: the comment :returns: Comment token
Generates a Comment token
def comment(self, data): """Generates a Comment token :arg data: the comment :returns: Comment token """ return {"type": "Comment", "data": data}
[ "def", "comment", "(", "self", ",", "data", ")", ":", "return", "{", "\"type\"", ":", "\"Comment\"", ",", "\"data\"", ":", "data", "}" ]
[ 137, 4 ]
[ 145, 48 ]
python
en
['en', 'en', 'en']
True
TreeWalker.doctype
(self, name, publicId=None, systemId=None)
Generates a Doctype token :arg name: :arg publicId: :arg systemId: :returns: the Doctype token
Generates a Doctype token
def doctype(self, name, publicId=None, systemId=None): """Generates a Doctype token :arg name: :arg publicId: :arg systemId: :returns: the Doctype token """ return {"type": "Doctype", "name": name, "publicId": publicId, ...
[ "def", "doctype", "(", "self", ",", "name", ",", "publicId", "=", "None", ",", "systemId", "=", "None", ")", ":", "return", "{", "\"type\"", ":", "\"Doctype\"", ",", "\"name\"", ":", "name", ",", "\"publicId\"", ":", "publicId", ",", "\"systemId\"", ":",...
[ 147, 4 ]
[ 162, 37 ]
python
en
['en', 'en', 'en']
True
TreeWalker.entity
(self, name)
Generates an Entity token :arg name: the entity name :returns: an Entity token
Generates an Entity token
def entity(self, name): """Generates an Entity token :arg name: the entity name :returns: an Entity token """ return {"type": "Entity", "name": name}
[ "def", "entity", "(", "self", ",", "name", ")", ":", "return", "{", "\"type\"", ":", "\"Entity\"", ",", "\"name\"", ":", "name", "}" ]
[ 164, 4 ]
[ 172, 47 ]
python
en
['en', 'en', 'nl']
True
TreeWalker.unknown
(self, nodeType)
Handles unknown node types
Handles unknown node types
def unknown(self, nodeType): """Handles unknown node types""" return self.error("Unknown node type: " + nodeType)
[ "def", "unknown", "(", "self", ",", "nodeType", ")", ":", "return", "self", ".", "error", "(", "\"Unknown node type: \"", "+", "nodeType", ")" ]
[ 174, 4 ]
[ 176, 59 ]
python
en
['en', 'de', 'en']
True
get_platform
(archive_root)
Return our platform name 'win32', 'linux_x86_64
Return our platform name 'win32', 'linux_x86_64
def get_platform(archive_root): """Return our platform name 'win32', 'linux_x86_64'""" # XXX remove distutils dependency result = distutils.util.get_platform() if result.startswith("macosx") and archive_root is not None: result = calculate_macosx_platform_tag(archive_root, result) if result ...
[ "def", "get_platform", "(", "archive_root", ")", ":", "# XXX remove distutils dependency", "result", "=", "distutils", ".", "util", ".", "get_platform", "(", ")", "if", "result", ".", "startswith", "(", "\"macosx\"", ")", "and", "archive_root", "is", "not", "Non...
[ 46, 0 ]
[ 55, 17 ]
python
en
['fr', 'en', 'en']
True
get_flag
(var, fallback, expected=True, warn=True)
Use a fallback value for determining SOABI flags if the needed config var is unset or unavailable.
Use a fallback value for determining SOABI flags if the needed config var is unset or unavailable.
def get_flag(var, fallback, expected=True, warn=True): """Use a fallback value for determining SOABI flags if the needed config var is unset or unavailable.""" val = get_config_var(var) if val is None: if warn: warnings.warn("Config variable '{0}' is unset, Python ABI tag may " ...
[ "def", "get_flag", "(", "var", ",", "fallback", ",", "expected", "=", "True", ",", "warn", "=", "True", ")", ":", "val", "=", "get_config_var", "(", "var", ")", "if", "val", "is", "None", ":", "if", "warn", ":", "warnings", ".", "warn", "(", "\"Con...
[ 58, 0 ]
[ 67, 26 ]
python
en
['en', 'en', 'en']
True
get_abi_tag
()
Return the ABI tag based on SOABI (if available) or emulate SOABI (CPython 2, PyPy).
Return the ABI tag based on SOABI (if available) or emulate SOABI (CPython 2, PyPy).
def get_abi_tag(): """Return the ABI tag based on SOABI (if available) or emulate SOABI (CPython 2, PyPy).""" soabi = get_config_var('SOABI') impl = tags.interpreter_name() if not soabi and impl in ('cp', 'pp') and hasattr(sys, 'maxunicode'): d = '' m = '' u = '' if g...
[ "def", "get_abi_tag", "(", ")", ":", "soabi", "=", "get_config_var", "(", "'SOABI'", ")", "impl", "=", "tags", ".", "interpreter_name", "(", ")", "if", "not", "soabi", "and", "impl", "in", "(", "'cp'", ",", "'pp'", ")", "and", "hasattr", "(", "sys", ...
[ 70, 0 ]
[ 107, 14 ]
python
en
['en', 'sm', 'en']
True
bdist_wheel.wheel_dist_name
(self)
Return distribution full name with - replaced with _
Return distribution full name with - replaced with _
def wheel_dist_name(self): """Return distribution full name with - replaced with _""" components = (safer_name(self.distribution.get_name()), safer_version(self.distribution.get_version())) if self.build_number: components += (self.build_number,) return ...
[ "def", "wheel_dist_name", "(", "self", ")", ":", "components", "=", "(", "safer_name", "(", "self", ".", "distribution", ".", "get_name", "(", ")", ")", ",", "safer_version", "(", "self", ".", "distribution", ".", "get_version", "(", ")", ")", ")", "if",...
[ 233, 4 ]
[ 239, 35 ]
python
en
['en', 'en', 'en']
True
bdist_wheel.egg2dist
(self, egginfo_path, distinfo_path)
Convert an .egg-info directory into a .dist-info directory
Convert an .egg-info directory into a .dist-info directory
def egg2dist(self, egginfo_path, distinfo_path): """Convert an .egg-info directory into a .dist-info directory""" def adios(p): """Appropriately delete directory, file or link.""" if os.path.exists(p) and not os.path.islink(p) and os.path.isdir(p): shutil.rmtree(p...
[ "def", "egg2dist", "(", "self", ",", "egginfo_path", ",", "distinfo_path", ")", ":", "def", "adios", "(", "p", ")", ":", "\"\"\"Appropriately delete directory, file or link.\"\"\"", "if", "os", ".", "path", ".", "exists", "(", "p", ")", "and", "not", "os", "...
[ 436, 4 ]
[ 491, 27 ]
python
en
['it', 'lb', 'en']
False
isfits
(filename)
returns True if filename is a fits file
returns True if filename is a fits file
def isfits(filename): """returns True if filename is a fits file""" if not os.path.isfile(filename): return False if filename[-4:].lower() != 'fits': return False try: with pyfits.open(filename): pass except IOError: return False return True
[ "def", "isfits", "(", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "return", "False", "if", "filename", "[", "-", "4", ":", "]", ".", "lower", "(", ")", "!=", "'fits'", ":", "return", "False", "t...
[ 39, 0 ]
[ 50, 15 ]
python
en
['en', 'en', 'en']
True
iscasa
(filename)
returns True if filename is a lofar casa directory
returns True if filename is a lofar casa directory
def iscasa(filename): """returns True if filename is a lofar casa directory""" if not os.path.isdir(filename): return False for file_ in casafiles: casafile = os.path.join(filename, file_) if not os.path.isfile(casafile): logger.debug("%s doesn't contain %s" % (filename, ...
[ "def", "iscasa", "(", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "filename", ")", ":", "return", "False", "for", "file_", "in", "casafiles", ":", "casafile", "=", "os", ".", "path", ".", "join", "(", "filename", ",", "...
[ 53, 0 ]
[ 68, 15 ]
python
en
['en', 'ca', 'en']
True
islofarhdf5
(filename)
returns True if filename is a hdf5 container
returns True if filename is a hdf5 container
def islofarhdf5(filename): """returns True if filename is a hdf5 container""" if not os.path.isfile(filename): return False if filename[-2:].lower() != 'h5': return False try: casacore_image(filename) except RuntimeError: return False return True
[ "def", "islofarhdf5", "(", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "return", "False", "if", "filename", "[", "-", "2", ":", "]", ".", "lower", "(", ")", "!=", "'h5'", ":", "return", "False", ...
[ 71, 0 ]
[ 81, 15 ]
python
en
['en', 'en', 'en']
True