repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
abe-winter/pg13-py
pg13/sqex.py
NameIndexer.index_tuple
def index_tuple(self,tables_dict,index,is_set): "helper for rowget/rowset" if not self.aonly_resolved: raise RuntimeError('resolve_aonly() before querying nix') with tables_dict.tempkeys(): tables_dict.update(self.aonly) # todo: find spec support for aliases overwriting existing tables. (more likely, ...
python
def index_tuple(self,tables_dict,index,is_set): "helper for rowget/rowset" if not self.aonly_resolved: raise RuntimeError('resolve_aonly() before querying nix') with tables_dict.tempkeys(): tables_dict.update(self.aonly) # todo: find spec support for aliases overwriting existing tables. (more likely, ...
[ "def", "index_tuple", "(", "self", ",", "tables_dict", ",", "index", ",", "is_set", ")", ":", "if", "not", "self", ".", "aonly_resolved", ":", "raise", "RuntimeError", "(", "'resolve_aonly() before querying nix'", ")", "with", "tables_dict", ".", "tempkeys", "("...
helper for rowget/rowset
[ "helper", "for", "rowget", "/", "rowset" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/sqex.py#L141-L161
abe-winter/pg13-py
pg13/sqex.py
NameIndexer.rowget
def rowget(self,tables_dict,row_list,index): "row_list in self.row_order" tmp=row_list for i in self.index_tuple(tables_dict,index,False): tmp=tmp[i] return tmp
python
def rowget(self,tables_dict,row_list,index): "row_list in self.row_order" tmp=row_list for i in self.index_tuple(tables_dict,index,False): tmp=tmp[i] return tmp
[ "def", "rowget", "(", "self", ",", "tables_dict", ",", "row_list", ",", "index", ")", ":", "tmp", "=", "row_list", "for", "i", "in", "self", ".", "index_tuple", "(", "tables_dict", ",", "index", ",", "False", ")", ":", "tmp", "=", "tmp", "[", "i", ...
row_list in self.row_order
[ "row_list", "in", "self", ".", "row_order" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/sqex.py#L162-L166
abe-winter/pg13-py
pg13/sqex.py
Evaluator.eval_agg_call
def eval_agg_call(self, exp): "helper for eval_callx; evaluator for CallX that consume multiple rows" if not isinstance(self.c_row,list): raise TypeError('aggregate function expected a list of rows') if len(exp.args.children)!=1: raise ValueError('aggregate function expected a single value',exp.args) ar...
python
def eval_agg_call(self, exp): "helper for eval_callx; evaluator for CallX that consume multiple rows" if not isinstance(self.c_row,list): raise TypeError('aggregate function expected a list of rows') if len(exp.args.children)!=1: raise ValueError('aggregate function expected a single value',exp.args) ar...
[ "def", "eval_agg_call", "(", "self", ",", "exp", ")", ":", "if", "not", "isinstance", "(", "self", ".", "c_row", ",", "list", ")", ":", "raise", "TypeError", "(", "'aggregate function expected a list of rows'", ")", "if", "len", "(", "exp", ".", "args", "....
helper for eval_callx; evaluator for CallX that consume multiple rows
[ "helper", "for", "eval_callx", ";", "evaluator", "for", "CallX", "that", "consume", "multiple", "rows" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/sqex.py#L261-L271
abe-winter/pg13-py
pg13/sqex.py
Evaluator.eval_nonagg_call
def eval_nonagg_call(self, exp): "helper for eval_callx; evaluator for CallX that consume a single value" # todo: get more concrete about argument counts args=self.eval(exp.args) if exp.f=='coalesce': a,b=args # todo: does coalesce take more than 2 args? return b if a is None else a elif...
python
def eval_nonagg_call(self, exp): "helper for eval_callx; evaluator for CallX that consume a single value" # todo: get more concrete about argument counts args=self.eval(exp.args) if exp.f=='coalesce': a,b=args # todo: does coalesce take more than 2 args? return b if a is None else a elif...
[ "def", "eval_nonagg_call", "(", "self", ",", "exp", ")", ":", "# todo: get more concrete about argument counts", "args", "=", "self", ".", "eval", "(", "exp", ".", "args", ")", "if", "exp", ".", "f", "==", "'coalesce'", ":", "a", ",", "b", "=", "args", "...
helper for eval_callx; evaluator for CallX that consume a single value
[ "helper", "for", "eval_callx", ";", "evaluator", "for", "CallX", "that", "consume", "a", "single", "value" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/sqex.py#L273-L282
abe-winter/pg13-py
pg13/sqex.py
Evaluator.eval_callx
def eval_callx(self, exp): "dispatch for CallX" # below: this isn't contains(exp,consumes_row) -- it's just checking the current expression return (self.eval_agg_call if consumes_rows(exp) else self.eval_nonagg_call)(exp)
python
def eval_callx(self, exp): "dispatch for CallX" # below: this isn't contains(exp,consumes_row) -- it's just checking the current expression return (self.eval_agg_call if consumes_rows(exp) else self.eval_nonagg_call)(exp)
[ "def", "eval_callx", "(", "self", ",", "exp", ")", ":", "# below: this isn't contains(exp,consumes_row) -- it's just checking the current expression", "return", "(", "self", ".", "eval_agg_call", "if", "consumes_rows", "(", "exp", ")", "else", "self", ".", "eval_nonagg_ca...
dispatch for CallX
[ "dispatch", "for", "CallX" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/sqex.py#L284-L287
abe-winter/pg13-py
pg13/sqex.py
Evaluator.eval_unx
def eval_unx(self, exp): "unary expressions" inner=self.eval(exp.val) if exp.op.op=='+': return inner elif exp.op.op=='-': return -inner elif exp.op.op=='not': return threevl.ThreeVL.nein(inner) else: raise NotImplementedError('unk_op',exp.op)
python
def eval_unx(self, exp): "unary expressions" inner=self.eval(exp.val) if exp.op.op=='+': return inner elif exp.op.op=='-': return -inner elif exp.op.op=='not': return threevl.ThreeVL.nein(inner) else: raise NotImplementedError('unk_op',exp.op)
[ "def", "eval_unx", "(", "self", ",", "exp", ")", ":", "inner", "=", "self", ".", "eval", "(", "exp", ".", "val", ")", "if", "exp", ".", "op", ".", "op", "==", "'+'", ":", "return", "inner", "elif", "exp", ".", "op", ".", "op", "==", "'-'", ":...
unary expressions
[ "unary", "expressions" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/sqex.py#L289-L295
abe-winter/pg13-py
pg13/sqex.py
Evaluator.eval
def eval(self, exp): "main dispatch for expression evaluation" # todo: this needs an AST-assert that all BaseX descendants are being handled if isinstance(exp,sqparse2.BinX): return evalop(exp.op.op, *map(self.eval, (exp.left, exp.right))) elif isinstance(exp,sqparse2.UnX): return self.eval_unx(exp) ...
python
def eval(self, exp): "main dispatch for expression evaluation" # todo: this needs an AST-assert that all BaseX descendants are being handled if isinstance(exp,sqparse2.BinX): return evalop(exp.op.op, *map(self.eval, (exp.left, exp.right))) elif isinstance(exp,sqparse2.UnX): return self.eval_unx(exp) ...
[ "def", "eval", "(", "self", ",", "exp", ")", ":", "# todo: this needs an AST-assert that all BaseX descendants are being handled", "if", "isinstance", "(", "exp", ",", "sqparse2", ".", "BinX", ")", ":", "return", "evalop", "(", "exp", ".", "op", ".", "op", ",", ...
main dispatch for expression evaluation
[ "main", "dispatch", "for", "expression", "evaluation" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/sqex.py#L297-L337
alfredodeza/pecan-notario
pecan_notario/decorator.py
validate
def validate(schema, handler=None, status=400, **kw): """ Used to decorate a Pecan controller with form creation for GET | HEAD and form validation for anything else (e.g., POST | PUT | DELETE ). For an HTTP POST or PUT (RFC2616 unsafe methods) request, the schema is used to validate the request bo...
python
def validate(schema, handler=None, status=400, **kw): """ Used to decorate a Pecan controller with form creation for GET | HEAD and form validation for anything else (e.g., POST | PUT | DELETE ). For an HTTP POST or PUT (RFC2616 unsafe methods) request, the schema is used to validate the request bo...
[ "def", "validate", "(", "schema", ",", "handler", "=", "None", ",", "status", "=", "400", ",", "*", "*", "kw", ")", ":", "def", "deco", "(", "f", ")", ":", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "request", ".", ...
Used to decorate a Pecan controller with form creation for GET | HEAD and form validation for anything else (e.g., POST | PUT | DELETE ). For an HTTP POST or PUT (RFC2616 unsafe methods) request, the schema is used to validate the request body. Errors from validation (if any) are accessible at ``reques...
[ "Used", "to", "decorate", "a", "Pecan", "controller", "with", "form", "creation", "for", "GET", "|", "HEAD", "and", "form", "validation", "for", "anything", "else", "(", "e", ".", "g", ".", "POST", "|", "PUT", "|", "DELETE", ")", "." ]
train
https://github.com/alfredodeza/pecan-notario/blob/824e593e0ef16f276b5636315ba88f5c63b54816/pecan_notario/decorator.py#L11-L60
alfredodeza/pecan-notario
pecan_notario/decorator.py
redirect_to_handler
def redirect_to_handler(error, location): """ Cause a requset with an error to internally redirect to a URI path. This is generally for internal use, but can be called from within a Pecan controller to trigger a validation failure from *within* the controller itself, e.g.:: @expose() ...
python
def redirect_to_handler(error, location): """ Cause a requset with an error to internally redirect to a URI path. This is generally for internal use, but can be called from within a Pecan controller to trigger a validation failure from *within* the controller itself, e.g.:: @expose() ...
[ "def", "redirect_to_handler", "(", "error", ",", "location", ")", ":", "if", "callable", "(", "location", ")", ":", "location", "=", "location", "(", ")", "request", ".", "environ", "[", "'REQUEST_METHOD'", "]", "=", "'GET'", "redirect", "(", "location", "...
Cause a requset with an error to internally redirect to a URI path. This is generally for internal use, but can be called from within a Pecan controller to trigger a validation failure from *within* the controller itself, e.g.:: @expose() @validate(some_schema, '/some/handler') def...
[ "Cause", "a", "requset", "with", "an", "error", "to", "internally", "redirect", "to", "a", "URI", "path", "." ]
train
https://github.com/alfredodeza/pecan-notario/blob/824e593e0ef16f276b5636315ba88f5c63b54816/pecan_notario/decorator.py#L63-L81
awacha/credolib
credolib/qualitycontrol.py
assess_fitting_results
def assess_fitting_results(basename, cormap_alpha=0.01): """Assess the results of a fit based on the .fit and .fir files created by various programs from the ATSAS suite.""" plt.figure(figsize=(12, 4)) plt.subplot2grid((1, 4), (0, 0), colspan=2) fir = np.loadtxt(basename + '.fir', skiprows=1) # q, ...
python
def assess_fitting_results(basename, cormap_alpha=0.01): """Assess the results of a fit based on the .fit and .fir files created by various programs from the ATSAS suite.""" plt.figure(figsize=(12, 4)) plt.subplot2grid((1, 4), (0, 0), colspan=2) fir = np.loadtxt(basename + '.fir', skiprows=1) # q, ...
[ "def", "assess_fitting_results", "(", "basename", ",", "cormap_alpha", "=", "0.01", ")", ":", "plt", ".", "figure", "(", "figsize", "=", "(", "12", ",", "4", ")", ")", "plt", ".", "subplot2grid", "(", "(", "1", ",", "4", ")", ",", "(", "0", ",", ...
Assess the results of a fit based on the .fit and .fir files created by various programs from the ATSAS suite.
[ "Assess", "the", "results", "of", "a", "fit", "based", "on", "the", ".", "fit", "and", ".", "fir", "files", "created", "by", "various", "programs", "from", "the", "ATSAS", "suite", "." ]
train
https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/qualitycontrol.py#L184-L236
cirruscluster/cirruscluster
cirruscluster/ext/ansible/runner/__init__.py
Runner._transfer_str
def _transfer_str(self, conn, tmp, name, data): ''' transfer string to remote file ''' if type(data) == dict: data = utils.jsonify(data) afd, afile = tempfile.mkstemp() afo = os.fdopen(afd, 'w') try: afo.write(data.encode('utf8')) except: ...
python
def _transfer_str(self, conn, tmp, name, data): ''' transfer string to remote file ''' if type(data) == dict: data = utils.jsonify(data) afd, afile = tempfile.mkstemp() afo = os.fdopen(afd, 'w') try: afo.write(data.encode('utf8')) except: ...
[ "def", "_transfer_str", "(", "self", ",", "conn", ",", "tmp", ",", "name", ",", "data", ")", ":", "if", "type", "(", "data", ")", "==", "dict", ":", "data", "=", "utils", ".", "jsonify", "(", "data", ")", "afd", ",", "afile", "=", "tempfile", "."...
transfer string to remote file
[ "transfer", "string", "to", "remote", "file" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L168-L188
cirruscluster/cirruscluster
cirruscluster/ext/ansible/runner/__init__.py
Runner._execute_module
def _execute_module(self, conn, tmp, module_name, args, async_jid=None, async_module=None, async_limit=None, inject=None): ''' runs a module that has already been transferred ''' # hack to support fireball mode if module_name == 'fireball': args = "%s password=%s" % (args, ...
python
def _execute_module(self, conn, tmp, module_name, args, async_jid=None, async_module=None, async_limit=None, inject=None): ''' runs a module that has already been transferred ''' # hack to support fireball mode if module_name == 'fireball': args = "%s password=%s" % (args, ...
[ "def", "_execute_module", "(", "self", ",", "conn", ",", "tmp", ",", "module_name", ",", "args", ",", "async_jid", "=", "None", ",", "async_module", "=", "None", ",", "async_limit", "=", "None", ",", "inject", "=", "None", ")", ":", "# hack to support fire...
runs a module that has already been transferred
[ "runs", "a", "module", "that", "has", "already", "been", "transferred" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L192-L232
cirruscluster/cirruscluster
cirruscluster/ext/ansible/runner/__init__.py
Runner._executor
def _executor(self, host): ''' handler for multiprocessing library ''' try: exec_rc = self._executor_internal(host) #if type(exec_rc) != ReturnData and type(exec_rc) != ansible.runner.return_data.ReturnData: # raise Exception("unexpected return type: %s" % type(ex...
python
def _executor(self, host): ''' handler for multiprocessing library ''' try: exec_rc = self._executor_internal(host) #if type(exec_rc) != ReturnData and type(exec_rc) != ansible.runner.return_data.ReturnData: # raise Exception("unexpected return type: %s" % type(ex...
[ "def", "_executor", "(", "self", ",", "host", ")", ":", "try", ":", "exec_rc", "=", "self", ".", "_executor_internal", "(", "host", ")", "#if type(exec_rc) != ReturnData and type(exec_rc) != ansible.runner.return_data.ReturnData:", "# raise Exception(\"unexpected return type...
handler for multiprocessing library
[ "handler", "for", "multiprocessing", "library" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L240-L258
cirruscluster/cirruscluster
cirruscluster/ext/ansible/runner/__init__.py
Runner._executor_internal
def _executor_internal(self, host): ''' executes any module one or more times ''' host_variables = self.inventory.get_variables(host) if self.transport in [ 'paramiko', 'ssh' ]: port = host_variables.get('ansible_ssh_port', self.remote_port) if port is None: ...
python
def _executor_internal(self, host): ''' executes any module one or more times ''' host_variables = self.inventory.get_variables(host) if self.transport in [ 'paramiko', 'ssh' ]: port = host_variables.get('ansible_ssh_port', self.remote_port) if port is None: ...
[ "def", "_executor_internal", "(", "self", ",", "host", ")", ":", "host_variables", "=", "self", ".", "inventory", ".", "get_variables", "(", "host", ")", "if", "self", ".", "transport", "in", "[", "'paramiko'", ",", "'ssh'", "]", ":", "port", "=", "host_...
executes any module one or more times
[ "executes", "any", "module", "one", "or", "more", "times" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L262-L332
cirruscluster/cirruscluster
cirruscluster/ext/ansible/runner/__init__.py
Runner._executor_internal_inner
def _executor_internal_inner(self, host, module_name, module_args, inject, port, is_chained=False): ''' decides how to invoke a module ''' # allow module args to work as a dictionary # though it is usually a string new_args = "" if type(module_args) == dict: for (k,v...
python
def _executor_internal_inner(self, host, module_name, module_args, inject, port, is_chained=False): ''' decides how to invoke a module ''' # allow module args to work as a dictionary # though it is usually a string new_args = "" if type(module_args) == dict: for (k,v...
[ "def", "_executor_internal_inner", "(", "self", ",", "host", ",", "module_name", ",", "module_args", ",", "inject", ",", "port", ",", "is_chained", "=", "False", ")", ":", "# allow module args to work as a dictionary", "# though it is usually a string", "new_args", "=",...
decides how to invoke a module
[ "decides", "how", "to", "invoke", "a", "module" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L336-L444
cirruscluster/cirruscluster
cirruscluster/ext/ansible/runner/__init__.py
Runner._low_level_exec_command
def _low_level_exec_command(self, conn, cmd, tmp, sudoable=False, executable=None): ''' execute a command string over SSH, return the output ''' if executable is None: executable = '/bin/sh' sudo_user = self.sudo_user rc, stdin, stdout, stderr = conn.exec_command(cmd, tmp, ...
python
def _low_level_exec_command(self, conn, cmd, tmp, sudoable=False, executable=None): ''' execute a command string over SSH, return the output ''' if executable is None: executable = '/bin/sh' sudo_user = self.sudo_user rc, stdin, stdout, stderr = conn.exec_command(cmd, tmp, ...
[ "def", "_low_level_exec_command", "(", "self", ",", "conn", ",", "cmd", ",", "tmp", ",", "sudoable", "=", "False", ",", "executable", "=", "None", ")", ":", "if", "executable", "is", "None", ":", "executable", "=", "'/bin/sh'", "sudo_user", "=", "self", ...
execute a command string over SSH, return the output
[ "execute", "a", "command", "string", "over", "SSH", "return", "the", "output" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L448-L470
cirruscluster/cirruscluster
cirruscluster/ext/ansible/runner/__init__.py
Runner._remote_md5
def _remote_md5(self, conn, tmp, path): ''' takes a remote md5sum without requiring python, and returns 0 if no file ''' test = "rc=0; [ -r \"%s\" ] || rc=2; [ -f \"%s\" ] || rc=1" % (path,path) md5s = [ "(/usr/bin/md5sum %s 2>/dev/null)" % path, # Linux "(/sbin/md5sum ...
python
def _remote_md5(self, conn, tmp, path): ''' takes a remote md5sum without requiring python, and returns 0 if no file ''' test = "rc=0; [ -r \"%s\" ] || rc=2; [ -f \"%s\" ] || rc=1" % (path,path) md5s = [ "(/usr/bin/md5sum %s 2>/dev/null)" % path, # Linux "(/sbin/md5sum ...
[ "def", "_remote_md5", "(", "self", ",", "conn", ",", "tmp", ",", "path", ")", ":", "test", "=", "\"rc=0; [ -r \\\"%s\\\" ] || rc=2; [ -f \\\"%s\\\" ] || rc=1\"", "%", "(", "path", ",", "path", ")", "md5s", "=", "[", "\"(/usr/bin/md5sum %s 2>/dev/null)\"", "%", "pa...
takes a remote md5sum without requiring python, and returns 0 if no file
[ "takes", "a", "remote", "md5sum", "without", "requiring", "python", "and", "returns", "0", "if", "no", "file" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L474-L500
cirruscluster/cirruscluster
cirruscluster/ext/ansible/runner/__init__.py
Runner._make_tmp_path
def _make_tmp_path(self, conn): ''' make and return a temporary path on a remote box ''' basefile = 'ansible-%s-%s' % (time.time(), random.randint(0, 2**48)) basetmp = os.path.join(C.DEFAULT_REMOTE_TMP, basefile) if self.sudo and self.sudo_user != 'root': basetmp = os.path.j...
python
def _make_tmp_path(self, conn): ''' make and return a temporary path on a remote box ''' basefile = 'ansible-%s-%s' % (time.time(), random.randint(0, 2**48)) basetmp = os.path.join(C.DEFAULT_REMOTE_TMP, basefile) if self.sudo and self.sudo_user != 'root': basetmp = os.path.j...
[ "def", "_make_tmp_path", "(", "self", ",", "conn", ")", ":", "basefile", "=", "'ansible-%s-%s'", "%", "(", "time", ".", "time", "(", ")", ",", "random", ".", "randint", "(", "0", ",", "2", "**", "48", ")", ")", "basetmp", "=", "os", ".", "path", ...
make and return a temporary path on a remote box
[ "make", "and", "return", "a", "temporary", "path", "on", "a", "remote", "box" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L504-L519
cirruscluster/cirruscluster
cirruscluster/ext/ansible/runner/__init__.py
Runner._copy_module
def _copy_module(self, conn, tmp, module_name, module_args, inject): ''' transfer a module over SFTP, does not run it ''' if module_name.startswith("/"): raise errors.AnsibleFileNotFound("%s is not a module" % module_name) # Search module path(s) for named module. in_path =...
python
def _copy_module(self, conn, tmp, module_name, module_args, inject): ''' transfer a module over SFTP, does not run it ''' if module_name.startswith("/"): raise errors.AnsibleFileNotFound("%s is not a module" % module_name) # Search module path(s) for named module. in_path =...
[ "def", "_copy_module", "(", "self", ",", "conn", ",", "tmp", ",", "module_name", ",", "module_args", ",", "inject", ")", ":", "if", "module_name", ".", "startswith", "(", "\"/\"", ")", ":", "raise", "errors", ".", "AnsibleFileNotFound", "(", "\"%s is not a m...
transfer a module over SFTP, does not run it
[ "transfer", "a", "module", "over", "SFTP", "does", "not", "run", "it" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L524-L569
cirruscluster/cirruscluster
cirruscluster/ext/ansible/runner/__init__.py
Runner._parallel_exec
def _parallel_exec(self, hosts): ''' handles mulitprocessing when more than 1 fork is required ''' if not hosts: return p = multiprocessing.Pool(self.forks) results = [] #results = p.map(multiprocessing_runner, hosts) # can't handle keyboard interrupt results ...
python
def _parallel_exec(self, hosts): ''' handles mulitprocessing when more than 1 fork is required ''' if not hosts: return p = multiprocessing.Pool(self.forks) results = [] #results = p.map(multiprocessing_runner, hosts) # can't handle keyboard interrupt results ...
[ "def", "_parallel_exec", "(", "self", ",", "hosts", ")", ":", "if", "not", "hosts", ":", "return", "p", "=", "multiprocessing", ".", "Pool", "(", "self", ".", "forks", ")", "results", "=", "[", "]", "#results = p.map(multiprocessing_runner, hosts) # can't handle...
handles mulitprocessing when more than 1 fork is required
[ "handles", "mulitprocessing", "when", "more", "than", "1", "fork", "is", "required" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L621-L631
cirruscluster/cirruscluster
cirruscluster/ext/ansible/runner/__init__.py
Runner._partition_results
def _partition_results(self, results): ''' seperate results by ones we contacted & ones we didn't ''' if results is None: return None results2 = dict(contacted={}, dark={}) for result in results: host = result.host if host is None: ra...
python
def _partition_results(self, results): ''' seperate results by ones we contacted & ones we didn't ''' if results is None: return None results2 = dict(contacted={}, dark={}) for result in results: host = result.host if host is None: ra...
[ "def", "_partition_results", "(", "self", ",", "results", ")", ":", "if", "results", "is", "None", ":", "return", "None", "results2", "=", "dict", "(", "contacted", "=", "{", "}", ",", "dark", "=", "{", "}", ")", "for", "result", "in", "results", ":"...
seperate results by ones we contacted & ones we didn't
[ "seperate", "results", "by", "ones", "we", "contacted", "&", "ones", "we", "didn", "t" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L635-L655
cirruscluster/cirruscluster
cirruscluster/ext/ansible/runner/__init__.py
Runner.run
def run(self): ''' xfer & run module on all matched hosts ''' # find hosts that match the pattern hosts = self.inventory.list_hosts(self.pattern) if len(hosts) == 0: self.callbacks.on_no_hosts() return dict(contacted={}, dark={}) global multiprocessing_r...
python
def run(self): ''' xfer & run module on all matched hosts ''' # find hosts that match the pattern hosts = self.inventory.list_hosts(self.pattern) if len(hosts) == 0: self.callbacks.on_no_hosts() return dict(contacted={}, dark={}) global multiprocessing_r...
[ "def", "run", "(", "self", ")", ":", "# find hosts that match the pattern", "hosts", "=", "self", ".", "inventory", ".", "list_hosts", "(", "self", ".", "pattern", ")", "if", "len", "(", "hosts", ")", "==", "0", ":", "self", ".", "callbacks", ".", "on_no...
xfer & run module on all matched hosts
[ "xfer", "&", "run", "module", "on", "all", "matched", "hosts" ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L659-L701
cirruscluster/cirruscluster
cirruscluster/ext/ansible/runner/__init__.py
Runner.run_async
def run_async(self, time_limit): ''' Run this module asynchronously and return a poller. ''' self.background = time_limit results = self.run() return results, poller.AsyncPoller(results, self)
python
def run_async(self, time_limit): ''' Run this module asynchronously and return a poller. ''' self.background = time_limit results = self.run() return results, poller.AsyncPoller(results, self)
[ "def", "run_async", "(", "self", ",", "time_limit", ")", ":", "self", ".", "background", "=", "time_limit", "results", "=", "self", ".", "run", "(", ")", "return", "results", ",", "poller", ".", "AsyncPoller", "(", "results", ",", "self", ")" ]
Run this module asynchronously and return a poller.
[ "Run", "this", "module", "asynchronously", "and", "return", "a", "poller", "." ]
train
https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/__init__.py#L705-L710
motiejus/tictactoelib
tictactoelib/communicate.py
run_interactive
def run_interactive( source_x, source_o, timeout=None, memlimit=None, cgroup=None, cgroup_path=None): """Challenges source_x vs source_y under time/memory constraints memlimit = memory limit in bytes (for Lua interpreter and everything under) cgroup = existing cgroup where to put this conte...
python
def run_interactive( source_x, source_o, timeout=None, memlimit=None, cgroup=None, cgroup_path=None): """Challenges source_x vs source_y under time/memory constraints memlimit = memory limit in bytes (for Lua interpreter and everything under) cgroup = existing cgroup where to put this conte...
[ "def", "run_interactive", "(", "source_x", ",", "source_o", ",", "timeout", "=", "None", ",", "memlimit", "=", "None", ",", "cgroup", "=", "None", ",", "cgroup_path", "=", "None", ")", ":", "msg", "=", "msgpack", ".", "packb", "(", "[", "source_x", ","...
Challenges source_x vs source_y under time/memory constraints memlimit = memory limit in bytes (for Lua interpreter and everything under) cgroup = existing cgroup where to put this contest
[ "Challenges", "source_x", "vs", "source_y", "under", "time", "/", "memory", "constraints" ]
train
https://github.com/motiejus/tictactoelib/blob/c884e206f11d9472ce0b7d08e06f894b24a20989/tictactoelib/communicate.py#L27-L73
kshlm/gant
gant/utils/docker_helper.py
DockerHelper.image_by_id
def image_by_id(self, id): """ Return image with given Id """ if not id: return None return next((image for image in self.images() if image['Id'] == id), None)
python
def image_by_id(self, id): """ Return image with given Id """ if not id: return None return next((image for image in self.images() if image['Id'] == id), None)
[ "def", "image_by_id", "(", "self", ",", "id", ")", ":", "if", "not", "id", ":", "return", "None", "return", "next", "(", "(", "image", "for", "image", "in", "self", ".", "images", "(", ")", "if", "image", "[", "'Id'", "]", "==", "id", ")", ",", ...
Return image with given Id
[ "Return", "image", "with", "given", "Id" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/docker_helper.py#L21-L28
kshlm/gant
gant/utils/docker_helper.py
DockerHelper.image_by_tag
def image_by_tag(self, tag): """ Return image with given tag """ if not tag: return None return next((image for image in self.images() if tag in image['RepoTags']), None)
python
def image_by_tag(self, tag): """ Return image with given tag """ if not tag: return None return next((image for image in self.images() if tag in image['RepoTags']), None)
[ "def", "image_by_tag", "(", "self", ",", "tag", ")", ":", "if", "not", "tag", ":", "return", "None", "return", "next", "(", "(", "image", "for", "image", "in", "self", ".", "images", "(", ")", "if", "tag", "in", "image", "[", "'RepoTags'", "]", ")"...
Return image with given tag
[ "Return", "image", "with", "given", "tag" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/docker_helper.py#L30-L38
kshlm/gant
gant/utils/docker_helper.py
DockerHelper.image_exists
def image_exists(self, id=None, tag=None): """ Check if specified image exists """ exists = False if id and self.image_by_id(id): exists = True elif tag and self.image_by_tag(tag): exists = True return exists
python
def image_exists(self, id=None, tag=None): """ Check if specified image exists """ exists = False if id and self.image_by_id(id): exists = True elif tag and self.image_by_tag(tag): exists = True return exists
[ "def", "image_exists", "(", "self", ",", "id", "=", "None", ",", "tag", "=", "None", ")", ":", "exists", "=", "False", "if", "id", "and", "self", ".", "image_by_id", "(", "id", ")", ":", "exists", "=", "True", "elif", "tag", "and", "self", ".", "...
Check if specified image exists
[ "Check", "if", "specified", "image", "exists" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/docker_helper.py#L40-L50
kshlm/gant
gant/utils/docker_helper.py
DockerHelper.container_by_id
def container_by_id(self, id): """ Returns container with given id """ if not id: return None return next((container for container in self.containers(all=True) if container['Id'] == id), None)
python
def container_by_id(self, id): """ Returns container with given id """ if not id: return None return next((container for container in self.containers(all=True) if container['Id'] == id), None)
[ "def", "container_by_id", "(", "self", ",", "id", ")", ":", "if", "not", "id", ":", "return", "None", "return", "next", "(", "(", "container", "for", "container", "in", "self", ".", "containers", "(", "all", "=", "True", ")", "if", "container", "[", ...
Returns container with given id
[ "Returns", "container", "with", "given", "id" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/docker_helper.py#L52-L59
kshlm/gant
gant/utils/docker_helper.py
DockerHelper.container_by_name
def container_by_name(self, name): """ Returns container with given name """ if not name: return None # docker prepends a '/' to container names in the container dict name = '/'+name return next((container for container in self.containers(all=True) ...
python
def container_by_name(self, name): """ Returns container with given name """ if not name: return None # docker prepends a '/' to container names in the container dict name = '/'+name return next((container for container in self.containers(all=True) ...
[ "def", "container_by_name", "(", "self", ",", "name", ")", ":", "if", "not", "name", ":", "return", "None", "# docker prepends a '/' to container names in the container dict", "name", "=", "'/'", "+", "name", "return", "next", "(", "(", "container", "for", "contai...
Returns container with given name
[ "Returns", "container", "with", "given", "name" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/docker_helper.py#L61-L71
kshlm/gant
gant/utils/docker_helper.py
DockerHelper.container_exists
def container_exists(self, id=None, name=None): """ Checks if container exists already """ exists = False if id and self.container_by_id(id): exists = True elif name and self.container_by_name(name): exists = True return exists
python
def container_exists(self, id=None, name=None): """ Checks if container exists already """ exists = False if id and self.container_by_id(id): exists = True elif name and self.container_by_name(name): exists = True return exists
[ "def", "container_exists", "(", "self", ",", "id", "=", "None", ",", "name", "=", "None", ")", ":", "exists", "=", "False", "if", "id", "and", "self", ".", "container_by_id", "(", "id", ")", ":", "exists", "=", "True", "elif", "name", "and", "self", ...
Checks if container exists already
[ "Checks", "if", "container", "exists", "already" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/docker_helper.py#L73-L83
kshlm/gant
gant/utils/docker_helper.py
DockerHelper.container_running
def container_running(self, id=None, name=None): """ Checks if container is running """ running = False if id: running = self.inspect_container(id)['State']['Running'] elif name: running = self.inspect_container(name)['State']['Running'] re...
python
def container_running(self, id=None, name=None): """ Checks if container is running """ running = False if id: running = self.inspect_container(id)['State']['Running'] elif name: running = self.inspect_container(name)['State']['Running'] re...
[ "def", "container_running", "(", "self", ",", "id", "=", "None", ",", "name", "=", "None", ")", ":", "running", "=", "False", "if", "id", ":", "running", "=", "self", ".", "inspect_container", "(", "id", ")", "[", "'State'", "]", "[", "'Running'", "]...
Checks if container is running
[ "Checks", "if", "container", "is", "running" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/docker_helper.py#L85-L94
kshlm/gant
gant/utils/docker_helper.py
DockerHelper.get_container_ip
def get_container_ip(self, container): """ Returns the internal ip of the container if available """ info = self.inspect_container(container) if not info: return None netInfo = info['NetworkSettings'] if not netInfo: return None i...
python
def get_container_ip(self, container): """ Returns the internal ip of the container if available """ info = self.inspect_container(container) if not info: return None netInfo = info['NetworkSettings'] if not netInfo: return None i...
[ "def", "get_container_ip", "(", "self", ",", "container", ")", ":", "info", "=", "self", ".", "inspect_container", "(", "container", ")", "if", "not", "info", ":", "return", "None", "netInfo", "=", "info", "[", "'NetworkSettings'", "]", "if", "not", "netIn...
Returns the internal ip of the container if available
[ "Returns", "the", "internal", "ip", "of", "the", "container", "if", "available" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/docker_helper.py#L96-L112
polysquare/python-parse-shebang
parseshebang/__init__.py
_parse
def _parse(fileobj): """Parse fileobj for a shebang.""" fileobj.seek(0) try: part = fileobj.read(2) except UnicodeDecodeError: part = "" if part == "#!": shebang = shlex.split(fileobj.readline().strip()) if (platform.system() == "Windows" and len(sheb...
python
def _parse(fileobj): """Parse fileobj for a shebang.""" fileobj.seek(0) try: part = fileobj.read(2) except UnicodeDecodeError: part = "" if part == "#!": shebang = shlex.split(fileobj.readline().strip()) if (platform.system() == "Windows" and len(sheb...
[ "def", "_parse", "(", "fileobj", ")", ":", "fileobj", ".", "seek", "(", "0", ")", "try", ":", "part", "=", "fileobj", ".", "read", "(", "2", ")", "except", "UnicodeDecodeError", ":", "part", "=", "\"\"", "if", "part", "==", "\"#!\"", ":", "shebang", ...
Parse fileobj for a shebang.
[ "Parse", "fileobj", "for", "a", "shebang", "." ]
train
https://github.com/polysquare/python-parse-shebang/blob/18fddc6d987268edb031a2903c66820f5ad52902/parseshebang/__init__.py#L20-L37
polysquare/python-parse-shebang
parseshebang/__init__.py
parse
def parse(file_to_parse): # suppress(unused-function) """Check file_to_parse for a shebang and return its components. :file_to_parse: can be either a filename or an open file object. If file_to_parse's extension exists in PATHEXT then an empty list will be returned, as it is assumed that the operatin...
python
def parse(file_to_parse): # suppress(unused-function) """Check file_to_parse for a shebang and return its components. :file_to_parse: can be either a filename or an open file object. If file_to_parse's extension exists in PATHEXT then an empty list will be returned, as it is assumed that the operatin...
[ "def", "parse", "(", "file_to_parse", ")", ":", "# suppress(unused-function)", "if", "hasattr", "(", "file_to_parse", ",", "\"read\"", ")", ":", "return", "_parse", "(", "file_to_parse", ")", "elif", "isinstance", "(", "file_to_parse", ",", "six", ".", "string_t...
Check file_to_parse for a shebang and return its components. :file_to_parse: can be either a filename or an open file object. If file_to_parse's extension exists in PATHEXT then an empty list will be returned, as it is assumed that the operating system knows how to handle files of this type. All other...
[ "Check", "file_to_parse", "for", "a", "shebang", "and", "return", "its", "components", "." ]
train
https://github.com/polysquare/python-parse-shebang/blob/18fddc6d987268edb031a2903c66820f5ad52902/parseshebang/__init__.py#L40-L64
drewsonne/aws-autodiscovery-templater
awsautodiscoverytemplater/command.py
TemplateCommand.run
def run(self): """ Entrypoint to kick off the job to generate the templater :return: """ credentials = auth.Credentials(**vars(self)) if credentials.has_role(): credentials.assume_role() ################# # Set callbacks # ############...
python
def run(self): """ Entrypoint to kick off the job to generate the templater :return: """ credentials = auth.Credentials(**vars(self)) if credentials.has_role(): credentials.assume_role() ################# # Set callbacks # ############...
[ "def", "run", "(", "self", ")", ":", "credentials", "=", "auth", ".", "Credentials", "(", "*", "*", "vars", "(", "self", ")", ")", "if", "credentials", ".", "has_role", "(", ")", ":", "credentials", ".", "assume_role", "(", ")", "#################", "#...
Entrypoint to kick off the job to generate the templater :return:
[ "Entrypoint", "to", "kick", "off", "the", "job", "to", "generate", "the", "templater", ":", "return", ":" ]
train
https://github.com/drewsonne/aws-autodiscovery-templater/blob/9ef2edd6a373aeb5d343b841550c210966efe079/awsautodiscoverytemplater/command.py#L32-L80
drewsonne/aws-autodiscovery-templater
awsautodiscoverytemplater/command.py
TemplateCommand.generate_output_file
def generate_output_file(path): """ Generate a function to send the content to the file specified in 'path' :param path: :return: """ def write_file(content): """ Function to do write_file operation :param content: :return:...
python
def generate_output_file(path): """ Generate a function to send the content to the file specified in 'path' :param path: :return: """ def write_file(content): """ Function to do write_file operation :param content: :return:...
[ "def", "generate_output_file", "(", "path", ")", ":", "def", "write_file", "(", "content", ")", ":", "\"\"\"\n Function to do write_file operation\n :param content:\n :return:\n \"\"\"", "with", "open", "(", "path", ",", "'w+'", ")", ...
Generate a function to send the content to the file specified in 'path' :param path: :return:
[ "Generate", "a", "function", "to", "send", "the", "content", "to", "the", "file", "specified", "in", "path", ":", "param", "path", ":", ":", "return", ":" ]
train
https://github.com/drewsonne/aws-autodiscovery-templater/blob/9ef2edd6a373aeb5d343b841550c210966efe079/awsautodiscoverytemplater/command.py#L92-L108
drewsonne/aws-autodiscovery-templater
awsautodiscoverytemplater/command.py
TemplateCommand.generate_file_template_load
def generate_file_template_load(path): """ Generate calleable to return the content of the template on disk :param path: :return: """ path = os.path.expanduser(os.path.abspath( path )) def read_file(): """ Read file...
python
def generate_file_template_load(path): """ Generate calleable to return the content of the template on disk :param path: :return: """ path = os.path.expanduser(os.path.abspath( path )) def read_file(): """ Read file...
[ "def", "generate_file_template_load", "(", "path", ")", ":", "path", "=", "os", ".", "path", ".", "expanduser", "(", "os", ".", "path", ".", "abspath", "(", "path", ")", ")", "def", "read_file", "(", ")", ":", "\"\"\"\n Read file from path and retur...
Generate calleable to return the content of the template on disk :param path: :return:
[ "Generate", "calleable", "to", "return", "the", "content", "of", "the", "template", "on", "disk", ":", "param", "path", ":", ":", "return", ":" ]
train
https://github.com/drewsonne/aws-autodiscovery-templater/blob/9ef2edd6a373aeb5d343b841550c210966efe079/awsautodiscoverytemplater/command.py#L128-L146
drewsonne/aws-autodiscovery-templater
awsautodiscoverytemplater/command.py
TemplateRequest.response
def response(self): """ Dictionary of public and private, hostnames and ips. :rtype: dict """ describe_request_params = {} if self.filter is not None: if type(self.filter) is not dict: try: filters = json.loads(self.filter) ...
python
def response(self): """ Dictionary of public and private, hostnames and ips. :rtype: dict """ describe_request_params = {} if self.filter is not None: if type(self.filter) is not dict: try: filters = json.loads(self.filter) ...
[ "def", "response", "(", "self", ")", ":", "describe_request_params", "=", "{", "}", "if", "self", ".", "filter", "is", "not", "None", ":", "if", "type", "(", "self", ".", "filter", ")", "is", "not", "dict", ":", "try", ":", "filters", "=", "json", ...
Dictionary of public and private, hostnames and ips. :rtype: dict
[ "Dictionary", "of", "public", "and", "private", "hostnames", "and", "ips", ".", ":", "rtype", ":", "dict" ]
train
https://github.com/drewsonne/aws-autodiscovery-templater/blob/9ef2edd6a373aeb5d343b841550c210966efe079/awsautodiscoverytemplater/command.py#L178-L203
drewsonne/aws-autodiscovery-templater
awsautodiscoverytemplater/command.py
TemplateRequest._process_reservations
def _process_reservations(self, reservations): """ Given a dict with the structure of a response from boto3.ec2.describe_instances(...), find the public/private ips. :param reservations: :return: """ reservations = reservations['Reservations'] private_ip...
python
def _process_reservations(self, reservations): """ Given a dict with the structure of a response from boto3.ec2.describe_instances(...), find the public/private ips. :param reservations: :return: """ reservations = reservations['Reservations'] private_ip...
[ "def", "_process_reservations", "(", "self", ",", "reservations", ")", ":", "reservations", "=", "reservations", "[", "'Reservations'", "]", "private_ip_addresses", "=", "[", "]", "private_hostnames", "=", "[", "]", "public_ips", "=", "[", "]", "public_hostnames",...
Given a dict with the structure of a response from boto3.ec2.describe_instances(...), find the public/private ips. :param reservations: :return:
[ "Given", "a", "dict", "with", "the", "structure", "of", "a", "response", "from", "boto3", ".", "ec2", ".", "describe_instances", "(", "...", ")", "find", "the", "public", "/", "private", "ips", ".", ":", "param", "reservations", ":", ":", "return", ":" ]
train
https://github.com/drewsonne/aws-autodiscovery-templater/blob/9ef2edd6a373aeb5d343b841550c210966efe079/awsautodiscoverytemplater/command.py#L205-L244
drewsonne/aws-autodiscovery-templater
awsautodiscoverytemplater/command.py
TemplateRequest._parse_cli_filters
def _parse_cli_filters(filters): """ Parse the filters from the CLI and turn them into a filter dict for boto. :param filters: :return: """ parsed_filters = [] for filter_entry in filters: filter_parts = re.match('^Name=(?P<name_value>[^,]+),Values=\[?...
python
def _parse_cli_filters(filters): """ Parse the filters from the CLI and turn them into a filter dict for boto. :param filters: :return: """ parsed_filters = [] for filter_entry in filters: filter_parts = re.match('^Name=(?P<name_value>[^,]+),Values=\[?...
[ "def", "_parse_cli_filters", "(", "filters", ")", ":", "parsed_filters", "=", "[", "]", "for", "filter_entry", "in", "filters", ":", "filter_parts", "=", "re", ".", "match", "(", "'^Name=(?P<name_value>[^,]+),Values=\\[?(?P<key_values>[^\\]]+)\\]?'", ",", "filter_entry"...
Parse the filters from the CLI and turn them into a filter dict for boto. :param filters: :return:
[ "Parse", "the", "filters", "from", "the", "CLI", "and", "turn", "them", "into", "a", "filter", "dict", "for", "boto", ".", ":", "param", "filters", ":", ":", "return", ":" ]
train
https://github.com/drewsonne/aws-autodiscovery-templater/blob/9ef2edd6a373aeb5d343b841550c210966efe079/awsautodiscoverytemplater/command.py#L247-L260
tomokinakamaru/mapletree
mapletree/mapletree.py
MapleTree.run
def run(self, port=5000, background=False): """ Runs this application with builtin server for testing. This is only for test usage, do not use in production stage. :param port: Port number :param background: Flag to run in background :type port: int :type background: boo...
python
def run(self, port=5000, background=False): """ Runs this application with builtin server for testing. This is only for test usage, do not use in production stage. :param port: Port number :param background: Flag to run in background :type port: int :type background: boo...
[ "def", "run", "(", "self", ",", "port", "=", "5000", ",", "background", "=", "False", ")", ":", "target", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "sys", ".", "argv", "[", "0", "]", ")", ")", "driver"...
Runs this application with builtin server for testing. This is only for test usage, do not use in production stage. :param port: Port number :param background: Flag to run in background :type port: int :type background: bool
[ "Runs", "this", "application", "with", "builtin", "server", "for", "testing", ".", "This", "is", "only", "for", "test", "usage", "do", "not", "use", "in", "production", "stage", "." ]
train
https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/mapletree.py#L74-L89
stuaxo/mnd
mnd/dispatch.py
Dispatcher.bind
def bind(self, handler, argspec): """ :param handler: a function with :param argspec: :return: """ self.handlers[argspec.key].append((handler, argspec))
python
def bind(self, handler, argspec): """ :param handler: a function with :param argspec: :return: """ self.handlers[argspec.key].append((handler, argspec))
[ "def", "bind", "(", "self", ",", "handler", ",", "argspec", ")", ":", "self", ".", "handlers", "[", "argspec", ".", "key", "]", ".", "append", "(", "(", "handler", ",", "argspec", ")", ")" ]
:param handler: a function with :param argspec: :return:
[ ":", "param", "handler", ":", "a", "function", "with", ":", "param", "argspec", ":", ":", "return", ":" ]
train
https://github.com/stuaxo/mnd/blob/0eb30155d310fa1e550cb9efd6486816b9231d27/mnd/dispatch.py#L64-L70
stuaxo/mnd
mnd/dispatch.py
Dispatcher.unbind
def unbind(self, handler, argspec): """ handler will no longer be called if args match argspec :param argspec: instance of ArgSpec - args to be matched """ self.handlers[argspec.key].remove((handler, argspec)) if not len(self.handlers[argspec.key]): del self....
python
def unbind(self, handler, argspec): """ handler will no longer be called if args match argspec :param argspec: instance of ArgSpec - args to be matched """ self.handlers[argspec.key].remove((handler, argspec)) if not len(self.handlers[argspec.key]): del self....
[ "def", "unbind", "(", "self", ",", "handler", ",", "argspec", ")", ":", "self", ".", "handlers", "[", "argspec", ".", "key", "]", ".", "remove", "(", "(", "handler", ",", "argspec", ")", ")", "if", "not", "len", "(", "self", ".", "handlers", "[", ...
handler will no longer be called if args match argspec :param argspec: instance of ArgSpec - args to be matched
[ "handler", "will", "no", "longer", "be", "called", "if", "args", "match", "argspec" ]
train
https://github.com/stuaxo/mnd/blob/0eb30155d310fa1e550cb9efd6486816b9231d27/mnd/dispatch.py#L72-L80
stuaxo/mnd
mnd/dispatch.py
Dispatcher.dispatch
def dispatch(self, *args, **kwargs): """ Call handlers that match args or kwargs :return: set of handlers called """ called_handlers = set() for handler_list in self.handlers.values(): for handler, argspec in handler_list: accept_args, accept_...
python
def dispatch(self, *args, **kwargs): """ Call handlers that match args or kwargs :return: set of handlers called """ called_handlers = set() for handler_list in self.handlers.values(): for handler, argspec in handler_list: accept_args, accept_...
[ "def", "dispatch", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "called_handlers", "=", "set", "(", ")", "for", "handler_list", "in", "self", ".", "handlers", ".", "values", "(", ")", ":", "for", "handler", ",", "argspec", "in", ...
Call handlers that match args or kwargs :return: set of handlers called
[ "Call", "handlers", "that", "match", "args", "or", "kwargs" ]
train
https://github.com/stuaxo/mnd/blob/0eb30155d310fa1e550cb9efd6486816b9231d27/mnd/dispatch.py#L82-L99
sniegu/django-surround
surround/common/git_info.py
GitInfo.get_sorted_tags
def get_sorted_tags(self, pattern): """ pattern - for production: r'^v(\d+)\.(\d+)\.(\d+)\.0' all groups from pattern will be converted to integers, and tags will be compared using the resulting tuple """ matcher = re.compile(pattern) tags = [] for tag in self.ge...
python
def get_sorted_tags(self, pattern): """ pattern - for production: r'^v(\d+)\.(\d+)\.(\d+)\.0' all groups from pattern will be converted to integers, and tags will be compared using the resulting tuple """ matcher = re.compile(pattern) tags = [] for tag in self.ge...
[ "def", "get_sorted_tags", "(", "self", ",", "pattern", ")", ":", "matcher", "=", "re", ".", "compile", "(", "pattern", ")", "tags", "=", "[", "]", "for", "tag", "in", "self", ".", "get_repo", "(", ")", ".", "git", ".", "tag", "(", ")", ".", "spli...
pattern - for production: r'^v(\d+)\.(\d+)\.(\d+)\.0' all groups from pattern will be converted to integers, and tags will be compared using the resulting tuple
[ "pattern", "-", "for", "production", ":", "r", "^v", "(", "\\", "d", "+", ")", "\\", ".", "(", "\\", "d", "+", ")", "\\", ".", "(", "\\", "d", "+", ")", "\\", ".", "0" ]
train
https://github.com/sniegu/django-surround/blob/e076ec92a6611a056899f3f4f74a24e676dafb5c/surround/common/git_info.py#L144-L162
pbrisk/unicum
unicum/encode_json.py
UnicumJSONEncoder.iterencode
def iterencode(self, o, _one_shot=False): """Encode the given object and yield each string representation as available. For example:: for chunk in JSONEncoder().iterencode(bigobject): mysocket.write(chunk) """ if self.check_circular: mar...
python
def iterencode(self, o, _one_shot=False): """Encode the given object and yield each string representation as available. For example:: for chunk in JSONEncoder().iterencode(bigobject): mysocket.write(chunk) """ if self.check_circular: mar...
[ "def", "iterencode", "(", "self", ",", "o", ",", "_one_shot", "=", "False", ")", ":", "if", "self", ".", "check_circular", ":", "markers", "=", "{", "}", "else", ":", "markers", "=", "None", "if", "self", ".", "ensure_ascii", ":", "_encoder", "=", "e...
Encode the given object and yield each string representation as available. For example:: for chunk in JSONEncoder().iterencode(bigobject): mysocket.write(chunk)
[ "Encode", "the", "given", "object", "and", "yield", "each", "string", "representation", "as", "available", "." ]
train
https://github.com/pbrisk/unicum/blob/24bfa7355f36847a06646c58e9fd75bd3b689bfe/unicum/encode_json.py#L18-L69
EventTeam/beliefs
src/beliefs/cells/lazy.py
LazyCell.size
def size(self): """ Size of LazyCell: the size of the intension plus accounting for excluded and included additions. The exclusions are assumed to be part of the set The inclusions are assumed to NOT be part of the intension """ return self._size_full_intension ...
python
def size(self): """ Size of LazyCell: the size of the intension plus accounting for excluded and included additions. The exclusions are assumed to be part of the set The inclusions are assumed to NOT be part of the intension """ return self._size_full_intension ...
[ "def", "size", "(", "self", ")", ":", "return", "self", ".", "_size_full_intension", "-", "len", "(", "self", ".", "exclude", ")", "+", "len", "(", "self", ".", "include", ")" ]
Size of LazyCell: the size of the intension plus accounting for excluded and included additions. The exclusions are assumed to be part of the set The inclusions are assumed to NOT be part of the intension
[ "Size", "of", "LazyCell", ":", "the", "size", "of", "the", "intension", "plus", "accounting", "for", "excluded", "and", "included", "additions", "." ]
train
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/lazy.py#L42-L52
EventTeam/beliefs
src/beliefs/cells/lazy.py
LazyCell.update
def update(self): """ Updates intension and then adds or includes extension """ # updates intension self.update_intension() self._size_known_intension = len(self.members) self._update_members = False
python
def update(self): """ Updates intension and then adds or includes extension """ # updates intension self.update_intension() self._size_known_intension = len(self.members) self._update_members = False
[ "def", "update", "(", "self", ")", ":", "# updates intension", "self", ".", "update_intension", "(", ")", "self", ".", "_size_known_intension", "=", "len", "(", "self", ".", "members", ")", "self", ".", "_update_members", "=", "False" ]
Updates intension and then adds or includes extension
[ "Updates", "intension", "and", "then", "adds", "or", "includes", "extension" ]
train
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/lazy.py#L54-L61
EventTeam/beliefs
src/beliefs/cells/lazy.py
LazyCell.is_entailed_by
def is_entailed_by(self, other): """ Means merging other with self does not produce any new information. """ if not set(self.include.keys()).issubset(set(other.include.keys())): return False if not self.exclude.isuperset(other.exclude): return False ...
python
def is_entailed_by(self, other): """ Means merging other with self does not produce any new information. """ if not set(self.include.keys()).issubset(set(other.include.keys())): return False if not self.exclude.isuperset(other.exclude): return False ...
[ "def", "is_entailed_by", "(", "self", ",", "other", ")", ":", "if", "not", "set", "(", "self", ".", "include", ".", "keys", "(", ")", ")", ".", "issubset", "(", "set", "(", "other", ".", "include", ".", "keys", "(", ")", ")", ")", ":", "return", ...
Means merging other with self does not produce any new information.
[ "Means", "merging", "other", "with", "self", "does", "not", "produce", "any", "new", "information", "." ]
train
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/lazy.py#L74-L84
EventTeam/beliefs
src/beliefs/cells/lazy.py
LazyCell.is_equal
def is_equal(self, other): """ The objects must be the same - Same members (if enumerated) - Or same structure (if not enumerated) If the merge does not produce any new information (or contradiction) then these are equal. """ print type(self.prototype...
python
def is_equal(self, other): """ The objects must be the same - Same members (if enumerated) - Or same structure (if not enumerated) If the merge does not produce any new information (or contradiction) then these are equal. """ print type(self.prototype...
[ "def", "is_equal", "(", "self", ",", "other", ")", ":", "print", "type", "(", "self", ".", "prototype", ")", ",", "type", "(", "other", ".", "prototype", ")", "if", "not", "self", ".", "prototype", ".", "is_equal", "(", "other", ".", "prototype", ")"...
The objects must be the same - Same members (if enumerated) - Or same structure (if not enumerated) If the merge does not produce any new information (or contradiction) then these are equal.
[ "The", "objects", "must", "be", "the", "same", "-", "Same", "members", "(", "if", "enumerated", ")", "-", "Or", "same", "structure", "(", "if", "not", "enumerated", ")" ]
train
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/lazy.py#L86-L105
EventTeam/beliefs
src/beliefs/cells/lazy.py
LazyCell.get_instances
def get_instances(self): """ Returns the members of the LazyDict """ if self._update_members: self.update() return iter(sorted(self.members.iteritems()))
python
def get_instances(self): """ Returns the members of the LazyDict """ if self._update_members: self.update() return iter(sorted(self.members.iteritems()))
[ "def", "get_instances", "(", "self", ")", ":", "if", "self", ".", "_update_members", ":", "self", ".", "update", "(", ")", "return", "iter", "(", "sorted", "(", "self", ".", "members", ".", "iteritems", "(", ")", ")", ")" ]
Returns the members of the LazyDict
[ "Returns", "the", "members", "of", "the", "LazyDict" ]
train
https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/lazy.py#L107-L112
chatfirst/chatfirst
chatfirst/client.py
Chatfirst.bots_list
def bots_list(self): """ List all user's bots :rtype: list of Bot :return: user's bots """ data = self.client.bots() return [Bot(item) for item in data]
python
def bots_list(self): """ List all user's bots :rtype: list of Bot :return: user's bots """ data = self.client.bots() return [Bot(item) for item in data]
[ "def", "bots_list", "(", "self", ")", ":", "data", "=", "self", ".", "client", ".", "bots", "(", ")", "return", "[", "Bot", "(", "item", ")", "for", "item", "in", "data", "]" ]
List all user's bots :rtype: list of Bot :return: user's bots
[ "List", "all", "user", "s", "bots" ]
train
https://github.com/chatfirst/chatfirst/blob/11e023fc372e034dfd3417b61b67759ef8c37ad6/chatfirst/client.py#L19-L27
chatfirst/chatfirst
chatfirst/client.py
Chatfirst.bots_create
def bots_create(self, bot): """ Save new bot :param bot: bot object to save :type bot: Bot """ self.client.bots(_method="POST", _json=bot.to_json(), _params=dict(userToken=self.token))
python
def bots_create(self, bot): """ Save new bot :param bot: bot object to save :type bot: Bot """ self.client.bots(_method="POST", _json=bot.to_json(), _params=dict(userToken=self.token))
[ "def", "bots_create", "(", "self", ",", "bot", ")", ":", "self", ".", "client", ".", "bots", "(", "_method", "=", "\"POST\"", ",", "_json", "=", "bot", ".", "to_json", "(", ")", ",", "_params", "=", "dict", "(", "userToken", "=", "self", ".", "toke...
Save new bot :param bot: bot object to save :type bot: Bot
[ "Save", "new", "bot" ]
train
https://github.com/chatfirst/chatfirst/blob/11e023fc372e034dfd3417b61b67759ef8c37ad6/chatfirst/client.py#L29-L36
chatfirst/chatfirst
chatfirst/client.py
Chatfirst.bots_get
def bots_get(self, bot): """ Fetch and fill Bot object :param bot: empty bot object with name to search :type bot: Bot :rtype: Bot :return: filled bot object """ data = self.client.bots.__getattr__(bot.name).__call__() return Bot(data)
python
def bots_get(self, bot): """ Fetch and fill Bot object :param bot: empty bot object with name to search :type bot: Bot :rtype: Bot :return: filled bot object """ data = self.client.bots.__getattr__(bot.name).__call__() return Bot(data)
[ "def", "bots_get", "(", "self", ",", "bot", ")", ":", "data", "=", "self", ".", "client", ".", "bots", ".", "__getattr__", "(", "bot", ".", "name", ")", ".", "__call__", "(", ")", "return", "Bot", "(", "data", ")" ]
Fetch and fill Bot object :param bot: empty bot object with name to search :type bot: Bot :rtype: Bot :return: filled bot object
[ "Fetch", "and", "fill", "Bot", "object" ]
train
https://github.com/chatfirst/chatfirst/blob/11e023fc372e034dfd3417b61b67759ef8c37ad6/chatfirst/client.py#L38-L48
chatfirst/chatfirst
chatfirst/client.py
Chatfirst.bots_update
def bots_update(self, bot): """ Update Bot :param bot: bot object to update :type bot: Bot """ self.client.bots.__getattr__(bot.name).__call__(_method="PUT", _json=bot.to_json(), _params=dict(botName=bot.name))
python
def bots_update(self, bot): """ Update Bot :param bot: bot object to update :type bot: Bot """ self.client.bots.__getattr__(bot.name).__call__(_method="PUT", _json=bot.to_json(), _params=dict(botName=bot.name))
[ "def", "bots_update", "(", "self", ",", "bot", ")", ":", "self", ".", "client", ".", "bots", ".", "__getattr__", "(", "bot", ".", "name", ")", ".", "__call__", "(", "_method", "=", "\"PUT\"", ",", "_json", "=", "bot", ".", "to_json", "(", ")", ",",...
Update Bot :param bot: bot object to update :type bot: Bot
[ "Update", "Bot" ]
train
https://github.com/chatfirst/chatfirst/blob/11e023fc372e034dfd3417b61b67759ef8c37ad6/chatfirst/client.py#L50-L57
chatfirst/chatfirst
chatfirst/client.py
Chatfirst.bots_delete
def bots_delete(self, bot): """ Delete existing bot :param bot: bot to delete :type bot: Bot """ self.client.bots.__getattr__(bot.name).__call__(_method="DELETE", _params=dict(botName=bot.name))
python
def bots_delete(self, bot): """ Delete existing bot :param bot: bot to delete :type bot: Bot """ self.client.bots.__getattr__(bot.name).__call__(_method="DELETE", _params=dict(botName=bot.name))
[ "def", "bots_delete", "(", "self", ",", "bot", ")", ":", "self", ".", "client", ".", "bots", ".", "__getattr__", "(", "bot", ".", "name", ")", ".", "__call__", "(", "_method", "=", "\"DELETE\"", ",", "_params", "=", "dict", "(", "botName", "=", "bot"...
Delete existing bot :param bot: bot to delete :type bot: Bot
[ "Delete", "existing", "bot" ]
train
https://github.com/chatfirst/chatfirst/blob/11e023fc372e034dfd3417b61b67759ef8c37ad6/chatfirst/client.py#L59-L66
chatfirst/chatfirst
chatfirst/client.py
Chatfirst.talk
def talk(self, bot, message): """ Talk to bot and get response based You can use this method to integrate the platform with your own channels :param bot: bot to talk to :type bot: Bot :param message: message to send to bot :type message: Message :rtype: A...
python
def talk(self, bot, message): """ Talk to bot and get response based You can use this method to integrate the platform with your own channels :param bot: bot to talk to :type bot: Bot :param message: message to send to bot :type message: Message :rtype: A...
[ "def", "talk", "(", "self", ",", "bot", ",", "message", ")", ":", "data", "=", "self", ".", "client", ".", "talk", "(", "_method", "=", "\"POST\"", ",", "_params", "=", "dict", "(", "botName", "=", "bot", ".", "name", ")", ",", "_json", "=", "mes...
Talk to bot and get response based You can use this method to integrate the platform with your own channels :param bot: bot to talk to :type bot: Bot :param message: message to send to bot :type message: Message :rtype: ActionResponse :return: response object
[ "Talk", "to", "bot", "and", "get", "response", "based", "You", "can", "use", "this", "method", "to", "integrate", "the", "platform", "with", "your", "own", "channels" ]
train
https://github.com/chatfirst/chatfirst/blob/11e023fc372e034dfd3417b61b67759ef8c37ad6/chatfirst/client.py#L88-L101
chatfirst/chatfirst
chatfirst/client.py
Chatfirst.push
def push(self, bot, channel_type, ar, user_id): """ Use this method to push message to user of bot. The message should be packed into ActionResponse object. This allows to push text messages, buttons, images. This also allows to force current state of user. :param bot: b...
python
def push(self, bot, channel_type, ar, user_id): """ Use this method to push message to user of bot. The message should be packed into ActionResponse object. This allows to push text messages, buttons, images. This also allows to force current state of user. :param bot: b...
[ "def", "push", "(", "self", ",", "bot", ",", "channel_type", ",", "ar", ",", "user_id", ")", ":", "self", ".", "client", ".", "push", ".", "__getattr__", "(", "bot", ".", "name", ")", ".", "__call__", "(", "_method", "=", "\"POST\"", ",", "_params", ...
Use this method to push message to user of bot. The message should be packed into ActionResponse object. This allows to push text messages, buttons, images. This also allows to force current state of user. :param bot: bot that will push user :type bot: Bot :param channel...
[ "Use", "this", "method", "to", "push", "message", "to", "user", "of", "bot", ".", "The", "message", "should", "be", "packed", "into", "ActionResponse", "object", ".", "This", "allows", "to", "push", "text", "messages", "buttons", "images", ".", "This", "al...
train
https://github.com/chatfirst/chatfirst/blob/11e023fc372e034dfd3417b61b67759ef8c37ad6/chatfirst/client.py#L103-L121
chatfirst/chatfirst
chatfirst/client.py
Chatfirst.broadcast
def broadcast(self, bot, channel_type, text): """ Use this method to broadcast text message to all users of bot. :param bot: bot that will push user :type bot: Bot :param channel_type: one of [telegram, facebook, slack] :type channel_type: str :param text: text m...
python
def broadcast(self, bot, channel_type, text): """ Use this method to broadcast text message to all users of bot. :param bot: bot that will push user :type bot: Bot :param channel_type: one of [telegram, facebook, slack] :type channel_type: str :param text: text m...
[ "def", "broadcast", "(", "self", ",", "bot", ",", "channel_type", ",", "text", ")", ":", "self", ".", "client", ".", "broadcast", ".", "__getattr__", "(", "bot", ".", "name", ")", ".", "__call__", "(", "_method", "=", "\"POST\"", ",", "_params", "=", ...
Use this method to broadcast text message to all users of bot. :param bot: bot that will push user :type bot: Bot :param channel_type: one of [telegram, facebook, slack] :type channel_type: str :param text: text message :type text: str
[ "Use", "this", "method", "to", "broadcast", "text", "message", "to", "all", "users", "of", "bot", "." ]
train
https://github.com/chatfirst/chatfirst/blob/11e023fc372e034dfd3417b61b67759ef8c37ad6/chatfirst/client.py#L123-L136
luiscberrocal/pyjavaprops
pyjavaprops/javaproperties.py
JavaProperties.__parse
def __parse(self, lines): """ Parse a list of lines and create an internal property dictionary """ # Every line in the file must consist of either a comment # or a key-value pair. A key-value pair is a line consisting # of a key which is a combination of non-white space characte...
python
def __parse(self, lines): """ Parse a list of lines and create an internal property dictionary """ # Every line in the file must consist of either a comment # or a key-value pair. A key-value pair is a line consisting # of a key which is a combination of non-white space characte...
[ "def", "__parse", "(", "self", ",", "lines", ")", ":", "# Every line in the file must consist of either a comment", "# or a key-value pair. A key-value pair is a line consisting", "# of a key which is a combination of non-white space characters", "# The separator character between key-value pa...
Parse a list of lines and create an internal property dictionary
[ "Parse", "a", "list", "of", "lines", "and", "create", "an", "internal", "property", "dictionary" ]
train
https://github.com/luiscberrocal/pyjavaprops/blob/7d0327b1758b3d907af657e0df3b0618776ac46d/pyjavaprops/javaproperties.py#L68-L174
luiscberrocal/pyjavaprops
pyjavaprops/javaproperties.py
JavaProperties.process_pair
def process_pair(self, key, value): """ Process a (key, value) pair """ old_key = key old_value = value # Create key intelligently keyparts = self.bspacere.split(key) # print keyparts strippable = False lastpart = keyparts[-1] if lastpart.find(...
python
def process_pair(self, key, value): """ Process a (key, value) pair """ old_key = key old_value = value # Create key intelligently keyparts = self.bspacere.split(key) # print keyparts strippable = False lastpart = keyparts[-1] if lastpart.find(...
[ "def", "process_pair", "(", "self", ",", "key", ",", "value", ")", ":", "old_key", "=", "key", "old_value", "=", "value", "# Create key intelligently", "keyparts", "=", "self", ".", "bspacere", ".", "split", "(", "key", ")", "# print keyparts", "strippable", ...
Process a (key, value) pair
[ "Process", "a", "(", "key", "value", ")", "pair" ]
train
https://github.com/luiscberrocal/pyjavaprops/blob/7d0327b1758b3d907af657e0df3b0618776ac46d/pyjavaprops/javaproperties.py#L176-L230
luiscberrocal/pyjavaprops
pyjavaprops/javaproperties.py
JavaProperties.load
def load(self, stream): """ Load properties from an open file stream """ # For the time being only accept file input streams if not _is_file(stream): raise TypeError('Argument should be a file object!') # Check for the opened mode if stream.mode != 'r': r...
python
def load(self, stream): """ Load properties from an open file stream """ # For the time being only accept file input streams if not _is_file(stream): raise TypeError('Argument should be a file object!') # Check for the opened mode if stream.mode != 'r': r...
[ "def", "load", "(", "self", ",", "stream", ")", ":", "# For the time being only accept file input streams", "if", "not", "_is_file", "(", "stream", ")", ":", "raise", "TypeError", "(", "'Argument should be a file object!'", ")", "# Check for the opened mode", "if", "str...
Load properties from an open file stream
[ "Load", "properties", "from", "an", "open", "file", "stream" ]
train
https://github.com/luiscberrocal/pyjavaprops/blob/7d0327b1758b3d907af657e0df3b0618776ac46d/pyjavaprops/javaproperties.py#L250-L264
luiscberrocal/pyjavaprops
pyjavaprops/javaproperties.py
JavaProperties.set_property
def set_property(self, key, value): """ Set the property for the given key """ if type(key) is str and type(value) is str: self.process_pair(key, value) else: raise TypeError('Both key and value should be strings!')
python
def set_property(self, key, value): """ Set the property for the given key """ if type(key) is str and type(value) is str: self.process_pair(key, value) else: raise TypeError('Both key and value should be strings!')
[ "def", "set_property", "(", "self", ",", "key", ",", "value", ")", ":", "if", "type", "(", "key", ")", "is", "str", "and", "type", "(", "value", ")", "is", "str", ":", "self", ".", "process_pair", "(", "key", ",", "value", ")", "else", ":", "rais...
Set the property for the given key
[ "Set", "the", "property", "for", "the", "given", "key" ]
train
https://github.com/luiscberrocal/pyjavaprops/blob/7d0327b1758b3d907af657e0df3b0618776ac46d/pyjavaprops/javaproperties.py#L271-L277
luiscberrocal/pyjavaprops
pyjavaprops/javaproperties.py
JavaProperties.list
def list(self, out=sys.stdout): """ Prints a listing of the properties to the stream 'out' which defaults to the standard output """ out.write('-- listing properties --\n') for key,value in self._properties.items(): out.write(''.join((key,'=',value,'\n')))
python
def list(self, out=sys.stdout): """ Prints a listing of the properties to the stream 'out' which defaults to the standard output """ out.write('-- listing properties --\n') for key,value in self._properties.items(): out.write(''.join((key,'=',value,'\n')))
[ "def", "list", "(", "self", ",", "out", "=", "sys", ".", "stdout", ")", ":", "out", ".", "write", "(", "'-- listing properties --\\n'", ")", "for", "key", ",", "value", "in", "self", ".", "_properties", ".", "items", "(", ")", ":", "out", ".", "write...
Prints a listing of the properties to the stream 'out' which defaults to the standard output
[ "Prints", "a", "listing", "of", "the", "properties", "to", "the", "stream", "out", "which", "defaults", "to", "the", "standard", "output" ]
train
https://github.com/luiscberrocal/pyjavaprops/blob/7d0327b1758b3d907af657e0df3b0618776ac46d/pyjavaprops/javaproperties.py#L285-L291
luiscberrocal/pyjavaprops
pyjavaprops/javaproperties.py
JavaProperties.store
def store(self, out, header=""): """ Write the properties list to the stream 'out' along with the optional 'header' """ if out.mode[0] != 'w': raise ValueError('Steam should be opened in write mode!') try: out.write(''.join(('#',header,'\n'))) # Writ...
python
def store(self, out, header=""): """ Write the properties list to the stream 'out' along with the optional 'header' """ if out.mode[0] != 'w': raise ValueError('Steam should be opened in write mode!') try: out.write(''.join(('#',header,'\n'))) # Writ...
[ "def", "store", "(", "self", ",", "out", ",", "header", "=", "\"\"", ")", ":", "if", "out", ".", "mode", "[", "0", "]", "!=", "'w'", ":", "raise", "ValueError", "(", "'Steam should be opened in write mode!'", ")", "try", ":", "out", ".", "write", "(", ...
Write the properties list to the stream 'out' along with the optional 'header'
[ "Write", "the", "properties", "list", "to", "the", "stream", "out", "along", "with", "the", "optional", "header" ]
train
https://github.com/luiscberrocal/pyjavaprops/blob/7d0327b1758b3d907af657e0df3b0618776ac46d/pyjavaprops/javaproperties.py#L293-L313
swans-one/django-kittens
django_kittens/models.py
KittenManager.get_random
def get_random(self): """Get a kitten, either from the db, or a new one. """ num_kittens = self.count() new_cutoff = (num_kittens / (num_kittens + constants.KITTEN_FRESHNESS)) if random.random() < new_cutoff: return self._rand_inst() else: return s...
python
def get_random(self): """Get a kitten, either from the db, or a new one. """ num_kittens = self.count() new_cutoff = (num_kittens / (num_kittens + constants.KITTEN_FRESHNESS)) if random.random() < new_cutoff: return self._rand_inst() else: return s...
[ "def", "get_random", "(", "self", ")", ":", "num_kittens", "=", "self", ".", "count", "(", ")", "new_cutoff", "=", "(", "num_kittens", "/", "(", "num_kittens", "+", "constants", ".", "KITTEN_FRESHNESS", ")", ")", "if", "random", ".", "random", "(", ")", ...
Get a kitten, either from the db, or a new one.
[ "Get", "a", "kitten", "either", "from", "the", "db", "or", "a", "new", "one", "." ]
train
https://github.com/swans-one/django-kittens/blob/31e1ff54737c8ba3e99880dbff285a730ddac851/django_kittens/models.py#L10-L18
swans-one/django-kittens
django_kittens/models.py
KittenManager.create_new
def create_new(self): """Create a new kitten by querying /r/awww. """ kitten = reddit_kitten() if self.filter(url=kitten.url).exists(): return self.get(url=kitten.url) else: kitten_obj = self.create( url=kitten.url, thumbnai...
python
def create_new(self): """Create a new kitten by querying /r/awww. """ kitten = reddit_kitten() if self.filter(url=kitten.url).exists(): return self.get(url=kitten.url) else: kitten_obj = self.create( url=kitten.url, thumbnai...
[ "def", "create_new", "(", "self", ")", ":", "kitten", "=", "reddit_kitten", "(", ")", "if", "self", ".", "filter", "(", "url", "=", "kitten", ".", "url", ")", ".", "exists", "(", ")", ":", "return", "self", ".", "get", "(", "url", "=", "kitten", ...
Create a new kitten by querying /r/awww.
[ "Create", "a", "new", "kitten", "by", "querying", "/", "r", "/", "awww", "." ]
train
https://github.com/swans-one/django-kittens/blob/31e1ff54737c8ba3e99880dbff285a730ddac851/django_kittens/models.py#L25-L37
adamkerz/django-presentation
django_presentation/forms/fields/TypedChoiceField.py
TypedChoiceField.to_python
def to_python(self,value): """ Validates that the value is in self.choices and can be coerced to the right type. """ if value==self.emptyValue or value in EMPTY_VALUES: return self.emptyValue try: value=self.coerce(value) except(ValueErro...
python
def to_python(self,value): """ Validates that the value is in self.choices and can be coerced to the right type. """ if value==self.emptyValue or value in EMPTY_VALUES: return self.emptyValue try: value=self.coerce(value) except(ValueErro...
[ "def", "to_python", "(", "self", ",", "value", ")", ":", "if", "value", "==", "self", ".", "emptyValue", "or", "value", "in", "EMPTY_VALUES", ":", "return", "self", ".", "emptyValue", "try", ":", "value", "=", "self", ".", "coerce", "(", "value", ")", ...
Validates that the value is in self.choices and can be coerced to the right type.
[ "Validates", "that", "the", "value", "is", "in", "self", ".", "choices", "and", "can", "be", "coerced", "to", "the", "right", "type", "." ]
train
https://github.com/adamkerz/django-presentation/blob/1e812faa5f682e021fa6580509d8d324cfcc119c/django_presentation/forms/fields/TypedChoiceField.py#L15-L27
zaturox/glin
glin/__main__.py
boot
def boot(): """Read configuration files, initialize glin and run main loop""" argparser = argparse.ArgumentParser( description="Controller for LED stripes (WS2801, WS2811 an similar)") argparser.add_argument("-c", "--config", metavar="CONFIGFILE", dest="configfiles", action='append', ...
python
def boot(): """Read configuration files, initialize glin and run main loop""" argparser = argparse.ArgumentParser( description="Controller for LED stripes (WS2801, WS2811 an similar)") argparser.add_argument("-c", "--config", metavar="CONFIGFILE", dest="configfiles", action='append', ...
[ "def", "boot", "(", ")", ":", "argparser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Controller for LED stripes (WS2801, WS2811 an similar)\"", ")", "argparser", ".", "add_argument", "(", "\"-c\"", ",", "\"--config\"", ",", "metavar", "=", ...
Read configuration files, initialize glin and run main loop
[ "Read", "configuration", "files", "initialize", "glin", "and", "run", "main", "loop" ]
train
https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/__main__.py#L14-L69
xtrementl/focus
focus/plugin/modules/sounds.py
PlaySound._play_sound
def _play_sound(self, filename): """ Shells player with the provided filename. `filename` Filename for sound file. """ command = self._get_external_player() if not command: return # no player found if common.IS_MACOSX: c...
python
def _play_sound(self, filename): """ Shells player with the provided filename. `filename` Filename for sound file. """ command = self._get_external_player() if not command: return # no player found if common.IS_MACOSX: c...
[ "def", "_play_sound", "(", "self", ",", "filename", ")", ":", "command", "=", "self", ".", "_get_external_player", "(", ")", "if", "not", "command", ":", "return", "# no player found", "if", "common", ".", "IS_MACOSX", ":", "command", "+=", "' \"{0}\"'", "."...
Shells player with the provided filename. `filename` Filename for sound file.
[ "Shells", "player", "with", "the", "provided", "filename", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/sounds.py#L66-L91
xtrementl/focus
focus/plugin/modules/sounds.py
PlaySound.parse_option
def parse_option(self, option, block_name, *values): """ Parse options for play, end_play, and timer_play. """ if len(values) != 1: raise TypeError value = os.path.realpath(os.path.expanduser(values[0])) if not os.path.isfile(value) and not os.path.islink(value)...
python
def parse_option(self, option, block_name, *values): """ Parse options for play, end_play, and timer_play. """ if len(values) != 1: raise TypeError value = os.path.realpath(os.path.expanduser(values[0])) if not os.path.isfile(value) and not os.path.islink(value)...
[ "def", "parse_option", "(", "self", ",", "option", ",", "block_name", ",", "*", "values", ")", ":", "if", "len", "(", "values", ")", "!=", "1", ":", "raise", "TypeError", "value", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", "."...
Parse options for play, end_play, and timer_play.
[ "Parse", "options", "for", "play", "end_play", "and", "timer_play", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/sounds.py#L93-L115
xtrementl/focus
focus/plugin/modules/sounds.py
PlaySound.on_taskend
def on_taskend(self, task): """ Play sounds at task end. """ key = 'timer' if task.elapsed else 'end' filename = self.files.get(key) if filename: self._play_sound(filename)
python
def on_taskend(self, task): """ Play sounds at task end. """ key = 'timer' if task.elapsed else 'end' filename = self.files.get(key) if filename: self._play_sound(filename)
[ "def", "on_taskend", "(", "self", ",", "task", ")", ":", "key", "=", "'timer'", "if", "task", ".", "elapsed", "else", "'end'", "filename", "=", "self", ".", "files", ".", "get", "(", "key", ")", "if", "filename", ":", "self", ".", "_play_sound", "(",...
Play sounds at task end.
[ "Play", "sounds", "at", "task", "end", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/sounds.py#L123-L130
brbsix/python-batchpath
batchpath.py
_fixpath
def _fixpath(root, base): """Return absolute, normalized, joined paths""" return os.path.abspath(os.path.normpath(os.path.join(root, base)))
python
def _fixpath(root, base): """Return absolute, normalized, joined paths""" return os.path.abspath(os.path.normpath(os.path.join(root, base)))
[ "def", "_fixpath", "(", "root", ",", "base", ")", ":", "return", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "join", "(", "root", ",", "base", ")", ")", ")" ]
Return absolute, normalized, joined paths
[ "Return", "absolute", "normalized", "joined", "paths" ]
train
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L137-L139
brbsix/python-batchpath
batchpath.py
_sorter
def _sorter(generated): """Return a list of paths sorted by dirname & basename.""" pairs = [(os.path.dirname(f), os.path.basename(f)) for f in set(list(generated))] pairs.sort() return [os.path.join(pair[0], pair[1]) for pair in pairs]
python
def _sorter(generated): """Return a list of paths sorted by dirname & basename.""" pairs = [(os.path.dirname(f), os.path.basename(f)) for f in set(list(generated))] pairs.sort() return [os.path.join(pair[0], pair[1]) for pair in pairs]
[ "def", "_sorter", "(", "generated", ")", ":", "pairs", "=", "[", "(", "os", ".", "path", ".", "dirname", "(", "f", ")", ",", "os", ".", "path", ".", "basename", "(", "f", ")", ")", "for", "f", "in", "set", "(", "list", "(", "generated", ")", ...
Return a list of paths sorted by dirname & basename.
[ "Return", "a", "list", "of", "paths", "sorted", "by", "dirname", "&", "basename", "." ]
train
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L142-L149
brbsix/python-batchpath
batchpath.py
_walk
def _walk(recursion): """Returns a recursive or non-recursive directory walker""" try: from scandir import walk as walk_function except ImportError: from os import walk as walk_function if recursion: walk = partial(walk_function) else: def walk(path): # pylint: disa...
python
def _walk(recursion): """Returns a recursive or non-recursive directory walker""" try: from scandir import walk as walk_function except ImportError: from os import walk as walk_function if recursion: walk = partial(walk_function) else: def walk(path): # pylint: disa...
[ "def", "_walk", "(", "recursion", ")", ":", "try", ":", "from", "scandir", "import", "walk", "as", "walk_function", "except", "ImportError", ":", "from", "os", "import", "walk", "as", "walk_function", "if", "recursion", ":", "walk", "=", "partial", "(", "w...
Returns a recursive or non-recursive directory walker
[ "Returns", "a", "recursive", "or", "non", "-", "recursive", "directory", "walker" ]
train
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L152-L167
brbsix/python-batchpath
batchpath.py
isvalid
def isvalid(path, access=None, extensions=None, filetype=None, minsize=None): """Check whether file meets access, extension, size, and type criteria.""" return ((access is None or os.access(path, access)) and (extensions is None or checkext(path, extensions)) and (((filetype == 'all' and...
python
def isvalid(path, access=None, extensions=None, filetype=None, minsize=None): """Check whether file meets access, extension, size, and type criteria.""" return ((access is None or os.access(path, access)) and (extensions is None or checkext(path, extensions)) and (((filetype == 'all' and...
[ "def", "isvalid", "(", "path", ",", "access", "=", "None", ",", "extensions", "=", "None", ",", "filetype", "=", "None", ",", "minsize", "=", "None", ")", ":", "return", "(", "(", "access", "is", "None", "or", "os", ".", "access", "(", "path", ",",...
Check whether file meets access, extension, size, and type criteria.
[ "Check", "whether", "file", "meets", "access", "extension", "size", "and", "type", "criteria", "." ]
train
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L175-L184
brbsix/python-batchpath
batchpath.py
GeneratePaths._generator_file
def _generator_file(self): """Generator for `self.filetype` of 'file'""" for path in self.paths: if os.path.isfile(path): if isvalid(path, self.access, self.extensions, minsize=self.minsize): yield os.path.abspath(path) ...
python
def _generator_file(self): """Generator for `self.filetype` of 'file'""" for path in self.paths: if os.path.isfile(path): if isvalid(path, self.access, self.extensions, minsize=self.minsize): yield os.path.abspath(path) ...
[ "def", "_generator_file", "(", "self", ")", ":", "for", "path", "in", "self", ".", "paths", ":", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "if", "isvalid", "(", "path", ",", "self", ".", "access", ",", "self", ".", "extensions"...
Generator for `self.filetype` of 'file
[ "Generator", "for", "self", ".", "filetype", "of", "file" ]
train
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L33-L42
brbsix/python-batchpath
batchpath.py
GeneratePaths._generator_other
def _generator_other(self): """Generator for `self.filetype` other than file""" for path in self.paths: for root, dnames, fnames in self._walker(path): yield from self._generator_rebase(dnames, root) yield from self._generator_rebase(fnames, root)
python
def _generator_other(self): """Generator for `self.filetype` other than file""" for path in self.paths: for root, dnames, fnames in self._walker(path): yield from self._generator_rebase(dnames, root) yield from self._generator_rebase(fnames, root)
[ "def", "_generator_other", "(", "self", ")", ":", "for", "path", "in", "self", ".", "paths", ":", "for", "root", ",", "dnames", ",", "fnames", "in", "self", ".", "_walker", "(", "path", ")", ":", "yield", "from", "self", ".", "_generator_rebase", "(", ...
Generator for `self.filetype` other than file
[ "Generator", "for", "self", ".", "filetype", "other", "than", "file" ]
train
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L44-L49
brbsix/python-batchpath
batchpath.py
GeneratePaths._generator_rebase
def _generator_rebase(self, names, root): """Component of _generator_other()""" return (_fixpath(root, base) for base in names if isvalid(_fixpath(root, base), self.access, self.extensions, self.filetype, self.minsize))
python
def _generator_rebase(self, names, root): """Component of _generator_other()""" return (_fixpath(root, base) for base in names if isvalid(_fixpath(root, base), self.access, self.extensions, self.filetype, self.minsize))
[ "def", "_generator_rebase", "(", "self", ",", "names", ",", "root", ")", ":", "return", "(", "_fixpath", "(", "root", ",", "base", ")", "for", "base", "in", "names", "if", "isvalid", "(", "_fixpath", "(", "root", ",", "base", ")", ",", "self", ".", ...
Component of _generator_other()
[ "Component", "of", "_generator_other", "()" ]
train
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L51-L55
brbsix/python-batchpath
batchpath.py
GeneratePaths._walker
def _walker(self, path): """Walk a directory tree (optionally recursively)""" for root, dnames, fnames in _walk(self.recursion)(path): yield (root, dnames, fnames)
python
def _walker(self, path): """Walk a directory tree (optionally recursively)""" for root, dnames, fnames in _walk(self.recursion)(path): yield (root, dnames, fnames)
[ "def", "_walker", "(", "self", ",", "path", ")", ":", "for", "root", ",", "dnames", ",", "fnames", "in", "_walk", "(", "self", ".", "recursion", ")", "(", "path", ")", ":", "yield", "(", "root", ",", "dnames", ",", "fnames", ")" ]
Walk a directory tree (optionally recursively)
[ "Walk", "a", "directory", "tree", "(", "optionally", "recursively", ")" ]
train
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L57-L60
brbsix/python-batchpath
batchpath.py
GeneratePaths.all
def all(self, paths, access=None, recursion=False): """ Iterates over `paths` (which may consist of files and/or directories). Removes duplicates and returns list of valid paths meeting access criteria. """ self.__init__() self.access = access self.filetyp...
python
def all(self, paths, access=None, recursion=False): """ Iterates over `paths` (which may consist of files and/or directories). Removes duplicates and returns list of valid paths meeting access criteria. """ self.__init__() self.access = access self.filetyp...
[ "def", "all", "(", "self", ",", "paths", ",", "access", "=", "None", ",", "recursion", "=", "False", ")", ":", "self", ".", "__init__", "(", ")", "self", ".", "access", "=", "access", "self", ".", "filetype", "=", "'all'", "self", ".", "paths", "="...
Iterates over `paths` (which may consist of files and/or directories). Removes duplicates and returns list of valid paths meeting access criteria.
[ "Iterates", "over", "paths", "(", "which", "may", "consist", "of", "files", "and", "/", "or", "directories", ")", ".", "Removes", "duplicates", "and", "returns", "list", "of", "valid", "paths", "meeting", "access", "criteria", "." ]
train
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L62-L74
brbsix/python-batchpath
batchpath.py
GeneratePaths.files
def files(self, paths, access=None, extensions=None, minsize=None, recursion=False): """ Iterates over `paths` (which may consist of files and/or directories). Removes duplicates and returns list of valid files meeting access, extension, and minimum size criteria. "...
python
def files(self, paths, access=None, extensions=None, minsize=None, recursion=False): """ Iterates over `paths` (which may consist of files and/or directories). Removes duplicates and returns list of valid files meeting access, extension, and minimum size criteria. "...
[ "def", "files", "(", "self", ",", "paths", ",", "access", "=", "None", ",", "extensions", "=", "None", ",", "minsize", "=", "None", ",", "recursion", "=", "False", ")", ":", "self", ".", "__init__", "(", ")", "self", ".", "access", "=", "access", "...
Iterates over `paths` (which may consist of files and/or directories). Removes duplicates and returns list of valid files meeting access, extension, and minimum size criteria.
[ "Iterates", "over", "paths", "(", "which", "may", "consist", "of", "files", "and", "/", "or", "directories", ")", ".", "Removes", "duplicates", "and", "returns", "list", "of", "valid", "files", "meeting", "access", "extension", "and", "minimum", "size", "cri...
train
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L90-L105
brbsix/python-batchpath
batchpath.py
VerifyPaths.all
def all(self, paths, access=None): """Verify list of paths""" self.failures = [path for path in paths if not isvalid(path, access, filetype='all')] return not self.failures
python
def all(self, paths, access=None): """Verify list of paths""" self.failures = [path for path in paths if not isvalid(path, access, filetype='all')] return not self.failures
[ "def", "all", "(", "self", ",", "paths", ",", "access", "=", "None", ")", ":", "self", ".", "failures", "=", "[", "path", "for", "path", "in", "paths", "if", "not", "isvalid", "(", "path", ",", "access", ",", "filetype", "=", "'all'", ")", "]", "...
Verify list of paths
[ "Verify", "list", "of", "paths" ]
train
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L115-L120
brbsix/python-batchpath
batchpath.py
VerifyPaths.dirs
def dirs(self, paths, access=None): """Verify list of directories""" self.failures = [path for path in paths if not isvalid(path, access, filetype='dir')] return not self.failures
python
def dirs(self, paths, access=None): """Verify list of directories""" self.failures = [path for path in paths if not isvalid(path, access, filetype='dir')] return not self.failures
[ "def", "dirs", "(", "self", ",", "paths", ",", "access", "=", "None", ")", ":", "self", ".", "failures", "=", "[", "path", "for", "path", "in", "paths", "if", "not", "isvalid", "(", "path", ",", "access", ",", "filetype", "=", "'dir'", ")", "]", ...
Verify list of directories
[ "Verify", "list", "of", "directories" ]
train
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L122-L127
brbsix/python-batchpath
batchpath.py
VerifyPaths.files
def files(self, paths, access=None, extensions=None, minsize=None): """Verify list of files""" self.failures = [path for path in paths if not isvalid(path, access, extensions, 'file', minsize)] return not self.failures
python
def files(self, paths, access=None, extensions=None, minsize=None): """Verify list of files""" self.failures = [path for path in paths if not isvalid(path, access, extensions, 'file', minsize)] return not self.failures
[ "def", "files", "(", "self", ",", "paths", ",", "access", "=", "None", ",", "extensions", "=", "None", ",", "minsize", "=", "None", ")", ":", "self", ".", "failures", "=", "[", "path", "for", "path", "in", "paths", "if", "not", "isvalid", "(", "pat...
Verify list of files
[ "Verify", "list", "of", "files" ]
train
https://github.com/brbsix/python-batchpath/blob/e4426c7946189aa41f0c99d37bf843799fb00c33/batchpath.py#L129-L134
ardydedase/pycouchbase
pycouchbase/schema.py
SchemaDocument.validate
def validate(self): """Validates the document object with current values, always called within :meth:`couchbasekit.document.Document.save` method. :returns: Always True, or raises :exc:`couchbasekit.errors.StructureError` exception. :raises: :exc:`couchbasekit.errors.Structu...
python
def validate(self): """Validates the document object with current values, always called within :meth:`couchbasekit.document.Document.save` method. :returns: Always True, or raises :exc:`couchbasekit.errors.StructureError` exception. :raises: :exc:`couchbasekit.errors.Structu...
[ "def", "validate", "(", "self", ")", ":", "# __key_field__ value must be provided if defined", "if", "self", ".", "__key_field__", "and", "self", ".", "__key_field__", "not", "in", "self", ":", "raise", "self", ".", "StructureError", "(", "msg", "=", "\"Key field ...
Validates the document object with current values, always called within :meth:`couchbasekit.document.Document.save` method. :returns: Always True, or raises :exc:`couchbasekit.errors.StructureError` exception. :raises: :exc:`couchbasekit.errors.StructureError` if any val...
[ "Validates", "the", "document", "object", "with", "current", "values", "always", "called", "within", ":", "meth", ":", "couchbasekit", ".", "document", ".", "Document", ".", "save", "method", "." ]
train
https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/pycouchbase/schema.py#L273-L294
dr4ke616/pinky
pinky/core/manhole.py
get_manhole_factory
def get_manhole_factory(namespace, **passwords): """Get a Manhole Factory """ realm = manhole_ssh.TerminalRealm() realm.chainedProtocolFactory.protocolFactory = ( lambda _: EnhancedColoredManhole(namespace) ) p = portal.Portal(realm) p.registerChecker( checkers.InMemoryUser...
python
def get_manhole_factory(namespace, **passwords): """Get a Manhole Factory """ realm = manhole_ssh.TerminalRealm() realm.chainedProtocolFactory.protocolFactory = ( lambda _: EnhancedColoredManhole(namespace) ) p = portal.Portal(realm) p.registerChecker( checkers.InMemoryUser...
[ "def", "get_manhole_factory", "(", "namespace", ",", "*", "*", "passwords", ")", ":", "realm", "=", "manhole_ssh", ".", "TerminalRealm", "(", ")", "realm", ".", "chainedProtocolFactory", ".", "protocolFactory", "=", "(", "lambda", "_", ":", "EnhancedColoredManho...
Get a Manhole Factory
[ "Get", "a", "Manhole", "Factory" ]
train
https://github.com/dr4ke616/pinky/blob/35c165f5a1d410be467621f3152df1dbf458622a/pinky/core/manhole.py#L86-L99
dr4ke616/pinky
pinky/core/manhole.py
EnhancedColoredManhole.find_common
def find_common(self, l): """ Find common parts in thelist items ex: 'ab' for ['abcd','abce','abf'] requires an ordered list """ if len(l) == 1: return l[0] init = l[0] for item in l[1:]: for i, (x, y) in enumerate(zip(init, item)): ...
python
def find_common(self, l): """ Find common parts in thelist items ex: 'ab' for ['abcd','abce','abf'] requires an ordered list """ if len(l) == 1: return l[0] init = l[0] for item in l[1:]: for i, (x, y) in enumerate(zip(init, item)): ...
[ "def", "find_common", "(", "self", ",", "l", ")", ":", "if", "len", "(", "l", ")", "==", "1", ":", "return", "l", "[", "0", "]", "init", "=", "l", "[", "0", "]", "for", "item", "in", "l", "[", "1", ":", "]", ":", "for", "i", ",", "(", "...
Find common parts in thelist items ex: 'ab' for ['abcd','abce','abf'] requires an ordered list
[ "Find", "common", "parts", "in", "thelist", "items", "ex", ":", "ab", "for", "[", "abcd", "abce", "abf", "]", "requires", "an", "ordered", "list" ]
train
https://github.com/dr4ke616/pinky/blob/35c165f5a1d410be467621f3152df1dbf458622a/pinky/core/manhole.py#L25-L42
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/mapping.py
ClusterService.find_cluster
def find_cluster(cid=None, name=None): """ find the cluster according to provided ID or name :param cid: id of cluster to find :param name: name of cluster to find :return: the cluster if found else None """ LOGGER.debug("ClusterService.find_cluster") ret ...
python
def find_cluster(cid=None, name=None): """ find the cluster according to provided ID or name :param cid: id of cluster to find :param name: name of cluster to find :return: the cluster if found else None """ LOGGER.debug("ClusterService.find_cluster") ret ...
[ "def", "find_cluster", "(", "cid", "=", "None", ",", "name", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "\"ClusterService.find_cluster\"", ")", "ret", "=", "None", "if", "(", "cid", "is", "None", "or", "not", "cid", ")", "and", "(", "name", ...
find the cluster according to provided ID or name :param cid: id of cluster to find :param name: name of cluster to find :return: the cluster if found else None
[ "find", "the", "cluster", "according", "to", "provided", "ID", "or", "name", ":", "param", "cid", ":", "id", "of", "cluster", "to", "find", ":", "param", "name", ":", "name", "of", "cluster", "to", "find", ":", "return", ":", "the", "cluster", "if", ...
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/mapping.py#L286-L333
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/mapping.py
ClusterService.get_clusters
def get_clusters(): """ get all available cluster from Ariane server :return: """ LOGGER.debug("ClusterService.get_clusters") params = SessionService.complete_transactional_req(None) if MappingService.driver_type != DriverFactory.DRIVER_REST: if params...
python
def get_clusters(): """ get all available cluster from Ariane server :return: """ LOGGER.debug("ClusterService.get_clusters") params = SessionService.complete_transactional_req(None) if MappingService.driver_type != DriverFactory.DRIVER_REST: if params...
[ "def", "get_clusters", "(", ")", ":", "LOGGER", ".", "debug", "(", "\"ClusterService.get_clusters\"", ")", "params", "=", "SessionService", ".", "complete_transactional_req", "(", "None", ")", "if", "MappingService", ".", "driver_type", "!=", "DriverFactory", ".", ...
get all available cluster from Ariane server :return:
[ "get", "all", "available", "cluster", "from", "Ariane", "server", ":", "return", ":" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/mapping.py#L336-L372
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/mapping.py
Cluster.json_2_cluster
def json_2_cluster(json_obj): """ transform json from Ariane server to local object :param json_obj: json from Ariane Server :return: transformed cluster """ LOGGER.debug("Cluster.json_2_cluster") return Cluster( cid=json_obj['clusterID'], ...
python
def json_2_cluster(json_obj): """ transform json from Ariane server to local object :param json_obj: json from Ariane Server :return: transformed cluster """ LOGGER.debug("Cluster.json_2_cluster") return Cluster( cid=json_obj['clusterID'], ...
[ "def", "json_2_cluster", "(", "json_obj", ")", ":", "LOGGER", ".", "debug", "(", "\"Cluster.json_2_cluster\"", ")", "return", "Cluster", "(", "cid", "=", "json_obj", "[", "'clusterID'", "]", ",", "name", "=", "json_obj", "[", "'clusterName'", "]", ",", "cont...
transform json from Ariane server to local object :param json_obj: json from Ariane Server :return: transformed cluster
[ "transform", "json", "from", "Ariane", "server", "to", "local", "object", ":", "param", "json_obj", ":", "json", "from", "Ariane", "Server", ":", "return", ":", "transformed", "cluster" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/mapping.py#L378-L390
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/mapping.py
Cluster.cluster_2_json
def cluster_2_json(self): """ transform this local object ot Ariane server JSON object :return: the JSON object """ LOGGER.debug("Cluster.cluster_2_json") json_obj = { 'clusterID': self.id, 'clusterName': self.name, 'clusterContainersID...
python
def cluster_2_json(self): """ transform this local object ot Ariane server JSON object :return: the JSON object """ LOGGER.debug("Cluster.cluster_2_json") json_obj = { 'clusterID': self.id, 'clusterName': self.name, 'clusterContainersID...
[ "def", "cluster_2_json", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"Cluster.cluster_2_json\"", ")", "json_obj", "=", "{", "'clusterID'", ":", "self", ".", "id", ",", "'clusterName'", ":", "self", ".", "name", ",", "'clusterContainersID'", ":", "s...
transform this local object ot Ariane server JSON object :return: the JSON object
[ "transform", "this", "local", "object", "ot", "Ariane", "server", "JSON", "object", ":", "return", ":", "the", "JSON", "object" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/mapping.py#L392-L403
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/mapping.py
Cluster.add_container
def add_container(self, container, sync=True): """ add container to this cluster. if this cluster has no id then it's like sync=False. :param container: container to add to this cluster :param sync: If sync=True(default) synchronize with Ariane server. If sync=False, add the cont...
python
def add_container(self, container, sync=True): """ add container to this cluster. if this cluster has no id then it's like sync=False. :param container: container to add to this cluster :param sync: If sync=True(default) synchronize with Ariane server. If sync=False, add the cont...
[ "def", "add_container", "(", "self", ",", "container", ",", "sync", "=", "True", ")", ":", "LOGGER", ".", "debug", "(", "\"Cluster.add_container\"", ")", "if", "not", "sync", "or", "self", ".", "id", "is", "None", ":", "self", ".", "containers_2_add", "....
add container to this cluster. if this cluster has no id then it's like sync=False. :param container: container to add to this cluster :param sync: If sync=True(default) synchronize with Ariane server. If sync=False, add the container object on list to be added on next save(). :return:
[ "add", "container", "to", "this", "cluster", ".", "if", "this", "cluster", "has", "no", "id", "then", "it", "s", "like", "sync", "=", "False", ".", ":", "param", "container", ":", "container", "to", "add", "to", "this", "cluster", ":", "param", "sync",...
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/mapping.py#L449-L495
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/mapping.py
Cluster.save
def save(self): """ save or update this cluster in Ariane Server :return: """ LOGGER.debug("Cluster.save") post_payload = {} consolidated_containers_id = [] if self.id is not None: post_payload['clusterID'] = self.id if self.name is n...
python
def save(self): """ save or update this cluster in Ariane Server :return: """ LOGGER.debug("Cluster.save") post_payload = {} consolidated_containers_id = [] if self.id is not None: post_payload['clusterID'] = self.id if self.name is n...
[ "def", "save", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"Cluster.save\"", ")", "post_payload", "=", "{", "}", "consolidated_containers_id", "=", "[", "]", "if", "self", ".", "id", "is", "not", "None", ":", "post_payload", "[", "'clusterID'", ...
save or update this cluster in Ariane Server :return:
[ "save", "or", "update", "this", "cluster", "in", "Ariane", "Server", ":", "return", ":" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/mapping.py#L587-L649
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/mapping.py
Cluster.remove
def remove(self): """ remove this object from Ariane server :return: null if successfully removed else self """ LOGGER.debug("Cluster.remove - " + self.name) if self.id is None: return None else: params = SessionService.complete_transaction...
python
def remove(self): """ remove this object from Ariane server :return: null if successfully removed else self """ LOGGER.debug("Cluster.remove - " + self.name) if self.id is None: return None else: params = SessionService.complete_transaction...
[ "def", "remove", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"Cluster.remove - \"", "+", "self", ".", "name", ")", "if", "self", ".", "id", "is", "None", ":", "return", "None", "else", ":", "params", "=", "SessionService", ".", "complete_transa...
remove this object from Ariane server :return: null if successfully removed else self
[ "remove", "this", "object", "from", "Ariane", "server", ":", "return", ":", "null", "if", "successfully", "removed", "else", "self" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/mapping.py#L651-L686
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/mapping.py
ContainerService.find_container
def find_container(cid=None, primary_admin_gate_url=None): """ find container according ID or primary admin gate url. If both are defined this will return container according container ID. :param cid: container ID :param primary_admin_gate_url: container primary admin gate url ...
python
def find_container(cid=None, primary_admin_gate_url=None): """ find container according ID or primary admin gate url. If both are defined this will return container according container ID. :param cid: container ID :param primary_admin_gate_url: container primary admin gate url ...
[ "def", "find_container", "(", "cid", "=", "None", ",", "primary_admin_gate_url", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "\"ContainerService.find_container\"", ")", "ret", "=", "None", "if", "(", "cid", "is", "None", "or", "not", "cid", ")", "a...
find container according ID or primary admin gate url. If both are defined this will return container according container ID. :param cid: container ID :param primary_admin_gate_url: container primary admin gate url :return:
[ "find", "container", "according", "ID", "or", "primary", "admin", "gate", "url", ".", "If", "both", "are", "defined", "this", "will", "return", "container", "according", "container", "ID", ".", ":", "param", "cid", ":", "container", "ID", ":", "param", "pr...
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/mapping.py#L708-L761
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/mapping.py
ContainerService.get_containers
def get_containers(): """ get all known containers from Ariane Server :return: """ LOGGER.debug("ContainerService.get_containers") params = SessionService.complete_transactional_req(None) if params is None: if MappingService.driver_type != DriverFactor...
python
def get_containers(): """ get all known containers from Ariane Server :return: """ LOGGER.debug("ContainerService.get_containers") params = SessionService.complete_transactional_req(None) if params is None: if MappingService.driver_type != DriverFactor...
[ "def", "get_containers", "(", ")", ":", "LOGGER", ".", "debug", "(", "\"ContainerService.get_containers\"", ")", "params", "=", "SessionService", ".", "complete_transactional_req", "(", "None", ")", "if", "params", "is", "None", ":", "if", "MappingService", ".", ...
get all known containers from Ariane Server :return:
[ "get", "all", "known", "containers", "from", "Ariane", "Server", ":", "return", ":" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/mapping.py#L764-L803
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/mapping.py
Container.json_2_container
def json_2_container(json_obj): """ transform json from Ariane server to local object :param json_obj: json from Ariane Server :return: transformed container """ LOGGER.debug("Container.json_2_container") if MappingService.driver_type != DriverFactory.DRIVER_REST:...
python
def json_2_container(json_obj): """ transform json from Ariane server to local object :param json_obj: json from Ariane Server :return: transformed container """ LOGGER.debug("Container.json_2_container") if MappingService.driver_type != DriverFactory.DRIVER_REST:...
[ "def", "json_2_container", "(", "json_obj", ")", ":", "LOGGER", ".", "debug", "(", "\"Container.json_2_container\"", ")", "if", "MappingService", ".", "driver_type", "!=", "DriverFactory", ".", "DRIVER_REST", ":", "if", "'containerProperties'", "in", "json_obj", ":"...
transform json from Ariane server to local object :param json_obj: json from Ariane Server :return: transformed container
[ "transform", "json", "from", "Ariane", "server", "to", "local", "object", ":", "param", "json_obj", ":", "json", "from", "Ariane", "Server", ":", "return", ":", "transformed", "container" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/mapping.py#L839-L870
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/mapping.py
Container.container_2_json
def container_2_json(self): """ transform this local object ot Ariane server JSON object :return: the JSON object """ LOGGER.debug("Container.container_2_json") json_obj = { 'containerID': self.id, 'containerName': self.name, 'container...
python
def container_2_json(self): """ transform this local object ot Ariane server JSON object :return: the JSON object """ LOGGER.debug("Container.container_2_json") json_obj = { 'containerID': self.id, 'containerName': self.name, 'container...
[ "def", "container_2_json", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"Container.container_2_json\"", ")", "json_obj", "=", "{", "'containerID'", ":", "self", ".", "id", ",", "'containerName'", ":", "self", ".", "name", ",", "'containerGateURI'", ":...
transform this local object ot Ariane server JSON object :return: the JSON object
[ "transform", "this", "local", "object", "ot", "Ariane", "server", "JSON", "object", ":", "return", ":", "the", "JSON", "object" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/mapping.py#L872-L893
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/mapping.py
Container.sync
def sync(self, json_obj=None): """ synchronize self from Ariane server according its id :return: """ LOGGER.debug("Container.sync") if json_obj is None: params = None if self.id is not None: params = SessionService.complete_transact...
python
def sync(self, json_obj=None): """ synchronize self from Ariane server according its id :return: """ LOGGER.debug("Container.sync") if json_obj is None: params = None if self.id is not None: params = SessionService.complete_transact...
[ "def", "sync", "(", "self", ",", "json_obj", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "\"Container.sync\"", ")", "if", "json_obj", "is", "None", ":", "params", "=", "None", "if", "self", ".", "id", "is", "not", "None", ":", "params", "=", ...
synchronize self from Ariane server according its id :return:
[ "synchronize", "self", "from", "Ariane", "server", "according", "its", "id", ":", "return", ":" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/mapping.py#L895-L954