repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
danijar/sets
sets/utility.py
ensure_directory
def ensure_directory(directory): """ Create the directories along the provided directory path that do not exist. """ directory = os.path.expanduser(directory) try: os.makedirs(directory) except OSError as e: if e.errno != errno.EEXIST: raise e
python
def ensure_directory(directory): """ Create the directories along the provided directory path that do not exist. """ directory = os.path.expanduser(directory) try: os.makedirs(directory) except OSError as e: if e.errno != errno.EEXIST: raise e
[ "def", "ensure_directory", "(", "directory", ")", ":", "directory", "=", "os", ".", "path", ".", "expanduser", "(", "directory", ")", "try", ":", "os", ".", "makedirs", "(", "directory", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno"...
Create the directories along the provided directory path that do not exist.
[ "Create", "the", "directories", "along", "the", "provided", "directory", "path", "that", "do", "not", "exist", "." ]
train
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/utility.py#L71-L80
smarie/python-valid8
valid8/composition.py
_process_validation_function_s
def _process_validation_function_s(validation_func, # type: ValidationFuncs auto_and_wrapper=True # type: bool ): # type: (...) -> Union[Callable, List[Callable]] """ This function handles the various ways that users may enter 'val...
python
def _process_validation_function_s(validation_func, # type: ValidationFuncs auto_and_wrapper=True # type: bool ): # type: (...) -> Union[Callable, List[Callable]] """ This function handles the various ways that users may enter 'val...
[ "def", "_process_validation_function_s", "(", "validation_func", ",", "# type: ValidationFuncs", "auto_and_wrapper", "=", "True", "# type: bool", ")", ":", "# type: (...) -> Union[Callable, List[Callable]]", "# handle the case where validation_func is not yet a list or is empty or none", ...
This function handles the various ways that users may enter 'validation functions', so as to output a single callable method. Setting "auto_and_wrapper" to False allows callers to get a list of callables instead. valid8 supports the following expressions for 'validation functions' * <ValidationFunc> ...
[ "This", "function", "handles", "the", "various", "ways", "that", "users", "may", "enter", "validation", "functions", "so", "as", "to", "output", "a", "single", "callable", "method", ".", "Setting", "auto_and_wrapper", "to", "False", "allows", "callers", "to", ...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L43-L125
smarie/python-valid8
valid8/composition.py
and_
def and_(*validation_func # type: ValidationFuncs ): # type: (...) -> Callable """ An 'and' validator: it returns `True` if all of the provided validators return `True`, or raises a `AtLeastOneFailed` failure on the first `False` received or `Exception` caught. Note that an implicit `and_...
python
def and_(*validation_func # type: ValidationFuncs ): # type: (...) -> Callable """ An 'and' validator: it returns `True` if all of the provided validators return `True`, or raises a `AtLeastOneFailed` failure on the first `False` received or `Exception` caught. Note that an implicit `and_...
[ "def", "and_", "(", "*", "validation_func", "# type: ValidationFuncs", ")", ":", "# type: (...) -> Callable", "validation_func", "=", "_process_validation_function_s", "(", "list", "(", "validation_func", ")", ",", "auto_and_wrapper", "=", "False", ")", "if", "len", "...
An 'and' validator: it returns `True` if all of the provided validators return `True`, or raises a `AtLeastOneFailed` failure on the first `False` received or `Exception` caught. Note that an implicit `and_` is performed if you provide a list of validators to any of the entry points (`validate`, `validatio...
[ "An", "and", "validator", ":", "it", "returns", "True", "if", "all", "of", "the", "provided", "validators", "return", "True", "or", "raises", "a", "AtLeastOneFailed", "failure", "on", "the", "first", "False", "received", "or", "Exception", "caught", "." ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L229-L266
smarie/python-valid8
valid8/composition.py
not_
def not_(validation_func, # type: ValidationFuncs catch_all=False # type: bool ): # type: (...) -> Callable """ Generates the inverse of the provided validation functions: when the validator returns `False` or raises a `Failure`, this function returns `True`. Otherwise it raises a `...
python
def not_(validation_func, # type: ValidationFuncs catch_all=False # type: bool ): # type: (...) -> Callable """ Generates the inverse of the provided validation functions: when the validator returns `False` or raises a `Failure`, this function returns `True`. Otherwise it raises a `...
[ "def", "not_", "(", "validation_func", ",", "# type: ValidationFuncs", "catch_all", "=", "False", "# type: bool", ")", ":", "# type: (...) -> Callable", "def", "not_v_", "(", "x", ")", ":", "try", ":", "res", "=", "validation_func", "(", "x", ")", "if", "not",...
Generates the inverse of the provided validation functions: when the validator returns `False` or raises a `Failure`, this function returns `True`. Otherwise it raises a `DidNotFail` failure. By default, exceptions of types other than `Failure` are not caught and therefore fail the validation (`catch_all=F...
[ "Generates", "the", "inverse", "of", "the", "provided", "validation", "functions", ":", "when", "the", "validator", "returns", "False", "or", "raises", "a", "Failure", "this", "function", "returns", "True", ".", "Otherwise", "it", "raises", "a", "DidNotFail", ...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L274-L319
smarie/python-valid8
valid8/composition.py
or_
def or_(*validation_func # type: ValidationFuncs ): # type: (...) -> Callable """ An 'or' validator: returns `True` if at least one of the provided validators returns `True`. All exceptions will be silently caught. In case of failure, a global `AllValidatorsFailed` failure will be raised, toget...
python
def or_(*validation_func # type: ValidationFuncs ): # type: (...) -> Callable """ An 'or' validator: returns `True` if at least one of the provided validators returns `True`. All exceptions will be silently caught. In case of failure, a global `AllValidatorsFailed` failure will be raised, toget...
[ "def", "or_", "(", "*", "validation_func", "# type: ValidationFuncs", ")", ":", "# type: (...) -> Callable", "validation_func", "=", "_process_validation_function_s", "(", "list", "(", "validation_func", ")", ",", "auto_and_wrapper", "=", "False", ")", "if", "len", "(...
An 'or' validator: returns `True` if at least one of the provided validators returns `True`. All exceptions will be silently caught. In case of failure, a global `AllValidatorsFailed` failure will be raised, together with details about all validation results. :param validation_func: the base validation fun...
[ "An", "or", "validator", ":", "returns", "True", "if", "at", "least", "one", "of", "the", "provided", "validators", "returns", "True", ".", "All", "exceptions", "will", "be", "silently", "caught", ".", "In", "case", "of", "failure", "a", "global", "AllVali...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L330-L367
smarie/python-valid8
valid8/composition.py
xor_
def xor_(*validation_func # type: ValidationFuncs ): # type: (...) -> Callable """ A 'xor' validation function: returns `True` if exactly one of the provided validators returns `True`. All exceptions will be silently caught. In case of failure, a global `XorTooManySuccess` or `AllValidatorsFai...
python
def xor_(*validation_func # type: ValidationFuncs ): # type: (...) -> Callable """ A 'xor' validation function: returns `True` if exactly one of the provided validators returns `True`. All exceptions will be silently caught. In case of failure, a global `XorTooManySuccess` or `AllValidatorsFai...
[ "def", "xor_", "(", "*", "validation_func", "# type: ValidationFuncs", ")", ":", "# type: (...) -> Callable", "validation_func", "=", "_process_validation_function_s", "(", "list", "(", "validation_func", ")", ",", "auto_and_wrapper", "=", "False", ")", "if", "len", "...
A 'xor' validation function: returns `True` if exactly one of the provided validators returns `True`. All exceptions will be silently caught. In case of failure, a global `XorTooManySuccess` or `AllValidatorsFailed` will be raised, together with details about the various validation results. :param validati...
[ "A", "xor", "validation", "function", ":", "returns", "True", "if", "exactly", "one", "of", "the", "provided", "validators", "returns", "True", ".", "All", "exceptions", "will", "be", "silently", "caught", ".", "In", "case", "of", "failure", "a", "global", ...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L378-L424
smarie/python-valid8
valid8/composition.py
not_all
def not_all(*validation_func, # type: ValidationFuncs **kwargs ): # type: (...) -> Callable """ An alias for not_(and_(validators)). :param validation_func: the base validation function or list of base validation functions to use. A callable, a tuple(callable, help_msg_...
python
def not_all(*validation_func, # type: ValidationFuncs **kwargs ): # type: (...) -> Callable """ An alias for not_(and_(validators)). :param validation_func: the base validation function or list of base validation functions to use. A callable, a tuple(callable, help_msg_...
[ "def", "not_all", "(", "*", "validation_func", ",", "# type: ValidationFuncs", "*", "*", "kwargs", ")", ":", "# type: (...) -> Callable", "catch_all", "=", "pop_kwargs", "(", "kwargs", ",", "[", "(", "'catch_all'", ",", "False", ")", "]", ")", "# in case this is...
An alias for not_(and_(validators)). :param validation_func: the base validation function or list of base validation functions to use. A callable, a tuple(callable, help_msg_str), a tuple(callable, failure_type), or a list of several such elements. Nested lists are supported and indicate an implici...
[ "An", "alias", "for", "not_", "(", "and_", "(", "validators", "))", "." ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L436-L458
smarie/python-valid8
valid8/composition.py
failure_raiser
def failure_raiser(*validation_func, # type: ValidationFuncs **kwargs ): # type: (...) -> Callable """ This function is automatically used if you provide a tuple `(<function>, <msg>_or_<Failure_type>)`, to any of the methods in this page or to one of the `valid8` ...
python
def failure_raiser(*validation_func, # type: ValidationFuncs **kwargs ): # type: (...) -> Callable """ This function is automatically used if you provide a tuple `(<function>, <msg>_or_<Failure_type>)`, to any of the methods in this page or to one of the `valid8` ...
[ "def", "failure_raiser", "(", "*", "validation_func", ",", "# type: ValidationFuncs", "*", "*", "kwargs", ")", ":", "# type: (...) -> Callable", "failure_type", ",", "help_msg", "=", "pop_kwargs", "(", "kwargs", ",", "[", "(", "'failure_type'", ",", "None", ")", ...
This function is automatically used if you provide a tuple `(<function>, <msg>_or_<Failure_type>)`, to any of the methods in this page or to one of the `valid8` decorators. It transforms the provided `<function>` into a failure raiser, raising a subclass of `Failure` in case of failure (either not returning `Tr...
[ "This", "function", "is", "automatically", "used", "if", "you", "provide", "a", "tuple", "(", "<function", ">", "<msg", ">", "_or_<Failure_type", ">", ")", "to", "any", "of", "the", "methods", "in", "this", "page", "or", "to", "one", "of", "the", "valid8...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L473-L498
smarie/python-valid8
valid8/composition.py
pop_kwargs
def pop_kwargs(kwargs, names_with_defaults, # type: List[Tuple[str, Any]] allow_others=False ): """ Internal utility method to extract optional arguments from kwargs. :param kwargs: :param names_with_defaults: :param allow_others: if False (default) the...
python
def pop_kwargs(kwargs, names_with_defaults, # type: List[Tuple[str, Any]] allow_others=False ): """ Internal utility method to extract optional arguments from kwargs. :param kwargs: :param names_with_defaults: :param allow_others: if False (default) the...
[ "def", "pop_kwargs", "(", "kwargs", ",", "names_with_defaults", ",", "# type: List[Tuple[str, Any]]", "allow_others", "=", "False", ")", ":", "all_arguments", "=", "[", "]", "for", "name", ",", "default_", "in", "names_with_defaults", ":", "try", ":", "val", "="...
Internal utility method to extract optional arguments from kwargs. :param kwargs: :param names_with_defaults: :param allow_others: if False (default) then an error will be raised if kwargs still contains something at the end. :return:
[ "Internal", "utility", "method", "to", "extract", "optional", "arguments", "from", "kwargs", "." ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L539-L565
smarie/python-valid8
valid8/composition.py
CompositionFailure.get_details
def get_details(self): """ Overrides the base method in order to give details on the various successes and failures """ # transform the dictionary of failures into a printable form need_to_print_value = True failures_for_print = OrderedDict() for validator, failure in self.failu...
python
def get_details(self): """ Overrides the base method in order to give details on the various successes and failures """ # transform the dictionary of failures into a printable form need_to_print_value = True failures_for_print = OrderedDict() for validator, failure in self.failu...
[ "def", "get_details", "(", "self", ")", ":", "# transform the dictionary of failures into a printable form", "need_to_print_value", "=", "True", "failures_for_print", "=", "OrderedDict", "(", ")", "for", "validator", ",", "failure", "in", "self", ".", "failures", ".", ...
Overrides the base method in order to give details on the various successes and failures
[ "Overrides", "the", "base", "method", "in", "order", "to", "give", "details", "on", "the", "various", "successes", "and", "failures" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L160-L189
smarie/python-valid8
valid8/composition.py
CompositionFailure.play_all_validators
def play_all_validators(self, validators, value): """ Utility method to play all the provided validators on the provided value and output the :param validators: :param value: :return: """ successes = list() failures = OrderedDict() for validator i...
python
def play_all_validators(self, validators, value): """ Utility method to play all the provided validators on the provided value and output the :param validators: :param value: :return: """ successes = list() failures = OrderedDict() for validator i...
[ "def", "play_all_validators", "(", "self", ",", "validators", ",", "value", ")", ":", "successes", "=", "list", "(", ")", "failures", "=", "OrderedDict", "(", ")", "for", "validator", "in", "validators", ":", "name", "=", "get_callable_name", "(", "validator...
Utility method to play all the provided validators on the provided value and output the :param validators: :param value: :return:
[ "Utility", "method", "to", "play", "all", "the", "provided", "validators", "on", "the", "provided", "value", "and", "output", "the" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/composition.py#L191-L213
redhat-cip/dci-control-server
dci/common/signature.py
gen_secret
def gen_secret(length=64): """ Generates a secret of given length """ charset = string.ascii_letters + string.digits return ''.join(random.SystemRandom().choice(charset) for _ in range(length))
python
def gen_secret(length=64): """ Generates a secret of given length """ charset = string.ascii_letters + string.digits return ''.join(random.SystemRandom().choice(charset) for _ in range(length))
[ "def", "gen_secret", "(", "length", "=", "64", ")", ":", "charset", "=", "string", ".", "ascii_letters", "+", "string", ".", "digits", "return", "''", ".", "join", "(", "random", ".", "SystemRandom", "(", ")", ".", "choice", "(", "charset", ")", "for",...
Generates a secret of given length
[ "Generates", "a", "secret", "of", "given", "length" ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/common/signature.py#L21-L26
Antidote1911/cryptoshop
cryptoshop/cryptoshop.py
encryptfile
def encryptfile(filename, passphrase, algo='srp'): """ Encrypt a file and write it with .cryptoshop extension. :param filename: a string with the path to the file to encrypt. :param passphrase: a string with the user passphrase. :param algo: a string with the algorithm. Can be srp, aes, twf. Default...
python
def encryptfile(filename, passphrase, algo='srp'): """ Encrypt a file and write it with .cryptoshop extension. :param filename: a string with the path to the file to encrypt. :param passphrase: a string with the user passphrase. :param algo: a string with the algorithm. Can be srp, aes, twf. Default...
[ "def", "encryptfile", "(", "filename", ",", "passphrase", ",", "algo", "=", "'srp'", ")", ":", "try", ":", "if", "algo", "==", "\"srp\"", ":", "header", "=", "b\"Cryptoshop srp \"", "+", "b_version", "crypto_algo", "=", "\"Serpent/GCM\"", "if", "algo", "==",...
Encrypt a file and write it with .cryptoshop extension. :param filename: a string with the path to the file to encrypt. :param passphrase: a string with the user passphrase. :param algo: a string with the algorithm. Can be srp, aes, twf. Default is srp. :return: a string with "successfully encrypted" or...
[ "Encrypt", "a", "file", "and", "write", "it", "with", ".", "cryptoshop", "extension", ".", ":", "param", "filename", ":", "a", "string", "with", "the", "path", "to", "the", "file", "to", "encrypt", ".", ":", "param", "passphrase", ":", "a", "string", "...
train
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/cryptoshop.py#L104-L161
Antidote1911/cryptoshop
cryptoshop/cryptoshop.py
decryptfile
def decryptfile(filename, passphrase): """ Decrypt a file and write corresponding decrypted file. We remove the .cryptoshop extension. :param filename: a string with the path to the file to decrypt. :param passphrase: a string with the user passphrase. :return: a string with "successfully decrypted"...
python
def decryptfile(filename, passphrase): """ Decrypt a file and write corresponding decrypted file. We remove the .cryptoshop extension. :param filename: a string with the path to the file to decrypt. :param passphrase: a string with the user passphrase. :return: a string with "successfully decrypted"...
[ "def", "decryptfile", "(", "filename", ",", "passphrase", ")", ":", "try", ":", "outname", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "0", "]", ".", "split", "(", "\"_\"", ")", "[", "-", "1", "]", "# create a string file name w...
Decrypt a file and write corresponding decrypted file. We remove the .cryptoshop extension. :param filename: a string with the path to the file to decrypt. :param passphrase: a string with the user passphrase. :return: a string with "successfully decrypted" or error.
[ "Decrypt", "a", "file", "and", "write", "corresponding", "decrypted", "file", ".", "We", "remove", "the", ".", "cryptoshop", "extension", ".", ":", "param", "filename", ":", "a", "string", "with", "the", "path", "to", "the", "file", "to", "decrypt", ".", ...
train
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/cryptoshop.py#L164-L225
danijar/sets
sets/process/tokenize.py
Tokenize._tokenize
def _tokenize(cls, sentence): """ Split a sentence while preserving tags. """ while True: match = cls._regex_tag.search(sentence) if not match: yield from cls._split(sentence) return chunk = sentence[:match.start()] ...
python
def _tokenize(cls, sentence): """ Split a sentence while preserving tags. """ while True: match = cls._regex_tag.search(sentence) if not match: yield from cls._split(sentence) return chunk = sentence[:match.start()] ...
[ "def", "_tokenize", "(", "cls", ",", "sentence", ")", ":", "while", "True", ":", "match", "=", "cls", ".", "_regex_tag", ".", "search", "(", "sentence", ")", "if", "not", "match", ":", "yield", "from", "cls", ".", "_split", "(", "sentence", ")", "ret...
Split a sentence while preserving tags.
[ "Split", "a", "sentence", "while", "preserving", "tags", "." ]
train
https://github.com/danijar/sets/blob/2542c28f43d0af18932cb5b82f54ffb6ae557d12/sets/process/tokenize.py#L22-L35
mediawiki-utilities/python-mwxml
mwxml/map/map.py
map
def map(process, paths, threads=None): """ Implements a distributed stategy for processing XML files. This function constructs a set of py:mod:`multiprocessing` threads (spread over multiple cores) and uses an internal queue to aggregate outputs. To use this function, implement a `process()` funct...
python
def map(process, paths, threads=None): """ Implements a distributed stategy for processing XML files. This function constructs a set of py:mod:`multiprocessing` threads (spread over multiple cores) and uses an internal queue to aggregate outputs. To use this function, implement a `process()` funct...
[ "def", "map", "(", "process", ",", "paths", ",", "threads", "=", "None", ")", ":", "paths", "=", "[", "mwtypes", ".", "files", ".", "normalize_path", "(", "path", ")", "for", "path", "in", "paths", "]", "def", "process_path", "(", "path", ")", ":", ...
Implements a distributed stategy for processing XML files. This function constructs a set of py:mod:`multiprocessing` threads (spread over multiple cores) and uses an internal queue to aggregate outputs. To use this function, implement a `process()` function that takes two arguments -- a :class:`mwxml...
[ "Implements", "a", "distributed", "stategy", "for", "processing", "XML", "files", ".", "This", "function", "constructs", "a", "set", "of", "py", ":", "mod", ":", "multiprocessing", "threads", "(", "spread", "over", "multiple", "cores", ")", "and", "uses", "a...
train
https://github.com/mediawiki-utilities/python-mwxml/blob/6a8c18be99cd0bcee9c496e607f08bf4dfe5b510/mwxml/map/map.py#L11-L49
redhat-cip/dci-control-server
dci/trackers/__init__.py
Tracker.dump
def dump(self): """Return the object itself.""" return { 'title': self.title, 'issue_id': self.issue_id, 'reporter': self.reporter, 'assignee': self.assignee, 'status': self.status, 'product': self.product, 'component':...
python
def dump(self): """Return the object itself.""" return { 'title': self.title, 'issue_id': self.issue_id, 'reporter': self.reporter, 'assignee': self.assignee, 'status': self.status, 'product': self.product, 'component':...
[ "def", "dump", "(", "self", ")", ":", "return", "{", "'title'", ":", "self", ".", "title", ",", "'issue_id'", ":", "self", ".", "issue_id", ",", "'reporter'", ":", "self", ".", "reporter", ",", "'assignee'", ":", "self", ".", "assignee", ",", "'status'...
Return the object itself.
[ "Return", "the", "object", "itself", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/trackers/__init__.py#L39-L54
smarie/python-valid8
valid8/utils_decoration.py
apply_on_each_func_args_sig
def apply_on_each_func_args_sig(func, cur_args, cur_kwargs, sig, # type: Signature func_to_apply, func_to_apply_params_dict): """ Applies func_to_apply...
python
def apply_on_each_func_args_sig(func, cur_args, cur_kwargs, sig, # type: Signature func_to_apply, func_to_apply_params_dict): """ Applies func_to_apply...
[ "def", "apply_on_each_func_args_sig", "(", "func", ",", "cur_args", ",", "cur_kwargs", ",", "sig", ",", "# type: Signature", "func_to_apply", ",", "func_to_apply_params_dict", ")", ":", "# match the received arguments with the signature to know who is who", "bound_values", "=",...
Applies func_to_apply on each argument of func according to what's received in current call (cur_args, cur_kwargs). For each argument of func named 'att' in its signature, the following method is called: `func_to_apply(cur_att_value, func_to_apply_paramers_dict[att], func, att_name)` :param func: :par...
[ "Applies", "func_to_apply", "on", "each", "argument", "of", "func", "according", "to", "what", "s", "received", "in", "current", "call", "(", "cur_args", "cur_kwargs", ")", ".", "For", "each", "argument", "of", "func", "named", "att", "in", "its", "signature...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/utils_decoration.py#L15-L45
redhat-cip/dci-control-server
dci/identity.py
Identity.is_product_owner
def is_product_owner(self, team_id): """Ensure the user is a PRODUCT_OWNER.""" if self.is_super_admin(): return True team_id = uuid.UUID(str(team_id)) return team_id in self.child_teams_ids
python
def is_product_owner(self, team_id): """Ensure the user is a PRODUCT_OWNER.""" if self.is_super_admin(): return True team_id = uuid.UUID(str(team_id)) return team_id in self.child_teams_ids
[ "def", "is_product_owner", "(", "self", ",", "team_id", ")", ":", "if", "self", ".", "is_super_admin", "(", ")", ":", "return", "True", "team_id", "=", "uuid", ".", "UUID", "(", "str", "(", "team_id", ")", ")", "return", "team_id", "in", "self", ".", ...
Ensure the user is a PRODUCT_OWNER.
[ "Ensure", "the", "user", "is", "a", "PRODUCT_OWNER", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/identity.py#L71-L77
redhat-cip/dci-control-server
dci/identity.py
Identity.is_in_team
def is_in_team(self, team_id): """Test if user is in team""" if self.is_super_admin(): return True team_id = uuid.UUID(str(team_id)) return team_id in self.teams or team_id in self.child_teams_ids
python
def is_in_team(self, team_id): """Test if user is in team""" if self.is_super_admin(): return True team_id = uuid.UUID(str(team_id)) return team_id in self.teams or team_id in self.child_teams_ids
[ "def", "is_in_team", "(", "self", ",", "team_id", ")", ":", "if", "self", ".", "is_super_admin", "(", ")", ":", "return", "True", "team_id", "=", "uuid", ".", "UUID", "(", "str", "(", "team_id", ")", ")", "return", "team_id", "in", "self", ".", "team...
Test if user is in team
[ "Test", "if", "user", "is", "in", "team" ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/identity.py#L96-L102
redhat-cip/dci-control-server
dci/identity.py
Identity.is_remoteci
def is_remoteci(self, team_id=None): """Ensure ther resource has the role REMOTECI.""" if team_id is None: return self._is_remoteci team_id = uuid.UUID(str(team_id)) if team_id not in self.teams_ids: return False return self.teams[team_id]['role'] == 'REMO...
python
def is_remoteci(self, team_id=None): """Ensure ther resource has the role REMOTECI.""" if team_id is None: return self._is_remoteci team_id = uuid.UUID(str(team_id)) if team_id not in self.teams_ids: return False return self.teams[team_id]['role'] == 'REMO...
[ "def", "is_remoteci", "(", "self", ",", "team_id", "=", "None", ")", ":", "if", "team_id", "is", "None", ":", "return", "self", ".", "_is_remoteci", "team_id", "=", "uuid", ".", "UUID", "(", "str", "(", "team_id", ")", ")", "if", "team_id", "not", "i...
Ensure ther resource has the role REMOTECI.
[ "Ensure", "ther", "resource", "has", "the", "role", "REMOTECI", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/identity.py#L112-L119
redhat-cip/dci-control-server
dci/identity.py
Identity.is_feeder
def is_feeder(self, team_id=None): """Ensure ther resource has the role FEEDER.""" if team_id is None: return self._is_feeder team_id = uuid.UUID(str(team_id)) if team_id not in self.teams_ids: return False return self.teams[team_id]['role'] == 'FEEDER'
python
def is_feeder(self, team_id=None): """Ensure ther resource has the role FEEDER.""" if team_id is None: return self._is_feeder team_id = uuid.UUID(str(team_id)) if team_id not in self.teams_ids: return False return self.teams[team_id]['role'] == 'FEEDER'
[ "def", "is_feeder", "(", "self", ",", "team_id", "=", "None", ")", ":", "if", "team_id", "is", "None", ":", "return", "self", ".", "_is_feeder", "team_id", "=", "uuid", ".", "UUID", "(", "str", "(", "team_id", ")", ")", "if", "team_id", "not", "in", ...
Ensure ther resource has the role FEEDER.
[ "Ensure", "ther", "resource", "has", "the", "role", "FEEDER", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/identity.py#L121-L128
jmurty/xml4h
xml4h/nodes.py
Node.document
def document(self): """ :return: the :class:`Document` node that contains this node, or ``self`` if this node is the document. """ if self.is_document: return self return self.adapter.wrap_document(self.adapter.impl_document)
python
def document(self): """ :return: the :class:`Document` node that contains this node, or ``self`` if this node is the document. """ if self.is_document: return self return self.adapter.wrap_document(self.adapter.impl_document)
[ "def", "document", "(", "self", ")", ":", "if", "self", ".", "is_document", ":", "return", "self", "return", "self", ".", "adapter", ".", "wrap_document", "(", "self", ".", "adapter", ".", "impl_document", ")" ]
:return: the :class:`Document` node that contains this node, or ``self`` if this node is the document.
[ ":", "return", ":", "the", ":", "class", ":", "Document", "node", "that", "contains", "this", "node", "or", "self", "if", "this", "node", "is", "the", "document", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L111-L118
jmurty/xml4h
xml4h/nodes.py
Node.root
def root(self): """ :return: the root :class:`Element` node of the document that contains this node, or ``self`` if this node is the root element. """ if self.is_root: return self return self.adapter.wrap_node( self.adapter.impl_root_element, s...
python
def root(self): """ :return: the root :class:`Element` node of the document that contains this node, or ``self`` if this node is the root element. """ if self.is_root: return self return self.adapter.wrap_node( self.adapter.impl_root_element, s...
[ "def", "root", "(", "self", ")", ":", "if", "self", ".", "is_root", ":", "return", "self", "return", "self", ".", "adapter", ".", "wrap_node", "(", "self", ".", "adapter", ".", "impl_root_element", ",", "self", ".", "adapter", ".", "impl_document", ",", ...
:return: the root :class:`Element` node of the document that contains this node, or ``self`` if this node is the root element.
[ ":", "return", ":", "the", "root", ":", "class", ":", "Element", "node", "of", "the", "document", "that", "contains", "this", "node", "or", "self", "if", "this", "node", "is", "the", "root", "element", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L121-L130
jmurty/xml4h
xml4h/nodes.py
Node._convert_nodelist
def _convert_nodelist(self, impl_nodelist): """ Convert a list of underlying implementation nodes into a list of *xml4h* wrapper nodes. """ nodelist = [ self.adapter.wrap_node(n, self.adapter.impl_document, self.adapter) for n in impl_nodelist] ret...
python
def _convert_nodelist(self, impl_nodelist): """ Convert a list of underlying implementation nodes into a list of *xml4h* wrapper nodes. """ nodelist = [ self.adapter.wrap_node(n, self.adapter.impl_document, self.adapter) for n in impl_nodelist] ret...
[ "def", "_convert_nodelist", "(", "self", ",", "impl_nodelist", ")", ":", "nodelist", "=", "[", "self", ".", "adapter", ".", "wrap_node", "(", "n", ",", "self", ".", "adapter", ".", "impl_document", ",", "self", ".", "adapter", ")", "for", "n", "in", "i...
Convert a list of underlying implementation nodes into a list of *xml4h* wrapper nodes.
[ "Convert", "a", "list", "of", "underlying", "implementation", "nodes", "into", "a", "list", "of", "*", "xml4h", "*", "wrapper", "nodes", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L235-L243
jmurty/xml4h
xml4h/nodes.py
Node.parent
def parent(self): """ :return: the parent of this node, or *None* of the node has no parent. """ parent_impl_node = self.adapter.get_node_parent(self.impl_node) return self.adapter.wrap_node( parent_impl_node, self.adapter.impl_document, self.adapter)
python
def parent(self): """ :return: the parent of this node, or *None* of the node has no parent. """ parent_impl_node = self.adapter.get_node_parent(self.impl_node) return self.adapter.wrap_node( parent_impl_node, self.adapter.impl_document, self.adapter)
[ "def", "parent", "(", "self", ")", ":", "parent_impl_node", "=", "self", ".", "adapter", ".", "get_node_parent", "(", "self", ".", "impl_node", ")", "return", "self", ".", "adapter", ".", "wrap_node", "(", "parent_impl_node", ",", "self", ".", "adapter", "...
:return: the parent of this node, or *None* of the node has no parent.
[ ":", "return", ":", "the", "parent", "of", "this", "node", "or", "*", "None", "*", "of", "the", "node", "has", "no", "parent", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L246-L252
jmurty/xml4h
xml4h/nodes.py
Node.children
def children(self): """ :return: a :class:`NodeList` of this node's child nodes. """ impl_nodelist = self.adapter.get_node_children(self.impl_node) return self._convert_nodelist(impl_nodelist)
python
def children(self): """ :return: a :class:`NodeList` of this node's child nodes. """ impl_nodelist = self.adapter.get_node_children(self.impl_node) return self._convert_nodelist(impl_nodelist)
[ "def", "children", "(", "self", ")", ":", "impl_nodelist", "=", "self", ".", "adapter", ".", "get_node_children", "(", "self", ".", "impl_node", ")", "return", "self", ".", "_convert_nodelist", "(", "impl_nodelist", ")" ]
:return: a :class:`NodeList` of this node's child nodes.
[ ":", "return", ":", "a", ":", "class", ":", "NodeList", "of", "this", "node", "s", "child", "nodes", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L268-L273
jmurty/xml4h
xml4h/nodes.py
Node.child
def child(self, local_name=None, name=None, ns_uri=None, node_type=None, filter_fn=None): """ :return: the first child node matching the given constraints, or \ *None* if there are no matching child nodes. Delegates to :meth:`NodeList.filter`. """ re...
python
def child(self, local_name=None, name=None, ns_uri=None, node_type=None, filter_fn=None): """ :return: the first child node matching the given constraints, or \ *None* if there are no matching child nodes. Delegates to :meth:`NodeList.filter`. """ re...
[ "def", "child", "(", "self", ",", "local_name", "=", "None", ",", "name", "=", "None", ",", "ns_uri", "=", "None", ",", "node_type", "=", "None", ",", "filter_fn", "=", "None", ")", ":", "return", "self", ".", "children", "(", "name", "=", "name", ...
:return: the first child node matching the given constraints, or \ *None* if there are no matching child nodes. Delegates to :meth:`NodeList.filter`.
[ ":", "return", ":", "the", "first", "child", "node", "matching", "the", "given", "constraints", "or", "\\", "*", "None", "*", "if", "there", "are", "no", "matching", "child", "nodes", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L275-L284
jmurty/xml4h
xml4h/nodes.py
Node.siblings
def siblings(self): """ :return: a list of this node's sibling nodes. :rtype: NodeList """ impl_nodelist = self.adapter.get_node_children(self.parent.impl_node) return self._convert_nodelist( [n for n in impl_nodelist if n != self.impl_node])
python
def siblings(self): """ :return: a list of this node's sibling nodes. :rtype: NodeList """ impl_nodelist = self.adapter.get_node_children(self.parent.impl_node) return self._convert_nodelist( [n for n in impl_nodelist if n != self.impl_node])
[ "def", "siblings", "(", "self", ")", ":", "impl_nodelist", "=", "self", ".", "adapter", ".", "get_node_children", "(", "self", ".", "parent", ".", "impl_node", ")", "return", "self", ".", "_convert_nodelist", "(", "[", "n", "for", "n", "in", "impl_nodelist...
:return: a list of this node's sibling nodes. :rtype: NodeList
[ ":", "return", ":", "a", "list", "of", "this", "node", "s", "sibling", "nodes", ".", ":", "rtype", ":", "NodeList" ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L295-L302
jmurty/xml4h
xml4h/nodes.py
Node.siblings_before
def siblings_before(self): """ :return: a list of this node's siblings that occur *before* this node in the DOM. """ impl_nodelist = self.adapter.get_node_children(self.parent.impl_node) before_nodelist = [] for n in impl_nodelist: if n == self.imp...
python
def siblings_before(self): """ :return: a list of this node's siblings that occur *before* this node in the DOM. """ impl_nodelist = self.adapter.get_node_children(self.parent.impl_node) before_nodelist = [] for n in impl_nodelist: if n == self.imp...
[ "def", "siblings_before", "(", "self", ")", ":", "impl_nodelist", "=", "self", ".", "adapter", ".", "get_node_children", "(", "self", ".", "parent", ".", "impl_node", ")", "before_nodelist", "=", "[", "]", "for", "n", "in", "impl_nodelist", ":", "if", "n",...
:return: a list of this node's siblings that occur *before* this node in the DOM.
[ ":", "return", ":", "a", "list", "of", "this", "node", "s", "siblings", "that", "occur", "*", "before", "*", "this", "node", "in", "the", "DOM", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L305-L316
jmurty/xml4h
xml4h/nodes.py
Node.siblings_after
def siblings_after(self): """ :return: a list of this node's siblings that occur *after* this node in the DOM. """ impl_nodelist = self.adapter.get_node_children(self.parent.impl_node) after_nodelist = [] is_after_myself = False for n in impl_nodelist:...
python
def siblings_after(self): """ :return: a list of this node's siblings that occur *after* this node in the DOM. """ impl_nodelist = self.adapter.get_node_children(self.parent.impl_node) after_nodelist = [] is_after_myself = False for n in impl_nodelist:...
[ "def", "siblings_after", "(", "self", ")", ":", "impl_nodelist", "=", "self", ".", "adapter", ".", "get_node_children", "(", "self", ".", "parent", ".", "impl_node", ")", "after_nodelist", "=", "[", "]", "is_after_myself", "=", "False", "for", "n", "in", "...
:return: a list of this node's siblings that occur *after* this node in the DOM.
[ ":", "return", ":", "a", "list", "of", "this", "node", "s", "siblings", "that", "occur", "*", "after", "*", "this", "node", "in", "the", "DOM", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L319-L332
jmurty/xml4h
xml4h/nodes.py
Node.delete
def delete(self, destroy=True): """ Delete this node from the owning document. :param bool destroy: if True the child node will be destroyed in addition to being removed from the document. :returns: the removed child node, or *None* if the child was destroyed. """ ...
python
def delete(self, destroy=True): """ Delete this node from the owning document. :param bool destroy: if True the child node will be destroyed in addition to being removed from the document. :returns: the removed child node, or *None* if the child was destroyed. """ ...
[ "def", "delete", "(", "self", ",", "destroy", "=", "True", ")", ":", "removed_child", "=", "self", ".", "adapter", ".", "remove_node_child", "(", "self", ".", "adapter", ".", "get_node_parent", "(", "self", ".", "impl_node", ")", ",", "self", ".", "impl_...
Delete this node from the owning document. :param bool destroy: if True the child node will be destroyed in addition to being removed from the document. :returns: the removed child node, or *None* if the child was destroyed.
[ "Delete", "this", "node", "from", "the", "owning", "document", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L344-L359
jmurty/xml4h
xml4h/nodes.py
Node.clone_node
def clone_node(self, node): """ Clone a node from another document to become a child of this node, by copying the node's data into this document but leaving the node untouched in the source document. The node to be cloned can be a :class:`Node` based on the same underlying XML li...
python
def clone_node(self, node): """ Clone a node from another document to become a child of this node, by copying the node's data into this document but leaving the node untouched in the source document. The node to be cloned can be a :class:`Node` based on the same underlying XML li...
[ "def", "clone_node", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "xml4h", ".", "nodes", ".", "Node", ")", ":", "child_impl_node", "=", "node", ".", "impl_node", "else", ":", "child_impl_node", "=", "node", "# Assume it's a val...
Clone a node from another document to become a child of this node, by copying the node's data into this document but leaving the node untouched in the source document. The node to be cloned can be a :class:`Node` based on the same underlying XML library implementation and adapter, or a "...
[ "Clone", "a", "node", "from", "another", "document", "to", "become", "a", "child", "of", "this", "node", "by", "copying", "the", "node", "s", "data", "into", "this", "document", "but", "leaving", "the", "node", "untouched", "in", "the", "source", "document...
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L361-L376
jmurty/xml4h
xml4h/nodes.py
Node.transplant_node
def transplant_node(self, node): """ Transplant a node from another document to become a child of this node, removing it from the source document. The node to be transplanted can be a :class:`Node` based on the same underlying XML library implementation and adapter, or a "raw" n...
python
def transplant_node(self, node): """ Transplant a node from another document to become a child of this node, removing it from the source document. The node to be transplanted can be a :class:`Node` based on the same underlying XML library implementation and adapter, or a "raw" n...
[ "def", "transplant_node", "(", "self", ",", "node", ")", ":", "if", "isinstance", "(", "node", ",", "xml4h", ".", "nodes", ".", "Node", ")", ":", "child_impl_node", "=", "node", ".", "impl_node", "original_parent_impl_node", "=", "node", ".", "parent", "."...
Transplant a node from another document to become a child of this node, removing it from the source document. The node to be transplanted can be a :class:`Node` based on the same underlying XML library implementation and adapter, or a "raw" node from that implementation. :param node: t...
[ "Transplant", "a", "node", "from", "another", "document", "to", "become", "a", "child", "of", "this", "node", "removing", "it", "from", "the", "source", "document", ".", "The", "node", "to", "be", "transplanted", "can", "be", "a", ":", "class", ":", "Nod...
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L378-L395
jmurty/xml4h
xml4h/nodes.py
Node.find
def find(self, name=None, ns_uri=None, first_only=False): """ Find :class:`Element` node descendants of this node, with optional constraints to limit the results. :param name: limit results to elements with this name. If *None* or ``'*'`` all element names are matched. ...
python
def find(self, name=None, ns_uri=None, first_only=False): """ Find :class:`Element` node descendants of this node, with optional constraints to limit the results. :param name: limit results to elements with this name. If *None* or ``'*'`` all element names are matched. ...
[ "def", "find", "(", "self", ",", "name", "=", "None", ",", "ns_uri", "=", "None", ",", "first_only", "=", "False", ")", ":", "if", "name", "is", "None", ":", "name", "=", "'*'", "# Match all element names", "if", "ns_uri", "is", "None", ":", "ns_uri", ...
Find :class:`Element` node descendants of this node, with optional constraints to limit the results. :param name: limit results to elements with this name. If *None* or ``'*'`` all element names are matched. :type name: string or None :param ns_uri: limit results to elements...
[ "Find", ":", "class", ":", "Element", "node", "descendants", "of", "this", "node", "with", "optional", "constraints", "to", "limit", "the", "results", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L397-L426
jmurty/xml4h
xml4h/nodes.py
Node.find_first
def find_first(self, name=None, ns_uri=None): """ Find the first :class:`Element` node descendant of this node that matches any optional constraints, or None if there are no matching elements. Delegates to :meth:`find` with ``first_only=True``. """ return self.fi...
python
def find_first(self, name=None, ns_uri=None): """ Find the first :class:`Element` node descendant of this node that matches any optional constraints, or None if there are no matching elements. Delegates to :meth:`find` with ``first_only=True``. """ return self.fi...
[ "def", "find_first", "(", "self", ",", "name", "=", "None", ",", "ns_uri", "=", "None", ")", ":", "return", "self", ".", "find", "(", "name", "=", "name", ",", "ns_uri", "=", "ns_uri", ",", "first_only", "=", "True", ")" ]
Find the first :class:`Element` node descendant of this node that matches any optional constraints, or None if there are no matching elements. Delegates to :meth:`find` with ``first_only=True``.
[ "Find", "the", "first", ":", "class", ":", "Element", "node", "descendant", "of", "this", "node", "that", "matches", "any", "optional", "constraints", "or", "None", "if", "there", "are", "no", "matching", "elements", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L428-L436
jmurty/xml4h
xml4h/nodes.py
Node.find_doc
def find_doc(self, name=None, ns_uri=None, first_only=False): """ Find :class:`Element` node descendants of the document containing this node, with optional constraints to limit the results. Delegates to :meth:`find` applied to this node's owning document. """ return sel...
python
def find_doc(self, name=None, ns_uri=None, first_only=False): """ Find :class:`Element` node descendants of the document containing this node, with optional constraints to limit the results. Delegates to :meth:`find` applied to this node's owning document. """ return sel...
[ "def", "find_doc", "(", "self", ",", "name", "=", "None", ",", "ns_uri", "=", "None", ",", "first_only", "=", "False", ")", ":", "return", "self", ".", "document", ".", "find", "(", "name", "=", "name", ",", "ns_uri", "=", "ns_uri", ",", "first_only"...
Find :class:`Element` node descendants of the document containing this node, with optional constraints to limit the results. Delegates to :meth:`find` applied to this node's owning document.
[ "Find", ":", "class", ":", "Element", "node", "descendants", "of", "the", "document", "containing", "this", "node", "with", "optional", "constraints", "to", "limit", "the", "results", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L438-L446
jmurty/xml4h
xml4h/nodes.py
Node.write
def write(self, writer=None, encoding='utf-8', indent=0, newline='', omit_declaration=False, node_depth=0, quote_char='"'): """ Serialize this node and its descendants to text, writing the output to a given *writer* or to stdout. :param writer: an object such as a file or st...
python
def write(self, writer=None, encoding='utf-8', indent=0, newline='', omit_declaration=False, node_depth=0, quote_char='"'): """ Serialize this node and its descendants to text, writing the output to a given *writer* or to stdout. :param writer: an object such as a file or st...
[ "def", "write", "(", "self", ",", "writer", "=", "None", ",", "encoding", "=", "'utf-8'", ",", "indent", "=", "0", ",", "newline", "=", "''", ",", "omit_declaration", "=", "False", ",", "node_depth", "=", "0", ",", "quote_char", "=", "'\"'", ")", ":"...
Serialize this node and its descendants to text, writing the output to a given *writer* or to stdout. :param writer: an object such as a file or stream to which XML text is sent. If *None* text is sent to :attr:`sys.stdout`. :type writer: a file, stream, etc or None :param s...
[ "Serialize", "this", "node", "and", "its", "descendants", "to", "text", "writing", "the", "output", "to", "a", "given", "*", "writer", "*", "or", "to", "stdout", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L450-L492
jmurty/xml4h
xml4h/nodes.py
Node.xml
def xml(self, indent=4, **kwargs): """ :return: this node as XML text. Delegates to :meth:`write` """ writer = StringIO() self.write(writer, indent=indent, **kwargs) return writer.getvalue()
python
def xml(self, indent=4, **kwargs): """ :return: this node as XML text. Delegates to :meth:`write` """ writer = StringIO() self.write(writer, indent=indent, **kwargs) return writer.getvalue()
[ "def", "xml", "(", "self", ",", "indent", "=", "4", ",", "*", "*", "kwargs", ")", ":", "writer", "=", "StringIO", "(", ")", "self", ".", "write", "(", "writer", ",", "indent", "=", "indent", ",", "*", "*", "kwargs", ")", "return", "writer", ".", ...
:return: this node as XML text. Delegates to :meth:`write`
[ ":", "return", ":", "this", "node", "as", "XML", "text", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L503-L511
jmurty/xml4h
xml4h/nodes.py
XPathMixin.xpath
def xpath(self, xpath, **kwargs): """ Perform an XPath query on the current node. :param string xpath: XPath query. :param dict kwargs: Optional keyword arguments that are passed through to the underlying XML library implementation. :return: results of the query as ...
python
def xpath(self, xpath, **kwargs): """ Perform an XPath query on the current node. :param string xpath: XPath query. :param dict kwargs: Optional keyword arguments that are passed through to the underlying XML library implementation. :return: results of the query as ...
[ "def", "xpath", "(", "self", ",", "xpath", ",", "*", "*", "kwargs", ")", ":", "result", "=", "self", ".", "adapter", ".", "xpath_on_node", "(", "self", ".", "impl_node", ",", "xpath", ",", "*", "*", "kwargs", ")", "if", "isinstance", "(", "result", ...
Perform an XPath query on the current node. :param string xpath: XPath query. :param dict kwargs: Optional keyword arguments that are passed through to the underlying XML library implementation. :return: results of the query as a list of :class:`Node` objects, or a list...
[ "Perform", "an", "XPath", "query", "on", "the", "current", "node", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L595-L611
jmurty/xml4h
xml4h/nodes.py
Element.set_attributes
def set_attributes(self, attr_obj=None, ns_uri=None, **attr_dict): """ Add or update this element's attributes, where attributes can be specified in a number of ways. :param attr_obj: a dictionary or list of attribute name/value pairs. :type attr_obj: dict, list, tuple, or None ...
python
def set_attributes(self, attr_obj=None, ns_uri=None, **attr_dict): """ Add or update this element's attributes, where attributes can be specified in a number of ways. :param attr_obj: a dictionary or list of attribute name/value pairs. :type attr_obj: dict, list, tuple, or None ...
[ "def", "set_attributes", "(", "self", ",", "attr_obj", "=", "None", ",", "ns_uri", "=", "None", ",", "*", "*", "attr_dict", ")", ":", "self", ".", "_set_element_attributes", "(", "self", ".", "impl_node", ",", "attr_obj", "=", "attr_obj", ",", "ns_uri", ...
Add or update this element's attributes, where attributes can be specified in a number of ways. :param attr_obj: a dictionary or list of attribute name/value pairs. :type attr_obj: dict, list, tuple, or None :param ns_uri: a URI defining a namespace for the new attributes. :type...
[ "Add", "or", "update", "this", "element", "s", "attributes", "where", "attributes", "can", "be", "specified", "in", "a", "number", "of", "ways", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L841-L854
jmurty/xml4h
xml4h/nodes.py
Element.attributes
def attributes(self): """ Get or set this element's attributes as name/value pairs. .. note:: Setting element attributes via this accessor will **remove** any existing attributes, as opposed to the :meth:`set_attributes` method which only updates and replaces...
python
def attributes(self): """ Get or set this element's attributes as name/value pairs. .. note:: Setting element attributes via this accessor will **remove** any existing attributes, as opposed to the :meth:`set_attributes` method which only updates and replaces...
[ "def", "attributes", "(", "self", ")", ":", "attr_impl_nodes", "=", "self", ".", "adapter", ".", "get_node_attributes", "(", "self", ".", "impl_node", ")", "return", "AttributeDict", "(", "attr_impl_nodes", ",", "self", ".", "impl_node", ",", "self", ".", "a...
Get or set this element's attributes as name/value pairs. .. note:: Setting element attributes via this accessor will **remove** any existing attributes, as opposed to the :meth:`set_attributes` method which only updates and replaces them.
[ "Get", "or", "set", "this", "element", "s", "attributes", "as", "name", "/", "value", "pairs", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L857-L867
jmurty/xml4h
xml4h/nodes.py
Element.attribute_nodes
def attribute_nodes(self): """ :return: a list of this element's attributes as :class:`Attribute` nodes. """ impl_attr_nodes = self.adapter.get_node_attributes(self.impl_node) wrapped_attr_nodes = [ self.adapter.wrap_node(a, self.adapter.impl_document, sel...
python
def attribute_nodes(self): """ :return: a list of this element's attributes as :class:`Attribute` nodes. """ impl_attr_nodes = self.adapter.get_node_attributes(self.impl_node) wrapped_attr_nodes = [ self.adapter.wrap_node(a, self.adapter.impl_document, sel...
[ "def", "attribute_nodes", "(", "self", ")", ":", "impl_attr_nodes", "=", "self", ".", "adapter", ".", "get_node_attributes", "(", "self", ".", "impl_node", ")", "wrapped_attr_nodes", "=", "[", "self", ".", "adapter", ".", "wrap_node", "(", "a", ",", "self", ...
:return: a list of this element's attributes as :class:`Attribute` nodes.
[ ":", "return", ":", "a", "list", "of", "this", "element", "s", "attributes", "as", ":", "class", ":", "Attribute", "nodes", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L891-L900
jmurty/xml4h
xml4h/nodes.py
Element.attribute_node
def attribute_node(self, name, ns_uri=None): """ :param string name: the name of the attribute to return. :param ns_uri: a URI defining a namespace constraint on the attribute. :type ns_uri: string or None :return: this element's attributes that match ``ns_uri`` as :...
python
def attribute_node(self, name, ns_uri=None): """ :param string name: the name of the attribute to return. :param ns_uri: a URI defining a namespace constraint on the attribute. :type ns_uri: string or None :return: this element's attributes that match ``ns_uri`` as :...
[ "def", "attribute_node", "(", "self", ",", "name", ",", "ns_uri", "=", "None", ")", ":", "attr_impl_node", "=", "self", ".", "adapter", ".", "get_node_attribute_node", "(", "self", ".", "impl_node", ",", "name", ",", "ns_uri", ")", "return", "self", ".", ...
:param string name: the name of the attribute to return. :param ns_uri: a URI defining a namespace constraint on the attribute. :type ns_uri: string or None :return: this element's attributes that match ``ns_uri`` as :class:`Attribute` nodes.
[ ":", "param", "string", "name", ":", "the", "name", "of", "the", "attribute", "to", "return", ".", ":", "param", "ns_uri", ":", "a", "URI", "defining", "a", "namespace", "constraint", "on", "the", "attribute", ".", ":", "type", "ns_uri", ":", "string", ...
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L902-L914
jmurty/xml4h
xml4h/nodes.py
Element.set_ns_prefix
def set_ns_prefix(self, prefix, ns_uri): """ Define a namespace prefix that will serve as shorthand for the given namespace URI in element names. :param string prefix: prefix that will serve as an alias for a the namespace URI. :param string ns_uri: namespace URI tha...
python
def set_ns_prefix(self, prefix, ns_uri): """ Define a namespace prefix that will serve as shorthand for the given namespace URI in element names. :param string prefix: prefix that will serve as an alias for a the namespace URI. :param string ns_uri: namespace URI tha...
[ "def", "set_ns_prefix", "(", "self", ",", "prefix", ",", "ns_uri", ")", ":", "self", ".", "_add_ns_prefix_attr", "(", "self", ".", "impl_node", ",", "prefix", ",", "ns_uri", ")" ]
Define a namespace prefix that will serve as shorthand for the given namespace URI in element names. :param string prefix: prefix that will serve as an alias for a the namespace URI. :param string ns_uri: namespace URI that will be denoted by the prefix.
[ "Define", "a", "namespace", "prefix", "that", "will", "serve", "as", "shorthand", "for", "the", "given", "namespace", "URI", "in", "element", "names", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L925-L935
jmurty/xml4h
xml4h/nodes.py
Element.add_element
def add_element(self, name, ns_uri=None, attributes=None, text=None, before_this_element=False): """ Add a new child element to this element, with an optional namespace definition. If no namespace is provided the child will be assigned to the default namespace. :para...
python
def add_element(self, name, ns_uri=None, attributes=None, text=None, before_this_element=False): """ Add a new child element to this element, with an optional namespace definition. If no namespace is provided the child will be assigned to the default namespace. :para...
[ "def", "add_element", "(", "self", ",", "name", ",", "ns_uri", "=", "None", ",", "attributes", "=", "None", ",", "text", "=", "None", ",", "before_this_element", "=", "False", ")", ":", "# Determine local name, namespace and prefix info from tag name", "prefix", "...
Add a new child element to this element, with an optional namespace definition. If no namespace is provided the child will be assigned to the default namespace. :param string name: a name for the child node. The name may be used to apply a namespace to the child by including: ...
[ "Add", "a", "new", "child", "element", "to", "this", "element", "with", "an", "optional", "namespace", "definition", ".", "If", "no", "namespace", "is", "provided", "the", "child", "will", "be", "assigned", "to", "the", "default", "namespace", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L937-L1008
jmurty/xml4h
xml4h/nodes.py
Element.add_text
def add_text(self, text): """ Add a text node to this element. Adding text with this method is subtly different from assigning a new text value with :meth:`text` accessor, because it "appends" to rather than replacing this element's set of text nodes. :param text: text ...
python
def add_text(self, text): """ Add a text node to this element. Adding text with this method is subtly different from assigning a new text value with :meth:`text` accessor, because it "appends" to rather than replacing this element's set of text nodes. :param text: text ...
[ "def", "add_text", "(", "self", ",", "text", ")", ":", "if", "not", "isinstance", "(", "text", ",", "basestring", ")", ":", "text", "=", "unicode", "(", "text", ")", "self", ".", "_add_text", "(", "self", ".", "impl_node", ",", "text", ")" ]
Add a text node to this element. Adding text with this method is subtly different from assigning a new text value with :meth:`text` accessor, because it "appends" to rather than replacing this element's set of text nodes. :param text: text content to add to this element. :param...
[ "Add", "a", "text", "node", "to", "this", "element", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1014-L1027
jmurty/xml4h
xml4h/nodes.py
Element.add_instruction
def add_instruction(self, target, data): """ Add an instruction node to this element. :param string text: text content to add as an instruction. """ self._add_instruction(self.impl_node, target, data)
python
def add_instruction(self, target, data): """ Add an instruction node to this element. :param string text: text content to add as an instruction. """ self._add_instruction(self.impl_node, target, data)
[ "def", "add_instruction", "(", "self", ",", "target", ",", "data", ")", ":", "self", ".", "_add_instruction", "(", "self", ".", "impl_node", ",", "target", ",", "data", ")" ]
Add an instruction node to this element. :param string text: text content to add as an instruction.
[ "Add", "an", "instruction", "node", "to", "this", "element", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1045-L1051
jmurty/xml4h
xml4h/nodes.py
AttributeDict.items
def items(self): """ :return: a list of name/value attribute pairs sorted by attribute name. """ sorted_keys = sorted(self.keys()) return [(k, self[k]) for k in sorted_keys]
python
def items(self): """ :return: a list of name/value attribute pairs sorted by attribute name. """ sorted_keys = sorted(self.keys()) return [(k, self[k]) for k in sorted_keys]
[ "def", "items", "(", "self", ")", ":", "sorted_keys", "=", "sorted", "(", "self", ".", "keys", "(", ")", ")", "return", "[", "(", "k", ",", "self", "[", "k", "]", ")", "for", "k", "in", "sorted_keys", "]" ]
:return: a list of name/value attribute pairs sorted by attribute name.
[ ":", "return", ":", "a", "list", "of", "name", "/", "value", "attribute", "pairs", "sorted", "by", "attribute", "name", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1135-L1140
jmurty/xml4h
xml4h/nodes.py
AttributeDict.namespace_uri
def namespace_uri(self, name): """ :param string name: the name of an attribute to look up. :return: the namespace URI associated with the named attribute, or None. """ a_node = self.adapter.get_node_attribute_node(self.impl_element, name) if a_node is None: ...
python
def namespace_uri(self, name): """ :param string name: the name of an attribute to look up. :return: the namespace URI associated with the named attribute, or None. """ a_node = self.adapter.get_node_attribute_node(self.impl_element, name) if a_node is None: ...
[ "def", "namespace_uri", "(", "self", ",", "name", ")", ":", "a_node", "=", "self", ".", "adapter", ".", "get_node_attribute_node", "(", "self", ".", "impl_element", ",", "name", ")", "if", "a_node", "is", "None", ":", "return", "None", "return", "self", ...
:param string name: the name of an attribute to look up. :return: the namespace URI associated with the named attribute, or None.
[ ":", "param", "string", "name", ":", "the", "name", "of", "an", "attribute", "to", "look", "up", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1142-L1152
jmurty/xml4h
xml4h/nodes.py
AttributeDict.prefix
def prefix(self, name): """ :param string name: the name of an attribute to look up. :return: the prefix component of the named attribute's name, or None. """ a_node = self.adapter.get_node_attribute_node(self.impl_element, name) if a_node is None: ...
python
def prefix(self, name): """ :param string name: the name of an attribute to look up. :return: the prefix component of the named attribute's name, or None. """ a_node = self.adapter.get_node_attribute_node(self.impl_element, name) if a_node is None: ...
[ "def", "prefix", "(", "self", ",", "name", ")", ":", "a_node", "=", "self", ".", "adapter", ".", "get_node_attribute_node", "(", "self", ".", "impl_element", ",", "name", ")", "if", "a_node", "is", "None", ":", "return", "None", "return", "a_node", ".", ...
:param string name: the name of an attribute to look up. :return: the prefix component of the named attribute's name, or None.
[ ":", "param", "string", "name", ":", "the", "name", "of", "an", "attribute", "to", "look", "up", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1154-L1164
jmurty/xml4h
xml4h/nodes.py
AttributeDict.element
def element(self): """ :return: the :class:`Element` that contains these attributes. """ return self.adapter.wrap_node( self.impl_element, self.adapter.impl_document, self.adapter)
python
def element(self): """ :return: the :class:`Element` that contains these attributes. """ return self.adapter.wrap_node( self.impl_element, self.adapter.impl_document, self.adapter)
[ "def", "element", "(", "self", ")", ":", "return", "self", ".", "adapter", ".", "wrap_node", "(", "self", ".", "impl_element", ",", "self", ".", "adapter", ".", "impl_document", ",", "self", ".", "adapter", ")" ]
:return: the :class:`Element` that contains these attributes.
[ ":", "return", ":", "the", ":", "class", ":", "Element", "that", "contains", "these", "attributes", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1175-L1180
jmurty/xml4h
xml4h/nodes.py
NodeList.filter
def filter(self, local_name=None, name=None, ns_uri=None, node_type=None, filter_fn=None, first_only=False): """ Apply filters to the set of nodes in this list. :param local_name: a local name used to filter the nodes. :type local_name: string or None :param name: a ...
python
def filter(self, local_name=None, name=None, ns_uri=None, node_type=None, filter_fn=None, first_only=False): """ Apply filters to the set of nodes in this list. :param local_name: a local name used to filter the nodes. :type local_name: string or None :param name: a ...
[ "def", "filter", "(", "self", ",", "local_name", "=", "None", ",", "name", "=", "None", ",", "ns_uri", "=", "None", ",", "node_type", "=", "None", ",", "filter_fn", "=", "None", ",", "first_only", "=", "False", ")", ":", "# Build our own filter function un...
Apply filters to the set of nodes in this list. :param local_name: a local name used to filter the nodes. :type local_name: string or None :param name: a name used to filter the nodes. :type name: string or None :param ns_uri: a namespace URI used to filter the nodes. ...
[ "Apply", "filters", "to", "the", "set", "of", "nodes", "in", "this", "list", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/nodes.py#L1197-L1255
redhat-cip/dci-control-server
dci/api/v1/analytics.py
get_all_analytics
def get_all_analytics(user, job_id): """Get all analytics of a job.""" args = schemas.args(flask.request.args.to_dict()) v1_utils.verify_existence_and_get(job_id, models.JOBS) query = v1_utils.QueryBuilder(_TABLE, args, _A_COLUMNS) # If not admin nor rh employee then restrict the view to the team ...
python
def get_all_analytics(user, job_id): """Get all analytics of a job.""" args = schemas.args(flask.request.args.to_dict()) v1_utils.verify_existence_and_get(job_id, models.JOBS) query = v1_utils.QueryBuilder(_TABLE, args, _A_COLUMNS) # If not admin nor rh employee then restrict the view to the team ...
[ "def", "get_all_analytics", "(", "user", ",", "job_id", ")", ":", "args", "=", "schemas", ".", "args", "(", "flask", ".", "request", ".", "args", ".", "to_dict", "(", ")", ")", "v1_utils", ".", "verify_existence_and_get", "(", "job_id", ",", "models", "....
Get all analytics of a job.
[ "Get", "all", "analytics", "of", "a", "job", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/analytics.py#L53-L70
redhat-cip/dci-control-server
dci/api/v1/analytics.py
get_analytic
def get_analytic(user, job_id, anc_id): """Get an analytic.""" v1_utils.verify_existence_and_get(job_id, models.JOBS) analytic = v1_utils.verify_existence_and_get(anc_id, _TABLE) analytic = dict(analytic) if not user.is_in_team(analytic['team_id']): raise dci_exc.Unauthorized() return f...
python
def get_analytic(user, job_id, anc_id): """Get an analytic.""" v1_utils.verify_existence_and_get(job_id, models.JOBS) analytic = v1_utils.verify_existence_and_get(anc_id, _TABLE) analytic = dict(analytic) if not user.is_in_team(analytic['team_id']): raise dci_exc.Unauthorized() return f...
[ "def", "get_analytic", "(", "user", ",", "job_id", ",", "anc_id", ")", ":", "v1_utils", ".", "verify_existence_and_get", "(", "job_id", ",", "models", ".", "JOBS", ")", "analytic", "=", "v1_utils", ".", "verify_existence_and_get", "(", "anc_id", ",", "_TABLE",...
Get an analytic.
[ "Get", "an", "analytic", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/analytics.py#L75-L83
jmurty/xml4h
xml4h/writer.py
write_node
def write_node(node, writer=None, encoding='utf-8', indent=0, newline='', omit_declaration=False, node_depth=0, quote_char='"'): """ Serialize an *xml4h* DOM node and its descendants to text, writing the output to a given *writer* or to stdout. :param node: the DOM node whose content and descen...
python
def write_node(node, writer=None, encoding='utf-8', indent=0, newline='', omit_declaration=False, node_depth=0, quote_char='"'): """ Serialize an *xml4h* DOM node and its descendants to text, writing the output to a given *writer* or to stdout. :param node: the DOM node whose content and descen...
[ "def", "write_node", "(", "node", ",", "writer", "=", "None", ",", "encoding", "=", "'utf-8'", ",", "indent", "=", "0", ",", "newline", "=", "''", ",", "omit_declaration", "=", "False", ",", "node_depth", "=", "0", ",", "quote_char", "=", "'\"'", ")", ...
Serialize an *xml4h* DOM node and its descendants to text, writing the output to a given *writer* or to stdout. :param node: the DOM node whose content and descendants will be serialized. :type node: an :class:`xml4h.nodes.Node` or subclass :param writer: an object such as a file or stream to w...
[ "Serialize", "an", "*", "xml4h", "*", "DOM", "node", "and", "its", "descendants", "to", "text", "writing", "the", "output", "to", "a", "given", "*", "writer", "*", "or", "to", "stdout", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/writer.py#L12-L182
Antidote1911/cryptoshop
cryptoshop/_chunk_engine.py
encry_decry_chunk
def encry_decry_chunk(chunk, key, algo, bool_encry, assoc_data): """ When bool_encry is True, encrypt a chunk of the file with the key and a randomly generated nonce. When it is False, the function extract the nonce from the cipherchunk (first 16 bytes), and decrypt the rest of the chunk. :param chunk: ...
python
def encry_decry_chunk(chunk, key, algo, bool_encry, assoc_data): """ When bool_encry is True, encrypt a chunk of the file with the key and a randomly generated nonce. When it is False, the function extract the nonce from the cipherchunk (first 16 bytes), and decrypt the rest of the chunk. :param chunk: ...
[ "def", "encry_decry_chunk", "(", "chunk", ",", "key", ",", "algo", ",", "bool_encry", ",", "assoc_data", ")", ":", "engine", "=", "botan", ".", "cipher", "(", "algo", "=", "algo", ",", "encrypt", "=", "bool_encry", ")", "engine", ".", "set_key", "(", "...
When bool_encry is True, encrypt a chunk of the file with the key and a randomly generated nonce. When it is False, the function extract the nonce from the cipherchunk (first 16 bytes), and decrypt the rest of the chunk. :param chunk: a chunk in bytes to encrypt or decrypt. :param key: a 32 bytes key in byt...
[ "When", "bool_encry", "is", "True", "encrypt", "a", "chunk", "of", "the", "file", "with", "the", "key", "and", "a", "randomly", "generated", "nonce", ".", "When", "it", "is", "False", "the", "function", "extract", "the", "nonce", "from", "the", "cipherchun...
train
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_chunk_engine.py#L39-L64
redhat-cip/dci-control-server
dci/trackers/bugzilla.py
Bugzilla.retrieve_info
def retrieve_info(self): """Query Bugzilla API to retrieve the needed infos.""" scheme = urlparse(self.url).scheme netloc = urlparse(self.url).netloc query = urlparse(self.url).query if scheme not in ('http', 'https'): return for item in query.split('&'): ...
python
def retrieve_info(self): """Query Bugzilla API to retrieve the needed infos.""" scheme = urlparse(self.url).scheme netloc = urlparse(self.url).netloc query = urlparse(self.url).query if scheme not in ('http', 'https'): return for item in query.split('&'): ...
[ "def", "retrieve_info", "(", "self", ")", ":", "scheme", "=", "urlparse", "(", "self", ".", "url", ")", ".", "scheme", "netloc", "=", "urlparse", "(", "self", ".", "url", ")", ".", "netloc", "query", "=", "urlparse", "(", "self", ".", "url", ")", "...
Query Bugzilla API to retrieve the needed infos.
[ "Query", "Bugzilla", "API", "to", "retrieve", "the", "needed", "infos", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/trackers/bugzilla.py#L32-L74
smarie/python-valid8
valid8/validation_lib/collections.py
minlen
def minlen(min_length, strict=False # type: bool ): """ 'Minimum length' validation_function generator. Returns a validation_function to check that len(x) >= min_length (strict=False, default) or len(x) > min_length (strict=True) :param min_length: minimum length for x :p...
python
def minlen(min_length, strict=False # type: bool ): """ 'Minimum length' validation_function generator. Returns a validation_function to check that len(x) >= min_length (strict=False, default) or len(x) > min_length (strict=True) :param min_length: minimum length for x :p...
[ "def", "minlen", "(", "min_length", ",", "strict", "=", "False", "# type: bool", ")", ":", "if", "strict", ":", "def", "minlen_", "(", "x", ")", ":", "if", "len", "(", "x", ")", ">", "min_length", ":", "return", "True", "else", ":", "# raise Failure('m...
'Minimum length' validation_function generator. Returns a validation_function to check that len(x) >= min_length (strict=False, default) or len(x) > min_length (strict=True) :param min_length: minimum length for x :param strict: Boolean flag to switch between len(x) >= min_length (strict=False) and len...
[ "Minimum", "length", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "len", "(", "x", ")", ">", "=", "min_length", "(", "strict", "=", "False", "default", ")", "or", "len", "(", "x", ")", ">", "min_len...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L18-L47
smarie/python-valid8
valid8/validation_lib/collections.py
maxlen
def maxlen(max_length, strict=False # type: bool ): """ 'Maximum length' validation_function generator. Returns a validation_function to check that len(x) <= max_length (strict=False, default) or len(x) < max_length (strict=True) :param max_length: maximum length for x :param...
python
def maxlen(max_length, strict=False # type: bool ): """ 'Maximum length' validation_function generator. Returns a validation_function to check that len(x) <= max_length (strict=False, default) or len(x) < max_length (strict=True) :param max_length: maximum length for x :param...
[ "def", "maxlen", "(", "max_length", ",", "strict", "=", "False", "# type: bool", ")", ":", "if", "strict", ":", "def", "maxlen_", "(", "x", ")", ":", "if", "len", "(", "x", ")", "<", "max_length", ":", "return", "True", "else", ":", "# raise Failure('m...
'Maximum length' validation_function generator. Returns a validation_function to check that len(x) <= max_length (strict=False, default) or len(x) < max_length (strict=True) :param max_length: maximum length for x :param strict: Boolean flag to switch between len(x) <= max_length (strict=False) and len(x) ...
[ "Maximum", "length", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "len", "(", "x", ")", "<", "=", "max_length", "(", "strict", "=", "False", "default", ")", "or", "len", "(", "x", ")", "<", "max_len...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L63-L91
smarie/python-valid8
valid8/validation_lib/collections.py
has_length
def has_length(ref_length): """ 'length equals' validation function generator. Returns a validation_function to check that `len(x) == ref_length` :param ref_length: :return: """ def has_length_(x): if len(x) == ref_length: return True else: raise Wron...
python
def has_length(ref_length): """ 'length equals' validation function generator. Returns a validation_function to check that `len(x) == ref_length` :param ref_length: :return: """ def has_length_(x): if len(x) == ref_length: return True else: raise Wron...
[ "def", "has_length", "(", "ref_length", ")", ":", "def", "has_length_", "(", "x", ")", ":", "if", "len", "(", "x", ")", "==", "ref_length", ":", "return", "True", "else", ":", "raise", "WrongLength", "(", "wrong_value", "=", "x", ",", "ref_length", "="...
'length equals' validation function generator. Returns a validation_function to check that `len(x) == ref_length` :param ref_length: :return:
[ "length", "equals", "validation", "function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "len", "(", "x", ")", "==", "ref_length" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L106-L121
smarie/python-valid8
valid8/validation_lib/collections.py
length_between
def length_between(min_len, max_len, open_left=False, # type: bool open_right=False # type: bool ): """ 'Is length between' validation_function generator. Returns a validation_function to check that `min_len <= len(x) <= max_len (...
python
def length_between(min_len, max_len, open_left=False, # type: bool open_right=False # type: bool ): """ 'Is length between' validation_function generator. Returns a validation_function to check that `min_len <= len(x) <= max_len (...
[ "def", "length_between", "(", "min_len", ",", "max_len", ",", "open_left", "=", "False", ",", "# type: bool", "open_right", "=", "False", "# type: bool", ")", ":", "if", "open_left", "and", "open_right", ":", "def", "length_between_", "(", "x", ")", ":", "if...
'Is length between' validation_function generator. Returns a validation_function to check that `min_len <= len(x) <= max_len (default)`. `open_right` and `open_left` flags allow to transform each side into strict mode. For example setting `open_left=True` will enforce `min_len < len(x) <= max_len`. :pa...
[ "Is", "length", "between", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "min_len", "<", "=", "len", "(", "x", ")", "<", "=", "max_len", "(", "default", ")", ".", "open_right", "and", "open_left", "fla...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L134-L189
smarie/python-valid8
valid8/validation_lib/collections.py
is_in
def is_in(allowed_values # type: Set ): """ 'Values in' validation_function generator. Returns a validation_function to check that x is in the provided set of allowed values :param allowed_values: a set of allowed values :return: """ def is_in_allowed_values(x): if x in a...
python
def is_in(allowed_values # type: Set ): """ 'Values in' validation_function generator. Returns a validation_function to check that x is in the provided set of allowed values :param allowed_values: a set of allowed values :return: """ def is_in_allowed_values(x): if x in a...
[ "def", "is_in", "(", "allowed_values", "# type: Set", ")", ":", "def", "is_in_allowed_values", "(", "x", ")", ":", "if", "x", "in", "allowed_values", ":", "return", "True", "else", ":", "# raise Failure('is_in: x in ' + str(allowed_values) + ' does not hold for x=' + str(...
'Values in' validation_function generator. Returns a validation_function to check that x is in the provided set of allowed values :param allowed_values: a set of allowed values :return:
[ "Values", "in", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "x", "is", "in", "the", "provided", "set", "of", "allowed", "values" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L200-L217
smarie/python-valid8
valid8/validation_lib/collections.py
is_subset
def is_subset(reference_set # type: Set ): """ 'Is subset' validation_function generator. Returns a validation_function to check that x is a subset of reference_set :param reference_set: the reference set :return: """ def is_subset_of(x): missing = x - reference_set ...
python
def is_subset(reference_set # type: Set ): """ 'Is subset' validation_function generator. Returns a validation_function to check that x is a subset of reference_set :param reference_set: the reference set :return: """ def is_subset_of(x): missing = x - reference_set ...
[ "def", "is_subset", "(", "reference_set", "# type: Set", ")", ":", "def", "is_subset_of", "(", "x", ")", ":", "missing", "=", "x", "-", "reference_set", "if", "len", "(", "missing", ")", "==", "0", ":", "return", "True", "else", ":", "# raise Failure('is_s...
'Is subset' validation_function generator. Returns a validation_function to check that x is a subset of reference_set :param reference_set: the reference set :return:
[ "Is", "subset", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "x", "is", "a", "subset", "of", "reference_set" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L228-L248
smarie/python-valid8
valid8/validation_lib/collections.py
contains
def contains(ref_value): """ 'Contains' validation_function generator. Returns a validation_function to check that `ref_value in x` :param ref_value: a value that must be present in x :return: """ def contains_ref_value(x): if ref_value in x: return True else: ...
python
def contains(ref_value): """ 'Contains' validation_function generator. Returns a validation_function to check that `ref_value in x` :param ref_value: a value that must be present in x :return: """ def contains_ref_value(x): if ref_value in x: return True else: ...
[ "def", "contains", "(", "ref_value", ")", ":", "def", "contains_ref_value", "(", "x", ")", ":", "if", "ref_value", "in", "x", ":", "return", "True", "else", ":", "raise", "DoesNotContainValue", "(", "wrong_value", "=", "x", ",", "ref_value", "=", "ref_valu...
'Contains' validation_function generator. Returns a validation_function to check that `ref_value in x` :param ref_value: a value that must be present in x :return:
[ "Contains", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "ref_value", "in", "x" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L259-L274
smarie/python-valid8
valid8/validation_lib/collections.py
is_superset
def is_superset(reference_set # type: Set ): """ 'Is superset' validation_function generator. Returns a validation_function to check that x is a superset of reference_set :param reference_set: the reference set :return: """ def is_superset_of(x): missing = reference...
python
def is_superset(reference_set # type: Set ): """ 'Is superset' validation_function generator. Returns a validation_function to check that x is a superset of reference_set :param reference_set: the reference set :return: """ def is_superset_of(x): missing = reference...
[ "def", "is_superset", "(", "reference_set", "# type: Set", ")", ":", "def", "is_superset_of", "(", "x", ")", ":", "missing", "=", "reference_set", "-", "x", "if", "len", "(", "missing", ")", "==", "0", ":", "return", "True", "else", ":", "# raise Failure('...
'Is superset' validation_function generator. Returns a validation_function to check that x is a superset of reference_set :param reference_set: the reference set :return:
[ "Is", "superset", "validation_function", "generator", ".", "Returns", "a", "validation_function", "to", "check", "that", "x", "is", "a", "superset", "of", "reference_set" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L285-L305
smarie/python-valid8
valid8/validation_lib/collections.py
on_all_
def on_all_(*validation_func): """ Generates a validation_function for collection inputs where each element of the input will be validated against the validation_functions provided. For convenience, a list of validation_functions can be provided and will be replaced with an 'and_'. Note that if you...
python
def on_all_(*validation_func): """ Generates a validation_function for collection inputs where each element of the input will be validated against the validation_functions provided. For convenience, a list of validation_functions can be provided and will be replaced with an 'and_'. Note that if you...
[ "def", "on_all_", "(", "*", "validation_func", ")", ":", "# create the validation functions", "validation_function_func", "=", "_process_validation_function_s", "(", "list", "(", "validation_func", ")", ")", "def", "on_all_val", "(", "x", ")", ":", "# validate all eleme...
Generates a validation_function for collection inputs where each element of the input will be validated against the validation_functions provided. For convenience, a list of validation_functions can be provided and will be replaced with an 'and_'. Note that if you want to apply DIFFERENT validation_functio...
[ "Generates", "a", "validation_function", "for", "collection", "inputs", "where", "each", "element", "of", "the", "input", "will", "be", "validated", "against", "the", "validation_functions", "provided", ".", "For", "convenience", "a", "list", "of", "validation_funct...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L314-L349
smarie/python-valid8
valid8/validation_lib/collections.py
on_each_
def on_each_(*validation_functions_collection): """ Generates a validation_function for collection inputs where each element of the input will be validated against the corresponding validation_function(s) in the validation_functions_collection. Validators inside the tuple can be provided as a list for c...
python
def on_each_(*validation_functions_collection): """ Generates a validation_function for collection inputs where each element of the input will be validated against the corresponding validation_function(s) in the validation_functions_collection. Validators inside the tuple can be provided as a list for c...
[ "def", "on_each_", "(", "*", "validation_functions_collection", ")", ":", "# create a tuple of validation functions.", "validation_function_funcs", "=", "tuple", "(", "_process_validation_function_s", "(", "validation_func", ")", "for", "validation_func", "in", "validation_func...
Generates a validation_function for collection inputs where each element of the input will be validated against the corresponding validation_function(s) in the validation_functions_collection. Validators inside the tuple can be provided as a list for convenience, this will be replaced with an 'and_' operator if...
[ "Generates", "a", "validation_function", "for", "collection", "inputs", "where", "each", "element", "of", "the", "input", "will", "be", "validated", "against", "the", "corresponding", "validation_function", "(", "s", ")", "in", "the", "validation_functions_collection"...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/validation_lib/collections.py#L353-L404
redhat-cip/dci-control-server
dci/api/v1/jobs_events.py
get_jobs_events_from_sequence
def get_jobs_events_from_sequence(user, sequence): """Get all the jobs events from a given sequence number.""" args = schemas.args(flask.request.args.to_dict()) if user.is_not_super_admin(): raise dci_exc.Unauthorized() query = sql.select([models.JOBS_EVENTS]). \ select_from(models.JO...
python
def get_jobs_events_from_sequence(user, sequence): """Get all the jobs events from a given sequence number.""" args = schemas.args(flask.request.args.to_dict()) if user.is_not_super_admin(): raise dci_exc.Unauthorized() query = sql.select([models.JOBS_EVENTS]). \ select_from(models.JO...
[ "def", "get_jobs_events_from_sequence", "(", "user", ",", "sequence", ")", ":", "args", "=", "schemas", ".", "args", "(", "flask", ".", "request", ".", "args", ".", "to_dict", "(", ")", ")", "if", "user", ".", "is_not_super_admin", "(", ")", ":", "raise"...
Get all the jobs events from a given sequence number.
[ "Get", "all", "the", "jobs", "events", "from", "a", "given", "sequence", "number", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/jobs_events.py#L37-L63
mediawiki-utilities/python-mwxml
mwxml/iteration/dump.py
Dump.from_file
def from_file(cls, f): """ Constructs a :class:`~mwxml.iteration.dump.Dump` from a `file` pointer. :Parameters: f : `file` A plain text file pointer containing XML to process """ element = ElementIterator.from_file(f) assert element.tag == "me...
python
def from_file(cls, f): """ Constructs a :class:`~mwxml.iteration.dump.Dump` from a `file` pointer. :Parameters: f : `file` A plain text file pointer containing XML to process """ element = ElementIterator.from_file(f) assert element.tag == "me...
[ "def", "from_file", "(", "cls", ",", "f", ")", ":", "element", "=", "ElementIterator", ".", "from_file", "(", "f", ")", "assert", "element", ".", "tag", "==", "\"mediawiki\"", "return", "cls", ".", "from_element", "(", "element", ")" ]
Constructs a :class:`~mwxml.iteration.dump.Dump` from a `file` pointer. :Parameters: f : `file` A plain text file pointer containing XML to process
[ "Constructs", "a", ":", "class", ":", "~mwxml", ".", "iteration", ".", "dump", ".", "Dump", "from", "a", "file", "pointer", "." ]
train
https://github.com/mediawiki-utilities/python-mwxml/blob/6a8c18be99cd0bcee9c496e607f08bf4dfe5b510/mwxml/iteration/dump.py#L136-L146
mediawiki-utilities/python-mwxml
mwxml/iteration/dump.py
Dump.from_page_xml
def from_page_xml(cls, page_xml): """ Constructs a :class:`~mwxml.iteration.dump.Dump` from a <page> block. :Parameters: page_xml : `str` | `file` Either a plain string or a file containing <page> block XML to process """ header = """ ...
python
def from_page_xml(cls, page_xml): """ Constructs a :class:`~mwxml.iteration.dump.Dump` from a <page> block. :Parameters: page_xml : `str` | `file` Either a plain string or a file containing <page> block XML to process """ header = """ ...
[ "def", "from_page_xml", "(", "cls", ",", "page_xml", ")", ":", "header", "=", "\"\"\"\n <mediawiki xmlns=\"http://www.mediawiki.org/xml/export-0.5/\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.mediawiki.o...
Constructs a :class:`~mwxml.iteration.dump.Dump` from a <page> block. :Parameters: page_xml : `str` | `file` Either a plain string or a file containing <page> block XML to process
[ "Constructs", "a", ":", "class", ":", "~mwxml", ".", "iteration", ".", "dump", ".", "Dump", "from", "a", "<page", ">", "block", "." ]
train
https://github.com/mediawiki-utilities/python-mwxml/blob/6a8c18be99cd0bcee9c496e607f08bf4dfe5b510/mwxml/iteration/dump.py#L149-L170
Antidote1911/cryptoshop
cryptoshop/_derivation_engine.py
calc_derivation
def calc_derivation(passphrase, salt): """ Calculate a 32 bytes key derivation with Argon2. :param passphrase: A string of any length specified by user. :param salt: 512 bits generated by Botan Random Number Generator. :return: a 32 bytes keys. """ argonhash = argon2.low_level.hash_secret_ra...
python
def calc_derivation(passphrase, salt): """ Calculate a 32 bytes key derivation with Argon2. :param passphrase: A string of any length specified by user. :param salt: 512 bits generated by Botan Random Number Generator. :return: a 32 bytes keys. """ argonhash = argon2.low_level.hash_secret_ra...
[ "def", "calc_derivation", "(", "passphrase", ",", "salt", ")", ":", "argonhash", "=", "argon2", ".", "low_level", ".", "hash_secret_raw", "(", "(", "str", ".", "encode", "(", "passphrase", ")", ")", ",", "salt", "=", "salt", ",", "hash_len", "=", "32", ...
Calculate a 32 bytes key derivation with Argon2. :param passphrase: A string of any length specified by user. :param salt: 512 bits generated by Botan Random Number Generator. :return: a 32 bytes keys.
[ "Calculate", "a", "32", "bytes", "key", "derivation", "with", "Argon2", ".", ":", "param", "passphrase", ":", "A", "string", "of", "any", "length", "specified", "by", "user", ".", ":", "param", "salt", ":", "512", "bits", "generated", "by", "Botan", "Ran...
train
https://github.com/Antidote1911/cryptoshop/blob/0b7ff4a6848f2733f4737606957e8042a4d6ca0b/cryptoshop/_derivation_engine.py#L29-L39
jmurty/xml4h
xml4h/impls/xml_dom_minidom.py
XmlDomImplAdapter.get_node_text
def get_node_text(self, node): """ Return contatenated value of all text node children of this element """ text_children = [n.nodeValue for n in self.get_node_children(node) if n.nodeType == xml.dom.Node.TEXT_NODE] if text_children: return u''...
python
def get_node_text(self, node): """ Return contatenated value of all text node children of this element """ text_children = [n.nodeValue for n in self.get_node_children(node) if n.nodeType == xml.dom.Node.TEXT_NODE] if text_children: return u''...
[ "def", "get_node_text", "(", "self", ",", "node", ")", ":", "text_children", "=", "[", "n", ".", "nodeValue", "for", "n", "in", "self", ".", "get_node_children", "(", "node", ")", "if", "n", ".", "nodeType", "==", "xml", ".", "dom", ".", "Node", ".",...
Return contatenated value of all text node children of this element
[ "Return", "contatenated", "value", "of", "all", "text", "node", "children", "of", "this", "element" ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_dom_minidom.py#L119-L128
jmurty/xml4h
xml4h/impls/xml_dom_minidom.py
XmlDomImplAdapter.set_node_text
def set_node_text(self, node, text): """ Set text value as sole Text child node of element; any existing Text nodes are removed """ # Remove any existing Text node children for child in self.get_node_children(node): if child.nodeType == xml.dom.Node.TEXT_NODE:...
python
def set_node_text(self, node, text): """ Set text value as sole Text child node of element; any existing Text nodes are removed """ # Remove any existing Text node children for child in self.get_node_children(node): if child.nodeType == xml.dom.Node.TEXT_NODE:...
[ "def", "set_node_text", "(", "self", ",", "node", ",", "text", ")", ":", "# Remove any existing Text node children", "for", "child", "in", "self", ".", "get_node_children", "(", "node", ")", ":", "if", "child", ".", "nodeType", "==", "xml", ".", "dom", ".", ...
Set text value as sole Text child node of element; any existing Text nodes are removed
[ "Set", "text", "value", "as", "sole", "Text", "child", "node", "of", "element", ";", "any", "existing", "Text", "nodes", "are", "removed" ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/impls/xml_dom_minidom.py#L130-L141
inveniosoftware/invenio-assets
invenio_assets/glob.py
GlobBundle._get_contents
def _get_contents(self): """Create strings from glob strings.""" def files(): for value in super(GlobBundle, self)._get_contents(): for path in glob.glob(value): yield path return list(files())
python
def _get_contents(self): """Create strings from glob strings.""" def files(): for value in super(GlobBundle, self)._get_contents(): for path in glob.glob(value): yield path return list(files())
[ "def", "_get_contents", "(", "self", ")", ":", "def", "files", "(", ")", ":", "for", "value", "in", "super", "(", "GlobBundle", ",", "self", ")", ".", "_get_contents", "(", ")", ":", "for", "path", "in", "glob", ".", "glob", "(", "value", ")", ":",...
Create strings from glob strings.
[ "Create", "strings", "from", "glob", "strings", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/glob.py#L31-L37
smarie/python-valid8
valid8/_typing_inspect.py
is_generic_type
def is_generic_type(tp): """Test if the given type is a generic type. This includes Generic itself, but excludes special typing constructs such as Union, Tuple, Callable, ClassVar. Examples:: is_generic_type(int) == False is_generic_type(Union[int, str]) == False is_generic_type(Uni...
python
def is_generic_type(tp): """Test if the given type is a generic type. This includes Generic itself, but excludes special typing constructs such as Union, Tuple, Callable, ClassVar. Examples:: is_generic_type(int) == False is_generic_type(Union[int, str]) == False is_generic_type(Uni...
[ "def", "is_generic_type", "(", "tp", ")", ":", "if", "NEW_TYPING", ":", "return", "(", "isinstance", "(", "tp", ",", "type", ")", "and", "issubclass", "(", "tp", ",", "Generic", ")", "or", "isinstance", "(", "tp", ",", "_GenericAlias", ")", "and", "tp"...
Test if the given type is a generic type. This includes Generic itself, but excludes special typing constructs such as Union, Tuple, Callable, ClassVar. Examples:: is_generic_type(int) == False is_generic_type(Union[int, str]) == False is_generic_type(Union[int, T]) == False is_...
[ "Test", "if", "the", "given", "type", "is", "a", "generic", "type", ".", "This", "includes", "Generic", "itself", "but", "excludes", "special", "typing", "constructs", "such", "as", "Union", "Tuple", "Callable", "ClassVar", ".", "Examples", "::" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/_typing_inspect.py#L39-L62
smarie/python-valid8
valid8/_typing_inspect.py
is_union_type
def is_union_type(tp): """Test if the type is a union type. Examples:: is_union_type(int) == False is_union_type(Union) == True is_union_type(Union[int, int]) == False is_union_type(Union[T, int]) == True """ if NEW_TYPING: return (tp is Union or isin...
python
def is_union_type(tp): """Test if the type is a union type. Examples:: is_union_type(int) == False is_union_type(Union) == True is_union_type(Union[int, int]) == False is_union_type(Union[T, int]) == True """ if NEW_TYPING: return (tp is Union or isin...
[ "def", "is_union_type", "(", "tp", ")", ":", "if", "NEW_TYPING", ":", "return", "(", "tp", "is", "Union", "or", "isinstance", "(", "tp", ",", "_GenericAlias", ")", "and", "tp", ".", "__origin__", "is", "Union", ")", "try", ":", "from", "typing", "impor...
Test if the type is a union type. Examples:: is_union_type(int) == False is_union_type(Union) == True is_union_type(Union[int, int]) == False is_union_type(Union[T, int]) == True
[ "Test", "if", "the", "type", "is", "a", "union", "type", ".", "Examples", "::" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/_typing_inspect.py#L136-L152
smarie/python-valid8
valid8/_typing_inspect.py
is_classvar
def is_classvar(tp): """Test if the type represents a class variable. Examples:: is_classvar(int) == False is_classvar(ClassVar) == True is_classvar(ClassVar[int]) == True is_classvar(ClassVar[List[T]]) == True """ if NEW_TYPING: return (tp is ClassVar or ...
python
def is_classvar(tp): """Test if the type represents a class variable. Examples:: is_classvar(int) == False is_classvar(ClassVar) == True is_classvar(ClassVar[int]) == True is_classvar(ClassVar[List[T]]) == True """ if NEW_TYPING: return (tp is ClassVar or ...
[ "def", "is_classvar", "(", "tp", ")", ":", "if", "NEW_TYPING", ":", "return", "(", "tp", "is", "ClassVar", "or", "isinstance", "(", "tp", ",", "_GenericAlias", ")", "and", "tp", ".", "__origin__", "is", "ClassVar", ")", "try", ":", "from", "typing", "i...
Test if the type represents a class variable. Examples:: is_classvar(int) == False is_classvar(ClassVar) == True is_classvar(ClassVar[int]) == True is_classvar(ClassVar[List[T]]) == True
[ "Test", "if", "the", "type", "represents", "a", "class", "variable", ".", "Examples", "::" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/_typing_inspect.py#L166-L182
jmurty/xml4h
xml4h/__init__.py
parse
def parse(to_parse, ignore_whitespace_text_nodes=True, adapter=None): """ Parse an XML document into an *xml4h*-wrapped DOM representation using an underlying XML library implementation. :param to_parse: an XML document file, document string, or the path to an XML file. If a string value is giv...
python
def parse(to_parse, ignore_whitespace_text_nodes=True, adapter=None): """ Parse an XML document into an *xml4h*-wrapped DOM representation using an underlying XML library implementation. :param to_parse: an XML document file, document string, or the path to an XML file. If a string value is giv...
[ "def", "parse", "(", "to_parse", ",", "ignore_whitespace_text_nodes", "=", "True", ",", "adapter", "=", "None", ")", ":", "if", "adapter", "is", "None", ":", "adapter", "=", "best_adapter", "if", "isinstance", "(", "to_parse", ",", "basestring", ")", "and", ...
Parse an XML document into an *xml4h*-wrapped DOM representation using an underlying XML library implementation. :param to_parse: an XML document file, document string, or the path to an XML file. If a string value is given that contains a ``<`` character it is treated as literal XML data, othe...
[ "Parse", "an", "XML", "document", "into", "an", "*", "xml4h", "*", "-", "wrapped", "DOM", "representation", "using", "an", "underlying", "XML", "library", "implementation", "." ]
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/__init__.py#L41-L70
jmurty/xml4h
xml4h/__init__.py
build
def build(tagname_or_element, ns_uri=None, adapter=None): """ Return a :class:`~xml4h.builder.Builder` that represents an element in a new or existing XML DOM and provides "chainable" methods focussed specifically on adding XML content. :param tagname_or_element: a string name for the root node of ...
python
def build(tagname_or_element, ns_uri=None, adapter=None): """ Return a :class:`~xml4h.builder.Builder` that represents an element in a new or existing XML DOM and provides "chainable" methods focussed specifically on adding XML content. :param tagname_or_element: a string name for the root node of ...
[ "def", "build", "(", "tagname_or_element", ",", "ns_uri", "=", "None", ",", "adapter", "=", "None", ")", ":", "if", "adapter", "is", "None", ":", "adapter", "=", "best_adapter", "if", "isinstance", "(", "tagname_or_element", ",", "basestring", ")", ":", "d...
Return a :class:`~xml4h.builder.Builder` that represents an element in a new or existing XML DOM and provides "chainable" methods focussed specifically on adding XML content. :param tagname_or_element: a string name for the root node of a new XML document, or an :class:`~xml4h.nodes.Element` node i...
[ "Return", "a", ":", "class", ":", "~xml4h", ".", "builder", ".", "Builder", "that", "represents", "an", "element", "in", "a", "new", "or", "existing", "XML", "DOM", "and", "provides", "chainable", "methods", "focussed", "specifically", "on", "adding", "XML",...
train
https://github.com/jmurty/xml4h/blob/adbb45e27a01a869a505aee7bc16bad2f517b511/xml4h/__init__.py#L73-L105
smarie/python-valid8
valid8/entry_points.py
get_none_policy_text
def get_none_policy_text(none_policy, # type: int verbose=False # type: bool ): """ Returns a user-friendly description of a NonePolicy taking into account NoneArgPolicy :param none_policy: :param verbose: :return: """ if none_policy is N...
python
def get_none_policy_text(none_policy, # type: int verbose=False # type: bool ): """ Returns a user-friendly description of a NonePolicy taking into account NoneArgPolicy :param none_policy: :param verbose: :return: """ if none_policy is N...
[ "def", "get_none_policy_text", "(", "none_policy", ",", "# type: int", "verbose", "=", "False", "# type: bool", ")", ":", "if", "none_policy", "is", "NonePolicy", ".", "SKIP", ":", "return", "\"accept None without performing validation\"", "if", "verbose", "else", "'S...
Returns a user-friendly description of a NonePolicy taking into account NoneArgPolicy :param none_policy: :param verbose: :return:
[ "Returns", "a", "user", "-", "friendly", "description", "of", "a", "NonePolicy", "taking", "into", "account", "NoneArgPolicy" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L53-L76
smarie/python-valid8
valid8/entry_points.py
_add_none_handler
def _add_none_handler(validation_callable, # type: Callable none_policy # type: int ): # type: (...) -> Callable """ Adds a wrapper or nothing around the provided validation_callable, depending on the selected policy :param validation_callable: ...
python
def _add_none_handler(validation_callable, # type: Callable none_policy # type: int ): # type: (...) -> Callable """ Adds a wrapper or nothing around the provided validation_callable, depending on the selected policy :param validation_callable: ...
[ "def", "_add_none_handler", "(", "validation_callable", ",", "# type: Callable", "none_policy", "# type: int", ")", ":", "# type: (...) -> Callable", "if", "none_policy", "is", "NonePolicy", ".", "SKIP", ":", "return", "_none_accepter", "(", "validation_callable", ")", ...
Adds a wrapper or nothing around the provided validation_callable, depending on the selected policy :param validation_callable: :param none_policy: an int representing the None policy, see NonePolicy :return:
[ "Adds", "a", "wrapper", "or", "nothing", "around", "the", "provided", "validation_callable", "depending", "on", "the", "selected", "policy" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L79-L100
smarie/python-valid8
valid8/entry_points.py
add_base_type_dynamically
def add_base_type_dynamically(error_type, additional_type): """ Utility method to create a new type dynamically, inheriting from both error_type (first) and additional_type (second). The class representation (repr(cls)) of the resulting class reflects this by displaying both names (fully qualified for t...
python
def add_base_type_dynamically(error_type, additional_type): """ Utility method to create a new type dynamically, inheriting from both error_type (first) and additional_type (second). The class representation (repr(cls)) of the resulting class reflects this by displaying both names (fully qualified for t...
[ "def", "add_base_type_dynamically", "(", "error_type", ",", "additional_type", ")", ":", "# the new type created dynamically, with the same name", "class", "new_error_type", "(", "with_metaclass", "(", "MetaReprForValidator", ",", "error_type", ",", "additional_type", ",", "o...
Utility method to create a new type dynamically, inheriting from both error_type (first) and additional_type (second). The class representation (repr(cls)) of the resulting class reflects this by displaying both names (fully qualified for the first type, __name__ for the second) For example ``` > n...
[ "Utility", "method", "to", "create", "a", "new", "type", "dynamically", "inheriting", "from", "both", "error_type", "(", "first", ")", "and", "additional_type", "(", "second", ")", ".", "The", "class", "representation", "(", "repr", "(", "cls", "))", "of", ...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L346-L369
smarie/python-valid8
valid8/entry_points.py
assert_valid
def assert_valid(name, # type: str value, # type: Any *validation_func, # type: ValidationFuncs **kwargs): """ Validates value `value` using validation function(s) `base_validator_s`. As opposed to `is_valid`, this function raises ...
python
def assert_valid(name, # type: str value, # type: Any *validation_func, # type: ValidationFuncs **kwargs): """ Validates value `value` using validation function(s) `base_validator_s`. As opposed to `is_valid`, this function raises ...
[ "def", "assert_valid", "(", "name", ",", "# type: str", "value", ",", "# type: Any", "*", "validation_func", ",", "# type: ValidationFuncs", "*", "*", "kwargs", ")", ":", "error_type", ",", "help_msg", ",", "none_policy", "=", "pop_kwargs", "(", "kwargs", ",", ...
Validates value `value` using validation function(s) `base_validator_s`. As opposed to `is_valid`, this function raises a `ValidationError` if validation fails. It is therefore designed to be used for defensive programming, in an independent statement before the code that you intent to protect. ```pyt...
[ "Validates", "value", "value", "using", "validation", "function", "(", "s", ")", "base_validator_s", ".", "As", "opposed", "to", "is_valid", "this", "function", "raises", "a", "ValidationError", "if", "validation", "fails", "." ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L669-L711
smarie/python-valid8
valid8/entry_points.py
is_valid
def is_valid(value, *validation_func, # type: Union[Callable, List[Callable]] **kwargs ): # type: (...) -> bool """ Validates value `value` using validation function(s) `validator_func`. As opposed to `assert_valid`, this function returns a boolean indicating if v...
python
def is_valid(value, *validation_func, # type: Union[Callable, List[Callable]] **kwargs ): # type: (...) -> bool """ Validates value `value` using validation function(s) `validator_func`. As opposed to `assert_valid`, this function returns a boolean indicating if v...
[ "def", "is_valid", "(", "value", ",", "*", "validation_func", ",", "# type: Union[Callable, List[Callable]]", "*", "*", "kwargs", ")", ":", "# type: (...) -> bool", "none_policy", "=", "pop_kwargs", "(", "kwargs", ",", "[", "(", "'none_policy'", ",", "None", ")", ...
Validates value `value` using validation function(s) `validator_func`. As opposed to `assert_valid`, this function returns a boolean indicating if validation was a success or a failure. It is therefore designed to be used within if ... else ... statements: ```python if is_valid(x, isfinite): .....
[ "Validates", "value", "value", "using", "validation", "function", "(", "s", ")", "validator_func", ".", "As", "opposed", "to", "assert_valid", "this", "function", "returns", "a", "boolean", "indicating", "if", "validation", "was", "a", "success", "or", "a", "f...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L724-L757
smarie/python-valid8
valid8/entry_points.py
ValidationError.create_manually
def create_manually(cls, validation_function_name, # type: str var_name, # type: str var_value, validation_outcome=None, # type: Any help_msg=None, # type: str ...
python
def create_manually(cls, validation_function_name, # type: str var_name, # type: str var_value, validation_outcome=None, # type: Any help_msg=None, # type: str ...
[ "def", "create_manually", "(", "cls", ",", "validation_function_name", ",", "# type: str", "var_name", ",", "# type: str", "var_value", ",", "validation_outcome", "=", "None", ",", "# type: Any", "help_msg", "=", "None", ",", "# type: str", "append_details", "=", "T...
Creates an instance without using a Validator. This method is not the primary way that errors are created - they should rather created by the validation entry points. However it can be handy in rare edge cases. :param validation_function_name: :param var_name: :param var_value:...
[ "Creates", "an", "instance", "without", "using", "a", "Validator", "." ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L174-L208
smarie/python-valid8
valid8/entry_points.py
ValidationError.get_details
def get_details(self): """ The function called to get the details appended to the help message when self.append_details is True """ # create the exception main message according to the type of result if isinstance(self.validation_outcome, Exception): prefix = 'Validation function [...
python
def get_details(self): """ The function called to get the details appended to the help message when self.append_details is True """ # create the exception main message according to the type of result if isinstance(self.validation_outcome, Exception): prefix = 'Validation function [...
[ "def", "get_details", "(", "self", ")", ":", "# create the exception main message according to the type of result", "if", "isinstance", "(", "self", ".", "validation_outcome", ",", "Exception", ")", ":", "prefix", "=", "'Validation function [{val}] raised '", "if", "self", ...
The function called to get the details appended to the help message when self.append_details is True
[ "The", "function", "called", "to", "get", "the", "details", "appended", "to", "the", "help", "message", "when", "self", ".", "append_details", "is", "True" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L282-L303
smarie/python-valid8
valid8/entry_points.py
ValidationError.get_variable_str
def get_variable_str(self): """ Utility method to get the variable value or 'var_name=value' if name is not None. Note that values with large string representations will not get printed :return: """ if self.var_name is None: prefix = '' else: ...
python
def get_variable_str(self): """ Utility method to get the variable value or 'var_name=value' if name is not None. Note that values with large string representations will not get printed :return: """ if self.var_name is None: prefix = '' else: ...
[ "def", "get_variable_str", "(", "self", ")", ":", "if", "self", ".", "var_name", "is", "None", ":", "prefix", "=", "''", "else", ":", "prefix", "=", "self", ".", "var_name", "suffix", "=", "str", "(", "self", ".", "var_value", ")", "if", "len", "(", ...
Utility method to get the variable value or 'var_name=value' if name is not None. Note that values with large string representations will not get printed :return:
[ "Utility", "method", "to", "get", "the", "variable", "value", "or", "var_name", "=", "value", "if", "name", "is", "not", "None", ".", "Note", "that", "values", "with", "large", "string", "representations", "will", "not", "get", "printed" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L305-L326
smarie/python-valid8
valid8/entry_points.py
Validator.assert_valid
def assert_valid(self, name, # type: str value, # type: Any error_type=None, # type: Type[ValidationError] help_msg=None, # type: str **kw_context_args): """ Asserts that t...
python
def assert_valid(self, name, # type: str value, # type: Any error_type=None, # type: Type[ValidationError] help_msg=None, # type: str **kw_context_args): """ Asserts that t...
[ "def", "assert_valid", "(", "self", ",", "name", ",", "# type: str", "value", ",", "# type: Any", "error_type", "=", "None", ",", "# type: Type[ValidationError]", "help_msg", "=", "None", ",", "# type: str", "*", "*", "kw_context_args", ")", ":", "try", ":", "...
Asserts that the provided named value is valid with respect to the inner base validation functions. It returns silently in case of success, and raises a `ValidationError` or a subclass in case of failure. This corresponds to a 'Defensive programming' (sometimes known as 'Offensive programming') mode. ...
[ "Asserts", "that", "the", "provided", "named", "value", "is", "valid", "with", "respect", "to", "the", "inner", "base", "validation", "functions", ".", "It", "returns", "silently", "in", "case", "of", "success", "and", "raises", "a", "ValidationError", "or", ...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L517-L564
smarie/python-valid8
valid8/entry_points.py
Validator._create_validation_error
def _create_validation_error(self, name, # type: str value, # type: Any validation_outcome=None, # type: Any error_type=None, # type: Type[...
python
def _create_validation_error(self, name, # type: str value, # type: Any validation_outcome=None, # type: Any error_type=None, # type: Type[...
[ "def", "_create_validation_error", "(", "self", ",", "name", ",", "# type: str", "value", ",", "# type: Any", "validation_outcome", "=", "None", ",", "# type: Any", "error_type", "=", "None", ",", "# type: Type[ValidationError]", "help_msg", "=", "None", ",", "# typ...
The function doing the final error raising.
[ "The", "function", "doing", "the", "final", "error", "raising", "." ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L566-L604
smarie/python-valid8
valid8/entry_points.py
Validator.is_valid
def is_valid(self, value # type: Any ): # type: (...) -> bool """ Validates the provided value and returns a boolean indicating success or failure. Any Exception happening in the validation process will be silently caught. :param value: the val...
python
def is_valid(self, value # type: Any ): # type: (...) -> bool """ Validates the provided value and returns a boolean indicating success or failure. Any Exception happening in the validation process will be silently caught. :param value: the val...
[ "def", "is_valid", "(", "self", ",", "value", "# type: Any", ")", ":", "# type: (...) -> bool", "# noinspection PyBroadException", "try", ":", "# perform validation", "res", "=", "self", ".", "main_function", "(", "value", ")", "# return a boolean indicating if success or...
Validates the provided value and returns a boolean indicating success or failure. Any Exception happening in the validation process will be silently caught. :param value: the value to validate :return: a boolean flag indicating success or failure
[ "Validates", "the", "provided", "value", "and", "returns", "a", "boolean", "indicating", "success", "or", "failure", ".", "Any", "Exception", "happening", "in", "the", "validation", "process", "will", "be", "silently", "caught", "." ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points.py#L631-L652
redhat-cip/dci-control-server
dci/api/v1/tags.py
create_tags
def create_tags(user): """Create a tag.""" values = { 'id': utils.gen_uuid(), 'created_at': datetime.datetime.utcnow().isoformat() } values.update(schemas.tag.post(flask.request.json)) with flask.g.db_conn.begin(): where_clause = sql.and_( _TABLE.c.name == values...
python
def create_tags(user): """Create a tag.""" values = { 'id': utils.gen_uuid(), 'created_at': datetime.datetime.utcnow().isoformat() } values.update(schemas.tag.post(flask.request.json)) with flask.g.db_conn.begin(): where_clause = sql.and_( _TABLE.c.name == values...
[ "def", "create_tags", "(", "user", ")", ":", "values", "=", "{", "'id'", ":", "utils", ".", "gen_uuid", "(", ")", ",", "'created_at'", ":", "datetime", ".", "datetime", ".", "utcnow", "(", ")", ".", "isoformat", "(", ")", "}", "values", ".", "update"...
Create a tag.
[ "Create", "a", "tag", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/tags.py#L72-L93
redhat-cip/dci-control-server
dci/api/v1/tags.py
get_tags
def get_tags(user): """Get all tags.""" args = schemas.args(flask.request.args.to_dict()) query = v1_utils.QueryBuilder(_TABLE, args, _T_COLUMNS) nb_rows = query.get_number_of_rows() rows = query.execute(fetchall=True) rows = v1_utils.format_result(rows, _TABLE.name) return flask.jsonify({'t...
python
def get_tags(user): """Get all tags.""" args = schemas.args(flask.request.args.to_dict()) query = v1_utils.QueryBuilder(_TABLE, args, _T_COLUMNS) nb_rows = query.get_number_of_rows() rows = query.execute(fetchall=True) rows = v1_utils.format_result(rows, _TABLE.name) return flask.jsonify({'t...
[ "def", "get_tags", "(", "user", ")", ":", "args", "=", "schemas", ".", "args", "(", "flask", ".", "request", ".", "args", ".", "to_dict", "(", ")", ")", "query", "=", "v1_utils", ".", "QueryBuilder", "(", "_TABLE", ",", "args", ",", "_T_COLUMNS", ")"...
Get all tags.
[ "Get", "all", "tags", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/tags.py#L98-L105
redhat-cip/dci-control-server
dci/api/v1/tags.py
delete_tag_by_id
def delete_tag_by_id(user, tag_id): """Delete a tag.""" query = _TABLE.delete().where(_TABLE.c.id == tag_id) result = flask.g.db_conn.execute(query) if not result.rowcount: raise dci_exc.DCIConflict('Tag deletion conflict', tag_id) return flask.Response(None, 204, content_type='application...
python
def delete_tag_by_id(user, tag_id): """Delete a tag.""" query = _TABLE.delete().where(_TABLE.c.id == tag_id) result = flask.g.db_conn.execute(query) if not result.rowcount: raise dci_exc.DCIConflict('Tag deletion conflict', tag_id) return flask.Response(None, 204, content_type='application...
[ "def", "delete_tag_by_id", "(", "user", ",", "tag_id", ")", ":", "query", "=", "_TABLE", ".", "delete", "(", ")", ".", "where", "(", "_TABLE", ".", "c", ".", "id", "==", "tag_id", ")", "result", "=", "flask", ".", "g", ".", "db_conn", ".", "execute...
Delete a tag.
[ "Delete", "a", "tag", "." ]
train
https://github.com/redhat-cip/dci-control-server/blob/b416cf935ec93e4fdd5741f61a21cabecf8454d2/dci/api/v1/tags.py#L110-L118
inveniosoftware/invenio-assets
invenio_assets/ext.py
InvenioAssets.init_app
def init_app(self, app, entry_point_group='invenio_assets.bundles', **kwargs): """Initialize application object. :param app: An instance of :class:`~flask.Flask`. :param entry_point_group: A name of entry point group used to load ``webassets`` bundles. .. v...
python
def init_app(self, app, entry_point_group='invenio_assets.bundles', **kwargs): """Initialize application object. :param app: An instance of :class:`~flask.Flask`. :param entry_point_group: A name of entry point group used to load ``webassets`` bundles. .. v...
[ "def", "init_app", "(", "self", ",", "app", ",", "entry_point_group", "=", "'invenio_assets.bundles'", ",", "*", "*", "kwargs", ")", ":", "self", ".", "init_config", "(", "app", ")", "self", ".", "env", ".", "init_app", "(", "app", ")", "self", ".", "c...
Initialize application object. :param app: An instance of :class:`~flask.Flask`. :param entry_point_group: A name of entry point group used to load ``webassets`` bundles. .. versionchanged:: 1.0.0b2 The *entrypoint* has been renamed to *entry_point_group*.
[ "Initialize", "application", "object", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/ext.py#L41-L60
inveniosoftware/invenio-assets
invenio_assets/ext.py
InvenioAssets.init_config
def init_config(self, app): """Initialize configuration. :param app: An instance of :class:`~flask.Flask`. """ app.config.setdefault('REQUIREJS_BASEURL', app.static_folder) app.config.setdefault('COLLECT_STATIC_ROOT', app.static_folder) app.config.setdefault('COLLECT_STO...
python
def init_config(self, app): """Initialize configuration. :param app: An instance of :class:`~flask.Flask`. """ app.config.setdefault('REQUIREJS_BASEURL', app.static_folder) app.config.setdefault('COLLECT_STATIC_ROOT', app.static_folder) app.config.setdefault('COLLECT_STO...
[ "def", "init_config", "(", "self", ",", "app", ")", ":", "app", ".", "config", ".", "setdefault", "(", "'REQUIREJS_BASEURL'", ",", "app", ".", "static_folder", ")", "app", ".", "config", ".", "setdefault", "(", "'COLLECT_STATIC_ROOT'", ",", "app", ".", "st...
Initialize configuration. :param app: An instance of :class:`~flask.Flask`.
[ "Initialize", "configuration", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/ext.py#L62-L73
inveniosoftware/invenio-assets
invenio_assets/ext.py
InvenioAssets.load_entrypoint
def load_entrypoint(self, entry_point_group): """Load entrypoint. :param entry_point_group: A name of entry point group used to load ``webassets`` bundles. .. versionchanged:: 1.0.0b2 The *entrypoint* has been renamed to *entry_point_group*. """ for ep in...
python
def load_entrypoint(self, entry_point_group): """Load entrypoint. :param entry_point_group: A name of entry point group used to load ``webassets`` bundles. .. versionchanged:: 1.0.0b2 The *entrypoint* has been renamed to *entry_point_group*. """ for ep in...
[ "def", "load_entrypoint", "(", "self", ",", "entry_point_group", ")", ":", "for", "ep", "in", "pkg_resources", ".", "iter_entry_points", "(", "entry_point_group", ")", ":", "self", ".", "env", ".", "register", "(", "ep", ".", "name", ",", "ep", ".", "load"...
Load entrypoint. :param entry_point_group: A name of entry point group used to load ``webassets`` bundles. .. versionchanged:: 1.0.0b2 The *entrypoint* has been renamed to *entry_point_group*.
[ "Load", "entrypoint", "." ]
train
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/ext.py#L75-L85
smarie/python-valid8
valid8/entry_points_inline.py
assert_instance_of
def assert_instance_of(value, allowed_types # type: Union[Type, Tuple[Type]] ): """ An inlined version of instance_of(var_types)(value) without 'return True': it does not return anything in case of success, and raises a HasWrongType exception in case of failure...
python
def assert_instance_of(value, allowed_types # type: Union[Type, Tuple[Type]] ): """ An inlined version of instance_of(var_types)(value) without 'return True': it does not return anything in case of success, and raises a HasWrongType exception in case of failure...
[ "def", "assert_instance_of", "(", "value", ",", "allowed_types", "# type: Union[Type, Tuple[Type]]", ")", ":", "if", "not", "isinstance", "(", "value", ",", "allowed_types", ")", ":", "try", ":", "# more than 1 ?", "allowed_types", "[", "1", "]", "raise", "HasWron...
An inlined version of instance_of(var_types)(value) without 'return True': it does not return anything in case of success, and raises a HasWrongType exception in case of failure. Used in validate and validation/validator :param value: the value to check :param allowed_types: the type(s) to enforce. If...
[ "An", "inlined", "version", "of", "instance_of", "(", "var_types", ")", "(", "value", ")", "without", "return", "True", ":", "it", "does", "not", "return", "anything", "in", "case", "of", "success", "and", "raises", "a", "HasWrongType", "exception", "in", ...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_inline.py#L25-L51
smarie/python-valid8
valid8/entry_points_inline.py
assert_subclass_of
def assert_subclass_of(typ, allowed_types # type: Union[Type, Tuple[Type]] ): """ An inlined version of subclass_of(var_types)(value) without 'return True': it does not return anything in case of success, and raises a IsWrongType exception in case of failure. ...
python
def assert_subclass_of(typ, allowed_types # type: Union[Type, Tuple[Type]] ): """ An inlined version of subclass_of(var_types)(value) without 'return True': it does not return anything in case of success, and raises a IsWrongType exception in case of failure. ...
[ "def", "assert_subclass_of", "(", "typ", ",", "allowed_types", "# type: Union[Type, Tuple[Type]]", ")", ":", "if", "not", "issubclass", "(", "typ", ",", "allowed_types", ")", ":", "try", ":", "# more than 1 ?", "allowed_types", "[", "1", "]", "raise", "IsWrongType...
An inlined version of subclass_of(var_types)(value) without 'return True': it does not return anything in case of success, and raises a IsWrongType exception in case of failure. Used in validate and validation/validator :param typ: the type to check :param allowed_types: the type(s) to enforce. If a t...
[ "An", "inlined", "version", "of", "subclass_of", "(", "var_types", ")", "(", "value", ")", "without", "return", "True", ":", "it", "does", "not", "return", "anything", "in", "case", "of", "success", "and", "raises", "a", "IsWrongType", "exception", "in", "...
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_inline.py#L54-L80
smarie/python-valid8
valid8/entry_points_inline.py
validate
def validate(name, # type: str value, # type: Any enforce_not_none=True, # type: bool equals=None, # type: Any instance_of=None, # type: Union[Type, Tuple[Type]] subclass_of=None, # type: Union[Ty...
python
def validate(name, # type: str value, # type: Any enforce_not_none=True, # type: bool equals=None, # type: Any instance_of=None, # type: Union[Type, Tuple[Type]] subclass_of=None, # type: Union[Ty...
[ "def", "validate", "(", "name", ",", "# type: str", "value", ",", "# type: Any", "enforce_not_none", "=", "True", ",", "# type: bool", "equals", "=", "None", ",", "# type: Any", "instance_of", "=", "None", ",", "# type: Union[Type, Tuple[Type]]", "subclass_of", "=",...
A validation function for quick inline validation of `value`, with minimal capabilities: * None handling: reject None (enforce_not_none=True, default), or accept None silently (enforce_not_none=False) * Type validation: `value` should be an instance of any of `var_types` if provided * Value validation: ...
[ "A", "validation", "function", "for", "quick", "inline", "validation", "of", "value", "with", "minimal", "capabilities", ":" ]
train
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_inline.py#L125-L305