partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
iter_tree
Walks the specified directory for all files. *root* (:class:`str`) is the root directory to search for files. *on_error* (:class:`~collections.abc.Callable` or :data:`None`) optionally is the error handler for file-system exceptions. It will be called with the exception (:exc:`OSError`). Reraise the exception to ...
pathspec/util.py
def iter_tree(root, on_error=None, follow_links=None): """ Walks the specified directory for all files. *root* (:class:`str`) is the root directory to search for files. *on_error* (:class:`~collections.abc.Callable` or :data:`None`) optionally is the error handler for file-system exceptions. It will be called w...
def iter_tree(root, on_error=None, follow_links=None): """ Walks the specified directory for all files. *root* (:class:`str`) is the root directory to search for files. *on_error* (:class:`~collections.abc.Callable` or :data:`None`) optionally is the error handler for file-system exceptions. It will be called w...
[ "Walks", "the", "specified", "directory", "for", "all", "files", "." ]
cpburnz/python-path-specification
python
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L27-L55
[ "def", "iter_tree", "(", "root", ",", "on_error", "=", "None", ",", "follow_links", "=", "None", ")", ":", "if", "on_error", "is", "not", "None", "and", "not", "callable", "(", "on_error", ")", ":", "raise", "TypeError", "(", "\"on_error:{!r} is not callable...
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
train
_iter_tree_next
Scan the directory for all descendant files. *root_full* (:class:`str`) the absolute path to the root directory. *dir_rel* (:class:`str`) the path to the directory to scan relative to *root_full*. *memo* (:class:`dict`) keeps track of ancestor directories encountered. Maps each ancestor real path (:class:`str``...
pathspec/util.py
def _iter_tree_next(root_full, dir_rel, memo, on_error, follow_links): """ Scan the directory for all descendant files. *root_full* (:class:`str`) the absolute path to the root directory. *dir_rel* (:class:`str`) the path to the directory to scan relative to *root_full*. *memo* (:class:`dict`) keeps track of a...
def _iter_tree_next(root_full, dir_rel, memo, on_error, follow_links): """ Scan the directory for all descendant files. *root_full* (:class:`str`) the absolute path to the root directory. *dir_rel* (:class:`str`) the path to the directory to scan relative to *root_full*. *memo* (:class:`dict`) keeps track of a...
[ "Scan", "the", "directory", "for", "all", "descendant", "files", "." ]
cpburnz/python-path-specification
python
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L57-L126
[ "def", "_iter_tree_next", "(", "root_full", ",", "dir_rel", ",", "memo", ",", "on_error", ",", "follow_links", ")", ":", "dir_full", "=", "os", ".", "path", ".", "join", "(", "root_full", ",", "dir_rel", ")", "dir_real", "=", "os", ".", "path", ".", "r...
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
train
match_file
Matches the file to the patterns. *patterns* (:class:`~collections.abc.Iterable` of :class:`~pathspec.pattern.Pattern`) contains the patterns to use. *file* (:class:`str`) is the normalized file path to be matched against *patterns*. Returns :data:`True` if *file* matched; otherwise, :data:`False`.
pathspec/util.py
def match_file(patterns, file): """ Matches the file to the patterns. *patterns* (:class:`~collections.abc.Iterable` of :class:`~pathspec.pattern.Pattern`) contains the patterns to use. *file* (:class:`str`) is the normalized file path to be matched against *patterns*. Returns :data:`True` if *file* matched; ...
def match_file(patterns, file): """ Matches the file to the patterns. *patterns* (:class:`~collections.abc.Iterable` of :class:`~pathspec.pattern.Pattern`) contains the patterns to use. *file* (:class:`str`) is the normalized file path to be matched against *patterns*. Returns :data:`True` if *file* matched; ...
[ "Matches", "the", "file", "to", "the", "patterns", "." ]
cpburnz/python-path-specification
python
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L139-L156
[ "def", "match_file", "(", "patterns", ",", "file", ")", ":", "matched", "=", "False", "for", "pattern", "in", "patterns", ":", "if", "pattern", ".", "include", "is", "not", "None", ":", "if", "file", "in", "pattern", ".", "match", "(", "(", "file", "...
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
train
match_files
Matches the files to the patterns. *patterns* (:class:`~collections.abc.Iterable` of :class:`~pathspec.pattern.Pattern`) contains the patterns to use. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains the normalized file paths to be matched against *patterns*. Returns the matched files (:cla...
pathspec/util.py
def match_files(patterns, files): """ Matches the files to the patterns. *patterns* (:class:`~collections.abc.Iterable` of :class:`~pathspec.pattern.Pattern`) contains the patterns to use. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains the normalized file paths to be matched against *patt...
def match_files(patterns, files): """ Matches the files to the patterns. *patterns* (:class:`~collections.abc.Iterable` of :class:`~pathspec.pattern.Pattern`) contains the patterns to use. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains the normalized file paths to be matched against *patt...
[ "Matches", "the", "files", "to", "the", "patterns", "." ]
cpburnz/python-path-specification
python
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L158-L179
[ "def", "match_files", "(", "patterns", ",", "files", ")", ":", "all_files", "=", "files", "if", "isinstance", "(", "files", ",", "collection_type", ")", "else", "list", "(", "files", ")", "return_files", "=", "set", "(", ")", "for", "pattern", "in", "pat...
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
train
normalize_file
Normalizes the file path to use the POSIX path separator (i.e., ``'/'``). *file* (:class:`str`) is the file path. *separators* (:class:`~collections.abc.Collection` of :class:`str`; or :data:`None`) optionally contains the path separators to normalize. This does not need to include the POSIX path separator (``'/'...
pathspec/util.py
def normalize_file(file, separators=None): """ Normalizes the file path to use the POSIX path separator (i.e., ``'/'``). *file* (:class:`str`) is the file path. *separators* (:class:`~collections.abc.Collection` of :class:`str`; or :data:`None`) optionally contains the path separators to normalize. This does no...
def normalize_file(file, separators=None): """ Normalizes the file path to use the POSIX path separator (i.e., ``'/'``). *file* (:class:`str`) is the file path. *separators* (:class:`~collections.abc.Collection` of :class:`str`; or :data:`None`) optionally contains the path separators to normalize. This does no...
[ "Normalizes", "the", "file", "path", "to", "use", "the", "POSIX", "path", "separator", "(", "i", ".", "e", ".", "/", ")", "." ]
cpburnz/python-path-specification
python
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L181-L207
[ "def", "normalize_file", "(", "file", ",", "separators", "=", "None", ")", ":", "# Normalize path separators.", "if", "separators", "is", "None", ":", "separators", "=", "NORMALIZE_PATH_SEPS", "norm_file", "=", "file", "for", "sep", "in", "separators", ":", "nor...
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
train
normalize_files
Normalizes the file paths to use the POSIX path separator. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains the file paths to be normalized. *separators* (:class:`~collections.abc.Collection` of :class:`str`; or :data:`None`) optionally contains the path separators to normalize. See :func:`n...
pathspec/util.py
def normalize_files(files, separators=None): """ Normalizes the file paths to use the POSIX path separator. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains the file paths to be normalized. *separators* (:class:`~collections.abc.Collection` of :class:`str`; or :data:`None`) optionally conta...
def normalize_files(files, separators=None): """ Normalizes the file paths to use the POSIX path separator. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains the file paths to be normalized. *separators* (:class:`~collections.abc.Collection` of :class:`str`; or :data:`None`) optionally conta...
[ "Normalizes", "the", "file", "paths", "to", "use", "the", "POSIX", "path", "separator", "." ]
cpburnz/python-path-specification
python
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L209-L226
[ "def", "normalize_files", "(", "files", ",", "separators", "=", "None", ")", ":", "norm_files", "=", "{", "}", "for", "path", "in", "files", ":", "norm_files", "[", "normalize_file", "(", "path", ",", "separators", "=", "separators", ")", "]", "=", "path...
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
train
register_pattern
Registers the specified pattern factory. *name* (:class:`str`) is the name to register the pattern factory under. *pattern_factory* (:class:`~collections.abc.Callable`) is used to compile patterns. It must accept an uncompiled pattern (:class:`str`) and return the compiled pattern (:class:`.Pattern`). *overrid...
pathspec/util.py
def register_pattern(name, pattern_factory, override=None): """ Registers the specified pattern factory. *name* (:class:`str`) is the name to register the pattern factory under. *pattern_factory* (:class:`~collections.abc.Callable`) is used to compile patterns. It must accept an uncompiled pattern (:class:`str`...
def register_pattern(name, pattern_factory, override=None): """ Registers the specified pattern factory. *name* (:class:`str`) is the name to register the pattern factory under. *pattern_factory* (:class:`~collections.abc.Callable`) is used to compile patterns. It must accept an uncompiled pattern (:class:`str`...
[ "Registers", "the", "specified", "pattern", "factory", "." ]
cpburnz/python-path-specification
python
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L228-L250
[ "def", "register_pattern", "(", "name", ",", "pattern_factory", ",", "override", "=", "None", ")", ":", "if", "not", "isinstance", "(", "name", ",", "string_types", ")", ":", "raise", "TypeError", "(", "\"name:{!r} is not a string.\"", ".", "format", "(", "nam...
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
train
RecursionError.message
*message* (:class:`str`) is the error message.
pathspec/util.py
def message(self): """ *message* (:class:`str`) is the error message. """ return "Real path {real!r} was encountered at {first!r} and then {second!r}.".format( real=self.real_path, first=self.first_path, second=self.second_path, )
def message(self): """ *message* (:class:`str`) is the error message. """ return "Real path {real!r} was encountered at {first!r} and then {second!r}.".format( real=self.real_path, first=self.first_path, second=self.second_path, )
[ "*", "message", "*", "(", ":", "class", ":", "str", ")", "is", "the", "error", "message", "." ]
cpburnz/python-path-specification
python
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L326-L334
[ "def", "message", "(", "self", ")", ":", "return", "\"Real path {real!r} was encountered at {first!r} and then {second!r}.\"", ".", "format", "(", "real", "=", "self", ".", "real_path", ",", "first", "=", "self", ".", "first_path", ",", "second", "=", "self", ".",...
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
train
Pattern.match
Matches this pattern against the specified files. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains each file relative to the root directory (e.g., ``"relative/path/to/file"``). Returns an :class:`~collections.abc.Iterable` yielding each matched file path (:class:`str`).
pathspec/pattern.py
def match(self, files): """ Matches this pattern against the specified files. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains each file relative to the root directory (e.g., ``"relative/path/to/file"``). Returns an :class:`~collections.abc.Iterable` yielding each matched file path (:...
def match(self, files): """ Matches this pattern against the specified files. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains each file relative to the root directory (e.g., ``"relative/path/to/file"``). Returns an :class:`~collections.abc.Iterable` yielding each matched file path (:...
[ "Matches", "this", "pattern", "against", "the", "specified", "files", "." ]
cpburnz/python-path-specification
python
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/pattern.py#L35-L45
[ "def", "match", "(", "self", ",", "files", ")", ":", "raise", "NotImplementedError", "(", "\"{}.{} must override match().\"", ".", "format", "(", "self", ".", "__class__", ".", "__module__", ",", "self", ".", "__class__", ".", "__name__", ")", ")" ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
train
RegexPattern.match
Matches this pattern against the specified files. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains each file relative to the root directory (e.g., "relative/path/to/file"). Returns an :class:`~collections.abc.Iterable` yielding each matched file path (:class:`str`).
pathspec/pattern.py
def match(self, files): """ Matches this pattern against the specified files. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains each file relative to the root directory (e.g., "relative/path/to/file"). Returns an :class:`~collections.abc.Iterable` yielding each matched file path (:clas...
def match(self, files): """ Matches this pattern against the specified files. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains each file relative to the root directory (e.g., "relative/path/to/file"). Returns an :class:`~collections.abc.Iterable` yielding each matched file path (:clas...
[ "Matches", "this", "pattern", "against", "the", "specified", "files", "." ]
cpburnz/python-path-specification
python
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/pattern.py#L116-L129
[ "def", "match", "(", "self", ",", "files", ")", ":", "if", "self", ".", "include", "is", "not", "None", ":", "for", "path", "in", "files", ":", "if", "self", ".", "regex", ".", "match", "(", "path", ")", "is", "not", "None", ":", "yield", "path" ...
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
train
SampleCache.user_default_serializer
Convert a User to a cached instance representation.
sample_poll_app/cache.py
def user_default_serializer(self, obj): """Convert a User to a cached instance representation.""" if not obj: return None self.user_default_add_related_pks(obj) return dict(( ('id', obj.id), ('username', obj.username), self.field_to_json('D...
def user_default_serializer(self, obj): """Convert a User to a cached instance representation.""" if not obj: return None self.user_default_add_related_pks(obj) return dict(( ('id', obj.id), ('username', obj.username), self.field_to_json('D...
[ "Convert", "a", "User", "to", "a", "cached", "instance", "representation", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L13-L24
[ "def", "user_default_serializer", "(", "self", ",", "obj", ")", ":", "if", "not", "obj", ":", "return", "None", "self", ".", "user_default_add_related_pks", "(", "obj", ")", "return", "dict", "(", "(", "(", "'id'", ",", "obj", ".", "id", ")", ",", "(",...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
SampleCache.user_default_loader
Load a User from the database.
sample_poll_app/cache.py
def user_default_loader(self, pk): """Load a User from the database.""" try: obj = User.objects.get(pk=pk) except User.DoesNotExist: return None else: self.user_default_add_related_pks(obj) return obj
def user_default_loader(self, pk): """Load a User from the database.""" try: obj = User.objects.get(pk=pk) except User.DoesNotExist: return None else: self.user_default_add_related_pks(obj) return obj
[ "Load", "a", "User", "from", "the", "database", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L26-L34
[ "def", "user_default_loader", "(", "self", ",", "pk", ")", ":", "try", ":", "obj", "=", "User", ".", "objects", ".", "get", "(", "pk", "=", "pk", ")", "except", "User", ".", "DoesNotExist", ":", "return", "None", "else", ":", "self", ".", "user_defau...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
SampleCache.user_default_add_related_pks
Add related primary keys to a User instance.
sample_poll_app/cache.py
def user_default_add_related_pks(self, obj): """Add related primary keys to a User instance.""" if not hasattr(obj, '_votes_pks'): obj._votes_pks = list(obj.votes.values_list('pk', flat=True))
def user_default_add_related_pks(self, obj): """Add related primary keys to a User instance.""" if not hasattr(obj, '_votes_pks'): obj._votes_pks = list(obj.votes.values_list('pk', flat=True))
[ "Add", "related", "primary", "keys", "to", "a", "User", "instance", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L36-L39
[ "def", "user_default_add_related_pks", "(", "self", ",", "obj", ")", ":", "if", "not", "hasattr", "(", "obj", ",", "'_votes_pks'", ")", ":", "obj", ".", "_votes_pks", "=", "list", "(", "obj", ".", "votes", ".", "values_list", "(", "'pk'", ",", "flat", ...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
SampleCache.group_default_invalidator
Invalidated cached items when the Group changes.
sample_poll_app/cache.py
def group_default_invalidator(self, obj): """Invalidated cached items when the Group changes.""" user_pks = User.objects.values_list('pk', flat=True) return [('User', pk, False) for pk in user_pks]
def group_default_invalidator(self, obj): """Invalidated cached items when the Group changes.""" user_pks = User.objects.values_list('pk', flat=True) return [('User', pk, False) for pk in user_pks]
[ "Invalidated", "cached", "items", "when", "the", "Group", "changes", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L51-L54
[ "def", "group_default_invalidator", "(", "self", ",", "obj", ")", ":", "user_pks", "=", "User", ".", "objects", ".", "values_list", "(", "'pk'", ",", "flat", "=", "True", ")", "return", "[", "(", "'User'", ",", "pk", ",", "False", ")", "for", "pk", "...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
SampleCache.question_default_serializer
Convert a Question to a cached instance representation.
sample_poll_app/cache.py
def question_default_serializer(self, obj): """Convert a Question to a cached instance representation.""" if not obj: return None self.question_default_add_related_pks(obj) return dict(( ('id', obj.id), ('question_text', obj.question_text), ...
def question_default_serializer(self, obj): """Convert a Question to a cached instance representation.""" if not obj: return None self.question_default_add_related_pks(obj) return dict(( ('id', obj.id), ('question_text', obj.question_text), ...
[ "Convert", "a", "Question", "to", "a", "cached", "instance", "representation", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L60-L71
[ "def", "question_default_serializer", "(", "self", ",", "obj", ")", ":", "if", "not", "obj", ":", "return", "None", "self", ".", "question_default_add_related_pks", "(", "obj", ")", "return", "dict", "(", "(", "(", "'id'", ",", "obj", ".", "id", ")", ","...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
SampleCache.question_default_loader
Load a Question from the database.
sample_poll_app/cache.py
def question_default_loader(self, pk): """Load a Question from the database.""" try: obj = Question.objects.get(pk=pk) except Question.DoesNotExist: return None else: self.question_default_add_related_pks(obj) return obj
def question_default_loader(self, pk): """Load a Question from the database.""" try: obj = Question.objects.get(pk=pk) except Question.DoesNotExist: return None else: self.question_default_add_related_pks(obj) return obj
[ "Load", "a", "Question", "from", "the", "database", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L73-L81
[ "def", "question_default_loader", "(", "self", ",", "pk", ")", ":", "try", ":", "obj", "=", "Question", ".", "objects", ".", "get", "(", "pk", "=", "pk", ")", "except", "Question", ".", "DoesNotExist", ":", "return", "None", "else", ":", "self", ".", ...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
SampleCache.question_default_add_related_pks
Add related primary keys to a Question instance.
sample_poll_app/cache.py
def question_default_add_related_pks(self, obj): """Add related primary keys to a Question instance.""" if not hasattr(obj, '_choice_pks'): obj._choice_pks = list(obj.choices.values_list('pk', flat=True))
def question_default_add_related_pks(self, obj): """Add related primary keys to a Question instance.""" if not hasattr(obj, '_choice_pks'): obj._choice_pks = list(obj.choices.values_list('pk', flat=True))
[ "Add", "related", "primary", "keys", "to", "a", "Question", "instance", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L83-L86
[ "def", "question_default_add_related_pks", "(", "self", ",", "obj", ")", ":", "if", "not", "hasattr", "(", "obj", ",", "'_choice_pks'", ")", ":", "obj", ".", "_choice_pks", "=", "list", "(", "obj", ".", "choices", ".", "values_list", "(", "'pk'", ",", "f...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
SampleCache.choice_default_serializer
Convert a Choice to a cached instance representation.
sample_poll_app/cache.py
def choice_default_serializer(self, obj): """Convert a Choice to a cached instance representation.""" if not obj: return None self.choice_default_add_related_pks(obj) return dict(( ('id', obj.id), ('choice_text', obj.choice_text), self.fiel...
def choice_default_serializer(self, obj): """Convert a Choice to a cached instance representation.""" if not obj: return None self.choice_default_add_related_pks(obj) return dict(( ('id', obj.id), ('choice_text', obj.choice_text), self.fiel...
[ "Convert", "a", "Choice", "to", "a", "cached", "instance", "representation", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L92-L104
[ "def", "choice_default_serializer", "(", "self", ",", "obj", ")", ":", "if", "not", "obj", ":", "return", "None", "self", ".", "choice_default_add_related_pks", "(", "obj", ")", "return", "dict", "(", "(", "(", "'id'", ",", "obj", ".", "id", ")", ",", ...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
SampleCache.choice_default_loader
Load a Choice from the database.
sample_poll_app/cache.py
def choice_default_loader(self, pk): """Load a Choice from the database.""" try: obj = Choice.objects.get(pk=pk) except Choice.DoesNotExist: return None else: self.choice_default_add_related_pks(obj) return obj
def choice_default_loader(self, pk): """Load a Choice from the database.""" try: obj = Choice.objects.get(pk=pk) except Choice.DoesNotExist: return None else: self.choice_default_add_related_pks(obj) return obj
[ "Load", "a", "Choice", "from", "the", "database", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L106-L114
[ "def", "choice_default_loader", "(", "self", ",", "pk", ")", ":", "try", ":", "obj", "=", "Choice", ".", "objects", ".", "get", "(", "pk", "=", "pk", ")", "except", "Choice", ".", "DoesNotExist", ":", "return", "None", "else", ":", "self", ".", "choi...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
SampleCache.choice_default_add_related_pks
Add related primary keys to a Choice instance.
sample_poll_app/cache.py
def choice_default_add_related_pks(self, obj): """Add related primary keys to a Choice instance.""" if not hasattr(obj, '_voter_pks'): obj._voter_pks = obj.voters.values_list('pk', flat=True)
def choice_default_add_related_pks(self, obj): """Add related primary keys to a Choice instance.""" if not hasattr(obj, '_voter_pks'): obj._voter_pks = obj.voters.values_list('pk', flat=True)
[ "Add", "related", "primary", "keys", "to", "a", "Choice", "instance", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L116-L119
[ "def", "choice_default_add_related_pks", "(", "self", ",", "obj", ")", ":", "if", "not", "hasattr", "(", "obj", ",", "'_voter_pks'", ")", ":", "obj", ".", "_voter_pks", "=", "obj", ".", "voters", ".", "values_list", "(", "'pk'", ",", "flat", "=", "True",...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
SampleCache.choice_default_invalidator
Invalidated cached items when the Choice changes.
sample_poll_app/cache.py
def choice_default_invalidator(self, obj): """Invalidated cached items when the Choice changes.""" invalid = [('Question', obj.question_id, True)] for pk in obj.voters.values_list('pk', flat=True): invalid.append(('User', pk, False)) return invalid
def choice_default_invalidator(self, obj): """Invalidated cached items when the Choice changes.""" invalid = [('Question', obj.question_id, True)] for pk in obj.voters.values_list('pk', flat=True): invalid.append(('User', pk, False)) return invalid
[ "Invalidated", "cached", "items", "when", "the", "Choice", "changes", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L121-L126
[ "def", "choice_default_invalidator", "(", "self", ",", "obj", ")", ":", "invalid", "=", "[", "(", "'Question'", ",", "obj", ".", "question_id", ",", "True", ")", "]", "for", "pk", "in", "obj", ".", "voters", ".", "values_list", "(", "'pk'", ",", "flat"...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.cache
Get the Django cache interface. This allows disabling the cache with settings.USE_DRF_INSTANCE_CACHE=False. It also delays import so that Django Debug Toolbar will record cache requests.
drf_cached_instances/cache.py
def cache(self): """Get the Django cache interface. This allows disabling the cache with settings.USE_DRF_INSTANCE_CACHE=False. It also delays import so that Django Debug Toolbar will record cache requests. """ if not self._cache: use_cache = getattr(setting...
def cache(self): """Get the Django cache interface. This allows disabling the cache with settings.USE_DRF_INSTANCE_CACHE=False. It also delays import so that Django Debug Toolbar will record cache requests. """ if not self._cache: use_cache = getattr(setting...
[ "Get", "the", "Django", "cache", "interface", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L33-L45
[ "def", "cache", "(", "self", ")", ":", "if", "not", "self", ".", "_cache", ":", "use_cache", "=", "getattr", "(", "settings", ",", "'USE_DRF_INSTANCE_CACHE'", ",", "True", ")", "if", "use_cache", ":", "from", "django", ".", "core", ".", "cache", "import"...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.delete_all_versions
Delete all versions of a cached instance.
drf_cached_instances/cache.py
def delete_all_versions(self, model_name, obj_pk): """Delete all versions of a cached instance.""" if self.cache: for version in self.versions: key = self.key_for(version, model_name, obj_pk) self.cache.delete(key)
def delete_all_versions(self, model_name, obj_pk): """Delete all versions of a cached instance.""" if self.cache: for version in self.versions: key = self.key_for(version, model_name, obj_pk) self.cache.delete(key)
[ "Delete", "all", "versions", "of", "a", "cached", "instance", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L51-L56
[ "def", "delete_all_versions", "(", "self", ",", "model_name", ",", "obj_pk", ")", ":", "if", "self", ".", "cache", ":", "for", "version", "in", "self", ".", "versions", ":", "key", "=", "self", ".", "key_for", "(", "version", ",", "model_name", ",", "o...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.model_function
Return the model-specific caching function.
drf_cached_instances/cache.py
def model_function(self, model_name, version, func_name): """Return the model-specific caching function.""" assert func_name in ('serializer', 'loader', 'invalidator') name = "%s_%s_%s" % (model_name.lower(), version, func_name) return getattr(self, name)
def model_function(self, model_name, version, func_name): """Return the model-specific caching function.""" assert func_name in ('serializer', 'loader', 'invalidator') name = "%s_%s_%s" % (model_name.lower(), version, func_name) return getattr(self, name)
[ "Return", "the", "model", "-", "specific", "caching", "function", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L58-L62
[ "def", "model_function", "(", "self", ",", "model_name", ",", "version", ",", "func_name", ")", ":", "assert", "func_name", "in", "(", "'serializer'", ",", "'loader'", ",", "'invalidator'", ")", "name", "=", "\"%s_%s_%s\"", "%", "(", "model_name", ".", "lowe...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.field_function
Return the field function.
drf_cached_instances/cache.py
def field_function(self, type_code, func_name): """Return the field function.""" assert func_name in ('to_json', 'from_json') name = "field_%s_%s" % (type_code.lower(), func_name) return getattr(self, name)
def field_function(self, type_code, func_name): """Return the field function.""" assert func_name in ('to_json', 'from_json') name = "field_%s_%s" % (type_code.lower(), func_name) return getattr(self, name)
[ "Return", "the", "field", "function", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L64-L68
[ "def", "field_function", "(", "self", ",", "type_code", ",", "func_name", ")", ":", "assert", "func_name", "in", "(", "'to_json'", ",", "'from_json'", ")", "name", "=", "\"field_%s_%s\"", "%", "(", "type_code", ".", "lower", "(", ")", ",", "func_name", ")"...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.field_to_json
Convert a field to a JSON-serializable representation.
drf_cached_instances/cache.py
def field_to_json(self, type_code, key, *args, **kwargs): """Convert a field to a JSON-serializable representation.""" assert ':' not in key to_json = self.field_function(type_code, 'to_json') key_and_type = "%s:%s" % (key, type_code) json_value = to_json(*args, **kwargs) ...
def field_to_json(self, type_code, key, *args, **kwargs): """Convert a field to a JSON-serializable representation.""" assert ':' not in key to_json = self.field_function(type_code, 'to_json') key_and_type = "%s:%s" % (key, type_code) json_value = to_json(*args, **kwargs) ...
[ "Convert", "a", "field", "to", "a", "JSON", "-", "serializable", "representation", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L70-L76
[ "def", "field_to_json", "(", "self", ",", "type_code", ",", "key", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "assert", "':'", "not", "in", "key", "to_json", "=", "self", ".", "field_function", "(", "type_code", ",", "'to_json'", ")", "key_an...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.field_from_json
Convert a JSON-serializable representation back to a field.
drf_cached_instances/cache.py
def field_from_json(self, key_and_type, json_value): """Convert a JSON-serializable representation back to a field.""" assert ':' in key_and_type key, type_code = key_and_type.split(':', 1) from_json = self.field_function(type_code, 'from_json') value = from_json(json_value) ...
def field_from_json(self, key_and_type, json_value): """Convert a JSON-serializable representation back to a field.""" assert ':' in key_and_type key, type_code = key_and_type.split(':', 1) from_json = self.field_function(type_code, 'from_json') value = from_json(json_value) ...
[ "Convert", "a", "JSON", "-", "serializable", "representation", "back", "to", "a", "field", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L78-L84
[ "def", "field_from_json", "(", "self", ",", "key_and_type", ",", "json_value", ")", ":", "assert", "':'", "in", "key_and_type", "key", ",", "type_code", "=", "key_and_type", ".", "split", "(", "':'", ",", "1", ")", "from_json", "=", "self", ".", "field_fun...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.get_instances
Get the cached native representation for one or more objects. Keyword arguments: object_specs - A sequence of triples (model name, pk, obj): - model name - the name of the model - pk - the primary key of the instance - obj - the instance, or None to load it version - The...
drf_cached_instances/cache.py
def get_instances(self, object_specs, version=None): """Get the cached native representation for one or more objects. Keyword arguments: object_specs - A sequence of triples (model name, pk, obj): - model name - the name of the model - pk - the primary key of the instance ...
def get_instances(self, object_specs, version=None): """Get the cached native representation for one or more objects. Keyword arguments: object_specs - A sequence of triples (model name, pk, obj): - model name - the name of the model - pk - the primary key of the instance ...
[ "Get", "the", "cached", "native", "representation", "for", "one", "or", "more", "objects", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L86-L157
[ "def", "get_instances", "(", "self", ",", "object_specs", ",", "version", "=", "None", ")", ":", "ret", "=", "dict", "(", ")", "spec_keys", "=", "set", "(", ")", "cache_keys", "=", "[", "]", "version", "=", "version", "or", "self", ".", "default_versio...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.update_instance
Create or update a cached instance. Keyword arguments are: model_name - The name of the model pk - The primary key of the instance instance - The Django model instance, or None to load it versions - Version to update, or None for all update_only - If False (default), the...
drf_cached_instances/cache.py
def update_instance( self, model_name, pk, instance=None, version=None, update_only=False): """Create or update a cached instance. Keyword arguments are: model_name - The name of the model pk - The primary key of the instance instance - The Django model i...
def update_instance( self, model_name, pk, instance=None, version=None, update_only=False): """Create or update a cached instance. Keyword arguments are: model_name - The name of the model pk - The primary key of the instance instance - The Django model i...
[ "Create", "or", "update", "a", "cached", "instance", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L159-L228
[ "def", "update_instance", "(", "self", ",", "model_name", ",", "pk", ",", "instance", "=", "None", ",", "version", "=", "None", ",", "update_only", "=", "False", ")", ":", "versions", "=", "[", "version", "]", "if", "version", "else", "self", ".", "ver...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.field_date_to_json
Convert a date to a date triple.
drf_cached_instances/cache.py
def field_date_to_json(self, day): """Convert a date to a date triple.""" if isinstance(day, six.string_types): day = parse_date(day) return [day.year, day.month, day.day] if day else None
def field_date_to_json(self, day): """Convert a date to a date triple.""" if isinstance(day, six.string_types): day = parse_date(day) return [day.year, day.month, day.day] if day else None
[ "Convert", "a", "date", "to", "a", "date", "triple", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L238-L242
[ "def", "field_date_to_json", "(", "self", ",", "day", ")", ":", "if", "isinstance", "(", "day", ",", "six", ".", "string_types", ")", ":", "day", "=", "parse_date", "(", "day", ")", "return", "[", "day", ".", "year", ",", "day", ".", "month", ",", ...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.field_datetime_from_json
Convert a UTC timestamp to a UTC datetime.
drf_cached_instances/cache.py
def field_datetime_from_json(self, json_val): """Convert a UTC timestamp to a UTC datetime.""" if type(json_val) == int: seconds = int(json_val) dt = datetime.fromtimestamp(seconds, utc) elif json_val is None: dt = None else: seconds, micro...
def field_datetime_from_json(self, json_val): """Convert a UTC timestamp to a UTC datetime.""" if type(json_val) == int: seconds = int(json_val) dt = datetime.fromtimestamp(seconds, utc) elif json_val is None: dt = None else: seconds, micro...
[ "Convert", "a", "UTC", "timestamp", "to", "a", "UTC", "datetime", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L244-L255
[ "def", "field_datetime_from_json", "(", "self", ",", "json_val", ")", ":", "if", "type", "(", "json_val", ")", "==", "int", ":", "seconds", "=", "int", "(", "json_val", ")", "dt", "=", "datetime", ".", "fromtimestamp", "(", "seconds", ",", "utc", ")", ...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.field_datetime_to_json
Convert a datetime to a UTC timestamp w/ microsecond resolution. datetimes w/o timezone will be assumed to be in UTC
drf_cached_instances/cache.py
def field_datetime_to_json(self, dt): """Convert a datetime to a UTC timestamp w/ microsecond resolution. datetimes w/o timezone will be assumed to be in UTC """ if isinstance(dt, six.string_types): dt = parse_datetime(dt) if not dt: return None t...
def field_datetime_to_json(self, dt): """Convert a datetime to a UTC timestamp w/ microsecond resolution. datetimes w/o timezone will be assumed to be in UTC """ if isinstance(dt, six.string_types): dt = parse_datetime(dt) if not dt: return None t...
[ "Convert", "a", "datetime", "to", "a", "UTC", "timestamp", "w", "/", "microsecond", "resolution", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L257-L270
[ "def", "field_datetime_to_json", "(", "self", ",", "dt", ")", ":", "if", "isinstance", "(", "dt", ",", "six", ".", "string_types", ")", ":", "dt", "=", "parse_datetime", "(", "dt", ")", "if", "not", "dt", ":", "return", "None", "ts", "=", "timegm", "...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.field_timedelta_from_json
Convert json_val to a timedelta object. json_val contains total number of seconds in the timedelta. If json_val is a string it will be converted to a float.
drf_cached_instances/cache.py
def field_timedelta_from_json(self, json_val): """Convert json_val to a timedelta object. json_val contains total number of seconds in the timedelta. If json_val is a string it will be converted to a float. """ if isinstance(json_val, str): return timedelta(seconds=f...
def field_timedelta_from_json(self, json_val): """Convert json_val to a timedelta object. json_val contains total number of seconds in the timedelta. If json_val is a string it will be converted to a float. """ if isinstance(json_val, str): return timedelta(seconds=f...
[ "Convert", "json_val", "to", "a", "timedelta", "object", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L272-L283
[ "def", "field_timedelta_from_json", "(", "self", ",", "json_val", ")", ":", "if", "isinstance", "(", "json_val", ",", "str", ")", ":", "return", "timedelta", "(", "seconds", "=", "float", "(", "json_val", ")", ")", "elif", "json_val", "is", "None", ":", ...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.field_timedelta_to_json
Convert timedelta to value containing total number of seconds. If there are fractions of a second the return value will be a string, otherwise it will be an int.
drf_cached_instances/cache.py
def field_timedelta_to_json(self, td): """Convert timedelta to value containing total number of seconds. If there are fractions of a second the return value will be a string, otherwise it will be an int. """ if isinstance(td, six.string_types): td = parse_duration(td...
def field_timedelta_to_json(self, td): """Convert timedelta to value containing total number of seconds. If there are fractions of a second the return value will be a string, otherwise it will be an int. """ if isinstance(td, six.string_types): td = parse_duration(td...
[ "Convert", "timedelta", "to", "value", "containing", "total", "number", "of", "seconds", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L285-L298
[ "def", "field_timedelta_to_json", "(", "self", ",", "td", ")", ":", "if", "isinstance", "(", "td", ",", "six", ".", "string_types", ")", ":", "td", "=", "parse_duration", "(", "td", ")", "if", "not", "td", ":", "return", "None", "if", "td", ".", "mic...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.field_pklist_from_json
Load a PkOnlyQueryset from a JSON dict. This uses the same format as cached_queryset_from_json
drf_cached_instances/cache.py
def field_pklist_from_json(self, data): """Load a PkOnlyQueryset from a JSON dict. This uses the same format as cached_queryset_from_json """ model = get_model(data['app'], data['model']) return PkOnlyQueryset(self, model, data['pks'])
def field_pklist_from_json(self, data): """Load a PkOnlyQueryset from a JSON dict. This uses the same format as cached_queryset_from_json """ model = get_model(data['app'], data['model']) return PkOnlyQueryset(self, model, data['pks'])
[ "Load", "a", "PkOnlyQueryset", "from", "a", "JSON", "dict", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L300-L306
[ "def", "field_pklist_from_json", "(", "self", ",", "data", ")", ":", "model", "=", "get_model", "(", "data", "[", "'app'", "]", ",", "data", "[", "'model'", "]", ")", "return", "PkOnlyQueryset", "(", "self", ",", "model", ",", "data", "[", "'pks'", "]"...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.field_pklist_to_json
Convert a list of primary keys to a JSON dict. This uses the same format as cached_queryset_to_json
drf_cached_instances/cache.py
def field_pklist_to_json(self, model, pks): """Convert a list of primary keys to a JSON dict. This uses the same format as cached_queryset_to_json """ app_label = model._meta.app_label model_name = model._meta.model_name return { 'app': app_label, ...
def field_pklist_to_json(self, model, pks): """Convert a list of primary keys to a JSON dict. This uses the same format as cached_queryset_to_json """ app_label = model._meta.app_label model_name = model._meta.model_name return { 'app': app_label, ...
[ "Convert", "a", "list", "of", "primary", "keys", "to", "a", "JSON", "dict", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L308-L319
[ "def", "field_pklist_to_json", "(", "self", ",", "model", ",", "pks", ")", ":", "app_label", "=", "model", ".", "_meta", ".", "app_label", "model_name", "=", "model", ".", "_meta", ".", "model_name", "return", "{", "'app'", ":", "app_label", ",", "'model'"...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.field_pk_from_json
Load a PkOnlyModel from a JSON dict.
drf_cached_instances/cache.py
def field_pk_from_json(self, data): """Load a PkOnlyModel from a JSON dict.""" model = get_model(data['app'], data['model']) return PkOnlyModel(self, model, data['pk'])
def field_pk_from_json(self, data): """Load a PkOnlyModel from a JSON dict.""" model = get_model(data['app'], data['model']) return PkOnlyModel(self, model, data['pk'])
[ "Load", "a", "PkOnlyModel", "from", "a", "JSON", "dict", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L321-L324
[ "def", "field_pk_from_json", "(", "self", ",", "data", ")", ":", "model", "=", "get_model", "(", "data", "[", "'app'", "]", ",", "data", "[", "'model'", "]", ")", "return", "PkOnlyModel", "(", "self", ",", "model", ",", "data", "[", "'pk'", "]", ")" ...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
BaseCache.field_pk_to_json
Convert a primary key to a JSON dict.
drf_cached_instances/cache.py
def field_pk_to_json(self, model, pk): """Convert a primary key to a JSON dict.""" app_label = model._meta.app_label model_name = model._meta.model_name return { 'app': app_label, 'model': model_name, 'pk': pk, }
def field_pk_to_json(self, model, pk): """Convert a primary key to a JSON dict.""" app_label = model._meta.app_label model_name = model._meta.model_name return { 'app': app_label, 'model': model_name, 'pk': pk, }
[ "Convert", "a", "primary", "key", "to", "a", "JSON", "dict", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L326-L334
[ "def", "field_pk_to_json", "(", "self", ",", "model", ",", "pk", ")", ":", "app_label", "=", "model", ".", "_meta", ".", "app_label", "model_name", "=", "model", ".", "_meta", ".", "model_name", "return", "{", "'app'", ":", "app_label", ",", "'model'", "...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
choice_voters_changed_update_cache
Update cache when choice.voters changes.
sample_poll_app/models.py
def choice_voters_changed_update_cache( sender, instance, action, reverse, model, pk_set, **kwargs): """Update cache when choice.voters changes.""" if action not in ('post_add', 'post_remove', 'post_clear'): # post_clear is not handled, because clear is called in # django.db.models.field...
def choice_voters_changed_update_cache( sender, instance, action, reverse, model, pk_set, **kwargs): """Update cache when choice.voters changes.""" if action not in ('post_add', 'post_remove', 'post_clear'): # post_clear is not handled, because clear is called in # django.db.models.field...
[ "Update", "cache", "when", "choice", ".", "voters", "changes", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/models.py#L33-L60
[ "def", "choice_voters_changed_update_cache", "(", "sender", ",", "instance", ",", "action", ",", "reverse", ",", "model", ",", "pk_set", ",", "*", "*", "kwargs", ")", ":", "if", "action", "not", "in", "(", "'post_add'", ",", "'post_remove'", ",", "'post_clea...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
post_delete_update_cache
Update the cache when an instance is deleted.
sample_poll_app/models.py
def post_delete_update_cache(sender, instance, **kwargs): """Update the cache when an instance is deleted.""" name = sender.__name__ if name in cached_model_names: from .tasks import update_cache_for_instance update_cache_for_instance(name, instance.pk, instance)
def post_delete_update_cache(sender, instance, **kwargs): """Update the cache when an instance is deleted.""" name = sender.__name__ if name in cached_model_names: from .tasks import update_cache_for_instance update_cache_for_instance(name, instance.pk, instance)
[ "Update", "the", "cache", "when", "an", "instance", "is", "deleted", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/models.py#L64-L69
[ "def", "post_delete_update_cache", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "name", "=", "sender", ".", "__name__", "if", "name", "in", "cached_model_names", ":", "from", ".", "tasks", "import", "update_cache_for_instance", "update_cach...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
post_save_update_cache
Update the cache when an instance is created or modified.
sample_poll_app/models.py
def post_save_update_cache(sender, instance, created, raw, **kwargs): """Update the cache when an instance is created or modified.""" if raw: return name = sender.__name__ if name in cached_model_names: delay_cache = getattr(instance, '_delay_cache', False) if not delay_cache: ...
def post_save_update_cache(sender, instance, created, raw, **kwargs): """Update the cache when an instance is created or modified.""" if raw: return name = sender.__name__ if name in cached_model_names: delay_cache = getattr(instance, '_delay_cache', False) if not delay_cache: ...
[ "Update", "the", "cache", "when", "an", "instance", "is", "created", "or", "modified", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/models.py#L73-L82
[ "def", "post_save_update_cache", "(", "sender", ",", "instance", ",", "created", ",", "raw", ",", "*", "*", "kwargs", ")", ":", "if", "raw", ":", "return", "name", "=", "sender", ".", "__name__", "if", "name", "in", "cached_model_names", ":", "delay_cache"...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
CachedViewMixin.get_queryset
Get the queryset for the action. If action is read action, return a CachedQueryset Otherwise, return a Django queryset
drf_cached_instances/mixins.py
def get_queryset(self): """Get the queryset for the action. If action is read action, return a CachedQueryset Otherwise, return a Django queryset """ queryset = super(CachedViewMixin, self).get_queryset() if self.action in ('list', 'retrieve'): return CachedQ...
def get_queryset(self): """Get the queryset for the action. If action is read action, return a CachedQueryset Otherwise, return a Django queryset """ queryset = super(CachedViewMixin, self).get_queryset() if self.action in ('list', 'retrieve'): return CachedQ...
[ "Get", "the", "queryset", "for", "the", "action", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/mixins.py#L17-L27
[ "def", "get_queryset", "(", "self", ")", ":", "queryset", "=", "super", "(", "CachedViewMixin", ",", "self", ")", ".", "get_queryset", "(", ")", "if", "self", ".", "action", "in", "(", "'list'", ",", "'retrieve'", ")", ":", "return", "CachedQueryset", "(...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
CachedViewMixin.get_object
Return the object the view is displaying. Same as rest_framework.generics.GenericAPIView, but: - Failed assertions instead of deprecations
drf_cached_instances/mixins.py
def get_object(self, queryset=None): """ Return the object the view is displaying. Same as rest_framework.generics.GenericAPIView, but: - Failed assertions instead of deprecations """ # Determine the base queryset to use. assert queryset is None, "Passing a query...
def get_object(self, queryset=None): """ Return the object the view is displaying. Same as rest_framework.generics.GenericAPIView, but: - Failed assertions instead of deprecations """ # Determine the base queryset to use. assert queryset is None, "Passing a query...
[ "Return", "the", "object", "the", "view", "is", "displaying", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/mixins.py#L33-L54
[ "def", "get_object", "(", "self", ",", "queryset", "=", "None", ")", ":", "# Determine the base queryset to use.", "assert", "queryset", "is", "None", ",", "\"Passing a queryset is disabled\"", "queryset", "=", "self", ".", "filter_queryset", "(", "self", ".", "get_...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
CachedViewMixin.get_object_or_404
Return an object or raise a 404. Same as Django's standard shortcut, but make sure to raise 404 if the filter_kwargs don't match the required types.
drf_cached_instances/mixins.py
def get_object_or_404(self, queryset, *filter_args, **filter_kwargs): """Return an object or raise a 404. Same as Django's standard shortcut, but make sure to raise 404 if the filter_kwargs don't match the required types. """ if isinstance(queryset, CachedQueryset): ...
def get_object_or_404(self, queryset, *filter_args, **filter_kwargs): """Return an object or raise a 404. Same as Django's standard shortcut, but make sure to raise 404 if the filter_kwargs don't match the required types. """ if isinstance(queryset, CachedQueryset): ...
[ "Return", "an", "object", "or", "raise", "a", "404", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/mixins.py#L56-L69
[ "def", "get_object_or_404", "(", "self", ",", "queryset", ",", "*", "filter_args", ",", "*", "*", "filter_kwargs", ")", ":", "if", "isinstance", "(", "queryset", ",", "CachedQueryset", ")", ":", "try", ":", "return", "queryset", ".", "get", "(", "*", "fi...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
Empty.r
Resolve the object. This returns default (if present) or fails on an Empty.
jsane/traversable.py
def r(self, **kwargs): """ Resolve the object. This returns default (if present) or fails on an Empty. """ # by using kwargs we ensure that usage of positional arguments, as if # this object were another kind of function, will fail-fast and raise # a TypeError ...
def r(self, **kwargs): """ Resolve the object. This returns default (if present) or fails on an Empty. """ # by using kwargs we ensure that usage of positional arguments, as if # this object were another kind of function, will fail-fast and raise # a TypeError ...
[ "Resolve", "the", "object", "." ]
skorokithakis/jsane
python
https://github.com/skorokithakis/jsane/blob/f63c01ab50899e207dae8427e4faef0e9d35e41e/jsane/traversable.py#L35-L54
[ "def", "r", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# by using kwargs we ensure that usage of positional arguments, as if", "# this object were another kind of function, will fail-fast and raise", "# a TypeError", "if", "'default'", "in", "kwargs", ":", "default", "=",...
f63c01ab50899e207dae8427e4faef0e9d35e41e
train
Traversable.r
Resolve the object. This will always succeed, since, if a lookup fails, an Empty instance will be returned farther upstream.
jsane/traversable.py
def r(self, **kwargs): """ Resolve the object. This will always succeed, since, if a lookup fails, an Empty instance will be returned farther upstream. """ # by using kwargs we ensure that usage of positional arguments, as if # this object were another kind of fu...
def r(self, **kwargs): """ Resolve the object. This will always succeed, since, if a lookup fails, an Empty instance will be returned farther upstream. """ # by using kwargs we ensure that usage of positional arguments, as if # this object were another kind of fu...
[ "Resolve", "the", "object", "." ]
skorokithakis/jsane
python
https://github.com/skorokithakis/jsane/blob/f63c01ab50899e207dae8427e4faef0e9d35e41e/jsane/traversable.py#L125-L140
[ "def", "r", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# by using kwargs we ensure that usage of positional arguments, as if", "# this object were another kind of function, will fail-fast and raise", "# a TypeError", "kwargs", ".", "pop", "(", "'default'", ",", "None", ...
f63c01ab50899e207dae8427e4faef0e9d35e41e
train
update_cache_for_instance
Update the cache for an instance, with cascading updates.
sample_poll_app/tasks.py
def update_cache_for_instance( model_name, instance_pk, instance=None, version=None): """Update the cache for an instance, with cascading updates.""" cache = SampleCache() invalid = cache.update_instance(model_name, instance_pk, instance, version) for invalid_name, invalid_pk, invalid_version in...
def update_cache_for_instance( model_name, instance_pk, instance=None, version=None): """Update the cache for an instance, with cascading updates.""" cache = SampleCache() invalid = cache.update_instance(model_name, instance_pk, instance, version) for invalid_name, invalid_pk, invalid_version in...
[ "Update", "the", "cache", "for", "an", "instance", "with", "cascading", "updates", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/tasks.py#L8-L15
[ "def", "update_cache_for_instance", "(", "model_name", ",", "instance_pk", ",", "instance", "=", "None", ",", "version", "=", "None", ")", ":", "cache", "=", "SampleCache", "(", ")", "invalid", "=", "cache", ".", "update_instance", "(", "model_name", ",", "i...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
PkOnlyQueryset.values_list
Return the primary keys as a list. The only valid call is values_list('pk', flat=True)
drf_cached_instances/models.py
def values_list(self, *args, **kwargs): """Return the primary keys as a list. The only valid call is values_list('pk', flat=True) """ flat = kwargs.pop('flat', False) assert flat is True assert len(args) == 1 assert args[0] == self.model._meta.pk.name ret...
def values_list(self, *args, **kwargs): """Return the primary keys as a list. The only valid call is values_list('pk', flat=True) """ flat = kwargs.pop('flat', False) assert flat is True assert len(args) == 1 assert args[0] == self.model._meta.pk.name ret...
[ "Return", "the", "primary", "keys", "as", "a", "list", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/models.py#L46-L55
[ "def", "values_list", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "flat", "=", "kwargs", ".", "pop", "(", "'flat'", ",", "False", ")", "assert", "flat", "is", "True", "assert", "len", "(", "args", ")", "==", "1", "assert", "...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
CachedQueryset.pks
Lazy-load the primary keys.
drf_cached_instances/models.py
def pks(self): """Lazy-load the primary keys.""" if self._primary_keys is None: self._primary_keys = list( self.queryset.values_list('pk', flat=True)) return self._primary_keys
def pks(self): """Lazy-load the primary keys.""" if self._primary_keys is None: self._primary_keys = list( self.queryset.values_list('pk', flat=True)) return self._primary_keys
[ "Lazy", "-", "load", "the", "primary", "keys", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/models.py#L95-L100
[ "def", "pks", "(", "self", ")", ":", "if", "self", ".", "_primary_keys", "is", "None", ":", "self", ".", "_primary_keys", "=", "list", "(", "self", ".", "queryset", ".", "values_list", "(", "'pk'", ",", "flat", "=", "True", ")", ")", "return", "self"...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
CachedQueryset.count
Return a count of instances.
drf_cached_instances/models.py
def count(self): """Return a count of instances.""" if self._primary_keys is None: return self.queryset.count() else: return len(self.pks)
def count(self): """Return a count of instances.""" if self._primary_keys is None: return self.queryset.count() else: return len(self.pks)
[ "Return", "a", "count", "of", "instances", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/models.py#L119-L124
[ "def", "count", "(", "self", ")", ":", "if", "self", ".", "_primary_keys", "is", "None", ":", "return", "self", ".", "queryset", ".", "count", "(", ")", "else", ":", "return", "len", "(", "self", ".", "pks", ")" ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
CachedQueryset.filter
Filter the base queryset.
drf_cached_instances/models.py
def filter(self, **kwargs): """Filter the base queryset.""" assert not self._primary_keys self.queryset = self.queryset.filter(**kwargs) return self
def filter(self, **kwargs): """Filter the base queryset.""" assert not self._primary_keys self.queryset = self.queryset.filter(**kwargs) return self
[ "Filter", "the", "base", "queryset", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/models.py#L126-L130
[ "def", "filter", "(", "self", ",", "*", "*", "kwargs", ")", ":", "assert", "not", "self", ".", "_primary_keys", "self", ".", "queryset", "=", "self", ".", "queryset", ".", "filter", "(", "*", "*", "kwargs", ")", "return", "self" ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
CachedQueryset.get
Return the single item from the filtered queryset.
drf_cached_instances/models.py
def get(self, *args, **kwargs): """Return the single item from the filtered queryset.""" assert not args assert list(kwargs.keys()) == ['pk'] pk = kwargs['pk'] model_name = self.model.__name__ object_spec = (model_name, pk, None) instances = self.cache.get_instanc...
def get(self, *args, **kwargs): """Return the single item from the filtered queryset.""" assert not args assert list(kwargs.keys()) == ['pk'] pk = kwargs['pk'] model_name = self.model.__name__ object_spec = (model_name, pk, None) instances = self.cache.get_instanc...
[ "Return", "the", "single", "item", "from", "the", "filtered", "queryset", "." ]
jwhitlock/drf-cached-instances
python
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/models.py#L132-L147
[ "def", "get", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "assert", "not", "args", "assert", "list", "(", "kwargs", ".", "keys", "(", ")", ")", "==", "[", "'pk'", "]", "pk", "=", "kwargs", "[", "'pk'", "]", "model_name", "...
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
train
WebpackConstants.collect
Load all constant generators from settings.WEBPACK_CONSTANT_PROCESSORS and concat their values.
tg_react/webpack.py
def collect(cls): """ Load all constant generators from settings.WEBPACK_CONSTANT_PROCESSORS and concat their values. """ constants = {} for method_path in WebpackConstants.get_constant_processors(): method = import_string(method_path) if not callabl...
def collect(cls): """ Load all constant generators from settings.WEBPACK_CONSTANT_PROCESSORS and concat their values. """ constants = {} for method_path in WebpackConstants.get_constant_processors(): method = import_string(method_path) if not callabl...
[ "Load", "all", "constant", "generators", "from", "settings", ".", "WEBPACK_CONSTANT_PROCESSORS", "and", "concat", "their", "values", "." ]
thorgate/tg-react
python
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/webpack.py#L23-L40
[ "def", "collect", "(", "cls", ")", ":", "constants", "=", "{", "}", "for", "method_path", "in", "WebpackConstants", ".", "get_constant_processors", "(", ")", ":", "method", "=", "import_string", "(", "method_path", ")", "if", "not", "callable", "(", "method"...
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
train
phonenumber_validation
Validates phonenumber Similar to phonenumber_field.validators.validate_international_phonenumber() but uses a different message if the country prefix is absent.
tg_react/api/accounts/serializers.py
def phonenumber_validation(data): """ Validates phonenumber Similar to phonenumber_field.validators.validate_international_phonenumber() but uses a different message if the country prefix is absent. """ from phonenumber_field.phonenumber import to_python phone_number = to_python(data) if no...
def phonenumber_validation(data): """ Validates phonenumber Similar to phonenumber_field.validators.validate_international_phonenumber() but uses a different message if the country prefix is absent. """ from phonenumber_field.phonenumber import to_python phone_number = to_python(data) if no...
[ "Validates", "phonenumber" ]
thorgate/tg-react
python
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/api/accounts/serializers.py#L98-L113
[ "def", "phonenumber_validation", "(", "data", ")", ":", "from", "phonenumber_field", ".", "phonenumber", "import", "to_python", "phone_number", "=", "to_python", "(", "data", ")", "if", "not", "phone_number", ":", "return", "data", "elif", "not", "phone_number", ...
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
train
DjangoLocaleData.get_catalog
Create Django translation catalogue for `locale`.
tg_react/language.py
def get_catalog(self, locale): """Create Django translation catalogue for `locale`.""" with translation.override(locale): translation_engine = DjangoTranslation(locale, domain=self.domain, localedirs=self.paths) trans_cat = translation_engine._catalog trans_fallback_...
def get_catalog(self, locale): """Create Django translation catalogue for `locale`.""" with translation.override(locale): translation_engine = DjangoTranslation(locale, domain=self.domain, localedirs=self.paths) trans_cat = translation_engine._catalog trans_fallback_...
[ "Create", "Django", "translation", "catalogue", "for", "locale", "." ]
thorgate/tg-react
python
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L28-L36
[ "def", "get_catalog", "(", "self", ",", "locale", ")", ":", "with", "translation", ".", "override", "(", "locale", ")", ":", "translation_engine", "=", "DjangoTranslation", "(", "locale", ",", "domain", "=", "self", ".", "domain", ",", "localedirs", "=", "...
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
train
DjangoLocaleData.get_paths
Create list of matching packages for translation engine.
tg_react/language.py
def get_paths(cls, packages): """Create list of matching packages for translation engine.""" allowable_packages = dict((app_config.name, app_config) for app_config in apps.get_app_configs()) app_configs = [allowable_packages[p] for p in packages if p in allowable_packages] # paths of req...
def get_paths(cls, packages): """Create list of matching packages for translation engine.""" allowable_packages = dict((app_config.name, app_config) for app_config in apps.get_app_configs()) app_configs = [allowable_packages[p] for p in packages if p in allowable_packages] # paths of req...
[ "Create", "list", "of", "matching", "packages", "for", "translation", "engine", "." ]
thorgate/tg-react
python
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L39-L44
[ "def", "get_paths", "(", "cls", ",", "packages", ")", ":", "allowable_packages", "=", "dict", "(", "(", "app_config", ".", "name", ",", "app_config", ")", "for", "app_config", "in", "apps", ".", "get_app_configs", "(", ")", ")", "app_configs", "=", "[", ...
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
train
DjangoLocaleData.get_catalogue_header_value
Get `.po` header value.
tg_react/language.py
def get_catalogue_header_value(cls, catalog, key): """Get `.po` header value.""" header_value = None if '' in catalog: for line in catalog[''].split('\n'): if line.startswith('%s:' % key): header_value = line.split(':', 1)[1].strip() retur...
def get_catalogue_header_value(cls, catalog, key): """Get `.po` header value.""" header_value = None if '' in catalog: for line in catalog[''].split('\n'): if line.startswith('%s:' % key): header_value = line.split(':', 1)[1].strip() retur...
[ "Get", ".", "po", "header", "value", "." ]
thorgate/tg-react
python
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L47-L55
[ "def", "get_catalogue_header_value", "(", "cls", ",", "catalog", ",", "key", ")", ":", "header_value", "=", "None", "if", "''", "in", "catalog", ":", "for", "line", "in", "catalog", "[", "''", "]", ".", "split", "(", "'\\n'", ")", ":", "if", "line", ...
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
train
DjangoLocaleData._num_plurals
Return the number of plurals for this catalog language, or 2 if no plural string is available.
tg_react/language.py
def _num_plurals(self, catalogue): """ Return the number of plurals for this catalog language, or 2 if no plural string is available. """ match = re.search(r'nplurals=\s*(\d+)', self.get_plural(catalogue) or '') if match: return int(match.groups()[0]) ...
def _num_plurals(self, catalogue): """ Return the number of plurals for this catalog language, or 2 if no plural string is available. """ match = re.search(r'nplurals=\s*(\d+)', self.get_plural(catalogue) or '') if match: return int(match.groups()[0]) ...
[ "Return", "the", "number", "of", "plurals", "for", "this", "catalog", "language", "or", "2", "if", "no", "plural", "string", "is", "available", "." ]
thorgate/tg-react
python
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L57-L65
[ "def", "_num_plurals", "(", "self", ",", "catalogue", ")", ":", "match", "=", "re", ".", "search", "(", "r'nplurals=\\s*(\\d+)'", ",", "self", ".", "get_plural", "(", "catalogue", ")", "or", "''", ")", "if", "match", ":", "return", "int", "(", "match", ...
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
train
DjangoLocaleData.make_header
Populate header with correct data from top-most locale file.
tg_react/language.py
def make_header(self, locale, catalog): """Populate header with correct data from top-most locale file.""" return { "po-revision-date": self.get_catalogue_header_value(catalog, 'PO-Revision-Date'), "mime-version": self.get_catalogue_header_value(catalog, 'MIME-Version'), ...
def make_header(self, locale, catalog): """Populate header with correct data from top-most locale file.""" return { "po-revision-date": self.get_catalogue_header_value(catalog, 'PO-Revision-Date'), "mime-version": self.get_catalogue_header_value(catalog, 'MIME-Version'), ...
[ "Populate", "header", "with", "correct", "data", "from", "top", "-", "most", "locale", "file", "." ]
thorgate/tg-react
python
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L72-L89
[ "def", "make_header", "(", "self", ",", "locale", ",", "catalog", ")", ":", "return", "{", "\"po-revision-date\"", ":", "self", ".", "get_catalogue_header_value", "(", "catalog", ",", "'PO-Revision-Date'", ")", ",", "\"mime-version\"", ":", "self", ".", "get_cat...
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
train
DjangoLocaleData.collect_translations
Collect all `domain` translations and return `Tuple[languages, locale_data]`
tg_react/language.py
def collect_translations(self): """Collect all `domain` translations and return `Tuple[languages, locale_data]`""" languages = {} locale_data = {} for language_code, label in settings.LANGUAGES: languages[language_code] = '%s' % label # Create django translation...
def collect_translations(self): """Collect all `domain` translations and return `Tuple[languages, locale_data]`""" languages = {} locale_data = {} for language_code, label in settings.LANGUAGES: languages[language_code] = '%s' % label # Create django translation...
[ "Collect", "all", "domain", "translations", "and", "return", "Tuple", "[", "languages", "locale_data", "]" ]
thorgate/tg-react
python
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L91-L132
[ "def", "collect_translations", "(", "self", ")", ":", "languages", "=", "{", "}", "locale_data", "=", "{", "}", "for", "language_code", ",", "label", "in", "settings", ".", "LANGUAGES", ":", "languages", "[", "language_code", "]", "=", "'%s'", "%", "label"...
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
train
get_endpoint_obj
Tiny helper function that gets used all over the place to join the object ID to the endpoint and run a GET request, returning the result
wunderpy2/endpoint_helpers.py
def get_endpoint_obj(client, endpoint, object_id): ''' Tiny helper function that gets used all over the place to join the object ID to the endpoint and run a GET request, returning the result ''' endpoint = '/'.join([endpoint, str(object_id)]) return client.authenticated_request(endpoint).json()
def get_endpoint_obj(client, endpoint, object_id): ''' Tiny helper function that gets used all over the place to join the object ID to the endpoint and run a GET request, returning the result ''' endpoint = '/'.join([endpoint, str(object_id)]) return client.authenticated_request(endpoint).json()
[ "Tiny", "helper", "function", "that", "gets", "used", "all", "over", "the", "place", "to", "join", "the", "object", "ID", "to", "the", "endpoint", "and", "run", "a", "GET", "request", "returning", "the", "result" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/endpoint_helpers.py#L1-L4
[ "def", "get_endpoint_obj", "(", "client", ",", "endpoint", ",", "object_id", ")", ":", "endpoint", "=", "'/'", ".", "join", "(", "[", "endpoint", ",", "str", "(", "object_id", ")", "]", ")", "return", "client", ".", "authenticated_request", "(", "endpoint"...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
update_endpoint_obj
Helper method to ease the repetitiveness of updating an... SO VERY DRY (That's a doubly-effective pun becuase my predecessor - https://github.com/bsmt/wunderpy - found maintaing a Python Wunderlist API to be "as tedious and boring as a liberal arts school poetry slam")
wunderpy2/endpoint_helpers.py
def update_endpoint_obj(client, endpoint, object_id, revision, data): ''' Helper method to ease the repetitiveness of updating an... SO VERY DRY (That's a doubly-effective pun becuase my predecessor - https://github.com/bsmt/wunderpy - found maintaing a Python Wunderlist API to be "as tedious and bor...
def update_endpoint_obj(client, endpoint, object_id, revision, data): ''' Helper method to ease the repetitiveness of updating an... SO VERY DRY (That's a doubly-effective pun becuase my predecessor - https://github.com/bsmt/wunderpy - found maintaing a Python Wunderlist API to be "as tedious and bor...
[ "Helper", "method", "to", "ease", "the", "repetitiveness", "of", "updating", "an", "...", "SO", "VERY", "DRY", "(", "That", "s", "a", "doubly", "-", "effective", "pun", "becuase", "my", "predecessor", "-", "https", ":", "//", "github", ".", "com", "/", ...
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/endpoint_helpers.py#L6-L14
[ "def", "update_endpoint_obj", "(", "client", ",", "endpoint", ",", "object_id", ",", "revision", ",", "data", ")", ":", "data", "[", "'revision'", "]", "=", "int", "(", "revision", ")", "endpoint", "=", "'/'", ".", "join", "(", "[", "endpoint", ",", "s...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderApi._validate_response
Helper method to validate the given to a Wunderlist API request is as expected
wunderpy2/wunderapi.py
def _validate_response(self, method, response): ''' Helper method to validate the given to a Wunderlist API request is as expected ''' # TODO Fill this out using the error codes here: https://developer.wunderlist.com/documentation/concepts/formats # The expected results can change based on API v...
def _validate_response(self, method, response): ''' Helper method to validate the given to a Wunderlist API request is as expected ''' # TODO Fill this out using the error codes here: https://developer.wunderlist.com/documentation/concepts/formats # The expected results can change based on API v...
[ "Helper", "method", "to", "validate", "the", "given", "to", "a", "Wunderlist", "API", "request", "is", "as", "expected" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderapi.py#L34-L48
[ "def", "_validate_response", "(", "self", ",", "method", ",", "response", ")", ":", "# TODO Fill this out using the error codes here: https://developer.wunderlist.com/documentation/concepts/formats", "# The expected results can change based on API version, so validate this here", "if", "se...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderApi.request
Send a request to the given Wunderlist API endpoint Params: endpoint -- API endpoint to send request to Keyword Args: headers -- headers to add to the request method -- GET, PUT, PATCH, DELETE, etc. params -- parameters to encode in the request data -- data to s...
wunderpy2/wunderapi.py
def request(self, endpoint, method='GET', headers=None, params=None, data=None): ''' Send a request to the given Wunderlist API endpoint Params: endpoint -- API endpoint to send request to Keyword Args: headers -- headers to add to the request method -- GET, PUT...
def request(self, endpoint, method='GET', headers=None, params=None, data=None): ''' Send a request to the given Wunderlist API endpoint Params: endpoint -- API endpoint to send request to Keyword Args: headers -- headers to add to the request method -- GET, PUT...
[ "Send", "a", "request", "to", "the", "given", "Wunderlist", "API", "endpoint" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderapi.py#L50-L77
[ "def", "request", "(", "self", ",", "endpoint", ",", "method", "=", "'GET'", ",", "headers", "=", "None", ",", "params", "=", "None", ",", "data", "=", "None", ")", ":", "if", "not", "headers", ":", "headers", "=", "{", "}", "if", "method", "in", ...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderApi.get_access_token
Exchange a temporary code for an access token allowing access to a user's account See https://developer.wunderlist.com/documentation/concepts/authorization for more info
wunderpy2/wunderapi.py
def get_access_token(self, code, client_id, client_secret): ''' Exchange a temporary code for an access token allowing access to a user's account See https://developer.wunderlist.com/documentation/concepts/authorization for more info ''' headers = { 'Content-Typ...
def get_access_token(self, code, client_id, client_secret): ''' Exchange a temporary code for an access token allowing access to a user's account See https://developer.wunderlist.com/documentation/concepts/authorization for more info ''' headers = { 'Content-Typ...
[ "Exchange", "a", "temporary", "code", "for", "an", "access", "token", "allowing", "access", "to", "a", "user", "s", "account" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderapi.py#L79-L98
[ "def", "get_access_token", "(", "self", ",", "code", ",", "client_id", ",", "client_secret", ")", ":", "headers", "=", "{", "'Content-Type'", ":", "'application/json'", "}", "data", "=", "{", "'client_id'", ":", "client_id", ",", "'client_secret'", ":", "clien...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderClient.authenticated_request
Send a request to the given Wunderlist API with 'X-Access-Token' and 'X-Client-ID' headers and ensure the response code is as expected given the request type Params: endpoint -- API endpoint to send request to Keyword Args: method -- GET, PUT, PATCH, DELETE, etc. params -- para...
wunderpy2/wunderclient.py
def authenticated_request(self, endpoint, method='GET', params=None, data=None): ''' Send a request to the given Wunderlist API with 'X-Access-Token' and 'X-Client-ID' headers and ensure the response code is as expected given the request type Params: endpoint -- API endpoint to send req...
def authenticated_request(self, endpoint, method='GET', params=None, data=None): ''' Send a request to the given Wunderlist API with 'X-Access-Token' and 'X-Client-ID' headers and ensure the response code is as expected given the request type Params: endpoint -- API endpoint to send req...
[ "Send", "a", "request", "to", "the", "given", "Wunderlist", "API", "with", "X", "-", "Access", "-", "Token", "and", "X", "-", "Client", "-", "ID", "headers", "and", "ensure", "the", "response", "code", "is", "as", "expected", "given", "the", "request", ...
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L29-L45
[ "def", "authenticated_request", "(", "self", ",", "endpoint", ",", "method", "=", "'GET'", ",", "params", "=", "None", ",", "data", "=", "None", ")", ":", "headers", "=", "{", "'X-Access-Token'", ":", "self", ".", "access_token", ",", "'X-Client-ID'", ":",...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderClient.update_list
Updates the list with the given ID to have the given title and public flag
wunderpy2/wunderclient.py
def update_list(self, list_id, revision, title=None, public=None): ''' Updates the list with the given ID to have the given title and public flag ''' return lists_endpoint.update_list(self, list_id, revision, title=title, public=public)
def update_list(self, list_id, revision, title=None, public=None): ''' Updates the list with the given ID to have the given title and public flag ''' return lists_endpoint.update_list(self, list_id, revision, title=title, public=public)
[ "Updates", "the", "list", "with", "the", "given", "ID", "to", "have", "the", "given", "title", "and", "public", "flag" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L59-L61
[ "def", "update_list", "(", "self", ",", "list_id", ",", "revision", ",", "title", "=", "None", ",", "public", "=", "None", ")", ":", "return", "lists_endpoint", ".", "update_list", "(", "self", ",", "list_id", ",", "revision", ",", "title", "=", "title",...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderClient.get_tasks
Gets tasks for the list with the given ID, filtered by the given completion flag
wunderpy2/wunderclient.py
def get_tasks(self, list_id, completed=False): ''' Gets tasks for the list with the given ID, filtered by the given completion flag ''' return tasks_endpoint.get_tasks(self, list_id, completed=completed)
def get_tasks(self, list_id, completed=False): ''' Gets tasks for the list with the given ID, filtered by the given completion flag ''' return tasks_endpoint.get_tasks(self, list_id, completed=completed)
[ "Gets", "tasks", "for", "the", "list", "with", "the", "given", "ID", "filtered", "by", "the", "given", "completion", "flag" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L67-L69
[ "def", "get_tasks", "(", "self", ",", "list_id", ",", "completed", "=", "False", ")", ":", "return", "tasks_endpoint", ".", "get_tasks", "(", "self", ",", "list_id", ",", "completed", "=", "completed", ")" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderClient.create_task
Creates a new task with the given information in the list with the given ID
wunderpy2/wunderclient.py
def create_task(self, list_id, title, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None): ''' Creates a new task with the given information in the list with the given ID ''' return tasks_endpoint.create_task(self, list_id, title, assignee_id=assig...
def create_task(self, list_id, title, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None): ''' Creates a new task with the given information in the list with the given ID ''' return tasks_endpoint.create_task(self, list_id, title, assignee_id=assig...
[ "Creates", "a", "new", "task", "with", "the", "given", "information", "in", "the", "list", "with", "the", "given", "ID" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L75-L77
[ "def", "create_task", "(", "self", ",", "list_id", ",", "title", ",", "assignee_id", "=", "None", ",", "completed", "=", "None", ",", "recurrence_type", "=", "None", ",", "recurrence_count", "=", "None", ",", "due_date", "=", "None", ",", "starred", "=", ...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderClient.update_task
Updates the task with the given ID to have the given information NOTE: The 'remove' parameter is an optional list of parameters to remove from the given task, e.g. ['due_date']
wunderpy2/wunderclient.py
def update_task(self, task_id, revision, title=None, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None, remove=None): ''' Updates the task with the given ID to have the given information NOTE: The 'remove' parameter is an option...
def update_task(self, task_id, revision, title=None, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None, remove=None): ''' Updates the task with the given ID to have the given information NOTE: The 'remove' parameter is an option...
[ "Updates", "the", "task", "with", "the", "given", "ID", "to", "have", "the", "given", "information", "NOTE", ":", "The", "remove", "parameter", "is", "an", "optional", "list", "of", "parameters", "to", "remove", "from", "the", "given", "task", "e", ".", ...
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L79-L85
[ "def", "update_task", "(", "self", ",", "task_id", ",", "revision", ",", "title", "=", "None", ",", "assignee_id", "=", "None", ",", "completed", "=", "None", ",", "recurrence_type", "=", "None", ",", "recurrence_count", "=", "None", ",", "due_date", "=", ...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderClient.update_note
Updates the note with the given ID to have the given content
wunderpy2/wunderclient.py
def update_note(self, note_id, revision, content): ''' Updates the note with the given ID to have the given content ''' return notes_endpoint.update_note(self, note_id, revision, content)
def update_note(self, note_id, revision, content): ''' Updates the note with the given ID to have the given content ''' return notes_endpoint.update_note(self, note_id, revision, content)
[ "Updates", "the", "note", "with", "the", "given", "ID", "to", "have", "the", "given", "content" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L116-L118
[ "def", "update_note", "(", "self", ",", "note_id", ",", "revision", ",", "content", ")", ":", "return", "notes_endpoint", ".", "update_note", "(", "self", ",", "note_id", ",", "revision", ",", "content", ")" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderClient.get_task_subtasks
Gets subtasks for task with given ID
wunderpy2/wunderclient.py
def get_task_subtasks(self, task_id, completed=False): ''' Gets subtasks for task with given ID ''' return subtasks_endpoint.get_task_subtasks(self, task_id, completed=completed)
def get_task_subtasks(self, task_id, completed=False): ''' Gets subtasks for task with given ID ''' return subtasks_endpoint.get_task_subtasks(self, task_id, completed=completed)
[ "Gets", "subtasks", "for", "task", "with", "given", "ID" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L130-L132
[ "def", "get_task_subtasks", "(", "self", ",", "task_id", ",", "completed", "=", "False", ")", ":", "return", "subtasks_endpoint", ".", "get_task_subtasks", "(", "self", ",", "task_id", ",", "completed", "=", "completed", ")" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderClient.get_list_subtasks
Gets subtasks for the list with given ID
wunderpy2/wunderclient.py
def get_list_subtasks(self, list_id, completed=False): ''' Gets subtasks for the list with given ID ''' return subtasks_endpoint.get_list_subtasks(self, list_id, completed=completed)
def get_list_subtasks(self, list_id, completed=False): ''' Gets subtasks for the list with given ID ''' return subtasks_endpoint.get_list_subtasks(self, list_id, completed=completed)
[ "Gets", "subtasks", "for", "the", "list", "with", "given", "ID" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L134-L136
[ "def", "get_list_subtasks", "(", "self", ",", "list_id", ",", "completed", "=", "False", ")", ":", "return", "subtasks_endpoint", ".", "get_list_subtasks", "(", "self", ",", "list_id", ",", "completed", "=", "completed", ")" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderClient.create_subtask
Creates a subtask with the given title under the task with the given ID Return: Newly-created subtask
wunderpy2/wunderclient.py
def create_subtask(self, task_id, title, completed=False): ''' Creates a subtask with the given title under the task with the given ID Return: Newly-created subtask ''' return subtasks_endpoint.create_subtask(self, task_id, title, completed=completed)
def create_subtask(self, task_id, title, completed=False): ''' Creates a subtask with the given title under the task with the given ID Return: Newly-created subtask ''' return subtasks_endpoint.create_subtask(self, task_id, title, completed=completed)
[ "Creates", "a", "subtask", "with", "the", "given", "title", "under", "the", "task", "with", "the", "given", "ID", "Return", ":", "Newly", "-", "created", "subtask" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L142-L149
[ "def", "create_subtask", "(", "self", ",", "task_id", ",", "title", ",", "completed", "=", "False", ")", ":", "return", "subtasks_endpoint", ".", "create_subtask", "(", "self", ",", "task_id", ",", "title", ",", "completed", "=", "completed", ")" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderClient.update_subtask
Updates the subtask with the given ID See https://developer.wunderlist.com/documentation/endpoints/subtask for detailed parameter information Returns: Subtask with given ID with properties and revision updated
wunderpy2/wunderclient.py
def update_subtask(self, subtask_id, revision, title=None, completed=None): ''' Updates the subtask with the given ID See https://developer.wunderlist.com/documentation/endpoints/subtask for detailed parameter information Returns: Subtask with given ID with properties and revis...
def update_subtask(self, subtask_id, revision, title=None, completed=None): ''' Updates the subtask with the given ID See https://developer.wunderlist.com/documentation/endpoints/subtask for detailed parameter information Returns: Subtask with given ID with properties and revis...
[ "Updates", "the", "subtask", "with", "the", "given", "ID" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L151-L160
[ "def", "update_subtask", "(", "self", ",", "subtask_id", ",", "revision", ",", "title", "=", "None", ",", "completed", "=", "None", ")", ":", "return", "subtasks_endpoint", ".", "update_subtask", "(", "self", ",", "subtask_id", ",", "revision", ",", "title",...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderClient.update_list_positions_obj
Updates the ordering of lists to have the given value. The given ID and revision should match the singleton object defining how lists are laid out. See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: The updated ListPositionsObj-mapped object defining t...
wunderpy2/wunderclient.py
def update_list_positions_obj(self, positions_obj_id, revision, values): ''' Updates the ordering of lists to have the given value. The given ID and revision should match the singleton object defining how lists are laid out. See https://developer.wunderlist.com/documentation/endpoints/positions...
def update_list_positions_obj(self, positions_obj_id, revision, values): ''' Updates the ordering of lists to have the given value. The given ID and revision should match the singleton object defining how lists are laid out. See https://developer.wunderlist.com/documentation/endpoints/positions...
[ "Updates", "the", "ordering", "of", "lists", "to", "have", "the", "given", "value", ".", "The", "given", "ID", "and", "revision", "should", "match", "the", "singleton", "object", "defining", "how", "lists", "are", "laid", "out", "." ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L188-L197
[ "def", "update_list_positions_obj", "(", "self", ",", "positions_obj_id", ",", "revision", ",", "values", ")", ":", "return", "positions_endpoints", ".", "update_list_positions_obj", "(", "self", ",", "positions_obj_id", ",", "revision", ",", "values", ")" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderClient.update_task_positions_obj
Updates the ordering of tasks in the positions object with the given ID to the ordering in the given values. See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: The updated TaskPositionsObj-mapped object defining the order of list layout
wunderpy2/wunderclient.py
def update_task_positions_obj(self, positions_obj_id, revision, values): ''' Updates the ordering of tasks in the positions object with the given ID to the ordering in the given values. See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: ...
def update_task_positions_obj(self, positions_obj_id, revision, values): ''' Updates the ordering of tasks in the positions object with the given ID to the ordering in the given values. See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: ...
[ "Updates", "the", "ordering", "of", "tasks", "in", "the", "positions", "object", "with", "the", "given", "ID", "to", "the", "ordering", "in", "the", "given", "values", "." ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L221-L230
[ "def", "update_task_positions_obj", "(", "self", ",", "positions_obj_id", ",", "revision", ",", "values", ")", ":", "return", "positions_endpoints", ".", "update_task_positions_obj", "(", "self", ",", "positions_obj_id", ",", "revision", ",", "values", ")" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
WunderClient.update_subtask_positions_obj
Updates the ordering of subtasks in the positions object with the given ID to the ordering in the given values. See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: The updated SubtaskPositionsObj-mapped object defining the order of list layout
wunderpy2/wunderclient.py
def update_subtask_positions_obj(self, positions_obj_id, revision, values): ''' Updates the ordering of subtasks in the positions object with the given ID to the ordering in the given values. See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: ...
def update_subtask_positions_obj(self, positions_obj_id, revision, values): ''' Updates the ordering of subtasks in the positions object with the given ID to the ordering in the given values. See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: ...
[ "Updates", "the", "ordering", "of", "subtasks", "in", "the", "positions", "object", "with", "the", "given", "ID", "to", "the", "ordering", "in", "the", "given", "values", "." ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L263-L272
[ "def", "update_subtask_positions_obj", "(", "self", ",", "positions_obj_id", ",", "revision", ",", "values", ")", ":", "return", "positions_endpoints", ".", "update_subtask_positions_obj", "(", "self", ",", "positions_obj_id", ",", "revision", ",", "values", ")" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
_check_date_format
Checks that the given date string conforms to the given API's date format specification
wunderpy2/tasks_endpoint.py
def _check_date_format(date, api): ''' Checks that the given date string conforms to the given API's date format specification ''' try: datetime.datetime.strptime(date, api.DATE_FORMAT) except ValueError: raise ValueError("Date '{}' does not conform to API format: {}".format(date, api.DATE_F...
def _check_date_format(date, api): ''' Checks that the given date string conforms to the given API's date format specification ''' try: datetime.datetime.strptime(date, api.DATE_FORMAT) except ValueError: raise ValueError("Date '{}' does not conform to API format: {}".format(date, api.DATE_F...
[ "Checks", "that", "the", "given", "date", "string", "conforms", "to", "the", "given", "API", "s", "date", "format", "specification" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/tasks_endpoint.py#L11-L16
[ "def", "_check_date_format", "(", "date", ",", "api", ")", ":", "try", ":", "datetime", ".", "datetime", ".", "strptime", "(", "date", ",", "api", ".", "DATE_FORMAT", ")", "except", "ValueError", ":", "raise", "ValueError", "(", "\"Date '{}' does not conform t...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
get_tasks
Gets un/completed tasks for the given list ID
wunderpy2/tasks_endpoint.py
def get_tasks(client, list_id, completed=False): ''' Gets un/completed tasks for the given list ID ''' params = { 'list_id' : str(list_id), 'completed' : completed } response = client.authenticated_request(client.api.Endpoints.TASKS, params=params) return response....
def get_tasks(client, list_id, completed=False): ''' Gets un/completed tasks for the given list ID ''' params = { 'list_id' : str(list_id), 'completed' : completed } response = client.authenticated_request(client.api.Endpoints.TASKS, params=params) return response....
[ "Gets", "un", "/", "completed", "tasks", "for", "the", "given", "list", "ID" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/tasks_endpoint.py#L18-L25
[ "def", "get_tasks", "(", "client", ",", "list_id", ",", "completed", "=", "False", ")", ":", "params", "=", "{", "'list_id'", ":", "str", "(", "list_id", ")", ",", "'completed'", ":", "completed", "}", "response", "=", "client", ".", "authenticated_request...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
get_task
Gets task information for the given ID
wunderpy2/tasks_endpoint.py
def get_task(client, task_id): ''' Gets task information for the given ID ''' endpoint = '/'.join([client.api.Endpoints.TASKS, str(task_id)]) response = client.authenticated_request(endpoint) return response.json()
def get_task(client, task_id): ''' Gets task information for the given ID ''' endpoint = '/'.join([client.api.Endpoints.TASKS, str(task_id)]) response = client.authenticated_request(endpoint) return response.json()
[ "Gets", "task", "information", "for", "the", "given", "ID" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/tasks_endpoint.py#L27-L31
[ "def", "get_task", "(", "client", ",", "task_id", ")", ":", "endpoint", "=", "'/'", ".", "join", "(", "[", "client", ".", "api", ".", "Endpoints", ".", "TASKS", ",", "str", "(", "task_id", ")", "]", ")", "response", "=", "client", ".", "authenticated...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
create_task
Creates a task in the given list See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter information
wunderpy2/tasks_endpoint.py
def create_task(client, list_id, title, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None): ''' Creates a task in the given list See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter information ''' _check...
def create_task(client, list_id, title, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None): ''' Creates a task in the given list See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter information ''' _check...
[ "Creates", "a", "task", "in", "the", "given", "list" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/tasks_endpoint.py#L33-L56
[ "def", "create_task", "(", "client", ",", "list_id", ",", "title", ",", "assignee_id", "=", "None", ",", "completed", "=", "None", ",", "recurrence_type", "=", "None", ",", "recurrence_count", "=", "None", ",", "due_date", "=", "None", ",", "starred", "=",...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
update_task
Updates the task with the given ID See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter information
wunderpy2/tasks_endpoint.py
def update_task(client, task_id, revision, title=None, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None, remove=None): ''' Updates the task with the given ID See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter in...
def update_task(client, task_id, revision, title=None, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None, remove=None): ''' Updates the task with the given ID See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter in...
[ "Updates", "the", "task", "with", "the", "given", "ID" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/tasks_endpoint.py#L58-L84
[ "def", "update_task", "(", "client", ",", "task_id", ",", "revision", ",", "title", "=", "None", ",", "assignee_id", "=", "None", ",", "completed", "=", "None", ",", "recurrence_type", "=", "None", ",", "recurrence_count", "=", "None", ",", "due_date", "="...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
_check_title_length
Checks the given title against the given API specifications to ensure it's short enough
wunderpy2/lists_endpoint.py
def _check_title_length(title, api): ''' Checks the given title against the given API specifications to ensure it's short enough ''' if len(title) > api.MAX_LIST_TITLE_LENGTH: raise ValueError("Title cannot be longer than {} characters".format(api.MAX_TASK_TITLE_LENGTH))
def _check_title_length(title, api): ''' Checks the given title against the given API specifications to ensure it's short enough ''' if len(title) > api.MAX_LIST_TITLE_LENGTH: raise ValueError("Title cannot be longer than {} characters".format(api.MAX_TASK_TITLE_LENGTH))
[ "Checks", "the", "given", "title", "against", "the", "given", "API", "specifications", "to", "ensure", "it", "s", "short", "enough" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/lists_endpoint.py#L4-L7
[ "def", "_check_title_length", "(", "title", ",", "api", ")", ":", "if", "len", "(", "title", ")", ">", "api", ".", "MAX_LIST_TITLE_LENGTH", ":", "raise", "ValueError", "(", "\"Title cannot be longer than {} characters\"", ".", "format", "(", "api", ".", "MAX_TAS...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
get_lists
Gets all the client's lists
wunderpy2/lists_endpoint.py
def get_lists(client): ''' Gets all the client's lists ''' response = client.authenticated_request(client.api.Endpoints.LISTS) return response.json()
def get_lists(client): ''' Gets all the client's lists ''' response = client.authenticated_request(client.api.Endpoints.LISTS) return response.json()
[ "Gets", "all", "the", "client", "s", "lists" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/lists_endpoint.py#L9-L12
[ "def", "get_lists", "(", "client", ")", ":", "response", "=", "client", ".", "authenticated_request", "(", "client", ".", "api", ".", "Endpoints", ".", "LISTS", ")", "return", "response", ".", "json", "(", ")" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
get_list
Gets the given list
wunderpy2/lists_endpoint.py
def get_list(client, list_id): ''' Gets the given list ''' endpoint = '/'.join([client.api.Endpoints.LISTS, str(list_id)]) response = client.authenticated_request(endpoint) return response.json()
def get_list(client, list_id): ''' Gets the given list ''' endpoint = '/'.join([client.api.Endpoints.LISTS, str(list_id)]) response = client.authenticated_request(endpoint) return response.json()
[ "Gets", "the", "given", "list" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/lists_endpoint.py#L14-L18
[ "def", "get_list", "(", "client", ",", "list_id", ")", ":", "endpoint", "=", "'/'", ".", "join", "(", "[", "client", ".", "api", ".", "Endpoints", ".", "LISTS", ",", "str", "(", "list_id", ")", "]", ")", "response", "=", "client", ".", "authenticated...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
create_list
Creates a new list with the given title
wunderpy2/lists_endpoint.py
def create_list(client, title): ''' Creates a new list with the given title ''' _check_title_length(title, client.api) data = { 'title' : title, } response = client.authenticated_request(client.api.Endpoints.LISTS, method='POST', data=data) return response.json()
def create_list(client, title): ''' Creates a new list with the given title ''' _check_title_length(title, client.api) data = { 'title' : title, } response = client.authenticated_request(client.api.Endpoints.LISTS, method='POST', data=data) return response.json()
[ "Creates", "a", "new", "list", "with", "the", "given", "title" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/lists_endpoint.py#L20-L27
[ "def", "create_list", "(", "client", ",", "title", ")", ":", "_check_title_length", "(", "title", ",", "client", ".", "api", ")", "data", "=", "{", "'title'", ":", "title", ",", "}", "response", "=", "client", ".", "authenticated_request", "(", "client", ...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
update_list
Updates the list with the given ID to have the given properties See https://developer.wunderlist.com/documentation/endpoints/list for detailed parameter information
wunderpy2/lists_endpoint.py
def update_list(client, list_id, revision, title=None, public=None): ''' Updates the list with the given ID to have the given properties See https://developer.wunderlist.com/documentation/endpoints/list for detailed parameter information ''' if title is not None: _check_title_length(title, ...
def update_list(client, list_id, revision, title=None, public=None): ''' Updates the list with the given ID to have the given properties See https://developer.wunderlist.com/documentation/endpoints/list for detailed parameter information ''' if title is not None: _check_title_length(title, ...
[ "Updates", "the", "list", "with", "the", "given", "ID", "to", "have", "the", "given", "properties" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/lists_endpoint.py#L29-L45
[ "def", "update_list", "(", "client", ",", "list_id", ",", "revision", ",", "title", "=", "None", ",", "public", "=", "None", ")", ":", "if", "title", "is", "not", "None", ":", "_check_title_length", "(", "title", ",", "client", ".", "api", ")", "data",...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
get_list_positions_obj
Gets the object that defines how lists are ordered (there will always be only one of these) See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: A ListPositionsObj-mapped object defining the order of list layout
wunderpy2/positions_endpoints.py
def get_list_positions_obj(client, positions_obj_id): ''' Gets the object that defines how lists are ordered (there will always be only one of these) See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: A ListPositionsObj-mapped object defining the order of ...
def get_list_positions_obj(client, positions_obj_id): ''' Gets the object that defines how lists are ordered (there will always be only one of these) See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: A ListPositionsObj-mapped object defining the order of ...
[ "Gets", "the", "object", "that", "defines", "how", "lists", "are", "ordered", "(", "there", "will", "always", "be", "only", "one", "of", "these", ")" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/positions_endpoints.py#L27-L36
[ "def", "get_list_positions_obj", "(", "client", ",", "positions_obj_id", ")", ":", "return", "endpoint_helpers", ".", "get_endpoint_obj", "(", "client", ",", "client", ".", "api", ".", "Endpoints", ".", "LIST_POSITIONS", ",", "positions_obj_id", ")" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
update_list_positions_obj
Updates the ordering of lists to have the given value. The given ID and revision should match the singleton object defining how lists are laid out. See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: The updated ListPositionsObj-mapped object defining the order of ...
wunderpy2/positions_endpoints.py
def update_list_positions_obj(client, positions_obj_id, revision, values): ''' Updates the ordering of lists to have the given value. The given ID and revision should match the singleton object defining how lists are laid out. See https://developer.wunderlist.com/documentation/endpoints/positions for more ...
def update_list_positions_obj(client, positions_obj_id, revision, values): ''' Updates the ordering of lists to have the given value. The given ID and revision should match the singleton object defining how lists are laid out. See https://developer.wunderlist.com/documentation/endpoints/positions for more ...
[ "Updates", "the", "ordering", "of", "lists", "to", "have", "the", "given", "value", ".", "The", "given", "ID", "and", "revision", "should", "match", "the", "singleton", "object", "defining", "how", "lists", "are", "laid", "out", "." ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/positions_endpoints.py#L39-L48
[ "def", "update_list_positions_obj", "(", "client", ",", "positions_obj_id", ",", "revision", ",", "values", ")", ":", "return", "_update_positions_obj", "(", "client", ",", "client", ".", "api", ".", "Endpoints", ".", "LIST_POSITIONS", ",", "positions_obj_id", ","...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
get_task_positions_objs
Gets a list containing the object that encapsulates information about the order lists are laid out in. This list will always contain exactly one object. See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: A list containing a single ListPositionsObj-mapped object
wunderpy2/positions_endpoints.py
def get_task_positions_objs(client, list_id): ''' Gets a list containing the object that encapsulates information about the order lists are laid out in. This list will always contain exactly one object. See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: A ...
def get_task_positions_objs(client, list_id): ''' Gets a list containing the object that encapsulates information about the order lists are laid out in. This list will always contain exactly one object. See https://developer.wunderlist.com/documentation/endpoints/positions for more info Return: A ...
[ "Gets", "a", "list", "containing", "the", "object", "that", "encapsulates", "information", "about", "the", "order", "lists", "are", "laid", "out", "in", ".", "This", "list", "will", "always", "contain", "exactly", "one", "object", "." ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/positions_endpoints.py#L50-L63
[ "def", "get_task_positions_objs", "(", "client", ",", "list_id", ")", ":", "params", "=", "{", "'list_id'", ":", "int", "(", "list_id", ")", "}", "response", "=", "client", ".", "authenticated_request", "(", "client", ".", "api", ".", "Endpoints", ".", "TA...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
get_task_subtask_positions_objs
Gets a list of the positions of a single task's subtasks Each task should (will?) only have one positions object defining how its subtasks are laid out
wunderpy2/positions_endpoints.py
def get_task_subtask_positions_objs(client, task_id): ''' Gets a list of the positions of a single task's subtasks Each task should (will?) only have one positions object defining how its subtasks are laid out ''' params = { 'task_id' : int(task_id) } response = client.a...
def get_task_subtask_positions_objs(client, task_id): ''' Gets a list of the positions of a single task's subtasks Each task should (will?) only have one positions object defining how its subtasks are laid out ''' params = { 'task_id' : int(task_id) } response = client.a...
[ "Gets", "a", "list", "of", "the", "positions", "of", "a", "single", "task", "s", "subtasks" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/positions_endpoints.py#L71-L81
[ "def", "get_task_subtask_positions_objs", "(", "client", ",", "task_id", ")", ":", "params", "=", "{", "'task_id'", ":", "int", "(", "task_id", ")", "}", "response", "=", "client", ".", "authenticated_request", "(", "client", ".", "api", ".", "Endpoints", "....
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
get_list_subtask_positions_objs
Gets all subtask positions objects for the tasks within a given list. This is a convenience method so you don't have to get all the list's tasks before getting subtasks, though I can't fathom how mass subtask reordering is useful. Returns: List of SubtaskPositionsObj-mapped objects representing the order of su...
wunderpy2/positions_endpoints.py
def get_list_subtask_positions_objs(client, list_id): ''' Gets all subtask positions objects for the tasks within a given list. This is a convenience method so you don't have to get all the list's tasks before getting subtasks, though I can't fathom how mass subtask reordering is useful. Returns: List ...
def get_list_subtask_positions_objs(client, list_id): ''' Gets all subtask positions objects for the tasks within a given list. This is a convenience method so you don't have to get all the list's tasks before getting subtasks, though I can't fathom how mass subtask reordering is useful. Returns: List ...
[ "Gets", "all", "subtask", "positions", "objects", "for", "the", "tasks", "within", "a", "given", "list", ".", "This", "is", "a", "convenience", "method", "so", "you", "don", "t", "have", "to", "get", "all", "the", "list", "s", "tasks", "before", "getting...
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/positions_endpoints.py#L84-L95
[ "def", "get_list_subtask_positions_objs", "(", "client", ",", "list_id", ")", ":", "params", "=", "{", "'list_id'", ":", "int", "(", "list_id", ")", "}", "response", "=", "client", ".", "authenticated_request", "(", "client", ".", "api", ".", "Endpoints", "....
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
_check_title_length
Checks the given title against the given API specifications to ensure it's short enough
wunderpy2/subtasks_endpoint.py
def _check_title_length(title, api): ''' Checks the given title against the given API specifications to ensure it's short enough ''' if len(title) > api.MAX_SUBTASK_TITLE_LENGTH: raise ValueError("Title cannot be longer than {} characters".format(api.MAX_SUBTASK_TITLE_LENGTH))
def _check_title_length(title, api): ''' Checks the given title against the given API specifications to ensure it's short enough ''' if len(title) > api.MAX_SUBTASK_TITLE_LENGTH: raise ValueError("Title cannot be longer than {} characters".format(api.MAX_SUBTASK_TITLE_LENGTH))
[ "Checks", "the", "given", "title", "against", "the", "given", "API", "specifications", "to", "ensure", "it", "s", "short", "enough" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L5-L8
[ "def", "_check_title_length", "(", "title", ",", "api", ")", ":", "if", "len", "(", "title", ")", ">", "api", ".", "MAX_SUBTASK_TITLE_LENGTH", ":", "raise", "ValueError", "(", "\"Title cannot be longer than {} characters\"", ".", "format", "(", "api", ".", "MAX_...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
get_task_subtasks
Gets subtasks for task with given ID
wunderpy2/subtasks_endpoint.py
def get_task_subtasks(client, task_id, completed=False): ''' Gets subtasks for task with given ID ''' params = { 'task_id' : int(task_id), 'completed' : completed, } response = client.authenticated_request(client.api.Endpoints.SUBTASKS, params=params) return response....
def get_task_subtasks(client, task_id, completed=False): ''' Gets subtasks for task with given ID ''' params = { 'task_id' : int(task_id), 'completed' : completed, } response = client.authenticated_request(client.api.Endpoints.SUBTASKS, params=params) return response....
[ "Gets", "subtasks", "for", "task", "with", "given", "ID" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L10-L17
[ "def", "get_task_subtasks", "(", "client", ",", "task_id", ",", "completed", "=", "False", ")", ":", "params", "=", "{", "'task_id'", ":", "int", "(", "task_id", ")", ",", "'completed'", ":", "completed", ",", "}", "response", "=", "client", ".", "authen...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
get_list_subtasks
Gets subtasks for the list with given ID
wunderpy2/subtasks_endpoint.py
def get_list_subtasks(client, list_id, completed=False): ''' Gets subtasks for the list with given ID ''' params = { 'list_id' : int(list_id), 'completed' : completed, } response = client.authenticated_request(client.api.Endpoints.SUBTASKS, params=params) return respo...
def get_list_subtasks(client, list_id, completed=False): ''' Gets subtasks for the list with given ID ''' params = { 'list_id' : int(list_id), 'completed' : completed, } response = client.authenticated_request(client.api.Endpoints.SUBTASKS, params=params) return respo...
[ "Gets", "subtasks", "for", "the", "list", "with", "given", "ID" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L19-L26
[ "def", "get_list_subtasks", "(", "client", ",", "list_id", ",", "completed", "=", "False", ")", ":", "params", "=", "{", "'list_id'", ":", "int", "(", "list_id", ")", ",", "'completed'", ":", "completed", ",", "}", "response", "=", "client", ".", "authen...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
get_subtask
Gets the subtask with the given ID
wunderpy2/subtasks_endpoint.py
def get_subtask(client, subtask_id): ''' Gets the subtask with the given ID ''' endpoint = '/'.join([client.api.Endpoints.SUBTASKS, str(subtask_id)]) response = client.authenticated_request(endpoint) return response.json()
def get_subtask(client, subtask_id): ''' Gets the subtask with the given ID ''' endpoint = '/'.join([client.api.Endpoints.SUBTASKS, str(subtask_id)]) response = client.authenticated_request(endpoint) return response.json()
[ "Gets", "the", "subtask", "with", "the", "given", "ID" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L28-L32
[ "def", "get_subtask", "(", "client", ",", "subtask_id", ")", ":", "endpoint", "=", "'/'", ".", "join", "(", "[", "client", ".", "api", ".", "Endpoints", ".", "SUBTASKS", ",", "str", "(", "subtask_id", ")", "]", ")", "response", "=", "client", ".", "a...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
create_subtask
Creates a subtask with the given title under the task with the given ID
wunderpy2/subtasks_endpoint.py
def create_subtask(client, task_id, title, completed=False): ''' Creates a subtask with the given title under the task with the given ID ''' _check_title_length(title, client.api) data = { 'task_id' : int(task_id) if task_id else None, 'title' : title, 'completed' : compl...
def create_subtask(client, task_id, title, completed=False): ''' Creates a subtask with the given title under the task with the given ID ''' _check_title_length(title, client.api) data = { 'task_id' : int(task_id) if task_id else None, 'title' : title, 'completed' : compl...
[ "Creates", "a", "subtask", "with", "the", "given", "title", "under", "the", "task", "with", "the", "given", "ID" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L34-L44
[ "def", "create_subtask", "(", "client", ",", "task_id", ",", "title", ",", "completed", "=", "False", ")", ":", "_check_title_length", "(", "title", ",", "client", ".", "api", ")", "data", "=", "{", "'task_id'", ":", "int", "(", "task_id", ")", "if", "...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
update_subtask
Updates the subtask with the given ID See https://developer.wunderlist.com/documentation/endpoints/subtask for detailed parameter information
wunderpy2/subtasks_endpoint.py
def update_subtask(client, subtask_id, revision, title=None, completed=None): ''' Updates the subtask with the given ID See https://developer.wunderlist.com/documentation/endpoints/subtask for detailed parameter information ''' if title is not None: _check_title_length(title, client.api) ...
def update_subtask(client, subtask_id, revision, title=None, completed=None): ''' Updates the subtask with the given ID See https://developer.wunderlist.com/documentation/endpoints/subtask for detailed parameter information ''' if title is not None: _check_title_length(title, client.api) ...
[ "Updates", "the", "subtask", "with", "the", "given", "ID" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L46-L62
[ "def", "update_subtask", "(", "client", ",", "subtask_id", ",", "revision", ",", "title", "=", "None", ",", "completed", "=", "None", ")", ":", "if", "title", "is", "not", "None", ":", "_check_title_length", "(", "title", ",", "client", ".", "api", ")", ...
7106b6c13ca45ef4d56f805753c93258d5b822c2
train
delete_subtask
Deletes the subtask with the given ID provided the given revision equals the revision the server has
wunderpy2/subtasks_endpoint.py
def delete_subtask(client, subtask_id, revision): ''' Deletes the subtask with the given ID provided the given revision equals the revision the server has ''' params = { 'revision' : int(revision), } endpoint = '/'.join([client.api.Endpoints.SUBTASKS, str(subtask_id)]) client.aut...
def delete_subtask(client, subtask_id, revision): ''' Deletes the subtask with the given ID provided the given revision equals the revision the server has ''' params = { 'revision' : int(revision), } endpoint = '/'.join([client.api.Endpoints.SUBTASKS, str(subtask_id)]) client.aut...
[ "Deletes", "the", "subtask", "with", "the", "given", "ID", "provided", "the", "given", "revision", "equals", "the", "revision", "the", "server", "has" ]
mieubrisse/wunderpy2
python
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L64-L70
[ "def", "delete_subtask", "(", "client", ",", "subtask_id", ",", "revision", ")", ":", "params", "=", "{", "'revision'", ":", "int", "(", "revision", ")", ",", "}", "endpoint", "=", "'/'", ".", "join", "(", "[", "client", ".", "api", ".", "Endpoints", ...
7106b6c13ca45ef4d56f805753c93258d5b822c2