repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
atl/py-smartdc
smartdc/datacenter.py
DataCenter.delete_image
def delete_image(self, identifier): """ :: DELETE /:login/images/:id :param identifier: match on the listed image identifier :type identifier: :py:class:`basestring` or :py:class:`dict` A string or a dictionary containing an ``id`` key may b...
python
def delete_image(self, identifier): """ :: DELETE /:login/images/:id :param identifier: match on the listed image identifier :type identifier: :py:class:`basestring` or :py:class:`dict` A string or a dictionary containing an ``id`` key may b...
[ "def", "delete_image", "(", "self", ",", "identifier", ")", ":", "if", "isinstance", "(", "identifier", ",", "dict", ")", ":", "identifier", "=", "identifier", ".", "get", "(", "'id'", ",", "''", ")", "j", ",", "r", "=", "self", ".", "request", "(", ...
:: DELETE /:login/images/:id :param identifier: match on the listed image identifier :type identifier: :py:class:`basestring` or :py:class:`dict` A string or a dictionary containing an ``id`` key may be passed in. Will raise an error if the response...
[ "::", "DELETE", "/", ":", "login", "/", "images", "/", ":", "id", ":", "param", "identifier", ":", "match", "on", "the", "listed", "image", "identifier", ":", "type", "identifier", ":", ":", "py", ":", "class", ":", "basestring", "or", ":", "py", ":"...
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L999-L1017
train
This method deletes an image from the specified key.
pmacosta/pexdoc
pexdoc/exh.py
_build_exclusion_list
def _build_exclusion_list(exclude): """Build file names list of modules to exclude from exception handling.""" mod_files = [] if exclude: for mod in exclude: mdir = None mod_file = None for token in mod.split("."): try: mfile, m...
python
def _build_exclusion_list(exclude): """Build file names list of modules to exclude from exception handling.""" mod_files = [] if exclude: for mod in exclude: mdir = None mod_file = None for token in mod.split("."): try: mfile, m...
[ "def", "_build_exclusion_list", "(", "exclude", ")", ":", "mod_files", "=", "[", "]", "if", "exclude", ":", "for", "mod", "in", "exclude", ":", "mdir", "=", "None", "mod_file", "=", "None", "for", "token", "in", "mod", ".", "split", "(", "\".\"", ")", ...
Build file names list of modules to exclude from exception handling.
[ "Build", "file", "names", "list", "of", "modules", "to", "exclude", "from", "exception", "handling", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L42-L60
train
Build file names list of modules to exclude from exception handling.
pmacosta/pexdoc
pexdoc/exh.py
_invalid_frame
def _invalid_frame(fobj): """Select valid stack frame to process.""" fin = fobj.f_code.co_filename invalid_module = any([fin.endswith(item) for item in _INVALID_MODULES_LIST]) return invalid_module or (not os.path.isfile(fin))
python
def _invalid_frame(fobj): """Select valid stack frame to process.""" fin = fobj.f_code.co_filename invalid_module = any([fin.endswith(item) for item in _INVALID_MODULES_LIST]) return invalid_module or (not os.path.isfile(fin))
[ "def", "_invalid_frame", "(", "fobj", ")", ":", "fin", "=", "fobj", ".", "f_code", ".", "co_filename", "invalid_module", "=", "any", "(", "[", "fin", ".", "endswith", "(", "item", ")", "for", "item", "in", "_INVALID_MODULES_LIST", "]", ")", "return", "in...
Select valid stack frame to process.
[ "Select", "valid", "stack", "frame", "to", "process", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L63-L67
train
Select valid stack frame to process.
pmacosta/pexdoc
pexdoc/exh.py
_merge_cdicts
def _merge_cdicts(self, clut, exdict, separator): """Merge callable look-up tables from two objects.""" if not self._full_cname: return # Find all callables that are not in self exceptions dictionary # and create new tokens for them repl_dict = {} for key, value in _sorted_keys_items(clu...
python
def _merge_cdicts(self, clut, exdict, separator): """Merge callable look-up tables from two objects.""" if not self._full_cname: return # Find all callables that are not in self exceptions dictionary # and create new tokens for them repl_dict = {} for key, value in _sorted_keys_items(clu...
[ "def", "_merge_cdicts", "(", "self", ",", "clut", ",", "exdict", ",", "separator", ")", ":", "if", "not", "self", ".", "_full_cname", ":", "return", "# Find all callables that are not in self exceptions dictionary", "# and create new tokens for them", "repl_dict", "=", ...
Merge callable look-up tables from two objects.
[ "Merge", "callable", "look", "-", "up", "tables", "from", "two", "objects", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L81-L108
train
Merge callable look - up tables from two objects.
pmacosta/pexdoc
pexdoc/exh.py
_merge_ex_dicts
def _merge_ex_dicts(sexdict, oexdict): """Merge callable look-up tables from two objects.""" # pylint: disable=R0101 for okey, ovalue in oexdict.items(): # Keys in other dictionary are callable paths or # callables ids depending on the full_cname argument # of the handler if ...
python
def _merge_ex_dicts(sexdict, oexdict): """Merge callable look-up tables from two objects.""" # pylint: disable=R0101 for okey, ovalue in oexdict.items(): # Keys in other dictionary are callable paths or # callables ids depending on the full_cname argument # of the handler if ...
[ "def", "_merge_ex_dicts", "(", "sexdict", ",", "oexdict", ")", ":", "# pylint: disable=R0101", "for", "okey", ",", "ovalue", "in", "oexdict", ".", "items", "(", ")", ":", "# Keys in other dictionary are callable paths or", "# callables ids depending on the full_cname argume...
Merge callable look-up tables from two objects.
[ "Merge", "callable", "look", "-", "up", "tables", "from", "two", "objects", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L111-L147
train
Merge callable look - up tables from two objects.
pmacosta/pexdoc
pexdoc/exh.py
_sorted_keys_items
def _sorted_keys_items(dobj): """Return dictionary items sorted by key.""" keys = sorted(dobj.keys()) for key in keys: yield key, dobj[key]
python
def _sorted_keys_items(dobj): """Return dictionary items sorted by key.""" keys = sorted(dobj.keys()) for key in keys: yield key, dobj[key]
[ "def", "_sorted_keys_items", "(", "dobj", ")", ":", "keys", "=", "sorted", "(", "dobj", ".", "keys", "(", ")", ")", "for", "key", "in", "keys", ":", "yield", "key", ",", "dobj", "[", "key", "]" ]
Return dictionary items sorted by key.
[ "Return", "dictionary", "items", "sorted", "by", "key", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L150-L154
train
Return dictionary items sorted by key.
pmacosta/pexdoc
pexdoc/exh.py
addex
def addex(extype, exmsg, condition=None, edata=None): r""" Add an exception in the global exception handler. :param extype: Exception type; *must* be derived from the `Exception <https://docs.python.org/2/library/exceptions.html# exceptions.Exception>`_ class :type...
python
def addex(extype, exmsg, condition=None, edata=None): r""" Add an exception in the global exception handler. :param extype: Exception type; *must* be derived from the `Exception <https://docs.python.org/2/library/exceptions.html# exceptions.Exception>`_ class :type...
[ "def", "addex", "(", "extype", ",", "exmsg", ",", "condition", "=", "None", ",", "edata", "=", "None", ")", ":", "return", "_ExObj", "(", "extype", ",", "exmsg", ",", "condition", ",", "edata", ")", ".", "craise" ]
r""" Add an exception in the global exception handler. :param extype: Exception type; *must* be derived from the `Exception <https://docs.python.org/2/library/exceptions.html# exceptions.Exception>`_ class :type extype: Exception type object, i.e. RuntimeError, TypeEr...
[ "r", "Add", "an", "exception", "in", "the", "global", "exception", "handler", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L157-L207
train
r Adds an exception in the global exception handler.
pmacosta/pexdoc
pexdoc/exh.py
addai
def addai(argname, condition=None): r""" Add an "AI" exception in the global exception handler. An "AI" exception is of the type :code:`RuntimeError('Argument \`*[argname]*\` is not valid')` where :code:`*[argname]*` is the value of the **argname** argument :param argname: Argument name :t...
python
def addai(argname, condition=None): r""" Add an "AI" exception in the global exception handler. An "AI" exception is of the type :code:`RuntimeError('Argument \`*[argname]*\` is not valid')` where :code:`*[argname]*` is the value of the **argname** argument :param argname: Argument name :t...
[ "def", "addai", "(", "argname", ",", "condition", "=", "None", ")", ":", "# pylint: disable=C0123", "if", "not", "isinstance", "(", "argname", ",", "str", ")", ":", "raise", "RuntimeError", "(", "\"Argument `argname` is not valid\"", ")", "if", "(", "condition",...
r""" Add an "AI" exception in the global exception handler. An "AI" exception is of the type :code:`RuntimeError('Argument \`*[argname]*\` is not valid')` where :code:`*[argname]*` is the value of the **argname** argument :param argname: Argument name :type argname: string :param conditi...
[ "r", "Add", "an", "AI", "exception", "in", "the", "global", "exception", "handler", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L210-L239
train
r Add an AI exception in the global exception handler.
pmacosta/pexdoc
pexdoc/exh.py
get_or_create_exh_obj
def get_or_create_exh_obj(full_cname=False, exclude=None, callables_fname=None): r""" Return global exception handler if set, otherwise create a new one and return it. :param full_cname: Flag that indicates whether fully qualified function/method/class property names are obtained for...
python
def get_or_create_exh_obj(full_cname=False, exclude=None, callables_fname=None): r""" Return global exception handler if set, otherwise create a new one and return it. :param full_cname: Flag that indicates whether fully qualified function/method/class property names are obtained for...
[ "def", "get_or_create_exh_obj", "(", "full_cname", "=", "False", ",", "exclude", "=", "None", ",", "callables_fname", "=", "None", ")", ":", "if", "not", "hasattr", "(", "__builtin__", ",", "\"_EXH\"", ")", ":", "set_exh_obj", "(", "ExHandle", "(", "full_cna...
r""" Return global exception handler if set, otherwise create a new one and return it. :param full_cname: Flag that indicates whether fully qualified function/method/class property names are obtained for functions/methods/class properties that use the ...
[ "r", "Return", "global", "exception", "handler", "if", "set", "otherwise", "create", "a", "new", "one", "and", "return", "it", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L260-L305
train
r Returns global exception handler if set otherwise create a new one and return it.
pmacosta/pexdoc
pexdoc/exh.py
_ExObj.craise
def craise(self, condition, edata=None): r""" Raise exception conditionally. :param condition: Flag that indicates whether the exception is raised *(True)* or not *(False)* :type condition: boolean :param edata: Replacement values for fields in the ex...
python
def craise(self, condition, edata=None): r""" Raise exception conditionally. :param condition: Flag that indicates whether the exception is raised *(True)* or not *(False)* :type condition: boolean :param edata: Replacement values for fields in the ex...
[ "def", "craise", "(", "self", ",", "condition", ",", "edata", "=", "None", ")", ":", "self", ".", "_exh", ".", "raise_exception_if", "(", "self", ".", "_exname", ",", "condition", ",", "edata", ",", "_keys", "=", "self", ".", "_ex_data", ")" ]
r""" Raise exception conditionally. :param condition: Flag that indicates whether the exception is raised *(True)* or not *(False)* :type condition: boolean :param edata: Replacement values for fields in the exception message (see :py:me...
[ "r", "Raise", "exception", "conditionally", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L422-L459
train
Raise exception conditionally.
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._flatten_ex_dict
def _flatten_ex_dict(self): """Flatten structure of exceptions dictionary.""" odict = {} for _, fdict in self._ex_dict.items(): for (extype, exmsg), value in fdict.items(): key = value["name"] odict[key] = copy.deepcopy(value) del odict...
python
def _flatten_ex_dict(self): """Flatten structure of exceptions dictionary.""" odict = {} for _, fdict in self._ex_dict.items(): for (extype, exmsg), value in fdict.items(): key = value["name"] odict[key] = copy.deepcopy(value) del odict...
[ "def", "_flatten_ex_dict", "(", "self", ")", ":", "odict", "=", "{", "}", "for", "_", ",", "fdict", "in", "self", ".", "_ex_dict", ".", "items", "(", ")", ":", "for", "(", "extype", ",", "exmsg", ")", ",", "value", "in", "fdict", ".", "items", "(...
Flatten structure of exceptions dictionary.
[ "Flatten", "structure", "of", "exceptions", "dictionary", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L804-L814
train
Flatten structure of exceptions dictionary.
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._format_msg
def _format_msg(self, msg, edata): """Substitute parameters in exception message.""" edata = edata if isinstance(edata, list) else [edata] for fdict in edata: if "*[{token}]*".format(token=fdict["field"]) not in msg: raise RuntimeError( "Field {tok...
python
def _format_msg(self, msg, edata): """Substitute parameters in exception message.""" edata = edata if isinstance(edata, list) else [edata] for fdict in edata: if "*[{token}]*".format(token=fdict["field"]) not in msg: raise RuntimeError( "Field {tok...
[ "def", "_format_msg", "(", "self", ",", "msg", ",", "edata", ")", ":", "edata", "=", "edata", "if", "isinstance", "(", "edata", ",", "list", ")", "else", "[", "edata", "]", "for", "fdict", "in", "edata", ":", "if", "\"*[{token}]*\"", ".", "format", "...
Substitute parameters in exception message.
[ "Substitute", "parameters", "in", "exception", "message", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L816-L829
train
Substitute parameters in exception message.
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._get_callable_full_name
def _get_callable_full_name(self, fob, fin, uobj): """Get full path [module, class (if applicable), function name] of callable.""" # Check if object is a class property name = self._property_search(fob) if name: del fob, fin, uobj return name if os.path.is...
python
def _get_callable_full_name(self, fob, fin, uobj): """Get full path [module, class (if applicable), function name] of callable.""" # Check if object is a class property name = self._property_search(fob) if name: del fob, fin, uobj return name if os.path.is...
[ "def", "_get_callable_full_name", "(", "self", ",", "fob", ",", "fin", ",", "uobj", ")", ":", "# Check if object is a class property", "name", "=", "self", ".", "_property_search", "(", "fob", ")", "if", "name", ":", "del", "fob", ",", "fin", ",", "uobj", ...
Get full path [module, class (if applicable), function name] of callable.
[ "Get", "full", "path", "[", "module", "class", "(", "if", "applicable", ")", "function", "name", "]", "of", "callable", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L835-L860
train
Get full path of callable.
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._get_exceptions_db
def _get_exceptions_db(self): """Return a list of dictionaries suitable to be used with ptrie module.""" template = "{extype} ({exmsg}){raised}" if not self._full_cname: # When full callable name is not used the calling path is # irrelevant and there is no function associ...
python
def _get_exceptions_db(self): """Return a list of dictionaries suitable to be used with ptrie module.""" template = "{extype} ({exmsg}){raised}" if not self._full_cname: # When full callable name is not used the calling path is # irrelevant and there is no function associ...
[ "def", "_get_exceptions_db", "(", "self", ")", ":", "template", "=", "\"{extype} ({exmsg}){raised}\"", "if", "not", "self", ".", "_full_cname", ":", "# When full callable name is not used the calling path is", "# irrelevant and there is no function associated with an", "# exception...
Return a list of dictionaries suitable to be used with ptrie module.
[ "Return", "a", "list", "of", "dictionaries", "suitable", "to", "be", "used", "with", "ptrie", "module", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1025-L1063
train
Return a list of dictionaries suitable to be used with ptrie module module.
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._get_ex_data
def _get_ex_data(self): """Return hierarchical function name.""" func_id, func_name = self._get_callable_path() if self._full_cname: func_name = self.encode_call(func_name) return func_id, func_name
python
def _get_ex_data(self): """Return hierarchical function name.""" func_id, func_name = self._get_callable_path() if self._full_cname: func_name = self.encode_call(func_name) return func_id, func_name
[ "def", "_get_ex_data", "(", "self", ")", ":", "func_id", ",", "func_name", "=", "self", ".", "_get_callable_path", "(", ")", "if", "self", ".", "_full_cname", ":", "func_name", "=", "self", ".", "encode_call", "(", "func_name", ")", "return", "func_id", ",...
Return hierarchical function name.
[ "Return", "hierarchical", "function", "name", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1065-L1070
train
Return hierarchical function name.
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._property_search
def _property_search(self, fobj): """Return full name if object is a class property, otherwise return None.""" # Get class object scontext = fobj.f_locals.get("self", None) class_obj = scontext.__class__ if scontext is not None else None if not class_obj: del fobj, sc...
python
def _property_search(self, fobj): """Return full name if object is a class property, otherwise return None.""" # Get class object scontext = fobj.f_locals.get("self", None) class_obj = scontext.__class__ if scontext is not None else None if not class_obj: del fobj, sc...
[ "def", "_property_search", "(", "self", ",", "fobj", ")", ":", "# Get class object", "scontext", "=", "fobj", ".", "f_locals", ".", "get", "(", "\"self\"", ",", "None", ")", "class_obj", "=", "scontext", ".", "__class__", "if", "scontext", "is", "not", "No...
Return full name if object is a class property, otherwise return None.
[ "Return", "full", "name", "if", "object", "is", "a", "class", "property", "otherwise", "return", "None", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1072-L1129
train
Search for a class property in a file.
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._raise_exception
def _raise_exception(self, eobj, edata=None): """Raise exception by name.""" _, _, tbobj = sys.exc_info() if edata: emsg = self._format_msg(eobj["msg"], edata) _rwtb(eobj["type"], emsg, tbobj) else: _rwtb(eobj["type"], eobj["msg"], tbobj)
python
def _raise_exception(self, eobj, edata=None): """Raise exception by name.""" _, _, tbobj = sys.exc_info() if edata: emsg = self._format_msg(eobj["msg"], edata) _rwtb(eobj["type"], emsg, tbobj) else: _rwtb(eobj["type"], eobj["msg"], tbobj)
[ "def", "_raise_exception", "(", "self", ",", "eobj", ",", "edata", "=", "None", ")", ":", "_", ",", "_", ",", "tbobj", "=", "sys", ".", "exc_info", "(", ")", "if", "edata", ":", "emsg", "=", "self", ".", "_format_msg", "(", "eobj", "[", "\"msg\"", ...
Raise exception by name.
[ "Raise", "exception", "by", "name", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1131-L1138
train
Raise exception by name.
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._unwrap_obj
def _unwrap_obj(self, fobj, fun): """Unwrap decorators.""" try: prev_func_obj, next_func_obj = ( fobj.f_globals[fun], getattr(fobj.f_globals[fun], "__wrapped__", None), ) while next_func_obj: prev_func_obj, next_func_obj...
python
def _unwrap_obj(self, fobj, fun): """Unwrap decorators.""" try: prev_func_obj, next_func_obj = ( fobj.f_globals[fun], getattr(fobj.f_globals[fun], "__wrapped__", None), ) while next_func_obj: prev_func_obj, next_func_obj...
[ "def", "_unwrap_obj", "(", "self", ",", "fobj", ",", "fun", ")", ":", "try", ":", "prev_func_obj", ",", "next_func_obj", "=", "(", "fobj", ".", "f_globals", "[", "fun", "]", ",", "getattr", "(", "fobj", ".", "f_globals", "[", "fun", "]", ",", "\"__wr...
Unwrap decorators.
[ "Unwrap", "decorators", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1140-L1158
train
Unwrap decorators.
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._validate_edata
def _validate_edata(self, edata): """Validate edata argument of raise_exception_if method.""" # pylint: disable=R0916 if edata is None: return True if not (isinstance(edata, dict) or _isiterable(edata)): return False edata = [edata] if isinstance(edata, di...
python
def _validate_edata(self, edata): """Validate edata argument of raise_exception_if method.""" # pylint: disable=R0916 if edata is None: return True if not (isinstance(edata, dict) or _isiterable(edata)): return False edata = [edata] if isinstance(edata, di...
[ "def", "_validate_edata", "(", "self", ",", "edata", ")", ":", "# pylint: disable=R0916", "if", "edata", "is", "None", ":", "return", "True", "if", "not", "(", "isinstance", "(", "edata", ",", "dict", ")", "or", "_isiterable", "(", "edata", ")", ")", ":"...
Validate edata argument of raise_exception_if method.
[ "Validate", "edata", "argument", "of", "raise_exception_if", "method", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1160-L1178
train
Validate edata argument of raise_exception_if method.
pmacosta/pexdoc
pexdoc/exh.py
ExHandle.add_exception
def add_exception(self, exname, extype, exmsg): r""" Add an exception to the handler. :param exname: Exception name; has to be unique within the namespace, duplicates are eliminated :type exname: non-numeric string :param extype: Exception type; *must* b...
python
def add_exception(self, exname, extype, exmsg): r""" Add an exception to the handler. :param exname: Exception name; has to be unique within the namespace, duplicates are eliminated :type exname: non-numeric string :param extype: Exception type; *must* b...
[ "def", "add_exception", "(", "self", ",", "exname", ",", "extype", ",", "exmsg", ")", ":", "if", "not", "isinstance", "(", "exname", ",", "str", ")", ":", "raise", "RuntimeError", "(", "\"Argument `exname` is not valid\"", ")", "number", "=", "True", "try", ...
r""" Add an exception to the handler. :param exname: Exception name; has to be unique within the namespace, duplicates are eliminated :type exname: non-numeric string :param extype: Exception type; *must* be derived from the `Exception <ht...
[ "r", "Add", "an", "exception", "to", "the", "handler", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1180-L1259
train
r Adds an exception to the handler.
pmacosta/pexdoc
pexdoc/exh.py
ExHandle.decode_call
def decode_call(self, call): """ Replace callable tokens with callable names. :param call: Encoded callable name :type call: string :rtype: string """ # Callable name is None when callable is part of exclude list if call is None: return Non...
python
def decode_call(self, call): """ Replace callable tokens with callable names. :param call: Encoded callable name :type call: string :rtype: string """ # Callable name is None when callable is part of exclude list if call is None: return Non...
[ "def", "decode_call", "(", "self", ",", "call", ")", ":", "# Callable name is None when callable is part of exclude list", "if", "call", "is", "None", ":", "return", "None", "itokens", "=", "call", ".", "split", "(", "self", ".", "_callables_separator", ")", "odic...
Replace callable tokens with callable names. :param call: Encoded callable name :type call: string :rtype: string
[ "Replace", "callable", "tokens", "with", "callable", "names", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1261-L1278
train
Decodes a callable name into a list of callable names.
pmacosta/pexdoc
pexdoc/exh.py
ExHandle.encode_call
def encode_call(self, call): """ Replace callables with tokens to reduce object memory footprint. A callable token is an integer that denotes the order in which the callable was encountered by the encoder, i.e. the first callable encoded is assigned token 0, the second callable ...
python
def encode_call(self, call): """ Replace callables with tokens to reduce object memory footprint. A callable token is an integer that denotes the order in which the callable was encountered by the encoder, i.e. the first callable encoded is assigned token 0, the second callable ...
[ "def", "encode_call", "(", "self", ",", "call", ")", ":", "# Callable name is None when callable is part of exclude list", "if", "call", "is", "None", ":", "return", "None", "itokens", "=", "call", ".", "split", "(", "self", ".", "_callables_separator", ")", "otok...
Replace callables with tokens to reduce object memory footprint. A callable token is an integer that denotes the order in which the callable was encountered by the encoder, i.e. the first callable encoded is assigned token 0, the second callable encoded is assigned token 1, etc. ...
[ "Replace", "callables", "with", "tokens", "to", "reduce", "object", "memory", "footprint", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1280-L1305
train
Encodes a callable name with tokens to reduce object memory footprint.
pmacosta/pexdoc
pexdoc/exh.py
ExHandle.raise_exception_if
def raise_exception_if(self, exname, condition, edata=None, _keys=None): r""" Raise exception conditionally. :param exname: Exception name :type exname: string :param condition: Flag that indicates whether the exception is raised *(True)* or not *(Fal...
python
def raise_exception_if(self, exname, condition, edata=None, _keys=None): r""" Raise exception conditionally. :param exname: Exception name :type exname: string :param condition: Flag that indicates whether the exception is raised *(True)* or not *(Fal...
[ "def", "raise_exception_if", "(", "self", ",", "exname", ",", "condition", ",", "edata", "=", "None", ",", "_keys", "=", "None", ")", ":", "# _edict is an argument used by the _ExObj class which saves a", "# second exception look-up since the _ExObj class can save the", "# ca...
r""" Raise exception conditionally. :param exname: Exception name :type exname: string :param condition: Flag that indicates whether the exception is raised *(True)* or not *(False)* :type condition: boolean :param edata: Replacement values ...
[ "r", "Raise", "exception", "conditionally", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1307-L1369
train
r Raise exception conditionally.
Loudr/pale
pale/endpoint.py
PaleDefaultJSONEncoder.default
def default(self, obj): """Default JSON encoding.""" try: if isinstance(obj, datetime.datetime): # do the datetime thing, or encoded = arrow.get(obj).isoformat() else: # try the normal encoder encoded = json.JSONEnc...
python
def default(self, obj): """Default JSON encoding.""" try: if isinstance(obj, datetime.datetime): # do the datetime thing, or encoded = arrow.get(obj).isoformat() else: # try the normal encoder encoded = json.JSONEnc...
[ "def", "default", "(", "self", ",", "obj", ")", ":", "try", ":", "if", "isinstance", "(", "obj", ",", "datetime", ".", "datetime", ")", ":", "# do the datetime thing, or", "encoded", "=", "arrow", ".", "get", "(", "obj", ")", ".", "isoformat", "(", ")...
Default JSON encoding.
[ "Default", "JSON", "encoding", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/endpoint.py#L36-L52
train
Default JSON encoding.
Loudr/pale
pale/endpoint.py
Endpoint._fix_up_fields
def _fix_up_fields(cls): """Add names to all of the Endpoint's Arguments. This method will get called on class declaration because of Endpoint's metaclass. The functionality is based on Google's NDB implementation.""" cls._arguments = dict() if cls.__module__ == __name_...
python
def _fix_up_fields(cls): """Add names to all of the Endpoint's Arguments. This method will get called on class declaration because of Endpoint's metaclass. The functionality is based on Google's NDB implementation.""" cls._arguments = dict() if cls.__module__ == __name_...
[ "def", "_fix_up_fields", "(", "cls", ")", ":", "cls", ".", "_arguments", "=", "dict", "(", ")", "if", "cls", ".", "__module__", "==", "__name__", ":", "# skip the classes in this file", "return", "for", "name", "in", "set", "(", "dir", "(", "cls", ")", "...
Add names to all of the Endpoint's Arguments. This method will get called on class declaration because of Endpoint's metaclass. The functionality is based on Google's NDB implementation.
[ "Add", "names", "to", "all", "of", "the", "Endpoint", "s", "Arguments", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/endpoint.py#L68-L87
train
Add names to all of the Endpoint s Arguments.
Loudr/pale
pale/endpoint.py
Endpoint._execute
def _execute(self, request, **kwargs): """The top-level execute function for the endpoint. This method is intended to remain as-is, and not be overridden. It gets called by your HTTP framework's route handler, and performs the following actions to process the request: ``authent...
python
def _execute(self, request, **kwargs): """The top-level execute function for the endpoint. This method is intended to remain as-is, and not be overridden. It gets called by your HTTP framework's route handler, and performs the following actions to process the request: ``authent...
[ "def", "_execute", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", ".", "_create_context", "(", "request", ")", "self", ".", "_authenticate", "(", ")", "context", "=", "get_current_context", "(", ")", "self", ".", "_...
The top-level execute function for the endpoint. This method is intended to remain as-is, and not be overridden. It gets called by your HTTP framework's route handler, and performs the following actions to process the request: ``authenticate_request`` Validate the Bearer to...
[ "The", "top", "-", "level", "execute", "function", "for", "the", "endpoint", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/endpoint.py#L122-L286
train
The main execute method for the endpoint.
Loudr/pale
pale/endpoint.py
Endpoint._parse_handler_result
def _parse_handler_result(self, result): """Parses the item(s) returned by your handler implementation. Handlers may return a single item (payload), or a tuple that gets passed to the Response class __init__ method of your HTTP layer. _parse_handler_result separates the payload from th...
python
def _parse_handler_result(self, result): """Parses the item(s) returned by your handler implementation. Handlers may return a single item (payload), or a tuple that gets passed to the Response class __init__ method of your HTTP layer. _parse_handler_result separates the payload from th...
[ "def", "_parse_handler_result", "(", "self", ",", "result", ")", ":", "if", "isinstance", "(", "result", ",", "(", "list", ",", "tuple", ")", ")", ":", "payload", "=", "result", "[", "0", "]", "list_result", "=", "list", "(", "result", ")", "else", "...
Parses the item(s) returned by your handler implementation. Handlers may return a single item (payload), or a tuple that gets passed to the Response class __init__ method of your HTTP layer. _parse_handler_result separates the payload from the rest the tuple, as well as providing the t...
[ "Parses", "the", "item", "(", "s", ")", "returned", "by", "your", "handler", "implementation", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/endpoint.py#L351-L367
train
Parses the item returned by the handler implementation.
shaypal5/strct
strct/lists/_list.py
order_preserving_single_index_shift
def order_preserving_single_index_shift(arr, index, new_index): """Moves a list element to a new index while preserving order. Parameters --------- arr : list The list in which to shift an element. index : int The index of the element to shift. new_index : int The index ...
python
def order_preserving_single_index_shift(arr, index, new_index): """Moves a list element to a new index while preserving order. Parameters --------- arr : list The list in which to shift an element. index : int The index of the element to shift. new_index : int The index ...
[ "def", "order_preserving_single_index_shift", "(", "arr", ",", "index", ",", "new_index", ")", ":", "if", "new_index", "==", "0", ":", "return", "[", "arr", "[", "index", "]", "]", "+", "arr", "[", "0", ":", "index", "]", "+", "arr", "[", "index", "+...
Moves a list element to a new index while preserving order. Parameters --------- arr : list The list in which to shift an element. index : int The index of the element to shift. new_index : int The index to which to shift the element. Returns ------- list ...
[ "Moves", "a", "list", "element", "to", "a", "new", "index", "while", "preserving", "order", "." ]
f3a301692d052ddb79331230b3c00625db1d83fc
https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/lists/_list.py#L32-L66
train
Moves a list element to a new index while preserving order.
shaypal5/strct
strct/lists/_list.py
order_preserving_single_element_shift
def order_preserving_single_element_shift(arr, value, new_index): """Moves a list element to a new index while preserving order. Parameters --------- arr : list The list in which to shift an element. value : object The value of the element to shift. new_index : int The i...
python
def order_preserving_single_element_shift(arr, value, new_index): """Moves a list element to a new index while preserving order. Parameters --------- arr : list The list in which to shift an element. value : object The value of the element to shift. new_index : int The i...
[ "def", "order_preserving_single_element_shift", "(", "arr", ",", "value", ",", "new_index", ")", ":", "return", "order_preserving_single_index_shift", "(", "arr", "=", "arr", ",", "index", "=", "arr", ".", "index", "(", "value", ")", ",", "new_index", "=", "ne...
Moves a list element to a new index while preserving order. Parameters --------- arr : list The list in which to shift an element. value : object The value of the element to shift. new_index : int The index to which to shift the element. Returns ------- list ...
[ "Moves", "a", "list", "element", "to", "a", "new", "index", "while", "preserving", "order", "." ]
f3a301692d052ddb79331230b3c00625db1d83fc
https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/lists/_list.py#L69-L93
train
Moves a list element to a new index while preserving order.
AASHE/python-membersuite-api-client
membersuite_api_client/client.py
ConciergeClient.get_hashed_signature
def get_hashed_signature(self, url): """ Process from Membersuite Docs: http://bit.ly/2eSIDxz """ data = "%s%s" % (url, self.association_id) if self.session_id: data = "%s%s" % (data, self.session_id) data_b = bytearray(data, 'utf-8') secret_key = base...
python
def get_hashed_signature(self, url): """ Process from Membersuite Docs: http://bit.ly/2eSIDxz """ data = "%s%s" % (url, self.association_id) if self.session_id: data = "%s%s" % (data, self.session_id) data_b = bytearray(data, 'utf-8') secret_key = base...
[ "def", "get_hashed_signature", "(", "self", ",", "url", ")", ":", "data", "=", "\"%s%s\"", "%", "(", "url", ",", "self", ".", "association_id", ")", "if", "self", ".", "session_id", ":", "data", "=", "\"%s%s\"", "%", "(", "data", ",", "self", ".", "s...
Process from Membersuite Docs: http://bit.ly/2eSIDxz
[ "Process", "from", "Membersuite", "Docs", ":", "http", ":", "//", "bit", ".", "ly", "/", "2eSIDxz" ]
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/client.py#L31-L43
train
Return the hashed signature for the given URL.
AASHE/python-membersuite-api-client
membersuite_api_client/client.py
ConciergeClient.request_session
def request_session(self): """ Performs initial request to initialize session and get session id necessary to construct all future requests. :return: Session ID to be placed in header of all other requests. """ concierge_request_header = self.construct_concierge_header( ...
python
def request_session(self): """ Performs initial request to initialize session and get session id necessary to construct all future requests. :return: Session ID to be placed in header of all other requests. """ concierge_request_header = self.construct_concierge_header( ...
[ "def", "request_session", "(", "self", ")", ":", "concierge_request_header", "=", "self", ".", "construct_concierge_header", "(", "url", "=", "\"http://membersuite.com/contracts/IConciergeAPIService/WhoAmI\"", ")", "result", "=", "self", ".", "client", ".", "service", "...
Performs initial request to initialize session and get session id necessary to construct all future requests. :return: Session ID to be placed in header of all other requests.
[ "Performs", "initial", "request", "to", "initialize", "session", "and", "get", "session", "id", "necessary", "to", "construct", "all", "future", "requests", ".", ":", "return", ":", "Session", "ID", "to", "be", "placed", "in", "header", "of", "all", "other",...
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/client.py#L45-L63
train
Makes initial request to initialize session and get session id necessary to construct all future requests.
AASHE/python-membersuite-api-client
membersuite_api_client/client.py
ConciergeClient.construct_concierge_header
def construct_concierge_header(self, url): """ Constructs the Concierge Request Header lxml object to be used as the '_soapheaders' argument for WSDL methods. """ concierge_request_header = ( etree.Element( etree.QName(XHTML_NAMESPACE, "ConciergeReques...
python
def construct_concierge_header(self, url): """ Constructs the Concierge Request Header lxml object to be used as the '_soapheaders' argument for WSDL methods. """ concierge_request_header = ( etree.Element( etree.QName(XHTML_NAMESPACE, "ConciergeReques...
[ "def", "construct_concierge_header", "(", "self", ",", "url", ")", ":", "concierge_request_header", "=", "(", "etree", ".", "Element", "(", "etree", ".", "QName", "(", "XHTML_NAMESPACE", ",", "\"ConciergeRequestHeader\"", ")", ",", "nsmap", "=", "{", "'sch'", ...
Constructs the Concierge Request Header lxml object to be used as the '_soapheaders' argument for WSDL methods.
[ "Constructs", "the", "Concierge", "Request", "Header", "lxml", "object", "to", "be", "used", "as", "the", "_soapheaders", "argument", "for", "WSDL", "methods", "." ]
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/client.py#L65-L96
train
Constructs the Concierge Request Header lxml object to be used as the _soapheaders argument for WSDL methods.
a1ezzz/wasp-general
wasp_general/network/clients/webdav.py
WWebDavClientBase.scheme_specification
def scheme_specification(cls): """ :meth:`.WSchemeHandler.scheme_specification` method implementation """ return WSchemeSpecification( cls.scheme_name(), WURIComponentVerifier(WURI.Component.username, WURIComponentVerifier.Requirement.optional), WURIComponentVerifier(WURI.Component.password, WURICompone...
python
def scheme_specification(cls): """ :meth:`.WSchemeHandler.scheme_specification` method implementation """ return WSchemeSpecification( cls.scheme_name(), WURIComponentVerifier(WURI.Component.username, WURIComponentVerifier.Requirement.optional), WURIComponentVerifier(WURI.Component.password, WURICompone...
[ "def", "scheme_specification", "(", "cls", ")", ":", "return", "WSchemeSpecification", "(", "cls", ".", "scheme_name", "(", ")", ",", "WURIComponentVerifier", "(", "WURI", ".", "Component", ".", "username", ",", "WURIComponentVerifier", ".", "Requirement", ".", ...
:meth:`.WSchemeHandler.scheme_specification` method implementation
[ ":", "meth", ":", ".", "WSchemeHandler", ".", "scheme_specification", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/webdav.py#L107-L125
train
returns a new instance of the class WSchemeSpecification
a1ezzz/wasp-general
wasp_general/network/clients/webdav.py
WWebDavClientBase.change_directory
def change_directory(self, path, *args, **kwargs): """ :meth:`.WNetworkClientProto.change_directory` method implementation """ client = self.dav_client() previous_path = self.session_path() try: if client.is_dir(self.session_path(path)) is False: raise ValueError('Unable to change current working direc...
python
def change_directory(self, path, *args, **kwargs): """ :meth:`.WNetworkClientProto.change_directory` method implementation """ client = self.dav_client() previous_path = self.session_path() try: if client.is_dir(self.session_path(path)) is False: raise ValueError('Unable to change current working direc...
[ "def", "change_directory", "(", "self", ",", "path", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "client", "=", "self", ".", "dav_client", "(", ")", "previous_path", "=", "self", ".", "session_path", "(", ")", "try", ":", "if", "client", "."...
:meth:`.WNetworkClientProto.change_directory` method implementation
[ ":", "meth", ":", ".", "WNetworkClientProto", ".", "change_directory", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/webdav.py#L136-L146
train
method implementation self. session_path = path
a1ezzz/wasp-general
wasp_general/network/clients/webdav.py
WWebDavClientBase.list_directory
def list_directory(self, *args, **kwargs): """ :meth:`.WNetworkClientProto.list_directory` method implementation """ return tuple(self.dav_client().list(self.session_path()))
python
def list_directory(self, *args, **kwargs): """ :meth:`.WNetworkClientProto.list_directory` method implementation """ return tuple(self.dav_client().list(self.session_path()))
[ "def", "list_directory", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "tuple", "(", "self", ".", "dav_client", "(", ")", ".", "list", "(", "self", ".", "session_path", "(", ")", ")", ")" ]
:meth:`.WNetworkClientProto.list_directory` method implementation
[ ":", "meth", ":", ".", "WNetworkClientProto", ".", "list_directory", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/webdav.py#L149-L152
train
method implementation for list_directory
a1ezzz/wasp-general
wasp_general/network/clients/webdav.py
WWebDavClientBase.make_directory
def make_directory(self, directory_name, *args, **kwargs): """ :meth:`.WNetworkClientProto.make_directory` method implementation """ self.dav_client().mkdir(self.join_path(self.session_path(), directory_name))
python
def make_directory(self, directory_name, *args, **kwargs): """ :meth:`.WNetworkClientProto.make_directory` method implementation """ self.dav_client().mkdir(self.join_path(self.session_path(), directory_name))
[ "def", "make_directory", "(", "self", ",", "directory_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "dav_client", "(", ")", ".", "mkdir", "(", "self", ".", "join_path", "(", "self", ".", "session_path", "(", ")", ",", "dire...
:meth:`.WNetworkClientProto.make_directory` method implementation
[ ":", "meth", ":", ".", "WNetworkClientProto", ".", "make_directory", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/webdav.py#L157-L160
train
method implementation for create_directory
a1ezzz/wasp-general
wasp_general/network/clients/webdav.py
WWebDavClientBase.remove_directory
def remove_directory(self, directory_name, *args, **kwargs): """ :meth:`.WNetworkClientProto.remove_directory` method implementation """ client = self.dav_client() remote_path = self.join_path(self.session_path(), directory_name) if client.is_dir(remote_path) is False: raise ValueError('Unable to remove n...
python
def remove_directory(self, directory_name, *args, **kwargs): """ :meth:`.WNetworkClientProto.remove_directory` method implementation """ client = self.dav_client() remote_path = self.join_path(self.session_path(), directory_name) if client.is_dir(remote_path) is False: raise ValueError('Unable to remove n...
[ "def", "remove_directory", "(", "self", ",", "directory_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "client", "=", "self", ".", "dav_client", "(", ")", "remote_path", "=", "self", ".", "join_path", "(", "self", ".", "session_path", "(", ...
:meth:`.WNetworkClientProto.remove_directory` method implementation
[ ":", "meth", ":", ".", "WNetworkClientProto", ".", "remove_directory", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/webdav.py#L165-L173
train
method implementation . remove_directory
a1ezzz/wasp-general
wasp_general/network/clients/webdav.py
WWebDavClientBase.upload_file
def upload_file(self, file_name, file_obj, *args, **kwargs): """ :meth:`.WNetworkClientProto.upload_file` method implementation """ self.dav_client().upload_to(file_obj, self.join_path(self.session_path(), file_name))
python
def upload_file(self, file_name, file_obj, *args, **kwargs): """ :meth:`.WNetworkClientProto.upload_file` method implementation """ self.dav_client().upload_to(file_obj, self.join_path(self.session_path(), file_name))
[ "def", "upload_file", "(", "self", ",", "file_name", ",", "file_obj", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "dav_client", "(", ")", ".", "upload_to", "(", "file_obj", ",", "self", ".", "join_path", "(", "self", ".", "sessi...
:meth:`.WNetworkClientProto.upload_file` method implementation
[ ":", "meth", ":", ".", "WNetworkClientProto", ".", "upload_file", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/webdav.py#L178-L181
train
method implementation for DAV Upload File Method
a1ezzz/wasp-general
wasp_general/network/clients/webdav.py
WWebDavClientBase.remove_file
def remove_file(self, file_name, *args, **kwargs): """ :meth:`.WNetworkClientProto.remove_file` method implementation """ client = self.dav_client() remote_path = self.join_path(self.session_path(), file_name) if client.is_dir(remote_path) is True: raise ValueError('Unable to remove non-file entry') clie...
python
def remove_file(self, file_name, *args, **kwargs): """ :meth:`.WNetworkClientProto.remove_file` method implementation """ client = self.dav_client() remote_path = self.join_path(self.session_path(), file_name) if client.is_dir(remote_path) is True: raise ValueError('Unable to remove non-file entry') clie...
[ "def", "remove_file", "(", "self", ",", "file_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "client", "=", "self", ".", "dav_client", "(", ")", "remote_path", "=", "self", ".", "join_path", "(", "self", ".", "session_path", "(", ")", ",...
:meth:`.WNetworkClientProto.remove_file` method implementation
[ ":", "meth", ":", ".", "WNetworkClientProto", ".", "remove_file", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/clients/webdav.py#L186-L193
train
method implementation . remove_file
OpenGov/og-python-utils
ogutils/collections/transformations.py
recursive_iter
def recursive_iter(enumerables): ''' Walks nested list-like elements as though they were sequentially available recursive_iter([[1,2], 3]) # => 1, 2, 3 ''' if not is_collection(enumerables) or isinstance(enumerables, (basestring, dict)): yield enumerables else: for...
python
def recursive_iter(enumerables): ''' Walks nested list-like elements as though they were sequentially available recursive_iter([[1,2], 3]) # => 1, 2, 3 ''' if not is_collection(enumerables) or isinstance(enumerables, (basestring, dict)): yield enumerables else: for...
[ "def", "recursive_iter", "(", "enumerables", ")", ":", "if", "not", "is_collection", "(", "enumerables", ")", "or", "isinstance", "(", "enumerables", ",", "(", "basestring", ",", "dict", ")", ")", ":", "yield", "enumerables", "else", ":", "for", "elem", "i...
Walks nested list-like elements as though they were sequentially available recursive_iter([[1,2], 3]) # => 1, 2, 3
[ "Walks", "nested", "list", "-", "like", "elements", "as", "though", "they", "were", "sequentially", "available", "recursive_iter", "(", "[[", "1", "2", "]", "3", "]", ")", "#", "=", ">", "1", "2", "3" ]
00f44927383dd1bd6348f47302c4453d56963479
https://github.com/OpenGov/og-python-utils/blob/00f44927383dd1bd6348f47302c4453d56963479/ogutils/collections/transformations.py#L5-L17
train
Walks nested list - like elements as though they were sequentially available
OpenGov/og-python-utils
ogutils/collections/transformations.py
degenerate
def degenerate(enumerable): ''' Converts generators to lists degenerate(xrange(2)) # => [0, 1] ''' if (isinstance(enumerable, xrange) or inspect.isgeneratorfunction(enumerable) or inspect.isgenerator(enumerable)): return list(enumerable) return enumerable
python
def degenerate(enumerable): ''' Converts generators to lists degenerate(xrange(2)) # => [0, 1] ''' if (isinstance(enumerable, xrange) or inspect.isgeneratorfunction(enumerable) or inspect.isgenerator(enumerable)): return list(enumerable) return enumerable
[ "def", "degenerate", "(", "enumerable", ")", ":", "if", "(", "isinstance", "(", "enumerable", ",", "xrange", ")", "or", "inspect", ".", "isgeneratorfunction", "(", "enumerable", ")", "or", "inspect", ".", "isgenerator", "(", "enumerable", ")", ")", ":", "r...
Converts generators to lists degenerate(xrange(2)) # => [0, 1]
[ "Converts", "generators", "to", "lists", "degenerate", "(", "xrange", "(", "2", "))", "#", "=", ">", "[", "0", "1", "]" ]
00f44927383dd1bd6348f47302c4453d56963479
https://github.com/OpenGov/og-python-utils/blob/00f44927383dd1bd6348f47302c4453d56963479/ogutils/collections/transformations.py#L28-L39
train
Converts generator functions to lists
OpenGov/og-python-utils
ogutils/collections/transformations.py
merge_dicts
def merge_dicts(*dicts, **copy_check): ''' Combines dictionaries into a single dictionary. If the 'copy' keyword is passed then the first dictionary is copied before update. merge_dicts({'a': 1, 'c': 1}, {'a': 2, 'b': 1}) # => {'a': 2, 'b': 1, 'c': 1} ''' merged = {} if not dic...
python
def merge_dicts(*dicts, **copy_check): ''' Combines dictionaries into a single dictionary. If the 'copy' keyword is passed then the first dictionary is copied before update. merge_dicts({'a': 1, 'c': 1}, {'a': 2, 'b': 1}) # => {'a': 2, 'b': 1, 'c': 1} ''' merged = {} if not dic...
[ "def", "merge_dicts", "(", "*", "dicts", ",", "*", "*", "copy_check", ")", ":", "merged", "=", "{", "}", "if", "not", "dicts", ":", "return", "merged", "for", "index", ",", "merge_dict", "in", "enumerate", "(", "dicts", ")", ":", "if", "index", "==",...
Combines dictionaries into a single dictionary. If the 'copy' keyword is passed then the first dictionary is copied before update. merge_dicts({'a': 1, 'c': 1}, {'a': 2, 'b': 1}) # => {'a': 2, 'b': 1, 'c': 1}
[ "Combines", "dictionaries", "into", "a", "single", "dictionary", ".", "If", "the", "copy", "keyword", "is", "passed", "then", "the", "first", "dictionary", "is", "copied", "before", "update", ".", "merge_dicts", "(", "{", "a", ":", "1", "c", ":", "1", "}...
00f44927383dd1bd6348f47302c4453d56963479
https://github.com/OpenGov/og-python-utils/blob/00f44927383dd1bd6348f47302c4453d56963479/ogutils/collections/transformations.py#L41-L57
train
Merges multiple dictionaries into a single dictionary.
OpenGov/og-python-utils
ogutils/collections/transformations.py
batch
def batch(enumerable, batch_size): ''' Breaks enumerable argument into batch size enumerable pieces. The last chunk can be of any length up to batch_size. batch(xrange(5), 3) # => [0, 1, 2], [3, 4] ''' batch_size = max(int(batch_size), 1) try: enumerable.__getitem__ ...
python
def batch(enumerable, batch_size): ''' Breaks enumerable argument into batch size enumerable pieces. The last chunk can be of any length up to batch_size. batch(xrange(5), 3) # => [0, 1, 2], [3, 4] ''' batch_size = max(int(batch_size), 1) try: enumerable.__getitem__ ...
[ "def", "batch", "(", "enumerable", ",", "batch_size", ")", ":", "batch_size", "=", "max", "(", "int", "(", "batch_size", ")", ",", "1", ")", "try", ":", "enumerable", ".", "__getitem__", "total_size", "=", "len", "(", "enumerable", ")", "except", "(", ...
Breaks enumerable argument into batch size enumerable pieces. The last chunk can be of any length up to batch_size. batch(xrange(5), 3) # => [0, 1, 2], [3, 4]
[ "Breaks", "enumerable", "argument", "into", "batch", "size", "enumerable", "pieces", ".", "The", "last", "chunk", "can", "be", "of", "any", "length", "up", "to", "batch_size", ".", "batch", "(", "xrange", "(", "5", ")", "3", ")", "#", "=", ">", "[", ...
00f44927383dd1bd6348f47302c4453d56963479
https://github.com/OpenGov/og-python-utils/blob/00f44927383dd1bd6348f47302c4453d56963479/ogutils/collections/transformations.py#L59-L82
train
Yields the first batch of size 5 pieces of the given enumerable.
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/monitoring.py
AgeGroup.group
def group(self): """ :rtype: list """ lowerbound = self.lowerbound age_group_list = [] for age_group in self.et.findall("group"): upperbound = age_group.attrib["upperbound"] try: poppercent = age_group.attrib["poppercent"] ...
python
def group(self): """ :rtype: list """ lowerbound = self.lowerbound age_group_list = [] for age_group in self.et.findall("group"): upperbound = age_group.attrib["upperbound"] try: poppercent = age_group.attrib["poppercent"] ...
[ "def", "group", "(", "self", ")", ":", "lowerbound", "=", "self", ".", "lowerbound", "age_group_list", "=", "[", "]", "for", "age_group", "in", "self", ".", "et", ".", "findall", "(", "\"group\"", ")", ":", "upperbound", "=", "age_group", ".", "attrib", ...
:rtype: list
[ ":", "rtype", ":", "list" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/monitoring.py#L22-L38
train
returns a list of all age groups in the archive
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/monitoring.py
Monitoring.continuous
def continuous(self): """ List of measures in <continuous> section Example: ["simulated EIR", "GVI coverage"] :rtype: list """ list_of_measures = [] if self.et.find("continuous") is None: return list_of_measures return self._get_measures(self.e...
python
def continuous(self): """ List of measures in <continuous> section Example: ["simulated EIR", "GVI coverage"] :rtype: list """ list_of_measures = [] if self.et.find("continuous") is None: return list_of_measures return self._get_measures(self.e...
[ "def", "continuous", "(", "self", ")", ":", "list_of_measures", "=", "[", "]", "if", "self", ".", "et", ".", "find", "(", "\"continuous\"", ")", "is", "None", ":", "return", "list_of_measures", "return", "self", ".", "_get_measures", "(", "self", ".", "e...
List of measures in <continuous> section Example: ["simulated EIR", "GVI coverage"] :rtype: list
[ "List", "of", "measures", "in", "<continuous", ">", "section", "Example", ":", "[", "simulated", "EIR", "GVI", "coverage", "]", ":", "rtype", ":", "list" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/monitoring.py#L59-L68
train
Returns a list of all continuous EIR and GVI measures in the section containing the set of continuous EIR and GVI measures.
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/monitoring.py
Monitoring.SurveyOptions
def SurveyOptions(self): """ List of measures in <SurveyOpions> section Example: ["hHost", "nPatent", "nUncomp", "simulatedEIR", "nMassGVI"] :rtype: list """ list_of_measures = [] if self.et.find("SurveyOptions") is None: return list_of_measures ...
python
def SurveyOptions(self): """ List of measures in <SurveyOpions> section Example: ["hHost", "nPatent", "nUncomp", "simulatedEIR", "nMassGVI"] :rtype: list """ list_of_measures = [] if self.et.find("SurveyOptions") is None: return list_of_measures ...
[ "def", "SurveyOptions", "(", "self", ")", ":", "list_of_measures", "=", "[", "]", "if", "self", ".", "et", ".", "find", "(", "\"SurveyOptions\"", ")", "is", "None", ":", "return", "list_of_measures", "return", "self", ".", "_get_measures", "(", "self", "."...
List of measures in <SurveyOpions> section Example: ["hHost", "nPatent", "nUncomp", "simulatedEIR", "nMassGVI"] :rtype: list
[ "List", "of", "measures", "in", "<SurveyOpions", ">", "section", "Example", ":", "[", "hHost", "nPatent", "nUncomp", "simulatedEIR", "nMassGVI", "]", ":", "rtype", ":", "list" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/monitoring.py#L77-L86
train
Returns a list of measures in <SurveyOpions > section containing the names of the survey options.
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/monitoring.py
Monitoring.detectionLimit
def detectionLimit(self): """ Detection limit for parasitaemia Limit above which a human's infection is reported as patent https://github.com/SwissTPH/openmalaria/wiki/GeneratedSchema32Doc#detection-limit-for-parasitaemia """ surveys_elem = self.et.find("surveys") ...
python
def detectionLimit(self): """ Detection limit for parasitaemia Limit above which a human's infection is reported as patent https://github.com/SwissTPH/openmalaria/wiki/GeneratedSchema32Doc#detection-limit-for-parasitaemia """ surveys_elem = self.et.find("surveys") ...
[ "def", "detectionLimit", "(", "self", ")", ":", "surveys_elem", "=", "self", ".", "et", ".", "find", "(", "\"surveys\"", ")", "if", "surveys_elem", "is", "None", ":", "return", "None", "try", ":", "detectionLimit", "=", "float", "(", "surveys_elem", ".", ...
Detection limit for parasitaemia Limit above which a human's infection is reported as patent https://github.com/SwissTPH/openmalaria/wiki/GeneratedSchema32Doc#detection-limit-for-parasitaemia
[ "Detection", "limit", "for", "parasitaemia", "Limit", "above", "which", "a", "human", "s", "infection", "is", "reported", "as", "patent", "https", ":", "//", "github", ".", "com", "/", "SwissTPH", "/", "openmalaria", "/", "wiki", "/", "GeneratedSchema32Doc#det...
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/monitoring.py#L95-L109
train
Returns the detection limit for parasitaemia
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/monitoring.py
Monitoring.surveys
def surveys(self): """ Returns the list of timesteps when survey measures has been captured None if xml document is mailformed xpath: /scenario/monitoring/survey https://github.com/SwissTPH/openmalaria/wiki/GeneratedSchema32Doc#survey-times-time-steps """ survey_t...
python
def surveys(self): """ Returns the list of timesteps when survey measures has been captured None if xml document is mailformed xpath: /scenario/monitoring/survey https://github.com/SwissTPH/openmalaria/wiki/GeneratedSchema32Doc#survey-times-time-steps """ survey_t...
[ "def", "surveys", "(", "self", ")", ":", "survey_time_list", "=", "list", "(", ")", "# Extract surveyTimes from /scenario/monitoring/surveys section", "# Using root element instead of xpath to avoid problems with namespaces", "# (root tag was <scenario> prior to schema 32, and then it was ...
Returns the list of timesteps when survey measures has been captured None if xml document is mailformed xpath: /scenario/monitoring/survey https://github.com/SwissTPH/openmalaria/wiki/GeneratedSchema32Doc#survey-times-time-steps
[ "Returns", "the", "list", "of", "timesteps", "when", "survey", "measures", "has", "been", "captured", "None", "if", "xml", "document", "is", "mailformed", "xpath", ":", "/", "scenario", "/", "monitoring", "/", "survey", "https", ":", "//", "github", ".", "...
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/monitoring.py#L120-L137
train
Returns the list of timesteps when survey measures have been captured None if xml document is mailformed
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/monitoring.py
Monitoring._get_measures
def _get_measures(self, et): """ Get a list of measures in <continuous> or <SurveyOptions> section """ list_of_measures = [] for tag in et.findall("option"): if tag.attrib.get("value", "true") == "true": list_of_measures.append(tag.attrib["name"]) ...
python
def _get_measures(self, et): """ Get a list of measures in <continuous> or <SurveyOptions> section """ list_of_measures = [] for tag in et.findall("option"): if tag.attrib.get("value", "true") == "true": list_of_measures.append(tag.attrib["name"]) ...
[ "def", "_get_measures", "(", "self", ",", "et", ")", ":", "list_of_measures", "=", "[", "]", "for", "tag", "in", "et", ".", "findall", "(", "\"option\"", ")", ":", "if", "tag", ".", "attrib", ".", "get", "(", "\"value\"", ",", "\"true\"", ")", "==", ...
Get a list of measures in <continuous> or <SurveyOptions> section
[ "Get", "a", "list", "of", "measures", "in", "<continuous", ">", "or", "<SurveyOptions", ">", "section" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/monitoring.py#L155-L163
train
Get a list of measures in continuous or survey options section
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/monitoring.py
Monitoring._replace_measures
def _replace_measures(self, et, list_of_measures): """ Build <continuous> or <SurveyOptions> section """ for measure in et.findall("option"): et.remove(measure) for measure_name in list_of_measures: tag = Element("option") tag.attrib["name"] =...
python
def _replace_measures(self, et, list_of_measures): """ Build <continuous> or <SurveyOptions> section """ for measure in et.findall("option"): et.remove(measure) for measure_name in list_of_measures: tag = Element("option") tag.attrib["name"] =...
[ "def", "_replace_measures", "(", "self", ",", "et", ",", "list_of_measures", ")", ":", "for", "measure", "in", "et", ".", "findall", "(", "\"option\"", ")", ":", "et", ".", "remove", "(", "measure", ")", "for", "measure_name", "in", "list_of_measures", ":"...
Build <continuous> or <SurveyOptions> section
[ "Build", "<continuous", ">", "or", "<SurveyOptions", ">", "section" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/monitoring.py#L165-L176
train
Replace the measure names in the XML element et with the list of measures.
ET-CS/dry
dry/__init__.py
init_current_directory
def init_current_directory(): """Initialize and create dry config file(s) inside current directory""" settings_directory=project_path+'/.dry' settings_file=settings_directory+'/config.py' if os.path.isdir(settings_directory): # already initialized print("directory already initialized.") return # ...
python
def init_current_directory(): """Initialize and create dry config file(s) inside current directory""" settings_directory=project_path+'/.dry' settings_file=settings_directory+'/config.py' if os.path.isdir(settings_directory): # already initialized print("directory already initialized.") return # ...
[ "def", "init_current_directory", "(", ")", ":", "settings_directory", "=", "project_path", "+", "'/.dry'", "settings_file", "=", "settings_directory", "+", "'/config.py'", "if", "os", ".", "path", ".", "isdir", "(", "settings_directory", ")", ":", "# already initial...
Initialize and create dry config file(s) inside current directory
[ "Initialize", "and", "create", "dry", "config", "file", "(", "s", ")", "inside", "current", "directory" ]
e8e73903dab372122ebb89a11d2168dd239faf51
https://github.com/ET-CS/dry/blob/e8e73903dab372122ebb89a11d2168dd239faf51/dry/__init__.py#L382-L394
train
Initialize and create dry config file inside current directory
ET-CS/dry
dry/__init__.py
main
def main(): """Entry point for the application script""" from docopt import docopt; arguments = docopt(__doc__, version=package.title() + " v" + version) global verbose verbose = arguments['--verbose'] if verbose: print("target folder: " + target_folder + " (" + project_path +"/" + target_folder +...
python
def main(): """Entry point for the application script""" from docopt import docopt; arguments = docopt(__doc__, version=package.title() + " v" + version) global verbose verbose = arguments['--verbose'] if verbose: print("target folder: " + target_folder + " (" + project_path +"/" + target_folder +...
[ "def", "main", "(", ")", ":", "from", "docopt", "import", "docopt", "arguments", "=", "docopt", "(", "__doc__", ",", "version", "=", "package", ".", "title", "(", ")", "+", "\" v\"", "+", "version", ")", "global", "verbose", "verbose", "=", "arguments", ...
Entry point for the application script
[ "Entry", "point", "for", "the", "application", "script" ]
e8e73903dab372122ebb89a11d2168dd239faf51
https://github.com/ET-CS/dry/blob/e8e73903dab372122ebb89a11d2168dd239faf51/dry/__init__.py#L399-L434
train
Entry point for the application script
ashmastaflash/kal-wrapper
kalibrate/fn.py
options_string_builder
def options_string_builder(option_mapping, args): """Return arguments for CLI invocation of kal.""" options_string = "" for option, flag in option_mapping.items(): if option in args: options_string += str(" %s %s" % (flag, str(args[option]))) return options_string
python
def options_string_builder(option_mapping, args): """Return arguments for CLI invocation of kal.""" options_string = "" for option, flag in option_mapping.items(): if option in args: options_string += str(" %s %s" % (flag, str(args[option]))) return options_string
[ "def", "options_string_builder", "(", "option_mapping", ",", "args", ")", ":", "options_string", "=", "\"\"", "for", "option", ",", "flag", "in", "option_mapping", ".", "items", "(", ")", ":", "if", "option", "in", "args", ":", "options_string", "+=", "str",...
Return arguments for CLI invocation of kal.
[ "Return", "arguments", "for", "CLI", "invocation", "of", "kal", "." ]
80ee03ab7bd3172ac26b769d6b442960f3424b0e
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L6-L12
train
Return arguments for CLI invocation of kal.
ashmastaflash/kal-wrapper
kalibrate/fn.py
build_kal_scan_band_string
def build_kal_scan_band_string(kal_bin, band, args): """Return string for CLI invocation of kal, for band scan.""" option_mapping = {"gain": "-g", "device": "-d", "error": "-e"} if not sanity.scan_band_is_valid(band): err_txt = "Unsupported band designatio...
python
def build_kal_scan_band_string(kal_bin, band, args): """Return string for CLI invocation of kal, for band scan.""" option_mapping = {"gain": "-g", "device": "-d", "error": "-e"} if not sanity.scan_band_is_valid(band): err_txt = "Unsupported band designatio...
[ "def", "build_kal_scan_band_string", "(", "kal_bin", ",", "band", ",", "args", ")", ":", "option_mapping", "=", "{", "\"gain\"", ":", "\"-g\"", ",", "\"device\"", ":", "\"-d\"", ",", "\"error\"", ":", "\"-e\"", "}", "if", "not", "sanity", ".", "scan_band_is_...
Return string for CLI invocation of kal, for band scan.
[ "Return", "string", "for", "CLI", "invocation", "of", "kal", "for", "band", "scan", "." ]
80ee03ab7bd3172ac26b769d6b442960f3424b0e
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L15-L25
train
Build a string for CLI invocation of kal for band scan.
ashmastaflash/kal-wrapper
kalibrate/fn.py
build_kal_scan_channel_string
def build_kal_scan_channel_string(kal_bin, channel, args): """Return string for CLI invocation of kal, for channel scan.""" option_mapping = {"gain": "-g", "device": "-d", "error": "-e"} base_string = "%s -v -c %s" % (kal_bin, channel) base_string += options_s...
python
def build_kal_scan_channel_string(kal_bin, channel, args): """Return string for CLI invocation of kal, for channel scan.""" option_mapping = {"gain": "-g", "device": "-d", "error": "-e"} base_string = "%s -v -c %s" % (kal_bin, channel) base_string += options_s...
[ "def", "build_kal_scan_channel_string", "(", "kal_bin", ",", "channel", ",", "args", ")", ":", "option_mapping", "=", "{", "\"gain\"", ":", "\"-g\"", ",", "\"device\"", ":", "\"-d\"", ",", "\"error\"", ":", "\"-e\"", "}", "base_string", "=", "\"%s -v -c %s\"", ...
Return string for CLI invocation of kal, for channel scan.
[ "Return", "string", "for", "CLI", "invocation", "of", "kal", "for", "channel", "scan", "." ]
80ee03ab7bd3172ac26b769d6b442960f3424b0e
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L28-L35
train
Build a string for CLI invocation of kal for channel scan.
ashmastaflash/kal-wrapper
kalibrate/fn.py
herz_me
def herz_me(val): """Return integer value for Hz, translated from (MHz|kHz|Hz).""" result = 0 if val.endswith("MHz"): stripped = val.replace("MHz", "") strip_fl = float(stripped) result = strip_fl * 1000000 elif val.endswith("kHz"): stripped = val.replace("kHz", "") ...
python
def herz_me(val): """Return integer value for Hz, translated from (MHz|kHz|Hz).""" result = 0 if val.endswith("MHz"): stripped = val.replace("MHz", "") strip_fl = float(stripped) result = strip_fl * 1000000 elif val.endswith("kHz"): stripped = val.replace("kHz", "") ...
[ "def", "herz_me", "(", "val", ")", ":", "result", "=", "0", "if", "val", ".", "endswith", "(", "\"MHz\"", ")", ":", "stripped", "=", "val", ".", "replace", "(", "\"MHz\"", ",", "\"\"", ")", "strip_fl", "=", "float", "(", "stripped", ")", "result", ...
Return integer value for Hz, translated from (MHz|kHz|Hz).
[ "Return", "integer", "value", "for", "Hz", "translated", "from", "(", "MHz|kHz|Hz", ")", "." ]
80ee03ab7bd3172ac26b769d6b442960f3424b0e
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L38-L52
train
Return integer value for Hz translated from ( MHz | kHz |Hz.
ashmastaflash/kal-wrapper
kalibrate/fn.py
determine_final_freq
def determine_final_freq(base, direction, modifier): """Return integer for frequency.""" result = 0 if direction == "+": result = base + modifier elif direction == "-": result = base - modifier return(result)
python
def determine_final_freq(base, direction, modifier): """Return integer for frequency.""" result = 0 if direction == "+": result = base + modifier elif direction == "-": result = base - modifier return(result)
[ "def", "determine_final_freq", "(", "base", ",", "direction", ",", "modifier", ")", ":", "result", "=", "0", "if", "direction", "==", "\"+\"", ":", "result", "=", "base", "+", "modifier", "elif", "direction", "==", "\"-\"", ":", "result", "=", "base", "-...
Return integer for frequency.
[ "Return", "integer", "for", "frequency", "." ]
80ee03ab7bd3172ac26b769d6b442960f3424b0e
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L55-L62
train
Return integer for frequency.
ashmastaflash/kal-wrapper
kalibrate/fn.py
to_eng
def to_eng(num_in): """Return number in engineering notation.""" x = decimal.Decimal(str(num_in)) eng_not = x.normalize().to_eng_string() return(eng_not)
python
def to_eng(num_in): """Return number in engineering notation.""" x = decimal.Decimal(str(num_in)) eng_not = x.normalize().to_eng_string() return(eng_not)
[ "def", "to_eng", "(", "num_in", ")", ":", "x", "=", "decimal", ".", "Decimal", "(", "str", "(", "num_in", ")", ")", "eng_not", "=", "x", ".", "normalize", "(", ")", ".", "to_eng_string", "(", ")", "return", "(", "eng_not", ")" ]
Return number in engineering notation.
[ "Return", "number", "in", "engineering", "notation", "." ]
80ee03ab7bd3172ac26b769d6b442960f3424b0e
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L65-L69
train
Return number in engineering notation.
ashmastaflash/kal-wrapper
kalibrate/fn.py
determine_device
def determine_device(kal_out): """Extract and return device from scan results.""" device = "" while device == "": for line in kal_out.splitlines(): if "Using device " in line: device = str(line.split(' ', 2)[-1]) if device == "": device = None retu...
python
def determine_device(kal_out): """Extract and return device from scan results.""" device = "" while device == "": for line in kal_out.splitlines(): if "Using device " in line: device = str(line.split(' ', 2)[-1]) if device == "": device = None retu...
[ "def", "determine_device", "(", "kal_out", ")", ":", "device", "=", "\"\"", "while", "device", "==", "\"\"", ":", "for", "line", "in", "kal_out", ".", "splitlines", "(", ")", ":", "if", "\"Using device \"", "in", "line", ":", "device", "=", "str", "(", ...
Extract and return device from scan results.
[ "Extract", "and", "return", "device", "from", "scan", "results", "." ]
80ee03ab7bd3172ac26b769d6b442960f3424b0e
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L81-L90
train
Extract and return device from scan results.
ashmastaflash/kal-wrapper
kalibrate/fn.py
extract_value_from_output
def extract_value_from_output(canary, split_offset, kal_out): """Return value parsed from output. Args: canary(str): This string must exist in the target line. split_offset(int): Split offset for target value in string. kal_out(int): Output from kal. """ retval = "" while re...
python
def extract_value_from_output(canary, split_offset, kal_out): """Return value parsed from output. Args: canary(str): This string must exist in the target line. split_offset(int): Split offset for target value in string. kal_out(int): Output from kal. """ retval = "" while re...
[ "def", "extract_value_from_output", "(", "canary", ",", "split_offset", ",", "kal_out", ")", ":", "retval", "=", "\"\"", "while", "retval", "==", "\"\"", ":", "for", "line", "in", "kal_out", ".", "splitlines", "(", ")", ":", "if", "canary", "in", "line", ...
Return value parsed from output. Args: canary(str): This string must exist in the target line. split_offset(int): Split offset for target value in string. kal_out(int): Output from kal.
[ "Return", "value", "parsed", "from", "output", "." ]
80ee03ab7bd3172ac26b769d6b442960f3424b0e
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L103-L118
train
Extract value from kal output.
ashmastaflash/kal-wrapper
kalibrate/fn.py
determine_chan_detect_threshold
def determine_chan_detect_threshold(kal_out): """Return channel detect threshold from kal output.""" channel_detect_threshold = "" while channel_detect_threshold == "": for line in kal_out.splitlines(): if "channel detect threshold: " in line: channel_detect_threshold = s...
python
def determine_chan_detect_threshold(kal_out): """Return channel detect threshold from kal output.""" channel_detect_threshold = "" while channel_detect_threshold == "": for line in kal_out.splitlines(): if "channel detect threshold: " in line: channel_detect_threshold = s...
[ "def", "determine_chan_detect_threshold", "(", "kal_out", ")", ":", "channel_detect_threshold", "=", "\"\"", "while", "channel_detect_threshold", "==", "\"\"", ":", "for", "line", "in", "kal_out", ".", "splitlines", "(", ")", ":", "if", "\"channel detect threshold: \"...
Return channel detect threshold from kal output.
[ "Return", "channel", "detect", "threshold", "from", "kal", "output", "." ]
80ee03ab7bd3172ac26b769d6b442960f3424b0e
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L127-L137
train
Return channel detect threshold from kal output.
ashmastaflash/kal-wrapper
kalibrate/fn.py
determine_band_channel
def determine_band_channel(kal_out): """Return band, channel, target frequency from kal output.""" band = "" channel = "" tgt_freq = "" while band == "": for line in kal_out.splitlines(): if "Using " in line and " channel " in line: band = str(line.split()[1]) ...
python
def determine_band_channel(kal_out): """Return band, channel, target frequency from kal output.""" band = "" channel = "" tgt_freq = "" while band == "": for line in kal_out.splitlines(): if "Using " in line and " channel " in line: band = str(line.split()[1]) ...
[ "def", "determine_band_channel", "(", "kal_out", ")", ":", "band", "=", "\"\"", "channel", "=", "\"\"", "tgt_freq", "=", "\"\"", "while", "band", "==", "\"\"", ":", "for", "line", "in", "kal_out", ".", "splitlines", "(", ")", ":", "if", "\"Using \"", "in...
Return band, channel, target frequency from kal output.
[ "Return", "band", "channel", "target", "frequency", "from", "kal", "output", "." ]
80ee03ab7bd3172ac26b769d6b442960f3424b0e
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L140-L154
train
Return band channel target frequency from kal output.
ashmastaflash/kal-wrapper
kalibrate/fn.py
parse_kal_scan
def parse_kal_scan(kal_out): """Parse kal band scan output.""" kal_data = [] scan_band = determine_scan_band(kal_out) scan_gain = determine_scan_gain(kal_out) scan_device = determine_device(kal_out) sample_rate = determine_sample_rate(kal_out) chan_detect_threshold = determine_chan_detect_th...
python
def parse_kal_scan(kal_out): """Parse kal band scan output.""" kal_data = [] scan_band = determine_scan_band(kal_out) scan_gain = determine_scan_gain(kal_out) scan_device = determine_device(kal_out) sample_rate = determine_sample_rate(kal_out) chan_detect_threshold = determine_chan_detect_th...
[ "def", "parse_kal_scan", "(", "kal_out", ")", ":", "kal_data", "=", "[", "]", "scan_band", "=", "determine_scan_band", "(", "kal_out", ")", "scan_gain", "=", "determine_scan_gain", "(", "kal_out", ")", "scan_device", "=", "determine_device", "(", "kal_out", ")",...
Parse kal band scan output.
[ "Parse", "kal", "band", "scan", "output", "." ]
80ee03ab7bd3172ac26b769d6b442960f3424b0e
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L157-L189
train
Parse kal band scan output.
ashmastaflash/kal-wrapper
kalibrate/fn.py
parse_kal_channel
def parse_kal_channel(kal_out): """Parse kal channel scan output.""" scan_band, scan_channel, tgt_freq = determine_band_channel(kal_out) kal_data = {"device": determine_device(kal_out), "sample_rate": determine_sample_rate(kal_out), "gain": determine_scan_gain(kal_out), ...
python
def parse_kal_channel(kal_out): """Parse kal channel scan output.""" scan_band, scan_channel, tgt_freq = determine_band_channel(kal_out) kal_data = {"device": determine_device(kal_out), "sample_rate": determine_sample_rate(kal_out), "gain": determine_scan_gain(kal_out), ...
[ "def", "parse_kal_channel", "(", "kal_out", ")", ":", "scan_band", ",", "scan_channel", ",", "tgt_freq", "=", "determine_band_channel", "(", "kal_out", ")", "kal_data", "=", "{", "\"device\"", ":", "determine_device", "(", "kal_out", ")", ",", "\"sample_rate\"", ...
Parse kal channel scan output.
[ "Parse", "kal", "channel", "scan", "output", "." ]
80ee03ab7bd3172ac26b769d6b442960f3424b0e
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L192-L204
train
Parse kal channel scan output.
ashmastaflash/kal-wrapper
kalibrate/fn.py
get_measurements_from_kal_scan
def get_measurements_from_kal_scan(kal_out): """Return a list of all measurements from kalibrate channel scan.""" result = [] for line in kal_out.splitlines(): if "offset " in line: p_line = line.split(' ') result.append(p_line[-1]) return result
python
def get_measurements_from_kal_scan(kal_out): """Return a list of all measurements from kalibrate channel scan.""" result = [] for line in kal_out.splitlines(): if "offset " in line: p_line = line.split(' ') result.append(p_line[-1]) return result
[ "def", "get_measurements_from_kal_scan", "(", "kal_out", ")", ":", "result", "=", "[", "]", "for", "line", "in", "kal_out", ".", "splitlines", "(", ")", ":", "if", "\"offset \"", "in", "line", ":", "p_line", "=", "line", ".", "split", "(", "' '", ")", ...
Return a list of all measurements from kalibrate channel scan.
[ "Return", "a", "list", "of", "all", "measurements", "from", "kalibrate", "channel", "scan", "." ]
80ee03ab7bd3172ac26b769d6b442960f3424b0e
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L206-L213
train
Return a list of all measurements from kalibrate channel scan.
Loudr/pale
pale/fields/base.py
BaseField.render
def render(self, obj, name, context): """The default field renderer. This basic renderer assumes that the object has an attribute with the same name as the field, unless a different field is specified as a `property_name`. The renderer is also passed the context so that it can ...
python
def render(self, obj, name, context): """The default field renderer. This basic renderer assumes that the object has an attribute with the same name as the field, unless a different field is specified as a `property_name`. The renderer is also passed the context so that it can ...
[ "def", "render", "(", "self", ",", "obj", ",", "name", ",", "context", ")", ":", "if", "self", ".", "value_lambda", "is", "not", "None", ":", "val", "=", "self", ".", "value_lambda", "(", "obj", ")", "else", ":", "attr_name", "=", "name", "if", "se...
The default field renderer. This basic renderer assumes that the object has an attribute with the same name as the field, unless a different field is specified as a `property_name`. The renderer is also passed the context so that it can be propagated to the `_render_serializabl...
[ "The", "default", "field", "renderer", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/fields/base.py#L58-L93
train
The default renderer for nested resources.
Loudr/pale
pale/fields/base.py
BaseField.doc_dict
def doc_dict(self): """Generate the documentation for this field.""" doc = { 'type': self.value_type, 'description': self.description, 'extended_description': self.details } return doc
python
def doc_dict(self): """Generate the documentation for this field.""" doc = { 'type': self.value_type, 'description': self.description, 'extended_description': self.details } return doc
[ "def", "doc_dict", "(", "self", ")", ":", "doc", "=", "{", "'type'", ":", "self", ".", "value_type", ",", "'description'", ":", "self", ".", "description", ",", "'extended_description'", ":", "self", ".", "details", "}", "return", "doc" ]
Generate the documentation for this field.
[ "Generate", "the", "documentation", "for", "this", "field", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/fields/base.py#L96-L103
train
Generate the documentation for this field.
a1ezzz/wasp-general
wasp_general/capability.py
WCapabilitiesHolder.capability
def capability(self, cap_name): """ Return capability by its name :param cap_name: name of a capability to return :return: bounded method or None (if a capability is not found) """ if cap_name in self.__class_capabilities__: function_name = self.__class_capabilities__[cap_name] return getattr(self, fun...
python
def capability(self, cap_name): """ Return capability by its name :param cap_name: name of a capability to return :return: bounded method or None (if a capability is not found) """ if cap_name in self.__class_capabilities__: function_name = self.__class_capabilities__[cap_name] return getattr(self, fun...
[ "def", "capability", "(", "self", ",", "cap_name", ")", ":", "if", "cap_name", "in", "self", ".", "__class_capabilities__", ":", "function_name", "=", "self", ".", "__class_capabilities__", "[", "cap_name", "]", "return", "getattr", "(", "self", ",", "function...
Return capability by its name :param cap_name: name of a capability to return :return: bounded method or None (if a capability is not found)
[ "Return", "capability", "by", "its", "name" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/capability.py#L100-L108
train
Return a bounded method by its name
a1ezzz/wasp-general
wasp_general/capability.py
WCapabilitiesHolder.has_capabilities
def has_capabilities(self, *cap_names): """ Check if class has all of the specified capabilities :param cap_names: capabilities names to check :return: bool """ for name in cap_names: if name not in self.__class_capabilities__: return False return True
python
def has_capabilities(self, *cap_names): """ Check if class has all of the specified capabilities :param cap_names: capabilities names to check :return: bool """ for name in cap_names: if name not in self.__class_capabilities__: return False return True
[ "def", "has_capabilities", "(", "self", ",", "*", "cap_names", ")", ":", "for", "name", "in", "cap_names", ":", "if", "name", "not", "in", "self", ".", "__class_capabilities__", ":", "return", "False", "return", "True" ]
Check if class has all of the specified capabilities :param cap_names: capabilities names to check :return: bool
[ "Check", "if", "class", "has", "all", "of", "the", "specified", "capabilities" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/capability.py#L111-L121
train
Check if class has all of the specified capabilities.
projectshift/shift-schema
shiftschema/result.py
Result.add_state_errors
def add_state_errors(self, errors): """ Add state errors Accepts a list of errors (or a single Error) coming from validators applied to entity as whole that are used for entity state validation The errors will exist on a __state__ property of the errors object. :param e...
python
def add_state_errors(self, errors): """ Add state errors Accepts a list of errors (or a single Error) coming from validators applied to entity as whole that are used for entity state validation The errors will exist on a __state__ property of the errors object. :param e...
[ "def", "add_state_errors", "(", "self", ",", "errors", ")", ":", "if", "not", "self", ".", "errors", ":", "self", ".", "errors", "=", "dict", "(", ")", "if", "'__state__'", "not", "in", "self", ".", "errors", ":", "self", ".", "errors", "[", "'__stat...
Add state errors Accepts a list of errors (or a single Error) coming from validators applied to entity as whole that are used for entity state validation The errors will exist on a __state__ property of the errors object. :param errors: list or Error, list of entity state validation er...
[ "Add", "state", "errors", "Accepts", "a", "list", "of", "errors", "(", "or", "a", "single", "Error", ")", "coming", "from", "validators", "applied", "to", "entity", "as", "whole", "that", "are", "used", "for", "entity", "state", "validation", "The", "error...
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L59-L83
train
Adds state errors to the errors object
projectshift/shift-schema
shiftschema/result.py
Result.add_errors
def add_errors(self, property_name, errors): """ Add one or several errors to properties. :param property_name: str, property name :param errors: list or Error, error object(s) :return: shiftschema.result.Result """ if type(errors) is not list: errors ...
python
def add_errors(self, property_name, errors): """ Add one or several errors to properties. :param property_name: str, property name :param errors: list or Error, error object(s) :return: shiftschema.result.Result """ if type(errors) is not list: errors ...
[ "def", "add_errors", "(", "self", ",", "property_name", ",", "errors", ")", ":", "if", "type", "(", "errors", ")", "is", "not", "list", ":", "errors", "=", "[", "errors", "]", "for", "error", "in", "errors", ":", "if", "not", "isinstance", "(", "erro...
Add one or several errors to properties. :param property_name: str, property name :param errors: list or Error, error object(s) :return: shiftschema.result.Result
[ "Add", "one", "or", "several", "errors", "to", "properties", ".", ":", "param", "property_name", ":", "str", "property", "name", ":", "param", "errors", ":", "list", "or", "Error", "error", "object", "(", "s", ")", ":", "return", ":", "shiftschema", ".",...
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L85-L104
train
Add one or several errors to properties.
projectshift/shift-schema
shiftschema/result.py
Result.add_entity_errors
def add_entity_errors( self, property_name, direct_errors=None, schema_errors=None ): """ Attach nested entity errors Accepts a list errors coming from validators attached directly, or a dict of errors produced by a nested schema. :param prope...
python
def add_entity_errors( self, property_name, direct_errors=None, schema_errors=None ): """ Attach nested entity errors Accepts a list errors coming from validators attached directly, or a dict of errors produced by a nested schema. :param prope...
[ "def", "add_entity_errors", "(", "self", ",", "property_name", ",", "direct_errors", "=", "None", ",", "schema_errors", "=", "None", ")", ":", "if", "direct_errors", "is", "None", "and", "schema_errors", "is", "None", ":", "return", "self", "# direct errors", ...
Attach nested entity errors Accepts a list errors coming from validators attached directly, or a dict of errors produced by a nested schema. :param property_name: str, property name :param direct_errors: list, errors from validators attached directly :param schema_errors: dict, ...
[ "Attach", "nested", "entity", "errors", "Accepts", "a", "list", "errors", "coming", "from", "validators", "attached", "directly", "or", "a", "dict", "of", "errors", "produced", "by", "a", "nested", "schema", "." ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L106-L161
train
Adds nested entity errors to the errors dictionary.
projectshift/shift-schema
shiftschema/result.py
Result.add_collection_errors
def add_collection_errors( self, property_name, direct_errors=None, collection_errors=None ): """ Add collection errors Accepts a list errors coming from validators attached directly, or a list of schema results for each item in the collection. ...
python
def add_collection_errors( self, property_name, direct_errors=None, collection_errors=None ): """ Add collection errors Accepts a list errors coming from validators attached directly, or a list of schema results for each item in the collection. ...
[ "def", "add_collection_errors", "(", "self", ",", "property_name", ",", "direct_errors", "=", "None", ",", "collection_errors", "=", "None", ")", ":", "if", "direct_errors", "is", "None", "and", "collection_errors", "is", "None", ":", "return", "self", "# direct...
Add collection errors Accepts a list errors coming from validators attached directly, or a list of schema results for each item in the collection. :param property_name: str, property name :param direct_errors: list, errors from validators attached directly :param collection_erro...
[ "Add", "collection", "errors", "Accepts", "a", "list", "errors", "coming", "from", "validators", "attached", "directly", "or", "a", "list", "of", "schema", "results", "for", "each", "item", "in", "the", "collection", "." ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L163-L220
train
Adds collection errors to the error dictionary.
projectshift/shift-schema
shiftschema/result.py
Result.merge_errors
def merge_errors(self, errors_local, errors_remote): """ Merge errors Recursively traverses error graph to merge remote errors into local errors to return a new joined graph. :param errors_local: dict, local errors, will be updated :param errors_remote: dict, remote erro...
python
def merge_errors(self, errors_local, errors_remote): """ Merge errors Recursively traverses error graph to merge remote errors into local errors to return a new joined graph. :param errors_local: dict, local errors, will be updated :param errors_remote: dict, remote erro...
[ "def", "merge_errors", "(", "self", ",", "errors_local", ",", "errors_remote", ")", ":", "for", "prop", "in", "errors_remote", ":", "# create if doesn't exist", "if", "prop", "not", "in", "errors_local", ":", "errors_local", "[", "prop", "]", "=", "errors_remote...
Merge errors Recursively traverses error graph to merge remote errors into local errors to return a new joined graph. :param errors_local: dict, local errors, will be updated :param errors_remote: dict, remote errors, provides updates :return: dict
[ "Merge", "errors", "Recursively", "traverses", "error", "graph", "to", "merge", "remote", "errors", "into", "local", "errors", "to", "return", "a", "new", "joined", "graph", "." ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L222-L290
train
Merge errors from local to remote errors into local errors.
projectshift/shift-schema
shiftschema/result.py
Result.merge
def merge(self, another): """ Merges another validation result graph into itself""" if isinstance(another, Result): another = another.errors self.errors = self.merge_errors(self.errors, another)
python
def merge(self, another): """ Merges another validation result graph into itself""" if isinstance(another, Result): another = another.errors self.errors = self.merge_errors(self.errors, another)
[ "def", "merge", "(", "self", ",", "another", ")", ":", "if", "isinstance", "(", "another", ",", "Result", ")", ":", "another", "=", "another", ".", "errors", "self", ".", "errors", "=", "self", ".", "merge_errors", "(", "self", ".", "errors", ",", "a...
Merges another validation result graph into itself
[ "Merges", "another", "validation", "result", "graph", "into", "itself" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L292-L296
train
Merges another validation result graph into itself
projectshift/shift-schema
shiftschema/result.py
Result.get_messages
def get_messages(self, locale=None): """ Get a dictionary of translated messages """ if locale is None: locale = self.locale if self.translator: def translate(error): return self.translator.translate(error, locale) else: def translate(...
python
def get_messages(self, locale=None): """ Get a dictionary of translated messages """ if locale is None: locale = self.locale if self.translator: def translate(error): return self.translator.translate(error, locale) else: def translate(...
[ "def", "get_messages", "(", "self", ",", "locale", "=", "None", ")", ":", "if", "locale", "is", "None", ":", "locale", "=", "self", ".", "locale", "if", "self", ".", "translator", ":", "def", "translate", "(", "error", ")", ":", "return", "self", "."...
Get a dictionary of translated messages
[ "Get", "a", "dictionary", "of", "translated", "messages" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L298-L312
train
Get a dictionary of translated messages
projectshift/shift-schema
shiftschema/result.py
Result._translate_errors
def _translate_errors(self, errors, translate): """ Recursively apply translate callback to each error message""" for prop in errors: prop_errors = errors[prop] # state and simple if type(prop_errors) is list: for index, error in enumerate(prop_errors...
python
def _translate_errors(self, errors, translate): """ Recursively apply translate callback to each error message""" for prop in errors: prop_errors = errors[prop] # state and simple if type(prop_errors) is list: for index, error in enumerate(prop_errors...
[ "def", "_translate_errors", "(", "self", ",", "errors", ",", "translate", ")", ":", "for", "prop", "in", "errors", ":", "prop_errors", "=", "errors", "[", "prop", "]", "# state and simple", "if", "type", "(", "prop_errors", ")", "is", "list", ":", "for", ...
Recursively apply translate callback to each error message
[ "Recursively", "apply", "translate", "callback", "to", "each", "error", "message" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L314-L350
train
Recursively apply translate callback to each error message
projectshift/shift-schema
shiftschema/result.py
Result.format_error
def format_error(self, error, args=None): """ Format error with positional or named arguments (if any) """ if type(args) is dict: return error.format(**args) if type(args) is list or type(args) is tuple: return error.format(*args) return error
python
def format_error(self, error, args=None): """ Format error with positional or named arguments (if any) """ if type(args) is dict: return error.format(**args) if type(args) is list or type(args) is tuple: return error.format(*args) return error
[ "def", "format_error", "(", "self", ",", "error", ",", "args", "=", "None", ")", ":", "if", "type", "(", "args", ")", "is", "dict", ":", "return", "error", ".", "format", "(", "*", "*", "args", ")", "if", "type", "(", "args", ")", "is", "list", ...
Format error with positional or named arguments (if any)
[ "Format", "error", "with", "positional", "or", "named", "arguments", "(", "if", "any", ")" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L352-L359
train
Format error with positional or named arguments
projectshift/shift-schema
shiftschema/filters/linkify.py
Linkify.filter
def filter(self, value, model=None, context=None): """ Filter Performs value filtering and returns filtered result. :param value: input value :param model: parent model being validated :param context: object, filtering context ...
python
def filter(self, value, model=None, context=None): """ Filter Performs value filtering and returns filtered result. :param value: input value :param model: parent model being validated :param context: object, filtering context ...
[ "def", "filter", "(", "self", ",", "value", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "value", "=", "str", "(", "value", ")", "linker", "=", "Linker", "(", "*", "*", "self", ".", "linkify_params", ")", "return", "linker", "....
Filter Performs value filtering and returns filtered result. :param value: input value :param model: parent model being validated :param context: object, filtering context :return: filtered value
[ "Filter", "Performs", "value", "filtering", "and", "returns", "filtered", "result", "." ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/filters/linkify.py#L56-L68
train
Filter the value and returns the result.
sublee/etc
etc/adapters/etcd.py
EtcdAdapter.make_url
def make_url(self, path, api_root=u'/v2/'): """Gets a full URL from just path.""" return urljoin(urljoin(self.url, api_root), path)
python
def make_url(self, path, api_root=u'/v2/'): """Gets a full URL from just path.""" return urljoin(urljoin(self.url, api_root), path)
[ "def", "make_url", "(", "self", ",", "path", ",", "api_root", "=", "u'/v2/'", ")", ":", "return", "urljoin", "(", "urljoin", "(", "self", ".", "url", ",", "api_root", ")", ",", "path", ")" ]
Gets a full URL from just path.
[ "Gets", "a", "full", "URL", "from", "just", "path", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/etcd.py#L40-L42
train
Gets a full URL from just path.
sublee/etc
etc/adapters/etcd.py
EtcdAdapter.make_key_url
def make_key_url(self, key): """Gets a URL for a key.""" if type(key) is bytes: key = key.decode('utf-8') buf = io.StringIO() buf.write(u'keys') if not key.startswith(u'/'): buf.write(u'/') buf.write(key) return self.make_url(buf.getvalue()...
python
def make_key_url(self, key): """Gets a URL for a key.""" if type(key) is bytes: key = key.decode('utf-8') buf = io.StringIO() buf.write(u'keys') if not key.startswith(u'/'): buf.write(u'/') buf.write(key) return self.make_url(buf.getvalue()...
[ "def", "make_key_url", "(", "self", ",", "key", ")", ":", "if", "type", "(", "key", ")", "is", "bytes", ":", "key", "=", "key", ".", "decode", "(", "'utf-8'", ")", "buf", "=", "io", ".", "StringIO", "(", ")", "buf", ".", "write", "(", "u'keys'", ...
Gets a URL for a key.
[ "Gets", "a", "URL", "for", "a", "key", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/etcd.py#L44-L53
train
Gets a URL for a key.
sublee/etc
etc/adapters/etcd.py
EtcdAdapter.erred
def erred(): """Wraps errors. Call it in `except` clause:: try: do_something() except: self.erred() """ exc_type, exc, tb = sys.exc_info() if issubclass(exc_type, socket.timeout): raise TimedOut elif issubclass(ex...
python
def erred(): """Wraps errors. Call it in `except` clause:: try: do_something() except: self.erred() """ exc_type, exc, tb = sys.exc_info() if issubclass(exc_type, socket.timeout): raise TimedOut elif issubclass(ex...
[ "def", "erred", "(", ")", ":", "exc_type", ",", "exc", ",", "tb", "=", "sys", ".", "exc_info", "(", ")", "if", "issubclass", "(", "exc_type", ",", "socket", ".", "timeout", ")", ":", "raise", "TimedOut", "elif", "issubclass", "(", "exc_type", ",", "r...
Wraps errors. Call it in `except` clause:: try: do_something() except: self.erred()
[ "Wraps", "errors", ".", "Call", "it", "in", "except", "clause", "::" ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/etcd.py#L133-L153
train
Wraps errors in except clause.
sublee/etc
etc/adapters/etcd.py
EtcdAdapter.get
def get(self, key, recursive=False, sorted=False, quorum=False, wait=False, wait_index=None, timeout=None): """Requests to get a node by the given key.""" url = self.make_key_url(key) params = self.build_args({ 'recursive': (bool, recursive or None), 'sorted':...
python
def get(self, key, recursive=False, sorted=False, quorum=False, wait=False, wait_index=None, timeout=None): """Requests to get a node by the given key.""" url = self.make_key_url(key) params = self.build_args({ 'recursive': (bool, recursive or None), 'sorted':...
[ "def", "get", "(", "self", ",", "key", ",", "recursive", "=", "False", ",", "sorted", "=", "False", ",", "quorum", "=", "False", ",", "wait", "=", "False", ",", "wait_index", "=", "None", ",", "timeout", "=", "None", ")", ":", "url", "=", "self", ...
Requests to get a node by the given key.
[ "Requests", "to", "get", "a", "node", "by", "the", "given", "key", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/etcd.py#L155-L185
train
Requests to get a node by the given key.
sublee/etc
etc/adapters/etcd.py
EtcdAdapter.set
def set(self, key, value=None, dir=False, refresh=False, ttl=None, prev_value=None, prev_index=None, prev_exist=None, timeout=None): """Requests to create an ordered node into a node by the given key.""" url = self.make_key_url(key) data = self.build_args({ 'value': (six....
python
def set(self, key, value=None, dir=False, refresh=False, ttl=None, prev_value=None, prev_index=None, prev_exist=None, timeout=None): """Requests to create an ordered node into a node by the given key.""" url = self.make_key_url(key) data = self.build_args({ 'value': (six....
[ "def", "set", "(", "self", ",", "key", ",", "value", "=", "None", ",", "dir", "=", "False", ",", "refresh", "=", "False", ",", "ttl", "=", "None", ",", "prev_value", "=", "None", ",", "prev_index", "=", "None", ",", "prev_exist", "=", "None", ",", ...
Requests to create an ordered node into a node by the given key.
[ "Requests", "to", "create", "an", "ordered", "node", "into", "a", "node", "by", "the", "given", "key", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/etcd.py#L187-L204
train
Requests to create an ordered node into a node by the given key.
sublee/etc
etc/adapters/etcd.py
EtcdAdapter.append
def append(self, key, value=None, dir=False, ttl=None, timeout=None): """Requests to create an ordered node into a node by the given key.""" url = self.make_key_url(key) data = self.build_args({ 'value': (six.text_type, value), 'dir': (bool, dir or None), 'ttl...
python
def append(self, key, value=None, dir=False, ttl=None, timeout=None): """Requests to create an ordered node into a node by the given key.""" url = self.make_key_url(key) data = self.build_args({ 'value': (six.text_type, value), 'dir': (bool, dir or None), 'ttl...
[ "def", "append", "(", "self", ",", "key", ",", "value", "=", "None", ",", "dir", "=", "False", ",", "ttl", "=", "None", ",", "timeout", "=", "None", ")", ":", "url", "=", "self", ".", "make_key_url", "(", "key", ")", "data", "=", "self", ".", "...
Requests to create an ordered node into a node by the given key.
[ "Requests", "to", "create", "an", "ordered", "node", "into", "a", "node", "by", "the", "given", "key", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/etcd.py#L206-L218
train
Requests to create an ordered node into a node by the given key.
sublee/etc
etc/adapters/etcd.py
EtcdAdapter.delete
def delete(self, key, dir=False, recursive=False, prev_value=None, prev_index=None, timeout=None): """Requests to delete a node by the given key.""" url = self.make_key_url(key) params = self.build_args({ 'dir': (bool, dir or None), 'recursive': (bool, recu...
python
def delete(self, key, dir=False, recursive=False, prev_value=None, prev_index=None, timeout=None): """Requests to delete a node by the given key.""" url = self.make_key_url(key) params = self.build_args({ 'dir': (bool, dir or None), 'recursive': (bool, recu...
[ "def", "delete", "(", "self", ",", "key", ",", "dir", "=", "False", ",", "recursive", "=", "False", ",", "prev_value", "=", "None", ",", "prev_index", "=", "None", ",", "timeout", "=", "None", ")", ":", "url", "=", "self", ".", "make_key_url", "(", ...
Requests to delete a node by the given key.
[ "Requests", "to", "delete", "a", "node", "by", "the", "given", "key", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/etcd.py#L220-L234
train
Requests to delete a node by the given key.
AASHE/python-membersuite-api-client
membersuite_api_client/security/services.py
login_to_portal
def login_to_portal(username, password, client, retries=2, delay=0): """Log `username` into the MemberSuite Portal. Returns a PortalUser object if successful, raises LoginToPortalError if not. Will retry logging in if a GeneralException occurs, up to `retries`. Will pause `delay` seconds between r...
python
def login_to_portal(username, password, client, retries=2, delay=0): """Log `username` into the MemberSuite Portal. Returns a PortalUser object if successful, raises LoginToPortalError if not. Will retry logging in if a GeneralException occurs, up to `retries`. Will pause `delay` seconds between r...
[ "def", "login_to_portal", "(", "username", ",", "password", ",", "client", ",", "retries", "=", "2", ",", "delay", "=", "0", ")", ":", "if", "not", "client", ".", "session_id", ":", "client", ".", "request_session", "(", ")", "concierge_request_header", "=...
Log `username` into the MemberSuite Portal. Returns a PortalUser object if successful, raises LoginToPortalError if not. Will retry logging in if a GeneralException occurs, up to `retries`. Will pause `delay` seconds between retries.
[ "Log", "username", "into", "the", "MemberSuite", "Portal", "." ]
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/security/services.py#L10-L56
train
Log username into the MemberSuite Portal.
AASHE/python-membersuite-api-client
membersuite_api_client/security/services.py
logout
def logout(client): """Log out the currently logged-in user. There's a really crappy side-effect here - the session_id attribute of the `client` passed in will be reset to None if the logout succeeds, which is going to be almost always, let's hope. """ if not client.session_id: client....
python
def logout(client): """Log out the currently logged-in user. There's a really crappy side-effect here - the session_id attribute of the `client` passed in will be reset to None if the logout succeeds, which is going to be almost always, let's hope. """ if not client.session_id: client....
[ "def", "logout", "(", "client", ")", ":", "if", "not", "client", ".", "session_id", ":", "client", ".", "request_session", "(", ")", "concierge_request_header", "=", "client", ".", "construct_concierge_header", "(", "url", "=", "(", "\"http://membersuite.com/contr...
Log out the currently logged-in user. There's a really crappy side-effect here - the session_id attribute of the `client` passed in will be reset to None if the logout succeeds, which is going to be almost always, let's hope.
[ "Log", "out", "the", "currently", "logged", "-", "in", "user", "." ]
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/security/services.py#L59-L82
train
Log out the currently logged - in user.
AASHE/python-membersuite-api-client
membersuite_api_client/security/services.py
get_user_for_membersuite_entity
def get_user_for_membersuite_entity(membersuite_entity): """Returns a User for `membersuite_entity`. membersuite_entity is any MemberSuite object that has the fields membersuite_id, email_address, first_name, and last_name, e.g., PortalUser or Individual. """ user = None user_created = Fal...
python
def get_user_for_membersuite_entity(membersuite_entity): """Returns a User for `membersuite_entity`. membersuite_entity is any MemberSuite object that has the fields membersuite_id, email_address, first_name, and last_name, e.g., PortalUser or Individual. """ user = None user_created = Fal...
[ "def", "get_user_for_membersuite_entity", "(", "membersuite_entity", ")", ":", "user", "=", "None", "user_created", "=", "False", "# First, try to match on username.", "user_username", "=", "generate_username", "(", "membersuite_entity", ")", "try", ":", "user", "=", "U...
Returns a User for `membersuite_entity`. membersuite_entity is any MemberSuite object that has the fields membersuite_id, email_address, first_name, and last_name, e.g., PortalUser or Individual.
[ "Returns", "a", "User", "for", "membersuite_entity", "." ]
221f5ed8bc7d4424237a4669c5af9edc11819ee9
https://github.com/AASHE/python-membersuite-api-client/blob/221f5ed8bc7d4424237a4669c5af9edc11819ee9/membersuite_api_client/security/services.py#L89-L124
train
Returns a User object for the given membersuite_entity.
a1ezzz/wasp-general
wasp_general/network/messenger/composer.py
WMessengerComposerLayer.process
def process(self, envelope, session, mode=None, composer_factory=None, **kwargs): """ :meth:`.WMessengerOnionLayerProto.process` implementation """ if mode == WMessengerComposerLayer.Mode.compose: return self.compose(envelope, session, composer_factory, **kwargs) elif mode == WMessengerComposerLayer.Mode.dec...
python
def process(self, envelope, session, mode=None, composer_factory=None, **kwargs): """ :meth:`.WMessengerOnionLayerProto.process` implementation """ if mode == WMessengerComposerLayer.Mode.compose: return self.compose(envelope, session, composer_factory, **kwargs) elif mode == WMessengerComposerLayer.Mode.dec...
[ "def", "process", "(", "self", ",", "envelope", ",", "session", ",", "mode", "=", "None", ",", "composer_factory", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "mode", "==", "WMessengerComposerLayer", ".", "Mode", ".", "compose", ":", "return", ...
:meth:`.WMessengerOnionLayerProto.process` implementation
[ ":", "meth", ":", ".", "WMessengerOnionLayerProto", ".", "process", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/composer.py#L56-L63
train
Implementation of WMessengerOnionLayerProto. process method.
projectshift/shift-schema
shiftschema/property.py
SimpleProperty.add_filter
def add_filter(self, filter): """ Add filter to property :param filter: object, extending from AbstractFilter :return: None """ if not isinstance(filter, AbstractFilter): err = 'Filters must be of type {}'.format(AbstractFilter) raise InvalidFilter...
python
def add_filter(self, filter): """ Add filter to property :param filter: object, extending from AbstractFilter :return: None """ if not isinstance(filter, AbstractFilter): err = 'Filters must be of type {}'.format(AbstractFilter) raise InvalidFilter...
[ "def", "add_filter", "(", "self", ",", "filter", ")", ":", "if", "not", "isinstance", "(", "filter", ",", "AbstractFilter", ")", ":", "err", "=", "'Filters must be of type {}'", ".", "format", "(", "AbstractFilter", ")", "raise", "InvalidFilter", "(", "err", ...
Add filter to property :param filter: object, extending from AbstractFilter :return: None
[ "Add", "filter", "to", "property", ":", "param", "filter", ":", "object", "extending", "from", "AbstractFilter", ":", "return", ":", "None" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L28-L40
train
Add filter to property
projectshift/shift-schema
shiftschema/property.py
SimpleProperty.add_validator
def add_validator(self, validator): """ Add validator to property :param validator: object, extending from AbstractValidator :return: None """ if not isinstance(validator, AbstractValidator): err = 'Validator must be of type {}'.format(AbstractValidator) ...
python
def add_validator(self, validator): """ Add validator to property :param validator: object, extending from AbstractValidator :return: None """ if not isinstance(validator, AbstractValidator): err = 'Validator must be of type {}'.format(AbstractValidator) ...
[ "def", "add_validator", "(", "self", ",", "validator", ")", ":", "if", "not", "isinstance", "(", "validator", ",", "AbstractValidator", ")", ":", "err", "=", "'Validator must be of type {}'", ".", "format", "(", "AbstractValidator", ")", "raise", "InvalidValidator...
Add validator to property :param validator: object, extending from AbstractValidator :return: None
[ "Add", "validator", "to", "property" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L42-L54
train
Adds a validator to the property AttributeNames
projectshift/shift-schema
shiftschema/property.py
SimpleProperty.filter
def filter(self, value=None, model=None, context=None): """ Sequentially applies all the filters to provided value :param value: a value to filter :param model: parent entity :param context: filtering context, usually parent entity :return: filtered value """ ...
python
def filter(self, value=None, model=None, context=None): """ Sequentially applies all the filters to provided value :param value: a value to filter :param model: parent entity :param context: filtering context, usually parent entity :return: filtered value """ ...
[ "def", "filter", "(", "self", ",", "value", "=", "None", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "if", "value", "is", "None", ":", "return", "value", "for", "filter_obj", "in", "self", ".", "filters", ":", "value", "=", "f...
Sequentially applies all the filters to provided value :param value: a value to filter :param model: parent entity :param context: filtering context, usually parent entity :return: filtered value
[ "Sequentially", "applies", "all", "the", "filters", "to", "provided", "value" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L56-L73
train
Sequentially applies all the filters to provided value
projectshift/shift-schema
shiftschema/property.py
SimpleProperty.validate
def validate(self, value=None, model=None, context=None): """ Sequentially apply each validator to value and collect errors. :param value: a value to validate :param model: parent entity :param context: validation context, usually parent entity :return: list of errors (i...
python
def validate(self, value=None, model=None, context=None): """ Sequentially apply each validator to value and collect errors. :param value: a value to validate :param model: parent entity :param context: validation context, usually parent entity :return: list of errors (i...
[ "def", "validate", "(", "self", ",", "value", "=", "None", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "errors", "=", "[", "]", "for", "validator", "in", "self", ".", "validators", ":", "if", "value", "is", "None", "and", "not...
Sequentially apply each validator to value and collect errors. :param value: a value to validate :param model: parent entity :param context: validation context, usually parent entity :return: list of errors (if any)
[ "Sequentially", "apply", "each", "validator", "to", "value", "and", "collect", "errors", "." ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L75-L97
train
Sequentially apply each validator to value and collect errors.
projectshift/shift-schema
shiftschema/property.py
EntityProperty.filter_with_schema
def filter_with_schema(self, model=None, context=None): """ Perform model filtering with schema """ if model is None or self.schema is None: return self._schema.filter( model=model, context=context if self.use_context else None )
python
def filter_with_schema(self, model=None, context=None): """ Perform model filtering with schema """ if model is None or self.schema is None: return self._schema.filter( model=model, context=context if self.use_context else None )
[ "def", "filter_with_schema", "(", "self", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "if", "model", "is", "None", "or", "self", ".", "schema", "is", "None", ":", "return", "self", ".", "_schema", ".", "filter", "(", "model", "=...
Perform model filtering with schema
[ "Perform", "model", "filtering", "with", "schema" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L125-L133
train
Perform model filtering with schema
projectshift/shift-schema
shiftschema/property.py
EntityProperty.validate_with_schema
def validate_with_schema(self, model=None, context=None): """ Perform model validation with schema""" if self._schema is None or model is None: return result = self._schema.validate( model=model, context=context if self.use_context else None ) ...
python
def validate_with_schema(self, model=None, context=None): """ Perform model validation with schema""" if self._schema is None or model is None: return result = self._schema.validate( model=model, context=context if self.use_context else None ) ...
[ "def", "validate_with_schema", "(", "self", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "if", "self", ".", "_schema", "is", "None", "or", "model", "is", "None", ":", "return", "result", "=", "self", ".", "_schema", ".", "validate"...
Perform model validation with schema
[ "Perform", "model", "validation", "with", "schema" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L135-L144
train
Perform model validation with schema
projectshift/shift-schema
shiftschema/property.py
CollectionProperty.filter_with_schema
def filter_with_schema(self, collection=None, context=None): """ Perform collection items filtering with schema """ if collection is None or self.schema is None: return try: for item in collection: self._schema.filter( model=item, ...
python
def filter_with_schema(self, collection=None, context=None): """ Perform collection items filtering with schema """ if collection is None or self.schema is None: return try: for item in collection: self._schema.filter( model=item, ...
[ "def", "filter_with_schema", "(", "self", ",", "collection", "=", "None", ",", "context", "=", "None", ")", ":", "if", "collection", "is", "None", "or", "self", ".", "schema", "is", "None", ":", "return", "try", ":", "for", "item", "in", "collection", ...
Perform collection items filtering with schema
[ "Perform", "collection", "items", "filtering", "with", "schema" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L155-L167
train
Perform collection items filtering with schema
projectshift/shift-schema
shiftschema/property.py
CollectionProperty.validate_with_schema
def validate_with_schema(self, collection=None, context=None): """ Validate each item in collection with our schema""" if self._schema is None or not collection: return result = [] try: for index, item in enumerate(collection): item_result = self....
python
def validate_with_schema(self, collection=None, context=None): """ Validate each item in collection with our schema""" if self._schema is None or not collection: return result = [] try: for index, item in enumerate(collection): item_result = self....
[ "def", "validate_with_schema", "(", "self", ",", "collection", "=", "None", ",", "context", "=", "None", ")", ":", "if", "self", ".", "_schema", "is", "None", "or", "not", "collection", ":", "return", "result", "=", "[", "]", "try", ":", "for", "index"...
Validate each item in collection with our schema
[ "Validate", "each", "item", "in", "collection", "with", "our", "schema" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L169-L185
train
Validate each item in collection with our schema
shaypal5/strct
strct/hash/_hash.py
json_based_stable_hash
def json_based_stable_hash(obj): """Computes a cross-kernel stable hash value for the given object. The supported data structure are the built-in list, tuple and dict types. Any included tuple or list, whether outer or nested, may only contain values of the following built-in types: bool, int, float, ...
python
def json_based_stable_hash(obj): """Computes a cross-kernel stable hash value for the given object. The supported data structure are the built-in list, tuple and dict types. Any included tuple or list, whether outer or nested, may only contain values of the following built-in types: bool, int, float, ...
[ "def", "json_based_stable_hash", "(", "obj", ")", ":", "encoded_str", "=", "json", ".", "dumps", "(", "obj", "=", "obj", ",", "skipkeys", "=", "False", ",", "ensure_ascii", "=", "False", ",", "check_circular", "=", "True", ",", "allow_nan", "=", "True", ...
Computes a cross-kernel stable hash value for the given object. The supported data structure are the built-in list, tuple and dict types. Any included tuple or list, whether outer or nested, may only contain values of the following built-in types: bool, int, float, complex, str, list, tuple and dict. ...
[ "Computes", "a", "cross", "-", "kernel", "stable", "hash", "value", "for", "the", "given", "object", "." ]
f3a301692d052ddb79331230b3c00625db1d83fc
https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/hash/_hash.py#L86-L122
train
Computes a cross - kernel stable hash value for the given object.
a1ezzz/wasp-general
wasp_general/network/web/session.py
WWebSessionBase.read_request_line
def read_request_line(self, request_line): """ Read HTTP-request line :param request_line: line to parse for HTTP/0.9 is GET <Request-URI> for HTTP/1.0 and 1.1 is <METHOD> <Request-URI> HTTP/<HTTP-Version>, where HTTP-Version is 1.0 or 1.1. for HTTP/2: binary headers are used """ request = self.__...
python
def read_request_line(self, request_line): """ Read HTTP-request line :param request_line: line to parse for HTTP/0.9 is GET <Request-URI> for HTTP/1.0 and 1.1 is <METHOD> <Request-URI> HTTP/<HTTP-Version>, where HTTP-Version is 1.0 or 1.1. for HTTP/2: binary headers are used """ request = self.__...
[ "def", "read_request_line", "(", "self", ",", "request_line", ")", ":", "request", "=", "self", ".", "__request_cls", ".", "parse_request_line", "(", "self", ",", "request_line", ")", "protocol_version", "=", "self", ".", "protocol_version", "(", ")", "if", "p...
Read HTTP-request line :param request_line: line to parse for HTTP/0.9 is GET <Request-URI> for HTTP/1.0 and 1.1 is <METHOD> <Request-URI> HTTP/<HTTP-Version>, where HTTP-Version is 1.0 or 1.1. for HTTP/2: binary headers are used
[ "Read", "HTTP", "-", "request", "line" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/session.py#L67-L88
train
Read HTTP - request line from request_line.