partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
AssertionBuilder.does_not_contain_value
Asserts that val is a dict and does not contain the given value or values.
assertpy/assertpy.py
def does_not_contain_value(self, *values): """Asserts that val is a dict and does not contain the given value or values.""" self._check_dict_like(self.val, check_getitem=False) if len(values) == 0: raise ValueError('one or more value args must be given') else: fou...
def does_not_contain_value(self, *values): """Asserts that val is a dict and does not contain the given value or values.""" self._check_dict_like(self.val, check_getitem=False) if len(values) == 0: raise ValueError('one or more value args must be given') else: fou...
[ "Asserts", "that", "val", "is", "a", "dict", "and", "does", "not", "contain", "the", "given", "value", "or", "values", "." ]
ActivisionGameScience/assertpy
python
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L801-L813
[ "def", "does_not_contain_value", "(", "self", ",", "*", "values", ")", ":", "self", ".", "_check_dict_like", "(", "self", ".", "val", ",", "check_getitem", "=", "False", ")", "if", "len", "(", "values", ")", "==", "0", ":", "raise", "ValueError", "(", ...
08d799cdb01f9a25d3e20672efac991c7bc26d79
valid
AssertionBuilder.contains_entry
Asserts that val is a dict and contains the given entry or entries.
assertpy/assertpy.py
def contains_entry(self, *args, **kwargs): """Asserts that val is a dict and contains the given entry or entries.""" self._check_dict_like(self.val, check_values=False) entries = list(args) + [{k:v} for k,v in kwargs.items()] if len(entries) == 0: raise ValueError('one or mor...
def contains_entry(self, *args, **kwargs): """Asserts that val is a dict and contains the given entry or entries.""" self._check_dict_like(self.val, check_values=False) entries = list(args) + [{k:v} for k,v in kwargs.items()] if len(entries) == 0: raise ValueError('one or mor...
[ "Asserts", "that", "val", "is", "a", "dict", "and", "contains", "the", "given", "entry", "or", "entries", "." ]
ActivisionGameScience/assertpy
python
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L815-L834
[ "def", "contains_entry", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_dict_like", "(", "self", ".", "val", ",", "check_values", "=", "False", ")", "entries", "=", "list", "(", "args", ")", "+", "[", "{", "k...
08d799cdb01f9a25d3e20672efac991c7bc26d79
valid
AssertionBuilder.is_before
Asserts that val is a date and is before other date.
assertpy/assertpy.py
def is_before(self, other): """Asserts that val is a date and is before other date.""" if type(self.val) is not datetime.datetime: raise TypeError('val must be datetime, but was type <%s>' % type(self.val).__name__) if type(other) is not datetime.datetime: raise TypeError...
def is_before(self, other): """Asserts that val is a date and is before other date.""" if type(self.val) is not datetime.datetime: raise TypeError('val must be datetime, but was type <%s>' % type(self.val).__name__) if type(other) is not datetime.datetime: raise TypeError...
[ "Asserts", "that", "val", "is", "a", "date", "and", "is", "before", "other", "date", "." ]
ActivisionGameScience/assertpy
python
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L856-L864
[ "def", "is_before", "(", "self", ",", "other", ")", ":", "if", "type", "(", "self", ".", "val", ")", "is", "not", "datetime", ".", "datetime", ":", "raise", "TypeError", "(", "'val must be datetime, but was type <%s>'", "%", "type", "(", "self", ".", "val"...
08d799cdb01f9a25d3e20672efac991c7bc26d79
valid
AssertionBuilder.exists
Asserts that val is a path and that it exists.
assertpy/assertpy.py
def exists(self): """Asserts that val is a path and that it exists.""" if not isinstance(self.val, str_types): raise TypeError('val is not a path') if not os.path.exists(self.val): self._err('Expected <%s> to exist, but was not found.' % self.val) return self
def exists(self): """Asserts that val is a path and that it exists.""" if not isinstance(self.val, str_types): raise TypeError('val is not a path') if not os.path.exists(self.val): self._err('Expected <%s> to exist, but was not found.' % self.val) return self
[ "Asserts", "that", "val", "is", "a", "path", "and", "that", "it", "exists", "." ]
ActivisionGameScience/assertpy
python
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L904-L910
[ "def", "exists", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "val", ",", "str_types", ")", ":", "raise", "TypeError", "(", "'val is not a path'", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "val", ")"...
08d799cdb01f9a25d3e20672efac991c7bc26d79
valid
AssertionBuilder.is_file
Asserts that val is an existing path to a file.
assertpy/assertpy.py
def is_file(self): """Asserts that val is an existing path to a file.""" self.exists() if not os.path.isfile(self.val): self._err('Expected <%s> to be a file, but was not.' % self.val) return self
def is_file(self): """Asserts that val is an existing path to a file.""" self.exists() if not os.path.isfile(self.val): self._err('Expected <%s> to be a file, but was not.' % self.val) return self
[ "Asserts", "that", "val", "is", "an", "existing", "path", "to", "a", "file", "." ]
ActivisionGameScience/assertpy
python
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L920-L925
[ "def", "is_file", "(", "self", ")", ":", "self", ".", "exists", "(", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "self", ".", "val", ")", ":", "self", ".", "_err", "(", "'Expected <%s> to be a file, but was not.'", "%", "self", ".", "val",...
08d799cdb01f9a25d3e20672efac991c7bc26d79
valid
AssertionBuilder.is_directory
Asserts that val is an existing path to a directory.
assertpy/assertpy.py
def is_directory(self): """Asserts that val is an existing path to a directory.""" self.exists() if not os.path.isdir(self.val): self._err('Expected <%s> to be a directory, but was not.' % self.val) return self
def is_directory(self): """Asserts that val is an existing path to a directory.""" self.exists() if not os.path.isdir(self.val): self._err('Expected <%s> to be a directory, but was not.' % self.val) return self
[ "Asserts", "that", "val", "is", "an", "existing", "path", "to", "a", "directory", "." ]
ActivisionGameScience/assertpy
python
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L927-L932
[ "def", "is_directory", "(", "self", ")", ":", "self", ".", "exists", "(", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "val", ")", ":", "self", ".", "_err", "(", "'Expected <%s> to be a directory, but was not.'", "%", "self", ".",...
08d799cdb01f9a25d3e20672efac991c7bc26d79
valid
AssertionBuilder.is_named
Asserts that val is an existing path to a file and that file is named filename.
assertpy/assertpy.py
def is_named(self, filename): """Asserts that val is an existing path to a file and that file is named filename.""" self.is_file() if not isinstance(filename, str_types): raise TypeError('given filename arg must be a path') val_filename = os.path.basename(os.path.abspath(self...
def is_named(self, filename): """Asserts that val is an existing path to a file and that file is named filename.""" self.is_file() if not isinstance(filename, str_types): raise TypeError('given filename arg must be a path') val_filename = os.path.basename(os.path.abspath(self...
[ "Asserts", "that", "val", "is", "an", "existing", "path", "to", "a", "file", "and", "that", "file", "is", "named", "filename", "." ]
ActivisionGameScience/assertpy
python
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L934-L942
[ "def", "is_named", "(", "self", ",", "filename", ")", ":", "self", ".", "is_file", "(", ")", "if", "not", "isinstance", "(", "filename", ",", "str_types", ")", ":", "raise", "TypeError", "(", "'given filename arg must be a path'", ")", "val_filename", "=", "...
08d799cdb01f9a25d3e20672efac991c7bc26d79
valid
AssertionBuilder.is_child_of
Asserts that val is an existing path to a file and that file is a child of parent.
assertpy/assertpy.py
def is_child_of(self, parent): """Asserts that val is an existing path to a file and that file is a child of parent.""" self.is_file() if not isinstance(parent, str_types): raise TypeError('given parent directory arg must be a path') val_abspath = os.path.abspath(self.val) ...
def is_child_of(self, parent): """Asserts that val is an existing path to a file and that file is a child of parent.""" self.is_file() if not isinstance(parent, str_types): raise TypeError('given parent directory arg must be a path') val_abspath = os.path.abspath(self.val) ...
[ "Asserts", "that", "val", "is", "an", "existing", "path", "to", "a", "file", "and", "that", "file", "is", "a", "child", "of", "parent", "." ]
ActivisionGameScience/assertpy
python
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L944-L953
[ "def", "is_child_of", "(", "self", ",", "parent", ")", ":", "self", ".", "is_file", "(", ")", "if", "not", "isinstance", "(", "parent", ",", "str_types", ")", ":", "raise", "TypeError", "(", "'given parent directory arg must be a path'", ")", "val_abspath", "=...
08d799cdb01f9a25d3e20672efac991c7bc26d79
valid
AssertionBuilder.extracting
Asserts that val is collection, then extracts the named properties or named zero-arg methods into a list (or list of tuples if multiple names are given).
assertpy/assertpy.py
def extracting(self, *names, **kwargs): """Asserts that val is collection, then extracts the named properties or named zero-arg methods into a list (or list of tuples if multiple names are given).""" if not isinstance(self.val, Iterable): raise TypeError('val is not iterable') if isi...
def extracting(self, *names, **kwargs): """Asserts that val is collection, then extracts the named properties or named zero-arg methods into a list (or list of tuples if multiple names are given).""" if not isinstance(self.val, Iterable): raise TypeError('val is not iterable') if isi...
[ "Asserts", "that", "val", "is", "collection", "then", "extracts", "the", "named", "properties", "or", "named", "zero", "-", "arg", "methods", "into", "a", "list", "(", "or", "list", "of", "tuples", "if", "multiple", "names", "are", "given", ")", "." ]
ActivisionGameScience/assertpy
python
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L956-L1020
[ "def", "extracting", "(", "self", ",", "*", "names", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "self", ".", "val", ",", "Iterable", ")", ":", "raise", "TypeError", "(", "'val is not iterable'", ")", "if", "isinstance", "(", "se...
08d799cdb01f9a25d3e20672efac991c7bc26d79
valid
AssertionBuilder.raises
Asserts that val is callable and that when called raises the given error.
assertpy/assertpy.py
def raises(self, ex): """Asserts that val is callable and that when called raises the given error.""" if not callable(self.val): raise TypeError('val must be callable') if not issubclass(ex, BaseException): raise TypeError('given arg must be exception') return Ass...
def raises(self, ex): """Asserts that val is callable and that when called raises the given error.""" if not callable(self.val): raise TypeError('val must be callable') if not issubclass(ex, BaseException): raise TypeError('given arg must be exception') return Ass...
[ "Asserts", "that", "val", "is", "callable", "and", "that", "when", "called", "raises", "the", "given", "error", "." ]
ActivisionGameScience/assertpy
python
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L1067-L1073
[ "def", "raises", "(", "self", ",", "ex", ")", ":", "if", "not", "callable", "(", "self", ".", "val", ")", ":", "raise", "TypeError", "(", "'val must be callable'", ")", "if", "not", "issubclass", "(", "ex", ",", "BaseException", ")", ":", "raise", "Typ...
08d799cdb01f9a25d3e20672efac991c7bc26d79
valid
AssertionBuilder.when_called_with
Asserts the val callable when invoked with the given args and kwargs raises the expected exception.
assertpy/assertpy.py
def when_called_with(self, *some_args, **some_kwargs): """Asserts the val callable when invoked with the given args and kwargs raises the expected exception.""" if not self.expected: raise TypeError('expected exception not set, raises() must be called first') try: self.va...
def when_called_with(self, *some_args, **some_kwargs): """Asserts the val callable when invoked with the given args and kwargs raises the expected exception.""" if not self.expected: raise TypeError('expected exception not set, raises() must be called first') try: self.va...
[ "Asserts", "the", "val", "callable", "when", "invoked", "with", "the", "given", "args", "and", "kwargs", "raises", "the", "expected", "exception", "." ]
ActivisionGameScience/assertpy
python
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L1075-L1097
[ "def", "when_called_with", "(", "self", ",", "*", "some_args", ",", "*", "*", "some_kwargs", ")", ":", "if", "not", "self", ".", "expected", ":", "raise", "TypeError", "(", "'expected exception not set, raises() must be called first'", ")", "try", ":", "self", "...
08d799cdb01f9a25d3e20672efac991c7bc26d79
valid
AssertionBuilder._err
Helper to raise an AssertionError, and optionally prepend custom description.
assertpy/assertpy.py
def _err(self, msg): """Helper to raise an AssertionError, and optionally prepend custom description.""" out = '%s%s' % ('[%s] ' % self.description if len(self.description) > 0 else '', msg) if self.kind == 'warn': print(out) return self elif self.kind == 'soft': ...
def _err(self, msg): """Helper to raise an AssertionError, and optionally prepend custom description.""" out = '%s%s' % ('[%s] ' % self.description if len(self.description) > 0 else '', msg) if self.kind == 'warn': print(out) return self elif self.kind == 'soft': ...
[ "Helper", "to", "raise", "an", "AssertionError", "and", "optionally", "prepend", "custom", "description", "." ]
ActivisionGameScience/assertpy
python
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L1100-L1111
[ "def", "_err", "(", "self", ",", "msg", ")", ":", "out", "=", "'%s%s'", "%", "(", "'[%s] '", "%", "self", ".", "description", "if", "len", "(", "self", ".", "description", ")", ">", "0", "else", "''", ",", "msg", ")", "if", "self", ".", "kind", ...
08d799cdb01f9a25d3e20672efac991c7bc26d79
valid
AssertionBuilder._fmt_args_kwargs
Helper to convert the given args and kwargs into a string.
assertpy/assertpy.py
def _fmt_args_kwargs(self, *some_args, **some_kwargs): """Helper to convert the given args and kwargs into a string.""" if some_args: out_args = str(some_args).lstrip('(').rstrip(',)') if some_kwargs: out_kwargs = ', '.join([str(i).lstrip('(').rstrip(')').replace(', ',': ...
def _fmt_args_kwargs(self, *some_args, **some_kwargs): """Helper to convert the given args and kwargs into a string.""" if some_args: out_args = str(some_args).lstrip('(').rstrip(',)') if some_kwargs: out_kwargs = ', '.join([str(i).lstrip('(').rstrip(')').replace(', ',': ...
[ "Helper", "to", "convert", "the", "given", "args", "and", "kwargs", "into", "a", "string", "." ]
ActivisionGameScience/assertpy
python
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L1121-L1136
[ "def", "_fmt_args_kwargs", "(", "self", ",", "*", "some_args", ",", "*", "*", "some_kwargs", ")", ":", "if", "some_args", ":", "out_args", "=", "str", "(", "some_args", ")", ".", "lstrip", "(", "'('", ")", ".", "rstrip", "(", "',)'", ")", "if", "some...
08d799cdb01f9a25d3e20672efac991c7bc26d79
valid
generate_words
Transform list of files to list of words, removing new line character and replace name entity '<NE>...</NE>' and abbreviation '<AB>...</AB>' symbol
deepcut/train.py
def generate_words(files): """ Transform list of files to list of words, removing new line character and replace name entity '<NE>...</NE>' and abbreviation '<AB>...</AB>' symbol """ repls = {'<NE>' : '','</NE>' : '','<AB>': '','</AB>': ''} words_all = [] for i, file in enumerate(files...
def generate_words(files): """ Transform list of files to list of words, removing new line character and replace name entity '<NE>...</NE>' and abbreviation '<AB>...</AB>' symbol """ repls = {'<NE>' : '','</NE>' : '','<AB>': '','</AB>': ''} words_all = [] for i, file in enumerate(files...
[ "Transform", "list", "of", "files", "to", "list", "of", "words", "removing", "new", "line", "character", "and", "replace", "name", "entity", "<NE", ">", "...", "<", "/", "NE", ">", "and", "abbreviation", "<AB", ">", "...", "<", "/", "AB", ">", "symbol"...
rkcosmos/deepcut
python
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/train.py#L20-L36
[ "def", "generate_words", "(", "files", ")", ":", "repls", "=", "{", "'<NE>'", ":", "''", ",", "'</NE>'", ":", "''", ",", "'<AB>'", ":", "''", ",", "'</AB>'", ":", "''", "}", "words_all", "=", "[", "]", "for", "i", ",", "file", "in", "enumerate", ...
9a2729071d01972af805acede85d7aa9e7a6da30
valid
create_char_dataframe
Give list of input tokenized words, create dataframe of characters where first character of the word is tagged as 1, otherwise 0 Example ======= ['กิน', 'หมด'] to dataframe of [{'char': 'ก', 'type': ..., 'target': 1}, ..., {'char': 'ด', 'type': ..., 'target': 0}]
deepcut/train.py
def create_char_dataframe(words): """ Give list of input tokenized words, create dataframe of characters where first character of the word is tagged as 1, otherwise 0 Example ======= ['กิน', 'หมด'] to dataframe of [{'char': 'ก', 'type': ..., 'target': 1}, ..., {'char': 'ด', 'type':...
def create_char_dataframe(words): """ Give list of input tokenized words, create dataframe of characters where first character of the word is tagged as 1, otherwise 0 Example ======= ['กิน', 'หมด'] to dataframe of [{'char': 'ก', 'type': ..., 'target': 1}, ..., {'char': 'ด', 'type':...
[ "Give", "list", "of", "input", "tokenized", "words", "create", "dataframe", "of", "characters", "where", "first", "character", "of", "the", "word", "is", "tagged", "as", "1", "otherwise", "0" ]
rkcosmos/deepcut
python
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/train.py#L39-L62
[ "def", "create_char_dataframe", "(", "words", ")", ":", "char_dict", "=", "[", "]", "for", "word", "in", "words", ":", "for", "i", ",", "char", "in", "enumerate", "(", "word", ")", ":", "if", "i", "==", "0", ":", "char_dict", ".", "append", "(", "{...
9a2729071d01972af805acede85d7aa9e7a6da30
valid
generate_best_dataset
Generate CSV file for training and testing data Input ===== best_path: str, path to BEST folder which contains unzipped subfolder 'article', 'encyclopedia', 'news', 'novel' cleaned_data: str, path to output folder, the cleaned data will be saved in the given folder name where training ...
deepcut/train.py
def generate_best_dataset(best_path, output_path='cleaned_data', create_val=False): """ Generate CSV file for training and testing data Input ===== best_path: str, path to BEST folder which contains unzipped subfolder 'article', 'encyclopedia', 'news', 'novel' cleaned_data: str, path t...
def generate_best_dataset(best_path, output_path='cleaned_data', create_val=False): """ Generate CSV file for training and testing data Input ===== best_path: str, path to BEST folder which contains unzipped subfolder 'article', 'encyclopedia', 'news', 'novel' cleaned_data: str, path t...
[ "Generate", "CSV", "file", "for", "training", "and", "testing", "data" ]
rkcosmos/deepcut
python
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/train.py#L65-L104
[ "def", "generate_best_dataset", "(", "best_path", ",", "output_path", "=", "'cleaned_data'", ",", "create_val", "=", "False", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "output_path", ")", ":", "os", ".", "mkdir", "(", "output_path", ")",...
9a2729071d01972af805acede85d7aa9e7a6da30
valid
prepare_feature
Transform processed path into feature matrix and output array Input ===== best_processed_path: str, path to processed BEST dataset option: str, 'train' or 'test'
deepcut/train.py
def prepare_feature(best_processed_path, option='train'): """ Transform processed path into feature matrix and output array Input ===== best_processed_path: str, path to processed BEST dataset option: str, 'train' or 'test' """ # padding for training and testing set n_pad = 21 ...
def prepare_feature(best_processed_path, option='train'): """ Transform processed path into feature matrix and output array Input ===== best_processed_path: str, path to processed BEST dataset option: str, 'train' or 'test' """ # padding for training and testing set n_pad = 21 ...
[ "Transform", "processed", "path", "into", "feature", "matrix", "and", "output", "array" ]
rkcosmos/deepcut
python
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/train.py#L107-L142
[ "def", "prepare_feature", "(", "best_processed_path", ",", "option", "=", "'train'", ")", ":", "# padding for training and testing set", "n_pad", "=", "21", "n_pad_2", "=", "int", "(", "(", "n_pad", "-", "1", ")", "/", "2", ")", "pad", "=", "[", "{", "'cha...
9a2729071d01972af805acede85d7aa9e7a6da30
valid
train_model
Given path to processed BEST dataset, train CNN model for words beginning alongside with character label encoder and character type label encoder Input ===== best_processed_path: str, path to processed BEST dataset weight_path: str, path to weight path file verbose: int, verbost option for ...
deepcut/train.py
def train_model(best_processed_path, weight_path='../weight/model_weight.h5', verbose=2): """ Given path to processed BEST dataset, train CNN model for words beginning alongside with character label encoder and character type label encoder Input ===== best_processed_path: str, path to proce...
def train_model(best_processed_path, weight_path='../weight/model_weight.h5', verbose=2): """ Given path to processed BEST dataset, train CNN model for words beginning alongside with character label encoder and character type label encoder Input ===== best_processed_path: str, path to proce...
[ "Given", "path", "to", "processed", "BEST", "dataset", "train", "CNN", "model", "for", "words", "beginning", "alongside", "with", "character", "label", "encoder", "and", "character", "type", "label", "encoder" ]
rkcosmos/deepcut
python
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/train.py#L145-L201
[ "def", "train_model", "(", "best_processed_path", ",", "weight_path", "=", "'../weight/model_weight.h5'", ",", "verbose", "=", "2", ")", ":", "x_train_char", ",", "x_train_type", ",", "y_train", "=", "prepare_feature", "(", "best_processed_path", ",", "option", "=",...
9a2729071d01972af805acede85d7aa9e7a6da30
valid
evaluate
Evaluate model on splitted 10 percent testing set
deepcut/train.py
def evaluate(best_processed_path, model): """ Evaluate model on splitted 10 percent testing set """ x_test_char, x_test_type, y_test = prepare_feature(best_processed_path, option='test') y_predict = model.predict([x_test_char, x_test_type]) y_predict = (y_predict.ravel() > 0.5).astype(int) ...
def evaluate(best_processed_path, model): """ Evaluate model on splitted 10 percent testing set """ x_test_char, x_test_type, y_test = prepare_feature(best_processed_path, option='test') y_predict = model.predict([x_test_char, x_test_type]) y_predict = (y_predict.ravel() > 0.5).astype(int) ...
[ "Evaluate", "model", "on", "splitted", "10", "percent", "testing", "set" ]
rkcosmos/deepcut
python
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/train.py#L204-L217
[ "def", "evaluate", "(", "best_processed_path", ",", "model", ")", ":", "x_test_char", ",", "x_test_type", ",", "y_test", "=", "prepare_feature", "(", "best_processed_path", ",", "option", "=", "'test'", ")", "y_predict", "=", "model", ".", "predict", "(", "[",...
9a2729071d01972af805acede85d7aa9e7a6da30
valid
tokenize
Tokenize given Thai text string Input ===== text: str, Thai text string custom_dict: str (or list), path to customized dictionary file It allows the function not to tokenize given dictionary wrongly. The file should contain custom words separated by line. Alternatively, you can ...
deepcut/deepcut.py
def tokenize(text, custom_dict=None): """ Tokenize given Thai text string Input ===== text: str, Thai text string custom_dict: str (or list), path to customized dictionary file It allows the function not to tokenize given dictionary wrongly. The file should contain custom words ...
def tokenize(text, custom_dict=None): """ Tokenize given Thai text string Input ===== text: str, Thai text string custom_dict: str (or list), path to customized dictionary file It allows the function not to tokenize given dictionary wrongly. The file should contain custom words ...
[ "Tokenize", "given", "Thai", "text", "string" ]
rkcosmos/deepcut
python
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/deepcut.py#L23-L48
[ "def", "tokenize", "(", "text", ",", "custom_dict", "=", "None", ")", ":", "global", "TOKENIZER", "if", "not", "TOKENIZER", ":", "TOKENIZER", "=", "DeepcutTokenizer", "(", ")", "return", "TOKENIZER", ".", "tokenize", "(", "text", ",", "custom_dict", "=", "...
9a2729071d01972af805acede85d7aa9e7a6da30
valid
_document_frequency
Count the number of non-zero values for each feature in sparse X.
deepcut/deepcut.py
def _document_frequency(X): """ Count the number of non-zero values for each feature in sparse X. """ if sp.isspmatrix_csr(X): return np.bincount(X.indices, minlength=X.shape[1]) return np.diff(sp.csc_matrix(X, copy=False).indptr)
def _document_frequency(X): """ Count the number of non-zero values for each feature in sparse X. """ if sp.isspmatrix_csr(X): return np.bincount(X.indices, minlength=X.shape[1]) return np.diff(sp.csc_matrix(X, copy=False).indptr)
[ "Count", "the", "number", "of", "non", "-", "zero", "values", "for", "each", "feature", "in", "sparse", "X", "." ]
rkcosmos/deepcut
python
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/deepcut.py#L70-L76
[ "def", "_document_frequency", "(", "X", ")", ":", "if", "sp", ".", "isspmatrix_csr", "(", "X", ")", ":", "return", "np", ".", "bincount", "(", "X", ".", "indices", ",", "minlength", "=", "X", ".", "shape", "[", "1", "]", ")", "return", "np", ".", ...
9a2729071d01972af805acede85d7aa9e7a6da30
valid
_check_stop_list
Check stop words list ref: https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/feature_extraction/text.py#L87-L95
deepcut/deepcut.py
def _check_stop_list(stop): """ Check stop words list ref: https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/feature_extraction/text.py#L87-L95 """ if stop == "thai": return THAI_STOP_WORDS elif isinstance(stop, six.string_types): raise ValueError("not a built-in s...
def _check_stop_list(stop): """ Check stop words list ref: https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/feature_extraction/text.py#L87-L95 """ if stop == "thai": return THAI_STOP_WORDS elif isinstance(stop, six.string_types): raise ValueError("not a built-in s...
[ "Check", "stop", "words", "list", "ref", ":", "https", ":", "//", "github", ".", "com", "/", "scikit", "-", "learn", "/", "scikit", "-", "learn", "/", "blob", "/", "master", "/", "sklearn", "/", "feature_extraction", "/", "text", ".", "py#L87", "-", ...
rkcosmos/deepcut
python
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/deepcut.py#L79-L91
[ "def", "_check_stop_list", "(", "stop", ")", ":", "if", "stop", "==", "\"thai\"", ":", "return", "THAI_STOP_WORDS", "elif", "isinstance", "(", "stop", ",", "six", ".", "string_types", ")", ":", "raise", "ValueError", "(", "\"not a built-in stop list: %s\"", "%",...
9a2729071d01972af805acede85d7aa9e7a6da30
valid
DeepcutTokenizer._word_ngrams
Turn tokens into a tokens of n-grams ref: https://github.com/scikit-learn/scikit-learn/blob/ef5cb84a/sklearn/feature_extraction/text.py#L124-L153
deepcut/deepcut.py
def _word_ngrams(self, tokens): """ Turn tokens into a tokens of n-grams ref: https://github.com/scikit-learn/scikit-learn/blob/ef5cb84a/sklearn/feature_extraction/text.py#L124-L153 """ # handle stop words if self.stop_words is not None: tokens = [w for w in ...
def _word_ngrams(self, tokens): """ Turn tokens into a tokens of n-grams ref: https://github.com/scikit-learn/scikit-learn/blob/ef5cb84a/sklearn/feature_extraction/text.py#L124-L153 """ # handle stop words if self.stop_words is not None: tokens = [w for w in ...
[ "Turn", "tokens", "into", "a", "tokens", "of", "n", "-", "grams" ]
rkcosmos/deepcut
python
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/deepcut.py#L146-L179
[ "def", "_word_ngrams", "(", "self", ",", "tokens", ")", ":", "# handle stop words", "if", "self", ".", "stop_words", "is", "not", "None", ":", "tokens", "=", "[", "w", "for", "w", "in", "tokens", "if", "w", "not", "in", "self", ".", "stop_words", "]", ...
9a2729071d01972af805acede85d7aa9e7a6da30
valid
DeepcutTokenizer.fit_tranform
Transform given list of raw_documents to document-term matrix in sparse CSR format (see scipy)
deepcut/deepcut.py
def fit_tranform(self, raw_documents): """ Transform given list of raw_documents to document-term matrix in sparse CSR format (see scipy) """ X = self.transform(raw_documents, new_document=True) return X
def fit_tranform(self, raw_documents): """ Transform given list of raw_documents to document-term matrix in sparse CSR format (see scipy) """ X = self.transform(raw_documents, new_document=True) return X
[ "Transform", "given", "list", "of", "raw_documents", "to", "document", "-", "term", "matrix", "in", "sparse", "CSR", "format", "(", "see", "scipy", ")" ]
rkcosmos/deepcut
python
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/deepcut.py#L273-L279
[ "def", "fit_tranform", "(", "self", ",", "raw_documents", ")", ":", "X", "=", "self", ".", "transform", "(", "raw_documents", ",", "new_document", "=", "True", ")", "return", "X" ]
9a2729071d01972af805acede85d7aa9e7a6da30
valid
create_feature_array
Create feature array of character and surrounding characters
deepcut/utils.py
def create_feature_array(text, n_pad=21): """ Create feature array of character and surrounding characters """ n = len(text) n_pad_2 = int((n_pad - 1)/2) text_pad = [' '] * n_pad_2 + [t for t in text] + [' '] * n_pad_2 x_char, x_type = [], [] for i in range(n_pad_2, n_pad_2 + n): ...
def create_feature_array(text, n_pad=21): """ Create feature array of character and surrounding characters """ n = len(text) n_pad_2 = int((n_pad - 1)/2) text_pad = [' '] * n_pad_2 + [t for t in text] + [' '] * n_pad_2 x_char, x_type = [], [] for i in range(n_pad_2, n_pad_2 + n): ...
[ "Create", "feature", "array", "of", "character", "and", "surrounding", "characters" ]
rkcosmos/deepcut
python
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/utils.py#L55-L74
[ "def", "create_feature_array", "(", "text", ",", "n_pad", "=", "21", ")", ":", "n", "=", "len", "(", "text", ")", "n_pad_2", "=", "int", "(", "(", "n_pad", "-", "1", ")", "/", "2", ")", "text_pad", "=", "[", "' '", "]", "*", "n_pad_2", "+", "["...
9a2729071d01972af805acede85d7aa9e7a6da30
valid
create_n_gram_df
Given input dataframe, create feature dataframe of shifted characters
deepcut/utils.py
def create_n_gram_df(df, n_pad): """ Given input dataframe, create feature dataframe of shifted characters """ n_pad_2 = int((n_pad - 1)/2) for i in range(n_pad_2): df['char-{}'.format(i+1)] = df['char'].shift(i + 1) df['type-{}'.format(i+1)] = df['type'].shift(i + 1) df['cha...
def create_n_gram_df(df, n_pad): """ Given input dataframe, create feature dataframe of shifted characters """ n_pad_2 = int((n_pad - 1)/2) for i in range(n_pad_2): df['char-{}'.format(i+1)] = df['char'].shift(i + 1) df['type-{}'.format(i+1)] = df['type'].shift(i + 1) df['cha...
[ "Given", "input", "dataframe", "create", "feature", "dataframe", "of", "shifted", "characters" ]
rkcosmos/deepcut
python
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/utils.py#L77-L87
[ "def", "create_n_gram_df", "(", "df", ",", "n_pad", ")", ":", "n_pad_2", "=", "int", "(", "(", "n_pad", "-", "1", ")", "/", "2", ")", "for", "i", "in", "range", "(", "n_pad_2", ")", ":", "df", "[", "'char-{}'", ".", "format", "(", "i", "+", "1"...
9a2729071d01972af805acede85d7aa9e7a6da30
valid
Command._fetch_course_enrollment_data
Return enterprise customer UUID/user_id/course_run_id triples which represent CourseEnrollment records which do not have a matching EnterpriseCourseEnrollment record. The query used below looks for CourseEnrollment records that are associated with enterprise learners where the enrollment data i...
enterprise/management/commands/create_enterprise_course_enrollments.py
def _fetch_course_enrollment_data(self, enterprise_customer_uuid): """ Return enterprise customer UUID/user_id/course_run_id triples which represent CourseEnrollment records which do not have a matching EnterpriseCourseEnrollment record. The query used below looks for CourseEnrollment r...
def _fetch_course_enrollment_data(self, enterprise_customer_uuid): """ Return enterprise customer UUID/user_id/course_run_id triples which represent CourseEnrollment records which do not have a matching EnterpriseCourseEnrollment record. The query used below looks for CourseEnrollment r...
[ "Return", "enterprise", "customer", "UUID", "/", "user_id", "/", "course_run_id", "triples", "which", "represent", "CourseEnrollment", "records", "which", "do", "not", "have", "a", "matching", "EnterpriseCourseEnrollment", "record", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/management/commands/create_enterprise_course_enrollments.py#L77-L119
[ "def", "_fetch_course_enrollment_data", "(", "self", ",", "enterprise_customer_uuid", ")", ":", "query", "=", "'''\n SELECT\n au.id as user_id,\n ecu.enterprise_customer_id as enterprise_customer_uuid,\n sce.course_id as course_run_id\n ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
Command._dictfetchall
Return all rows from a cursor as a dict.
enterprise/management/commands/create_enterprise_course_enrollments.py
def _dictfetchall(self, cursor): """ Return all rows from a cursor as a dict. """ columns = [col[0] for col in cursor.description] return [ dict(zip(columns, row)) for row in cursor.fetchall() ]
def _dictfetchall(self, cursor): """ Return all rows from a cursor as a dict. """ columns = [col[0] for col in cursor.description] return [ dict(zip(columns, row)) for row in cursor.fetchall() ]
[ "Return", "all", "rows", "from", "a", "cursor", "as", "a", "dict", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/management/commands/create_enterprise_course_enrollments.py#L121-L127
[ "def", "_dictfetchall", "(", "self", ",", "cursor", ")", ":", "columns", "=", "[", "col", "[", "0", "]", "for", "col", "in", "cursor", ".", "description", "]", "return", "[", "dict", "(", "zip", "(", "columns", ",", "row", ")", ")", "for", "row", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
parse_lms_api_datetime
Parse a received datetime into a timezone-aware, Python datetime object. Arguments: datetime_string: A string to be parsed. datetime_format: A datetime format string to be used for parsing
enterprise/api_client/lms.py
def parse_lms_api_datetime(datetime_string, datetime_format=LMS_API_DATETIME_FORMAT): """ Parse a received datetime into a timezone-aware, Python datetime object. Arguments: datetime_string: A string to be parsed. datetime_format: A datetime format string to be used for parsing """ ...
def parse_lms_api_datetime(datetime_string, datetime_format=LMS_API_DATETIME_FORMAT): """ Parse a received datetime into a timezone-aware, Python datetime object. Arguments: datetime_string: A string to be parsed. datetime_format: A datetime format string to be used for parsing """ ...
[ "Parse", "a", "received", "datetime", "into", "a", "timezone", "-", "aware", "Python", "datetime", "object", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L483-L505
[ "def", "parse_lms_api_datetime", "(", "datetime_string", ",", "datetime_format", "=", "LMS_API_DATETIME_FORMAT", ")", ":", "if", "isinstance", "(", "datetime_string", ",", "datetime", ".", "datetime", ")", ":", "date_time", "=", "datetime_string", "else", ":", "try"...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
JwtLmsApiClient.connect
Connect to the REST API, authenticating with a JWT for the current user.
enterprise/api_client/lms.py
def connect(self): """ Connect to the REST API, authenticating with a JWT for the current user. """ if JwtBuilder is None: raise NotConnectedToOpenEdX("This package must be installed in an OpenEdX environment.") now = int(time()) jwt = JwtBuilder.create_jwt_f...
def connect(self): """ Connect to the REST API, authenticating with a JWT for the current user. """ if JwtBuilder is None: raise NotConnectedToOpenEdX("This package must be installed in an OpenEdX environment.") now = int(time()) jwt = JwtBuilder.create_jwt_f...
[ "Connect", "to", "the", "REST", "API", "authenticating", "with", "a", "JWT", "for", "the", "current", "user", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L78-L90
[ "def", "connect", "(", "self", ")", ":", "if", "JwtBuilder", "is", "None", ":", "raise", "NotConnectedToOpenEdX", "(", "\"This package must be installed in an OpenEdX environment.\"", ")", "now", "=", "int", "(", "time", "(", ")", ")", "jwt", "=", "JwtBuilder", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
JwtLmsApiClient.refresh_token
Use this method decorator to ensure the JWT token is refreshed when needed.
enterprise/api_client/lms.py
def refresh_token(func): """ Use this method decorator to ensure the JWT token is refreshed when needed. """ @wraps(func) def inner(self, *args, **kwargs): """ Before calling the wrapped function, we check if the JWT token is expired, and if so, re-connect...
def refresh_token(func): """ Use this method decorator to ensure the JWT token is refreshed when needed. """ @wraps(func) def inner(self, *args, **kwargs): """ Before calling the wrapped function, we check if the JWT token is expired, and if so, re-connect...
[ "Use", "this", "method", "decorator", "to", "ensure", "the", "JWT", "token", "is", "refreshed", "when", "needed", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L99-L111
[ "def", "refresh_token", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "inner", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n Before calling the wrapped function, we check if the JWT token is expired, and if so, ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EmbargoApiClient.redirect_if_blocked
Return redirect to embargo error page if the given user is blocked.
enterprise/api_client/lms.py
def redirect_if_blocked(course_run_ids, user=None, ip_address=None, url=None): """ Return redirect to embargo error page if the given user is blocked. """ for course_run_id in course_run_ids: redirect_url = embargo_api.redirect_if_blocked( CourseKey.from_strin...
def redirect_if_blocked(course_run_ids, user=None, ip_address=None, url=None): """ Return redirect to embargo error page if the given user is blocked. """ for course_run_id in course_run_ids: redirect_url = embargo_api.redirect_if_blocked( CourseKey.from_strin...
[ "Return", "redirect", "to", "embargo", "error", "page", "if", "the", "given", "user", "is", "blocked", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L120-L132
[ "def", "redirect_if_blocked", "(", "course_run_ids", ",", "user", "=", "None", ",", "ip_address", "=", "None", ",", "url", "=", "None", ")", ":", "for", "course_run_id", "in", "course_run_ids", ":", "redirect_url", "=", "embargo_api", ".", "redirect_if_blocked",...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnrollmentApiClient.get_course_details
Query the Enrollment API for the course details of the given course_id. Args: course_id (str): The string value of the course's unique identifier Returns: dict: A dictionary containing details about the course, in an enrollment context (allowed modes, etc.)
enterprise/api_client/lms.py
def get_course_details(self, course_id): """ Query the Enrollment API for the course details of the given course_id. Args: course_id (str): The string value of the course's unique identifier Returns: dict: A dictionary containing details about the course, in an ...
def get_course_details(self, course_id): """ Query the Enrollment API for the course details of the given course_id. Args: course_id (str): The string value of the course's unique identifier Returns: dict: A dictionary containing details about the course, in an ...
[ "Query", "the", "Enrollment", "API", "for", "the", "course", "details", "of", "the", "given", "course_id", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L142-L159
[ "def", "get_course_details", "(", "self", ",", "course_id", ")", ":", "try", ":", "return", "self", ".", "client", ".", "course", "(", "course_id", ")", ".", "get", "(", ")", "except", "(", "SlumberBaseException", ",", "ConnectionError", ",", "Timeout", ")...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnrollmentApiClient._sort_course_modes
Sort the course mode dictionaries by slug according to the COURSE_MODE_SORT_ORDER constant. Arguments: modes (list): A list of course mode dictionaries. Returns: list: A list with the course modes dictionaries sorted by slug.
enterprise/api_client/lms.py
def _sort_course_modes(self, modes): """ Sort the course mode dictionaries by slug according to the COURSE_MODE_SORT_ORDER constant. Arguments: modes (list): A list of course mode dictionaries. Returns: list: A list with the course modes dictionaries sorted by sl...
def _sort_course_modes(self, modes): """ Sort the course mode dictionaries by slug according to the COURSE_MODE_SORT_ORDER constant. Arguments: modes (list): A list of course mode dictionaries. Returns: list: A list with the course modes dictionaries sorted by sl...
[ "Sort", "the", "course", "mode", "dictionaries", "by", "slug", "according", "to", "the", "COURSE_MODE_SORT_ORDER", "constant", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L161-L181
[ "def", "_sort_course_modes", "(", "self", ",", "modes", ")", ":", "def", "slug_weight", "(", "mode", ")", ":", "\"\"\"\n Assign a weight to the course mode dictionary based on the position of its slug in the sorting list.\n \"\"\"", "sorting_slugs", "=", "COUR...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnrollmentApiClient.get_course_modes
Query the Enrollment API for the specific course modes that are available for the given course_id. Arguments: course_id (str): The string value of the course's unique identifier Returns: list: A list of course mode dictionaries.
enterprise/api_client/lms.py
def get_course_modes(self, course_id): """ Query the Enrollment API for the specific course modes that are available for the given course_id. Arguments: course_id (str): The string value of the course's unique identifier Returns: list: A list of course mode dict...
def get_course_modes(self, course_id): """ Query the Enrollment API for the specific course modes that are available for the given course_id. Arguments: course_id (str): The string value of the course's unique identifier Returns: list: A list of course mode dict...
[ "Query", "the", "Enrollment", "API", "for", "the", "specific", "course", "modes", "that", "are", "available", "for", "the", "given", "course_id", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L183-L196
[ "def", "get_course_modes", "(", "self", ",", "course_id", ")", ":", "details", "=", "self", ".", "get_course_details", "(", "course_id", ")", "modes", "=", "details", ".", "get", "(", "'course_modes'", ",", "[", "]", ")", "return", "self", ".", "_sort_cour...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnrollmentApiClient.has_course_mode
Query the Enrollment API to see whether a course run has a given course mode available. Arguments: course_run_id (str): The string value of the course run's unique identifier Returns: bool: Whether the course run has the given mode avaialble for enrollment.
enterprise/api_client/lms.py
def has_course_mode(self, course_run_id, mode): """ Query the Enrollment API to see whether a course run has a given course mode available. Arguments: course_run_id (str): The string value of the course run's unique identifier Returns: bool: Whether the course r...
def has_course_mode(self, course_run_id, mode): """ Query the Enrollment API to see whether a course run has a given course mode available. Arguments: course_run_id (str): The string value of the course run's unique identifier Returns: bool: Whether the course r...
[ "Query", "the", "Enrollment", "API", "to", "see", "whether", "a", "course", "run", "has", "a", "given", "course", "mode", "available", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L198-L210
[ "def", "has_course_mode", "(", "self", ",", "course_run_id", ",", "mode", ")", ":", "course_modes", "=", "self", ".", "get_course_modes", "(", "course_run_id", ")", "return", "any", "(", "course_mode", "for", "course_mode", "in", "course_modes", "if", "course_mo...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnrollmentApiClient.enroll_user_in_course
Call the enrollment API to enroll the user in the course specified by course_id. Args: username (str): The username by which the user goes on the OpenEdX platform course_id (str): The string value of the course's unique identifier mode (str): The enrollment mode which should...
enterprise/api_client/lms.py
def enroll_user_in_course(self, username, course_id, mode, cohort=None): """ Call the enrollment API to enroll the user in the course specified by course_id. Args: username (str): The username by which the user goes on the OpenEdX platform course_id (str): The string val...
def enroll_user_in_course(self, username, course_id, mode, cohort=None): """ Call the enrollment API to enroll the user in the course specified by course_id. Args: username (str): The username by which the user goes on the OpenEdX platform course_id (str): The string val...
[ "Call", "the", "enrollment", "API", "to", "enroll", "the", "user", "in", "the", "course", "specified", "by", "course_id", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L212-L233
[ "def", "enroll_user_in_course", "(", "self", ",", "username", ",", "course_id", ",", "mode", ",", "cohort", "=", "None", ")", ":", "return", "self", ".", "client", ".", "enrollment", ".", "post", "(", "{", "'user'", ":", "username", ",", "'course_details'"...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnrollmentApiClient.unenroll_user_from_course
Call the enrollment API to unenroll the user in the course specified by course_id. Args: username (str): The username by which the user goes on the OpenEdx platform course_id (str): The string value of the course's unique identifier Returns: bool: Whether the unenroll...
enterprise/api_client/lms.py
def unenroll_user_from_course(self, username, course_id): """ Call the enrollment API to unenroll the user in the course specified by course_id. Args: username (str): The username by which the user goes on the OpenEdx platform course_id (str): The string value of the cour...
def unenroll_user_from_course(self, username, course_id): """ Call the enrollment API to unenroll the user in the course specified by course_id. Args: username (str): The username by which the user goes on the OpenEdx platform course_id (str): The string value of the cour...
[ "Call", "the", "enrollment", "API", "to", "unenroll", "the", "user", "in", "the", "course", "specified", "by", "course_id", ".", "Args", ":", "username", "(", "str", ")", ":", "The", "username", "by", "which", "the", "user", "goes", "on", "the", "OpenEdx...
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L235-L254
[ "def", "unenroll_user_from_course", "(", "self", ",", "username", ",", "course_id", ")", ":", "enrollment", "=", "self", ".", "get_course_enrollment", "(", "username", ",", "course_id", ")", "if", "enrollment", "and", "enrollment", "[", "'is_active'", "]", ":", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnrollmentApiClient.get_course_enrollment
Query the enrollment API to get information about a single course enrollment. Args: username (str): The username by which the user goes on the OpenEdX platform course_id (str): The string value of the course's unique identifier Returns: dict: A dictionary containing...
enterprise/api_client/lms.py
def get_course_enrollment(self, username, course_id): """ Query the enrollment API to get information about a single course enrollment. Args: username (str): The username by which the user goes on the OpenEdX platform course_id (str): The string value of the course's uni...
def get_course_enrollment(self, username, course_id): """ Query the enrollment API to get information about a single course enrollment. Args: username (str): The username by which the user goes on the OpenEdX platform course_id (str): The string value of the course's uni...
[ "Query", "the", "enrollment", "API", "to", "get", "information", "about", "a", "single", "course", "enrollment", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L256-L288
[ "def", "get_course_enrollment", "(", "self", ",", "username", ",", "course_id", ")", ":", "endpoint", "=", "getattr", "(", "self", ".", "client", ".", "enrollment", ",", "'{username},{course_id}'", ".", "format", "(", "username", "=", "username", ",", "course_...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnrollmentApiClient.is_enrolled
Query the enrollment API and determine if a learner is enrolled in a course run. Args: username (str): The username by which the user goes on the OpenEdX platform course_run_id (str): The string value of the course's unique identifier Returns: bool: Indicating wheth...
enterprise/api_client/lms.py
def is_enrolled(self, username, course_run_id): """ Query the enrollment API and determine if a learner is enrolled in a course run. Args: username (str): The username by which the user goes on the OpenEdX platform course_run_id (str): The string value of the course's un...
def is_enrolled(self, username, course_run_id): """ Query the enrollment API and determine if a learner is enrolled in a course run. Args: username (str): The username by which the user goes on the OpenEdX platform course_run_id (str): The string value of the course's un...
[ "Query", "the", "enrollment", "API", "and", "determine", "if", "a", "learner", "is", "enrolled", "in", "a", "course", "run", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L290-L303
[ "def", "is_enrolled", "(", "self", ",", "username", ",", "course_run_id", ")", ":", "enrollment", "=", "self", ".", "get_course_enrollment", "(", "username", ",", "course_run_id", ")", "return", "enrollment", "is", "not", "None", "and", "enrollment", ".", "get...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ThirdPartyAuthApiClient._get_results
Calls the third party auth api endpoint to get the mapping between usernames and remote ids.
enterprise/api_client/lms.py
def _get_results(self, identity_provider, param_name, param_value, result_field_name): """ Calls the third party auth api endpoint to get the mapping between usernames and remote ids. """ try: kwargs = {param_name: param_value} returned = self.client.providers(ide...
def _get_results(self, identity_provider, param_name, param_value, result_field_name): """ Calls the third party auth api endpoint to get the mapping between usernames and remote ids. """ try: kwargs = {param_name: param_value} returned = self.client.providers(ide...
[ "Calls", "the", "third", "party", "auth", "api", "endpoint", "to", "get", "the", "mapping", "between", "usernames", "and", "remote", "ids", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L377-L398
[ "def", "_get_results", "(", "self", ",", "identity_provider", ",", "param_name", ",", "param_value", ",", "result_field_name", ")", ":", "try", ":", "kwargs", "=", "{", "param_name", ":", "param_value", "}", "returned", "=", "self", ".", "client", ".", "prov...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
GradesApiClient.get_course_grade
Retrieve the grade for the given username for the given course_id. Args: * ``course_id`` (str): The string value of the course's unique identifier * ``username`` (str): The username ID identifying the user for which to retrieve the grade. Raises: HttpNotFoundError if no grade ...
enterprise/api_client/lms.py
def get_course_grade(self, course_id, username): """ Retrieve the grade for the given username for the given course_id. Args: * ``course_id`` (str): The string value of the course's unique identifier * ``username`` (str): The username ID identifying the user for which to retriev...
def get_course_grade(self, course_id, username): """ Retrieve the grade for the given username for the given course_id. Args: * ``course_id`` (str): The string value of the course's unique identifier * ``username`` (str): The username ID identifying the user for which to retriev...
[ "Retrieve", "the", "grade", "for", "the", "given", "username", "for", "the", "given", "course_id", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L412-L440
[ "def", "get_course_grade", "(", "self", ",", "course_id", ",", "username", ")", ":", "results", "=", "self", ".", "client", ".", "courses", "(", "course_id", ")", ".", "get", "(", "username", "=", "username", ")", "for", "row", "in", "results", ":", "i...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CertificatesApiClient.get_course_certificate
Retrieve the certificate for the given username for the given course_id. Args: * ``course_id`` (str): The string value of the course's unique identifier * ``username`` (str): The username ID identifying the user for which to retrieve the certificate Raises: HttpNotFoundError i...
enterprise/api_client/lms.py
def get_course_certificate(self, course_id, username): """ Retrieve the certificate for the given username for the given course_id. Args: * ``course_id`` (str): The string value of the course's unique identifier * ``username`` (str): The username ID identifying the user for whic...
def get_course_certificate(self, course_id, username): """ Retrieve the certificate for the given username for the given course_id. Args: * ``course_id`` (str): The string value of the course's unique identifier * ``username`` (str): The username ID identifying the user for whic...
[ "Retrieve", "the", "certificate", "for", "the", "given", "username", "for", "the", "given", "course_id", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/lms.py#L454-L480
[ "def", "get_course_certificate", "(", "self", ",", "course_id", ",", "username", ")", ":", "return", "self", ".", "client", ".", "certificates", "(", "username", ")", ".", "courses", "(", "course_id", ")", ".", "get", "(", ")" ]
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
course_discovery_api_client
Return a Course Discovery API client setup with authentication for the specified user.
enterprise/api_client/discovery.py
def course_discovery_api_client(user, catalog_url): """ Return a Course Discovery API client setup with authentication for the specified user. """ if JwtBuilder is None: raise NotConnectedToOpenEdX( _("To get a Catalog API client, this package must be " "installed in an...
def course_discovery_api_client(user, catalog_url): """ Return a Course Discovery API client setup with authentication for the specified user. """ if JwtBuilder is None: raise NotConnectedToOpenEdX( _("To get a Catalog API client, this package must be " "installed in an...
[ "Return", "a", "Course", "Discovery", "API", "client", "setup", "with", "authentication", "for", "the", "specified", "user", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L45-L56
[ "def", "course_discovery_api_client", "(", "user", ",", "catalog_url", ")", ":", "if", "JwtBuilder", "is", "None", ":", "raise", "NotConnectedToOpenEdX", "(", "_", "(", "\"To get a Catalog API client, this package must be \"", "\"installed in an Open edX environment.\"", ")",...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.traverse_pagination
Traverse a paginated API response and extracts and concatenates "results" returned by API. Arguments: response (dict): API response object. endpoint (Slumber.Resource): API endpoint object. content_filter_query (dict): query parameters used to filter catalog results. ...
enterprise/api_client/discovery.py
def traverse_pagination(response, endpoint, content_filter_query, query_params): """ Traverse a paginated API response and extracts and concatenates "results" returned by API. Arguments: response (dict): API response object. endpoint (Slumber.Resource): API endpoint obje...
def traverse_pagination(response, endpoint, content_filter_query, query_params): """ Traverse a paginated API response and extracts and concatenates "results" returned by API. Arguments: response (dict): API response object. endpoint (Slumber.Resource): API endpoint obje...
[ "Traverse", "a", "paginated", "API", "response", "and", "extracts", "and", "concatenates", "results", "returned", "by", "API", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L102-L123
[ "def", "traverse_pagination", "(", "response", ",", "endpoint", ",", "content_filter_query", ",", "query_params", ")", ":", "results", "=", "response", ".", "get", "(", "'results'", ",", "[", "]", ")", "page", "=", "1", "while", "response", ".", "get", "("...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.get_catalog_results
Return results from the discovery service's search/all endpoint. Arguments: content_filter_query (dict): query parameters used to filter catalog results. query_params (dict): query parameters used to paginate results. traverse_pagination (bool): True to return all results, F...
enterprise/api_client/discovery.py
def get_catalog_results(self, content_filter_query, query_params=None, traverse_pagination=False): """ Return results from the discovery service's search/all endpoint. Arguments: content_filter_query (dict): query parameters used to filter catalog results. query_params (...
def get_catalog_results(self, content_filter_query, query_params=None, traverse_pagination=False): """ Return results from the discovery service's search/all endpoint. Arguments: content_filter_query (dict): query parameters used to filter catalog results. query_params (...
[ "Return", "results", "from", "the", "discovery", "service", "s", "search", "/", "all", "endpoint", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L125-L159
[ "def", "get_catalog_results", "(", "self", ",", "content_filter_query", ",", "query_params", "=", "None", ",", "traverse_pagination", "=", "False", ")", ":", "query_params", "=", "query_params", "or", "{", "}", "try", ":", "endpoint", "=", "getattr", "(", "sel...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.get_catalog
Return specified course catalog. Returns: dict: catalog details if it is available for the user.
enterprise/api_client/discovery.py
def get_catalog(self, catalog_id): """ Return specified course catalog. Returns: dict: catalog details if it is available for the user. """ return self._load_data( self.CATALOGS_ENDPOINT, default=[], resource_id=catalog_id ...
def get_catalog(self, catalog_id): """ Return specified course catalog. Returns: dict: catalog details if it is available for the user. """ return self._load_data( self.CATALOGS_ENDPOINT, default=[], resource_id=catalog_id ...
[ "Return", "specified", "course", "catalog", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L174-L186
[ "def", "get_catalog", "(", "self", ",", "catalog_id", ")", ":", "return", "self", ".", "_load_data", "(", "self", ".", "CATALOGS_ENDPOINT", ",", "default", "=", "[", "]", ",", "resource_id", "=", "catalog_id", ")" ]
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.get_paginated_catalog_courses
Return paginated response for all catalog courses. Returns: dict: API response with links to next and previous pages.
enterprise/api_client/discovery.py
def get_paginated_catalog_courses(self, catalog_id, querystring=None): """ Return paginated response for all catalog courses. Returns: dict: API response with links to next and previous pages. """ return self._load_data( self.CATALOGS_COURSES_ENDPOINT.fo...
def get_paginated_catalog_courses(self, catalog_id, querystring=None): """ Return paginated response for all catalog courses. Returns: dict: API response with links to next and previous pages. """ return self._load_data( self.CATALOGS_COURSES_ENDPOINT.fo...
[ "Return", "paginated", "response", "for", "all", "catalog", "courses", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L188-L202
[ "def", "get_paginated_catalog_courses", "(", "self", ",", "catalog_id", ",", "querystring", "=", "None", ")", ":", "return", "self", ".", "_load_data", "(", "self", ".", "CATALOGS_COURSES_ENDPOINT", ".", "format", "(", "catalog_id", ")", ",", "default", "=", "...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.get_paginated_catalogs
Return a paginated list of course catalogs, including name and ID. Returns: dict: Paginated response containing catalogs available for the user.
enterprise/api_client/discovery.py
def get_paginated_catalogs(self, querystring=None): """ Return a paginated list of course catalogs, including name and ID. Returns: dict: Paginated response containing catalogs available for the user. """ return self._load_data( self.CATALOGS_ENDPOINT, ...
def get_paginated_catalogs(self, querystring=None): """ Return a paginated list of course catalogs, including name and ID. Returns: dict: Paginated response containing catalogs available for the user. """ return self._load_data( self.CATALOGS_ENDPOINT, ...
[ "Return", "a", "paginated", "list", "of", "course", "catalogs", "including", "name", "and", "ID", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L204-L218
[ "def", "get_paginated_catalogs", "(", "self", ",", "querystring", "=", "None", ")", ":", "return", "self", ".", "_load_data", "(", "self", ".", "CATALOGS_ENDPOINT", ",", "default", "=", "[", "]", ",", "querystring", "=", "querystring", ",", "traverse_paginatio...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.get_catalog_courses
Return the courses included in a single course catalog by ID. Args: catalog_id (int): The catalog ID we want to retrieve. Returns: list: Courses of the catalog in question
enterprise/api_client/discovery.py
def get_catalog_courses(self, catalog_id): """ Return the courses included in a single course catalog by ID. Args: catalog_id (int): The catalog ID we want to retrieve. Returns: list: Courses of the catalog in question """ return self._load_data...
def get_catalog_courses(self, catalog_id): """ Return the courses included in a single course catalog by ID. Args: catalog_id (int): The catalog ID we want to retrieve. Returns: list: Courses of the catalog in question """ return self._load_data...
[ "Return", "the", "courses", "included", "in", "a", "single", "course", "catalog", "by", "ID", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L220-L234
[ "def", "get_catalog_courses", "(", "self", ",", "catalog_id", ")", ":", "return", "self", ".", "_load_data", "(", "self", ".", "CATALOGS_COURSES_ENDPOINT", ".", "format", "(", "catalog_id", ")", ",", "default", "=", "[", "]", ")" ]
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.get_course_and_course_run
Return the course and course run metadata for the given course run ID. Arguments: course_run_id (str): The course run ID. Returns: tuple: The course metadata and the course run metadata.
enterprise/api_client/discovery.py
def get_course_and_course_run(self, course_run_id): """ Return the course and course run metadata for the given course run ID. Arguments: course_run_id (str): The course run ID. Returns: tuple: The course metadata and the course run metadata. """ ...
def get_course_and_course_run(self, course_run_id): """ Return the course and course run metadata for the given course run ID. Arguments: course_run_id (str): The course run ID. Returns: tuple: The course metadata and the course run metadata. """ ...
[ "Return", "the", "course", "and", "course", "run", "metadata", "for", "the", "given", "course", "run", "ID", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L236-L259
[ "def", "get_course_and_course_run", "(", "self", ",", "course_run_id", ")", ":", "# Parse the course ID from the course run ID.", "course_id", "=", "parse_course_key", "(", "course_run_id", ")", "# Retrieve the course metadata from the catalog service.", "course", "=", "self", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.get_course_details
Return the details of a single course by id - not a course run id. Args: course_id (str): The unique id for the course in question. Returns: dict: Details of the course in question.
enterprise/api_client/discovery.py
def get_course_details(self, course_id): """ Return the details of a single course by id - not a course run id. Args: course_id (str): The unique id for the course in question. Returns: dict: Details of the course in question. """ return self._l...
def get_course_details(self, course_id): """ Return the details of a single course by id - not a course run id. Args: course_id (str): The unique id for the course in question. Returns: dict: Details of the course in question. """ return self._l...
[ "Return", "the", "details", "of", "a", "single", "course", "by", "id", "-", "not", "a", "course", "run", "id", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L261-L276
[ "def", "get_course_details", "(", "self", ",", "course_id", ")", ":", "return", "self", ".", "_load_data", "(", "self", ".", "COURSES_ENDPOINT", ",", "resource_id", "=", "course_id", ",", "many", "=", "False", ")" ]
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.get_program_by_title
Return single program by name, or None if not found. Arguments: program_title(string): Program title as seen by students and in Course Catalog Admin Returns: dict: Program data provided by Course Catalog API
enterprise/api_client/discovery.py
def get_program_by_title(self, program_title): """ Return single program by name, or None if not found. Arguments: program_title(string): Program title as seen by students and in Course Catalog Admin Returns: dict: Program data provided by Course Catalog API ...
def get_program_by_title(self, program_title): """ Return single program by name, or None if not found. Arguments: program_title(string): Program title as seen by students and in Course Catalog Admin Returns: dict: Program data provided by Course Catalog API ...
[ "Return", "single", "program", "by", "name", "or", "None", "if", "not", "found", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L294-L312
[ "def", "get_program_by_title", "(", "self", ",", "program_title", ")", ":", "all_programs", "=", "self", ".", "_load_data", "(", "self", ".", "PROGRAMS_ENDPOINT", ",", "default", "=", "[", "]", ")", "matching_programs", "=", "[", "program", "for", "program", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.get_program_by_uuid
Return single program by UUID, or None if not found. Arguments: program_uuid(string): Program UUID in string form Returns: dict: Program data provided by Course Catalog API
enterprise/api_client/discovery.py
def get_program_by_uuid(self, program_uuid): """ Return single program by UUID, or None if not found. Arguments: program_uuid(string): Program UUID in string form Returns: dict: Program data provided by Course Catalog API """ return self._load_d...
def get_program_by_uuid(self, program_uuid): """ Return single program by UUID, or None if not found. Arguments: program_uuid(string): Program UUID in string form Returns: dict: Program data provided by Course Catalog API """ return self._load_d...
[ "Return", "single", "program", "by", "UUID", "or", "None", "if", "not", "found", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L314-L329
[ "def", "get_program_by_uuid", "(", "self", ",", "program_uuid", ")", ":", "return", "self", ".", "_load_data", "(", "self", ".", "PROGRAMS_ENDPOINT", ",", "resource_id", "=", "program_uuid", ",", "default", "=", "None", ")" ]
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.get_program_course_keys
Get a list of the course IDs (not course run IDs) contained in the program. Arguments: program_uuid (str): Program UUID in string form Returns: list(str): List of course keys in string form that are included in the program
enterprise/api_client/discovery.py
def get_program_course_keys(self, program_uuid): """ Get a list of the course IDs (not course run IDs) contained in the program. Arguments: program_uuid (str): Program UUID in string form Returns: list(str): List of course keys in string form that are included i...
def get_program_course_keys(self, program_uuid): """ Get a list of the course IDs (not course run IDs) contained in the program. Arguments: program_uuid (str): Program UUID in string form Returns: list(str): List of course keys in string form that are included i...
[ "Get", "a", "list", "of", "the", "course", "IDs", "(", "not", "course", "run", "IDs", ")", "contained", "in", "the", "program", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L331-L345
[ "def", "get_program_course_keys", "(", "self", ",", "program_uuid", ")", ":", "program_details", "=", "self", ".", "get_program_by_uuid", "(", "program_uuid", ")", "if", "not", "program_details", ":", "return", "[", "]", "return", "[", "course", "[", "'key'", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.get_program_type_by_slug
Get a program type by its slug. Arguments: slug (str): The slug to identify the program type. Returns: dict: A program type object.
enterprise/api_client/discovery.py
def get_program_type_by_slug(self, slug): """ Get a program type by its slug. Arguments: slug (str): The slug to identify the program type. Returns: dict: A program type object. """ return self._load_data( self.PROGRAM_TYPES_ENDPOINT...
def get_program_type_by_slug(self, slug): """ Get a program type by its slug. Arguments: slug (str): The slug to identify the program type. Returns: dict: A program type object. """ return self._load_data( self.PROGRAM_TYPES_ENDPOINT...
[ "Get", "a", "program", "type", "by", "its", "slug", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L347-L362
[ "def", "get_program_type_by_slug", "(", "self", ",", "slug", ")", ":", "return", "self", ".", "_load_data", "(", "self", ".", "PROGRAM_TYPES_ENDPOINT", ",", "resource_id", "=", "slug", ",", "default", "=", "None", ",", ")" ]
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.get_common_course_modes
Find common course modes for a set of course runs. This function essentially returns an intersection of types of seats available for each course run. Arguments: course_run_ids(Iterable[str]): Target Course run IDs. Returns: set: course modes found in all given ...
enterprise/api_client/discovery.py
def get_common_course_modes(self, course_run_ids): """ Find common course modes for a set of course runs. This function essentially returns an intersection of types of seats available for each course run. Arguments: course_run_ids(Iterable[str]): Target Course run I...
def get_common_course_modes(self, course_run_ids): """ Find common course modes for a set of course runs. This function essentially returns an intersection of types of seats available for each course run. Arguments: course_run_ids(Iterable[str]): Target Course run I...
[ "Find", "common", "course", "modes", "for", "a", "set", "of", "course", "runs", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L364-L416
[ "def", "get_common_course_modes", "(", "self", ",", "course_run_ids", ")", ":", "available_course_modes", "=", "None", "for", "course_run_id", "in", "course_run_ids", ":", "course_run", "=", "self", ".", "get_course_run", "(", "course_run_id", ")", "or", "{", "}",...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient.is_course_in_catalog
Determine if the given course or course run ID is contained in the catalog with the given ID. Args: catalog_id (int): The ID of the catalog course_id (str): The ID of the course or course run Returns: bool: Whether the course or course run is contained in the given ...
enterprise/api_client/discovery.py
def is_course_in_catalog(self, catalog_id, course_id): """ Determine if the given course or course run ID is contained in the catalog with the given ID. Args: catalog_id (int): The ID of the catalog course_id (str): The ID of the course or course run Returns: ...
def is_course_in_catalog(self, catalog_id, course_id): """ Determine if the given course or course run ID is contained in the catalog with the given ID. Args: catalog_id (int): The ID of the catalog course_id (str): The ID of the course or course run Returns: ...
[ "Determine", "if", "the", "given", "course", "or", "course", "run", "ID", "is", "contained", "in", "the", "catalog", "with", "the", "given", "ID", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L418-L442
[ "def", "is_course_in_catalog", "(", "self", ",", "catalog_id", ",", "course_id", ")", ":", "try", ":", "# Determine if we have a course run ID, rather than a plain course ID", "course_run_id", "=", "str", "(", "CourseKey", ".", "from_string", "(", "course_id", ")", ")",...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseCatalogApiClient._load_data
Load data from API client. Arguments: resource(string): type of resource to load default(any): value to return if API query returned empty result. Sensible values: [], {}, None etc. Returns: dict: Deserialized response from Course Catalog API
enterprise/api_client/discovery.py
def _load_data(self, resource, default=DEFAULT_VALUE_SAFEGUARD, **kwargs): """ Load data from API client. Arguments: resource(string): type of resource to load default(any): value to return if API query returned empty result. Sensible values: [], {}, None etc. R...
def _load_data(self, resource, default=DEFAULT_VALUE_SAFEGUARD, **kwargs): """ Load data from API client. Arguments: resource(string): type of resource to load default(any): value to return if API query returned empty result. Sensible values: [], {}, None etc. R...
[ "Load", "data", "from", "API", "client", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/discovery.py#L444-L469
[ "def", "_load_data", "(", "self", ",", "resource", ",", "default", "=", "DEFAULT_VALUE_SAFEGUARD", ",", "*", "*", "kwargs", ")", ":", "default_val", "=", "default", "if", "default", "!=", "self", ".", "DEFAULT_VALUE_SAFEGUARD", "else", "{", "}", "try", ":", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseApiClient.get_content_metadata
Return all content metadata contained in the catalogs associated with the EnterpriseCustomer. Arguments: enterprise_customer (EnterpriseCustomer): The EnterpriseCustomer to return content metadata for. Returns: list: List of dicts containing content metadata.
enterprise/api_client/enterprise.py
def get_content_metadata(self, enterprise_customer): """ Return all content metadata contained in the catalogs associated with the EnterpriseCustomer. Arguments: enterprise_customer (EnterpriseCustomer): The EnterpriseCustomer to return content metadata for. Returns: ...
def get_content_metadata(self, enterprise_customer): """ Return all content metadata contained in the catalogs associated with the EnterpriseCustomer. Arguments: enterprise_customer (EnterpriseCustomer): The EnterpriseCustomer to return content metadata for. Returns: ...
[ "Return", "all", "content", "metadata", "contained", "in", "the", "catalogs", "associated", "with", "the", "EnterpriseCustomer", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/enterprise.py#L33-L70
[ "def", "get_content_metadata", "(", "self", ",", "enterprise_customer", ")", ":", "content_metadata", "=", "OrderedDict", "(", ")", "# TODO: This if block can be removed when we get rid of discovery service-based catalogs.", "if", "enterprise_customer", ".", "catalog", ":", "re...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseApiClient._load_data
Loads a response from a call to one of the Enterprise endpoints. :param resource: The endpoint resource name. :param detail_resource: The sub-resource to append to the path. :param resource_id: The resource ID for the specific detail to get from the endpoint. :param querystring: Optiona...
enterprise/api_client/enterprise.py
def _load_data( self, resource, detail_resource=None, resource_id=None, querystring=None, traverse_pagination=False, default=DEFAULT_VALUE_SAFEGUARD, ): """ Loads a response from a call to one of the Enterprise endpo...
def _load_data( self, resource, detail_resource=None, resource_id=None, querystring=None, traverse_pagination=False, default=DEFAULT_VALUE_SAFEGUARD, ): """ Loads a response from a call to one of the Enterprise endpo...
[ "Loads", "a", "response", "from", "a", "call", "to", "one", "of", "the", "Enterprise", "endpoints", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api_client/enterprise.py#L73-L119
[ "def", "_load_data", "(", "self", ",", "resource", ",", "detail_resource", "=", "None", ",", "resource_id", "=", "None", ",", "querystring", "=", "None", ",", "traverse_pagination", "=", "False", ",", "default", "=", "DEFAULT_VALUE_SAFEGUARD", ",", ")", ":", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ContentMetadataTransmitter.transmit
Transmit content metadata items to the integrated channel.
integrated_channels/integrated_channel/transmitters/content_metadata.py
def transmit(self, payload, **kwargs): """ Transmit content metadata items to the integrated channel. """ items_to_create, items_to_update, items_to_delete, transmission_map = self._partition_items(payload) self._transmit_delete(items_to_delete) self._transmit_create(item...
def transmit(self, payload, **kwargs): """ Transmit content metadata items to the integrated channel. """ items_to_create, items_to_update, items_to_delete, transmission_map = self._partition_items(payload) self._transmit_delete(items_to_delete) self._transmit_create(item...
[ "Transmit", "content", "metadata", "items", "to", "the", "integrated", "channel", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/integrated_channel/transmitters/content_metadata.py#L37-L44
[ "def", "transmit", "(", "self", ",", "payload", ",", "*", "*", "kwargs", ")", ":", "items_to_create", ",", "items_to_update", ",", "items_to_delete", ",", "transmission_map", "=", "self", ".", "_partition_items", "(", "payload", ")", "self", ".", "_transmit_de...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ContentMetadataTransmitter._partition_items
Return items that need to be created, updated, and deleted along with the current ContentMetadataItemTransmissions.
integrated_channels/integrated_channel/transmitters/content_metadata.py
def _partition_items(self, channel_metadata_item_map): """ Return items that need to be created, updated, and deleted along with the current ContentMetadataItemTransmissions. """ items_to_create = {} items_to_update = {} items_to_delete = {} transmission_m...
def _partition_items(self, channel_metadata_item_map): """ Return items that need to be created, updated, and deleted along with the current ContentMetadataItemTransmissions. """ items_to_create = {} items_to_update = {} items_to_delete = {} transmission_m...
[ "Return", "items", "that", "need", "to", "be", "created", "updated", "and", "deleted", "along", "with", "the", "current", "ContentMetadataItemTransmissions", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/integrated_channel/transmitters/content_metadata.py#L46-L96
[ "def", "_partition_items", "(", "self", ",", "channel_metadata_item_map", ")", ":", "items_to_create", "=", "{", "}", "items_to_update", "=", "{", "}", "items_to_delete", "=", "{", "}", "transmission_map", "=", "{", "}", "export_content_ids", "=", "channel_metadat...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ContentMetadataTransmitter._serialize_items
Serialize content metadata items for a create transmission to the integrated channel.
integrated_channels/integrated_channel/transmitters/content_metadata.py
def _serialize_items(self, channel_metadata_items): """ Serialize content metadata items for a create transmission to the integrated channel. """ return json.dumps( self._prepare_items_for_transmission(channel_metadata_items), sort_keys=True ).encode('utf-...
def _serialize_items(self, channel_metadata_items): """ Serialize content metadata items for a create transmission to the integrated channel. """ return json.dumps( self._prepare_items_for_transmission(channel_metadata_items), sort_keys=True ).encode('utf-...
[ "Serialize", "content", "metadata", "items", "for", "a", "create", "transmission", "to", "the", "integrated", "channel", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/integrated_channel/transmitters/content_metadata.py#L107-L114
[ "def", "_serialize_items", "(", "self", ",", "channel_metadata_items", ")", ":", "return", "json", ".", "dumps", "(", "self", ".", "_prepare_items_for_transmission", "(", "channel_metadata_items", ")", ",", "sort_keys", "=", "True", ")", ".", "encode", "(", "'ut...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ContentMetadataTransmitter._transmit_create
Transmit content metadata creation to integrated channel.
integrated_channels/integrated_channel/transmitters/content_metadata.py
def _transmit_create(self, channel_metadata_item_map): """ Transmit content metadata creation to integrated channel. """ for chunk in chunks(channel_metadata_item_map, self.enterprise_configuration.transmission_chunk_size): serialized_chunk = self._serialize_items(list(chunk....
def _transmit_create(self, channel_metadata_item_map): """ Transmit content metadata creation to integrated channel. """ for chunk in chunks(channel_metadata_item_map, self.enterprise_configuration.transmission_chunk_size): serialized_chunk = self._serialize_items(list(chunk....
[ "Transmit", "content", "metadata", "creation", "to", "integrated", "channel", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/integrated_channel/transmitters/content_metadata.py#L116-L133
[ "def", "_transmit_create", "(", "self", ",", "channel_metadata_item_map", ")", ":", "for", "chunk", "in", "chunks", "(", "channel_metadata_item_map", ",", "self", ".", "enterprise_configuration", ".", "transmission_chunk_size", ")", ":", "serialized_chunk", "=", "self...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ContentMetadataTransmitter._transmit_update
Transmit content metadata update to integrated channel.
integrated_channels/integrated_channel/transmitters/content_metadata.py
def _transmit_update(self, channel_metadata_item_map, transmission_map): """ Transmit content metadata update to integrated channel. """ for chunk in chunks(channel_metadata_item_map, self.enterprise_configuration.transmission_chunk_size): serialized_chunk = self._serialize_i...
def _transmit_update(self, channel_metadata_item_map, transmission_map): """ Transmit content metadata update to integrated channel. """ for chunk in chunks(channel_metadata_item_map, self.enterprise_configuration.transmission_chunk_size): serialized_chunk = self._serialize_i...
[ "Transmit", "content", "metadata", "update", "to", "integrated", "channel", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/integrated_channel/transmitters/content_metadata.py#L135-L152
[ "def", "_transmit_update", "(", "self", ",", "channel_metadata_item_map", ",", "transmission_map", ")", ":", "for", "chunk", "in", "chunks", "(", "channel_metadata_item_map", ",", "self", ".", "enterprise_configuration", ".", "transmission_chunk_size", ")", ":", "seri...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ContentMetadataTransmitter._transmit_delete
Transmit content metadata deletion to integrated channel.
integrated_channels/integrated_channel/transmitters/content_metadata.py
def _transmit_delete(self, channel_metadata_item_map): """ Transmit content metadata deletion to integrated channel. """ for chunk in chunks(channel_metadata_item_map, self.enterprise_configuration.transmission_chunk_size): serialized_chunk = self._serialize_items(list(chunk....
def _transmit_delete(self, channel_metadata_item_map): """ Transmit content metadata deletion to integrated channel. """ for chunk in chunks(channel_metadata_item_map, self.enterprise_configuration.transmission_chunk_size): serialized_chunk = self._serialize_items(list(chunk....
[ "Transmit", "content", "metadata", "deletion", "to", "integrated", "channel", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/integrated_channel/transmitters/content_metadata.py#L154-L171
[ "def", "_transmit_delete", "(", "self", ",", "channel_metadata_item_map", ")", ":", "for", "chunk", "in", "chunks", "(", "channel_metadata_item_map", ",", "self", ".", "enterprise_configuration", ".", "transmission_chunk_size", ")", ":", "serialized_chunk", "=", "self...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ContentMetadataTransmitter._get_transmissions
Return the ContentMetadataItemTransmision models for previously transmitted content metadata items.
integrated_channels/integrated_channel/transmitters/content_metadata.py
def _get_transmissions(self): """ Return the ContentMetadataItemTransmision models for previously transmitted content metadata items. """ # pylint: disable=invalid-name ContentMetadataItemTransmission = apps.get_model( 'integrated_channel', 'Conten...
def _get_transmissions(self): """ Return the ContentMetadataItemTransmision models for previously transmitted content metadata items. """ # pylint: disable=invalid-name ContentMetadataItemTransmission = apps.get_model( 'integrated_channel', 'Conten...
[ "Return", "the", "ContentMetadataItemTransmision", "models", "for", "previously", "transmitted", "content", "metadata", "items", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/integrated_channel/transmitters/content_metadata.py#L173-L186
[ "def", "_get_transmissions", "(", "self", ")", ":", "# pylint: disable=invalid-name", "ContentMetadataItemTransmission", "=", "apps", ".", "get_model", "(", "'integrated_channel'", ",", "'ContentMetadataItemTransmission'", ")", "return", "ContentMetadataItemTransmission", ".", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ContentMetadataTransmitter._create_transmissions
Create ContentMetadataItemTransmision models for the given content metadata items.
integrated_channels/integrated_channel/transmitters/content_metadata.py
def _create_transmissions(self, content_metadata_item_map): """ Create ContentMetadataItemTransmision models for the given content metadata items. """ # pylint: disable=invalid-name ContentMetadataItemTransmission = apps.get_model( 'integrated_channel', 'C...
def _create_transmissions(self, content_metadata_item_map): """ Create ContentMetadataItemTransmision models for the given content metadata items. """ # pylint: disable=invalid-name ContentMetadataItemTransmission = apps.get_model( 'integrated_channel', 'C...
[ "Create", "ContentMetadataItemTransmision", "models", "for", "the", "given", "content", "metadata", "items", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/integrated_channel/transmitters/content_metadata.py#L188-L207
[ "def", "_create_transmissions", "(", "self", ",", "content_metadata_item_map", ")", ":", "# pylint: disable=invalid-name", "ContentMetadataItemTransmission", "=", "apps", ".", "get_model", "(", "'integrated_channel'", ",", "'ContentMetadataItemTransmission'", ")", "transmission...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ContentMetadataTransmitter._update_transmissions
Update ContentMetadataItemTransmision models for the given content metadata items.
integrated_channels/integrated_channel/transmitters/content_metadata.py
def _update_transmissions(self, content_metadata_item_map, transmission_map): """ Update ContentMetadataItemTransmision models for the given content metadata items. """ for content_id, channel_metadata in content_metadata_item_map.items(): transmission = transmission_map[cont...
def _update_transmissions(self, content_metadata_item_map, transmission_map): """ Update ContentMetadataItemTransmision models for the given content metadata items. """ for content_id, channel_metadata in content_metadata_item_map.items(): transmission = transmission_map[cont...
[ "Update", "ContentMetadataItemTransmision", "models", "for", "the", "given", "content", "metadata", "items", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/integrated_channel/transmitters/content_metadata.py#L209-L216
[ "def", "_update_transmissions", "(", "self", ",", "content_metadata_item_map", ",", "transmission_map", ")", ":", "for", "content_id", ",", "channel_metadata", "in", "content_metadata_item_map", ".", "items", "(", ")", ":", "transmission", "=", "transmission_map", "["...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ContentMetadataTransmitter._delete_transmissions
Delete ContentMetadataItemTransmision models associated with the given content metadata items.
integrated_channels/integrated_channel/transmitters/content_metadata.py
def _delete_transmissions(self, content_metadata_item_ids): """ Delete ContentMetadataItemTransmision models associated with the given content metadata items. """ # pylint: disable=invalid-name ContentMetadataItemTransmission = apps.get_model( 'integrated_channel', ...
def _delete_transmissions(self, content_metadata_item_ids): """ Delete ContentMetadataItemTransmision models associated with the given content metadata items. """ # pylint: disable=invalid-name ContentMetadataItemTransmission = apps.get_model( 'integrated_channel', ...
[ "Delete", "ContentMetadataItemTransmision", "models", "associated", "with", "the", "given", "content", "metadata", "items", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/integrated_channel/transmitters/content_metadata.py#L218-L231
[ "def", "_delete_transmissions", "(", "self", ",", "content_metadata_item_ids", ")", ":", "# pylint: disable=invalid-name", "ContentMetadataItemTransmission", "=", "apps", ".", "get_model", "(", "'integrated_channel'", ",", "'ContentMetadataItemTransmission'", ")", "ContentMetad...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
deprecated
Flag a method as deprecated. :param extra: Extra text you'd like to display after the default text.
enterprise/decorators.py
def deprecated(extra): """ Flag a method as deprecated. :param extra: Extra text you'd like to display after the default text. """ def decorator(func): """ Return a decorated function that emits a deprecation warning on use. """ @wraps(func) def wrapper(*args...
def deprecated(extra): """ Flag a method as deprecated. :param extra: Extra text you'd like to display after the default text. """ def decorator(func): """ Return a decorated function that emits a deprecation warning on use. """ @wraps(func) def wrapper(*args...
[ "Flag", "a", "method", "as", "deprecated", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/decorators.py#L22-L50
[ "def", "deprecated", "(", "extra", ")", ":", "def", "decorator", "(", "func", ")", ":", "\"\"\"\n Return a decorated function that emits a deprecation warning on use.\n \"\"\"", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*"...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ignore_warning
Ignore any emitted warnings from a function. :param warning: The category of warning to ignore.
enterprise/decorators.py
def ignore_warning(warning): """ Ignore any emitted warnings from a function. :param warning: The category of warning to ignore. """ def decorator(func): """ Return a decorated function whose emitted warnings are ignored. """ @wraps(func) def wrapper(*args, *...
def ignore_warning(warning): """ Ignore any emitted warnings from a function. :param warning: The category of warning to ignore. """ def decorator(func): """ Return a decorated function whose emitted warnings are ignored. """ @wraps(func) def wrapper(*args, *...
[ "Ignore", "any", "emitted", "warnings", "from", "a", "function", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/decorators.py#L53-L71
[ "def", "ignore_warning", "(", "warning", ")", ":", "def", "decorator", "(", "func", ")", ":", "\"\"\"\n Return a decorated function whose emitted warnings are ignored.\n \"\"\"", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
enterprise_login_required
View decorator for allowing authenticated user with valid enterprise UUID. This decorator requires enterprise identifier as a parameter `enterprise_uuid`. This decorator will throw 404 if no kwarg `enterprise_uuid` is provided to the decorated view . If there is no enterprise in database against ...
enterprise/decorators.py
def enterprise_login_required(view): """ View decorator for allowing authenticated user with valid enterprise UUID. This decorator requires enterprise identifier as a parameter `enterprise_uuid`. This decorator will throw 404 if no kwarg `enterprise_uuid` is provided to the decorated view . ...
def enterprise_login_required(view): """ View decorator for allowing authenticated user with valid enterprise UUID. This decorator requires enterprise identifier as a parameter `enterprise_uuid`. This decorator will throw 404 if no kwarg `enterprise_uuid` is provided to the decorated view . ...
[ "View", "decorator", "for", "allowing", "authenticated", "user", "with", "valid", "enterprise", "UUID", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/decorators.py#L93-L158
[ "def", "enterprise_login_required", "(", "view", ")", ":", "@", "wraps", "(", "view", ")", "def", "wrapper", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n Wrap the decorator.\n \"\"\"", "if", "'enterprise_uuid'", "n...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
force_fresh_session
View decorator which terminates stale TPA sessions. This decorator forces the user to obtain a new session the first time they access the decorated view. This prevents TPA-authenticated users from hijacking the session of another user who may have been previously logged in using the same browser wi...
enterprise/decorators.py
def force_fresh_session(view): """ View decorator which terminates stale TPA sessions. This decorator forces the user to obtain a new session the first time they access the decorated view. This prevents TPA-authenticated users from hijacking the session of another user who may have been previou...
def force_fresh_session(view): """ View decorator which terminates stale TPA sessions. This decorator forces the user to obtain a new session the first time they access the decorated view. This prevents TPA-authenticated users from hijacking the session of another user who may have been previou...
[ "View", "decorator", "which", "terminates", "stale", "TPA", "sessions", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/decorators.py#L161-L221
[ "def", "force_fresh_session", "(", "view", ")", ":", "@", "wraps", "(", "view", ")", "def", "wrapper", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n Wrap the function.\n \"\"\"", "if", "not", "request", ".", "GE...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCourseEnrollmentWriteSerializer.validate_username
Verify that the username has a matching user, and that the user has an associated EnterpriseCustomerUser.
enterprise/api/v1/serializers.py
def validate_username(self, value): """ Verify that the username has a matching user, and that the user has an associated EnterpriseCustomerUser. """ try: user = User.objects.get(username=value) except User.DoesNotExist: raise serializers.ValidationError("...
def validate_username(self, value): """ Verify that the username has a matching user, and that the user has an associated EnterpriseCustomerUser. """ try: user = User.objects.get(username=value) except User.DoesNotExist: raise serializers.ValidationError("...
[ "Verify", "that", "the", "username", "has", "a", "matching", "user", "and", "that", "the", "user", "has", "an", "associated", "EnterpriseCustomerUser", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L156-L171
[ "def", "validate_username", "(", "self", ",", "value", ")", ":", "try", ":", "user", "=", "User", ".", "objects", ".", "get", "(", "username", "=", "value", ")", "except", "User", ".", "DoesNotExist", ":", "raise", "serializers", ".", "ValidationError", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCourseEnrollmentWriteSerializer.save
Save the model with the found EnterpriseCustomerUser.
enterprise/api/v1/serializers.py
def save(self): # pylint: disable=arguments-differ """ Save the model with the found EnterpriseCustomerUser. """ course_id = self.validated_data['course_id'] __, created = models.EnterpriseCourseEnrollment.objects.get_or_create( enterprise_customer_user=self.enterpr...
def save(self): # pylint: disable=arguments-differ """ Save the model with the found EnterpriseCustomerUser. """ course_id = self.validated_data['course_id'] __, created = models.EnterpriseCourseEnrollment.objects.get_or_create( enterprise_customer_user=self.enterpr...
[ "Save", "the", "model", "with", "the", "found", "EnterpriseCustomerUser", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L173-L184
[ "def", "save", "(", "self", ")", ":", "# pylint: disable=arguments-differ", "course_id", "=", "self", ".", "validated_data", "[", "'course_id'", "]", "__", ",", "created", "=", "models", ".", "EnterpriseCourseEnrollment", ".", "objects", ".", "get_or_create", "(",...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerCatalogDetailSerializer.to_representation
Serialize the EnterpriseCustomerCatalog object. Arguments: instance (EnterpriseCustomerCatalog): The EnterpriseCustomerCatalog to serialize. Returns: dict: The EnterpriseCustomerCatalog converted to a dict.
enterprise/api/v1/serializers.py
def to_representation(self, instance): """ Serialize the EnterpriseCustomerCatalog object. Arguments: instance (EnterpriseCustomerCatalog): The EnterpriseCustomerCatalog to serialize. Returns: dict: The EnterpriseCustomerCatalog converted to a dict. """ ...
def to_representation(self, instance): """ Serialize the EnterpriseCustomerCatalog object. Arguments: instance (EnterpriseCustomerCatalog): The EnterpriseCustomerCatalog to serialize. Returns: dict: The EnterpriseCustomerCatalog converted to a dict. """ ...
[ "Serialize", "the", "EnterpriseCustomerCatalog", "object", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L205-L255
[ "def", "to_representation", "(", "self", ",", "instance", ")", ":", "request", "=", "self", ".", "context", "[", "'request'", "]", "enterprise_customer", "=", "instance", ".", "enterprise_customer", "representation", "=", "super", "(", "EnterpriseCustomerCatalogDeta...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerUserReadOnlySerializer.get_groups
Return the enterprise related django groups that this user is a part of.
enterprise/api/v1/serializers.py
def get_groups(self, obj): """ Return the enterprise related django groups that this user is a part of. """ if obj.user: return [group.name for group in obj.user.groups.filter(name__in=ENTERPRISE_PERMISSION_GROUPS)] return []
def get_groups(self, obj): """ Return the enterprise related django groups that this user is a part of. """ if obj.user: return [group.name for group in obj.user.groups.filter(name__in=ENTERPRISE_PERMISSION_GROUPS)] return []
[ "Return", "the", "enterprise", "related", "django", "groups", "that", "this", "user", "is", "a", "part", "of", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L286-L292
[ "def", "get_groups", "(", "self", ",", "obj", ")", ":", "if", "obj", ".", "user", ":", "return", "[", "group", ".", "name", "for", "group", "in", "obj", ".", "user", ".", "groups", ".", "filter", "(", "name__in", "=", "ENTERPRISE_PERMISSION_GROUPS", ")...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerUserWriteSerializer.validate_username
Verify that the username has a matching user.
enterprise/api/v1/serializers.py
def validate_username(self, value): """ Verify that the username has a matching user. """ try: self.user = User.objects.get(username=value) except User.DoesNotExist: raise serializers.ValidationError("User does not exist") return value
def validate_username(self, value): """ Verify that the username has a matching user. """ try: self.user = User.objects.get(username=value) except User.DoesNotExist: raise serializers.ValidationError("User does not exist") return value
[ "Verify", "that", "the", "username", "has", "a", "matching", "user", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L309-L318
[ "def", "validate_username", "(", "self", ",", "value", ")", ":", "try", ":", "self", ".", "user", "=", "User", ".", "objects", ".", "get", "(", "username", "=", "value", ")", "except", "User", ".", "DoesNotExist", ":", "raise", "serializers", ".", "Val...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerUserWriteSerializer.save
Save the EnterpriseCustomerUser.
enterprise/api/v1/serializers.py
def save(self): # pylint: disable=arguments-differ """ Save the EnterpriseCustomerUser. """ enterprise_customer = self.validated_data['enterprise_customer'] ecu = models.EnterpriseCustomerUser( user_id=self.user.pk, enterprise_customer=enterprise_custome...
def save(self): # pylint: disable=arguments-differ """ Save the EnterpriseCustomerUser. """ enterprise_customer = self.validated_data['enterprise_customer'] ecu = models.EnterpriseCustomerUser( user_id=self.user.pk, enterprise_customer=enterprise_custome...
[ "Save", "the", "EnterpriseCustomerUser", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L320-L330
[ "def", "save", "(", "self", ")", ":", "# pylint: disable=arguments-differ", "enterprise_customer", "=", "self", ".", "validated_data", "[", "'enterprise_customer'", "]", "ecu", "=", "models", ".", "EnterpriseCustomerUser", "(", "user_id", "=", "self", ".", "user", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseDetailSerializer.to_representation
Return the updated course data dictionary. Arguments: instance (dict): The course data. Returns: dict: The updated course data.
enterprise/api/v1/serializers.py
def to_representation(self, instance): """ Return the updated course data dictionary. Arguments: instance (dict): The course data. Returns: dict: The updated course data. """ updated_course = copy.deepcopy(instance) enterprise_customer_ca...
def to_representation(self, instance): """ Return the updated course data dictionary. Arguments: instance (dict): The course data. Returns: dict: The updated course data. """ updated_course = copy.deepcopy(instance) enterprise_customer_ca...
[ "Return", "the", "updated", "course", "data", "dictionary", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L382-L401
[ "def", "to_representation", "(", "self", ",", "instance", ")", ":", "updated_course", "=", "copy", ".", "deepcopy", "(", "instance", ")", "enterprise_customer_catalog", "=", "self", ".", "context", "[", "'enterprise_customer_catalog'", "]", "updated_course", "[", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
CourseRunDetailSerializer.to_representation
Return the updated course run data dictionary. Arguments: instance (dict): The course run data. Returns: dict: The updated course run data.
enterprise/api/v1/serializers.py
def to_representation(self, instance): """ Return the updated course run data dictionary. Arguments: instance (dict): The course run data. Returns: dict: The updated course run data. """ updated_course_run = copy.deepcopy(instance) enterp...
def to_representation(self, instance): """ Return the updated course run data dictionary. Arguments: instance (dict): The course run data. Returns: dict: The updated course run data. """ updated_course_run = copy.deepcopy(instance) enterp...
[ "Return", "the", "updated", "course", "run", "data", "dictionary", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L412-L427
[ "def", "to_representation", "(", "self", ",", "instance", ")", ":", "updated_course_run", "=", "copy", ".", "deepcopy", "(", "instance", ")", "enterprise_customer_catalog", "=", "self", ".", "context", "[", "'enterprise_customer_catalog'", "]", "updated_course_run", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ProgramDetailSerializer.to_representation
Return the updated program data dictionary. Arguments: instance (dict): The program data. Returns: dict: The updated program data.
enterprise/api/v1/serializers.py
def to_representation(self, instance): """ Return the updated program data dictionary. Arguments: instance (dict): The program data. Returns: dict: The updated program data. """ updated_program = copy.deepcopy(instance) enterprise_custome...
def to_representation(self, instance): """ Return the updated program data dictionary. Arguments: instance (dict): The program data. Returns: dict: The updated program data. """ updated_program = copy.deepcopy(instance) enterprise_custome...
[ "Return", "the", "updated", "program", "data", "dictionary", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L438-L459
[ "def", "to_representation", "(", "self", ",", "instance", ")", ":", "updated_program", "=", "copy", ".", "deepcopy", "(", "instance", ")", "enterprise_customer_catalog", "=", "self", ".", "context", "[", "'enterprise_customer_catalog'", "]", "updated_program", "[", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerCourseEnrollmentsListSerializer.to_internal_value
This implements the same relevant logic as ListSerializer except that if one or more items fail validation, processing for other items that did not fail will continue.
enterprise/api/v1/serializers.py
def to_internal_value(self, data): """ This implements the same relevant logic as ListSerializer except that if one or more items fail validation, processing for other items that did not fail will continue. """ if not isinstance(data, list): message = self.error_mess...
def to_internal_value(self, data): """ This implements the same relevant logic as ListSerializer except that if one or more items fail validation, processing for other items that did not fail will continue. """ if not isinstance(data, list): message = self.error_mess...
[ "This", "implements", "the", "same", "relevant", "logic", "as", "ListSerializer", "except", "that", "if", "one", "or", "more", "items", "fail", "validation", "processing", "for", "other", "items", "that", "did", "not", "fail", "will", "continue", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L491-L515
[ "def", "to_internal_value", "(", "self", ",", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "list", ")", ":", "message", "=", "self", ".", "error_messages", "[", "'not_a_list'", "]", ".", "format", "(", "input_type", "=", "type", "(", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerCourseEnrollmentsListSerializer.create
This selectively calls the child create method based on whether or not validation failed for each payload.
enterprise/api/v1/serializers.py
def create(self, validated_data): """ This selectively calls the child create method based on whether or not validation failed for each payload. """ ret = [] for attrs in validated_data: if 'non_field_errors' not in attrs and not any(isinstance(attrs[field], list) for...
def create(self, validated_data): """ This selectively calls the child create method based on whether or not validation failed for each payload. """ ret = [] for attrs in validated_data: if 'non_field_errors' not in attrs and not any(isinstance(attrs[field], list) for...
[ "This", "selectively", "calls", "the", "child", "create", "method", "based", "on", "whether", "or", "not", "validation", "failed", "for", "each", "payload", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L517-L528
[ "def", "create", "(", "self", ",", "validated_data", ")", ":", "ret", "=", "[", "]", "for", "attrs", "in", "validated_data", ":", "if", "'non_field_errors'", "not", "in", "attrs", "and", "not", "any", "(", "isinstance", "(", "attrs", "[", "field", "]", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerCourseEnrollmentsListSerializer.to_representation
This selectively calls to_representation on each result that was processed by create.
enterprise/api/v1/serializers.py
def to_representation(self, data): """ This selectively calls to_representation on each result that was processed by create. """ return [ self.child.to_representation(item) if 'detail' in item else item for item in data ]
def to_representation(self, data): """ This selectively calls to_representation on each result that was processed by create. """ return [ self.child.to_representation(item) if 'detail' in item else item for item in data ]
[ "This", "selectively", "calls", "to_representation", "on", "each", "result", "that", "was", "processed", "by", "create", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L530-L536
[ "def", "to_representation", "(", "self", ",", "data", ")", ":", "return", "[", "self", ".", "child", ".", "to_representation", "(", "item", ")", "if", "'detail'", "in", "item", "else", "item", "for", "item", "in", "data", "]" ]
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerCourseEnrollmentsSerializer.create
Perform the enrollment for existing enterprise customer users, or create the pending objects for new users.
enterprise/api/v1/serializers.py
def create(self, validated_data): """ Perform the enrollment for existing enterprise customer users, or create the pending objects for new users. """ enterprise_customer = self.context.get('enterprise_customer') lms_user = validated_data.get('lms_user_id') tpa_user = vali...
def create(self, validated_data): """ Perform the enrollment for existing enterprise customer users, or create the pending objects for new users. """ enterprise_customer = self.context.get('enterprise_customer') lms_user = validated_data.get('lms_user_id') tpa_user = vali...
[ "Perform", "the", "enrollment", "for", "existing", "enterprise", "customer", "users", "or", "create", "the", "pending", "objects", "for", "new", "users", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L567-L616
[ "def", "create", "(", "self", ",", "validated_data", ")", ":", "enterprise_customer", "=", "self", ".", "context", ".", "get", "(", "'enterprise_customer'", ")", "lms_user", "=", "validated_data", ".", "get", "(", "'lms_user_id'", ")", "tpa_user", "=", "valida...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerCourseEnrollmentsSerializer.validate_lms_user_id
Validates the lms_user_id, if is given, to see if there is an existing EnterpriseCustomerUser for it.
enterprise/api/v1/serializers.py
def validate_lms_user_id(self, value): """ Validates the lms_user_id, if is given, to see if there is an existing EnterpriseCustomerUser for it. """ enterprise_customer = self.context.get('enterprise_customer') try: # Ensure the given user is associated with the ente...
def validate_lms_user_id(self, value): """ Validates the lms_user_id, if is given, to see if there is an existing EnterpriseCustomerUser for it. """ enterprise_customer = self.context.get('enterprise_customer') try: # Ensure the given user is associated with the ente...
[ "Validates", "the", "lms_user_id", "if", "is", "given", "to", "see", "if", "there", "is", "an", "existing", "EnterpriseCustomerUser", "for", "it", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L618-L633
[ "def", "validate_lms_user_id", "(", "self", ",", "value", ")", ":", "enterprise_customer", "=", "self", ".", "context", ".", "get", "(", "'enterprise_customer'", ")", "try", ":", "# Ensure the given user is associated with the enterprise.", "return", "models", ".", "E...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerCourseEnrollmentsSerializer.validate_tpa_user_id
Validates the tpa_user_id, if is given, to see if there is an existing EnterpriseCustomerUser for it. It first uses the third party auth api to find the associated username to do the lookup.
enterprise/api/v1/serializers.py
def validate_tpa_user_id(self, value): """ Validates the tpa_user_id, if is given, to see if there is an existing EnterpriseCustomerUser for it. It first uses the third party auth api to find the associated username to do the lookup. """ enterprise_customer = self.context.get('e...
def validate_tpa_user_id(self, value): """ Validates the tpa_user_id, if is given, to see if there is an existing EnterpriseCustomerUser for it. It first uses the third party auth api to find the associated username to do the lookup. """ enterprise_customer = self.context.get('e...
[ "Validates", "the", "tpa_user_id", "if", "is", "given", "to", "see", "if", "there", "is", "an", "existing", "EnterpriseCustomerUser", "for", "it", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L635-L656
[ "def", "validate_tpa_user_id", "(", "self", ",", "value", ")", ":", "enterprise_customer", "=", "self", ".", "context", ".", "get", "(", "'enterprise_customer'", ")", "try", ":", "tpa_client", "=", "ThirdPartyAuthApiClient", "(", ")", "username", "=", "tpa_clien...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerCourseEnrollmentsSerializer.validate_user_email
Validates the user_email, if given, to see if an existing EnterpriseCustomerUser exists for it. If it does not, it does not fail validation, unlike for the other field validation methods above.
enterprise/api/v1/serializers.py
def validate_user_email(self, value): """ Validates the user_email, if given, to see if an existing EnterpriseCustomerUser exists for it. If it does not, it does not fail validation, unlike for the other field validation methods above. """ enterprise_customer = self.context.get(...
def validate_user_email(self, value): """ Validates the user_email, if given, to see if an existing EnterpriseCustomerUser exists for it. If it does not, it does not fail validation, unlike for the other field validation methods above. """ enterprise_customer = self.context.get(...
[ "Validates", "the", "user_email", "if", "given", "to", "see", "if", "an", "existing", "EnterpriseCustomerUser", "exists", "for", "it", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L658-L675
[ "def", "validate_user_email", "(", "self", ",", "value", ")", ":", "enterprise_customer", "=", "self", ".", "context", ".", "get", "(", "'enterprise_customer'", ")", "try", ":", "user", "=", "User", ".", "objects", ".", "get", "(", "email", "=", "value", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerCourseEnrollmentsSerializer.validate_course_run_id
Validates that the course run id is part of the Enterprise Customer's catalog.
enterprise/api/v1/serializers.py
def validate_course_run_id(self, value): """ Validates that the course run id is part of the Enterprise Customer's catalog. """ enterprise_customer = self.context.get('enterprise_customer') if not enterprise_customer.catalog_contains_course(value): raise serializers....
def validate_course_run_id(self, value): """ Validates that the course run id is part of the Enterprise Customer's catalog. """ enterprise_customer = self.context.get('enterprise_customer') if not enterprise_customer.catalog_contains_course(value): raise serializers....
[ "Validates", "that", "the", "course", "run", "id", "is", "part", "of", "the", "Enterprise", "Customer", "s", "catalog", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L677-L692
[ "def", "validate_course_run_id", "(", "self", ",", "value", ")", ":", "enterprise_customer", "=", "self", ".", "context", ".", "get", "(", "'enterprise_customer'", ")", "if", "not", "enterprise_customer", ".", "catalog_contains_course", "(", "value", ")", ":", "...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerCourseEnrollmentsSerializer.validate
Validate that at least one of the user identifier fields has been passed in.
enterprise/api/v1/serializers.py
def validate(self, data): # pylint: disable=arguments-differ """ Validate that at least one of the user identifier fields has been passed in. """ lms_user_id = data.get('lms_user_id') tpa_user_id = data.get('tpa_user_id') user_email = data.get('user_email') if no...
def validate(self, data): # pylint: disable=arguments-differ """ Validate that at least one of the user identifier fields has been passed in. """ lms_user_id = data.get('lms_user_id') tpa_user_id = data.get('tpa_user_id') user_email = data.get('user_email') if no...
[ "Validate", "that", "at", "least", "one", "of", "the", "user", "identifier", "fields", "has", "been", "passed", "in", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/serializers.py#L694-L707
[ "def", "validate", "(", "self", ",", "data", ")", ":", "# pylint: disable=arguments-differ", "lms_user_id", "=", "data", ".", "get", "(", "'lms_user_id'", ")", "tpa_user_id", "=", "data", ".", "get", "(", "'tpa_user_id'", ")", "user_email", "=", "data", ".", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_paginated_response
Update pagination links in course catalog data and return DRF Response. Arguments: data (dict): Dictionary containing catalog courses. request (HttpRequest): Current request object. Returns: (Response): DRF response object containing pagination links.
enterprise/api/pagination.py
def get_paginated_response(data, request): """ Update pagination links in course catalog data and return DRF Response. Arguments: data (dict): Dictionary containing catalog courses. request (HttpRequest): Current request object. Returns: (Response): DRF response object containi...
def get_paginated_response(data, request): """ Update pagination links in course catalog data and return DRF Response. Arguments: data (dict): Dictionary containing catalog courses. request (HttpRequest): Current request object. Returns: (Response): DRF response object containi...
[ "Update", "pagination", "links", "in", "course", "catalog", "data", "and", "return", "DRF", "Response", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/pagination.py#L13-L47
[ "def", "get_paginated_response", "(", "data", ",", "request", ")", ":", "url", "=", "urlparse", "(", "request", ".", "build_absolute_uri", "(", ")", ")", ".", "_replace", "(", "query", "=", "None", ")", ".", "geturl", "(", ")", "next_page", "=", "None", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
create_switch
Create the `role_based_access_control` switch if it does not already exist.
enterprise/migrations/0067_add_role_based_access_control_switch.py
def create_switch(apps, schema_editor): """Create the `role_based_access_control` switch if it does not already exist.""" Switch = apps.get_model('waffle', 'Switch') Switch.objects.update_or_create(name=ENTERPRISE_ROLE_BASED_ACCESS_CONTROL_SWITCH, defaults={'active': False})
def create_switch(apps, schema_editor): """Create the `role_based_access_control` switch if it does not already exist.""" Switch = apps.get_model('waffle', 'Switch') Switch.objects.update_or_create(name=ENTERPRISE_ROLE_BASED_ACCESS_CONTROL_SWITCH, defaults={'active': False})
[ "Create", "the", "role_based_access_control", "switch", "if", "it", "does", "not", "already", "exist", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/migrations/0067_add_role_based_access_control_switch.py#L9-L12
[ "def", "create_switch", "(", "apps", ",", "schema_editor", ")", ":", "Switch", "=", "apps", ".", "get_model", "(", "'waffle'", ",", "'Switch'", ")", "Switch", ".", "objects", ".", "update_or_create", "(", "name", "=", "ENTERPRISE_ROLE_BASED_ACCESS_CONTROL_SWITCH",...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
delete_switch
Delete the `role_based_access_control` switch.
enterprise/migrations/0067_add_role_based_access_control_switch.py
def delete_switch(apps, schema_editor): """Delete the `role_based_access_control` switch.""" Switch = apps.get_model('waffle', 'Switch') Switch.objects.filter(name=ENTERPRISE_ROLE_BASED_ACCESS_CONTROL_SWITCH).delete()
def delete_switch(apps, schema_editor): """Delete the `role_based_access_control` switch.""" Switch = apps.get_model('waffle', 'Switch') Switch.objects.filter(name=ENTERPRISE_ROLE_BASED_ACCESS_CONTROL_SWITCH).delete()
[ "Delete", "the", "role_based_access_control", "switch", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/migrations/0067_add_role_based_access_control_switch.py#L15-L18
[ "def", "delete_switch", "(", "apps", ",", "schema_editor", ")", ":", "Switch", "=", "apps", ".", "get_model", "(", "'waffle'", ",", "'Switch'", ")", "Switch", ".", "objects", ".", "filter", "(", "name", "=", "ENTERPRISE_ROLE_BASED_ACCESS_CONTROL_SWITCH", ")", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
create_switch
Create and activate the SAP_USE_ENTERPRISE_ENROLLMENT_PAGE switch if it does not already exist.
integrated_channels/sap_success_factors/migrations/0009_sapsuccessfactors_remove_enterprise_enrollment_page_waffle_flag.py
def create_switch(apps, schema_editor): """Create and activate the SAP_USE_ENTERPRISE_ENROLLMENT_PAGE switch if it does not already exist.""" Switch = apps.get_model('waffle', 'Switch') Switch.objects.get_or_create(name='SAP_USE_ENTERPRISE_ENROLLMENT_PAGE', defaults={'active': False})
def create_switch(apps, schema_editor): """Create and activate the SAP_USE_ENTERPRISE_ENROLLMENT_PAGE switch if it does not already exist.""" Switch = apps.get_model('waffle', 'Switch') Switch.objects.get_or_create(name='SAP_USE_ENTERPRISE_ENROLLMENT_PAGE', defaults={'active': False})
[ "Create", "and", "activate", "the", "SAP_USE_ENTERPRISE_ENROLLMENT_PAGE", "switch", "if", "it", "does", "not", "already", "exist", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/sap_success_factors/migrations/0009_sapsuccessfactors_remove_enterprise_enrollment_page_waffle_flag.py#L7-L10
[ "def", "create_switch", "(", "apps", ",", "schema_editor", ")", ":", "Switch", "=", "apps", ".", "get_model", "(", "'waffle'", ",", "'Switch'", ")", "Switch", ".", "objects", ".", "get_or_create", "(", "name", "=", "'SAP_USE_ENTERPRISE_ENROLLMENT_PAGE'", ",", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
SapSuccessFactorsLearnerTransmitter.transmit
Send a completion status call to SAP SuccessFactors using the client. Args: payload: The learner completion data payload to send to SAP SuccessFactors
integrated_channels/sap_success_factors/transmitters/learner_data.py
def transmit(self, payload, **kwargs): """ Send a completion status call to SAP SuccessFactors using the client. Args: payload: The learner completion data payload to send to SAP SuccessFactors """ kwargs['app_label'] = 'sap_success_factors' kwargs['model_nam...
def transmit(self, payload, **kwargs): """ Send a completion status call to SAP SuccessFactors using the client. Args: payload: The learner completion data payload to send to SAP SuccessFactors """ kwargs['app_label'] = 'sap_success_factors' kwargs['model_nam...
[ "Send", "a", "completion", "status", "call", "to", "SAP", "SuccessFactors", "using", "the", "client", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/sap_success_factors/transmitters/learner_data.py#L32-L42
[ "def", "transmit", "(", "self", ",", "payload", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'app_label'", "]", "=", "'sap_success_factors'", "kwargs", "[", "'model_name'", "]", "=", "'SapSuccessFactorsLearnerDataTransmissionAudit'", "kwargs", "[", "'remote_...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
SapSuccessFactorsLearnerTransmitter.handle_transmission_error
Handle the case where the employee on SAPSF's side is marked as inactive.
integrated_channels/sap_success_factors/transmitters/learner_data.py
def handle_transmission_error(self, learner_data, request_exception): """Handle the case where the employee on SAPSF's side is marked as inactive.""" try: sys_msg = request_exception.response.content except AttributeError: pass else: if 'user account i...
def handle_transmission_error(self, learner_data, request_exception): """Handle the case where the employee on SAPSF's side is marked as inactive.""" try: sys_msg = request_exception.response.content except AttributeError: pass else: if 'user account i...
[ "Handle", "the", "case", "where", "the", "employee", "on", "SAPSF", "s", "side", "is", "marked", "as", "inactive", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/sap_success_factors/transmitters/learner_data.py#L44-L62
[ "def", "handle_transmission_error", "(", "self", ",", "learner_data", ",", "request_exception", ")", ":", "try", ":", "sys_msg", "=", "request_exception", ".", "response", ".", "content", "except", "AttributeError", ":", "pass", "else", ":", "if", "'user account i...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ServiceUserThrottle.allow_request
Modify throttling for service users. Updates throttling rate if the request is coming from the service user, and defaults to UserRateThrottle's configured setting otherwise. Updated throttling rate comes from `DEFAULT_THROTTLE_RATES` key in `REST_FRAMEWORK` setting. service user thrott...
enterprise/api/throttles.py
def allow_request(self, request, view): """ Modify throttling for service users. Updates throttling rate if the request is coming from the service user, and defaults to UserRateThrottle's configured setting otherwise. Updated throttling rate comes from `DEFAULT_THROTTLE_RATES` ...
def allow_request(self, request, view): """ Modify throttling for service users. Updates throttling rate if the request is coming from the service user, and defaults to UserRateThrottle's configured setting otherwise. Updated throttling rate comes from `DEFAULT_THROTTLE_RATES` ...
[ "Modify", "throttling", "for", "service", "users", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/throttles.py#L19-L46
[ "def", "allow_request", "(", "self", ",", "request", ",", "view", ")", ":", "service_users", "=", "get_service_usernames", "(", ")", "# User service user throttling rates for service user.", "if", "request", ".", "user", ".", "username", "in", "service_users", ":", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80