repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
newville/asteval | asteval/asteval.py | Interpreter.on_excepthandler | def on_excepthandler(self, node): # ('type', 'name', 'body')
"""Exception handler..."""
return (self.run(node.type), node.name, node.body) | python | def on_excepthandler(self, node): # ('type', 'name', 'body')
"""Exception handler..."""
return (self.run(node.type), node.name, node.body) | [
"def",
"on_excepthandler",
"(",
"self",
",",
"node",
")",
":",
"# ('type', 'name', 'body')",
"return",
"(",
"self",
".",
"run",
"(",
"node",
".",
"type",
")",
",",
"node",
".",
"name",
",",
"node",
".",
"body",
")"
] | Exception handler... | [
"Exception",
"handler",
"..."
] | bb7d3a95079f96ead75ea55662014bbcc82f9b28 | https://github.com/newville/asteval/blob/bb7d3a95079f96ead75ea55662014bbcc82f9b28/asteval/asteval.py#L697-L699 | train |
newville/asteval | asteval/asteval.py | Interpreter.on_call | def on_call(self, node):
"""Function execution."""
# ('func', 'args', 'keywords'. Py<3.5 has 'starargs' and 'kwargs' too)
func = self.run(node.func)
if not hasattr(func, '__call__') and not isinstance(func, type):
msg = "'%s' is not callable!!" % (func)
self.rais... | python | def on_call(self, node):
"""Function execution."""
# ('func', 'args', 'keywords'. Py<3.5 has 'starargs' and 'kwargs' too)
func = self.run(node.func)
if not hasattr(func, '__call__') and not isinstance(func, type):
msg = "'%s' is not callable!!" % (func)
self.rais... | [
"def",
"on_call",
"(",
"self",
",",
"node",
")",
":",
"# ('func', 'args', 'keywords'. Py<3.5 has 'starargs' and 'kwargs' too)",
"func",
"=",
"self",
".",
"run",
"(",
"node",
".",
"func",
")",
"if",
"not",
"hasattr",
"(",
"func",
",",
"'__call__'",
")",
"and",
... | Function execution. | [
"Function",
"execution",
"."
] | bb7d3a95079f96ead75ea55662014bbcc82f9b28 | https://github.com/newville/asteval/blob/bb7d3a95079f96ead75ea55662014bbcc82f9b28/asteval/asteval.py#L744-L776 | train |
newville/asteval | asteval/asteval.py | Interpreter.on_functiondef | def on_functiondef(self, node):
"""Define procedures."""
# ('name', 'args', 'body', 'decorator_list')
if node.decorator_list:
raise Warning("decorated procedures not supported!")
kwargs = []
if not valid_symbol_name(node.name) or node.name in self.readonly_symbols:
... | python | def on_functiondef(self, node):
"""Define procedures."""
# ('name', 'args', 'body', 'decorator_list')
if node.decorator_list:
raise Warning("decorated procedures not supported!")
kwargs = []
if not valid_symbol_name(node.name) or node.name in self.readonly_symbols:
... | [
"def",
"on_functiondef",
"(",
"self",
",",
"node",
")",
":",
"# ('name', 'args', 'body', 'decorator_list')",
"if",
"node",
".",
"decorator_list",
":",
"raise",
"Warning",
"(",
"\"decorated procedures not supported!\"",
")",
"kwargs",
"=",
"[",
"]",
"if",
"not",
"val... | Define procedures. | [
"Define",
"procedures",
"."
] | bb7d3a95079f96ead75ea55662014bbcc82f9b28 | https://github.com/newville/asteval/blob/bb7d3a95079f96ead75ea55662014bbcc82f9b28/asteval/asteval.py#L782-L823 | train |
newville/asteval | asteval/astutils.py | safe_pow | def safe_pow(base, exp):
"""safe version of pow"""
if exp > MAX_EXPONENT:
raise RuntimeError("Invalid exponent, max exponent is {}".format(MAX_EXPONENT))
return base ** exp | python | def safe_pow(base, exp):
"""safe version of pow"""
if exp > MAX_EXPONENT:
raise RuntimeError("Invalid exponent, max exponent is {}".format(MAX_EXPONENT))
return base ** exp | [
"def",
"safe_pow",
"(",
"base",
",",
"exp",
")",
":",
"if",
"exp",
">",
"MAX_EXPONENT",
":",
"raise",
"RuntimeError",
"(",
"\"Invalid exponent, max exponent is {}\"",
".",
"format",
"(",
"MAX_EXPONENT",
")",
")",
"return",
"base",
"**",
"exp"
] | safe version of pow | [
"safe",
"version",
"of",
"pow"
] | bb7d3a95079f96ead75ea55662014bbcc82f9b28 | https://github.com/newville/asteval/blob/bb7d3a95079f96ead75ea55662014bbcc82f9b28/asteval/astutils.py#L183-L187 | train |
newville/asteval | asteval/astutils.py | safe_mult | def safe_mult(a, b):
"""safe version of multiply"""
if isinstance(a, str) and isinstance(b, int) and len(a) * b > MAX_STR_LEN:
raise RuntimeError("String length exceeded, max string length is {}".format(MAX_STR_LEN))
return a * b | python | def safe_mult(a, b):
"""safe version of multiply"""
if isinstance(a, str) and isinstance(b, int) and len(a) * b > MAX_STR_LEN:
raise RuntimeError("String length exceeded, max string length is {}".format(MAX_STR_LEN))
return a * b | [
"def",
"safe_mult",
"(",
"a",
",",
"b",
")",
":",
"if",
"isinstance",
"(",
"a",
",",
"str",
")",
"and",
"isinstance",
"(",
"b",
",",
"int",
")",
"and",
"len",
"(",
"a",
")",
"*",
"b",
">",
"MAX_STR_LEN",
":",
"raise",
"RuntimeError",
"(",
"\"Stri... | safe version of multiply | [
"safe",
"version",
"of",
"multiply"
] | bb7d3a95079f96ead75ea55662014bbcc82f9b28 | https://github.com/newville/asteval/blob/bb7d3a95079f96ead75ea55662014bbcc82f9b28/asteval/astutils.py#L190-L194 | train |
newville/asteval | asteval/astutils.py | safe_add | def safe_add(a, b):
"""safe version of add"""
if isinstance(a, str) and isinstance(b, str) and len(a) + len(b) > MAX_STR_LEN:
raise RuntimeError("String length exceeded, max string length is {}".format(MAX_STR_LEN))
return a + b | python | def safe_add(a, b):
"""safe version of add"""
if isinstance(a, str) and isinstance(b, str) and len(a) + len(b) > MAX_STR_LEN:
raise RuntimeError("String length exceeded, max string length is {}".format(MAX_STR_LEN))
return a + b | [
"def",
"safe_add",
"(",
"a",
",",
"b",
")",
":",
"if",
"isinstance",
"(",
"a",
",",
"str",
")",
"and",
"isinstance",
"(",
"b",
",",
"str",
")",
"and",
"len",
"(",
"a",
")",
"+",
"len",
"(",
"b",
")",
">",
"MAX_STR_LEN",
":",
"raise",
"RuntimeEr... | safe version of add | [
"safe",
"version",
"of",
"add"
] | bb7d3a95079f96ead75ea55662014bbcc82f9b28 | https://github.com/newville/asteval/blob/bb7d3a95079f96ead75ea55662014bbcc82f9b28/asteval/astutils.py#L197-L201 | train |
newville/asteval | asteval/astutils.py | safe_lshift | def safe_lshift(a, b):
"""safe version of lshift"""
if b > MAX_SHIFT:
raise RuntimeError("Invalid left shift, max left shift is {}".format(MAX_SHIFT))
return a << b | python | def safe_lshift(a, b):
"""safe version of lshift"""
if b > MAX_SHIFT:
raise RuntimeError("Invalid left shift, max left shift is {}".format(MAX_SHIFT))
return a << b | [
"def",
"safe_lshift",
"(",
"a",
",",
"b",
")",
":",
"if",
"b",
">",
"MAX_SHIFT",
":",
"raise",
"RuntimeError",
"(",
"\"Invalid left shift, max left shift is {}\"",
".",
"format",
"(",
"MAX_SHIFT",
")",
")",
"return",
"a",
"<<",
"b"
] | safe version of lshift | [
"safe",
"version",
"of",
"lshift"
] | bb7d3a95079f96ead75ea55662014bbcc82f9b28 | https://github.com/newville/asteval/blob/bb7d3a95079f96ead75ea55662014bbcc82f9b28/asteval/astutils.py#L204-L208 | train |
newville/asteval | asteval/astutils.py | valid_symbol_name | def valid_symbol_name(name):
"""Determine whether the input symbol name is a valid name.
Arguments
---------
name : str
name to check for validity.
Returns
--------
valid : bool
whether name is a a valid symbol name
This checks for Python reserved words and that... | python | def valid_symbol_name(name):
"""Determine whether the input symbol name is a valid name.
Arguments
---------
name : str
name to check for validity.
Returns
--------
valid : bool
whether name is a a valid symbol name
This checks for Python reserved words and that... | [
"def",
"valid_symbol_name",
"(",
"name",
")",
":",
"if",
"name",
"in",
"RESERVED_WORDS",
":",
"return",
"False",
"gen",
"=",
"generate_tokens",
"(",
"io",
".",
"BytesIO",
"(",
"name",
".",
"encode",
"(",
"'utf-8'",
")",
")",
".",
"readline",
")",
"typ",
... | Determine whether the input symbol name is a valid name.
Arguments
---------
name : str
name to check for validity.
Returns
--------
valid : bool
whether name is a a valid symbol name
This checks for Python reserved words and that the name matches
the regular ex... | [
"Determine",
"whether",
"the",
"input",
"symbol",
"name",
"is",
"a",
"valid",
"name",
"."
] | bb7d3a95079f96ead75ea55662014bbcc82f9b28 | https://github.com/newville/asteval/blob/bb7d3a95079f96ead75ea55662014bbcc82f9b28/asteval/astutils.py#L241-L264 | train |
newville/asteval | asteval/astutils.py | make_symbol_table | def make_symbol_table(use_numpy=True, **kws):
"""Create a default symboltable, taking dict of user-defined symbols.
Arguments
---------
numpy : bool, optional
whether to include symbols from numpy
kws : optional
additional symbol name, value pairs to include in symbol table
Retu... | python | def make_symbol_table(use_numpy=True, **kws):
"""Create a default symboltable, taking dict of user-defined symbols.
Arguments
---------
numpy : bool, optional
whether to include symbols from numpy
kws : optional
additional symbol name, value pairs to include in symbol table
Retu... | [
"def",
"make_symbol_table",
"(",
"use_numpy",
"=",
"True",
",",
"*",
"*",
"kws",
")",
":",
"symtable",
"=",
"{",
"}",
"for",
"sym",
"in",
"FROM_PY",
":",
"if",
"sym",
"in",
"builtins",
":",
"symtable",
"[",
"sym",
"]",
"=",
"builtins",
"[",
"sym",
... | Create a default symboltable, taking dict of user-defined symbols.
Arguments
---------
numpy : bool, optional
whether to include symbols from numpy
kws : optional
additional symbol name, value pairs to include in symbol table
Returns
--------
symbol_table : dict
a sym... | [
"Create",
"a",
"default",
"symboltable",
"taking",
"dict",
"of",
"user",
"-",
"defined",
"symbols",
"."
] | bb7d3a95079f96ead75ea55662014bbcc82f9b28 | https://github.com/newville/asteval/blob/bb7d3a95079f96ead75ea55662014bbcc82f9b28/asteval/astutils.py#L351-L389 | train |
newville/asteval | asteval/astutils.py | ExceptionHolder.get_error | def get_error(self):
"""Retrieve error data."""
col_offset = -1
if self.node is not None:
try:
col_offset = self.node.col_offset
except AttributeError:
pass
try:
exc_name = self.exc.__name__
except AttributeError... | python | def get_error(self):
"""Retrieve error data."""
col_offset = -1
if self.node is not None:
try:
col_offset = self.node.col_offset
except AttributeError:
pass
try:
exc_name = self.exc.__name__
except AttributeError... | [
"def",
"get_error",
"(",
"self",
")",
":",
"col_offset",
"=",
"-",
"1",
"if",
"self",
".",
"node",
"is",
"not",
"None",
":",
"try",
":",
"col_offset",
"=",
"self",
".",
"node",
".",
"col_offset",
"except",
"AttributeError",
":",
"pass",
"try",
":",
"... | Retrieve error data. | [
"Retrieve",
"error",
"data",
"."
] | bb7d3a95079f96ead75ea55662014bbcc82f9b28 | https://github.com/newville/asteval/blob/bb7d3a95079f96ead75ea55662014bbcc82f9b28/asteval/astutils.py#L303-L322 | train |
admiralobvious/vyper | vyper/vyper.py | Vyper.add_config_path | def add_config_path(self, path):
"""Add a path for Vyper to search for the config file in.
Can be called multiple times to define multiple search paths.
"""
abspath = util.abs_pathify(path)
if abspath not in self._config_paths:
log.info("Adding {0} to paths to search"... | python | def add_config_path(self, path):
"""Add a path for Vyper to search for the config file in.
Can be called multiple times to define multiple search paths.
"""
abspath = util.abs_pathify(path)
if abspath not in self._config_paths:
log.info("Adding {0} to paths to search"... | [
"def",
"add_config_path",
"(",
"self",
",",
"path",
")",
":",
"abspath",
"=",
"util",
".",
"abs_pathify",
"(",
"path",
")",
"if",
"abspath",
"not",
"in",
"self",
".",
"_config_paths",
":",
"log",
".",
"info",
"(",
"\"Adding {0} to paths to search\"",
".",
... | Add a path for Vyper to search for the config file in.
Can be called multiple times to define multiple search paths. | [
"Add",
"a",
"path",
"for",
"Vyper",
"to",
"search",
"for",
"the",
"config",
"file",
"in",
".",
"Can",
"be",
"called",
"multiple",
"times",
"to",
"define",
"multiple",
"search",
"paths",
"."
] | 58ec7b90661502b7b2fea7a30849b90b907fcdec | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L122-L129 | train |
admiralobvious/vyper | vyper/vyper.py | Vyper.sub | def sub(self, key):
"""Returns new Vyper instance representing a sub tree of this instance.
"""
subv = Vyper()
data = self.get(key)
if isinstance(data, dict):
subv._config = data
return subv
else:
return None | python | def sub(self, key):
"""Returns new Vyper instance representing a sub tree of this instance.
"""
subv = Vyper()
data = self.get(key)
if isinstance(data, dict):
subv._config = data
return subv
else:
return None | [
"def",
"sub",
"(",
"self",
",",
"key",
")",
":",
"subv",
"=",
"Vyper",
"(",
")",
"data",
"=",
"self",
".",
"get",
"(",
"key",
")",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"subv",
".",
"_config",
"=",
"data",
"return",
"subv",
"e... | Returns new Vyper instance representing a sub tree of this instance. | [
"Returns",
"new",
"Vyper",
"instance",
"representing",
"a",
"sub",
"tree",
"of",
"this",
"instance",
"."
] | 58ec7b90661502b7b2fea7a30849b90b907fcdec | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L224-L233 | train |
admiralobvious/vyper | vyper/vyper.py | Vyper.unmarshall_key | def unmarshall_key(self, key, cls):
"""Takes a single key and unmarshalls it into a class."""
return setattr(cls, key, self.get(key)) | python | def unmarshall_key(self, key, cls):
"""Takes a single key and unmarshalls it into a class."""
return setattr(cls, key, self.get(key)) | [
"def",
"unmarshall_key",
"(",
"self",
",",
"key",
",",
"cls",
")",
":",
"return",
"setattr",
"(",
"cls",
",",
"key",
",",
"self",
".",
"get",
"(",
"key",
")",
")"
] | Takes a single key and unmarshalls it into a class. | [
"Takes",
"a",
"single",
"key",
"and",
"unmarshalls",
"it",
"into",
"a",
"class",
"."
] | 58ec7b90661502b7b2fea7a30849b90b907fcdec | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L235-L237 | train |
admiralobvious/vyper | vyper/vyper.py | Vyper.unmarshall | def unmarshall(self, cls):
"""Unmarshalls the config into a class. Make sure that the tags on
the attributes of the class are properly set.
"""
for k, v in self.all_settings().items():
setattr(cls, k, v)
return cls | python | def unmarshall(self, cls):
"""Unmarshalls the config into a class. Make sure that the tags on
the attributes of the class are properly set.
"""
for k, v in self.all_settings().items():
setattr(cls, k, v)
return cls | [
"def",
"unmarshall",
"(",
"self",
",",
"cls",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"all_settings",
"(",
")",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"cls",
",",
"k",
",",
"v",
")",
"return",
"cls"
] | Unmarshalls the config into a class. Make sure that the tags on
the attributes of the class are properly set. | [
"Unmarshalls",
"the",
"config",
"into",
"a",
"class",
".",
"Make",
"sure",
"that",
"the",
"tags",
"on",
"the",
"attributes",
"of",
"the",
"class",
"are",
"properly",
"set",
"."
] | 58ec7b90661502b7b2fea7a30849b90b907fcdec | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L239-L246 | train |
admiralobvious/vyper | vyper/vyper.py | Vyper.bind_env | def bind_env(self, *input_):
"""Binds a Vyper key to a ENV variable.
ENV variables are case sensitive.
If only a key is provided, it will use the env key matching the key,
uppercased.
`env_prefix` will be used when set when env name is not provided.
"""
if len(inp... | python | def bind_env(self, *input_):
"""Binds a Vyper key to a ENV variable.
ENV variables are case sensitive.
If only a key is provided, it will use the env key matching the key,
uppercased.
`env_prefix` will be used when set when env name is not provided.
"""
if len(inp... | [
"def",
"bind_env",
"(",
"self",
",",
"*",
"input_",
")",
":",
"if",
"len",
"(",
"input_",
")",
"==",
"0",
":",
"return",
"\"bind_env missing key to bind to\"",
"key",
"=",
"input_",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"if",
"len",
"(",
"input_",
"... | Binds a Vyper key to a ENV variable.
ENV variables are case sensitive.
If only a key is provided, it will use the env key matching the key,
uppercased.
`env_prefix` will be used when set when env name is not provided. | [
"Binds",
"a",
"Vyper",
"key",
"to",
"a",
"ENV",
"variable",
".",
"ENV",
"variables",
"are",
"case",
"sensitive",
".",
"If",
"only",
"a",
"key",
"is",
"provided",
"it",
"will",
"use",
"the",
"env",
"key",
"matching",
"the",
"key",
"uppercased",
".",
"en... | 58ec7b90661502b7b2fea7a30849b90b907fcdec | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L289-L321 | train |
admiralobvious/vyper | vyper/vyper.py | Vyper.is_set | def is_set(self, key):
"""Check to see if the key has been set in any of the data locations.
"""
path = key.split(self._key_delimiter)
lower_case_key = key.lower()
val = self._find(lower_case_key)
if val is None:
source = self._find(path[0].lower())
... | python | def is_set(self, key):
"""Check to see if the key has been set in any of the data locations.
"""
path = key.split(self._key_delimiter)
lower_case_key = key.lower()
val = self._find(lower_case_key)
if val is None:
source = self._find(path[0].lower())
... | [
"def",
"is_set",
"(",
"self",
",",
"key",
")",
":",
"path",
"=",
"key",
".",
"split",
"(",
"self",
".",
"_key_delimiter",
")",
"lower_case_key",
"=",
"key",
".",
"lower",
"(",
")",
"val",
"=",
"self",
".",
"_find",
"(",
"lower_case_key",
")",
"if",
... | Check to see if the key has been set in any of the data locations. | [
"Check",
"to",
"see",
"if",
"the",
"key",
"has",
"been",
"set",
"in",
"any",
"of",
"the",
"data",
"locations",
"."
] | 58ec7b90661502b7b2fea7a30849b90b907fcdec | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L438-L451 | train |
admiralobvious/vyper | vyper/vyper.py | Vyper.register_alias | def register_alias(self, alias, key):
"""Aliases provide another accessor for the same key.
This enables one to change a name without breaking the application.
"""
alias = alias.lower()
key = key.lower()
if alias != key and alias != self._real_key(key):
exists... | python | def register_alias(self, alias, key):
"""Aliases provide another accessor for the same key.
This enables one to change a name without breaking the application.
"""
alias = alias.lower()
key = key.lower()
if alias != key and alias != self._real_key(key):
exists... | [
"def",
"register_alias",
"(",
"self",
",",
"alias",
",",
"key",
")",
":",
"alias",
"=",
"alias",
".",
"lower",
"(",
")",
"key",
"=",
"key",
".",
"lower",
"(",
")",
"if",
"alias",
"!=",
"key",
"and",
"alias",
"!=",
"self",
".",
"_real_key",
"(",
"... | Aliases provide another accessor for the same key.
This enables one to change a name without breaking the application. | [
"Aliases",
"provide",
"another",
"accessor",
"for",
"the",
"same",
"key",
".",
"This",
"enables",
"one",
"to",
"change",
"a",
"name",
"without",
"breaking",
"the",
"application",
"."
] | 58ec7b90661502b7b2fea7a30849b90b907fcdec | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L466-L499 | train |
admiralobvious/vyper | vyper/vyper.py | Vyper.set_default | def set_default(self, key, value):
"""Set the default value for this key.
Default only used when no value is provided by the user via
arg, config or env.
"""
k = self._real_key(key.lower())
self._defaults[k] = value | python | def set_default(self, key, value):
"""Set the default value for this key.
Default only used when no value is provided by the user via
arg, config or env.
"""
k = self._real_key(key.lower())
self._defaults[k] = value | [
"def",
"set_default",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"k",
"=",
"self",
".",
"_real_key",
"(",
"key",
".",
"lower",
"(",
")",
")",
"self",
".",
"_defaults",
"[",
"k",
"]",
"=",
"value"
] | Set the default value for this key.
Default only used when no value is provided by the user via
arg, config or env. | [
"Set",
"the",
"default",
"value",
"for",
"this",
"key",
".",
"Default",
"only",
"used",
"when",
"no",
"value",
"is",
"provided",
"by",
"the",
"user",
"via",
"arg",
"config",
"or",
"env",
"."
] | 58ec7b90661502b7b2fea7a30849b90b907fcdec | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L517-L523 | train |
admiralobvious/vyper | vyper/vyper.py | Vyper._unmarshall_reader | def _unmarshall_reader(self, file_, d):
"""Unmarshall a file into a `dict`."""
return util.unmarshall_config_reader(file_, d, self._get_config_type()) | python | def _unmarshall_reader(self, file_, d):
"""Unmarshall a file into a `dict`."""
return util.unmarshall_config_reader(file_, d, self._get_config_type()) | [
"def",
"_unmarshall_reader",
"(",
"self",
",",
"file_",
",",
"d",
")",
":",
"return",
"util",
".",
"unmarshall_config_reader",
"(",
"file_",
",",
"d",
",",
"self",
".",
"_get_config_type",
"(",
")",
")"
] | Unmarshall a file into a `dict`. | [
"Unmarshall",
"a",
"file",
"into",
"a",
"dict",
"."
] | 58ec7b90661502b7b2fea7a30849b90b907fcdec | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L586-L588 | train |
admiralobvious/vyper | vyper/vyper.py | Vyper._get_key_value_config | def _get_key_value_config(self):
"""Retrieves the first found remote configuration."""
for rp in self._remote_providers:
val = self._get_remote_config(rp)
self._kvstore = val
return None
raise errors.RemoteConfigError("No Files Found") | python | def _get_key_value_config(self):
"""Retrieves the first found remote configuration."""
for rp in self._remote_providers:
val = self._get_remote_config(rp)
self._kvstore = val
return None
raise errors.RemoteConfigError("No Files Found") | [
"def",
"_get_key_value_config",
"(",
"self",
")",
":",
"for",
"rp",
"in",
"self",
".",
"_remote_providers",
":",
"val",
"=",
"self",
".",
"_get_remote_config",
"(",
"rp",
")",
"self",
".",
"_kvstore",
"=",
"val",
"return",
"None",
"raise",
"errors",
".",
... | Retrieves the first found remote configuration. | [
"Retrieves",
"the",
"first",
"found",
"remote",
"configuration",
"."
] | 58ec7b90661502b7b2fea7a30849b90b907fcdec | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L590-L597 | train |
admiralobvious/vyper | vyper/vyper.py | Vyper.all_keys | def all_keys(self, uppercase_keys=False):
"""Return all keys regardless where they are set."""
d = {}
for k in self._override.keys():
d[k.upper() if uppercase_keys else k.lower()] = {}
for k in self._args.keys():
d[k.upper() if uppercase_keys else k.lower()] = {... | python | def all_keys(self, uppercase_keys=False):
"""Return all keys regardless where they are set."""
d = {}
for k in self._override.keys():
d[k.upper() if uppercase_keys else k.lower()] = {}
for k in self._args.keys():
d[k.upper() if uppercase_keys else k.lower()] = {... | [
"def",
"all_keys",
"(",
"self",
",",
"uppercase_keys",
"=",
"False",
")",
":",
"d",
"=",
"{",
"}",
"for",
"k",
"in",
"self",
".",
"_override",
".",
"keys",
"(",
")",
":",
"d",
"[",
"k",
".",
"upper",
"(",
")",
"if",
"uppercase_keys",
"else",
"k",... | Return all keys regardless where they are set. | [
"Return",
"all",
"keys",
"regardless",
"where",
"they",
"are",
"set",
"."
] | 58ec7b90661502b7b2fea7a30849b90b907fcdec | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L617-L642 | train |
admiralobvious/vyper | vyper/vyper.py | Vyper.all_settings | def all_settings(self, uppercase_keys=False):
"""Return all settings as a `dict`."""
d = {}
for k in self.all_keys(uppercase_keys):
d[k] = self.get(k)
return d | python | def all_settings(self, uppercase_keys=False):
"""Return all settings as a `dict`."""
d = {}
for k in self.all_keys(uppercase_keys):
d[k] = self.get(k)
return d | [
"def",
"all_settings",
"(",
"self",
",",
"uppercase_keys",
"=",
"False",
")",
":",
"d",
"=",
"{",
"}",
"for",
"k",
"in",
"self",
".",
"all_keys",
"(",
"uppercase_keys",
")",
":",
"d",
"[",
"k",
"]",
"=",
"self",
".",
"get",
"(",
"k",
")",
"return... | Return all settings as a `dict`. | [
"Return",
"all",
"settings",
"as",
"a",
"dict",
"."
] | 58ec7b90661502b7b2fea7a30849b90b907fcdec | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L644-L651 | train |
admiralobvious/vyper | vyper/vyper.py | Vyper.debug | def debug(self): # pragma: no cover
"""Prints all configuration registries for debugging purposes."""
print("Aliases:")
pprint.pprint(self._aliases)
print("Override:")
pprint.pprint(self._override)
print("Args:")
pprint.pprint(self._args)
print("Env:")
... | python | def debug(self): # pragma: no cover
"""Prints all configuration registries for debugging purposes."""
print("Aliases:")
pprint.pprint(self._aliases)
print("Override:")
pprint.pprint(self._override)
print("Args:")
pprint.pprint(self._args)
print("Env:")
... | [
"def",
"debug",
"(",
"self",
")",
":",
"# pragma: no cover",
"print",
"(",
"\"Aliases:\"",
")",
"pprint",
".",
"pprint",
"(",
"self",
".",
"_aliases",
")",
"print",
"(",
"\"Override:\"",
")",
"pprint",
".",
"pprint",
"(",
"self",
".",
"_override",
")",
"... | Prints all configuration registries for debugging purposes. | [
"Prints",
"all",
"configuration",
"registries",
"for",
"debugging",
"purposes",
"."
] | 58ec7b90661502b7b2fea7a30849b90b907fcdec | https://github.com/admiralobvious/vyper/blob/58ec7b90661502b7b2fea7a30849b90b907fcdec/vyper/vyper.py#L713-L729 | train |
rsalmei/clearly | clearly/command_line.py | server | def server(**kwargs):
"""
Starts the Clearly Server.
BROKER: The broker being used by celery, like "amqp://localhost".
"""
start_server(**{k: v for k, v in kwargs.items() if v},
blocking=True) | python | def server(**kwargs):
"""
Starts the Clearly Server.
BROKER: The broker being used by celery, like "amqp://localhost".
"""
start_server(**{k: v for k, v in kwargs.items() if v},
blocking=True) | [
"def",
"server",
"(",
"*",
"*",
"kwargs",
")",
":",
"start_server",
"(",
"*",
"*",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
"if",
"v",
"}",
",",
"blocking",
"=",
"True",
")"
] | Starts the Clearly Server.
BROKER: The broker being used by celery, like "amqp://localhost". | [
"Starts",
"the",
"Clearly",
"Server",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/command_line.py#L25-L32 | train |
rsalmei/clearly | clearly/server.py | start_server | def start_server(broker, backend=None, port=12223,
max_tasks=10000, max_workers=100,
blocking=False, debug=False): # pragma: no cover
"""Starts a Clearly Server programmatically."""
_setup_logging(debug)
queue_listener_dispatcher = Queue()
listener = EventListener(bro... | python | def start_server(broker, backend=None, port=12223,
max_tasks=10000, max_workers=100,
blocking=False, debug=False): # pragma: no cover
"""Starts a Clearly Server programmatically."""
_setup_logging(debug)
queue_listener_dispatcher = Queue()
listener = EventListener(bro... | [
"def",
"start_server",
"(",
"broker",
",",
"backend",
"=",
"None",
",",
"port",
"=",
"12223",
",",
"max_tasks",
"=",
"10000",
",",
"max_workers",
"=",
"100",
",",
"blocking",
"=",
"False",
",",
"debug",
"=",
"False",
")",
":",
"# pragma: no cover",
"_set... | Starts a Clearly Server programmatically. | [
"Starts",
"a",
"Clearly",
"Server",
"programmatically",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/server.py#L193-L205 | train |
rsalmei/clearly | clearly/server.py | ClearlyServer._event_to_pb | def _event_to_pb(event):
"""Supports converting internal TaskData and WorkerData, as well as
celery Task and Worker to proto buffers messages.
Args:
event (Union[TaskData|Task|WorkerData|Worker]):
Returns:
ProtoBuf object
"""
if isinstance(event... | python | def _event_to_pb(event):
"""Supports converting internal TaskData and WorkerData, as well as
celery Task and Worker to proto buffers messages.
Args:
event (Union[TaskData|Task|WorkerData|Worker]):
Returns:
ProtoBuf object
"""
if isinstance(event... | [
"def",
"_event_to_pb",
"(",
"event",
")",
":",
"if",
"isinstance",
"(",
"event",
",",
"(",
"TaskData",
",",
"Task",
")",
")",
":",
"key",
",",
"klass",
"=",
"'task'",
",",
"clearly_pb2",
".",
"TaskMessage",
"elif",
"isinstance",
"(",
"event",
",",
"(",... | Supports converting internal TaskData and WorkerData, as well as
celery Task and Worker to proto buffers messages.
Args:
event (Union[TaskData|Task|WorkerData|Worker]):
Returns:
ProtoBuf object | [
"Supports",
"converting",
"internal",
"TaskData",
"and",
"WorkerData",
"as",
"well",
"as",
"celery",
"Task",
"and",
"Worker",
"to",
"proto",
"buffers",
"messages",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/server.py#L73-L96 | train |
rsalmei/clearly | clearly/server.py | ClearlyServer.filter_tasks | def filter_tasks(self, request, context):
"""Filter tasks by matching patterns to name, routing key and state."""
_log_request(request, context)
tasks_pattern, tasks_negate = PATTERN_PARAMS_OP(request.tasks_filter)
state_pattern = request.state_pattern
limit, reverse = request.li... | python | def filter_tasks(self, request, context):
"""Filter tasks by matching patterns to name, routing key and state."""
_log_request(request, context)
tasks_pattern, tasks_negate = PATTERN_PARAMS_OP(request.tasks_filter)
state_pattern = request.state_pattern
limit, reverse = request.li... | [
"def",
"filter_tasks",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"_log_request",
"(",
"request",
",",
"context",
")",
"tasks_pattern",
",",
"tasks_negate",
"=",
"PATTERN_PARAMS_OP",
"(",
"request",
".",
"tasks_filter",
")",
"state_pattern",
"=",
"... | Filter tasks by matching patterns to name, routing key and state. | [
"Filter",
"tasks",
"by",
"matching",
"patterns",
"to",
"name",
"routing",
"key",
"and",
"state",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/server.py#L98-L124 | train |
rsalmei/clearly | clearly/server.py | ClearlyServer.filter_workers | def filter_workers(self, request, context):
"""Filter workers by matching a pattern to hostname."""
_log_request(request, context)
workers_pattern, workers_negate = PATTERN_PARAMS_OP(request.workers_filter)
hregex = re.compile(workers_pattern) # hostname filter condition
def h... | python | def filter_workers(self, request, context):
"""Filter workers by matching a pattern to hostname."""
_log_request(request, context)
workers_pattern, workers_negate = PATTERN_PARAMS_OP(request.workers_filter)
hregex = re.compile(workers_pattern) # hostname filter condition
def h... | [
"def",
"filter_workers",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"_log_request",
"(",
"request",
",",
"context",
")",
"workers_pattern",
",",
"workers_negate",
"=",
"PATTERN_PARAMS_OP",
"(",
"request",
".",
"workers_filter",
")",
"hregex",
"=",
... | Filter workers by matching a pattern to hostname. | [
"Filter",
"workers",
"by",
"matching",
"a",
"pattern",
"to",
"hostname",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/server.py#L126-L146 | train |
rsalmei/clearly | clearly/server.py | ClearlyServer.seen_tasks | def seen_tasks(self, request, context):
"""Returns all seen task types."""
_log_request(request, context)
result = clearly_pb2.SeenTasksMessage()
result.task_types.extend(self.listener.memory.task_types())
return result | python | def seen_tasks(self, request, context):
"""Returns all seen task types."""
_log_request(request, context)
result = clearly_pb2.SeenTasksMessage()
result.task_types.extend(self.listener.memory.task_types())
return result | [
"def",
"seen_tasks",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"_log_request",
"(",
"request",
",",
"context",
")",
"result",
"=",
"clearly_pb2",
".",
"SeenTasksMessage",
"(",
")",
"result",
".",
"task_types",
".",
"extend",
"(",
"self",
".",
... | Returns all seen task types. | [
"Returns",
"all",
"seen",
"task",
"types",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/server.py#L156-L161 | train |
rsalmei/clearly | clearly/server.py | ClearlyServer.reset_tasks | def reset_tasks(self, request, context):
"""Resets all captured tasks."""
_log_request(request, context)
self.listener.memory.clear_tasks()
return clearly_pb2.Empty() | python | def reset_tasks(self, request, context):
"""Resets all captured tasks."""
_log_request(request, context)
self.listener.memory.clear_tasks()
return clearly_pb2.Empty() | [
"def",
"reset_tasks",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"_log_request",
"(",
"request",
",",
"context",
")",
"self",
".",
"listener",
".",
"memory",
".",
"clear_tasks",
"(",
")",
"return",
"clearly_pb2",
".",
"Empty",
"(",
")"
] | Resets all captured tasks. | [
"Resets",
"all",
"captured",
"tasks",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/server.py#L163-L167 | train |
rsalmei/clearly | clearly/server.py | ClearlyServer.get_stats | def get_stats(self, request, context):
"""Returns the server statistics."""
_log_request(request, context)
m = self.listener.memory
return clearly_pb2.StatsMessage(
task_count=m.task_count,
event_count=m.event_count,
len_tasks=len(m.tasks),
... | python | def get_stats(self, request, context):
"""Returns the server statistics."""
_log_request(request, context)
m = self.listener.memory
return clearly_pb2.StatsMessage(
task_count=m.task_count,
event_count=m.event_count,
len_tasks=len(m.tasks),
... | [
"def",
"get_stats",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"_log_request",
"(",
"request",
",",
"context",
")",
"m",
"=",
"self",
".",
"listener",
".",
"memory",
"return",
"clearly_pb2",
".",
"StatsMessage",
"(",
"task_count",
"=",
"m",
"... | Returns the server statistics. | [
"Returns",
"the",
"server",
"statistics",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/server.py#L169-L178 | train |
rsalmei/clearly | clearly/utils/data.py | accepts | def accepts(regex, negate, *values):
"""Given a compiled regex and a negate, find if any of the values match.
Args:
regex (Pattern):
negate (bool):
*values (str):
Returns:
"""
return any(v and regex.search(v) for v in values) != negate | python | def accepts(regex, negate, *values):
"""Given a compiled regex and a negate, find if any of the values match.
Args:
regex (Pattern):
negate (bool):
*values (str):
Returns:
"""
return any(v and regex.search(v) for v in values) != negate | [
"def",
"accepts",
"(",
"regex",
",",
"negate",
",",
"*",
"values",
")",
":",
"return",
"any",
"(",
"v",
"and",
"regex",
".",
"search",
"(",
"v",
")",
"for",
"v",
"in",
"values",
")",
"!=",
"negate"
] | Given a compiled regex and a negate, find if any of the values match.
Args:
regex (Pattern):
negate (bool):
*values (str):
Returns: | [
"Given",
"a",
"compiled",
"regex",
"and",
"a",
"negate",
"find",
"if",
"any",
"of",
"the",
"values",
"match",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/utils/data.py#L1-L12 | train |
rsalmei/clearly | clearly/utils/data.py | copy_update | def copy_update(pb_message, **kwds):
"""Returns a copy of the PB object, with some fields updated.
Args:
pb_message:
**kwds:
Returns:
"""
result = pb_message.__class__()
result.CopyFrom(pb_message)
for k, v in kwds.items():
setattr(result, k, v)
return result | python | def copy_update(pb_message, **kwds):
"""Returns a copy of the PB object, with some fields updated.
Args:
pb_message:
**kwds:
Returns:
"""
result = pb_message.__class__()
result.CopyFrom(pb_message)
for k, v in kwds.items():
setattr(result, k, v)
return result | [
"def",
"copy_update",
"(",
"pb_message",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"pb_message",
".",
"__class__",
"(",
")",
"result",
".",
"CopyFrom",
"(",
"pb_message",
")",
"for",
"k",
",",
"v",
"in",
"kwds",
".",
"items",
"(",
")",
":",
"... | Returns a copy of the PB object, with some fields updated.
Args:
pb_message:
**kwds:
Returns: | [
"Returns",
"a",
"copy",
"of",
"the",
"PB",
"object",
"with",
"some",
"fields",
"updated",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/utils/data.py#L15-L29 | train |
rsalmei/clearly | clearly/event_core/streaming_dispatcher.py | StreamingDispatcher.__start | def __start(self): # pragma: no cover
"""Starts the real-time engine that captures tasks."""
assert not self.dispatcher_thread
self.dispatcher_thread = threading.Thread(target=self.__run_dispatcher,
name='clearly-dispatcher')
self.disp... | python | def __start(self): # pragma: no cover
"""Starts the real-time engine that captures tasks."""
assert not self.dispatcher_thread
self.dispatcher_thread = threading.Thread(target=self.__run_dispatcher,
name='clearly-dispatcher')
self.disp... | [
"def",
"__start",
"(",
"self",
")",
":",
"# pragma: no cover",
"assert",
"not",
"self",
".",
"dispatcher_thread",
"self",
".",
"dispatcher_thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"__run_dispatcher",
",",
"name",
"=",
"'clearl... | Starts the real-time engine that captures tasks. | [
"Starts",
"the",
"real",
"-",
"time",
"engine",
"that",
"captures",
"tasks",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/event_core/streaming_dispatcher.py#L56-L65 | train |
rsalmei/clearly | clearly/event_core/streaming_dispatcher.py | StreamingDispatcher.streaming_client | def streaming_client(self, tasks_regex, tasks_negate, workers_regex, workers_negate):
"""Connects a client to the streaming capture, filtering the events that are sent
to it.
Args:
tasks_regex (str): a pattern to filter tasks to capture.
ex.: '^dispatch|^email' to fi... | python | def streaming_client(self, tasks_regex, tasks_negate, workers_regex, workers_negate):
"""Connects a client to the streaming capture, filtering the events that are sent
to it.
Args:
tasks_regex (str): a pattern to filter tasks to capture.
ex.: '^dispatch|^email' to fi... | [
"def",
"streaming_client",
"(",
"self",
",",
"tasks_regex",
",",
"tasks_negate",
",",
"workers_regex",
",",
"workers_negate",
")",
":",
"cc",
"=",
"CapturingClient",
"(",
"Queue",
"(",
")",
",",
"re",
".",
"compile",
"(",
"tasks_regex",
")",
",",
"tasks_nega... | Connects a client to the streaming capture, filtering the events that are sent
to it.
Args:
tasks_regex (str): a pattern to filter tasks to capture.
ex.: '^dispatch|^email' to filter names starting with that
or 'dispatch.*123456' to filter that exact na... | [
"Connects",
"a",
"client",
"to",
"the",
"streaming",
"capture",
"filtering",
"the",
"events",
"that",
"are",
"sent",
"to",
"it",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/event_core/streaming_dispatcher.py#L79-L100 | train |
rsalmei/clearly | clearly/event_core/event_listener.py | EventListener.__start | def __start(self): # pragma: no cover
"""Starts the real-time engine that captures events."""
assert not self._listener_thread
self._listener_thread = threading.Thread(target=self.__run_listener,
name='clearly-listener')
self._listener_... | python | def __start(self): # pragma: no cover
"""Starts the real-time engine that captures events."""
assert not self._listener_thread
self._listener_thread = threading.Thread(target=self.__run_listener,
name='clearly-listener')
self._listener_... | [
"def",
"__start",
"(",
"self",
")",
":",
"# pragma: no cover",
"assert",
"not",
"self",
".",
"_listener_thread",
"self",
".",
"_listener_thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"__run_listener",
",",
"name",
"=",
"'clearly-li... | Starts the real-time engine that captures events. | [
"Starts",
"the",
"real",
"-",
"time",
"engine",
"that",
"captures",
"events",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/event_core/event_listener.py#L71-L81 | train |
rsalmei/clearly | clearly/client.py | ClearlyClient.capture | def capture(self, pattern=None, negate=False, workers=None, negate_workers=False,
params=None, success=False, error=True, stats=False):
"""Starts capturing selected events in real-time. You can filter exactly what
you want to see, as the Clearly Server handles all tasks and workers updat... | python | def capture(self, pattern=None, negate=False, workers=None, negate_workers=False,
params=None, success=False, error=True, stats=False):
"""Starts capturing selected events in real-time. You can filter exactly what
you want to see, as the Clearly Server handles all tasks and workers updat... | [
"def",
"capture",
"(",
"self",
",",
"pattern",
"=",
"None",
",",
"negate",
"=",
"False",
",",
"workers",
"=",
"None",
",",
"negate_workers",
"=",
"False",
",",
"params",
"=",
"None",
",",
"success",
"=",
"False",
",",
"error",
"=",
"True",
",",
"stat... | Starts capturing selected events in real-time. You can filter exactly what
you want to see, as the Clearly Server handles all tasks and workers updates
being sent to celery. Several clients can see different sets of events at the
same time.
This runs in the foreground, so you can see in... | [
"Starts",
"capturing",
"selected",
"events",
"in",
"real",
"-",
"time",
".",
"You",
"can",
"filter",
"exactly",
"what",
"you",
"want",
"to",
"see",
"as",
"the",
"Clearly",
"Server",
"handles",
"all",
"tasks",
"and",
"workers",
"updates",
"being",
"sent",
"... | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/client.py#L40-L92 | train |
rsalmei/clearly | clearly/client.py | ClearlyClient.tasks | def tasks(self, pattern=None, negate=False, state=None, limit=None, reverse=True,
params=None, success=False, error=True):
"""Filters stored tasks and displays their current statuses.
Note that, to be able to list the tasks sorted chronologically, celery retrieves
tasks from the L... | python | def tasks(self, pattern=None, negate=False, state=None, limit=None, reverse=True,
params=None, success=False, error=True):
"""Filters stored tasks and displays their current statuses.
Note that, to be able to list the tasks sorted chronologically, celery retrieves
tasks from the L... | [
"def",
"tasks",
"(",
"self",
",",
"pattern",
"=",
"None",
",",
"negate",
"=",
"False",
",",
"state",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"reverse",
"=",
"True",
",",
"params",
"=",
"None",
",",
"success",
"=",
"False",
",",
"error",
"=",
... | Filters stored tasks and displays their current statuses.
Note that, to be able to list the tasks sorted chronologically, celery retrieves
tasks from the LRU event heap instead of the dict storage, so the total number
of tasks fetched may be different than the server `max_tasks` setting. For
... | [
"Filters",
"stored",
"tasks",
"and",
"displays",
"their",
"current",
"statuses",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/client.py#L118-L158 | train |
rsalmei/clearly | clearly/client.py | ClearlyClient.seen_tasks | def seen_tasks(self):
"""Shows a list of seen task types."""
print('\n'.join(self._stub.seen_tasks(clearly_pb2.Empty()).task_types)) | python | def seen_tasks(self):
"""Shows a list of seen task types."""
print('\n'.join(self._stub.seen_tasks(clearly_pb2.Empty()).task_types)) | [
"def",
"seen_tasks",
"(",
"self",
")",
":",
"print",
"(",
"'\\n'",
".",
"join",
"(",
"self",
".",
"_stub",
".",
"seen_tasks",
"(",
"clearly_pb2",
".",
"Empty",
"(",
")",
")",
".",
"task_types",
")",
")"
] | Shows a list of seen task types. | [
"Shows",
"a",
"list",
"of",
"seen",
"task",
"types",
"."
] | fd784843d13f0fed28fc192565bec3668f1363f4 | https://github.com/rsalmei/clearly/blob/fd784843d13f0fed28fc192565bec3668f1363f4/clearly/client.py#L197-L199 | train |
linuxlewis/channels-api | channels_api/decorators.py | detail_action | def detail_action(**kwargs):
"""
Used to mark a method on a ResourceBinding that should be routed for detail actions.
"""
def decorator(func):
func.action = True
func.detail = True
func.kwargs = kwargs
return func
return decorator | python | def detail_action(**kwargs):
"""
Used to mark a method on a ResourceBinding that should be routed for detail actions.
"""
def decorator(func):
func.action = True
func.detail = True
func.kwargs = kwargs
return func
return decorator | [
"def",
"detail_action",
"(",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"func",
".",
"action",
"=",
"True",
"func",
".",
"detail",
"=",
"True",
"func",
".",
"kwargs",
"=",
"kwargs",
"return",
"func",
"return",
"decorator"
... | Used to mark a method on a ResourceBinding that should be routed for detail actions. | [
"Used",
"to",
"mark",
"a",
"method",
"on",
"a",
"ResourceBinding",
"that",
"should",
"be",
"routed",
"for",
"detail",
"actions",
"."
] | ec2a81a1ae83606980ad5bb709bca517fdde077d | https://github.com/linuxlewis/channels-api/blob/ec2a81a1ae83606980ad5bb709bca517fdde077d/channels_api/decorators.py#L1-L10 | train |
linuxlewis/channels-api | channels_api/decorators.py | list_action | def list_action(**kwargs):
"""
Used to mark a method on a ResourceBinding that should be routed for list actions.
"""
def decorator(func):
func.action = True
func.detail = False
func.kwargs = kwargs
return func
return decorator | python | def list_action(**kwargs):
"""
Used to mark a method on a ResourceBinding that should be routed for list actions.
"""
def decorator(func):
func.action = True
func.detail = False
func.kwargs = kwargs
return func
return decorator | [
"def",
"list_action",
"(",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"func",
".",
"action",
"=",
"True",
"func",
".",
"detail",
"=",
"False",
"func",
".",
"kwargs",
"=",
"kwargs",
"return",
"func",
"return",
"decorator"
] | Used to mark a method on a ResourceBinding that should be routed for list actions. | [
"Used",
"to",
"mark",
"a",
"method",
"on",
"a",
"ResourceBinding",
"that",
"should",
"be",
"routed",
"for",
"list",
"actions",
"."
] | ec2a81a1ae83606980ad5bb709bca517fdde077d | https://github.com/linuxlewis/channels-api/blob/ec2a81a1ae83606980ad5bb709bca517fdde077d/channels_api/decorators.py#L13-L22 | train |
mattja/sdeint | sdeint/_broadcast.py | broadcast_to | def broadcast_to(array, shape, subok=False):
"""Broadcast an array to a new shape.
Parameters
----------
array : array_like
The array to broadcast.
shape : tuple
The shape of the desired array.
subok : bool, optional
If True, then sub-classes will be passed-through, othe... | python | def broadcast_to(array, shape, subok=False):
"""Broadcast an array to a new shape.
Parameters
----------
array : array_like
The array to broadcast.
shape : tuple
The shape of the desired array.
subok : bool, optional
If True, then sub-classes will be passed-through, othe... | [
"def",
"broadcast_to",
"(",
"array",
",",
"shape",
",",
"subok",
"=",
"False",
")",
":",
"return",
"_broadcast_to",
"(",
"array",
",",
"shape",
",",
"subok",
"=",
"subok",
",",
"readonly",
"=",
"True",
")"
] | Broadcast an array to a new shape.
Parameters
----------
array : array_like
The array to broadcast.
shape : tuple
The shape of the desired array.
subok : bool, optional
If True, then sub-classes will be passed-through, otherwise
the returned array will be forced to b... | [
"Broadcast",
"an",
"array",
"to",
"a",
"new",
"shape",
"."
] | 7cf807cdf97b3bb39d29e1c2dc834b519499b601 | https://github.com/mattja/sdeint/blob/7cf807cdf97b3bb39d29e1c2dc834b519499b601/sdeint/_broadcast.py#L70-L108 | train |
mattja/sdeint | sdeint/wiener.py | _K | def _K(m):
""" matrix K_m from Wiktorsson2001 """
M = m*(m - 1)//2
K = np.zeros((M, m**2), dtype=np.int64)
row = 0
for j in range(1, m):
col = (j - 1)*m + j
s = m - j
K[row:(row+s), col:(col+s)] = np.eye(s)
row += s
return K | python | def _K(m):
""" matrix K_m from Wiktorsson2001 """
M = m*(m - 1)//2
K = np.zeros((M, m**2), dtype=np.int64)
row = 0
for j in range(1, m):
col = (j - 1)*m + j
s = m - j
K[row:(row+s), col:(col+s)] = np.eye(s)
row += s
return K | [
"def",
"_K",
"(",
"m",
")",
":",
"M",
"=",
"m",
"*",
"(",
"m",
"-",
"1",
")",
"//",
"2",
"K",
"=",
"np",
".",
"zeros",
"(",
"(",
"M",
",",
"m",
"**",
"2",
")",
",",
"dtype",
"=",
"np",
".",
"int64",
")",
"row",
"=",
"0",
"for",
"j",
... | matrix K_m from Wiktorsson2001 | [
"matrix",
"K_m",
"from",
"Wiktorsson2001"
] | 7cf807cdf97b3bb39d29e1c2dc834b519499b601 | https://github.com/mattja/sdeint/blob/7cf807cdf97b3bb39d29e1c2dc834b519499b601/sdeint/wiener.py#L187-L197 | train |
riptano/ccm | ccmlib/cluster.py | Cluster.wait_for_compactions | def wait_for_compactions(self, timeout=600):
"""
Wait for all compactions to finish on all nodes.
"""
for node in list(self.nodes.values()):
if node.is_running():
node.wait_for_compactions(timeout)
return self | python | def wait_for_compactions(self, timeout=600):
"""
Wait for all compactions to finish on all nodes.
"""
for node in list(self.nodes.values()):
if node.is_running():
node.wait_for_compactions(timeout)
return self | [
"def",
"wait_for_compactions",
"(",
"self",
",",
"timeout",
"=",
"600",
")",
":",
"for",
"node",
"in",
"list",
"(",
"self",
".",
"nodes",
".",
"values",
"(",
")",
")",
":",
"if",
"node",
".",
"is_running",
"(",
")",
":",
"node",
".",
"wait_for_compac... | Wait for all compactions to finish on all nodes. | [
"Wait",
"for",
"all",
"compactions",
"to",
"finish",
"on",
"all",
"nodes",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/cluster.py#L472-L479 | train |
riptano/ccm | ccmlib/dse_node.py | DseNode.watch_log_for_alive | def watch_log_for_alive(self, nodes, from_mark=None, timeout=720, filename='system.log'):
"""
Watch the log of this node until it detects that the provided other
nodes are marked UP. This method works similarly to watch_log_for_death.
We want to provide a higher default timeout when thi... | python | def watch_log_for_alive(self, nodes, from_mark=None, timeout=720, filename='system.log'):
"""
Watch the log of this node until it detects that the provided other
nodes are marked UP. This method works similarly to watch_log_for_death.
We want to provide a higher default timeout when thi... | [
"def",
"watch_log_for_alive",
"(",
"self",
",",
"nodes",
",",
"from_mark",
"=",
"None",
",",
"timeout",
"=",
"720",
",",
"filename",
"=",
"'system.log'",
")",
":",
"super",
"(",
"DseNode",
",",
"self",
")",
".",
"watch_log_for_alive",
"(",
"nodes",
",",
... | Watch the log of this node until it detects that the provided other
nodes are marked UP. This method works similarly to watch_log_for_death.
We want to provide a higher default timeout when this is called on DSE. | [
"Watch",
"the",
"log",
"of",
"this",
"node",
"until",
"it",
"detects",
"that",
"the",
"provided",
"other",
"nodes",
"are",
"marked",
"UP",
".",
"This",
"method",
"works",
"similarly",
"to",
"watch_log_for_death",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/dse_node.py#L102-L109 | train |
riptano/ccm | ccmlib/node.py | Node.load | def load(path, name, cluster):
"""
Load a node from from the path on disk to the config files, the node name and the
cluster the node is part of.
"""
node_path = os.path.join(path, name)
filename = os.path.join(node_path, 'node.conf')
with open(filename, 'r') as f... | python | def load(path, name, cluster):
"""
Load a node from from the path on disk to the config files, the node name and the
cluster the node is part of.
"""
node_path = os.path.join(path, name)
filename = os.path.join(node_path, 'node.conf')
with open(filename, 'r') as f... | [
"def",
"load",
"(",
"path",
",",
"name",
",",
"cluster",
")",
":",
"node_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"name",
")",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"node_path",
",",
"'node.conf'",
")",
"with",
... | Load a node from from the path on disk to the config files, the node name and the
cluster the node is part of. | [
"Load",
"a",
"node",
"from",
"from",
"the",
"path",
"on",
"disk",
"to",
"the",
"config",
"files",
"the",
"node",
"name",
"and",
"the",
"cluster",
"the",
"node",
"is",
"part",
"of",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L150-L194 | train |
riptano/ccm | ccmlib/node.py | Node.get_install_dir | def get_install_dir(self):
"""
Returns the path to the cassandra source directory used by this node.
"""
if self.__install_dir is None:
return self.cluster.get_install_dir()
else:
common.validate_install_dir(self.__install_dir)
return self.__in... | python | def get_install_dir(self):
"""
Returns the path to the cassandra source directory used by this node.
"""
if self.__install_dir is None:
return self.cluster.get_install_dir()
else:
common.validate_install_dir(self.__install_dir)
return self.__in... | [
"def",
"get_install_dir",
"(",
"self",
")",
":",
"if",
"self",
".",
"__install_dir",
"is",
"None",
":",
"return",
"self",
".",
"cluster",
".",
"get_install_dir",
"(",
")",
"else",
":",
"common",
".",
"validate_install_dir",
"(",
"self",
".",
"__install_dir",... | Returns the path to the cassandra source directory used by this node. | [
"Returns",
"the",
"path",
"to",
"the",
"cassandra",
"source",
"directory",
"used",
"by",
"this",
"node",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L241-L249 | train |
riptano/ccm | ccmlib/node.py | Node.set_install_dir | def set_install_dir(self, install_dir=None, version=None, verbose=False):
"""
Sets the path to the cassandra source directory for use by this node.
"""
if version is None:
self.__install_dir = install_dir
if install_dir is not None:
common.validate... | python | def set_install_dir(self, install_dir=None, version=None, verbose=False):
"""
Sets the path to the cassandra source directory for use by this node.
"""
if version is None:
self.__install_dir = install_dir
if install_dir is not None:
common.validate... | [
"def",
"set_install_dir",
"(",
"self",
",",
"install_dir",
"=",
"None",
",",
"version",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"version",
"is",
"None",
":",
"self",
".",
"__install_dir",
"=",
"install_dir",
"if",
"install_dir",
"is",
... | Sets the path to the cassandra source directory for use by this node. | [
"Sets",
"the",
"path",
"to",
"the",
"cassandra",
"source",
"directory",
"for",
"use",
"by",
"this",
"node",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L255-L274 | train |
riptano/ccm | ccmlib/node.py | Node.show | def show(self, only_status=False, show_cluster=True):
"""
Print infos on this node configuration.
"""
self.__update_status()
indent = ''.join([" " for i in xrange(0, len(self.name) + 2)])
print_("{}: {}".format(self.name, self.__get_status_string()))
if not only_s... | python | def show(self, only_status=False, show_cluster=True):
"""
Print infos on this node configuration.
"""
self.__update_status()
indent = ''.join([" " for i in xrange(0, len(self.name) + 2)])
print_("{}: {}".format(self.name, self.__get_status_string()))
if not only_s... | [
"def",
"show",
"(",
"self",
",",
"only_status",
"=",
"False",
",",
"show_cluster",
"=",
"True",
")",
":",
"self",
".",
"__update_status",
"(",
")",
"indent",
"=",
"''",
".",
"join",
"(",
"[",
"\" \"",
"for",
"i",
"in",
"xrange",
"(",
"0",
",",
"len... | Print infos on this node configuration. | [
"Print",
"infos",
"on",
"this",
"node",
"configuration",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L329-L350 | train |
riptano/ccm | ccmlib/node.py | Node.is_running | def is_running(self):
"""
Return true if the node is running
"""
self.__update_status()
return self.status == Status.UP or self.status == Status.DECOMMISSIONED | python | def is_running(self):
"""
Return true if the node is running
"""
self.__update_status()
return self.status == Status.UP or self.status == Status.DECOMMISSIONED | [
"def",
"is_running",
"(",
"self",
")",
":",
"self",
".",
"__update_status",
"(",
")",
"return",
"self",
".",
"status",
"==",
"Status",
".",
"UP",
"or",
"self",
".",
"status",
"==",
"Status",
".",
"DECOMMISSIONED"
] | Return true if the node is running | [
"Return",
"true",
"if",
"the",
"node",
"is",
"running"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L352-L357 | train |
riptano/ccm | ccmlib/node.py | Node.grep_log | def grep_log(self, expr, filename='system.log', from_mark=None):
"""
Returns a list of lines matching the regular expression in parameter
in the Cassandra log of this node
"""
matchings = []
pattern = re.compile(expr)
with open(os.path.join(self.get_path(), 'logs'... | python | def grep_log(self, expr, filename='system.log', from_mark=None):
"""
Returns a list of lines matching the regular expression in parameter
in the Cassandra log of this node
"""
matchings = []
pattern = re.compile(expr)
with open(os.path.join(self.get_path(), 'logs'... | [
"def",
"grep_log",
"(",
"self",
",",
"expr",
",",
"filename",
"=",
"'system.log'",
",",
"from_mark",
"=",
"None",
")",
":",
"matchings",
"=",
"[",
"]",
"pattern",
"=",
"re",
".",
"compile",
"(",
"expr",
")",
"with",
"open",
"(",
"os",
".",
"path",
... | Returns a list of lines matching the regular expression in parameter
in the Cassandra log of this node | [
"Returns",
"a",
"list",
"of",
"lines",
"matching",
"the",
"regular",
"expression",
"in",
"parameter",
"in",
"the",
"Cassandra",
"log",
"of",
"this",
"node"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L387-L401 | train |
riptano/ccm | ccmlib/node.py | Node.wait_for_binary_interface | def wait_for_binary_interface(self, **kwargs):
"""
Waits for the Binary CQL interface to be listening. If > 1.2 will check
log for 'Starting listening for CQL clients' before checking for the
interface to be listening.
Emits a warning if not listening after 30 seconds.
... | python | def wait_for_binary_interface(self, **kwargs):
"""
Waits for the Binary CQL interface to be listening. If > 1.2 will check
log for 'Starting listening for CQL clients' before checking for the
interface to be listening.
Emits a warning if not listening after 30 seconds.
... | [
"def",
"wait_for_binary_interface",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"cluster",
".",
"version",
"(",
")",
">=",
"'1.2'",
":",
"self",
".",
"watch_log_for",
"(",
"\"Starting listening for CQL clients\"",
",",
"*",
"*",
"kwarg... | Waits for the Binary CQL interface to be listening. If > 1.2 will check
log for 'Starting listening for CQL clients' before checking for the
interface to be listening.
Emits a warning if not listening after 30 seconds. | [
"Waits",
"for",
"the",
"Binary",
"CQL",
"interface",
"to",
"be",
"listening",
".",
"If",
">",
"1",
".",
"2",
"will",
"check",
"log",
"for",
"Starting",
"listening",
"for",
"CQL",
"clients",
"before",
"checking",
"for",
"the",
"interface",
"to",
"be",
"li... | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L544-L558 | train |
riptano/ccm | ccmlib/node.py | Node.wait_for_thrift_interface | def wait_for_thrift_interface(self, **kwargs):
"""
Waits for the Thrift interface to be listening.
Emits a warning if not listening after 30 seconds.
"""
if self.cluster.version() >= '4':
return;
self.watch_log_for("Listening for thrift clients...", **kwargs... | python | def wait_for_thrift_interface(self, **kwargs):
"""
Waits for the Thrift interface to be listening.
Emits a warning if not listening after 30 seconds.
"""
if self.cluster.version() >= '4':
return;
self.watch_log_for("Listening for thrift clients...", **kwargs... | [
"def",
"wait_for_thrift_interface",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"cluster",
".",
"version",
"(",
")",
">=",
"'4'",
":",
"return",
"self",
".",
"watch_log_for",
"(",
"\"Listening for thrift clients...\"",
",",
"*",
"*",
... | Waits for the Thrift interface to be listening.
Emits a warning if not listening after 30 seconds. | [
"Waits",
"for",
"the",
"Thrift",
"interface",
"to",
"be",
"listening",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L560-L573 | train |
riptano/ccm | ccmlib/node.py | Node.wait_for_compactions | def wait_for_compactions(self, timeout=120):
"""
Wait for all compactions to finish on this node.
"""
pattern = re.compile("pending tasks: 0")
start = time.time()
while time.time() - start < timeout:
output, err, rc = self.nodetool("compactionstats")
... | python | def wait_for_compactions(self, timeout=120):
"""
Wait for all compactions to finish on this node.
"""
pattern = re.compile("pending tasks: 0")
start = time.time()
while time.time() - start < timeout:
output, err, rc = self.nodetool("compactionstats")
... | [
"def",
"wait_for_compactions",
"(",
"self",
",",
"timeout",
"=",
"120",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"\"pending tasks: 0\"",
")",
"start",
"=",
"time",
".",
"time",
"(",
")",
"while",
"time",
".",
"time",
"(",
")",
"-",
"start",... | Wait for all compactions to finish on this node. | [
"Wait",
"for",
"all",
"compactions",
"to",
"finish",
"on",
"this",
"node",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L804-L815 | train |
riptano/ccm | ccmlib/node.py | Node.update_startup_byteman_script | def update_startup_byteman_script(self, byteman_startup_script):
"""
Update the byteman startup script, i.e., rule injected before the node starts.
:param byteman_startup_script: the relative path to the script
:raise common.LoadError: if the node does not have byteman installed
... | python | def update_startup_byteman_script(self, byteman_startup_script):
"""
Update the byteman startup script, i.e., rule injected before the node starts.
:param byteman_startup_script: the relative path to the script
:raise common.LoadError: if the node does not have byteman installed
... | [
"def",
"update_startup_byteman_script",
"(",
"self",
",",
"byteman_startup_script",
")",
":",
"if",
"self",
".",
"byteman_port",
"==",
"'0'",
":",
"raise",
"common",
".",
"LoadError",
"(",
"'Byteman is not installed'",
")",
"self",
".",
"byteman_startup_script",
"="... | Update the byteman startup script, i.e., rule injected before the node starts.
:param byteman_startup_script: the relative path to the script
:raise common.LoadError: if the node does not have byteman installed | [
"Update",
"the",
"byteman",
"startup",
"script",
"i",
".",
"e",
".",
"rule",
"injected",
"before",
"the",
"node",
"starts",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L953-L963 | train |
riptano/ccm | ccmlib/node.py | Node._find_cmd | def _find_cmd(self, cmd):
"""
Locates command under cassandra root and fixes permissions if needed
"""
cdir = self.get_install_cassandra_root()
if self.get_base_cassandra_version() >= 2.1:
fcmd = common.join_bin(cdir, os.path.join('tools', 'bin'), cmd)
else:
... | python | def _find_cmd(self, cmd):
"""
Locates command under cassandra root and fixes permissions if needed
"""
cdir = self.get_install_cassandra_root()
if self.get_base_cassandra_version() >= 2.1:
fcmd = common.join_bin(cdir, os.path.join('tools', 'bin'), cmd)
else:
... | [
"def",
"_find_cmd",
"(",
"self",
",",
"cmd",
")",
":",
"cdir",
"=",
"self",
".",
"get_install_cassandra_root",
"(",
")",
"if",
"self",
".",
"get_base_cassandra_version",
"(",
")",
">=",
"2.1",
":",
"fcmd",
"=",
"common",
".",
"join_bin",
"(",
"cdir",
","... | Locates command under cassandra root and fixes permissions if needed | [
"Locates",
"command",
"under",
"cassandra",
"root",
"and",
"fixes",
"permissions",
"if",
"needed"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L1209-L1224 | train |
riptano/ccm | ccmlib/node.py | Node.data_size | def data_size(self, live_data=None):
"""Uses `nodetool info` to get the size of a node's data in KB."""
if live_data is not None:
warnings.warn("The 'live_data' keyword argument is deprecated.",
DeprecationWarning)
output = self.nodetool('info')[0]
r... | python | def data_size(self, live_data=None):
"""Uses `nodetool info` to get the size of a node's data in KB."""
if live_data is not None:
warnings.warn("The 'live_data' keyword argument is deprecated.",
DeprecationWarning)
output = self.nodetool('info')[0]
r... | [
"def",
"data_size",
"(",
"self",
",",
"live_data",
"=",
"None",
")",
":",
"if",
"live_data",
"is",
"not",
"None",
":",
"warnings",
".",
"warn",
"(",
"\"The 'live_data' keyword argument is deprecated.\"",
",",
"DeprecationWarning",
")",
"output",
"=",
"self",
"."... | Uses `nodetool info` to get the size of a node's data in KB. | [
"Uses",
"nodetool",
"info",
"to",
"get",
"the",
"size",
"of",
"a",
"node",
"s",
"data",
"in",
"KB",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L1338-L1344 | train |
riptano/ccm | ccmlib/node.py | Node.get_sstable_data_files | def get_sstable_data_files(self, ks, table):
"""
Read sstable data files by using sstableutil, so we ignore temporary files
"""
p = self.get_sstable_data_files_process(ks=ks, table=table)
out, _, _ = handle_external_tool_process(p, ["sstableutil", '--type', 'final', ks, table])
... | python | def get_sstable_data_files(self, ks, table):
"""
Read sstable data files by using sstableutil, so we ignore temporary files
"""
p = self.get_sstable_data_files_process(ks=ks, table=table)
out, _, _ = handle_external_tool_process(p, ["sstableutil", '--type', 'final', ks, table])
... | [
"def",
"get_sstable_data_files",
"(",
"self",
",",
"ks",
",",
"table",
")",
":",
"p",
"=",
"self",
".",
"get_sstable_data_files_process",
"(",
"ks",
"=",
"ks",
",",
"table",
"=",
"table",
")",
"out",
",",
"_",
",",
"_",
"=",
"handle_external_tool_process",... | Read sstable data files by using sstableutil, so we ignore temporary files | [
"Read",
"sstable",
"data",
"files",
"by",
"using",
"sstableutil",
"so",
"we",
"ignore",
"temporary",
"files"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/node.py#L2005-L2013 | train |
riptano/ccm | ccmlib/common.py | is_modern_windows_install | def is_modern_windows_install(version):
"""
The 2.1 release line was when Cassandra received beta windows support.
Many features are gated based on that added compatibility.
Handles floats, strings, and LooseVersions by first converting all three types to a string, then to a LooseVersion.
"""
v... | python | def is_modern_windows_install(version):
"""
The 2.1 release line was when Cassandra received beta windows support.
Many features are gated based on that added compatibility.
Handles floats, strings, and LooseVersions by first converting all three types to a string, then to a LooseVersion.
"""
v... | [
"def",
"is_modern_windows_install",
"(",
"version",
")",
":",
"version",
"=",
"LooseVersion",
"(",
"str",
"(",
"version",
")",
")",
"if",
"is_win",
"(",
")",
"and",
"version",
">=",
"LooseVersion",
"(",
"'2.1'",
")",
":",
"return",
"True",
"else",
":",
"... | The 2.1 release line was when Cassandra received beta windows support.
Many features are gated based on that added compatibility.
Handles floats, strings, and LooseVersions by first converting all three types to a string, then to a LooseVersion. | [
"The",
"2",
".",
"1",
"release",
"line",
"was",
"when",
"Cassandra",
"received",
"beta",
"windows",
"support",
".",
"Many",
"features",
"are",
"gated",
"based",
"on",
"that",
"added",
"compatibility",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/common.py#L354-L365 | train |
riptano/ccm | ccmlib/common.py | get_jdk_version | def get_jdk_version():
"""
Retrieve the Java version as reported in the quoted string returned
by invoking 'java -version'.
Works for Java 1.8, Java 9 and should also be fine for Java 10.
"""
try:
version = subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT)
exce... | python | def get_jdk_version():
"""
Retrieve the Java version as reported in the quoted string returned
by invoking 'java -version'.
Works for Java 1.8, Java 9 and should also be fine for Java 10.
"""
try:
version = subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT)
exce... | [
"def",
"get_jdk_version",
"(",
")",
":",
"try",
":",
"version",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'java'",
",",
"'-version'",
"]",
",",
"stderr",
"=",
"subprocess",
".",
"STDOUT",
")",
"except",
"OSError",
":",
"print_",
"(",
"\"ERROR: Cou... | Retrieve the Java version as reported in the quoted string returned
by invoking 'java -version'.
Works for Java 1.8, Java 9 and should also be fine for Java 10. | [
"Retrieve",
"the",
"Java",
"version",
"as",
"reported",
"in",
"the",
"quoted",
"string",
"returned",
"by",
"invoking",
"java",
"-",
"version",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/common.py#L706-L719 | train |
riptano/ccm | ccmlib/common.py | wait_for_any_log | def wait_for_any_log(nodes, pattern, timeout, filename='system.log', marks=None):
"""
Look for a pattern in the system.log of any in a given list
of nodes.
@param nodes The list of nodes whose logs to scan
@param pattern The target pattern
@param timeout How long to wait for the pattern. Note th... | python | def wait_for_any_log(nodes, pattern, timeout, filename='system.log', marks=None):
"""
Look for a pattern in the system.log of any in a given list
of nodes.
@param nodes The list of nodes whose logs to scan
@param pattern The target pattern
@param timeout How long to wait for the pattern. Note th... | [
"def",
"wait_for_any_log",
"(",
"nodes",
",",
"pattern",
",",
"timeout",
",",
"filename",
"=",
"'system.log'",
",",
"marks",
"=",
"None",
")",
":",
"if",
"marks",
"is",
"None",
":",
"marks",
"=",
"{",
"}",
"for",
"_",
"in",
"range",
"(",
"timeout",
"... | Look for a pattern in the system.log of any in a given list
of nodes.
@param nodes The list of nodes whose logs to scan
@param pattern The target pattern
@param timeout How long to wait for the pattern. Note that
strictly speaking, timeout is not really a timeout,
... | [
"Look",
"for",
"a",
"pattern",
"in",
"the",
"system",
".",
"log",
"of",
"any",
"in",
"a",
"given",
"list",
"of",
"nodes",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/common.py#L769-L793 | train |
riptano/ccm | ccmlib/repository.py | download_version | def download_version(version, url=None, verbose=False, binary=False):
"""Download, extract, and build Cassandra tarball.
if binary == True, download precompiled tarball, otherwise build from source tarball.
"""
assert_jdk_valid_for_cassandra_version(version)
archive_url = ARCHIVE
if CCM_CONFIG... | python | def download_version(version, url=None, verbose=False, binary=False):
"""Download, extract, and build Cassandra tarball.
if binary == True, download precompiled tarball, otherwise build from source tarball.
"""
assert_jdk_valid_for_cassandra_version(version)
archive_url = ARCHIVE
if CCM_CONFIG... | [
"def",
"download_version",
"(",
"version",
",",
"url",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"binary",
"=",
"False",
")",
":",
"assert_jdk_valid_for_cassandra_version",
"(",
"version",
")",
"archive_url",
"=",
"ARCHIVE",
"if",
"CCM_CONFIG",
".",
"has... | Download, extract, and build Cassandra tarball.
if binary == True, download precompiled tarball, otherwise build from source tarball. | [
"Download",
"extract",
"and",
"build",
"Cassandra",
"tarball",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/repository.py#L331-L381 | train |
riptano/ccm | ccmlib/repository.py | get_tagged_version_numbers | def get_tagged_version_numbers(series='stable'):
"""Retrieve git tags and find version numbers for a release series
series - 'stable', 'oldstable', or 'testing'"""
releases = []
if series == 'testing':
# Testing releases always have a hyphen after the version number:
tag_regex = re.comp... | python | def get_tagged_version_numbers(series='stable'):
"""Retrieve git tags and find version numbers for a release series
series - 'stable', 'oldstable', or 'testing'"""
releases = []
if series == 'testing':
# Testing releases always have a hyphen after the version number:
tag_regex = re.comp... | [
"def",
"get_tagged_version_numbers",
"(",
"series",
"=",
"'stable'",
")",
":",
"releases",
"=",
"[",
"]",
"if",
"series",
"==",
"'testing'",
":",
"# Testing releases always have a hyphen after the version number:",
"tag_regex",
"=",
"re",
".",
"compile",
"(",
"'^refs/... | Retrieve git tags and find version numbers for a release series
series - 'stable', 'oldstable', or 'testing | [
"Retrieve",
"git",
"tags",
"and",
"find",
"version",
"numbers",
"for",
"a",
"release",
"series"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/repository.py#L477-L511 | train |
riptano/ccm | ccmlib/remote.py | SSHClient.__connect | def __connect(host, port, username, password, private_key):
"""
Establish remote connection
:param host: Hostname or IP address to connect to
:param port: Port number to use for SSH
:param username: Username credentials for SSH access
:param password: Password credential... | python | def __connect(host, port, username, password, private_key):
"""
Establish remote connection
:param host: Hostname or IP address to connect to
:param port: Port number to use for SSH
:param username: Username credentials for SSH access
:param password: Password credential... | [
"def",
"__connect",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
",",
"private_key",
")",
":",
"# Initialize the SSH connection",
"ssh",
"=",
"paramiko",
".",
"SSHClient",
"(",
")",
"ssh",
".",
"set_missing_host_key_policy",
"(",
"paramiko",
".",
... | Establish remote connection
:param host: Hostname or IP address to connect to
:param port: Port number to use for SSH
:param username: Username credentials for SSH access
:param password: Password credentials for SSH access (or private key passphrase)
:param private_key: Private... | [
"Establish",
"remote",
"connection"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L142-L169 | train |
riptano/ccm | ccmlib/remote.py | SSHClient.execute_ccm_command | def execute_ccm_command(self, ccm_args, is_displayed=True):
"""
Execute a CCM command on the remote server
:param ccm_args: CCM arguments to execute remotely
:param is_displayed: True if information should be display; false to return output
(default: true)
... | python | def execute_ccm_command(self, ccm_args, is_displayed=True):
"""
Execute a CCM command on the remote server
:param ccm_args: CCM arguments to execute remotely
:param is_displayed: True if information should be display; false to return output
(default: true)
... | [
"def",
"execute_ccm_command",
"(",
"self",
",",
"ccm_args",
",",
"is_displayed",
"=",
"True",
")",
":",
"return",
"self",
".",
"execute",
"(",
"[",
"\"ccm\"",
"]",
"+",
"ccm_args",
",",
"profile",
"=",
"self",
".",
"profile",
")"
] | Execute a CCM command on the remote server
:param ccm_args: CCM arguments to execute remotely
:param is_displayed: True if information should be display; false to return output
(default: true)
:return: A tuple defining the execution of the command
... | [
"Execute",
"a",
"CCM",
"command",
"on",
"the",
"remote",
"server"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L244-L255 | train |
riptano/ccm | ccmlib/remote.py | SSHClient.execute_python_script | def execute_python_script(self, script):
"""
Execute a python script of the remote server
:param script: Inline script to convert to a file and execute remotely
:return: The output of the script execution
"""
# Create the local file to copy to remote
file_handle,... | python | def execute_python_script(self, script):
"""
Execute a python script of the remote server
:param script: Inline script to convert to a file and execute remotely
:return: The output of the script execution
"""
# Create the local file to copy to remote
file_handle,... | [
"def",
"execute_python_script",
"(",
"self",
",",
"script",
")",
":",
"# Create the local file to copy to remote",
"file_handle",
",",
"filename",
"=",
"tempfile",
".",
"mkstemp",
"(",
")",
"temp_file",
"=",
"os",
".",
"fdopen",
"(",
"file_handle",
",",
"\"wt\"",
... | Execute a python script of the remote server
:param script: Inline script to convert to a file and execute remotely
:return: The output of the script execution | [
"Execute",
"a",
"python",
"script",
"of",
"the",
"remote",
"server"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L257-L278 | train |
riptano/ccm | ccmlib/remote.py | SSHClient.__put_dir | def __put_dir(self, ftp, local_path, remote_path=None):
"""
Helper function to perform copy operation to remote server
:param ftp: SFTP handle to perform copy operation(s)
:param local_path: Local path to copy to; can be file or directory
:param remote_path: Remote path to copy ... | python | def __put_dir(self, ftp, local_path, remote_path=None):
"""
Helper function to perform copy operation to remote server
:param ftp: SFTP handle to perform copy operation(s)
:param local_path: Local path to copy to; can be file or directory
:param remote_path: Remote path to copy ... | [
"def",
"__put_dir",
"(",
"self",
",",
"ftp",
",",
"local_path",
",",
"remote_path",
"=",
"None",
")",
":",
"# Determine if local_path should be put into remote user directory",
"if",
"remote_path",
"is",
"None",
":",
"remote_path",
"=",
"os",
".",
"path",
".",
"ba... | Helper function to perform copy operation to remote server
:param ftp: SFTP handle to perform copy operation(s)
:param local_path: Local path to copy to; can be file or directory
:param remote_path: Remote path to copy to (default: None - Copies file or directory to
... | [
"Helper",
"function",
"to",
"perform",
"copy",
"operation",
"to",
"remote",
"server"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L299-L326 | train |
riptano/ccm | ccmlib/remote.py | SSHClient.remove | def remove(self, remote_path):
"""
Delete a file or directory recursively on the remote server
:param remote_path: Remote path to remove
"""
# Based on the remote file stats; remove a file or directory recursively
ftp = self.ssh.open_sftp()
if stat.S_ISDIR(ftp.st... | python | def remove(self, remote_path):
"""
Delete a file or directory recursively on the remote server
:param remote_path: Remote path to remove
"""
# Based on the remote file stats; remove a file or directory recursively
ftp = self.ssh.open_sftp()
if stat.S_ISDIR(ftp.st... | [
"def",
"remove",
"(",
"self",
",",
"remote_path",
")",
":",
"# Based on the remote file stats; remove a file or directory recursively",
"ftp",
"=",
"self",
".",
"ssh",
".",
"open_sftp",
"(",
")",
"if",
"stat",
".",
"S_ISDIR",
"(",
"ftp",
".",
"stat",
"(",
"remot... | Delete a file or directory recursively on the remote server
:param remote_path: Remote path to remove | [
"Delete",
"a",
"file",
"or",
"directory",
"recursively",
"on",
"the",
"remote",
"server"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L328-L340 | train |
riptano/ccm | ccmlib/remote.py | SSHClient.__remove_dir | def __remove_dir(self, ftp, remote_path):
"""
Helper function to perform delete operation on the remote server
:param ftp: SFTP handle to perform delete operation(s)
:param remote_path: Remote path to remove
"""
# Iterate over the remote path and perform remove operation... | python | def __remove_dir(self, ftp, remote_path):
"""
Helper function to perform delete operation on the remote server
:param ftp: SFTP handle to perform delete operation(s)
:param remote_path: Remote path to remove
"""
# Iterate over the remote path and perform remove operation... | [
"def",
"__remove_dir",
"(",
"self",
",",
"ftp",
",",
"remote_path",
")",
":",
"# Iterate over the remote path and perform remove operations",
"files",
"=",
"ftp",
".",
"listdir",
"(",
"remote_path",
")",
"for",
"filename",
"in",
"files",
":",
"# Attempt to remove the ... | Helper function to perform delete operation on the remote server
:param ftp: SFTP handle to perform delete operation(s)
:param remote_path: Remote path to remove | [
"Helper",
"function",
"to",
"perform",
"delete",
"operation",
"on",
"the",
"remote",
"server"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L342-L360 | train |
riptano/ccm | ccmlib/remote.py | RemoteOptionsParser.usage | def usage(self):
"""
Get the usage for the remote exectuion options
:return Usage for the remote execution options
"""
# Retrieve the text for just the arguments
usage = self.parser.format_help().split("optional arguments:")[1]
# Remove any blank lines and retur... | python | def usage(self):
"""
Get the usage for the remote exectuion options
:return Usage for the remote execution options
"""
# Retrieve the text for just the arguments
usage = self.parser.format_help().split("optional arguments:")[1]
# Remove any blank lines and retur... | [
"def",
"usage",
"(",
"self",
")",
":",
"# Retrieve the text for just the arguments",
"usage",
"=",
"self",
".",
"parser",
".",
"format_help",
"(",
")",
".",
"split",
"(",
"\"optional arguments:\"",
")",
"[",
"1",
"]",
"# Remove any blank lines and return",
"return",... | Get the usage for the remote exectuion options
:return Usage for the remote execution options | [
"Get",
"the",
"usage",
"for",
"the",
"remote",
"exectuion",
"options"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L490-L501 | train |
mattupstate/flask-jwt | flask_jwt/__init__.py | jwt_required | def jwt_required(realm=None):
"""View decorator that requires a valid JWT token to be present in the request
:param realm: an optional realm
"""
def wrapper(fn):
@wraps(fn)
def decorator(*args, **kwargs):
_jwt_required(realm or current_app.config['JWT_DEFAULT_REALM'])
... | python | def jwt_required(realm=None):
"""View decorator that requires a valid JWT token to be present in the request
:param realm: an optional realm
"""
def wrapper(fn):
@wraps(fn)
def decorator(*args, **kwargs):
_jwt_required(realm or current_app.config['JWT_DEFAULT_REALM'])
... | [
"def",
"jwt_required",
"(",
"realm",
"=",
"None",
")",
":",
"def",
"wrapper",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"decorator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"_jwt_required",
"(",
"realm",
"or",
"current_... | View decorator that requires a valid JWT token to be present in the request
:param realm: an optional realm | [
"View",
"decorator",
"that",
"requires",
"a",
"valid",
"JWT",
"token",
"to",
"be",
"present",
"in",
"the",
"request"
] | c27084114e258863b82753fc574a362cd6c62fcd | https://github.com/mattupstate/flask-jwt/blob/c27084114e258863b82753fc574a362cd6c62fcd/flask_jwt/__init__.py#L168-L179 | train |
mattupstate/flask-jwt | flask_jwt/__init__.py | JWT.auth_request_handler | def auth_request_handler(self, callback):
"""Specifies the authentication response handler function.
:param callable callback: the auth request handler function
.. deprecated
"""
warnings.warn("This handler is deprecated. The recommended approach to have control over "
... | python | def auth_request_handler(self, callback):
"""Specifies the authentication response handler function.
:param callable callback: the auth request handler function
.. deprecated
"""
warnings.warn("This handler is deprecated. The recommended approach to have control over "
... | [
"def",
"auth_request_handler",
"(",
"self",
",",
"callback",
")",
":",
"warnings",
".",
"warn",
"(",
"\"This handler is deprecated. The recommended approach to have control over \"",
"\"the authentication resource is to disable the built-in resource by \"",
"\"setting JWT_AUTH_URL_RULE=... | Specifies the authentication response handler function.
:param callable callback: the auth request handler function
.. deprecated | [
"Specifies",
"the",
"authentication",
"response",
"handler",
"function",
"."
] | c27084114e258863b82753fc574a362cd6c62fcd | https://github.com/mattupstate/flask-jwt/blob/c27084114e258863b82753fc574a362cd6c62fcd/flask_jwt/__init__.py#L294-L306 | train |
jwass/mplleaflet | mplleaflet/leaflet_renderer.py | LeafletRenderer._svg_path | def _svg_path(self, pathcodes, data):
"""
Return the SVG path's 'd' element.
"""
def gen_path_elements(pathcodes, data):
counts = {'M': 1, 'L': 1, 'C': 3, 'Z': 0}
it = iter(data)
for code in pathcodes:
yield code
for _ ... | python | def _svg_path(self, pathcodes, data):
"""
Return the SVG path's 'd' element.
"""
def gen_path_elements(pathcodes, data):
counts = {'M': 1, 'L': 1, 'C': 3, 'Z': 0}
it = iter(data)
for code in pathcodes:
yield code
for _ ... | [
"def",
"_svg_path",
"(",
"self",
",",
"pathcodes",
",",
"data",
")",
":",
"def",
"gen_path_elements",
"(",
"pathcodes",
",",
"data",
")",
":",
"counts",
"=",
"{",
"'M'",
":",
"1",
",",
"'L'",
":",
"1",
",",
"'C'",
":",
"3",
",",
"'Z'",
":",
"0",
... | Return the SVG path's 'd' element. | [
"Return",
"the",
"SVG",
"path",
"s",
"d",
"element",
"."
] | a83d7b69c56d5507dd7c17f5be377d23a31e84ab | https://github.com/jwass/mplleaflet/blob/a83d7b69c56d5507dd7c17f5be377d23a31e84ab/mplleaflet/leaflet_renderer.py#L69-L84 | train |
jwass/mplleaflet | mplleaflet/_display.py | fig_to_html | def fig_to_html(fig=None, template='base.html', tiles=None, crs=None,
epsg=None, embed_links=False, float_precision=6):
"""
Convert a Matplotlib Figure to a Leaflet map
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
template : string, def... | python | def fig_to_html(fig=None, template='base.html', tiles=None, crs=None,
epsg=None, embed_links=False, float_precision=6):
"""
Convert a Matplotlib Figure to a Leaflet map
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
template : string, def... | [
"def",
"fig_to_html",
"(",
"fig",
"=",
"None",
",",
"template",
"=",
"'base.html'",
",",
"tiles",
"=",
"None",
",",
"crs",
"=",
"None",
",",
"epsg",
"=",
"None",
",",
"embed_links",
"=",
"False",
",",
"float_precision",
"=",
"6",
")",
":",
"if",
"til... | Convert a Matplotlib Figure to a Leaflet map
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
template : string, default 'base.html'
The Jinja2 template to use
tiles : string or tuple
The tiles argument is used to control the map tile source in... | [
"Convert",
"a",
"Matplotlib",
"Figure",
"to",
"a",
"Leaflet",
"map"
] | a83d7b69c56d5507dd7c17f5be377d23a31e84ab | https://github.com/jwass/mplleaflet/blob/a83d7b69c56d5507dd7c17f5be377d23a31e84ab/mplleaflet/_display.py#L27-L107 | train |
jwass/mplleaflet | mplleaflet/_display.py | fig_to_geojson | def fig_to_geojson(fig=None, **kwargs):
"""
Returns a figure's GeoJSON representation as a dictionary
All arguments passed to fig_to_html()
Returns
-------
GeoJSON dictionary
"""
if fig is None:
fig = plt.gcf()
renderer = LeafletRenderer(**kwargs)
exporter = Exporter(r... | python | def fig_to_geojson(fig=None, **kwargs):
"""
Returns a figure's GeoJSON representation as a dictionary
All arguments passed to fig_to_html()
Returns
-------
GeoJSON dictionary
"""
if fig is None:
fig = plt.gcf()
renderer = LeafletRenderer(**kwargs)
exporter = Exporter(r... | [
"def",
"fig_to_geojson",
"(",
"fig",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"fig",
"is",
"None",
":",
"fig",
"=",
"plt",
".",
"gcf",
"(",
")",
"renderer",
"=",
"LeafletRenderer",
"(",
"*",
"*",
"kwargs",
")",
"exporter",
"=",
"Export... | Returns a figure's GeoJSON representation as a dictionary
All arguments passed to fig_to_html()
Returns
-------
GeoJSON dictionary | [
"Returns",
"a",
"figure",
"s",
"GeoJSON",
"representation",
"as",
"a",
"dictionary"
] | a83d7b69c56d5507dd7c17f5be377d23a31e84ab | https://github.com/jwass/mplleaflet/blob/a83d7b69c56d5507dd7c17f5be377d23a31e84ab/mplleaflet/_display.py#L110-L127 | train |
jwass/mplleaflet | mplleaflet/_display.py | display | def display(fig=None, closefig=True, **kwargs):
"""
Convert a Matplotlib Figure to a Leaflet map. Embed in IPython notebook.
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
closefig : boolean, default True
Close the current Figure
"""
from... | python | def display(fig=None, closefig=True, **kwargs):
"""
Convert a Matplotlib Figure to a Leaflet map. Embed in IPython notebook.
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
closefig : boolean, default True
Close the current Figure
"""
from... | [
"def",
"display",
"(",
"fig",
"=",
"None",
",",
"closefig",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"IPython",
".",
"display",
"import",
"HTML",
"if",
"fig",
"is",
"None",
":",
"fig",
"=",
"plt",
".",
"gcf",
"(",
")",
"if",
"close... | Convert a Matplotlib Figure to a Leaflet map. Embed in IPython notebook.
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
closefig : boolean, default True
Close the current Figure | [
"Convert",
"a",
"Matplotlib",
"Figure",
"to",
"a",
"Leaflet",
"map",
".",
"Embed",
"in",
"IPython",
"notebook",
"."
] | a83d7b69c56d5507dd7c17f5be377d23a31e84ab | https://github.com/jwass/mplleaflet/blob/a83d7b69c56d5507dd7c17f5be377d23a31e84ab/mplleaflet/_display.py#L140-L165 | train |
jwass/mplleaflet | mplleaflet/_display.py | show | def show(fig=None, path='_map.html', **kwargs):
"""
Convert a Matplotlib Figure to a Leaflet map. Open in a browser
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
path : string, default '_map.html'
Filename where output html will be saved
Se... | python | def show(fig=None, path='_map.html', **kwargs):
"""
Convert a Matplotlib Figure to a Leaflet map. Open in a browser
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
path : string, default '_map.html'
Filename where output html will be saved
Se... | [
"def",
"show",
"(",
"fig",
"=",
"None",
",",
"path",
"=",
"'_map.html'",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"webbrowser",
"fullpath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
"with",
"open",
"(",
"fullpath",
",",
"'w'",
"... | Convert a Matplotlib Figure to a Leaflet map. Open in a browser
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
path : string, default '_map.html'
Filename where output html will be saved
See fig_to_html() for description of keyword args. | [
"Convert",
"a",
"Matplotlib",
"Figure",
"to",
"a",
"Leaflet",
"map",
".",
"Open",
"in",
"a",
"browser"
] | a83d7b69c56d5507dd7c17f5be377d23a31e84ab | https://github.com/jwass/mplleaflet/blob/a83d7b69c56d5507dd7c17f5be377d23a31e84ab/mplleaflet/_display.py#L167-L185 | train |
dmsimard/python-cachetclient | contrib/sensu-cachet.py | create_incident | def create_incident(**kwargs):
"""
Creates an incident
"""
incidents = cachet.Incidents(endpoint=ENDPOINT, api_token=API_TOKEN)
if 'component_id' in kwargs:
return incidents.post(name=kwargs['name'],
message=kwargs['message'],
statu... | python | def create_incident(**kwargs):
"""
Creates an incident
"""
incidents = cachet.Incidents(endpoint=ENDPOINT, api_token=API_TOKEN)
if 'component_id' in kwargs:
return incidents.post(name=kwargs['name'],
message=kwargs['message'],
statu... | [
"def",
"create_incident",
"(",
"*",
"*",
"kwargs",
")",
":",
"incidents",
"=",
"cachet",
".",
"Incidents",
"(",
"endpoint",
"=",
"ENDPOINT",
",",
"api_token",
"=",
"API_TOKEN",
")",
"if",
"'component_id'",
"in",
"kwargs",
":",
"return",
"incidents",
".",
"... | Creates an incident | [
"Creates",
"an",
"incident"
] | 31bbc6d17ba5de088846e1ffae259b6755e672a0 | https://github.com/dmsimard/python-cachetclient/blob/31bbc6d17ba5de088846e1ffae259b6755e672a0/contrib/sensu-cachet.py#L110-L124 | train |
dmsimard/python-cachetclient | contrib/sensu-cachet.py | incident_exists | def incident_exists(name, message, status):
"""
Check if an incident with these attributes already exists
"""
incidents = cachet.Incidents(endpoint=ENDPOINT)
all_incidents = json.loads(incidents.get())
for incident in all_incidents['data']:
if name == incident['name'] and \
st... | python | def incident_exists(name, message, status):
"""
Check if an incident with these attributes already exists
"""
incidents = cachet.Incidents(endpoint=ENDPOINT)
all_incidents = json.loads(incidents.get())
for incident in all_incidents['data']:
if name == incident['name'] and \
st... | [
"def",
"incident_exists",
"(",
"name",
",",
"message",
",",
"status",
")",
":",
"incidents",
"=",
"cachet",
".",
"Incidents",
"(",
"endpoint",
"=",
"ENDPOINT",
")",
"all_incidents",
"=",
"json",
".",
"loads",
"(",
"incidents",
".",
"get",
"(",
")",
")",
... | Check if an incident with these attributes already exists | [
"Check",
"if",
"an",
"incident",
"with",
"these",
"attributes",
"already",
"exists"
] | 31bbc6d17ba5de088846e1ffae259b6755e672a0 | https://github.com/dmsimard/python-cachetclient/blob/31bbc6d17ba5de088846e1ffae259b6755e672a0/contrib/sensu-cachet.py#L127-L138 | train |
dmsimard/python-cachetclient | contrib/sensu-cachet.py | get_component | def get_component(id):
"""
Gets a Cachet component by id
"""
components = cachet.Components(endpoint=ENDPOINT)
component = json.loads(components.get(id=id))
return component['data'] | python | def get_component(id):
"""
Gets a Cachet component by id
"""
components = cachet.Components(endpoint=ENDPOINT)
component = json.loads(components.get(id=id))
return component['data'] | [
"def",
"get_component",
"(",
"id",
")",
":",
"components",
"=",
"cachet",
".",
"Components",
"(",
"endpoint",
"=",
"ENDPOINT",
")",
"component",
"=",
"json",
".",
"loads",
"(",
"components",
".",
"get",
"(",
"id",
"=",
"id",
")",
")",
"return",
"compon... | Gets a Cachet component by id | [
"Gets",
"a",
"Cachet",
"component",
"by",
"id"
] | 31bbc6d17ba5de088846e1ffae259b6755e672a0 | https://github.com/dmsimard/python-cachetclient/blob/31bbc6d17ba5de088846e1ffae259b6755e672a0/contrib/sensu-cachet.py#L141-L147 | train |
dmsimard/python-cachetclient | cachetclient/cachet.py | api_token_required | def api_token_required(f, *args, **kwargs):
"""
Decorator helper function to ensure some methods aren't needlessly called
without an api_token configured.
"""
try:
if args[0].api_token is None:
raise AttributeError('Parameter api_token is required.')
except AttributeError:
... | python | def api_token_required(f, *args, **kwargs):
"""
Decorator helper function to ensure some methods aren't needlessly called
without an api_token configured.
"""
try:
if args[0].api_token is None:
raise AttributeError('Parameter api_token is required.')
except AttributeError:
... | [
"def",
"api_token_required",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"if",
"args",
"[",
"0",
"]",
".",
"api_token",
"is",
"None",
":",
"raise",
"AttributeError",
"(",
"'Parameter api_token is required.'",
")",
"except",
... | Decorator helper function to ensure some methods aren't needlessly called
without an api_token configured. | [
"Decorator",
"helper",
"function",
"to",
"ensure",
"some",
"methods",
"aren",
"t",
"needlessly",
"called",
"without",
"an",
"api_token",
"configured",
"."
] | 31bbc6d17ba5de088846e1ffae259b6755e672a0 | https://github.com/dmsimard/python-cachetclient/blob/31bbc6d17ba5de088846e1ffae259b6755e672a0/cachetclient/cachet.py#L23-L34 | train |
robdmc/behold | behold/logger.py | Behold.is_true | def is_true(self, item=None):
"""
If you are filtering on object values, you need to pass that object here.
"""
if item:
values = [item]
else:
values = []
self._get_item_and_att_names(*values)
return self._passes_all | python | def is_true(self, item=None):
"""
If you are filtering on object values, you need to pass that object here.
"""
if item:
values = [item]
else:
values = []
self._get_item_and_att_names(*values)
return self._passes_all | [
"def",
"is_true",
"(",
"self",
",",
"item",
"=",
"None",
")",
":",
"if",
"item",
":",
"values",
"=",
"[",
"item",
"]",
"else",
":",
"values",
"=",
"[",
"]",
"self",
".",
"_get_item_and_att_names",
"(",
"*",
"values",
")",
"return",
"self",
".",
"_p... | If you are filtering on object values, you need to pass that object here. | [
"If",
"you",
"are",
"filtering",
"on",
"object",
"values",
"you",
"need",
"to",
"pass",
"that",
"object",
"here",
"."
] | ac1b7707e2d7472a50d837dda78be1e23af8fce5 | https://github.com/robdmc/behold/blob/ac1b7707e2d7472a50d837dda78be1e23af8fce5/behold/logger.py#L519-L528 | train |
chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | WebPage.new_from_url | def new_from_url(cls, url, verify=True):
"""
Constructs a new WebPage object for the URL,
using the `requests` module to fetch the HTML.
Parameters
----------
url : str
verify: bool
"""
response = requests.get(url, verify=verify, timeout=2.5)
... | python | def new_from_url(cls, url, verify=True):
"""
Constructs a new WebPage object for the URL,
using the `requests` module to fetch the HTML.
Parameters
----------
url : str
verify: bool
"""
response = requests.get(url, verify=verify, timeout=2.5)
... | [
"def",
"new_from_url",
"(",
"cls",
",",
"url",
",",
"verify",
"=",
"True",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"verify",
"=",
"verify",
",",
"timeout",
"=",
"2.5",
")",
"return",
"cls",
".",
"new_from_response",
"(",
"... | Constructs a new WebPage object for the URL,
using the `requests` module to fetch the HTML.
Parameters
----------
url : str
verify: bool | [
"Constructs",
"a",
"new",
"WebPage",
"object",
"for",
"the",
"URL",
"using",
"the",
"requests",
"module",
"to",
"fetch",
"the",
"HTML",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L66-L78 | train |
chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | WebPage.new_from_response | def new_from_response(cls, response):
"""
Constructs a new WebPage object for the response,
using the `BeautifulSoup` module to parse the HTML.
Parameters
----------
response : requests.Response object
"""
return cls(response.url, html=response.text, hea... | python | def new_from_response(cls, response):
"""
Constructs a new WebPage object for the response,
using the `BeautifulSoup` module to parse the HTML.
Parameters
----------
response : requests.Response object
"""
return cls(response.url, html=response.text, hea... | [
"def",
"new_from_response",
"(",
"cls",
",",
"response",
")",
":",
"return",
"cls",
"(",
"response",
".",
"url",
",",
"html",
"=",
"response",
".",
"text",
",",
"headers",
"=",
"response",
".",
"headers",
")"
] | Constructs a new WebPage object for the response,
using the `BeautifulSoup` module to parse the HTML.
Parameters
----------
response : requests.Response object | [
"Constructs",
"a",
"new",
"WebPage",
"object",
"for",
"the",
"response",
"using",
"the",
"BeautifulSoup",
"module",
"to",
"parse",
"the",
"HTML",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L81-L91 | train |
chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | Wappalyzer._prepare_app | def _prepare_app(self, app):
"""
Normalize app data, preparing it for the detection phase.
"""
# Ensure these keys' values are lists
for key in ['url', 'html', 'script', 'implies']:
try:
value = app[key]
except KeyError:
ap... | python | def _prepare_app(self, app):
"""
Normalize app data, preparing it for the detection phase.
"""
# Ensure these keys' values are lists
for key in ['url', 'html', 'script', 'implies']:
try:
value = app[key]
except KeyError:
ap... | [
"def",
"_prepare_app",
"(",
"self",
",",
"app",
")",
":",
"# Ensure these keys' values are lists",
"for",
"key",
"in",
"[",
"'url'",
",",
"'html'",
",",
"'script'",
",",
"'implies'",
"]",
":",
"try",
":",
"value",
"=",
"app",
"[",
"key",
"]",
"except",
"... | Normalize app data, preparing it for the detection phase. | [
"Normalize",
"app",
"data",
"preparing",
"it",
"for",
"the",
"detection",
"phase",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L131-L170 | train |
chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | Wappalyzer._has_app | def _has_app(self, app, webpage):
"""
Determine whether the web page matches the app signature.
"""
# Search the easiest things first and save the full-text search of the
# HTML for last
for regex in app['url']:
if regex.search(webpage.url):
r... | python | def _has_app(self, app, webpage):
"""
Determine whether the web page matches the app signature.
"""
# Search the easiest things first and save the full-text search of the
# HTML for last
for regex in app['url']:
if regex.search(webpage.url):
r... | [
"def",
"_has_app",
"(",
"self",
",",
"app",
",",
"webpage",
")",
":",
"# Search the easiest things first and save the full-text search of the",
"# HTML for last",
"for",
"regex",
"in",
"app",
"[",
"'url'",
"]",
":",
"if",
"regex",
".",
"search",
"(",
"webpage",
".... | Determine whether the web page matches the app signature. | [
"Determine",
"whether",
"the",
"web",
"page",
"matches",
"the",
"app",
"signature",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L189-L219 | train |
chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | Wappalyzer._get_implied_apps | def _get_implied_apps(self, detected_apps):
"""
Get the set of apps implied by `detected_apps`.
"""
def __get_implied_apps(apps):
_implied_apps = set()
for app in apps:
try:
_implied_apps.update(set(self.apps[app]['implies']))
... | python | def _get_implied_apps(self, detected_apps):
"""
Get the set of apps implied by `detected_apps`.
"""
def __get_implied_apps(apps):
_implied_apps = set()
for app in apps:
try:
_implied_apps.update(set(self.apps[app]['implies']))
... | [
"def",
"_get_implied_apps",
"(",
"self",
",",
"detected_apps",
")",
":",
"def",
"__get_implied_apps",
"(",
"apps",
")",
":",
"_implied_apps",
"=",
"set",
"(",
")",
"for",
"app",
"in",
"apps",
":",
"try",
":",
"_implied_apps",
".",
"update",
"(",
"set",
"... | Get the set of apps implied by `detected_apps`. | [
"Get",
"the",
"set",
"of",
"apps",
"implied",
"by",
"detected_apps",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L221-L242 | train |
chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | Wappalyzer.get_categories | def get_categories(self, app_name):
"""
Returns a list of the categories for an app name.
"""
cat_nums = self.apps.get(app_name, {}).get("cats", [])
cat_names = [self.categories.get("%s" % cat_num, "")
for cat_num in cat_nums]
return cat_names | python | def get_categories(self, app_name):
"""
Returns a list of the categories for an app name.
"""
cat_nums = self.apps.get(app_name, {}).get("cats", [])
cat_names = [self.categories.get("%s" % cat_num, "")
for cat_num in cat_nums]
return cat_names | [
"def",
"get_categories",
"(",
"self",
",",
"app_name",
")",
":",
"cat_nums",
"=",
"self",
".",
"apps",
".",
"get",
"(",
"app_name",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"cats\"",
",",
"[",
"]",
")",
"cat_names",
"=",
"[",
"self",
".",
"categories... | Returns a list of the categories for an app name. | [
"Returns",
"a",
"list",
"of",
"the",
"categories",
"for",
"an",
"app",
"name",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L244-L252 | train |
chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | Wappalyzer.analyze | def analyze(self, webpage):
"""
Return a list of applications that can be detected on the web page.
"""
detected_apps = set()
for app_name, app in self.apps.items():
if self._has_app(app, webpage):
detected_apps.add(app_name)
detected_apps |=... | python | def analyze(self, webpage):
"""
Return a list of applications that can be detected on the web page.
"""
detected_apps = set()
for app_name, app in self.apps.items():
if self._has_app(app, webpage):
detected_apps.add(app_name)
detected_apps |=... | [
"def",
"analyze",
"(",
"self",
",",
"webpage",
")",
":",
"detected_apps",
"=",
"set",
"(",
")",
"for",
"app_name",
",",
"app",
"in",
"self",
".",
"apps",
".",
"items",
"(",
")",
":",
"if",
"self",
".",
"_has_app",
"(",
"app",
",",
"webpage",
")",
... | Return a list of applications that can be detected on the web page. | [
"Return",
"a",
"list",
"of",
"applications",
"that",
"can",
"be",
"detected",
"on",
"the",
"web",
"page",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L254-L266 | train |
chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | Wappalyzer.analyze_with_categories | def analyze_with_categories(self, webpage):
"""
Return a list of applications and categories that can be detected on the web page.
"""
detected_apps = self.analyze(webpage)
categorised_apps = {}
for app_name in detected_apps:
cat_names = self.get_categories(a... | python | def analyze_with_categories(self, webpage):
"""
Return a list of applications and categories that can be detected on the web page.
"""
detected_apps = self.analyze(webpage)
categorised_apps = {}
for app_name in detected_apps:
cat_names = self.get_categories(a... | [
"def",
"analyze_with_categories",
"(",
"self",
",",
"webpage",
")",
":",
"detected_apps",
"=",
"self",
".",
"analyze",
"(",
"webpage",
")",
"categorised_apps",
"=",
"{",
"}",
"for",
"app_name",
"in",
"detected_apps",
":",
"cat_names",
"=",
"self",
".",
"get_... | Return a list of applications and categories that can be detected on the web page. | [
"Return",
"a",
"list",
"of",
"applications",
"and",
"categories",
"that",
"can",
"be",
"detected",
"on",
"the",
"web",
"page",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L268-L279 | train |
user-cont/conu | conu/utils/filesystem.py | Directory.clean | def clean(self):
"""
remove the directory we operated on
:return: None
"""
if self._initialized:
logger.info("brace yourselves, removing %r", self.path)
shutil.rmtree(self.path) | python | def clean(self):
"""
remove the directory we operated on
:return: None
"""
if self._initialized:
logger.info("brace yourselves, removing %r", self.path)
shutil.rmtree(self.path) | [
"def",
"clean",
"(",
"self",
")",
":",
"if",
"self",
".",
"_initialized",
":",
"logger",
".",
"info",
"(",
"\"brace yourselves, removing %r\"",
",",
"self",
".",
"path",
")",
"shutil",
".",
"rmtree",
"(",
"self",
".",
"path",
")"
] | remove the directory we operated on
:return: None | [
"remove",
"the",
"directory",
"we",
"operated",
"on"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/filesystem.py#L121-L129 | train |
user-cont/conu | conu/utils/filesystem.py | Directory.initialize | def initialize(self):
"""
create the directory if needed and configure it
:return: None
"""
if not self._initialized:
logger.info("initializing %r", self)
if not os.path.exists(self.path):
if self.mode is not None:
os.m... | python | def initialize(self):
"""
create the directory if needed and configure it
:return: None
"""
if not self._initialized:
logger.info("initializing %r", self)
if not os.path.exists(self.path):
if self.mode is not None:
os.m... | [
"def",
"initialize",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_initialized",
":",
"logger",
".",
"info",
"(",
"\"initializing %r\"",
",",
"self",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"if",
... | create the directory if needed and configure it
:return: None | [
"create",
"the",
"directory",
"if",
"needed",
"and",
"configure",
"it"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/filesystem.py#L131-L151 | train |
user-cont/conu | conu/utils/filesystem.py | Directory._set_selinux_context | def _set_selinux_context(self):
"""
Set SELinux context or fields using chcon program. Raises CommandDoesNotExistException
if the command is not present on the system.
:return: None
"""
chcon_command_exists()
# FIXME: do this using python API if possible
... | python | def _set_selinux_context(self):
"""
Set SELinux context or fields using chcon program. Raises CommandDoesNotExistException
if the command is not present on the system.
:return: None
"""
chcon_command_exists()
# FIXME: do this using python API if possible
... | [
"def",
"_set_selinux_context",
"(",
"self",
")",
":",
"chcon_command_exists",
"(",
")",
"# FIXME: do this using python API if possible",
"if",
"self",
".",
"selinux_context",
":",
"logger",
".",
"debug",
"(",
"\"setting SELinux context of %s to %s\"",
",",
"self",
".",
... | Set SELinux context or fields using chcon program. Raises CommandDoesNotExistException
if the command is not present on the system.
:return: None | [
"Set",
"SELinux",
"context",
"or",
"fields",
"using",
"chcon",
"program",
".",
"Raises",
"CommandDoesNotExistException",
"if",
"the",
"command",
"is",
"not",
"present",
"on",
"the",
"system",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/filesystem.py#L153-L175 | train |
user-cont/conu | conu/utils/filesystem.py | Directory._set_mode | def _set_mode(self):
"""
set permission bits if needed using python API os.chmod
:return: None
"""
if self.mode is not None:
logger.debug("changing permission bits of %s to %s", self.path, oct(self.mode))
os.chmod(self.path, self.mode) | python | def _set_mode(self):
"""
set permission bits if needed using python API os.chmod
:return: None
"""
if self.mode is not None:
logger.debug("changing permission bits of %s to %s", self.path, oct(self.mode))
os.chmod(self.path, self.mode) | [
"def",
"_set_mode",
"(",
"self",
")",
":",
"if",
"self",
".",
"mode",
"is",
"not",
"None",
":",
"logger",
".",
"debug",
"(",
"\"changing permission bits of %s to %s\"",
",",
"self",
".",
"path",
",",
"oct",
"(",
"self",
".",
"mode",
")",
")",
"os",
"."... | set permission bits if needed using python API os.chmod
:return: None | [
"set",
"permission",
"bits",
"if",
"needed",
"using",
"python",
"API",
"os",
".",
"chmod"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/filesystem.py#L192-L200 | train |
user-cont/conu | conu/utils/filesystem.py | Directory._add_facl_rules | def _add_facl_rules(self):
"""
Apply ACL rules on the directory using setfacl program. Raises CommandDoesNotExistException
if the command is not present on the system.
:return: None
"""
setfacl_command_exists()
# we are not using pylibacl b/c it's only for python... | python | def _add_facl_rules(self):
"""
Apply ACL rules on the directory using setfacl program. Raises CommandDoesNotExistException
if the command is not present on the system.
:return: None
"""
setfacl_command_exists()
# we are not using pylibacl b/c it's only for python... | [
"def",
"_add_facl_rules",
"(",
"self",
")",
":",
"setfacl_command_exists",
"(",
")",
"# we are not using pylibacl b/c it's only for python 2",
"if",
"self",
".",
"facl_rules",
":",
"logger",
".",
"debug",
"(",
"\"adding ACLs %s to %s\"",
",",
"self",
".",
"facl_rules",
... | Apply ACL rules on the directory using setfacl program. Raises CommandDoesNotExistException
if the command is not present on the system.
:return: None | [
"Apply",
"ACL",
"rules",
"on",
"the",
"directory",
"using",
"setfacl",
"program",
".",
"Raises",
"CommandDoesNotExistException",
"if",
"the",
"command",
"is",
"not",
"present",
"on",
"the",
"system",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/filesystem.py#L202-L214 | train |
user-cont/conu | conu/backend/podman/image.py | PodmanImage.get_volume_options | def get_volume_options(volumes):
"""
Generates volume options to run methods.
:param volumes: tuple or list of tuples in form target x source,target x source,target,mode.
:return: list of the form ["-v", "/source:/target", "-v", "/other/source:/destination:z", ...]
"""
i... | python | def get_volume_options(volumes):
"""
Generates volume options to run methods.
:param volumes: tuple or list of tuples in form target x source,target x source,target,mode.
:return: list of the form ["-v", "/source:/target", "-v", "/other/source:/destination:z", ...]
"""
i... | [
"def",
"get_volume_options",
"(",
"volumes",
")",
":",
"if",
"not",
"isinstance",
"(",
"volumes",
",",
"list",
")",
":",
"volumes",
"=",
"[",
"volumes",
"]",
"volumes",
"=",
"[",
"Volume",
".",
"create_from_tuple",
"(",
"v",
")",
"for",
"v",
"in",
"vol... | Generates volume options to run methods.
:param volumes: tuple or list of tuples in form target x source,target x source,target,mode.
:return: list of the form ["-v", "/source:/target", "-v", "/other/source:/destination:z", ...] | [
"Generates",
"volume",
"options",
"to",
"run",
"methods",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/image.py#L367-L380 | train |
user-cont/conu | conu/backend/podman/image.py | PodmanImage.layers | def layers(self, rev=True):
"""
Get list of PodmanImage for every layer in image
:param rev: get layers rev
:return: list of :class:`conu.PodmanImage`
"""
image_layers = [
PodmanImage(None, identifier=x, pull_policy=PodmanImagePullPolicy.NEVER)
fo... | python | def layers(self, rev=True):
"""
Get list of PodmanImage for every layer in image
:param rev: get layers rev
:return: list of :class:`conu.PodmanImage`
"""
image_layers = [
PodmanImage(None, identifier=x, pull_policy=PodmanImagePullPolicy.NEVER)
fo... | [
"def",
"layers",
"(",
"self",
",",
"rev",
"=",
"True",
")",
":",
"image_layers",
"=",
"[",
"PodmanImage",
"(",
"None",
",",
"identifier",
"=",
"x",
",",
"pull_policy",
"=",
"PodmanImagePullPolicy",
".",
"NEVER",
")",
"for",
"x",
"in",
"self",
".",
"get... | Get list of PodmanImage for every layer in image
:param rev: get layers rev
:return: list of :class:`conu.PodmanImage` | [
"Get",
"list",
"of",
"PodmanImage",
"for",
"every",
"layer",
"in",
"image"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/image.py#L395-L408 | train |
user-cont/conu | conu/backend/podman/image.py | PodmanImage.get_metadata | def get_metadata(self):
"""
Provide metadata about this image.
:return: ImageMetadata, Image metadata instance
"""
if self._metadata is None:
self._metadata = ImageMetadata()
inspect_to_metadata(self._metadata, self.inspect(refresh=True))
return self.... | python | def get_metadata(self):
"""
Provide metadata about this image.
:return: ImageMetadata, Image metadata instance
"""
if self._metadata is None:
self._metadata = ImageMetadata()
inspect_to_metadata(self._metadata, self.inspect(refresh=True))
return self.... | [
"def",
"get_metadata",
"(",
"self",
")",
":",
"if",
"self",
".",
"_metadata",
"is",
"None",
":",
"self",
".",
"_metadata",
"=",
"ImageMetadata",
"(",
")",
"inspect_to_metadata",
"(",
"self",
".",
"_metadata",
",",
"self",
".",
"inspect",
"(",
"refresh",
... | Provide metadata about this image.
:return: ImageMetadata, Image metadata instance | [
"Provide",
"metadata",
"about",
"this",
"image",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/image.py#L416-L425 | train |
user-cont/conu | conu/backend/podman/container.py | PodmanContainer.is_running | def is_running(self):
"""
returns True if the container is running
:return: bool
"""
try:
return graceful_get(self.inspect(refresh=True), "State", "Running")
except subprocess.CalledProcessError:
return False | python | def is_running(self):
"""
returns True if the container is running
:return: bool
"""
try:
return graceful_get(self.inspect(refresh=True), "State", "Running")
except subprocess.CalledProcessError:
return False | [
"def",
"is_running",
"(",
"self",
")",
":",
"try",
":",
"return",
"graceful_get",
"(",
"self",
".",
"inspect",
"(",
"refresh",
"=",
"True",
")",
",",
"\"State\"",
",",
"\"Running\"",
")",
"except",
"subprocess",
".",
"CalledProcessError",
":",
"return",
"F... | returns True if the container is running
:return: bool | [
"returns",
"True",
"if",
"the",
"container",
"is",
"running"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/container.py#L125-L134 | train |
user-cont/conu | conu/backend/podman/container.py | PodmanContainer.is_port_open | def is_port_open(self, port, timeout=2):
"""
check if given port is open and receiving connections on container ip_address
:param port: int, container port
:param timeout: int, how many seconds to wait for connection; defaults to 2
:return: True if the connection has been establ... | python | def is_port_open(self, port, timeout=2):
"""
check if given port is open and receiving connections on container ip_address
:param port: int, container port
:param timeout: int, how many seconds to wait for connection; defaults to 2
:return: True if the connection has been establ... | [
"def",
"is_port_open",
"(",
"self",
",",
"port",
",",
"timeout",
"=",
"2",
")",
":",
"addresses",
"=",
"self",
".",
"get_IPv4s",
"(",
")",
"if",
"not",
"addresses",
":",
"return",
"False",
"return",
"check_port",
"(",
"port",
",",
"host",
"=",
"address... | check if given port is open and receiving connections on container ip_address
:param port: int, container port
:param timeout: int, how many seconds to wait for connection; defaults to 2
:return: True if the connection has been established inside timeout, False otherwise | [
"check",
"if",
"given",
"port",
"is",
"open",
"and",
"receiving",
"connections",
"on",
"container",
"ip_address"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/container.py#L173-L184 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.