repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
d0c-s4vage/pfp
pfp/native/compat_io.py
FSeek
def FSeek(params, ctxt, scope, stream, coord): """Returns 0 if successful or -1 if the address is out of range """ if len(params) != 1: raise errors.InvalidArguments(coord, "{} args".format(len(params)), "FSeek accepts only one argument") pos = PYVAL(params[0]) curr_pos = stream.tell() ...
python
def FSeek(params, ctxt, scope, stream, coord): """Returns 0 if successful or -1 if the address is out of range """ if len(params) != 1: raise errors.InvalidArguments(coord, "{} args".format(len(params)), "FSeek accepts only one argument") pos = PYVAL(params[0]) curr_pos = stream.tell() ...
[ "def", "FSeek", "(", "params", ",", "ctxt", ",", "scope", ",", "stream", ",", "coord", ")", ":", "if", "len", "(", "params", ")", "!=", "1", ":", "raise", "errors", ".", "InvalidArguments", "(", "coord", ",", "\"{} args\"", ".", "format", "(", "len",...
Returns 0 if successful or -1 if the address is out of range
[ "Returns", "0", "if", "successful", "or", "-", "1", "if", "the", "address", "is", "out", "of", "range" ]
32f2d34fdec1c70019fa83c7006d5e3be0f92fcd
https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/compat_io.py#L117-L158
train
d0c-s4vage/pfp
pfp/native/compat_io.py
FSkip
def FSkip(params, ctxt, scope, stream, coord): """Returns 0 if successful or -1 if the address is out of range """ if len(params) != 1: raise errors.InvalidArguments(coord, "{} args".format(len(params)), "FSkip accepts only one argument") skip_amt = PYVAL(params[0]) pos = skip_amt + stream....
python
def FSkip(params, ctxt, scope, stream, coord): """Returns 0 if successful or -1 if the address is out of range """ if len(params) != 1: raise errors.InvalidArguments(coord, "{} args".format(len(params)), "FSkip accepts only one argument") skip_amt = PYVAL(params[0]) pos = skip_amt + stream....
[ "def", "FSkip", "(", "params", ",", "ctxt", ",", "scope", ",", "stream", ",", "coord", ")", ":", "if", "len", "(", "params", ")", "!=", "1", ":", "raise", "errors", ".", "InvalidArguments", "(", "coord", ",", "\"{} args\"", ".", "format", "(", "len",...
Returns 0 if successful or -1 if the address is out of range
[ "Returns", "0", "if", "successful", "or", "-", "1", "if", "the", "address", "is", "out", "of", "range" ]
32f2d34fdec1c70019fa83c7006d5e3be0f92fcd
https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/compat_io.py#L162-L170
train
d0c-s4vage/pfp
pfp/native/packers.py
packer_gzip
def packer_gzip(params, ctxt, scope, stream, coord): """``PackerGZip`` - implements both unpacking and packing. Can be used as the ``packer`` for a field. When packing, concats the build output of all params and gzip-compresses the result. When unpacking, concats the build output of all params and gzip-...
python
def packer_gzip(params, ctxt, scope, stream, coord): """``PackerGZip`` - implements both unpacking and packing. Can be used as the ``packer`` for a field. When packing, concats the build output of all params and gzip-compresses the result. When unpacking, concats the build output of all params and gzip-...
[ "def", "packer_gzip", "(", "params", ",", "ctxt", ",", "scope", ",", "stream", ",", "coord", ")", ":", "if", "len", "(", "params", ")", "<=", "1", ":", "raise", "errors", ".", "InvalidArguments", "(", "coord", ",", "\"{} args\"", ".", "format", "(", ...
``PackerGZip`` - implements both unpacking and packing. Can be used as the ``packer`` for a field. When packing, concats the build output of all params and gzip-compresses the result. When unpacking, concats the build output of all params and gzip-decompresses the result. Example: The code...
[ "PackerGZip", "-", "implements", "both", "unpacking", "and", "packing", ".", "Can", "be", "used", "as", "the", "packer", "for", "a", "field", ".", "When", "packing", "concats", "the", "build", "output", "of", "all", "params", "and", "gzip", "-", "compresse...
32f2d34fdec1c70019fa83c7006d5e3be0f92fcd
https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/packers.py#L14-L40
train
d0c-s4vage/pfp
pfp/native/packers.py
pack_gzip
def pack_gzip(params, ctxt, scope, stream, coord): """``PackGZip`` - Concats the build output of all params and gzips the resulting data, returning a char array. Example: :: char data[0x100]<pack=PackGZip, ...>; """ if len(params) == 0: raise errors.InvalidArguments(coord, "{} args...
python
def pack_gzip(params, ctxt, scope, stream, coord): """``PackGZip`` - Concats the build output of all params and gzips the resulting data, returning a char array. Example: :: char data[0x100]<pack=PackGZip, ...>; """ if len(params) == 0: raise errors.InvalidArguments(coord, "{} args...
[ "def", "pack_gzip", "(", "params", ",", "ctxt", ",", "scope", ",", "stream", ",", "coord", ")", ":", "if", "len", "(", "params", ")", "==", "0", ":", "raise", "errors", ".", "InvalidArguments", "(", "coord", ",", "\"{} args\"", ".", "format", "(", "l...
``PackGZip`` - Concats the build output of all params and gzips the resulting data, returning a char array. Example: :: char data[0x100]<pack=PackGZip, ...>;
[ "PackGZip", "-", "Concats", "the", "build", "output", "of", "all", "params", "and", "gzips", "the", "resulting", "data", "returning", "a", "char", "array", "." ]
32f2d34fdec1c70019fa83c7006d5e3be0f92fcd
https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/packers.py#L43-L61
train
d0c-s4vage/pfp
pfp/native/watchers.py
watch_length
def watch_length(params, ctxt, scope, stream, coord): """WatchLength - Watch the total length of each of the params. Example: The code below uses the ``WatchLength`` update function to update the ``length`` field to the length of the ``data`` field :: int length<watch=data, upd...
python
def watch_length(params, ctxt, scope, stream, coord): """WatchLength - Watch the total length of each of the params. Example: The code below uses the ``WatchLength`` update function to update the ``length`` field to the length of the ``data`` field :: int length<watch=data, upd...
[ "def", "watch_length", "(", "params", ",", "ctxt", ",", "scope", ",", "stream", ",", "coord", ")", ":", "if", "len", "(", "params", ")", "<=", "1", ":", "raise", "errors", ".", "InvalidArguments", "(", "coord", ",", "\"{} args\"", ".", "format", "(", ...
WatchLength - Watch the total length of each of the params. Example: The code below uses the ``WatchLength`` update function to update the ``length`` field to the length of the ``data`` field :: int length<watch=data, update=WatchLength>; char data[length];
[ "WatchLength", "-", "Watch", "the", "total", "length", "of", "each", "of", "the", "params", ".", "Example", ":", "The", "code", "below", "uses", "the", "WatchLength", "update", "function", "to", "update", "the", "length", "field", "to", "the", "length", "o...
32f2d34fdec1c70019fa83c7006d5e3be0f92fcd
https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/watchers.py#L15-L34
train
d0c-s4vage/pfp
pfp/native/watchers.py
watch_crc
def watch_crc(params, ctxt, scope, stream, coord): """WatchCrc32 - Watch the total crc32 of the params. Example: The code below uses the ``WatchCrc32`` update function to update the ``crc`` field to the crc of the ``length`` and ``data`` fields :: char length; char ...
python
def watch_crc(params, ctxt, scope, stream, coord): """WatchCrc32 - Watch the total crc32 of the params. Example: The code below uses the ``WatchCrc32`` update function to update the ``crc`` field to the crc of the ``length`` and ``data`` fields :: char length; char ...
[ "def", "watch_crc", "(", "params", ",", "ctxt", ",", "scope", ",", "stream", ",", "coord", ")", ":", "if", "len", "(", "params", ")", "<=", "1", ":", "raise", "errors", ".", "InvalidArguments", "(", "coord", ",", "\"{} args\"", ".", "format", "(", "l...
WatchCrc32 - Watch the total crc32 of the params. Example: The code below uses the ``WatchCrc32`` update function to update the ``crc`` field to the crc of the ``length`` and ``data`` fields :: char length; char data[length]; int crc<watch=length;data, updat...
[ "WatchCrc32", "-", "Watch", "the", "total", "crc32", "of", "the", "params", ".", "Example", ":", "The", "code", "below", "uses", "the", "WatchCrc32", "update", "function", "to", "update", "the", "crc", "field", "to", "the", "crc", "of", "the", "length", ...
32f2d34fdec1c70019fa83c7006d5e3be0f92fcd
https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/watchers.py#L37-L57
train
expfactory/expfactory
expfactory/validator/experiments.py
ExperimentValidator._validate_folder
def _validate_folder(self, folder=None): ''' validate folder takes a cloned github repo, ensures the existence of the config.json, and validates it. ''' from expfactory.experiment import load_experiment if folder is None: folder=os.path.abspath(os.getcwd()) ...
python
def _validate_folder(self, folder=None): ''' validate folder takes a cloned github repo, ensures the existence of the config.json, and validates it. ''' from expfactory.experiment import load_experiment if folder is None: folder=os.path.abspath(os.getcwd()) ...
[ "def", "_validate_folder", "(", "self", ",", "folder", "=", "None", ")", ":", "from", "expfactory", ".", "experiment", "import", "load_experiment", "if", "folder", "is", "None", ":", "folder", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "getc...
validate folder takes a cloned github repo, ensures the existence of the config.json, and validates it.
[ "validate", "folder", "takes", "a", "cloned", "github", "repo", "ensures", "the", "existence", "of", "the", "config", ".", "json", "and", "validates", "it", "." ]
27ce6cc93e17231df8a8024f18e631336afd3501
https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/validator/experiments.py#L52-L66
train
expfactory/expfactory
expfactory/validator/experiments.py
ExperimentValidator.validate
def validate(self, folder, cleanup=False, validate_folder=True): ''' validate is the entrypoint to all validation, for a folder, config, or url. If a URL is found, it is cloned and cleaned up. :param validate_folder: ensures the folder name (github repo) ...
python
def validate(self, folder, cleanup=False, validate_folder=True): ''' validate is the entrypoint to all validation, for a folder, config, or url. If a URL is found, it is cloned and cleaned up. :param validate_folder: ensures the folder name (github repo) ...
[ "def", "validate", "(", "self", ",", "folder", ",", "cleanup", "=", "False", ",", "validate_folder", "=", "True", ")", ":", "# Obtain any repository URL provided", "if", "folder", ".", "startswith", "(", "'http'", ")", "or", "'github'", "in", "folder", ":", ...
validate is the entrypoint to all validation, for a folder, config, or url. If a URL is found, it is cloned and cleaned up. :param validate_folder: ensures the folder name (github repo) matches.
[ "validate", "is", "the", "entrypoint", "to", "all", "validation", "for", "a", "folder", "config", "or", "url", ".", "If", "a", "URL", "is", "found", "it", "is", "cloned", "and", "cleaned", "up", ".", ":", "param", "validate_folder", ":", "ensures", "the"...
27ce6cc93e17231df8a8024f18e631336afd3501
https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/validator/experiments.py#L69-L90
train
expfactory/expfactory
expfactory/validator/experiments.py
ExperimentValidator._validate_config
def _validate_config(self, folder, validate_folder=True): ''' validate config is the primary validation function that checks for presence and format of required fields. Parameters ========== :folder: full path to folder with config.json :name: if provided, the folder...
python
def _validate_config(self, folder, validate_folder=True): ''' validate config is the primary validation function that checks for presence and format of required fields. Parameters ========== :folder: full path to folder with config.json :name: if provided, the folder...
[ "def", "_validate_config", "(", "self", ",", "folder", ",", "validate_folder", "=", "True", ")", ":", "config", "=", "\"%s/config.json\"", "%", "folder", "name", "=", "os", ".", "path", ".", "basename", "(", "folder", ")", "if", "not", "os", ".", "path",...
validate config is the primary validation function that checks for presence and format of required fields. Parameters ========== :folder: full path to folder with config.json :name: if provided, the folder name to check against exp_id
[ "validate", "config", "is", "the", "primary", "validation", "function", "that", "checks", "for", "presence", "and", "format", "of", "required", "fields", "." ]
27ce6cc93e17231df8a8024f18e631336afd3501
https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/validator/experiments.py#L93-L146
train
expfactory/expfactory
expfactory/validator/experiments.py
ExperimentValidator.get_validation_fields
def get_validation_fields(self): '''get_validation_fields returns a list of tuples (each a field) we only require the exp_id to coincide with the folder name, for the sake of reproducibility (given that all are served from sample image or Github organization). All other fields a...
python
def get_validation_fields(self): '''get_validation_fields returns a list of tuples (each a field) we only require the exp_id to coincide with the folder name, for the sake of reproducibility (given that all are served from sample image or Github organization). All other fields a...
[ "def", "get_validation_fields", "(", "self", ")", ":", "return", "[", "(", "\"name\"", ",", "1", ",", "str", ")", ",", "# required", "(", "\"time\"", ",", "1", ",", "int", ")", ",", "(", "\"url\"", ",", "1", ",", "str", ")", ",", "(", "\"descriptio...
get_validation_fields returns a list of tuples (each a field) we only require the exp_id to coincide with the folder name, for the sake of reproducibility (given that all are served from sample image or Github organization). All other fields are optional. To specify runtime v...
[ "get_validation_fields", "returns", "a", "list", "of", "tuples", "(", "each", "a", "field", ")", "we", "only", "require", "the", "exp_id", "to", "coincide", "with", "the", "folder", "name", "for", "the", "sake", "of", "reproducibility", "(", "given", "that",...
27ce6cc93e17231df8a8024f18e631336afd3501
https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/validator/experiments.py#L149-L172
train
expfactory/expfactory
expfactory/variables.py
get_runtime_vars
def get_runtime_vars(varset, experiment, token): '''get_runtime_vars will return the urlparsed string of one or more runtime variables. If None are present, None is returned. Parameters ========== varset: the variable set, a dictionary lookup with exp_id, token, vars experiment...
python
def get_runtime_vars(varset, experiment, token): '''get_runtime_vars will return the urlparsed string of one or more runtime variables. If None are present, None is returned. Parameters ========== varset: the variable set, a dictionary lookup with exp_id, token, vars experiment...
[ "def", "get_runtime_vars", "(", "varset", ",", "experiment", ",", "token", ")", ":", "url", "=", "''", "if", "experiment", "in", "varset", ":", "variables", "=", "dict", "(", ")", "# Participant set variables", "if", "token", "in", "varset", "[", "experiment...
get_runtime_vars will return the urlparsed string of one or more runtime variables. If None are present, None is returned. Parameters ========== varset: the variable set, a dictionary lookup with exp_id, token, vars experiment: the exp_id to look up token: the participant id...
[ "get_runtime_vars", "will", "return", "the", "urlparsed", "string", "of", "one", "or", "more", "runtime", "variables", ".", "If", "None", "are", "present", "None", "is", "returned", ".", "Parameters", "==========", "varset", ":", "the", "variable", "set", "a",...
27ce6cc93e17231df8a8024f18e631336afd3501
https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/variables.py#L45-L85
train
expfactory/expfactory
expfactory/variables.py
generate_runtime_vars
def generate_runtime_vars(variable_file=None, sep=','): '''generate a lookup data structure from a delimited file. We typically obtain the file name and delimiter from the environment by way of EXPFACTORY_RUNTIME_VARS, and EXPFACTORY_RUNTIME_DELIM, respectively, but the user can also parse ...
python
def generate_runtime_vars(variable_file=None, sep=','): '''generate a lookup data structure from a delimited file. We typically obtain the file name and delimiter from the environment by way of EXPFACTORY_RUNTIME_VARS, and EXPFACTORY_RUNTIME_DELIM, respectively, but the user can also parse ...
[ "def", "generate_runtime_vars", "(", "variable_file", "=", "None", ",", "sep", "=", "','", ")", ":", "# First preference goes to runtime, then environment, then unset", "if", "variable_file", "is", "None", ":", "if", "EXPFACTORY_RUNTIME_VARS", "is", "not", "None", ":", ...
generate a lookup data structure from a delimited file. We typically obtain the file name and delimiter from the environment by way of EXPFACTORY_RUNTIME_VARS, and EXPFACTORY_RUNTIME_DELIM, respectively, but the user can also parse from a custom variable file by way of specifying it to the ...
[ "generate", "a", "lookup", "data", "structure", "from", "a", "delimited", "file", ".", "We", "typically", "obtain", "the", "file", "name", "and", "delimiter", "from", "the", "environment", "by", "way", "of", "EXPFACTORY_RUNTIME_VARS", "and", "EXPFACTORY_RUNTIME_DE...
27ce6cc93e17231df8a8024f18e631336afd3501
https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/variables.py#L88-L180
train
expfactory/expfactory
expfactory/variables.py
_read_runtime_vars
def _read_runtime_vars(variable_file, sep=','): '''read the entire runtime variable file, and return a list of lists, each corresponding to a row. We also check the header, and exit if anything is missing or malformed. Parameters ========== variable_file: full path to the tabula...
python
def _read_runtime_vars(variable_file, sep=','): '''read the entire runtime variable file, and return a list of lists, each corresponding to a row. We also check the header, and exit if anything is missing or malformed. Parameters ========== variable_file: full path to the tabula...
[ "def", "_read_runtime_vars", "(", "variable_file", ",", "sep", "=", "','", ")", ":", "rows", "=", "[", "x", "for", "x", "in", "read_file", "(", "variable_file", ")", ".", "split", "(", "'\\n'", ")", "if", "x", ".", "strip", "(", ")", "]", "valid_rows...
read the entire runtime variable file, and return a list of lists, each corresponding to a row. We also check the header, and exit if anything is missing or malformed. Parameters ========== variable_file: full path to the tabular file with token, exp_id, etc. sep: the default...
[ "read", "the", "entire", "runtime", "variable", "file", "and", "return", "a", "list", "of", "lists", "each", "corresponding", "to", "a", "row", ".", "We", "also", "check", "the", "header", "and", "exit", "if", "anything", "is", "missing", "or", "malformed"...
27ce6cc93e17231df8a8024f18e631336afd3501
https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/variables.py#L183-L224
train
expfactory/expfactory
expfactory/variables.py
_validate_row
def _validate_row(row, sep=',', required_length=None): '''validate_row will ensure that a row has the proper length, and is not empty and cleaned of extra spaces. Parameters ========== row: a single row, not yet parsed. Returns a valid row, or None if not valid ''' if ...
python
def _validate_row(row, sep=',', required_length=None): '''validate_row will ensure that a row has the proper length, and is not empty and cleaned of extra spaces. Parameters ========== row: a single row, not yet parsed. Returns a valid row, or None if not valid ''' if ...
[ "def", "_validate_row", "(", "row", ",", "sep", "=", "','", ",", "required_length", "=", "None", ")", ":", "if", "not", "isinstance", "(", "row", ",", "list", ")", ":", "row", "=", "_parse_row", "(", "row", ",", "sep", ")", "if", "required_length", "...
validate_row will ensure that a row has the proper length, and is not empty and cleaned of extra spaces. Parameters ========== row: a single row, not yet parsed. Returns a valid row, or None if not valid
[ "validate_row", "will", "ensure", "that", "a", "row", "has", "the", "proper", "length", "and", "is", "not", "empty", "and", "cleaned", "of", "extra", "spaces", ".", "Parameters", "==========", "row", ":", "a", "single", "row", "not", "yet", "parsed", "." ]
27ce6cc93e17231df8a8024f18e631336afd3501
https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/variables.py#L227-L249
train
expfactory/expfactory
expfactory/variables.py
_parse_row
def _parse_row(row, sep=','): '''parse row is a helper function to simply clean up a string, and parse into a row based on a delimiter. If a required length is provided, we check for this too. ''' parsed = row.split(sep) parsed = [x for x in parsed if x.strip()] return parsed
python
def _parse_row(row, sep=','): '''parse row is a helper function to simply clean up a string, and parse into a row based on a delimiter. If a required length is provided, we check for this too. ''' parsed = row.split(sep) parsed = [x for x in parsed if x.strip()] return parsed
[ "def", "_parse_row", "(", "row", ",", "sep", "=", "','", ")", ":", "parsed", "=", "row", ".", "split", "(", "sep", ")", "parsed", "=", "[", "x", "for", "x", "in", "parsed", "if", "x", ".", "strip", "(", ")", "]", "return", "parsed" ]
parse row is a helper function to simply clean up a string, and parse into a row based on a delimiter. If a required length is provided, we check for this too.
[ "parse", "row", "is", "a", "helper", "function", "to", "simply", "clean", "up", "a", "string", "and", "parse", "into", "a", "row", "based", "on", "a", "delimiter", ".", "If", "a", "required", "length", "is", "provided", "we", "check", "for", "this", "t...
27ce6cc93e17231df8a8024f18e631336afd3501
https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/variables.py#L252-L260
train
expfactory/expfactory
expfactory/variables.py
validate_header
def validate_header(header, required_fields=None): '''validate_header ensures that the first row contains the exp_id, var_name, var_value, and token. Capitalization isn't important, but ordering is. This criteria is very strict, but it's reasonable to require. Parameters =======...
python
def validate_header(header, required_fields=None): '''validate_header ensures that the first row contains the exp_id, var_name, var_value, and token. Capitalization isn't important, but ordering is. This criteria is very strict, but it's reasonable to require. Parameters =======...
[ "def", "validate_header", "(", "header", ",", "required_fields", "=", "None", ")", ":", "if", "required_fields", "is", "None", ":", "required_fields", "=", "[", "'exp_id'", ",", "'var_name'", ",", "'var_value'", ",", "'token'", "]", "# The required length of the h...
validate_header ensures that the first row contains the exp_id, var_name, var_value, and token. Capitalization isn't important, but ordering is. This criteria is very strict, but it's reasonable to require. Parameters ========== header: the header row, as a list requir...
[ "validate_header", "ensures", "that", "the", "first", "row", "contains", "the", "exp_id", "var_name", "var_value", "and", "token", ".", "Capitalization", "isn", "t", "important", "but", "ordering", "is", ".", "This", "criteria", "is", "very", "strict", "but", ...
27ce6cc93e17231df8a8024f18e631336afd3501
https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/variables.py#L263-L294
train
littlepea/django-docs
docs/views.py
superuser_required
def superuser_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ @wraps(view_func) def _checklogin(request, *args, **kwargs): if request.user.is_active and request.user.is_superuser: ...
python
def superuser_required(view_func): """ Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary. """ @wraps(view_func) def _checklogin(request, *args, **kwargs): if request.user.is_active and request.user.is_superuser: ...
[ "def", "superuser_required", "(", "view_func", ")", ":", "@", "wraps", "(", "view_func", ")", "def", "_checklogin", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "request", ".", "user", ".", "is_active", "and", "request", "...
Decorator for views that checks that the user is logged in and is a staff member, displaying the login page if necessary.
[ "Decorator", "for", "views", "that", "checks", "that", "the", "user", "is", "logged", "in", "and", "is", "a", "staff", "member", "displaying", "the", "login", "page", "if", "necessary", "." ]
8e6c867dab51746c6482bd52c4f1270684af3870
https://github.com/littlepea/django-docs/blob/8e6c867dab51746c6482bd52c4f1270684af3870/docs/views.py#L18-L40
train
cpburnz/python-path-specification
pathspec/pathspec.py
PathSpec.from_lines
def from_lines(cls, pattern_factory, lines): """ Compiles the pattern lines. *pattern_factory* can be either the name of a registered pattern factory (:class:`str`), or a :class:`~collections.abc.Callable` used to compile patterns. It must accept an uncompiled pattern (:class:`str`) and return the compiled...
python
def from_lines(cls, pattern_factory, lines): """ Compiles the pattern lines. *pattern_factory* can be either the name of a registered pattern factory (:class:`str`), or a :class:`~collections.abc.Callable` used to compile patterns. It must accept an uncompiled pattern (:class:`str`) and return the compiled...
[ "def", "from_lines", "(", "cls", ",", "pattern_factory", ",", "lines", ")", ":", "if", "isinstance", "(", "pattern_factory", ",", "string_types", ")", ":", "pattern_factory", "=", "util", ".", "lookup_pattern", "(", "pattern_factory", ")", "if", "not", "callab...
Compiles the pattern lines. *pattern_factory* can be either the name of a registered pattern factory (:class:`str`), or a :class:`~collections.abc.Callable` used to compile patterns. It must accept an uncompiled pattern (:class:`str`) and return the compiled pattern (:class:`.Pattern`). *lines* (:class:`~co...
[ "Compiles", "the", "pattern", "lines", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/pathspec.py#L50-L75
train
cpburnz/python-path-specification
pathspec/pathspec.py
PathSpec.match_file
def match_file(self, file, separators=None): """ Matches the file to this path-spec. *file* (:class:`str`) is the file path to be matched against :attr:`self.patterns <PathSpec.patterns>`. *separators* (:class:`~collections.abc.Collection` of :class:`str`) optionally contains the path separators to normal...
python
def match_file(self, file, separators=None): """ Matches the file to this path-spec. *file* (:class:`str`) is the file path to be matched against :attr:`self.patterns <PathSpec.patterns>`. *separators* (:class:`~collections.abc.Collection` of :class:`str`) optionally contains the path separators to normal...
[ "def", "match_file", "(", "self", ",", "file", ",", "separators", "=", "None", ")", ":", "norm_file", "=", "util", ".", "normalize_file", "(", "file", ",", "separators", "=", "separators", ")", "return", "util", ".", "match_file", "(", "self", ".", "patt...
Matches the file to this path-spec. *file* (:class:`str`) is the file path to be matched against :attr:`self.patterns <PathSpec.patterns>`. *separators* (:class:`~collections.abc.Collection` of :class:`str`) optionally contains the path separators to normalize. See :func:`~pathspec.util.normalize_file` for ...
[ "Matches", "the", "file", "to", "this", "path", "-", "spec", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/pathspec.py#L77-L91
train
cpburnz/python-path-specification
pathspec/pathspec.py
PathSpec.match_files
def match_files(self, files, separators=None): """ Matches the files to this path-spec. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains the file paths to be matched against :attr:`self.patterns <PathSpec.patterns>`. *separators* (:class:`~collections.abc.Collection` of :class:`str`; ...
python
def match_files(self, files, separators=None): """ Matches the files to this path-spec. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains the file paths to be matched against :attr:`self.patterns <PathSpec.patterns>`. *separators* (:class:`~collections.abc.Collection` of :class:`str`; ...
[ "def", "match_files", "(", "self", ",", "files", ",", "separators", "=", "None", ")", ":", "if", "isinstance", "(", "files", ",", "(", "bytes", ",", "unicode", ")", ")", ":", "raise", "TypeError", "(", "\"files:{!r} is not an iterable.\"", ".", "format", "...
Matches the files to this path-spec. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains the file paths to be matched against :attr:`self.patterns <PathSpec.patterns>`. *separators* (:class:`~collections.abc.Collection` of :class:`str`; or :data:`None`) optionally contains the path separat...
[ "Matches", "the", "files", "to", "this", "path", "-", "spec", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/pathspec.py#L93-L115
train
cpburnz/python-path-specification
pathspec/pathspec.py
PathSpec.match_tree
def match_tree(self, root, on_error=None, follow_links=None): """ Walks the specified root path for all files and matches them to this path-spec. *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...
python
def match_tree(self, root, on_error=None, follow_links=None): """ Walks the specified root path for all files and matches them to this path-spec. *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...
[ "def", "match_tree", "(", "self", ",", "root", ",", "on_error", "=", "None", ",", "follow_links", "=", "None", ")", ":", "files", "=", "util", ".", "iter_tree", "(", "root", ",", "on_error", "=", "on_error", ",", "follow_links", "=", "follow_links", ")",...
Walks the specified root path for all files and matches them to this path-spec. *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. See :func:`~pathspec.util.iter_tree` fo...
[ "Walks", "the", "specified", "root", "path", "for", "all", "files", "and", "matches", "them", "to", "this", "path", "-", "spec", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/pathspec.py#L117-L137
train
cpburnz/python-path-specification
pathspec/patterns/gitwildmatch.py
GitWildMatchPattern.pattern_to_regex
def pattern_to_regex(cls, pattern): """ Convert the pattern into a regular expression. *pattern* (:class:`unicode` or :class:`bytes`) is the pattern to convert into a regular expression. Returns the uncompiled regular expression (:class:`unicode`, :class:`bytes`, or :data:`None`), and whether matched file...
python
def pattern_to_regex(cls, pattern): """ Convert the pattern into a regular expression. *pattern* (:class:`unicode` or :class:`bytes`) is the pattern to convert into a regular expression. Returns the uncompiled regular expression (:class:`unicode`, :class:`bytes`, or :data:`None`), and whether matched file...
[ "def", "pattern_to_regex", "(", "cls", ",", "pattern", ")", ":", "if", "isinstance", "(", "pattern", ",", "unicode", ")", ":", "return_type", "=", "unicode", "elif", "isinstance", "(", "pattern", ",", "bytes", ")", ":", "return_type", "=", "bytes", "patter...
Convert the pattern into a regular expression. *pattern* (:class:`unicode` or :class:`bytes`) is the pattern to convert into a regular expression. Returns the uncompiled regular expression (:class:`unicode`, :class:`bytes`, or :data:`None`), and whether matched files should be included (:data:`True`), exclu...
[ "Convert", "the", "pattern", "into", "a", "regular", "expression", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/patterns/gitwildmatch.py#L30-L174
train
cpburnz/python-path-specification
pathspec/patterns/gitwildmatch.py
GitWildMatchPattern._translate_segment_glob
def _translate_segment_glob(pattern): """ Translates the glob pattern to a regular expression. This is used in the constructor to translate a path segment glob pattern to its corresponding regular expression. *pattern* (:class:`str`) is the glob pattern. Returns the regular expression (:class:`str`). ""...
python
def _translate_segment_glob(pattern): """ Translates the glob pattern to a regular expression. This is used in the constructor to translate a path segment glob pattern to its corresponding regular expression. *pattern* (:class:`str`) is the glob pattern. Returns the regular expression (:class:`str`). ""...
[ "def", "_translate_segment_glob", "(", "pattern", ")", ":", "# NOTE: This is derived from `fnmatch.translate()` and is similar to", "# the POSIX function `fnmatch()` with the `FNM_PATHNAME` flag set.", "escape", "=", "False", "regex", "=", "''", "i", ",", "end", "=", "0", ",", ...
Translates the glob pattern to a regular expression. This is used in the constructor to translate a path segment glob pattern to its corresponding regular expression. *pattern* (:class:`str`) is the glob pattern. Returns the regular expression (:class:`str`).
[ "Translates", "the", "glob", "pattern", "to", "a", "regular", "expression", ".", "This", "is", "used", "in", "the", "constructor", "to", "translate", "a", "path", "segment", "glob", "pattern", "to", "its", "corresponding", "regular", "expression", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/patterns/gitwildmatch.py#L177-L280
train
cpburnz/python-path-specification
pathspec/patterns/gitwildmatch.py
GitIgnorePattern.pattern_to_regex
def pattern_to_regex(cls, *args, **kw): """ Warn about deprecation. """ cls._deprecated() return super(GitIgnorePattern, cls).pattern_to_regex(*args, **kw)
python
def pattern_to_regex(cls, *args, **kw): """ Warn about deprecation. """ cls._deprecated() return super(GitIgnorePattern, cls).pattern_to_regex(*args, **kw)
[ "def", "pattern_to_regex", "(", "cls", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "cls", ".", "_deprecated", "(", ")", "return", "super", "(", "GitIgnorePattern", ",", "cls", ")", ".", "pattern_to_regex", "(", "*", "args", ",", "*", "*", "kw", ...
Warn about deprecation.
[ "Warn", "about", "deprecation", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/patterns/gitwildmatch.py#L306-L311
train
cpburnz/python-path-specification
pathspec/util.py
iter_tree
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...
python
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", ")", ":", "if", "on_error", "is", "not", "None", "and", "not", "callable", "(", "on_error", ")", ":", "raise", "TypeError", "(", "\"on_error:{!r} is not callable...
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 ...
[ "Walks", "the", "specified", "directory", "for", "all", "files", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L27-L55
train
cpburnz/python-path-specification
pathspec/util.py
_iter_tree_next
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...
python
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", ")", ":", "dir_full", "=", "os", ".", "path", ".", "join", "(", "root_full", ",", "dir_rel", ")", "dir_real", "=", "os", ".", "path", ".", "r...
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``...
[ "Scan", "the", "directory", "for", "all", "descendant", "files", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L57-L126
train
cpburnz/python-path-specification
pathspec/util.py
match_file
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; ...
python
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", ")", ":", "matched", "=", "False", "for", "pattern", "in", "patterns", ":", "if", "pattern", ".", "include", "is", "not", "None", ":", "if", "file", "in", "pattern", ".", "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`.
[ "Matches", "the", "file", "to", "the", "patterns", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L139-L156
train
cpburnz/python-path-specification
pathspec/util.py
match_files
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...
python
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", ")", ":", "all_files", "=", "files", "if", "isinstance", "(", "files", ",", "collection_type", ")", "else", "list", "(", "files", ")", "return_files", "=", "set", "(", ")", "for", "pattern", "in", "pat...
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...
[ "Matches", "the", "files", "to", "the", "patterns", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L158-L179
train
cpburnz/python-path-specification
pathspec/util.py
normalize_file
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...
python
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", ")", ":", "# Normalize path separators.", "if", "separators", "is", "None", ":", "separators", "=", "NORMALIZE_PATH_SEPS", "norm_file", "=", "file", "for", "sep", "in", "separators", ":", "nor...
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 (``'/'...
[ "Normalizes", "the", "file", "path", "to", "use", "the", "POSIX", "path", "separator", "(", "i", ".", "e", ".", "/", ")", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L181-L207
train
cpburnz/python-path-specification
pathspec/util.py
normalize_files
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...
python
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", ")", ":", "norm_files", "=", "{", "}", "for", "path", "in", "files", ":", "norm_files", "[", "normalize_file", "(", "path", ",", "separators", "=", "separators", ")", "]", "=", "path...
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...
[ "Normalizes", "the", "file", "paths", "to", "use", "the", "POSIX", "path", "separator", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L209-L226
train
cpburnz/python-path-specification
pathspec/util.py
register_pattern
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`...
python
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", ")", ":", "if", "not", "isinstance", "(", "name", ",", "string_types", ")", ":", "raise", "TypeError", "(", "\"name:{!r} is not a string.\"", ".", "format", "(", "nam...
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...
[ "Registers", "the", "specified", "pattern", "factory", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L228-L250
train
cpburnz/python-path-specification
pathspec/util.py
RecursionError.message
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, )
python
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", ")", ":", "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", ".",...
*message* (:class:`str`) is the error message.
[ "*", "message", "*", "(", ":", "class", ":", "str", ")", "is", "the", "error", "message", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/util.py#L326-L334
train
cpburnz/python-path-specification
pathspec/pattern.py
Pattern.match
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 (:...
python
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", ")", ":", "raise", "NotImplementedError", "(", "\"{}.{} must override match().\"", ".", "format", "(", "self", ".", "__class__", ".", "__module__", ",", "self", ".", "__class__", ".", "__name__", ")", ")" ]
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`).
[ "Matches", "this", "pattern", "against", "the", "specified", "files", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/pattern.py#L35-L45
train
cpburnz/python-path-specification
pathspec/pattern.py
RegexPattern.match
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...
python
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", ")", ":", "if", "self", ".", "include", "is", "not", "None", ":", "for", "path", "in", "files", ":", "if", "self", ".", "regex", ".", "match", "(", "path", ")", "is", "not", "None", ":", "yield", "path" ...
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`).
[ "Matches", "this", "pattern", "against", "the", "specified", "files", "." ]
6fc7567a58cb68ec7d72cc287e7fb97dbe22c017
https://github.com/cpburnz/python-path-specification/blob/6fc7567a58cb68ec7d72cc287e7fb97dbe22c017/pathspec/pattern.py#L116-L129
train
jwhitlock/drf-cached-instances
sample_poll_app/cache.py
SampleCache.user_default_serializer
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...
python
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", ")", ":", "if", "not", "obj", ":", "return", "None", "self", ".", "user_default_add_related_pks", "(", "obj", ")", "return", "dict", "(", "(", "(", "'id'", ",", "obj", ".", "id", ")", ",", "(",...
Convert a User to a cached instance representation.
[ "Convert", "a", "User", "to", "a", "cached", "instance", "representation", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L13-L24
train
jwhitlock/drf-cached-instances
sample_poll_app/cache.py
SampleCache.user_default_loader
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
python
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", ")", ":", "try", ":", "obj", "=", "User", ".", "objects", ".", "get", "(", "pk", "=", "pk", ")", "except", "User", ".", "DoesNotExist", ":", "return", "None", "else", ":", "self", ".", "user_defau...
Load a User from the database.
[ "Load", "a", "User", "from", "the", "database", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L26-L34
train
jwhitlock/drf-cached-instances
sample_poll_app/cache.py
SampleCache.user_default_add_related_pks
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))
python
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", ")", ":", "if", "not", "hasattr", "(", "obj", ",", "'_votes_pks'", ")", ":", "obj", ".", "_votes_pks", "=", "list", "(", "obj", ".", "votes", ".", "values_list", "(", "'pk'", ",", "flat", ...
Add related primary keys to a User instance.
[ "Add", "related", "primary", "keys", "to", "a", "User", "instance", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L36-L39
train
jwhitlock/drf-cached-instances
sample_poll_app/cache.py
SampleCache.group_default_invalidator
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]
python
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", ")", ":", "user_pks", "=", "User", ".", "objects", ".", "values_list", "(", "'pk'", ",", "flat", "=", "True", ")", "return", "[", "(", "'User'", ",", "pk", ",", "False", ")", "for", "pk", "...
Invalidated cached items when the Group changes.
[ "Invalidated", "cached", "items", "when", "the", "Group", "changes", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L51-L54
train
jwhitlock/drf-cached-instances
sample_poll_app/cache.py
SampleCache.question_default_serializer
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), ...
python
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", ")", ":", "if", "not", "obj", ":", "return", "None", "self", ".", "question_default_add_related_pks", "(", "obj", ")", "return", "dict", "(", "(", "(", "'id'", ",", "obj", ".", "id", ")", ","...
Convert a Question to a cached instance representation.
[ "Convert", "a", "Question", "to", "a", "cached", "instance", "representation", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L60-L71
train
jwhitlock/drf-cached-instances
sample_poll_app/cache.py
SampleCache.question_default_loader
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
python
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", ")", ":", "try", ":", "obj", "=", "Question", ".", "objects", ".", "get", "(", "pk", "=", "pk", ")", "except", "Question", ".", "DoesNotExist", ":", "return", "None", "else", ":", "self", ".", ...
Load a Question from the database.
[ "Load", "a", "Question", "from", "the", "database", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L73-L81
train
jwhitlock/drf-cached-instances
sample_poll_app/cache.py
SampleCache.question_default_add_related_pks
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))
python
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", ")", ":", "if", "not", "hasattr", "(", "obj", ",", "'_choice_pks'", ")", ":", "obj", ".", "_choice_pks", "=", "list", "(", "obj", ".", "choices", ".", "values_list", "(", "'pk'", ",", "f...
Add related primary keys to a Question instance.
[ "Add", "related", "primary", "keys", "to", "a", "Question", "instance", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L83-L86
train
jwhitlock/drf-cached-instances
sample_poll_app/cache.py
SampleCache.choice_default_serializer
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...
python
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", ")", ":", "if", "not", "obj", ":", "return", "None", "self", ".", "choice_default_add_related_pks", "(", "obj", ")", "return", "dict", "(", "(", "(", "'id'", ",", "obj", ".", "id", ")", ",", ...
Convert a Choice to a cached instance representation.
[ "Convert", "a", "Choice", "to", "a", "cached", "instance", "representation", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L92-L104
train
jwhitlock/drf-cached-instances
sample_poll_app/cache.py
SampleCache.choice_default_loader
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
python
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", ")", ":", "try", ":", "obj", "=", "Choice", ".", "objects", ".", "get", "(", "pk", "=", "pk", ")", "except", "Choice", ".", "DoesNotExist", ":", "return", "None", "else", ":", "self", ".", "choi...
Load a Choice from the database.
[ "Load", "a", "Choice", "from", "the", "database", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L106-L114
train
jwhitlock/drf-cached-instances
sample_poll_app/cache.py
SampleCache.choice_default_add_related_pks
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)
python
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", ")", ":", "if", "not", "hasattr", "(", "obj", ",", "'_voter_pks'", ")", ":", "obj", ".", "_voter_pks", "=", "obj", ".", "voters", ".", "values_list", "(", "'pk'", ",", "flat", "=", "True",...
Add related primary keys to a Choice instance.
[ "Add", "related", "primary", "keys", "to", "a", "Choice", "instance", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L116-L119
train
jwhitlock/drf-cached-instances
sample_poll_app/cache.py
SampleCache.choice_default_invalidator
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
python
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", ")", ":", "invalid", "=", "[", "(", "'Question'", ",", "obj", ".", "question_id", ",", "True", ")", "]", "for", "pk", "in", "obj", ".", "voters", ".", "values_list", "(", "'pk'", ",", "flat"...
Invalidated cached items when the Choice changes.
[ "Invalidated", "cached", "items", "when", "the", "Choice", "changes", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/cache.py#L121-L126
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.cache
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...
python
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", ")", ":", "if", "not", "self", ".", "_cache", ":", "use_cache", "=", "getattr", "(", "settings", ",", "'USE_DRF_INSTANCE_CACHE'", ",", "True", ")", "if", "use_cache", ":", "from", "django", ".", "core", ".", "cache", "import"...
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.
[ "Get", "the", "Django", "cache", "interface", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L33-L45
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.delete_all_versions
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)
python
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", ")", ":", "if", "self", ".", "cache", ":", "for", "version", "in", "self", ".", "versions", ":", "key", "=", "self", ".", "key_for", "(", "version", ",", "model_name", ",", "o...
Delete all versions of a cached instance.
[ "Delete", "all", "versions", "of", "a", "cached", "instance", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L51-L56
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.model_function
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)
python
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", ")", ":", "assert", "func_name", "in", "(", "'serializer'", ",", "'loader'", ",", "'invalidator'", ")", "name", "=", "\"%s_%s_%s\"", "%", "(", "model_name", ".", "lowe...
Return the model-specific caching function.
[ "Return", "the", "model", "-", "specific", "caching", "function", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L58-L62
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.field_function
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)
python
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", ")", ":", "assert", "func_name", "in", "(", "'to_json'", ",", "'from_json'", ")", "name", "=", "\"field_%s_%s\"", "%", "(", "type_code", ".", "lower", "(", ")", ",", "func_name", ")"...
Return the field function.
[ "Return", "the", "field", "function", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L64-L68
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.field_to_json
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) ...
python
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", ")", ":", "assert", "':'", "not", "in", "key", "to_json", "=", "self", ".", "field_function", "(", "type_code", ",", "'to_json'", ")", "key_an...
Convert a field to a JSON-serializable representation.
[ "Convert", "a", "field", "to", "a", "JSON", "-", "serializable", "representation", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L70-L76
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.field_from_json
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) ...
python
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", ")", ":", "assert", "':'", "in", "key_and_type", "key", ",", "type_code", "=", "key_and_type", ".", "split", "(", "':'", ",", "1", ")", "from_json", "=", "self", ".", "field_fun...
Convert a JSON-serializable representation back to a field.
[ "Convert", "a", "JSON", "-", "serializable", "representation", "back", "to", "a", "field", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L78-L84
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.get_instances
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 ...
python
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", ")", ":", "ret", "=", "dict", "(", ")", "spec_keys", "=", "set", "(", ")", "cache_keys", "=", "[", "]", "version", "=", "version", "or", "self", ".", "default_versio...
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...
[ "Get", "the", "cached", "native", "representation", "for", "one", "or", "more", "objects", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L86-L157
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.update_instance
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...
python
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", ")", ":", "versions", "=", "[", "version", "]", "if", "version", "else", "self", ".", "ver...
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...
[ "Create", "or", "update", "a", "cached", "instance", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L159-L228
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.field_date_to_json
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
python
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", ")", ":", "if", "isinstance", "(", "day", ",", "six", ".", "string_types", ")", ":", "day", "=", "parse_date", "(", "day", ")", "return", "[", "day", ".", "year", ",", "day", ".", "month", ",", ...
Convert a date to a date triple.
[ "Convert", "a", "date", "to", "a", "date", "triple", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L238-L242
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.field_datetime_from_json
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...
python
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", ")", ":", "if", "type", "(", "json_val", ")", "==", "int", ":", "seconds", "=", "int", "(", "json_val", ")", "dt", "=", "datetime", ".", "fromtimestamp", "(", "seconds", ",", "utc", ")", ...
Convert a UTC timestamp to a UTC datetime.
[ "Convert", "a", "UTC", "timestamp", "to", "a", "UTC", "datetime", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L244-L255
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.field_datetime_to_json
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...
python
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", ")", ":", "if", "isinstance", "(", "dt", ",", "six", ".", "string_types", ")", ":", "dt", "=", "parse_datetime", "(", "dt", ")", "if", "not", "dt", ":", "return", "None", "ts", "=", "timegm", "...
Convert a datetime to a UTC timestamp w/ microsecond resolution. datetimes w/o timezone will be assumed to be in UTC
[ "Convert", "a", "datetime", "to", "a", "UTC", "timestamp", "w", "/", "microsecond", "resolution", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L257-L270
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.field_timedelta_from_json
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...
python
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", ")", ":", "if", "isinstance", "(", "json_val", ",", "str", ")", ":", "return", "timedelta", "(", "seconds", "=", "float", "(", "json_val", ")", ")", "elif", "json_val", "is", "None", ":", ...
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.
[ "Convert", "json_val", "to", "a", "timedelta", "object", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L272-L283
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.field_timedelta_to_json
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...
python
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", ")", ":", "if", "isinstance", "(", "td", ",", "six", ".", "string_types", ")", ":", "td", "=", "parse_duration", "(", "td", ")", "if", "not", "td", ":", "return", "None", "if", "td", ".", "mic...
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.
[ "Convert", "timedelta", "to", "value", "containing", "total", "number", "of", "seconds", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L285-L298
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.field_pklist_from_json
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'])
python
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", ")", ":", "model", "=", "get_model", "(", "data", "[", "'app'", "]", ",", "data", "[", "'model'", "]", ")", "return", "PkOnlyQueryset", "(", "self", ",", "model", ",", "data", "[", "'pks'", "]"...
Load a PkOnlyQueryset from a JSON dict. This uses the same format as cached_queryset_from_json
[ "Load", "a", "PkOnlyQueryset", "from", "a", "JSON", "dict", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L300-L306
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.field_pklist_to_json
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, ...
python
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", ")", ":", "app_label", "=", "model", ".", "_meta", ".", "app_label", "model_name", "=", "model", ".", "_meta", ".", "model_name", "return", "{", "'app'", ":", "app_label", ",", "'model'"...
Convert a list of primary keys to a JSON dict. This uses the same format as cached_queryset_to_json
[ "Convert", "a", "list", "of", "primary", "keys", "to", "a", "JSON", "dict", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L308-L319
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.field_pk_from_json
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'])
python
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", ")", ":", "model", "=", "get_model", "(", "data", "[", "'app'", "]", ",", "data", "[", "'model'", "]", ")", "return", "PkOnlyModel", "(", "self", ",", "model", ",", "data", "[", "'pk'", "]", ")" ...
Load a PkOnlyModel from a JSON dict.
[ "Load", "a", "PkOnlyModel", "from", "a", "JSON", "dict", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L321-L324
train
jwhitlock/drf-cached-instances
drf_cached_instances/cache.py
BaseCache.field_pk_to_json
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, }
python
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", ")", ":", "app_label", "=", "model", ".", "_meta", ".", "app_label", "model_name", "=", "model", ".", "_meta", ".", "model_name", "return", "{", "'app'", ":", "app_label", ",", "'model'", "...
Convert a primary key to a JSON dict.
[ "Convert", "a", "primary", "key", "to", "a", "JSON", "dict", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/cache.py#L326-L334
train
jwhitlock/drf-cached-instances
sample_poll_app/models.py
choice_voters_changed_update_cache
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...
python
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", ")", ":", "if", "action", "not", "in", "(", "'post_add'", ",", "'post_remove'", ",", "'post_clea...
Update cache when choice.voters changes.
[ "Update", "cache", "when", "choice", ".", "voters", "changes", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/models.py#L33-L60
train
jwhitlock/drf-cached-instances
sample_poll_app/models.py
post_delete_update_cache
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)
python
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", ")", ":", "name", "=", "sender", ".", "__name__", "if", "name", "in", "cached_model_names", ":", "from", ".", "tasks", "import", "update_cache_for_instance", "update_cach...
Update the cache when an instance is deleted.
[ "Update", "the", "cache", "when", "an", "instance", "is", "deleted", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/models.py#L64-L69
train
jwhitlock/drf-cached-instances
sample_poll_app/models.py
post_save_update_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: ...
python
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", ")", ":", "if", "raw", ":", "return", "name", "=", "sender", ".", "__name__", "if", "name", "in", "cached_model_names", ":", "delay_cache"...
Update the cache when an instance is created or modified.
[ "Update", "the", "cache", "when", "an", "instance", "is", "created", "or", "modified", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/models.py#L73-L82
train
jwhitlock/drf-cached-instances
drf_cached_instances/mixins.py
CachedViewMixin.get_queryset
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...
python
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", ")", ":", "queryset", "=", "super", "(", "CachedViewMixin", ",", "self", ")", ".", "get_queryset", "(", ")", "if", "self", ".", "action", "in", "(", "'list'", ",", "'retrieve'", ")", ":", "return", "CachedQueryset", "(...
Get the queryset for the action. If action is read action, return a CachedQueryset Otherwise, return a Django queryset
[ "Get", "the", "queryset", "for", "the", "action", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/mixins.py#L17-L27
train
jwhitlock/drf-cached-instances
drf_cached_instances/mixins.py
CachedViewMixin.get_object
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...
python
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", ")", ":", "# Determine the base queryset to use.", "assert", "queryset", "is", "None", ",", "\"Passing a queryset is disabled\"", "queryset", "=", "self", ".", "filter_queryset", "(", "self", ".", "get_...
Return the object the view is displaying. Same as rest_framework.generics.GenericAPIView, but: - Failed assertions instead of deprecations
[ "Return", "the", "object", "the", "view", "is", "displaying", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/mixins.py#L33-L54
train
jwhitlock/drf-cached-instances
drf_cached_instances/mixins.py
CachedViewMixin.get_object_or_404
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): ...
python
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", ")", ":", "if", "isinstance", "(", "queryset", ",", "CachedQueryset", ")", ":", "try", ":", "return", "queryset", ".", "get", "(", "*", "fi...
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.
[ "Return", "an", "object", "or", "raise", "a", "404", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/mixins.py#L56-L69
train
skorokithakis/jsane
jsane/traversable.py
Empty.r
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 ...
python
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", ")", ":", "# 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", "=",...
Resolve the object. This returns default (if present) or fails on an Empty.
[ "Resolve", "the", "object", "." ]
f63c01ab50899e207dae8427e4faef0e9d35e41e
https://github.com/skorokithakis/jsane/blob/f63c01ab50899e207dae8427e4faef0e9d35e41e/jsane/traversable.py#L35-L54
train
skorokithakis/jsane
jsane/traversable.py
Traversable.r
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...
python
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", ")", ":", "# 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", ...
Resolve the object. This will always succeed, since, if a lookup fails, an Empty instance will be returned farther upstream.
[ "Resolve", "the", "object", "." ]
f63c01ab50899e207dae8427e4faef0e9d35e41e
https://github.com/skorokithakis/jsane/blob/f63c01ab50899e207dae8427e4faef0e9d35e41e/jsane/traversable.py#L125-L140
train
jwhitlock/drf-cached-instances
sample_poll_app/tasks.py
update_cache_for_instance
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...
python
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", ")", ":", "cache", "=", "SampleCache", "(", ")", "invalid", "=", "cache", ".", "update_instance", "(", "model_name", ",", "i...
Update the cache for an instance, with cascading updates.
[ "Update", "the", "cache", "for", "an", "instance", "with", "cascading", "updates", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/sample_poll_app/tasks.py#L8-L15
train
jwhitlock/drf-cached-instances
drf_cached_instances/models.py
PkOnlyQueryset.values_list
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...
python
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", ")", ":", "flat", "=", "kwargs", ".", "pop", "(", "'flat'", ",", "False", ")", "assert", "flat", "is", "True", "assert", "len", "(", "args", ")", "==", "1", "assert", "...
Return the primary keys as a list. The only valid call is values_list('pk', flat=True)
[ "Return", "the", "primary", "keys", "as", "a", "list", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/models.py#L46-L55
train
jwhitlock/drf-cached-instances
drf_cached_instances/models.py
CachedQueryset.pks
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
python
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", ")", ":", "if", "self", ".", "_primary_keys", "is", "None", ":", "self", ".", "_primary_keys", "=", "list", "(", "self", ".", "queryset", ".", "values_list", "(", "'pk'", ",", "flat", "=", "True", ")", ")", "return", "self"...
Lazy-load the primary keys.
[ "Lazy", "-", "load", "the", "primary", "keys", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/models.py#L95-L100
train
jwhitlock/drf-cached-instances
drf_cached_instances/models.py
CachedQueryset.count
def count(self): """Return a count of instances.""" if self._primary_keys is None: return self.queryset.count() else: return len(self.pks)
python
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", ")", ":", "if", "self", ".", "_primary_keys", "is", "None", ":", "return", "self", ".", "queryset", ".", "count", "(", ")", "else", ":", "return", "len", "(", "self", ".", "pks", ")" ]
Return a count of instances.
[ "Return", "a", "count", "of", "instances", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/models.py#L119-L124
train
jwhitlock/drf-cached-instances
drf_cached_instances/models.py
CachedQueryset.filter
def filter(self, **kwargs): """Filter the base queryset.""" assert not self._primary_keys self.queryset = self.queryset.filter(**kwargs) return self
python
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", ")", ":", "assert", "not", "self", ".", "_primary_keys", "self", ".", "queryset", "=", "self", ".", "queryset", ".", "filter", "(", "*", "*", "kwargs", ")", "return", "self" ]
Filter the base queryset.
[ "Filter", "the", "base", "queryset", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/models.py#L126-L130
train
jwhitlock/drf-cached-instances
drf_cached_instances/models.py
CachedQueryset.get
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...
python
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", ")", ":", "assert", "not", "args", "assert", "list", "(", "kwargs", ".", "keys", "(", ")", ")", "==", "[", "'pk'", "]", "pk", "=", "kwargs", "[", "'pk'", "]", "model_name", "...
Return the single item from the filtered queryset.
[ "Return", "the", "single", "item", "from", "the", "filtered", "queryset", "." ]
ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a
https://github.com/jwhitlock/drf-cached-instances/blob/ec4e8a6e1e83eeea6ec0b924b2eaa40a38d5963a/drf_cached_instances/models.py#L132-L147
train
thorgate/tg-react
tg_react/webpack.py
WebpackConstants.collect
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...
python
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", ")", ":", "constants", "=", "{", "}", "for", "method_path", "in", "WebpackConstants", ".", "get_constant_processors", "(", ")", ":", "method", "=", "import_string", "(", "method_path", ")", "if", "not", "callable", "(", "method"...
Load all constant generators from settings.WEBPACK_CONSTANT_PROCESSORS and concat their values.
[ "Load", "all", "constant", "generators", "from", "settings", ".", "WEBPACK_CONSTANT_PROCESSORS", "and", "concat", "their", "values", "." ]
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/webpack.py#L23-L40
train
thorgate/tg-react
tg_react/api/accounts/serializers.py
phonenumber_validation
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...
python
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", ")", ":", "from", "phonenumber_field", ".", "phonenumber", "import", "to_python", "phone_number", "=", "to_python", "(", "data", ")", "if", "not", "phone_number", ":", "return", "data", "elif", "not", "phone_number", ...
Validates phonenumber Similar to phonenumber_field.validators.validate_international_phonenumber() but uses a different message if the country prefix is absent.
[ "Validates", "phonenumber" ]
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/api/accounts/serializers.py#L98-L113
train
thorgate/tg-react
tg_react/language.py
DjangoLocaleData.get_catalog
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_...
python
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", ")", ":", "with", "translation", ".", "override", "(", "locale", ")", ":", "translation_engine", "=", "DjangoTranslation", "(", "locale", ",", "domain", "=", "self", ".", "domain", ",", "localedirs", "=", "...
Create Django translation catalogue for `locale`.
[ "Create", "Django", "translation", "catalogue", "for", "locale", "." ]
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L28-L36
train
thorgate/tg-react
tg_react/language.py
DjangoLocaleData.get_paths
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...
python
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", ")", ":", "allowable_packages", "=", "dict", "(", "(", "app_config", ".", "name", ",", "app_config", ")", "for", "app_config", "in", "apps", ".", "get_app_configs", "(", ")", ")", "app_configs", "=", "[", ...
Create list of matching packages for translation engine.
[ "Create", "list", "of", "matching", "packages", "for", "translation", "engine", "." ]
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L39-L44
train
thorgate/tg-react
tg_react/language.py
DjangoLocaleData.get_catalogue_header_value
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...
python
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", ")", ":", "header_value", "=", "None", "if", "''", "in", "catalog", ":", "for", "line", "in", "catalog", "[", "''", "]", ".", "split", "(", "'\\n'", ")", ":", "if", "line", ...
Get `.po` header value.
[ "Get", ".", "po", "header", "value", "." ]
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L47-L55
train
thorgate/tg-react
tg_react/language.py
DjangoLocaleData._num_plurals
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]) ...
python
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", ")", ":", "match", "=", "re", ".", "search", "(", "r'nplurals=\\s*(\\d+)'", ",", "self", ".", "get_plural", "(", "catalogue", ")", "or", "''", ")", "if", "match", ":", "return", "int", "(", "match", ...
Return the number of plurals for this catalog language, or 2 if no plural string is available.
[ "Return", "the", "number", "of", "plurals", "for", "this", "catalog", "language", "or", "2", "if", "no", "plural", "string", "is", "available", "." ]
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L57-L65
train
thorgate/tg-react
tg_react/language.py
DjangoLocaleData.make_header
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'), ...
python
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", ")", ":", "return", "{", "\"po-revision-date\"", ":", "self", ".", "get_catalogue_header_value", "(", "catalog", ",", "'PO-Revision-Date'", ")", ",", "\"mime-version\"", ":", "self", ".", "get_cat...
Populate header with correct data from top-most locale file.
[ "Populate", "header", "with", "correct", "data", "from", "top", "-", "most", "locale", "file", "." ]
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L72-L89
train
thorgate/tg-react
tg_react/language.py
DjangoLocaleData.collect_translations
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...
python
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", ")", ":", "languages", "=", "{", "}", "locale_data", "=", "{", "}", "for", "language_code", ",", "label", "in", "settings", ".", "LANGUAGES", ":", "languages", "[", "language_code", "]", "=", "'%s'", "%", "label"...
Collect all `domain` translations and return `Tuple[languages, locale_data]`
[ "Collect", "all", "domain", "translations", "and", "return", "Tuple", "[", "languages", "locale_data", "]" ]
5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3
https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L91-L132
train
mieubrisse/wunderpy2
wunderpy2/endpoint_helpers.py
get_endpoint_obj
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()
python
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", ")", ":", "endpoint", "=", "'/'", ".", "join", "(", "[", "endpoint", ",", "str", "(", "object_id", ")", "]", ")", "return", "client", ".", "authenticated_request", "(", "endpoint"...
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
[ "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" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/endpoint_helpers.py#L1-L4
train
mieubrisse/wunderpy2
wunderpy2/endpoint_helpers.py
update_endpoint_obj
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...
python
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", ")", ":", "data", "[", "'revision'", "]", "=", "int", "(", "revision", ")", "endpoint", "=", "'/'", ".", "join", "(", "[", "endpoint", ",", "s...
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")
[ "Helper", "method", "to", "ease", "the", "repetitiveness", "of", "updating", "an", "...", "SO", "VERY", "DRY", "(", "That", "s", "a", "doubly", "-", "effective", "pun", "becuase", "my", "predecessor", "-", "https", ":", "//", "github", ".", "com", "/", ...
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/endpoint_helpers.py#L6-L14
train
mieubrisse/wunderpy2
wunderpy2/wunderapi.py
WunderApi._validate_response
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...
python
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", ")", ":", "# 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...
Helper method to validate the given to a Wunderlist API request is as expected
[ "Helper", "method", "to", "validate", "the", "given", "to", "a", "Wunderlist", "API", "request", "is", "as", "expected" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderapi.py#L34-L48
train
mieubrisse/wunderpy2
wunderpy2/wunderapi.py
WunderApi.request
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...
python
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", ")", ":", "if", "not", "headers", ":", "headers", "=", "{", "}", "if", "method", "in", ...
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...
[ "Send", "a", "request", "to", "the", "given", "Wunderlist", "API", "endpoint" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderapi.py#L50-L77
train
mieubrisse/wunderpy2
wunderpy2/wunderapi.py
WunderApi.get_access_token
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...
python
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", ")", ":", "headers", "=", "{", "'Content-Type'", ":", "'application/json'", "}", "data", "=", "{", "'client_id'", ":", "client_id", ",", "'client_secret'", ":", "clien...
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
[ "Exchange", "a", "temporary", "code", "for", "an", "access", "token", "allowing", "access", "to", "a", "user", "s", "account" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderapi.py#L79-L98
train
mieubrisse/wunderpy2
wunderpy2/wunderclient.py
WunderClient.authenticated_request
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...
python
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", ")", ":", "headers", "=", "{", "'X-Access-Token'", ":", "self", ".", "access_token", ",", "'X-Client-ID'", ":",...
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...
[ "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", ...
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L29-L45
train
mieubrisse/wunderpy2
wunderpy2/wunderclient.py
WunderClient.update_list
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)
python
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", ")", ":", "return", "lists_endpoint", ".", "update_list", "(", "self", ",", "list_id", ",", "revision", ",", "title", "=", "title",...
Updates the list with the given ID to have the given title and public flag
[ "Updates", "the", "list", "with", "the", "given", "ID", "to", "have", "the", "given", "title", "and", "public", "flag" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L59-L61
train
mieubrisse/wunderpy2
wunderpy2/wunderclient.py
WunderClient.get_tasks
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)
python
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", ")", ":", "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
[ "Gets", "tasks", "for", "the", "list", "with", "the", "given", "ID", "filtered", "by", "the", "given", "completion", "flag" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L67-L69
train
mieubrisse/wunderpy2
wunderpy2/wunderclient.py
WunderClient.create_task
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...
python
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", "=", ...
Creates a new task with the given information in the list with the given ID
[ "Creates", "a", "new", "task", "with", "the", "given", "information", "in", "the", "list", "with", "the", "given", "ID" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L75-L77
train
mieubrisse/wunderpy2
wunderpy2/wunderclient.py
WunderClient.update_task
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...
python
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", "=", ...
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']
[ "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", ".", ...
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L79-L85
train
mieubrisse/wunderpy2
wunderpy2/wunderclient.py
WunderClient.update_note
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)
python
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", ")", ":", "return", "notes_endpoint", ".", "update_note", "(", "self", ",", "note_id", ",", "revision", ",", "content", ")" ]
Updates the note with the given ID to have the given content
[ "Updates", "the", "note", "with", "the", "given", "ID", "to", "have", "the", "given", "content" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L116-L118
train
mieubrisse/wunderpy2
wunderpy2/wunderclient.py
WunderClient.get_task_subtasks
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)
python
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", ")", ":", "return", "subtasks_endpoint", ".", "get_task_subtasks", "(", "self", ",", "task_id", ",", "completed", "=", "completed", ")" ]
Gets subtasks for task with given ID
[ "Gets", "subtasks", "for", "task", "with", "given", "ID" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L130-L132
train
mieubrisse/wunderpy2
wunderpy2/wunderclient.py
WunderClient.get_list_subtasks
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)
python
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", ")", ":", "return", "subtasks_endpoint", ".", "get_list_subtasks", "(", "self", ",", "list_id", ",", "completed", "=", "completed", ")" ]
Gets subtasks for the list with given ID
[ "Gets", "subtasks", "for", "the", "list", "with", "given", "ID" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L134-L136
train
mieubrisse/wunderpy2
wunderpy2/wunderclient.py
WunderClient.create_subtask
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)
python
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", ")", ":", "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
[ "Creates", "a", "subtask", "with", "the", "given", "title", "under", "the", "task", "with", "the", "given", "ID", "Return", ":", "Newly", "-", "created", "subtask" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L142-L149
train
mieubrisse/wunderpy2
wunderpy2/wunderclient.py
WunderClient.update_subtask
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...
python
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", ")", ":", "return", "subtasks_endpoint", ".", "update_subtask", "(", "self", ",", "subtask_id", ",", "revision", ",", "title",...
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
[ "Updates", "the", "subtask", "with", "the", "given", "ID" ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L151-L160
train
mieubrisse/wunderpy2
wunderpy2/wunderclient.py
WunderClient.update_list_positions_obj
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...
python
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", ")", ":", "return", "positions_endpoints", ".", "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 for more info Return: The updated ListPositionsObj-mapped object defining t...
[ "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", "." ]
7106b6c13ca45ef4d56f805753c93258d5b822c2
https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L188-L197
train