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
Range.lower
(self)
The lower bound of the range. `!None` if empty or unbound.
The lower bound of the range. `!None` if empty or unbound.
def lower(self): """The lower bound of the range. `!None` if empty or unbound.""" return self._lower
[ "def", "lower", "(", "self", ")", ":", "return", "self", ".", "_lower" ]
[ 79, 4 ]
[ 81, 26 ]
python
en
['en', 'en', 'en']
True
Range.upper
(self)
The upper bound of the range. `!None` if empty or unbound.
The upper bound of the range. `!None` if empty or unbound.
def upper(self): """The upper bound of the range. `!None` if empty or unbound.""" return self._upper
[ "def", "upper", "(", "self", ")", ":", "return", "self", ".", "_upper" ]
[ 84, 4 ]
[ 86, 26 ]
python
en
['en', 'en', 'en']
True
Range.isempty
(self)
`!True` if the range is empty.
`!True` if the range is empty.
def isempty(self): """`!True` if the range is empty.""" return self._bounds is None
[ "def", "isempty", "(", "self", ")", ":", "return", "self", ".", "_bounds", "is", "None" ]
[ 89, 4 ]
[ 91, 35 ]
python
en
['en', 'sr', 'en']
True
Range.lower_inf
(self)
`!True` if the range doesn't have a lower bound.
`!True` if the range doesn't have a lower bound.
def lower_inf(self): """`!True` if the range doesn't have a lower bound.""" if self._bounds is None: return False return self._lower is None
[ "def", "lower_inf", "(", "self", ")", ":", "if", "self", ".", "_bounds", "is", "None", ":", "return", "False", "return", "self", ".", "_lower", "is", "None" ]
[ 94, 4 ]
[ 98, 34 ]
python
en
['en', 'en', 'en']
True
Range.upper_inf
(self)
`!True` if the range doesn't have an upper bound.
`!True` if the range doesn't have an upper bound.
def upper_inf(self): """`!True` if the range doesn't have an upper bound.""" if self._bounds is None: return False return self._upper is None
[ "def", "upper_inf", "(", "self", ")", ":", "if", "self", ".", "_bounds", "is", "None", ":", "return", "False", "return", "self", ".", "_upper", "is", "None" ]
[ 101, 4 ]
[ 105, 34 ]
python
en
['en', 'en', 'en']
True
Range.lower_inc
(self)
`!True` if the lower bound is included in the range.
`!True` if the lower bound is included in the range.
def lower_inc(self): """`!True` if the lower bound is included in the range.""" if self._bounds is None or self._lower is None: return False return self._bounds[0] == '['
[ "def", "lower_inc", "(", "self", ")", ":", "if", "self", ".", "_bounds", "is", "None", "or", "self", ".", "_lower", "is", "None", ":", "return", "False", "return", "self", ".", "_bounds", "[", "0", "]", "==", "'['" ]
[ 108, 4 ]
[ 112, 37 ]
python
en
['en', 'en', 'en']
True
Range.upper_inc
(self)
`!True` if the upper bound is included in the range.
`!True` if the upper bound is included in the range.
def upper_inc(self): """`!True` if the upper bound is included in the range.""" if self._bounds is None or self._upper is None: return False return self._bounds[1] == ']'
[ "def", "upper_inc", "(", "self", ")", ":", "if", "self", ".", "_bounds", "is", "None", "or", "self", ".", "_upper", "is", "None", ":", "return", "False", "return", "self", ".", "_bounds", "[", "1", "]", "==", "']'" ]
[ 115, 4 ]
[ 119, 37 ]
python
en
['en', 'en', 'en']
True
RangeCaster._create_ranges
(self, pgrange, pyrange)
Create Range and RangeAdapter classes if needed.
Create Range and RangeAdapter classes if needed.
def _create_ranges(self, pgrange, pyrange): """Create Range and RangeAdapter classes if needed.""" # if got a string create a new RangeAdapter concrete type (with a name) # else take it as an adapter. Passing an adapter should be considered # an implementation detail and is not documente...
[ "def", "_create_ranges", "(", "self", ",", "pgrange", ",", "pyrange", ")", ":", "# if got a string create a new RangeAdapter concrete type (with a name)", "# else take it as an adapter. Passing an adapter should be considered", "# an implementation detail and is not documented. It is current...
[ 310, 4 ]
[ 343, 68 ]
python
en
['en', 'sn', 'en']
True
RangeCaster._from_db
(self, name, pyrange, conn_or_curs)
Return a `RangeCaster` instance for the type *pgrange*. Raise `ProgrammingError` if the type is not found.
Return a `RangeCaster` instance for the type *pgrange*.
def _from_db(self, name, pyrange, conn_or_curs): """Return a `RangeCaster` instance for the type *pgrange*. Raise `ProgrammingError` if the type is not found. """ from psycopg2.extensions import STATUS_IN_TRANSACTION from psycopg2.extras import _solve_conn_curs conn, cur...
[ "def", "_from_db", "(", "self", ",", "name", ",", "pyrange", ",", "conn_or_curs", ")", ":", "from", "psycopg2", ".", "extensions", "import", "STATUS_IN_TRANSACTION", "from", "psycopg2", ".", "extras", "import", "_solve_conn_curs", "conn", ",", "curs", "=", "_s...
[ 346, 4 ]
[ 399, 59 ]
python
en
['en', 'no', 'en']
True
Loader.get_template_sources
(self, template_name, template_dirs=None)
Returns the absolute paths to "template_name", when appended to each directory in "template_dirs". Any paths that don't lie inside one of the template dirs are excluded from the result set, for security reasons.
Returns the absolute paths to "template_name", when appended to each directory in "template_dirs". Any paths that don't lie inside one of the template dirs are excluded from the result set, for security reasons.
def get_template_sources(self, template_name, template_dirs=None): """ Returns the absolute paths to "template_name", when appended to each directory in "template_dirs". Any paths that don't lie inside one of the template dirs are excluded from the result set, for security reasons. ...
[ "def", "get_template_sources", "(", "self", ",", "template_name", ",", "template_dirs", "=", "None", ")", ":", "if", "not", "template_dirs", ":", "template_dirs", "=", "app_template_dirs", "for", "template_dir", "in", "template_dirs", ":", "try", ":", "yield", "...
[ 38, 4 ]
[ 54, 20 ]
python
en
['en', 'error', 'th']
False
json_response_from_error
(exception: JsonableError)
This should only be needed in middleware; in app code, just raise. When app code raises a JsonableError, the JsonErrorHandler middleware takes care of transforming it into a response by calling this function.
This should only be needed in middleware; in app code, just raise.
def json_response_from_error(exception: JsonableError) -> HttpResponse: """ This should only be needed in middleware; in app code, just raise. When app code raises a JsonableError, the JsonErrorHandler middleware takes care of transforming it into a response by calling this function. """ re...
[ "def", "json_response_from_error", "(", "exception", ":", "JsonableError", ")", "->", "HttpResponse", ":", "response", "=", "json_response", "(", "\"error\"", ",", "msg", "=", "exception", ".", "msg", ",", "data", "=", "exception", ".", "data", ",", "status", ...
[ 66, 0 ]
[ 81, 19 ]
python
en
['en', 'error', 'th']
False
compose_views
(thunks: List[Callable[[], HttpResponse]])
This takes a series of thunks and calls them in sequence, and it smushes all the json results into a single response when everything goes right. (This helps clients avoid extra latency hops.) It rolls back the transaction when things go wrong in any one of the composed methods. TODO: Move th...
This takes a series of thunks and calls them in sequence, and it smushes all the json results into a single response when everything goes right. (This helps clients avoid extra latency hops.) It rolls back the transaction when things go wrong in any one of the composed methods.
def compose_views(thunks: List[Callable[[], HttpResponse]]) -> HttpResponse: """ This takes a series of thunks and calls them in sequence, and it smushes all the json results into a single response when everything goes right. (This helps clients avoid extra latency hops.) It rolls back the transac...
[ "def", "compose_views", "(", "thunks", ":", "List", "[", "Callable", "[", "[", "]", ",", "HttpResponse", "]", "]", ")", "->", "HttpResponse", ":", "json_dict", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", "with", "transaction", ".", "atom...
[ 351, 0 ]
[ 370, 34 ]
python
en
['en', 'error', 'th']
False
send_messages_for_new_subscribers
( user_profile: UserProfile, subscribers: Set[UserProfile], new_subscriptions: Dict[str, List[str]], email_to_user_profile: Dict[str, UserProfile], created_streams: List[Stream], announce: bool, )
If you are subscribing lots of new users to new streams, this function can be pretty expensive in terms of generating lots of queries and sending lots of messages. We isolate the code partly to make it easier to test things like excessive query counts by mocking this function so that it doesn'...
If you are subscribing lots of new users to new streams, this function can be pretty expensive in terms of generating lots of queries and sending lots of messages. We isolate the code partly to make it easier to test things like excessive query counts by mocking this function so that it doesn'...
def send_messages_for_new_subscribers( user_profile: UserProfile, subscribers: Set[UserProfile], new_subscriptions: Dict[str, List[str]], email_to_user_profile: Dict[str, UserProfile], created_streams: List[Stream], announce: bool, ) -> None: """ If you are subscribing lots of new users ...
[ "def", "send_messages_for_new_subscribers", "(", "user_profile", ":", "UserProfile", ",", "subscribers", ":", "Set", "[", "UserProfile", "]", ",", "new_subscriptions", ":", "Dict", "[", "str", ",", "List", "[", "str", "]", "]", ",", "email_to_user_profile", ":",...
[ 563, 0 ]
[ 662, 71 ]
python
en
['en', 'error', 'th']
False
update_subscription_properties_backend
( request: HttpRequest, user_profile: UserProfile, subscription_data: List[Dict[str, Any]] = REQ( json_validator=check_list( check_dict( [ ("stream_id", check_int), ("property", check_string), ("value", check_uni...
This is the entry point to changing subscription properties. This is a bulk endpoint: requestors always provide a subscription_data list containing dictionaries for each stream of interest. Requests are of the form: [{"stream_id": "1", "property": "is_muted", "value": False}, {"stream_id": "...
This is the entry point to changing subscription properties. This is a bulk endpoint: requestors always provide a subscription_data list containing dictionaries for each stream of interest.
def update_subscription_properties_backend( request: HttpRequest, user_profile: UserProfile, subscription_data: List[Dict[str, Any]] = REQ( json_validator=check_list( check_dict( [ ("stream_id", check_int), ("property", check_string...
[ "def", "update_subscription_properties_backend", "(", "request", ":", "HttpRequest", ",", "user_profile", ":", "UserProfile", ",", "subscription_data", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "REQ", "(", "json_validator", "=", "check_lis...
[ 820, 0 ]
[ 881, 61 ]
python
en
['en', 'error', 'th']
False
current_umask
()
Get the current umask which involves having to set it temporarily.
Get the current umask which involves having to set it temporarily.
def current_umask(): """Get the current umask which involves having to set it temporarily.""" mask = os.umask(0) os.umask(mask) return mask
[ "def", "current_umask", "(", ")", ":", "mask", "=", "os", ".", "umask", "(", "0", ")", "os", ".", "umask", "(", "mask", ")", "return", "mask" ]
[ 26, 0 ]
[ 30, 15 ]
python
en
['en', 'en', 'en']
True
set_extracted_file_to_default_mode_plus_executable
(path)
Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs
Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs
def set_extracted_file_to_default_mode_plus_executable(path): """ Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs """ os.chmod(path, (0o777 & ~current_umask() | 0o111))
[ "def", "set_extracted_file_to_default_mode_plus_executable", "(", "path", ")", ":", "os", ".", "chmod", "(", "path", ",", "(", "0o777", "&", "~", "current_umask", "(", ")", "|", "0o111", ")", ")" ]
[ 33, 0 ]
[ 38, 54 ]
python
en
['en', 'error', 'th']
False
main
()
Generate a BUILD file for an unzipped Wheel We allow for empty Python sources as for Wheels containing only compiled C code there may be no Python sources whatsoever (e.g. packages written in Cython: like `pymssql`).
Generate a BUILD file for an unzipped Wheel
def main(): """ Generate a BUILD file for an unzipped Wheel We allow for empty Python sources as for Wheels containing only compiled C code there may be no Python sources whatsoever (e.g. packages written in Cython: like `pymssql`). """ args = parser.parse_args() whl = Wheel(args.whl) # Extract the f...
[ "def", "main", "(", ")", ":", "args", "=", "parser", ".", "parse_args", "(", ")", "whl", "=", "Wheel", "(", "args", ".", "whl", ")", "# Extract the files into the current directory", "whl", ".", "expand", "(", "args", ".", "directory", ")", "whl", ".", "...
[ 218, 0 ]
[ 273, 6 ]
python
en
['en', 'error', 'th']
False
Wheel.dependencies
(self, extra=None)
Access the dependencies of this Wheel. Args: extra: if specified, include the additional dependencies of the named "extra". Yields: the names of requirements from the metadata.json, in lexical order.
Access the dependencies of this Wheel.
def dependencies(self, extra=None): """Access the dependencies of this Wheel. Args: extra: if specified, include the additional dependencies of the named "extra". Yields: the names of requirements from the metadata.json, in lexical order. """ # TODO(mattmoor): Is there a sc...
[ "def", "dependencies", "(", "self", ",", "extra", "=", "None", ")", ":", "# TODO(mattmoor): Is there a schema to follow for this?", "dependency_set", "=", "set", "(", ")", "run_requires", "=", "self", ".", "metadata", "(", ")", ".", "get", "(", "'run_requires'", ...
[ 112, 2 ]
[ 141, 33 ]
python
en
['en', 'en', 'en']
True
_convert_native_shape_to_list
(dims)
Takes a list of `neuropod_native.Dimension` objects and converts to a list of python types
Takes a list of `neuropod_native.Dimension` objects and converts to a list of python types
def _convert_native_shape_to_list(dims): """ Takes a list of `neuropod_native.Dimension` objects and converts to a list of python types """ out = [] for dim in dims: if dim.value == -2: # It's a symbol out.append(dim.symbol) elif dim.value == -1: #...
[ "def", "_convert_native_shape_to_list", "(", "dims", ")", ":", "out", "=", "[", "]", "for", "dim", "in", "dims", ":", "if", "dim", ".", "value", "==", "-", "2", ":", "# It's a symbol", "out", ".", "append", "(", "dim", ".", "symbol", ")", "elif", "di...
[ 25, 0 ]
[ 40, 14 ]
python
en
['en', 'error', 'th']
False
load_neuropod
(neuropod_path, _always_use_native=True, **kwargs)
Load a neuropod package. Returns a NeuropodExecutor :param neuropod_path The path to a neuropod package :param visible_gpu: The index of the GPU that this Neuropod should run on (if any). This is either `None` or a nonnegative integer. Setting this ...
Load a neuropod package. Returns a NeuropodExecutor
def load_neuropod(neuropod_path, _always_use_native=True, **kwargs): """ Load a neuropod package. Returns a NeuropodExecutor :param neuropod_path The path to a neuropod package :param visible_gpu: The index of the GPU that this Neuropod should run on (if any). ...
[ "def", "load_neuropod", "(", "neuropod_path", ",", "_always_use_native", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "_always_use_native", ":", "return", "NativeNeuropodExecutor", "(", "neuropod_path", ",", "*", "*", "kwargs", ")", "# If we were given a ...
[ 141, 0 ]
[ 176, 9 ]
python
en
['en', 'error', 'th']
False
NativeNeuropodExecutor.__init__
(self, neuropod_path, **kwargs)
Load a Neuropod using the native bindings :param neuropod_path: The path to a neuropod package
Load a Neuropod using the native bindings
def __init__(self, neuropod_path, **kwargs): """ Load a Neuropod using the native bindings :param neuropod_path: The path to a neuropod package """ # Load the model from neuropod.neuropod_native import Neuropod as NeuropodNative self.model = NeuropodNative( ...
[ "def", "__init__", "(", "self", ",", "neuropod_path", ",", "*", "*", "kwargs", ")", ":", "# Load the model", "from", "neuropod", ".", "neuropod_native", "import", "Neuropod", "as", "NeuropodNative", "self", ".", "model", "=", "NeuropodNative", "(", "neuropod_pat...
[ 48, 4 ]
[ 59, 9 ]
python
en
['en', 'error', 'th']
False
NativeNeuropodExecutor.name
(self)
Get the name of the loaded neuropod.
Get the name of the loaded neuropod.
def name(self): """ Get the name of the loaded neuropod. """ return self.model.get_name()
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "model", ".", "get_name", "(", ")" ]
[ 62, 4 ]
[ 66, 36 ]
python
en
['en', 'error', 'th']
False
NativeNeuropodExecutor.platform
(self)
Get the platform of backend of the loaded neuropod.
Get the platform of backend of the loaded neuropod.
def platform(self): """ Get the platform of backend of the loaded neuropod. """ return self.model.get_platform()
[ "def", "platform", "(", "self", ")", ":", "return", "self", ".", "model", ".", "get_platform", "(", ")" ]
[ 69, 4 ]
[ 73, 40 ]
python
en
['en', 'error', 'th']
False
NativeNeuropodExecutor.inputs
(self)
Get the inputs of the loaded neuropod. Returns a list of dicts representing the format of the expected input to the neuropod. Ex: [{"name": "x", "dtype": "float32", "shape": [None,]}]
Get the inputs of the loaded neuropod. Returns a list of dicts representing the format of the expected input to the neuropod.
def inputs(self): """ Get the inputs of the loaded neuropod. Returns a list of dicts representing the format of the expected input to the neuropod. Ex: [{"name": "x", "dtype": "float32", "shape": [None,]}] """ out = [] for item in self.model.get_inputs(): ...
[ "def", "inputs", "(", "self", ")", ":", "out", "=", "[", "]", "for", "item", "in", "self", ".", "model", ".", "get_inputs", "(", ")", ":", "out", ".", "append", "(", "{", "\"name\"", ":", "item", ".", "name", ",", "\"dtype\"", ":", "item", ".", ...
[ 76, 4 ]
[ 93, 18 ]
python
en
['en', 'error', 'th']
False
NativeNeuropodExecutor.outputs
(self)
Get the outputs of the loaded neuropod. Returns a list of dicts representing the format of the output of the neuropod. Ex: [{"name": "z", "dtype": "float32", "shape": [None,]}]
Get the outputs of the loaded neuropod. Returns a list of dicts representing the format of the output of the neuropod.
def outputs(self): """ Get the outputs of the loaded neuropod. Returns a list of dicts representing the format of the output of the neuropod. Ex: [{"name": "z", "dtype": "float32", "shape": [None,]}] """ out = [] for item in self.model.get_outputs(): ...
[ "def", "outputs", "(", "self", ")", ":", "out", "=", "[", "]", "for", "item", "in", "self", ".", "model", ".", "get_outputs", "(", ")", ":", "out", ".", "append", "(", "{", "\"name\"", ":", "item", ".", "name", ",", "\"dtype\"", ":", "item", ".",...
[ 96, 4 ]
[ 113, 18 ]
python
en
['en', 'error', 'th']
False
NativeNeuropodExecutor.infer
(self, inputs)
Run inference using the specifed inputs. :param inputs: A dict mapping input names to values. This must match the input spec in the neuropod config for the loaded model. Ex: {'x1': np.array([5]), 'x2': np.array([6])} ...
Run inference using the specifed inputs.
def infer(self, inputs): """ Run inference using the specifed inputs. :param inputs: A dict mapping input names to values. This must match the input spec in the neuropod config for the loaded model. Ex: {'x1': np.array([5]), 'x2': np....
[ "def", "infer", "(", "self", ",", "inputs", ")", ":", "inputs", "=", "maybe_convert_bindings_types", "(", "inputs", ")", "return", "self", ".", "model", ".", "infer", "(", "inputs", ")" ]
[ 115, 4 ]
[ 130, 39 ]
python
en
['en', 'error', 'th']
False
BaseMemcachedCache._cache
(self)
Implement transparent thread-safe access to a memcached client.
Implement transparent thread-safe access to a memcached client.
def _cache(self): """ Implement transparent thread-safe access to a memcached client. """ if getattr(self, '_client', None) is None: self._client = self._lib.Client(self._servers, **self._options) return self._client
[ "def", "_cache", "(", "self", ")", ":", "if", "getattr", "(", "self", ",", "'_client'", ",", "None", ")", "is", "None", ":", "self", ".", "_client", "=", "self", ".", "_lib", ".", "Client", "(", "self", ".", "_servers", ",", "*", "*", "self", "."...
[ 30, 4 ]
[ 37, 27 ]
python
en
['en', 'error', 'th']
False
BaseMemcachedCache.get_backend_timeout
(self, timeout=DEFAULT_TIMEOUT)
Memcached deals with long (> 30 days) timeouts in a special way. Call this function to obtain a safe value for your timeout.
Memcached deals with long (> 30 days) timeouts in a special way. Call this function to obtain a safe value for your timeout.
def get_backend_timeout(self, timeout=DEFAULT_TIMEOUT): """ Memcached deals with long (> 30 days) timeouts in a special way. Call this function to obtain a safe value for your timeout. """ if timeout == DEFAULT_TIMEOUT: timeout = self.default_timeout if timeo...
[ "def", "get_backend_timeout", "(", "self", ",", "timeout", "=", "DEFAULT_TIMEOUT", ")", ":", "if", "timeout", "==", "DEFAULT_TIMEOUT", ":", "timeout", "=", "self", ".", "default_timeout", "if", "timeout", "is", "None", ":", "# Using 0 in memcache sets a non-expiring...
[ 39, 4 ]
[ 64, 27 ]
python
en
['en', 'error', 'th']
False
choose_boundary
()
Our embarrassingly-simple replacement for mimetools.choose_boundary.
Our embarrassingly-simple replacement for mimetools.choose_boundary.
def choose_boundary(): """ Our embarrassingly-simple replacement for mimetools.choose_boundary. """ boundary = binascii.hexlify(os.urandom(16)) if not six.PY2: boundary = boundary.decode("ascii") return boundary
[ "def", "choose_boundary", "(", ")", ":", "boundary", "=", "binascii", ".", "hexlify", "(", "os", ".", "urandom", "(", "16", ")", ")", "if", "not", "six", ".", "PY2", ":", "boundary", "=", "boundary", ".", "decode", "(", "\"ascii\"", ")", "return", "b...
[ 14, 0 ]
[ 21, 19 ]
python
en
['en', 'error', 'th']
False
iter_field_objects
(fields)
Iterate over fields. Supports list of (k, v) tuples and dicts, and lists of :class:`~urllib3.fields.RequestField`.
Iterate over fields.
def iter_field_objects(fields): """ Iterate over fields. Supports list of (k, v) tuples and dicts, and lists of :class:`~urllib3.fields.RequestField`. """ if isinstance(fields, dict): i = six.iteritems(fields) else: i = iter(fields) for field in i: if isinstanc...
[ "def", "iter_field_objects", "(", "fields", ")", ":", "if", "isinstance", "(", "fields", ",", "dict", ")", ":", "i", "=", "six", ".", "iteritems", "(", "fields", ")", "else", ":", "i", "=", "iter", "(", "fields", ")", "for", "field", "in", "i", ":"...
[ 24, 0 ]
[ 41, 50 ]
python
en
['en', 'error', 'th']
False
iter_fields
(fields)
.. deprecated:: 1.6 Iterate over fields. The addition of :class:`~urllib3.fields.RequestField` makes this function obsolete. Instead, use :func:`iter_field_objects`, which returns :class:`~urllib3.fields.RequestField` objects. Supports list of (k, v) tuples and dicts.
.. deprecated:: 1.6
def iter_fields(fields): """ .. deprecated:: 1.6 Iterate over fields. The addition of :class:`~urllib3.fields.RequestField` makes this function obsolete. Instead, use :func:`iter_field_objects`, which returns :class:`~urllib3.fields.RequestField` objects. Supports list of (k, v) tuples an...
[ "def", "iter_fields", "(", "fields", ")", ":", "if", "isinstance", "(", "fields", ",", "dict", ")", ":", "return", "(", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "fields", ")", ")", "return", "(", "(", "...
[ 44, 0 ]
[ 59, 38 ]
python
en
['en', 'error', 'th']
False
encode_multipart_formdata
(fields, boundary=None)
Encode a dictionary of ``fields`` using the multipart/form-data MIME format. :param fields: Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`). :param boundary: If not specified, then a random boundary will be generated using :func:`urllib3.filepost.choos...
Encode a dictionary of ``fields`` using the multipart/form-data MIME format.
def encode_multipart_formdata(fields, boundary=None): """ Encode a dictionary of ``fields`` using the multipart/form-data MIME format. :param fields: Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`). :param boundary: If not specified, then a random boundary ...
[ "def", "encode_multipart_formdata", "(", "fields", ",", "boundary", "=", "None", ")", ":", "body", "=", "BytesIO", "(", ")", "if", "boundary", "is", "None", ":", "boundary", "=", "choose_boundary", "(", ")", "for", "field", "in", "iter_field_objects", "(", ...
[ 62, 0 ]
[ 97, 40 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_table_list
(self, cursor)
Return a list of table and view names in the current database.
Return a list of table and view names in the current database.
def get_table_list(self, cursor): """Return a list of table and view names in the current database.""" cursor.execute(""" SELECT c.relname, CASE WHEN {} THEN 'p' WHEN c.relkind IN ('m', 'v') THEN 'v' ELSE 't' END FROM pg_catalog.pg_class c LEFT JOIN pg_cat...
[ "def", "get_table_list", "(", "self", ",", "cursor", ")", ":", "cursor", ".", "execute", "(", "\"\"\"\n SELECT c.relname,\n CASE WHEN {} THEN 'p' WHEN c.relkind IN ('m', 'v') THEN 'v' ELSE 't' END\n FROM pg_catalog.pg_class c\n LEFT JOIN pg_catalog...
[ 43, 4 ]
[ 54, 98 ]
python
en
['en', 'en', 'en']
True
DatabaseIntrospection.get_table_description
(self, cursor, table_name)
Return a description of the table with the DB-API cursor.description interface.
Return a description of the table with the DB-API cursor.description interface.
def get_table_description(self, cursor, table_name): """ Return a description of the table with the DB-API cursor.description interface. """ # Query the pg_catalog tables as cursor.description does not reliably # return the nullable property and information_schema.columns...
[ "def", "get_table_description", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "# Query the pg_catalog tables as cursor.description does not reliably", "# return the nullable property and information_schema.columns does not", "# contain details of materialized views.", "cursor", ...
[ 56, 4 ]
[ 92, 9 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_relations
(self, cursor, table_name)
Return a dictionary of {field_name: (field_name_other_table, other_table)} representing all relationships to the given table.
Return a dictionary of {field_name: (field_name_other_table, other_table)} representing all relationships to the given table.
def get_relations(self, cursor, table_name): """ Return a dictionary of {field_name: (field_name_other_table, other_table)} representing all relationships to the given table. """ return {row[0]: (row[2], row[1]) for row in self.get_key_columns(cursor, table_name)}
[ "def", "get_relations", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "return", "{", "row", "[", "0", "]", ":", "(", "row", "[", "2", "]", ",", "row", "[", "1", "]", ")", "for", "row", "in", "self", ".", "get_key_columns", "(", "cursor...
[ 113, 4 ]
[ 118, 93 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_constraints
(self, cursor, table_name)
Retrieve any constraints or keys (unique, pk, fk, check, index) across one or more columns. Also retrieve the definition of expression-based indexes.
Retrieve any constraints or keys (unique, pk, fk, check, index) across one or more columns. Also retrieve the definition of expression-based indexes.
def get_constraints(self, cursor, table_name): """ Retrieve any constraints or keys (unique, pk, fk, check, index) across one or more columns. Also retrieve the definition of expression-based indexes. """ constraints = {} # Loop over the key table, collecting thin...
[ "def", "get_constraints", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "constraints", "=", "{", "}", "# Loop over the key table, collecting things as constraints. The column", "# array must return column names in the same order in which they were", "# created.", "cursor...
[ 136, 4 ]
[ 223, 26 ]
python
en
['en', 'error', 'th']
False
ItemID.__init__
(self, id, change_key)
Initialize the ItemID. You probably shouldn't call this by hand.
Initialize the ItemID. You probably shouldn't call this by hand.
def __init__(self, id, change_key): """ Initialize the ItemID. You probably shouldn't call this by hand. """ self._id = force_text(id) self._change_key = force_text(change_key)
[ "def", "__init__", "(", "self", ",", "id", ",", "change_key", ")", ":", "self", ".", "_id", "=", "force_text", "(", "id", ")", "self", ".", "_change_key", "=", "force_text", "(", "change_key", ")" ]
[ 13, 4 ]
[ 18, 49 ]
python
en
['en', 'error', 'th']
False
ItemID.change_key
(self)
Get the change key for this item ID. As I understand things, the change key is sort of a timestamp/lock for change control. :rtype: str
Get the change key for this item ID.
def change_key(self): """ Get the change key for this item ID. As I understand things, the change key is sort of a timestamp/lock for change control. :rtype: str """ return self._change_key
[ "def", "change_key", "(", "self", ")", ":", "return", "self", ".", "_change_key" ]
[ 21, 4 ]
[ 30, 31 ]
python
en
['en', 'error', 'th']
False
ItemID.id
(self)
Get the ID part of this item ID. This is assumed to be invariant. :rtype: str
Get the ID part of this item ID.
def id(self): """ Get the ID part of this item ID. This is assumed to be invariant. :rtype: str """ return self._id
[ "def", "id", "(", "self", ")", ":", "return", "self", ".", "_id" ]
[ 33, 4 ]
[ 41, 23 ]
python
en
['en', 'error', 'th']
False
ItemID.to_xml
(self)
Return an <ItemId> XML element for this item ID. :return: XML element :rtype: lxml.etree.Element
Return an <ItemId> XML element for this item ID.
def to_xml(self): """ Return an <ItemId> XML element for this item ID. :return: XML element :rtype: lxml.etree.Element """ return T.ItemId(Id=self.id, ChangeKey=self.change_key)
[ "def", "to_xml", "(", "self", ")", ":", "return", "T", ".", "ItemId", "(", "Id", "=", "self", ".", "id", ",", "ChangeKey", "=", "self", ".", "change_key", ")" ]
[ 43, 4 ]
[ 50, 62 ]
python
en
['en', 'error', 'th']
False
ItemID.from_tree
(cls, tree)
Get the first Item ID from the given XML tree (likely a response) :type tree: lxml.etree.Element :rtype: ItemID
Get the first Item ID from the given XML tree (likely a response)
def from_tree(cls, tree): """ Get the first Item ID from the given XML tree (likely a response) :type tree: lxml.etree.Element :rtype: ItemID """ item_id = tree.find(".//t:ItemId", namespaces=NAMESPACES) if item_id is None: raise ValueError("Could not...
[ "def", "from_tree", "(", "cls", ",", "tree", ")", ":", "item_id", "=", "tree", ".", "find", "(", "\".//t:ItemId\"", ",", "namespaces", "=", "NAMESPACES", ")", "if", "item_id", "is", "None", ":", "raise", "ValueError", "(", "\"Could not find ItemId element in t...
[ 53, 4 ]
[ 66, 9 ]
python
en
['en', 'error', 'th']
False
ItemID.hash
(self)
The hash of this item id's ID component. Used for ExchangeReservation models. :return:
The hash of this item id's ID component.
def hash(self): """ The hash of this item id's ID component. Used for ExchangeReservation models. :return: """ return hashlib.md5(self.id.encode("utf8")).hexdigest()
[ "def", "hash", "(", "self", ")", ":", "return", "hashlib", ".", "md5", "(", "self", ".", "id", ".", "encode", "(", "\"utf8\"", ")", ")", ".", "hexdigest", "(", ")" ]
[ 69, 4 ]
[ 77, 62 ]
python
en
['en', 'error', 'th']
False
ConfigurationCommand._get_n_args
(self, args, example, n)
Helper to make sure the command got the right number of arguments
Helper to make sure the command got the right number of arguments
def _get_n_args(self, args, example, n): """Helper to make sure the command got the right number of arguments """ if len(args) != n: msg = ( 'Got unexpected number of arguments, expected {}. ' '(example: "{} config {}")' ).format(n, get_pro...
[ "def", "_get_n_args", "(", "self", ",", "args", ",", "example", ",", "n", ")", ":", "if", "len", "(", "args", ")", "!=", "n", ":", "msg", "=", "(", "'Got unexpected number of arguments, expected {}. '", "'(example: \"{} config {}\")'", ")", ".", "format", "(",...
[ 197, 4 ]
[ 210, 23 ]
python
en
['en', 'en', 'en']
True
fetch_dataset
( dataset_name: str, dataset_dir: Union[List[Union[str, os.PathLike]], Union[str, os.PathLike]], split: str, transform: Optional[Callable], two_image: bool = False, label_list="all", )
Dataset fetcher for config handling.
Dataset fetcher for config handling.
def fetch_dataset( dataset_name: str, dataset_dir: Union[List[Union[str, os.PathLike]], Union[str, os.PathLike]], split: str, transform: Optional[Callable], two_image: bool = False, label_list="all", ): """Dataset fetcher for config handling.""" assert split in ("train", "val", "test") ...
[ "def", "fetch_dataset", "(", "dataset_name", ":", "str", ",", "dataset_dir", ":", "Union", "[", "List", "[", "Union", "[", "str", ",", "os", ".", "PathLike", "]", "]", ",", "Union", "[", "str", ",", "os", ".", "PathLike", "]", "]", ",", "split", ":...
[ 48, 0 ]
[ 63, 18 ]
python
da
['da', 'da', 'en']
True
worker_init_fn
(worker_id)
Handle random seeding.
Handle random seeding.
def worker_init_fn(worker_id): """Handle random seeding.""" worker_info = torch.utils.data.get_worker_info() seed = worker_info.seed % (2 ** 32 - 1) # pylint: disable=no-member np.random.seed(seed)
[ "def", "worker_init_fn", "(", "worker_id", ")", ":", "worker_info", "=", "torch", ".", "utils", ".", "data", ".", "get_worker_info", "(", ")", "seed", "=", "worker_info", ".", "seed", "%", "(", "2", "**", "32", "-", "1", ")", "# pylint: disable=no-member",...
[ 66, 0 ]
[ 71, 24 ]
python
en
['sv', 'et', 'en']
False
create_package_set_from_installed
(**kwargs)
Converts a list of distributions into a PackageSet.
Converts a list of distributions into a PackageSet.
def create_package_set_from_installed(**kwargs): # type: (**Any) -> Tuple[PackageSet, bool] """Converts a list of distributions into a PackageSet. """ # Default to using all packages installed on the system if kwargs == {}: kwargs = {"local_only": False, "skip": ()} package_set = {} ...
[ "def", "create_package_set_from_installed", "(", "*", "*", "kwargs", ")", ":", "# type: (**Any) -> Tuple[PackageSet, bool]", "# Default to using all packages installed on the system", "if", "kwargs", "==", "{", "}", ":", "kwargs", "=", "{", "\"local_only\"", ":", "False", ...
[ 39, 0 ]
[ 57, 32 ]
python
en
['en', 'en', 'en']
True
check_package_set
(package_set, should_ignore=None)
Check if a package set is consistent If should_ignore is passed, it should be a callable that takes a package name and returns a boolean.
Check if a package set is consistent
def check_package_set(package_set, should_ignore=None): # type: (PackageSet, Optional[Callable[[str], bool]]) -> CheckResult """Check if a package set is consistent If should_ignore is passed, it should be a callable that takes a package name and returns a boolean. """ if should_ignore is None:...
[ "def", "check_package_set", "(", "package_set", ",", "should_ignore", "=", "None", ")", ":", "# type: (PackageSet, Optional[Callable[[str], bool]]) -> CheckResult", "if", "should_ignore", "is", "None", ":", "def", "should_ignore", "(", "name", ")", ":", "return", "False...
[ 60, 0 ]
[ 104, 31 ]
python
en
['en', 'en', 'en']
True
check_install_conflicts
(to_install)
For checking if the dependency graph would be consistent after \ installing given requirements
For checking if the dependency graph would be consistent after \ installing given requirements
def check_install_conflicts(to_install): # type: (List[InstallRequirement]) -> Tuple[PackageSet, CheckResult] """For checking if the dependency graph would be consistent after \ installing given requirements """ # Start from the current state package_set, _ = create_package_set_from_installed() ...
[ "def", "check_install_conflicts", "(", "to_install", ")", ":", "# type: (List[InstallRequirement]) -> Tuple[PackageSet, CheckResult]", "# Start from the current state", "package_set", ",", "_", "=", "create_package_set_from_installed", "(", ")", "# Install packages", "would_be_instal...
[ 107, 0 ]
[ 125, 5 ]
python
en
['en', 'en', 'en']
True
_simulate_installation_of
(to_install, package_set)
Computes the version of packages after installing to_install.
Computes the version of packages after installing to_install.
def _simulate_installation_of(to_install, package_set): # type: (List[InstallRequirement], PackageSet) -> Set[str] """Computes the version of packages after installing to_install. """ # Keep track of packages that were installed installed = set() # Modify it as installing requirement_set would...
[ "def", "_simulate_installation_of", "(", "to_install", ",", "package_set", ")", ":", "# type: (List[InstallRequirement], PackageSet) -> Set[str]", "# Keep track of packages that were installed", "installed", "=", "set", "(", ")", "# Modify it as installing requirement_set would (assumi...
[ 128, 0 ]
[ 146, 20 ]
python
en
['en', 'en', 'en']
True
_date_from_string
(year, year_format, month='', month_format='', day='', day_format='', delim='__')
Get a datetime.date object given a format string and a year, month, and day (only year is mandatory). Raise a 404 for an invalid date.
Get a datetime.date object given a format string and a year, month, and day (only year is mandatory). Raise a 404 for an invalid date.
def _date_from_string(year, year_format, month='', month_format='', day='', day_format='', delim='__'): """ Get a datetime.date object given a format string and a year, month, and day (only year is mandatory). Raise a 404 for an invalid date. """ format = year_format + delim + month_format + delim +...
[ "def", "_date_from_string", "(", "year", ",", "year_format", ",", "month", "=", "''", ",", "month_format", "=", "''", ",", "day", "=", "''", ",", "day_format", "=", "''", ",", "delim", "=", "'__'", ")", ":", "format", "=", "year_format", "+", "delim", ...
[ 612, 0 ]
[ 625, 10 ]
python
en
['en', 'error', 'th']
False
_get_next_prev
(generic_view, date, is_previous, period)
Get the next or the previous valid date. The idea is to allow links on month/day views to never be 404s by never providing a date that'll be invalid for the given view. This is a bit complicated since it handles different intervals of time, hence the coupling to generic_view. However in essen...
Get the next or the previous valid date. The idea is to allow links on month/day views to never be 404s by never providing a date that'll be invalid for the given view.
def _get_next_prev(generic_view, date, is_previous, period): """ Get the next or the previous valid date. The idea is to allow links on month/day views to never be 404s by never providing a date that'll be invalid for the given view. This is a bit complicated since it handles different intervals of...
[ "def", "_get_next_prev", "(", "generic_view", ",", "date", ",", "is_previous", ",", "period", ")", ":", "date_field", "=", "generic_view", ".", "get_date_field", "(", ")", "allow_empty", "=", "generic_view", ".", "get_allow_empty", "(", ")", "allow_future", "=",...
[ 628, 0 ]
[ 715, 34 ]
python
en
['en', 'error', 'th']
False
timezone_today
()
Return the current date in the current time zone.
Return the current date in the current time zone.
def timezone_today(): """Return the current date in the current time zone.""" if settings.USE_TZ: return timezone.localdate() else: return datetime.date.today()
[ "def", "timezone_today", "(", ")", ":", "if", "settings", ".", "USE_TZ", ":", "return", "timezone", ".", "localdate", "(", ")", "else", ":", "return", "datetime", ".", "date", ".", "today", "(", ")" ]
[ 718, 0 ]
[ 723, 36 ]
python
en
['en', 'en', 'en']
True
YearMixin.get_year_format
(self)
Get a year format string in strptime syntax to be used to parse the year from url variables.
Get a year format string in strptime syntax to be used to parse the year from url variables.
def get_year_format(self): """ Get a year format string in strptime syntax to be used to parse the year from url variables. """ return self.year_format
[ "def", "get_year_format", "(", "self", ")", ":", "return", "self", ".", "year_format" ]
[ 23, 4 ]
[ 28, 31 ]
python
en
['en', 'error', 'th']
False
YearMixin.get_year
(self)
Return the year for which this view should display data.
Return the year for which this view should display data.
def get_year(self): """Return the year for which this view should display data.""" year = self.year if year is None: try: year = self.kwargs['year'] except KeyError: try: year = self.request.GET['year'] e...
[ "def", "get_year", "(", "self", ")", ":", "year", "=", "self", ".", "year", "if", "year", "is", "None", ":", "try", ":", "year", "=", "self", ".", "kwargs", "[", "'year'", "]", "except", "KeyError", ":", "try", ":", "year", "=", "self", ".", "req...
[ 30, 4 ]
[ 41, 19 ]
python
en
['en', 'en', 'en']
True
YearMixin.get_next_year
(self, date)
Get the next valid year.
Get the next valid year.
def get_next_year(self, date): """Get the next valid year.""" return _get_next_prev(self, date, is_previous=False, period='year')
[ "def", "get_next_year", "(", "self", ",", "date", ")", ":", "return", "_get_next_prev", "(", "self", ",", "date", ",", "is_previous", "=", "False", ",", "period", "=", "'year'", ")" ]
[ 43, 4 ]
[ 45, 75 ]
python
en
['en', 'en', 'en']
True
YearMixin.get_previous_year
(self, date)
Get the previous valid year.
Get the previous valid year.
def get_previous_year(self, date): """Get the previous valid year.""" return _get_next_prev(self, date, is_previous=True, period='year')
[ "def", "get_previous_year", "(", "self", ",", "date", ")", ":", "return", "_get_next_prev", "(", "self", ",", "date", ",", "is_previous", "=", "True", ",", "period", "=", "'year'", ")" ]
[ 47, 4 ]
[ 49, 74 ]
python
en
['en', 'en', 'en']
True
YearMixin._get_next_year
(self, date)
Return the start date of the next interval. The interval is defined by start date <= item date < next start date.
Return the start date of the next interval.
def _get_next_year(self, date): """ Return the start date of the next interval. The interval is defined by start date <= item date < next start date. """ try: return date.replace(year=date.year + 1, month=1, day=1) except ValueError: raise Http404...
[ "def", "_get_next_year", "(", "self", ",", "date", ")", ":", "try", ":", "return", "date", ".", "replace", "(", "year", "=", "date", ".", "year", "+", "1", ",", "month", "=", "1", ",", "day", "=", "1", ")", "except", "ValueError", ":", "raise", "...
[ 51, 4 ]
[ 60, 49 ]
python
en
['en', 'error', 'th']
False
YearMixin._get_current_year
(self, date)
Return the start date of the current interval.
Return the start date of the current interval.
def _get_current_year(self, date): """Return the start date of the current interval.""" return date.replace(month=1, day=1)
[ "def", "_get_current_year", "(", "self", ",", "date", ")", ":", "return", "date", ".", "replace", "(", "month", "=", "1", ",", "day", "=", "1", ")" ]
[ 62, 4 ]
[ 64, 43 ]
python
en
['en', 'en', 'en']
True
MonthMixin.get_month_format
(self)
Get a month format string in strptime syntax to be used to parse the month from url variables.
Get a month format string in strptime syntax to be used to parse the month from url variables.
def get_month_format(self): """ Get a month format string in strptime syntax to be used to parse the month from url variables. """ return self.month_format
[ "def", "get_month_format", "(", "self", ")", ":", "return", "self", ".", "month_format" ]
[ 72, 4 ]
[ 77, 32 ]
python
en
['en', 'error', 'th']
False
MonthMixin.get_month
(self)
Return the month for which this view should display data.
Return the month for which this view should display data.
def get_month(self): """Return the month for which this view should display data.""" month = self.month if month is None: try: month = self.kwargs['month'] except KeyError: try: month = self.request.GET['month'] ...
[ "def", "get_month", "(", "self", ")", ":", "month", "=", "self", ".", "month", "if", "month", "is", "None", ":", "try", ":", "month", "=", "self", ".", "kwargs", "[", "'month'", "]", "except", "KeyError", ":", "try", ":", "month", "=", "self", ".",...
[ 79, 4 ]
[ 90, 20 ]
python
en
['en', 'en', 'en']
True
MonthMixin.get_next_month
(self, date)
Get the next valid month.
Get the next valid month.
def get_next_month(self, date): """Get the next valid month.""" return _get_next_prev(self, date, is_previous=False, period='month')
[ "def", "get_next_month", "(", "self", ",", "date", ")", ":", "return", "_get_next_prev", "(", "self", ",", "date", ",", "is_previous", "=", "False", ",", "period", "=", "'month'", ")" ]
[ 92, 4 ]
[ 94, 76 ]
python
en
['en', 'en', 'en']
True
MonthMixin.get_previous_month
(self, date)
Get the previous valid month.
Get the previous valid month.
def get_previous_month(self, date): """Get the previous valid month.""" return _get_next_prev(self, date, is_previous=True, period='month')
[ "def", "get_previous_month", "(", "self", ",", "date", ")", ":", "return", "_get_next_prev", "(", "self", ",", "date", ",", "is_previous", "=", "True", ",", "period", "=", "'month'", ")" ]
[ 96, 4 ]
[ 98, 75 ]
python
en
['en', 'en', 'en']
True
MonthMixin._get_next_month
(self, date)
Return the start date of the next interval. The interval is defined by start date <= item date < next start date.
Return the start date of the next interval.
def _get_next_month(self, date): """ Return the start date of the next interval. The interval is defined by start date <= item date < next start date. """ if date.month == 12: try: return date.replace(year=date.year + 1, month=1, day=1) ex...
[ "def", "_get_next_month", "(", "self", ",", "date", ")", ":", "if", "date", ".", "month", "==", "12", ":", "try", ":", "return", "date", ".", "replace", "(", "year", "=", "date", ".", "year", "+", "1", ",", "month", "=", "1", ",", "day", "=", "...
[ 100, 4 ]
[ 112, 60 ]
python
en
['en', 'error', 'th']
False
MonthMixin._get_current_month
(self, date)
Return the start date of the previous interval.
Return the start date of the previous interval.
def _get_current_month(self, date): """Return the start date of the previous interval.""" return date.replace(day=1)
[ "def", "_get_current_month", "(", "self", ",", "date", ")", ":", "return", "date", ".", "replace", "(", "day", "=", "1", ")" ]
[ 114, 4 ]
[ 116, 34 ]
python
en
['en', 'en', 'en']
True
DayMixin.get_day_format
(self)
Get a day format string in strptime syntax to be used to parse the day from url variables.
Get a day format string in strptime syntax to be used to parse the day from url variables.
def get_day_format(self): """ Get a day format string in strptime syntax to be used to parse the day from url variables. """ return self.day_format
[ "def", "get_day_format", "(", "self", ")", ":", "return", "self", ".", "day_format" ]
[ 124, 4 ]
[ 129, 30 ]
python
en
['en', 'error', 'th']
False
DayMixin.get_day
(self)
Return the day for which this view should display data.
Return the day for which this view should display data.
def get_day(self): """Return the day for which this view should display data.""" day = self.day if day is None: try: day = self.kwargs['day'] except KeyError: try: day = self.request.GET['day'] except Key...
[ "def", "get_day", "(", "self", ")", ":", "day", "=", "self", ".", "day", "if", "day", "is", "None", ":", "try", ":", "day", "=", "self", ".", "kwargs", "[", "'day'", "]", "except", "KeyError", ":", "try", ":", "day", "=", "self", ".", "request", ...
[ 131, 4 ]
[ 142, 18 ]
python
en
['en', 'en', 'en']
True
DayMixin.get_next_day
(self, date)
Get the next valid day.
Get the next valid day.
def get_next_day(self, date): """Get the next valid day.""" return _get_next_prev(self, date, is_previous=False, period='day')
[ "def", "get_next_day", "(", "self", ",", "date", ")", ":", "return", "_get_next_prev", "(", "self", ",", "date", ",", "is_previous", "=", "False", ",", "period", "=", "'day'", ")" ]
[ 144, 4 ]
[ 146, 74 ]
python
en
['en', 'en', 'en']
True
DayMixin.get_previous_day
(self, date)
Get the previous valid day.
Get the previous valid day.
def get_previous_day(self, date): """Get the previous valid day.""" return _get_next_prev(self, date, is_previous=True, period='day')
[ "def", "get_previous_day", "(", "self", ",", "date", ")", ":", "return", "_get_next_prev", "(", "self", ",", "date", ",", "is_previous", "=", "True", ",", "period", "=", "'day'", ")" ]
[ 148, 4 ]
[ 150, 73 ]
python
en
['en', 'en', 'en']
True
DayMixin._get_next_day
(self, date)
Return the start date of the next interval. The interval is defined by start date <= item date < next start date.
Return the start date of the next interval.
def _get_next_day(self, date): """ Return the start date of the next interval. The interval is defined by start date <= item date < next start date. """ return date + datetime.timedelta(days=1)
[ "def", "_get_next_day", "(", "self", ",", "date", ")", ":", "return", "date", "+", "datetime", ".", "timedelta", "(", "days", "=", "1", ")" ]
[ 152, 4 ]
[ 158, 48 ]
python
en
['en', 'error', 'th']
False
DayMixin._get_current_day
(self, date)
Return the start date of the current interval.
Return the start date of the current interval.
def _get_current_day(self, date): """Return the start date of the current interval.""" return date
[ "def", "_get_current_day", "(", "self", ",", "date", ")", ":", "return", "date" ]
[ 160, 4 ]
[ 162, 19 ]
python
en
['en', 'en', 'en']
True
WeekMixin.get_week_format
(self)
Get a week format string in strptime syntax to be used to parse the week from url variables.
Get a week format string in strptime syntax to be used to parse the week from url variables.
def get_week_format(self): """ Get a week format string in strptime syntax to be used to parse the week from url variables. """ return self.week_format
[ "def", "get_week_format", "(", "self", ")", ":", "return", "self", ".", "week_format" ]
[ 170, 4 ]
[ 175, 31 ]
python
en
['en', 'error', 'th']
False
WeekMixin.get_week
(self)
Return the week for which this view should display data.
Return the week for which this view should display data.
def get_week(self): """Return the week for which this view should display data.""" week = self.week if week is None: try: week = self.kwargs['week'] except KeyError: try: week = self.request.GET['week'] e...
[ "def", "get_week", "(", "self", ")", ":", "week", "=", "self", ".", "week", "if", "week", "is", "None", ":", "try", ":", "week", "=", "self", ".", "kwargs", "[", "'week'", "]", "except", "KeyError", ":", "try", ":", "week", "=", "self", ".", "req...
[ 177, 4 ]
[ 188, 19 ]
python
en
['en', 'en', 'en']
True
WeekMixin.get_next_week
(self, date)
Get the next valid week.
Get the next valid week.
def get_next_week(self, date): """Get the next valid week.""" return _get_next_prev(self, date, is_previous=False, period='week')
[ "def", "get_next_week", "(", "self", ",", "date", ")", ":", "return", "_get_next_prev", "(", "self", ",", "date", ",", "is_previous", "=", "False", ",", "period", "=", "'week'", ")" ]
[ 190, 4 ]
[ 192, 75 ]
python
en
['en', 'af', 'en']
True
WeekMixin.get_previous_week
(self, date)
Get the previous valid week.
Get the previous valid week.
def get_previous_week(self, date): """Get the previous valid week.""" return _get_next_prev(self, date, is_previous=True, period='week')
[ "def", "get_previous_week", "(", "self", ",", "date", ")", ":", "return", "_get_next_prev", "(", "self", ",", "date", ",", "is_previous", "=", "True", ",", "period", "=", "'week'", ")" ]
[ 194, 4 ]
[ 196, 74 ]
python
en
['en', 'af', 'en']
True
WeekMixin._get_next_week
(self, date)
Return the start date of the next interval. The interval is defined by start date <= item date < next start date.
Return the start date of the next interval.
def _get_next_week(self, date): """ Return the start date of the next interval. The interval is defined by start date <= item date < next start date. """ try: return date + datetime.timedelta(days=7 - self._get_weekday(date)) except OverflowError: ...
[ "def", "_get_next_week", "(", "self", ",", "date", ")", ":", "try", ":", "return", "date", "+", "datetime", ".", "timedelta", "(", "days", "=", "7", "-", "self", ".", "_get_weekday", "(", "date", ")", ")", "except", "OverflowError", ":", "raise", "Http...
[ 198, 4 ]
[ 207, 49 ]
python
en
['en', 'error', 'th']
False
WeekMixin._get_current_week
(self, date)
Return the start date of the current interval.
Return the start date of the current interval.
def _get_current_week(self, date): """Return the start date of the current interval.""" return date - datetime.timedelta(self._get_weekday(date))
[ "def", "_get_current_week", "(", "self", ",", "date", ")", ":", "return", "date", "-", "datetime", ".", "timedelta", "(", "self", ".", "_get_weekday", "(", "date", ")", ")" ]
[ 209, 4 ]
[ 211, 65 ]
python
en
['en', 'en', 'en']
True
WeekMixin._get_weekday
(self, date)
Return the weekday for a given date. The first day according to the week format is 0 and the last day is 6.
Return the weekday for a given date.
def _get_weekday(self, date): """ Return the weekday for a given date. The first day according to the week format is 0 and the last day is 6. """ week_format = self.get_week_format() if week_format == '%W': # week starts on Monday return date....
[ "def", "_get_weekday", "(", "self", ",", "date", ")", ":", "week_format", "=", "self", ".", "get_week_format", "(", ")", "if", "week_format", "==", "'%W'", ":", "# week starts on Monday", "return", "date", ".", "weekday", "(", ")", "elif", "week_format", "==...
[ 213, 4 ]
[ 225, 69 ]
python
en
['en', 'error', 'th']
False
DateMixin.get_date_field
(self)
Get the name of the date field to be used to filter by.
Get the name of the date field to be used to filter by.
def get_date_field(self): """Get the name of the date field to be used to filter by.""" if self.date_field is None: raise ImproperlyConfigured("%s.date_field is required." % self.__class__.__name__) return self.date_field
[ "def", "get_date_field", "(", "self", ")", ":", "if", "self", ".", "date_field", "is", "None", ":", "raise", "ImproperlyConfigured", "(", "\"%s.date_field is required.\"", "%", "self", ".", "__class__", ".", "__name__", ")", "return", "self", ".", "date_field" ]
[ 233, 4 ]
[ 237, 30 ]
python
en
['en', 'en', 'en']
True
DateMixin.get_allow_future
(self)
Return `True` if the view should be allowed to display objects from the future.
Return `True` if the view should be allowed to display objects from the future.
def get_allow_future(self): """ Return `True` if the view should be allowed to display objects from the future. """ return self.allow_future
[ "def", "get_allow_future", "(", "self", ")", ":", "return", "self", ".", "allow_future" ]
[ 239, 4 ]
[ 244, 32 ]
python
en
['en', 'error', 'th']
False
DateMixin.uses_datetime_field
(self)
Return `True` if the date field is a `DateTimeField` and `False` if it's a `DateField`.
Return `True` if the date field is a `DateTimeField` and `False` if it's a `DateField`.
def uses_datetime_field(self): """ Return `True` if the date field is a `DateTimeField` and `False` if it's a `DateField`. """ model = self.get_queryset().model if self.model is None else self.model field = model._meta.get_field(self.get_date_field()) return isins...
[ "def", "uses_datetime_field", "(", "self", ")", ":", "model", "=", "self", ".", "get_queryset", "(", ")", ".", "model", "if", "self", ".", "model", "is", "None", "else", "self", ".", "model", "field", "=", "model", ".", "_meta", ".", "get_field", "(", ...
[ 250, 4 ]
[ 257, 54 ]
python
en
['en', 'error', 'th']
False
DateMixin._make_date_lookup_arg
(self, value)
Convert a date into a datetime when the date field is a DateTimeField. When time zone support is enabled, `date` is assumed to be in the current time zone, so that displayed items are consistent with the URL.
Convert a date into a datetime when the date field is a DateTimeField.
def _make_date_lookup_arg(self, value): """ Convert a date into a datetime when the date field is a DateTimeField. When time zone support is enabled, `date` is assumed to be in the current time zone, so that displayed items are consistent with the URL. """ if self.uses_d...
[ "def", "_make_date_lookup_arg", "(", "self", ",", "value", ")", ":", "if", "self", ".", "uses_datetime_field", ":", "value", "=", "datetime", ".", "datetime", ".", "combine", "(", "value", ",", "datetime", ".", "time", ".", "min", ")", "if", "settings", ...
[ 259, 4 ]
[ 270, 20 ]
python
en
['en', 'error', 'th']
False
DateMixin._make_single_date_lookup
(self, date)
Get the lookup kwargs for filtering on a single date. If the date field is a DateTimeField, we can't just filter on date_field=date because that doesn't take the time into account.
Get the lookup kwargs for filtering on a single date.
def _make_single_date_lookup(self, date): """ Get the lookup kwargs for filtering on a single date. If the date field is a DateTimeField, we can't just filter on date_field=date because that doesn't take the time into account. """ date_field = self.get_date_field() ...
[ "def", "_make_single_date_lookup", "(", "self", ",", "date", ")", ":", "date_field", "=", "self", ".", "get_date_field", "(", ")", "if", "self", ".", "uses_datetime_field", ":", "since", "=", "self", ".", "_make_date_lookup_arg", "(", "date", ")", "until", "...
[ 272, 4 ]
[ 289, 37 ]
python
en
['en', 'error', 'th']
False
BaseDateListView.get_dated_items
(self)
Obtain the list of dates and items.
Obtain the list of dates and items.
def get_dated_items(self): """Obtain the list of dates and items.""" raise NotImplementedError('A DateView must provide an implementation of get_dated_items()')
[ "def", "get_dated_items", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'A DateView must provide an implementation of get_dated_items()'", ")" ]
[ 306, 4 ]
[ 308, 99 ]
python
en
['en', 'en', 'en']
True
BaseDateListView.get_ordering
(self)
Return the field or fields to use for ordering the queryset; use the date field by default.
Return the field or fields to use for ordering the queryset; use the date field by default.
def get_ordering(self): """ Return the field or fields to use for ordering the queryset; use the date field by default. """ return '-%s' % self.get_date_field() if self.ordering is None else self.ordering
[ "def", "get_ordering", "(", "self", ")", ":", "return", "'-%s'", "%", "self", ".", "get_date_field", "(", ")", "if", "self", ".", "ordering", "is", "None", "else", "self", ".", "ordering" ]
[ 310, 4 ]
[ 315, 88 ]
python
en
['en', 'error', 'th']
False
BaseDateListView.get_dated_queryset
(self, **lookup)
Get a queryset properly filtered according to `allow_future` and any extra lookup kwargs.
Get a queryset properly filtered according to `allow_future` and any extra lookup kwargs.
def get_dated_queryset(self, **lookup): """ Get a queryset properly filtered according to `allow_future` and any extra lookup kwargs. """ qs = self.get_queryset().filter(**lookup) date_field = self.get_date_field() allow_future = self.get_allow_future() al...
[ "def", "get_dated_queryset", "(", "self", ",", "*", "*", "lookup", ")", ":", "qs", "=", "self", ".", "get_queryset", "(", ")", ".", "filter", "(", "*", "*", "lookup", ")", "date_field", "=", "self", ".", "get_date_field", "(", ")", "allow_future", "=",...
[ 317, 4 ]
[ 341, 17 ]
python
en
['en', 'error', 'th']
False
BaseDateListView.get_date_list_period
(self)
Get the aggregation period for the list of dates: 'year', 'month', or 'day'.
Get the aggregation period for the list of dates: 'year', 'month', or 'day'.
def get_date_list_period(self): """ Get the aggregation period for the list of dates: 'year', 'month', or 'day'. """ return self.date_list_period
[ "def", "get_date_list_period", "(", "self", ")", ":", "return", "self", ".", "date_list_period" ]
[ 343, 4 ]
[ 348, 36 ]
python
en
['en', 'error', 'th']
False
BaseDateListView.get_date_list
(self, queryset, date_type=None, ordering='ASC')
Get a date list by calling `queryset.dates/datetimes()`, checking along the way for empty lists that aren't allowed.
Get a date list by calling `queryset.dates/datetimes()`, checking along the way for empty lists that aren't allowed.
def get_date_list(self, queryset, date_type=None, ordering='ASC'): """ Get a date list by calling `queryset.dates/datetimes()`, checking along the way for empty lists that aren't allowed. """ date_field = self.get_date_field() allow_empty = self.get_allow_empty() ...
[ "def", "get_date_list", "(", "self", ",", "queryset", ",", "date_type", "=", "None", ",", "ordering", "=", "'ASC'", ")", ":", "date_field", "=", "self", ".", "get_date_field", "(", ")", "allow_empty", "=", "self", ".", "get_allow_empty", "(", ")", "if", ...
[ 350, 4 ]
[ 371, 24 ]
python
en
['en', 'error', 'th']
False
BaseArchiveIndexView.get_dated_items
(self)
Return (date_list, items, extra_context) for this request.
Return (date_list, items, extra_context) for this request.
def get_dated_items(self): """Return (date_list, items, extra_context) for this request.""" qs = self.get_dated_queryset() date_list = self.get_date_list(qs, ordering='DESC') if not date_list: qs = qs.none() return (date_list, qs, {})
[ "def", "get_dated_items", "(", "self", ")", ":", "qs", "=", "self", ".", "get_dated_queryset", "(", ")", "date_list", "=", "self", ".", "get_date_list", "(", "qs", ",", "ordering", "=", "'DESC'", ")", "if", "not", "date_list", ":", "qs", "=", "qs", "."...
[ 380, 4 ]
[ 388, 34 ]
python
en
['en', 'en', 'en']
True
BaseYearArchiveView.get_dated_items
(self)
Return (date_list, items, extra_context) for this request.
Return (date_list, items, extra_context) for this request.
def get_dated_items(self): """Return (date_list, items, extra_context) for this request.""" year = self.get_year() date_field = self.get_date_field() date = _date_from_string(year, self.get_year_format()) since = self._make_date_lookup_arg(date) until = self._make_date_...
[ "def", "get_dated_items", "(", "self", ")", ":", "year", "=", "self", ".", "get_year", "(", ")", "date_field", "=", "self", ".", "get_date_field", "(", ")", "date", "=", "_date_from_string", "(", "year", ",", "self", ".", "get_year_format", "(", ")", ")"...
[ 401, 4 ]
[ 427, 10 ]
python
en
['en', 'en', 'en']
True
BaseYearArchiveView.get_make_object_list
(self)
Return `True` if this view should contain the full list of objects in the given year.
Return `True` if this view should contain the full list of objects in the given year.
def get_make_object_list(self): """ Return `True` if this view should contain the full list of objects in the given year. """ return self.make_object_list
[ "def", "get_make_object_list", "(", "self", ")", ":", "return", "self", ".", "make_object_list" ]
[ 429, 4 ]
[ 434, 36 ]
python
en
['en', 'error', 'th']
False
BaseMonthArchiveView.get_dated_items
(self)
Return (date_list, items, extra_context) for this request.
Return (date_list, items, extra_context) for this request.
def get_dated_items(self): """Return (date_list, items, extra_context) for this request.""" year = self.get_year() month = self.get_month() date_field = self.get_date_field() date = _date_from_string(year, self.get_year_format(), month, self.get_...
[ "def", "get_dated_items", "(", "self", ")", ":", "year", "=", "self", ".", "get_year", "(", ")", "month", "=", "self", ".", "get_month", "(", ")", "date_field", "=", "self", ".", "get_date_field", "(", ")", "date", "=", "_date_from_string", "(", "year", ...
[ 446, 4 ]
[ 469, 10 ]
python
en
['en', 'en', 'en']
True
BaseWeekArchiveView.get_dated_items
(self)
Return (date_list, items, extra_context) for this request.
Return (date_list, items, extra_context) for this request.
def get_dated_items(self): """Return (date_list, items, extra_context) for this request.""" year = self.get_year() week = self.get_week() date_field = self.get_date_field() week_format = self.get_week_format() week_choices = {'%W': '1', '%U': '0'} try: ...
[ "def", "get_dated_items", "(", "self", ")", ":", "year", "=", "self", ".", "get_year", "(", ")", "week", "=", "self", ".", "get_week", "(", ")", "date_field", "=", "self", ".", "get_date_field", "(", ")", "week_format", "=", "self", ".", "get_week_format...
[ 480, 4 ]
[ 512, 10 ]
python
en
['en', 'en', 'en']
True
BaseDayArchiveView.get_dated_items
(self)
Return (date_list, items, extra_context) for this request.
Return (date_list, items, extra_context) for this request.
def get_dated_items(self): """Return (date_list, items, extra_context) for this request.""" year = self.get_year() month = self.get_month() day = self.get_day() date = _date_from_string(year, self.get_year_format(), month, self.get_month_format()...
[ "def", "get_dated_items", "(", "self", ")", ":", "year", "=", "self", ".", "get_year", "(", ")", "month", "=", "self", ".", "get_month", "(", ")", "day", "=", "self", ".", "get_day", "(", ")", "date", "=", "_date_from_string", "(", "year", ",", "self...
[ 522, 4 ]
[ 532, 42 ]
python
en
['en', 'en', 'en']
True
BaseDayArchiveView._get_dated_items
(self, date)
Do the actual heavy lifting of getting the dated items; this accepts a date object so that TodayArchiveView can be trivial.
Do the actual heavy lifting of getting the dated items; this accepts a date object so that TodayArchiveView can be trivial.
def _get_dated_items(self, date): """ Do the actual heavy lifting of getting the dated items; this accepts a date object so that TodayArchiveView can be trivial. """ lookup_kwargs = self._make_single_date_lookup(date) qs = self.get_dated_queryset(**lookup_kwargs) ...
[ "def", "_get_dated_items", "(", "self", ",", "date", ")", ":", "lookup_kwargs", "=", "self", ".", "_make_single_date_lookup", "(", "date", ")", "qs", "=", "self", ".", "get_dated_queryset", "(", "*", "*", "lookup_kwargs", ")", "return", "(", "None", ",", "...
[ 534, 4 ]
[ 548, 10 ]
python
en
['en', 'error', 'th']
False
BaseTodayArchiveView.get_dated_items
(self)
Return (date_list, items, extra_context) for this request.
Return (date_list, items, extra_context) for this request.
def get_dated_items(self): """Return (date_list, items, extra_context) for this request.""" return self._get_dated_items(datetime.date.today())
[ "def", "get_dated_items", "(", "self", ")", ":", "return", "self", ".", "_get_dated_items", "(", "datetime", ".", "date", ".", "today", "(", ")", ")" ]
[ 559, 4 ]
[ 561, 59 ]
python
en
['en', 'en', 'en']
True
BaseDateDetailView.get_object
(self, queryset=None)
Get the object this request displays.
Get the object this request displays.
def get_object(self, queryset=None): """Get the object this request displays.""" year = self.get_year() month = self.get_month() day = self.get_day() date = _date_from_string(year, self.get_year_format(), month, self.get_month_format(), ...
[ "def", "get_object", "(", "self", ",", "queryset", "=", "None", ")", ":", "year", "=", "self", ".", "get_year", "(", ")", "month", "=", "self", ".", "get_month", "(", ")", "day", "=", "self", ".", "get_day", "(", ")", "date", "=", "_date_from_string"...
[ 574, 4 ]
[ 601, 46 ]
python
en
['en', 'en', 'en']
True
DatabaseSessionTests.test_session_str
(self)
Session repr should be the session key.
Session repr should be the session key.
def test_session_str(self): "Session repr should be the session key." self.session['x'] = 1 self.session.save() session_key = self.session.session_key s = Session.objects.get(session_key=session_key) self.assertEqual(force_text(s), session_key)
[ "def", "test_session_str", "(", "self", ")", ":", "self", ".", "session", "[", "'x'", "]", "=", "1", "self", ".", "session", ".", "save", "(", ")", "session_key", "=", "self", ".", "session", ".", "session_key", "s", "=", "Session", ".", "objects", "...
[ 316, 4 ]
[ 324, 52 ]
python
en
['en', 'en', 'en']
True
DatabaseSessionTests.test_session_get_decoded
(self)
Test we can use Session.get_decoded to retrieve data stored in normal way
Test we can use Session.get_decoded to retrieve data stored in normal way
def test_session_get_decoded(self): """ Test we can use Session.get_decoded to retrieve data stored in normal way """ self.session['x'] = 1 self.session.save() s = Session.objects.get(session_key=self.session.session_key) self.assertEqual(s.get_decoded()...
[ "def", "test_session_get_decoded", "(", "self", ")", ":", "self", ".", "session", "[", "'x'", "]", "=", "1", "self", ".", "session", ".", "save", "(", ")", "s", "=", "Session", ".", "objects", ".", "get", "(", "session_key", "=", "self", ".", "sessio...
[ 326, 4 ]
[ 336, 51 ]
python
en
['en', 'error', 'th']
False
DatabaseSessionTests.test_sessionmanager_save
(self)
Test SessionManager.save method
Test SessionManager.save method
def test_sessionmanager_save(self): """ Test SessionManager.save method """ # Create a session self.session['y'] = 1 self.session.save() s = Session.objects.get(session_key=self.session.session_key) # Change it Session.objects.save(s.session_key, ...
[ "def", "test_sessionmanager_save", "(", "self", ")", ":", "# Create a session", "self", ".", "session", "[", "'y'", "]", "=", "1", "self", ".", "session", ".", "save", "(", ")", "s", "=", "Session", ".", "objects", ".", "get", "(", "session_key", "=", ...
[ 338, 4 ]
[ 351, 46 ]
python
en
['en', 'error', 'th']
False
DatabaseSessionTests.test_clearsessions_command
(self)
Test clearsessions command for clearing expired sessions.
Test clearsessions command for clearing expired sessions.
def test_clearsessions_command(self): """ Test clearsessions command for clearing expired sessions. """ self.assertEqual(0, Session.objects.count()) # One object in the future self.session['foo'] = 'bar' self.session.set_expiry(3600) self.session.save() ...
[ "def", "test_clearsessions_command", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "0", ",", "Session", ".", "objects", ".", "count", "(", ")", ")", "# One object in the future", "self", ".", "session", "[", "'foo'", "]", "=", "'bar'", "self", "....
[ 354, 4 ]
[ 375, 52 ]
python
en
['en', 'error', 'th']
False