repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
manolomartinez/greg
greg/aux_functions.py
check_directory
def check_directory(placeholders): """ Find out, and create if needed, the directory in which the feed will be downloaded """ feed = placeholders.feed args = feed.args placeholders.directory = "This very directory" # wink, wink placeholders.fullpath = os.path.join( placeholders....
python
def check_directory(placeholders): """ Find out, and create if needed, the directory in which the feed will be downloaded """ feed = placeholders.feed args = feed.args placeholders.directory = "This very directory" # wink, wink placeholders.fullpath = os.path.join( placeholders....
[ "def", "check_directory", "(", "placeholders", ")", ":", "feed", "=", "placeholders", ".", "feed", "args", "=", "feed", ".", "args", "placeholders", ".", "directory", "=", "\"This very directory\"", "# wink, wink", "placeholders", ".", "fullpath", "=", "os", "."...
Find out, and create if needed, the directory in which the feed will be downloaded
[ "Find", "out", "and", "create", "if", "needed", "the", "directory", "in", "which", "the", "feed", "will", "be", "downloaded" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/aux_functions.py#L116-L147
manolomartinez/greg
greg/aux_functions.py
parse_for_download
def parse_for_download(args): """ Turn an argument such as 4, 6-8, 10 into a list such as [4,6,7,8,10] """ single_arg = "" # in the first bit we put all arguments # together and take out any extra spaces list_of_feeds = [] for arg in args["number"]: single_arg = ''.join([single_a...
python
def parse_for_download(args): """ Turn an argument such as 4, 6-8, 10 into a list such as [4,6,7,8,10] """ single_arg = "" # in the first bit we put all arguments # together and take out any extra spaces list_of_feeds = [] for arg in args["number"]: single_arg = ''.join([single_a...
[ "def", "parse_for_download", "(", "args", ")", ":", "single_arg", "=", "\"\"", "# in the first bit we put all arguments", "# together and take out any extra spaces", "list_of_feeds", "=", "[", "]", "for", "arg", "in", "args", "[", "\"number\"", "]", ":", "single_arg", ...
Turn an argument such as 4, 6-8, 10 into a list such as [4,6,7,8,10]
[ "Turn", "an", "argument", "such", "as", "4", "6", "-", "8", "10", "into", "a", "list", "such", "as", "[", "4", "6", "7", "8", "10", "]" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/aux_functions.py#L150-L168
manolomartinez/greg
greg/aux_functions.py
tag
def tag(placeholders): """ Tag the file at podpath with the information in podcast and entry """ # We first recover the name of the file to be tagged... template = placeholders.feed.retrieve_config("file_to_tag", "{filename}") filename = substitute_placeholders(template, placeholders) podpat...
python
def tag(placeholders): """ Tag the file at podpath with the information in podcast and entry """ # We first recover the name of the file to be tagged... template = placeholders.feed.retrieve_config("file_to_tag", "{filename}") filename = substitute_placeholders(template, placeholders) podpat...
[ "def", "tag", "(", "placeholders", ")", ":", "# We first recover the name of the file to be tagged...", "template", "=", "placeholders", ".", "feed", ".", "retrieve_config", "(", "\"file_to_tag\"", ",", "\"{filename}\"", ")", "filename", "=", "substitute_placeholders", "(...
Tag the file at podpath with the information in podcast and entry
[ "Tag", "the", "file", "at", "podpath", "with", "the", "information", "in", "podcast", "and", "entry" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/aux_functions.py#L171-L200
manolomartinez/greg
greg/aux_functions.py
download_handler
def download_handler(feed, placeholders): import shlex """ Parse and execute the download handler """ value = feed.retrieve_config('downloadhandler', 'greg') if value == 'greg': while os.path.isfile(placeholders.fullpath): placeholders.fullpath = placeholders.fullpath + '_' ...
python
def download_handler(feed, placeholders): import shlex """ Parse and execute the download handler """ value = feed.retrieve_config('downloadhandler', 'greg') if value == 'greg': while os.path.isfile(placeholders.fullpath): placeholders.fullpath = placeholders.fullpath + '_' ...
[ "def", "download_handler", "(", "feed", ",", "placeholders", ")", ":", "import", "shlex", "value", "=", "feed", ".", "retrieve_config", "(", "'downloadhandler'", ",", "'greg'", ")", "if", "value", "==", "'greg'", ":", "while", "os", ".", "path", ".", "isfi...
Parse and execute the download handler
[ "Parse", "and", "execute", "the", "download", "handler" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/aux_functions.py#L214-L231
manolomartinez/greg
greg/aux_functions.py
parse_feed_info
def parse_feed_info(infofile): """ Take a feed file in .local/share/greg/data and return a list of links and of dates """ entrylinks = [] linkdates = [] try: with open(infofile, 'r') as previous: for line in previous: entrylinks.append(line.split(sep=' ')[...
python
def parse_feed_info(infofile): """ Take a feed file in .local/share/greg/data and return a list of links and of dates """ entrylinks = [] linkdates = [] try: with open(infofile, 'r') as previous: for line in previous: entrylinks.append(line.split(sep=' ')[...
[ "def", "parse_feed_info", "(", "infofile", ")", ":", "entrylinks", "=", "[", "]", "linkdates", "=", "[", "]", "try", ":", "with", "open", "(", "infofile", ",", "'r'", ")", "as", "previous", ":", "for", "line", "in", "previous", ":", "entrylinks", ".", ...
Take a feed file in .local/share/greg/data and return a list of links and of dates
[ "Take", "a", "feed", "file", "in", ".", "local", "/", "share", "/", "greg", "/", "data", "and", "return", "a", "list", "of", "links", "and", "of", "dates" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/aux_functions.py#L234-L252
manolomartinez/greg
greg/aux_functions.py
pretty_print
def pretty_print(session, feed): """ Print the dictionary entry of a feed in a nice way. """ if feed in session.feeds: print() feed_info = os.path.join(session.data_dir, feed) entrylinks, linkdates = parse_feed_info(feed_info) print(feed) print("-"*len(feed)) ...
python
def pretty_print(session, feed): """ Print the dictionary entry of a feed in a nice way. """ if feed in session.feeds: print() feed_info = os.path.join(session.data_dir, feed) entrylinks, linkdates = parse_feed_info(feed_info) print(feed) print("-"*len(feed)) ...
[ "def", "pretty_print", "(", "session", ",", "feed", ")", ":", "if", "feed", "in", "session", ".", "feeds", ":", "print", "(", ")", "feed_info", "=", "os", ".", "path", ".", "join", "(", "session", ".", "data_dir", ",", "feed", ")", "entrylinks", ",",...
Print the dictionary entry of a feed in a nice way.
[ "Print", "the", "dictionary", "entry", "of", "a", "feed", "in", "a", "nice", "way", "." ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/aux_functions.py#L255-L271
manolomartinez/greg
greg/aux_functions.py
substitute_placeholders
def substitute_placeholders(inputstring, placeholders): """ Take a string with placeholders, and return the strings with substitutions. """ newst = inputstring.format(link=placeholders.link, filename=placeholders.filename, directory=placehold...
python
def substitute_placeholders(inputstring, placeholders): """ Take a string with placeholders, and return the strings with substitutions. """ newst = inputstring.format(link=placeholders.link, filename=placeholders.filename, directory=placehold...
[ "def", "substitute_placeholders", "(", "inputstring", ",", "placeholders", ")", ":", "newst", "=", "inputstring", ".", "format", "(", "link", "=", "placeholders", ".", "link", ",", "filename", "=", "placeholders", ".", "filename", ",", "directory", "=", "place...
Take a string with placeholders, and return the strings with substitutions.
[ "Take", "a", "string", "with", "placeholders", "and", "return", "the", "strings", "with", "substitutions", "." ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/aux_functions.py#L274-L291
bwesterb/py-tarjan
src/__init__.py
_tarjan_head
def _tarjan_head(ctx, v): """ Used by @tarjan and @tarjan_iter. This is the head of the main iteration """ ctx.index[v] = len(ctx.index) ctx.lowlink[v] = ctx.index[v] ctx.S.append(v) ctx.S_set.add(v) it = iter(ctx.g.get(v, ())) ctx.T.append((it,False,...
python
def _tarjan_head(ctx, v): """ Used by @tarjan and @tarjan_iter. This is the head of the main iteration """ ctx.index[v] = len(ctx.index) ctx.lowlink[v] = ctx.index[v] ctx.S.append(v) ctx.S_set.add(v) it = iter(ctx.g.get(v, ())) ctx.T.append((it,False,...
[ "def", "_tarjan_head", "(", "ctx", ",", "v", ")", ":", "ctx", ".", "index", "[", "v", "]", "=", "len", "(", "ctx", ".", "index", ")", "ctx", ".", "lowlink", "[", "v", "]", "=", "ctx", ".", "index", "[", "v", "]", "ctx", ".", "S", ".", "appe...
Used by @tarjan and @tarjan_iter. This is the head of the main iteration
[ "Used", "by" ]
train
https://github.com/bwesterb/py-tarjan/blob/60b0e3a1a7b925514fdce2ffbd84e1e246aba6d8/src/__init__.py#L18-L26
bwesterb/py-tarjan
src/__init__.py
_tarjan_body
def _tarjan_body(ctx, it, v): """ Used by @tarjan and @tarjan_iter. This is the body of the main iteration """ for w in it: if w not in ctx.index: ctx.T.append((it,True,v,w)) _tarjan_head(ctx, w) return ...
python
def _tarjan_body(ctx, it, v): """ Used by @tarjan and @tarjan_iter. This is the body of the main iteration """ for w in it: if w not in ctx.index: ctx.T.append((it,True,v,w)) _tarjan_head(ctx, w) return ...
[ "def", "_tarjan_body", "(", "ctx", ",", "it", ",", "v", ")", ":", "for", "w", "in", "it", ":", "if", "w", "not", "in", "ctx", ".", "index", ":", "ctx", ".", "T", ".", "append", "(", "(", "it", ",", "True", ",", "v", ",", "w", ")", ")", "_...
Used by @tarjan and @tarjan_iter. This is the body of the main iteration
[ "Used", "by" ]
train
https://github.com/bwesterb/py-tarjan/blob/60b0e3a1a7b925514fdce2ffbd84e1e246aba6d8/src/__init__.py#L28-L45
bwesterb/py-tarjan
src/__init__.py
tarjan_iter
def tarjan_iter(g): """ Returns the strongly connected components of the graph @g in a topological order. @g is the graph represented as a dictionary { <vertex> : <successors of vertex> }. This function does not recurse. It returns an iterator. ...
python
def tarjan_iter(g): """ Returns the strongly connected components of the graph @g in a topological order. @g is the graph represented as a dictionary { <vertex> : <successors of vertex> }. This function does not recurse. It returns an iterator. ...
[ "def", "tarjan_iter", "(", "g", ")", ":", "ctx", "=", "TarjanContext", "(", "g", "=", "g", ",", "S", "=", "[", "]", ",", "S_set", "=", "set", "(", ")", ",", "index", "=", "{", "}", ",", "lowlink", "=", "{", "}", ",", "T", "=", "[", "]", "...
Returns the strongly connected components of the graph @g in a topological order. @g is the graph represented as a dictionary { <vertex> : <successors of vertex> }. This function does not recurse. It returns an iterator.
[ "Returns", "the", "strongly", "connected", "components", "of", "the", "graph", "@g", "in", "a", "topological", "order", "." ]
train
https://github.com/bwesterb/py-tarjan/blob/60b0e3a1a7b925514fdce2ffbd84e1e246aba6d8/src/__init__.py#L47-L79
bwesterb/py-tarjan
src/__init__.py
tarjan_recursive
def tarjan_recursive(g): """ Returns the strongly connected components of the graph @g in a topological order. @g is the graph represented as a dictionary { <vertex> : <successors of vertex> }. This function recurses --- l...
python
def tarjan_recursive(g): """ Returns the strongly connected components of the graph @g in a topological order. @g is the graph represented as a dictionary { <vertex> : <successors of vertex> }. This function recurses --- l...
[ "def", "tarjan_recursive", "(", "g", ")", ":", "S", "=", "[", "]", "S_set", "=", "set", "(", ")", "index", "=", "{", "}", "lowlink", "=", "{", "}", "ret", "=", "[", "]", "def", "visit", "(", "v", ")", ":", "index", "[", "v", "]", "=", "len"...
Returns the strongly connected components of the graph @g in a topological order. @g is the graph represented as a dictionary { <vertex> : <successors of vertex> }. This function recurses --- large graphs may cause a stack ...
[ "Returns", "the", "strongly", "connected", "components", "of", "the", "graph", "@g", "in", "a", "topological", "order", "." ]
train
https://github.com/bwesterb/py-tarjan/blob/60b0e3a1a7b925514fdce2ffbd84e1e246aba6d8/src/__init__.py#L112-L150
mattjj/pylds
pylds/util.py
symm_block_tridiag_matmul
def symm_block_tridiag_matmul(H_diag, H_upper_diag, v): """ Compute matrix-vector product with a symmetric block tridiagonal matrix H and vector v. :param H_diag: block diagonal terms of H :param H_upper_diag: upper block diagonal terms of H :param v: vector to multipl...
python
def symm_block_tridiag_matmul(H_diag, H_upper_diag, v): """ Compute matrix-vector product with a symmetric block tridiagonal matrix H and vector v. :param H_diag: block diagonal terms of H :param H_upper_diag: upper block diagonal terms of H :param v: vector to multipl...
[ "def", "symm_block_tridiag_matmul", "(", "H_diag", ",", "H_upper_diag", ",", "v", ")", ":", "T", ",", "D", ",", "_", "=", "H_diag", ".", "shape", "assert", "H_diag", ".", "ndim", "==", "3", "and", "H_diag", ".", "shape", "[", "2", "]", "==", "D", "...
Compute matrix-vector product with a symmetric block tridiagonal matrix H and vector v. :param H_diag: block diagonal terms of H :param H_upper_diag: upper block diagonal terms of H :param v: vector to multiple :return: H * v
[ "Compute", "matrix", "-", "vector", "product", "with", "a", "symmetric", "block", "tridiagonal", "matrix", "H", "and", "vector", "v", "." ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/util.py#L21-L39
mattjj/pylds
pylds/util.py
convert_block_tridiag_to_banded
def convert_block_tridiag_to_banded(H_diag, H_upper_diag, lower=True): """ convert blocks to banded matrix representation required for scipy. we are using the "lower form." see https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.solveh_banded.html """ T, D, _ = H_diag.shape ass...
python
def convert_block_tridiag_to_banded(H_diag, H_upper_diag, lower=True): """ convert blocks to banded matrix representation required for scipy. we are using the "lower form." see https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.solveh_banded.html """ T, D, _ = H_diag.shape ass...
[ "def", "convert_block_tridiag_to_banded", "(", "H_diag", ",", "H_upper_diag", ",", "lower", "=", "True", ")", ":", "T", ",", "D", ",", "_", "=", "H_diag", ".", "shape", "assert", "H_diag", ".", "ndim", "==", "3", "and", "H_diag", ".", "shape", "[", "2"...
convert blocks to banded matrix representation required for scipy. we are using the "lower form." see https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.solveh_banded.html
[ "convert", "blocks", "to", "banded", "matrix", "representation", "required", "for", "scipy", ".", "we", "are", "using", "the", "lower", "form", ".", "see", "https", ":", "//", "docs", ".", "scipy", ".", "org", "/", "doc", "/", "scipy", "/", "reference", ...
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/util.py#L64-L101
mattjj/pylds
pylds/util.py
scipy_solve_symm_block_tridiag
def scipy_solve_symm_block_tridiag(H_diag, H_upper_diag, v, ab=None): """ use scipy.linalg.solve_banded to solve a symmetric block tridiagonal system see https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.solveh_banded.html """ from scipy.linalg import solveh_banded ab = convert_...
python
def scipy_solve_symm_block_tridiag(H_diag, H_upper_diag, v, ab=None): """ use scipy.linalg.solve_banded to solve a symmetric block tridiagonal system see https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.solveh_banded.html """ from scipy.linalg import solveh_banded ab = convert_...
[ "def", "scipy_solve_symm_block_tridiag", "(", "H_diag", ",", "H_upper_diag", ",", "v", ",", "ab", "=", "None", ")", ":", "from", "scipy", ".", "linalg", "import", "solveh_banded", "ab", "=", "convert_block_tridiag_to_banded", "(", "H_diag", ",", "H_upper_diag", ...
use scipy.linalg.solve_banded to solve a symmetric block tridiagonal system see https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.solveh_banded.html
[ "use", "scipy", ".", "linalg", ".", "solve_banded", "to", "solve", "a", "symmetric", "block", "tridiagonal", "system" ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/util.py#L114-L124
mattjj/pylds
pylds/util.py
sample_block_tridiag
def sample_block_tridiag(H_diag, H_upper_diag): """ helper function for sampling block tridiag gaussians. this is only for speed comparison with the solve approach. """ T, D, _ = H_diag.shape assert H_diag.ndim == 3 and H_diag.shape[2] == D assert H_upper_diag.shape == (T - 1, D, D) J_i...
python
def sample_block_tridiag(H_diag, H_upper_diag): """ helper function for sampling block tridiag gaussians. this is only for speed comparison with the solve approach. """ T, D, _ = H_diag.shape assert H_diag.ndim == 3 and H_diag.shape[2] == D assert H_upper_diag.shape == (T - 1, D, D) J_i...
[ "def", "sample_block_tridiag", "(", "H_diag", ",", "H_upper_diag", ")", ":", "T", ",", "D", ",", "_", "=", "H_diag", ".", "shape", "assert", "H_diag", ".", "ndim", "==", "3", "and", "H_diag", ".", "shape", "[", "2", "]", "==", "D", "assert", "H_upper...
helper function for sampling block tridiag gaussians. this is only for speed comparison with the solve approach.
[ "helper", "function", "for", "sampling", "block", "tridiag", "gaussians", ".", "this", "is", "only", "for", "speed", "comparison", "with", "the", "solve", "approach", "." ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/util.py#L141-L160
mattjj/pylds
pylds/util.py
logdet_symm_block_tridiag
def logdet_symm_block_tridiag(H_diag, H_upper_diag): """ compute the log determinant of a positive definite, symmetric block tridiag matrix. Use the Kalman info filter to do so. Specifically, the KF computes the normalizer: log Z = 1/2 h^T J^{-1} h -1/2 log |J| +n/2 log 2 \pi We set ...
python
def logdet_symm_block_tridiag(H_diag, H_upper_diag): """ compute the log determinant of a positive definite, symmetric block tridiag matrix. Use the Kalman info filter to do so. Specifically, the KF computes the normalizer: log Z = 1/2 h^T J^{-1} h -1/2 log |J| +n/2 log 2 \pi We set ...
[ "def", "logdet_symm_block_tridiag", "(", "H_diag", ",", "H_upper_diag", ")", ":", "T", ",", "D", ",", "_", "=", "H_diag", ".", "shape", "assert", "H_diag", ".", "ndim", "==", "3", "and", "H_diag", ".", "shape", "[", "2", "]", "==", "D", "assert", "H_...
compute the log determinant of a positive definite, symmetric block tridiag matrix. Use the Kalman info filter to do so. Specifically, the KF computes the normalizer: log Z = 1/2 h^T J^{-1} h -1/2 log |J| +n/2 log 2 \pi We set h=0 to get -1/2 log |J| + n/2 log 2 \pi and from this we solv...
[ "compute", "the", "log", "determinant", "of", "a", "positive", "definite", "symmetric", "block", "tridiag", "matrix", ".", "Use", "the", "Kalman", "info", "filter", "to", "do", "so", ".", "Specifically", "the", "KF", "computes", "the", "normalizer", ":" ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/util.py#L163-L196
mattjj/pylds
pylds/util.py
compute_symm_block_tridiag_covariances
def compute_symm_block_tridiag_covariances(H_diag, H_upper_diag): """ use the info smoother to solve a symmetric block tridiagonal system """ T, D, _ = H_diag.shape assert H_diag.ndim == 3 and H_diag.shape[2] == D assert H_upper_diag.shape == (T - 1, D, D) J_init = J_11 = J_22 = np.zeros((D...
python
def compute_symm_block_tridiag_covariances(H_diag, H_upper_diag): """ use the info smoother to solve a symmetric block tridiagonal system """ T, D, _ = H_diag.shape assert H_diag.ndim == 3 and H_diag.shape[2] == D assert H_upper_diag.shape == (T - 1, D, D) J_init = J_11 = J_22 = np.zeros((D...
[ "def", "compute_symm_block_tridiag_covariances", "(", "H_diag", ",", "H_upper_diag", ")", ":", "T", ",", "D", ",", "_", "=", "H_diag", ".", "shape", "assert", "H_diag", ".", "ndim", "==", "3", "and", "H_diag", ".", "shape", "[", "2", "]", "==", "D", "a...
use the info smoother to solve a symmetric block tridiagonal system
[ "use", "the", "info", "smoother", "to", "solve", "a", "symmetric", "block", "tridiagonal", "system" ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/util.py#L199-L218
mattjj/pylds
pylds/states.py
LDSStatesZeroInflatedCountData.resample_zeroinflation_variables
def resample_zeroinflation_variables(self): """ There's no way around the fact that we have to look at every data point, even the zeros here. """ # TODO: move this to cython? T, N, C, D, b = self.T, self.D_emission, self.C, self.D, self.emission_distn.b indptr = [...
python
def resample_zeroinflation_variables(self): """ There's no way around the fact that we have to look at every data point, even the zeros here. """ # TODO: move this to cython? T, N, C, D, b = self.T, self.D_emission, self.C, self.D, self.emission_distn.b indptr = [...
[ "def", "resample_zeroinflation_variables", "(", "self", ")", ":", "# TODO: move this to cython?", "T", ",", "N", ",", "C", ",", "D", ",", "b", "=", "self", ".", "T", ",", "self", ".", "D_emission", ",", "self", ".", "C", ",", "self", ".", "D", ",", "...
There's no way around the fact that we have to look at every data point, even the zeros here.
[ "There", "s", "no", "way", "around", "the", "fact", "that", "we", "have", "to", "look", "at", "every", "data", "point", "even", "the", "zeros", "here", "." ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/states.py#L905-L944
mattjj/pylds
pylds/distributions.py
PoissonRegression.expected_log_likelihood
def expected_log_likelihood(self, mus, sigmas, y): """ Compute the expected log likelihood for a mean and covariance of x and an observed value of y. """ # Flatten the covariance T = mus.shape[0] D = self.D_in sigs_vec = sigmas.reshape((T, D ** 2)) ...
python
def expected_log_likelihood(self, mus, sigmas, y): """ Compute the expected log likelihood for a mean and covariance of x and an observed value of y. """ # Flatten the covariance T = mus.shape[0] D = self.D_in sigs_vec = sigmas.reshape((T, D ** 2)) ...
[ "def", "expected_log_likelihood", "(", "self", ",", "mus", ",", "sigmas", ",", "y", ")", ":", "# Flatten the covariance", "T", "=", "mus", ".", "shape", "[", "0", "]", "D", "=", "self", ".", "D_in", "sigs_vec", "=", "sigmas", ".", "reshape", "(", "(", ...
Compute the expected log likelihood for a mean and covariance of x and an observed value of y.
[ "Compute", "the", "expected", "log", "likelihood", "for", "a", "mean", "and", "covariance", "of", "x", "and", "an", "observed", "value", "of", "y", "." ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/distributions.py#L55-L79
mattjj/pylds
pylds/distributions.py
BernoulliRegression.max_likelihood
def max_likelihood(self, data, weights=None, stats=None): """ Maximize the likelihood for given data :param data: :param weights: :param stats: :return: """ if isinstance(data, list): x = np.vstack([d[0] for d in data]) y = np.vstac...
python
def max_likelihood(self, data, weights=None, stats=None): """ Maximize the likelihood for given data :param data: :param weights: :param stats: :return: """ if isinstance(data, list): x = np.vstack([d[0] for d in data]) y = np.vstac...
[ "def", "max_likelihood", "(", "self", ",", "data", ",", "weights", "=", "None", ",", "stats", "=", "None", ")", ":", "if", "isinstance", "(", "data", ",", "list", ")", ":", "x", "=", "np", ".", "vstack", "(", "[", "d", "[", "0", "]", "for", "d"...
Maximize the likelihood for given data :param data: :param weights: :param stats: :return:
[ "Maximize", "the", "likelihood", "for", "given", "data", ":", "param", "data", ":", ":", "param", "weights", ":", ":", "param", "stats", ":", ":", "return", ":" ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/distributions.py#L204-L226
mattjj/pylds
pylds/laplace.py
_LaplaceApproxLDSStatesBase.log_conditional_likelihood
def log_conditional_likelihood(self, x): """ likelihood \sum_t log p(y_t | x_t) Optionally override this in base classes """ T, D = self.T, self.D_latent assert x.shape == (T, D) ll = 0 for t in range(self.T): ll += self.local_log_likelihood(x...
python
def log_conditional_likelihood(self, x): """ likelihood \sum_t log p(y_t | x_t) Optionally override this in base classes """ T, D = self.T, self.D_latent assert x.shape == (T, D) ll = 0 for t in range(self.T): ll += self.local_log_likelihood(x...
[ "def", "log_conditional_likelihood", "(", "self", ",", "x", ")", ":", "T", ",", "D", "=", "self", ".", "T", ",", "self", ".", "D_latent", "assert", "x", ".", "shape", "==", "(", "T", ",", "D", ")", "ll", "=", "0", "for", "t", "in", "range", "("...
likelihood \sum_t log p(y_t | x_t) Optionally override this in base classes
[ "likelihood", "\\", "sum_t", "log", "p", "(", "y_t", "|", "x_t", ")", "Optionally", "override", "this", "in", "base", "classes" ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/laplace.py#L26-L37
mattjj/pylds
pylds/laplace.py
_LaplaceApproxLDSStatesBase.grad_local_log_likelihood
def grad_local_log_likelihood(self, x): """ return d/dxt log p(yt | xt) evaluated at xt Optionally override this in base classes """ T, D = self.T, self.D_latent assert x.shape == (T, D) gfun = grad(self.local_log_likelihood) g = np.zeros((T, D)) ...
python
def grad_local_log_likelihood(self, x): """ return d/dxt log p(yt | xt) evaluated at xt Optionally override this in base classes """ T, D = self.T, self.D_latent assert x.shape == (T, D) gfun = grad(self.local_log_likelihood) g = np.zeros((T, D)) ...
[ "def", "grad_local_log_likelihood", "(", "self", ",", "x", ")", ":", "T", ",", "D", "=", "self", ".", "T", ",", "self", ".", "D_latent", "assert", "x", ".", "shape", "==", "(", "T", ",", "D", ")", "gfun", "=", "grad", "(", "self", ".", "local_log...
return d/dxt log p(yt | xt) evaluated at xt Optionally override this in base classes
[ "return", "d", "/", "dxt", "log", "p", "(", "yt", "|", "xt", ")", "evaluated", "at", "xt", "Optionally", "override", "this", "in", "base", "classes" ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/laplace.py#L39-L51
mattjj/pylds
pylds/laplace.py
_LaplaceApproxLDSStatesBase.hessian_local_log_likelihood
def hessian_local_log_likelihood(self, x): """ return d^2/dxt^2 log p(y | x) for each time bin Optionally override this in base classes """ T, D = self.T, self.D_latent assert x.shape == (T, D) hfun = hessian(self.local_log_likelihood) H_diag = np.zeros((...
python
def hessian_local_log_likelihood(self, x): """ return d^2/dxt^2 log p(y | x) for each time bin Optionally override this in base classes """ T, D = self.T, self.D_latent assert x.shape == (T, D) hfun = hessian(self.local_log_likelihood) H_diag = np.zeros((...
[ "def", "hessian_local_log_likelihood", "(", "self", ",", "x", ")", ":", "T", ",", "D", "=", "self", ".", "T", ",", "self", ".", "D_latent", "assert", "x", ".", "shape", "==", "(", "T", ",", "D", ")", "hfun", "=", "hessian", "(", "self", ".", "loc...
return d^2/dxt^2 log p(y | x) for each time bin Optionally override this in base classes
[ "return", "d^2", "/", "dxt^2", "log", "p", "(", "y", "|", "x", ")", "for", "each", "time", "bin", "Optionally", "override", "this", "in", "base", "classes" ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/laplace.py#L53-L65
mattjj/pylds
pylds/laplace.py
_LaplaceApproxLDSStatesBase.log_joint
def log_joint(self, x): """ Compute the log joint probability p(x, y) """ T, D = self.T, self.D_latent assert x.shape == (T, D) # prior log p(x) -- quadratic terms J_diag, J_upper_diag = self.sparse_J_prior lp = -0.5 * np.sum(x * symm_block_tridiag_matmul...
python
def log_joint(self, x): """ Compute the log joint probability p(x, y) """ T, D = self.T, self.D_latent assert x.shape == (T, D) # prior log p(x) -- quadratic terms J_diag, J_upper_diag = self.sparse_J_prior lp = -0.5 * np.sum(x * symm_block_tridiag_matmul...
[ "def", "log_joint", "(", "self", ",", "x", ")", ":", "T", ",", "D", "=", "self", ".", "T", ",", "self", ".", "D_latent", "assert", "x", ".", "shape", "==", "(", "T", ",", "D", ")", "# prior log p(x) -- quadratic terms", "J_diag", ",", "J_upper_diag", ...
Compute the log joint probability p(x, y)
[ "Compute", "the", "log", "joint", "probability", "p", "(", "x", "y", ")" ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/laplace.py#L82-L107
mattjj/pylds
pylds/laplace.py
_LaplaceApproxLDSStatesBase.sparse_hessian_log_joint
def sparse_hessian_log_joint(self, x): """ The Hessian includes the quadratic terms of the Gaussian LDS prior as well as the Hessian of the local log likelihood. """ T, D = self.T, self.D_latent assert x.shape == (T, D) # Collect the Gaussian LDS prior terms ...
python
def sparse_hessian_log_joint(self, x): """ The Hessian includes the quadratic terms of the Gaussian LDS prior as well as the Hessian of the local log likelihood. """ T, D = self.T, self.D_latent assert x.shape == (T, D) # Collect the Gaussian LDS prior terms ...
[ "def", "sparse_hessian_log_joint", "(", "self", ",", "x", ")", ":", "T", ",", "D", "=", "self", ".", "T", ",", "self", ".", "D_latent", "assert", "x", ".", "shape", "==", "(", "T", ",", "D", ")", "# Collect the Gaussian LDS prior terms", "J_diag", ",", ...
The Hessian includes the quadratic terms of the Gaussian LDS prior as well as the Hessian of the local log likelihood.
[ "The", "Hessian", "includes", "the", "quadratic", "terms", "of", "the", "Gaussian", "LDS", "prior", "as", "well", "as", "the", "Hessian", "of", "the", "local", "log", "likelihood", "." ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/laplace.py#L109-L127
mattjj/pylds
pylds/laplace.py
_LaplaceApproxLDSStatesBase.gradient_log_joint
def gradient_log_joint(self, x): """ The gradient of the log joint probability. For the Gaussian terms, this is d/dx [-1/2 x^T J x + h^T x] = -Jx + h. For the likelihood terms, we have for each time t d/dx log p(yt | xt) """ T, D = self.T, self...
python
def gradient_log_joint(self, x): """ The gradient of the log joint probability. For the Gaussian terms, this is d/dx [-1/2 x^T J x + h^T x] = -Jx + h. For the likelihood terms, we have for each time t d/dx log p(yt | xt) """ T, D = self.T, self...
[ "def", "gradient_log_joint", "(", "self", ",", "x", ")", ":", "T", ",", "D", "=", "self", ".", "T", ",", "self", ".", "D_latent", "assert", "x", ".", "shape", "==", "(", "T", ",", "D", ")", "# Collect the Gaussian LDS prior terms", "_", ",", "h_init", ...
The gradient of the log joint probability. For the Gaussian terms, this is d/dx [-1/2 x^T J x + h^T x] = -Jx + h. For the likelihood terms, we have for each time t d/dx log p(yt | xt)
[ "The", "gradient", "of", "the", "log", "joint", "probability", "." ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/laplace.py#L133-L162
mattjj/pylds
pylds/laplace.py
_LaplaceApproxLDSStatesBase._laplace_approximation_newton
def _laplace_approximation_newton(self, tol=1e-6, stepsz=0.9, verbose=False): """ Solve a block tridiagonal system with message passing. """ from pylds.util import solve_symm_block_tridiag, scipy_solve_symm_block_tridiag scale = self.T * self.D_emission def newton_step(x...
python
def _laplace_approximation_newton(self, tol=1e-6, stepsz=0.9, verbose=False): """ Solve a block tridiagonal system with message passing. """ from pylds.util import solve_symm_block_tridiag, scipy_solve_symm_block_tridiag scale = self.T * self.D_emission def newton_step(x...
[ "def", "_laplace_approximation_newton", "(", "self", ",", "tol", "=", "1e-6", ",", "stepsz", "=", "0.9", ",", "verbose", "=", "False", ")", ":", "from", "pylds", ".", "util", "import", "solve_symm_block_tridiag", ",", "scipy_solve_symm_block_tridiag", "scale", "...
Solve a block tridiagonal system with message passing.
[ "Solve", "a", "block", "tridiagonal", "system", "with", "message", "passing", "." ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/laplace.py#L212-L253
mattjj/pylds
pylds/laplace.py
LaplaceApproxPoissonLDSStates.grad_local_log_likelihood
def grad_local_log_likelihood(self, x): """ d/dx y^T Cx + y^T d - exp(Cx+d) = y^T C - exp(Cx+d)^T C = (y - lmbda)^T C """ # Observation likelihoods lmbda = np.exp(np.dot(x, self.C.T) + np.dot(self.inputs, self.D.T)) return (self.data - lmbda).dot(...
python
def grad_local_log_likelihood(self, x): """ d/dx y^T Cx + y^T d - exp(Cx+d) = y^T C - exp(Cx+d)^T C = (y - lmbda)^T C """ # Observation likelihoods lmbda = np.exp(np.dot(x, self.C.T) + np.dot(self.inputs, self.D.T)) return (self.data - lmbda).dot(...
[ "def", "grad_local_log_likelihood", "(", "self", ",", "x", ")", ":", "# Observation likelihoods", "lmbda", "=", "np", ".", "exp", "(", "np", ".", "dot", "(", "x", ",", "self", ".", "C", ".", "T", ")", "+", "np", ".", "dot", "(", "self", ".", "input...
d/dx y^T Cx + y^T d - exp(Cx+d) = y^T C - exp(Cx+d)^T C = (y - lmbda)^T C
[ "d", "/", "dx", "y^T", "Cx", "+", "y^T", "d", "-", "exp", "(", "Cx", "+", "d", ")", "=", "y^T", "C", "-", "exp", "(", "Cx", "+", "d", ")", "^T", "C", "=", "(", "y", "-", "lmbda", ")", "^T", "C" ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/laplace.py#L349-L357
mattjj/pylds
pylds/laplace.py
LaplaceApproxPoissonLDSStates.hessian_local_log_likelihood
def hessian_local_log_likelihood(self, x): """ d/dx (y - lmbda)^T C = d/dx -exp(Cx + d)^T C = -C^T exp(Cx + d)^T C """ # Observation likelihoods lmbda = np.exp(np.dot(x, self.C.T) + np.dot(self.inputs, self.D.T)) return np.einsum('tn, ni, nj ->tij', -lmbda, s...
python
def hessian_local_log_likelihood(self, x): """ d/dx (y - lmbda)^T C = d/dx -exp(Cx + d)^T C = -C^T exp(Cx + d)^T C """ # Observation likelihoods lmbda = np.exp(np.dot(x, self.C.T) + np.dot(self.inputs, self.D.T)) return np.einsum('tn, ni, nj ->tij', -lmbda, s...
[ "def", "hessian_local_log_likelihood", "(", "self", ",", "x", ")", ":", "# Observation likelihoods", "lmbda", "=", "np", ".", "exp", "(", "np", ".", "dot", "(", "x", ",", "self", ".", "C", ".", "T", ")", "+", "np", ".", "dot", "(", "self", ".", "in...
d/dx (y - lmbda)^T C = d/dx -exp(Cx + d)^T C = -C^T exp(Cx + d)^T C
[ "d", "/", "dx", "(", "y", "-", "lmbda", ")", "^T", "C", "=", "d", "/", "dx", "-", "exp", "(", "Cx", "+", "d", ")", "^T", "C", "=", "-", "C^T", "exp", "(", "Cx", "+", "d", ")", "^T", "C" ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/laplace.py#L359-L366
mattjj/pylds
pylds/laplace.py
LaplaceApproxBernoulliLDSStates.grad_local_log_likelihood
def grad_local_log_likelihood(self, x): """ d/d \psi y \psi - log (1 + exp(\psi)) = y - exp(\psi) / (1 + exp(\psi)) = y - sigma(psi) = y - p d \psi / dx = C d / dx = (y - sigma(psi)) * C """ C, D, u, y = self.C, self.D, self.inputs, ...
python
def grad_local_log_likelihood(self, x): """ d/d \psi y \psi - log (1 + exp(\psi)) = y - exp(\psi) / (1 + exp(\psi)) = y - sigma(psi) = y - p d \psi / dx = C d / dx = (y - sigma(psi)) * C """ C, D, u, y = self.C, self.D, self.inputs, ...
[ "def", "grad_local_log_likelihood", "(", "self", ",", "x", ")", ":", "C", ",", "D", ",", "u", ",", "y", "=", "self", ".", "C", ",", "self", ".", "D", ",", "self", ".", "inputs", ",", "self", ".", "data", "psi", "=", "x", ".", "dot", "(", "C",...
d/d \psi y \psi - log (1 + exp(\psi)) = y - exp(\psi) / (1 + exp(\psi)) = y - sigma(psi) = y - p d \psi / dx = C d / dx = (y - sigma(psi)) * C
[ "d", "/", "d", "\\", "psi", "y", "\\", "psi", "-", "log", "(", "1", "+", "exp", "(", "\\", "psi", "))", "=", "y", "-", "exp", "(", "\\", "psi", ")", "/", "(", "1", "+", "exp", "(", "\\", "psi", "))", "=", "y", "-", "sigma", "(", "psi", ...
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/laplace.py#L458-L472
mattjj/pylds
pylds/laplace.py
LaplaceApproxBernoulliLDSStates.hessian_local_log_likelihood
def hessian_local_log_likelihood(self, x): """ d/dx (y - p) * C = -dpsi/dx (dp/d\psi) C = -C p (1-p) C """ C, D, u, y = self.C, self.D, self.inputs, self.data psi = x.dot(C.T) + u.dot(D.T) p = 1. / (1 + np.exp(-psi)) dp_dpsi = p * (1 - p)...
python
def hessian_local_log_likelihood(self, x): """ d/dx (y - p) * C = -dpsi/dx (dp/d\psi) C = -C p (1-p) C """ C, D, u, y = self.C, self.D, self.inputs, self.data psi = x.dot(C.T) + u.dot(D.T) p = 1. / (1 + np.exp(-psi)) dp_dpsi = p * (1 - p)...
[ "def", "hessian_local_log_likelihood", "(", "self", ",", "x", ")", ":", "C", ",", "D", ",", "u", ",", "y", "=", "self", ".", "C", ",", "self", ".", "D", ",", "self", ".", "inputs", ",", "self", ".", "data", "psi", "=", "x", ".", "dot", "(", "...
d/dx (y - p) * C = -dpsi/dx (dp/d\psi) C = -C p (1-p) C
[ "d", "/", "dx", "(", "y", "-", "p", ")", "*", "C", "=", "-", "dpsi", "/", "dx", "(", "dp", "/", "d", "\\", "psi", ")", "C", "=", "-", "C", "p", "(", "1", "-", "p", ")", "C" ]
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/laplace.py#L474-L484
mattjj/pylds
pylds/models.py
ZeroInflatedCountLDS.resample_emission_distn
def resample_emission_distn(self): """ Now for the expensive part... the data is stored in a sparse row format, which is good for updating the latent states (since we primarily rely on dot products with the data, which can be efficiently performed for CSR matrices). Howe...
python
def resample_emission_distn(self): """ Now for the expensive part... the data is stored in a sparse row format, which is good for updating the latent states (since we primarily rely on dot products with the data, which can be efficiently performed for CSR matrices). Howe...
[ "def", "resample_emission_distn", "(", "self", ")", ":", "masked_datas", "=", "[", "s", ".", "masked_data", ".", "tocsc", "(", ")", "for", "s", "in", "self", ".", "states_list", "]", "xs", "=", "[", "np", ".", "hstack", "(", "(", "s", ".", "gaussian_...
Now for the expensive part... the data is stored in a sparse row format, which is good for updating the latent states (since we primarily rely on dot products with the data, which can be efficiently performed for CSR matrices). However, in order to update the n-th row of the emission ma...
[ "Now", "for", "the", "expensive", "part", "...", "the", "data", "is", "stored", "in", "a", "sparse", "row", "format", "which", "is", "good", "for", "updating", "the", "latent", "states", "(", "since", "we", "primarily", "rely", "on", "dot", "products", "...
train
https://github.com/mattjj/pylds/blob/e946bfa5aa76e8f8284614561a0f40ffd5d868fb/pylds/models.py#L434-L456
FirefighterBlu3/python-pam
pam.py
pam.authenticate
def authenticate(self, username, password, service='login', encoding='utf-8', resetcreds=True): """username and password authentication for the given service. Returns True for success, or False for failure. self.code (integer) and self.reason (string) are always stored and may ...
python
def authenticate(self, username, password, service='login', encoding='utf-8', resetcreds=True): """username and password authentication for the given service. Returns True for success, or False for failure. self.code (integer) and self.reason (string) are always stored and may ...
[ "def", "authenticate", "(", "self", ",", "username", ",", "password", ",", "service", "=", "'login'", ",", "encoding", "=", "'utf-8'", ",", "resetcreds", "=", "True", ")", ":", "@", "conv_func", "def", "my_conv", "(", "n_messages", ",", "messages", ",", ...
username and password authentication for the given service. Returns True for success, or False for failure. self.code (integer) and self.reason (string) are always stored and may be referenced for the reason why authentication failed. 0/'Success' will be stored for success....
[ "username", "and", "password", "authentication", "for", "the", "given", "service", "." ]
train
https://github.com/FirefighterBlu3/python-pam/blob/fe44b334970f421635d9e373b563c9e6566613bd/pam.py#L106-L191
cloudmesh/cloudmesh-common
cloudmesh/common/ssh/ssh_config.py
ssh_config.names
def names(self): """ The names defined in ~/.ssh/config :return: the names """ found_names = [] with open(self.filename) as f: content = f.readlines() for line in content: line = line.strip() if " " in line: attr...
python
def names(self): """ The names defined in ~/.ssh/config :return: the names """ found_names = [] with open(self.filename) as f: content = f.readlines() for line in content: line = line.strip() if " " in line: attr...
[ "def", "names", "(", "self", ")", ":", "found_names", "=", "[", "]", "with", "open", "(", "self", ".", "filename", ")", "as", "f", ":", "content", "=", "f", ".", "readlines", "(", ")", "for", "line", "in", "content", ":", "line", "=", "line", "."...
The names defined in ~/.ssh/config :return: the names
[ "The", "names", "defined", "in", "~", "/", ".", "ssh", "/", "config", ":", "return", ":", "the", "names" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ssh/ssh_config.py#L29-L45
cloudmesh/cloudmesh-common
cloudmesh/common/ssh/ssh_config.py
ssh_config.load
def load(self): """list the hosts defined in the ssh config file""" with open(self.filename) as f: content = f.readlines() content = [" ".join(x.split()).strip('\n').lstrip().split(' ', 1) for x in content] # removes duplicated spaces, and splits in two fields, removes leadi...
python
def load(self): """list the hosts defined in the ssh config file""" with open(self.filename) as f: content = f.readlines() content = [" ".join(x.split()).strip('\n').lstrip().split(' ', 1) for x in content] # removes duplicated spaces, and splits in two fields, removes leadi...
[ "def", "load", "(", "self", ")", ":", "with", "open", "(", "self", ".", "filename", ")", "as", "f", ":", "content", "=", "f", ".", "readlines", "(", ")", "content", "=", "[", "\" \"", ".", "join", "(", "x", ".", "split", "(", ")", ")", ".", "...
list the hosts defined in the ssh config file
[ "list", "the", "hosts", "defined", "in", "the", "ssh", "config", "file" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ssh/ssh_config.py#L48-L73
cloudmesh/cloudmesh-common
cloudmesh/common/ssh/ssh_config.py
ssh_config.execute
def execute(self, name, command): """ execute the command on the named host :param name: the name of the host in config :param command: the command to be executed :return: """ if name in ["localhost"]: r = '\n'.join(Shell.sh("-c", command).split()[-1:...
python
def execute(self, name, command): """ execute the command on the named host :param name: the name of the host in config :param command: the command to be executed :return: """ if name in ["localhost"]: r = '\n'.join(Shell.sh("-c", command).split()[-1:...
[ "def", "execute", "(", "self", ",", "name", ",", "command", ")", ":", "if", "name", "in", "[", "\"localhost\"", "]", ":", "r", "=", "'\\n'", ".", "join", "(", "Shell", ".", "sh", "(", "\"-c\"", ",", "command", ")", ".", "split", "(", ")", "[", ...
execute the command on the named host :param name: the name of the host in config :param command: the command to be executed :return:
[ "execute", "the", "command", "on", "the", "named", "host", ":", "param", "name", ":", "the", "name", "of", "the", "host", "in", "config", ":", "param", "command", ":", "the", "command", "to", "be", "executed", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ssh/ssh_config.py#L104-L115
cloudmesh/cloudmesh-common
cloudmesh/common/ssh/ssh_config.py
ssh_config.generate
def generate(self, key="india", host="india.futuresystems.org", username=None, force=False, verbose=False): """ adds a host to the config file with given parameters. #TODO: make sure this is better documented :...
python
def generate(self, key="india", host="india.futuresystems.org", username=None, force=False, verbose=False): """ adds a host to the config file with given parameters. #TODO: make sure this is better documented :...
[ "def", "generate", "(", "self", ",", "key", "=", "\"india\"", ",", "host", "=", "\"india.futuresystems.org\"", ",", "username", "=", "None", ",", "force", "=", "False", ",", "verbose", "=", "False", ")", ":", "data", "=", "{", "\"host\"", ":", "host", ...
adds a host to the config file with given parameters. #TODO: make sure this is better documented :param key: the key :param host: the host :param username: the username :param force: not used :param verbose: prints debug messages :return:
[ "adds", "a", "host", "to", "the", "config", "file", "with", "given", "parameters", ".", "#TODO", ":", "make", "sure", "this", "is", "better", "documented", ":", "param", "key", ":", "the", "key", ":", "param", "host", ":", "the", "host", ":", "param", ...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ssh/ssh_config.py#L136-L174
cloudmesh/cloudmesh-common
cloudmesh/common/logger.py
LOGGER
def LOGGER(filename): """creates a logger with the given name. You can use it as follows:: log = cloudmesh.common.LOGGER(__file__) log.error("this is an error") log.info("this is an info") log.warning("this is a warning") """ pwd = os.getcwd() name = filename.replace(p...
python
def LOGGER(filename): """creates a logger with the given name. You can use it as follows:: log = cloudmesh.common.LOGGER(__file__) log.error("this is an error") log.info("this is an info") log.warning("this is a warning") """ pwd = os.getcwd() name = filename.replace(p...
[ "def", "LOGGER", "(", "filename", ")", ":", "pwd", "=", "os", ".", "getcwd", "(", ")", "name", "=", "filename", ".", "replace", "(", "pwd", ",", "\"$PWD\"", ")", "try", ":", "(", "first", ",", "name", ")", "=", "name", ".", "split", "(", "\"site-...
creates a logger with the given name. You can use it as follows:: log = cloudmesh.common.LOGGER(__file__) log.error("this is an error") log.info("this is an info") log.warning("this is a warning")
[ "creates", "a", "logger", "with", "the", "given", "name", "." ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/logger.py#L12-L61
cloudmesh/cloudmesh-common
cloudmesh/common/FlatDict.py
key_prefix_replace
def key_prefix_replace(d, prefix, new_prefix=""): """ replaces the list of prefix in keys of a flattened dict :param d: the flattened dict :param prefix: a list of prefixes that are replaced with a new prefix. Typically this will be "" :type prefix: list of str :param new_pre...
python
def key_prefix_replace(d, prefix, new_prefix=""): """ replaces the list of prefix in keys of a flattened dict :param d: the flattened dict :param prefix: a list of prefixes that are replaced with a new prefix. Typically this will be "" :type prefix: list of str :param new_pre...
[ "def", "key_prefix_replace", "(", "d", ",", "prefix", ",", "new_prefix", "=", "\"\"", ")", ":", "items", "=", "[", "]", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", ":", "new_key", "=", "k", "for", "p", "in", "prefix", ":", "new_key",...
replaces the list of prefix in keys of a flattened dict :param d: the flattened dict :param prefix: a list of prefixes that are replaced with a new prefix. Typically this will be "" :type prefix: list of str :param new_prefix: The new prefix. By default it is set to "" :return: t...
[ "replaces", "the", "list", "of", "prefix", "in", "keys", "of", "a", "flattened", "dict" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/FlatDict.py#L14-L31
cloudmesh/cloudmesh-common
cloudmesh/common/FlatDict.py
flatten
def flatten(d, parent_key='', sep='__'): """ flattens the dict into a one dimensional dictionary :param d: multidimensional dict :param parent_key: replaces from the parent key :param sep: the separation character used when fattening. the default is __ :return: the flattened dict """ # ...
python
def flatten(d, parent_key='', sep='__'): """ flattens the dict into a one dimensional dictionary :param d: multidimensional dict :param parent_key: replaces from the parent key :param sep: the separation character used when fattening. the default is __ :return: the flattened dict """ # ...
[ "def", "flatten", "(", "d", ",", "parent_key", "=", "''", ",", "sep", "=", "'__'", ")", ":", "# http://stackoverflow.com/questions/6027558/flatten-nested-python-dictionaries-compressing-keys", "if", "type", "(", "d", ")", "==", "list", ":", "flat", "=", "[", "]", ...
flattens the dict into a one dimensional dictionary :param d: multidimensional dict :param parent_key: replaces from the parent key :param sep: the separation character used when fattening. the default is __ :return: the flattened dict
[ "flattens", "the", "dict", "into", "a", "one", "dimensional", "dictionary" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/FlatDict.py#L41-L67
cloudmesh/cloudmesh-common
cloudmesh/common/FlatDict.py
FlatDict2.convert
def convert(cls, obj, flatten=True): """ This function converts object into a Dict optionally Flattening it :param obj: Object to be converted :param flatten: boolean to specify if the dict has to be flattened :return dict: the dict of the object (Flattened or Un-...
python
def convert(cls, obj, flatten=True): """ This function converts object into a Dict optionally Flattening it :param obj: Object to be converted :param flatten: boolean to specify if the dict has to be flattened :return dict: the dict of the object (Flattened or Un-...
[ "def", "convert", "(", "cls", ",", "obj", ",", "flatten", "=", "True", ")", ":", "dict_result", "=", "cls", ".", "object_to_dict", "(", "obj", ")", "if", "flatten", ":", "dict_result", "=", "FlatDict", "(", "dict_result", ")", "return", "dict_result" ]
This function converts object into a Dict optionally Flattening it :param obj: Object to be converted :param flatten: boolean to specify if the dict has to be flattened :return dict: the dict of the object (Flattened or Un-flattened)
[ "This", "function", "converts", "object", "into", "a", "Dict", "optionally", "Flattening", "it", ":", "param", "obj", ":", "Object", "to", "be", "converted", ":", "param", "flatten", ":", "boolean", "to", "specify", "if", "the", "dict", "has", "to", "be", ...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/FlatDict.py#L143-L153
cloudmesh/cloudmesh-common
cloudmesh/common/FlatDict.py
FlatDict2.object_to_dict
def object_to_dict(cls, obj): """ This function converts Objects into Dictionary """ dict_obj = dict() if obj is not None: if type(obj) == list: dict_list = [] for inst in obj: dict_list.append(cls.object_to_dict...
python
def object_to_dict(cls, obj): """ This function converts Objects into Dictionary """ dict_obj = dict() if obj is not None: if type(obj) == list: dict_list = [] for inst in obj: dict_list.append(cls.object_to_dict...
[ "def", "object_to_dict", "(", "cls", ",", "obj", ")", ":", "dict_obj", "=", "dict", "(", ")", "if", "obj", "is", "not", "None", ":", "if", "type", "(", "obj", ")", "==", "list", ":", "dict_list", "=", "[", "]", "for", "inst", "in", "obj", ":", ...
This function converts Objects into Dictionary
[ "This", "function", "converts", "Objects", "into", "Dictionary" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/FlatDict.py#L156-L183
cloudmesh/cloudmesh-common
cloudmesh/common/error.py
Error.msg
def msg(cls, error=None, debug=True, trace=True): """ prints the error message :param error: the error message :param debug: only prints it if debug is set to true :param trace: if true prints the trace :return: """ if debug and error is not None: ...
python
def msg(cls, error=None, debug=True, trace=True): """ prints the error message :param error: the error message :param debug: only prints it if debug is set to true :param trace: if true prints the trace :return: """ if debug and error is not None: ...
[ "def", "msg", "(", "cls", ",", "error", "=", "None", ",", "debug", "=", "True", ",", "trace", "=", "True", ")", ":", "if", "debug", "and", "error", "is", "not", "None", ":", "print", "(", "error", ")", "# TODO: BUG: trace should only be printed if debug is...
prints the error message :param error: the error message :param debug: only prints it if debug is set to true :param trace: if true prints the trace :return:
[ "prints", "the", "error", "message", ":", "param", "error", ":", "the", "error", "message", ":", "param", "debug", ":", "only", "prints", "it", "if", "debug", "is", "set", "to", "true", ":", "param", "trace", ":", "if", "true", "prints", "the", "trace"...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/error.py#L20-L32
cloudmesh/cloudmesh-common
cloudmesh/common/error.py
Error.traceback
def traceback(cls, error=None, debug=True, trace=True): """ prints the trace :param error: a message preceding the trace :param debug: prints it if debug is set to true :param trace: :return: """ # TODO: if debug: Error.msg(error=error, debug=deb...
python
def traceback(cls, error=None, debug=True, trace=True): """ prints the trace :param error: a message preceding the trace :param debug: prints it if debug is set to true :param trace: :return: """ # TODO: if debug: Error.msg(error=error, debug=deb...
[ "def", "traceback", "(", "cls", ",", "error", "=", "None", ",", "debug", "=", "True", ",", "trace", "=", "True", ")", ":", "# TODO: if debug:", "Error", ".", "msg", "(", "error", "=", "error", ",", "debug", "=", "debug", ",", "trace", "=", "trace", ...
prints the trace :param error: a message preceding the trace :param debug: prints it if debug is set to true :param trace: :return:
[ "prints", "the", "trace", ":", "param", "error", ":", "a", "message", "preceding", "the", "trace", ":", "param", "debug", ":", "prints", "it", "if", "debug", "is", "set", "to", "true", ":", "param", "trace", ":", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/error.py#L35-L44
cloudmesh/cloudmesh-common
cloudmesh/common/console.py
indent
def indent(text, indent=2, width=128): """ indents the given text by the indent specified and wrapping to the given width :param text: the text to print :param indent: indent characters :param width: the width of the text :return: """ return "\n".join( textwrap.wrap(text, ...
python
def indent(text, indent=2, width=128): """ indents the given text by the indent specified and wrapping to the given width :param text: the text to print :param indent: indent characters :param width: the width of the text :return: """ return "\n".join( textwrap.wrap(text, ...
[ "def", "indent", "(", "text", ",", "indent", "=", "2", ",", "width", "=", "128", ")", ":", "return", "\"\\n\"", ".", "join", "(", "textwrap", ".", "wrap", "(", "text", ",", "width", "=", "width", ",", "initial_indent", "=", "\" \"", "*", "indent", ...
indents the given text by the indent specified and wrapping to the given width :param text: the text to print :param indent: indent characters :param width: the width of the text :return:
[ "indents", "the", "given", "text", "by", "the", "indent", "specified", "and", "wrapping", "to", "the", "given", "width", ":", "param", "text", ":", "the", "text", "to", "print", ":", "param", "indent", ":", "indent", "characters", ":", "param", "width", ...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/console.py#L15-L28
cloudmesh/cloudmesh-common
cloudmesh/common/console.py
Console.set_theme
def set_theme(color=True): """ defines if the console messages are printed in color :param color: if True its printed in color :return: """ if color: Console.theme = Console.theme_color else: Console.theme = Console.theme_bw Consol...
python
def set_theme(color=True): """ defines if the console messages are printed in color :param color: if True its printed in color :return: """ if color: Console.theme = Console.theme_color else: Console.theme = Console.theme_bw Consol...
[ "def", "set_theme", "(", "color", "=", "True", ")", ":", "if", "color", ":", "Console", ".", "theme", "=", "Console", ".", "theme_color", "else", ":", "Console", ".", "theme", "=", "Console", ".", "theme_bw", "Console", ".", "color", "=", "color" ]
defines if the console messages are printed in color :param color: if True its printed in color :return:
[ "defines", "if", "the", "console", "messages", "are", "printed", "in", "color", ":", "param", "color", ":", "if", "True", "its", "printed", "in", "color", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/console.py#L100-L110
cloudmesh/cloudmesh-common
cloudmesh/common/console.py
Console.error
def error(cls, message, prefix=True, traceflag=False): """ prints an error message :param message: the message :param prefix: a prefix for the message :param traceflag: if true the stack trace is retrieved and printed :return: """ # print (message, prefix...
python
def error(cls, message, prefix=True, traceflag=False): """ prints an error message :param message: the message :param prefix: a prefix for the message :param traceflag: if true the stack trace is retrieved and printed :return: """ # print (message, prefix...
[ "def", "error", "(", "cls", ",", "message", ",", "prefix", "=", "True", ",", "traceflag", "=", "False", ")", ":", "# print (message, prefix)", "message", "=", "message", "or", "\"\"", "if", "prefix", ":", "text", "=", "\"ERROR: \"", "else", ":", "text", ...
prints an error message :param message: the message :param prefix: a prefix for the message :param traceflag: if true the stack trace is retrieved and printed :return:
[ "prints", "an", "error", "message", ":", "param", "message", ":", "the", "message", ":", "param", "prefix", ":", "a", "prefix", "for", "the", "message", ":", "param", "traceflag", ":", "if", "true", "the", "stack", "trace", "is", "retrieved", "and", "pri...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/console.py#L145-L170
cloudmesh/cloudmesh-common
cloudmesh/common/console.py
Console.TODO
def TODO(message, prefix=True, traceflag=True): """ prints an TODO message :param message: the message :param prefix: if set to true it prints TODO: as prefix :param traceflag: if true the stack trace is retrieved and printed :return: """ message = messag...
python
def TODO(message, prefix=True, traceflag=True): """ prints an TODO message :param message: the message :param prefix: if set to true it prints TODO: as prefix :param traceflag: if true the stack trace is retrieved and printed :return: """ message = messag...
[ "def", "TODO", "(", "message", ",", "prefix", "=", "True", ",", "traceflag", "=", "True", ")", ":", "message", "=", "message", "or", "\"\"", "if", "prefix", ":", "text", "=", "\"TODO: \"", "else", ":", "text", "=", "\"\"", "if", "Console", ".", "colo...
prints an TODO message :param message: the message :param prefix: if set to true it prints TODO: as prefix :param traceflag: if true the stack trace is retrieved and printed :return:
[ "prints", "an", "TODO", "message", ":", "param", "message", ":", "the", "message", ":", "param", "prefix", ":", "if", "set", "to", "true", "it", "prints", "TODO", ":", "as", "prefix", ":", "param", "traceflag", ":", "if", "true", "the", "stack", "trace...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/console.py#L173-L196
cloudmesh/cloudmesh-common
cloudmesh/common/console.py
Console.debug_msg
def debug_msg(message): """ print a debug message :param message: the message :return: """ message = message or "" if Console.color: Console.cprint('RED', 'DEBUG: ', message) else: print(Console.msg('DEBUG: ' + message))
python
def debug_msg(message): """ print a debug message :param message: the message :return: """ message = message or "" if Console.color: Console.cprint('RED', 'DEBUG: ', message) else: print(Console.msg('DEBUG: ' + message))
[ "def", "debug_msg", "(", "message", ")", ":", "message", "=", "message", "or", "\"\"", "if", "Console", ".", "color", ":", "Console", ".", "cprint", "(", "'RED'", ",", "'DEBUG: '", ",", "message", ")", "else", ":", "print", "(", "Console", ".", "msg", ...
print a debug message :param message: the message :return:
[ "print", "a", "debug", "message", ":", "param", "message", ":", "the", "message", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/console.py#L199-L209
cloudmesh/cloudmesh-common
cloudmesh/common/console.py
Console.info
def info(message): """ prints an informational message :param message: the message :return: """ message = message or "" if Console.color: Console.cprint('OKBLUE', "INFO: ", message) else: print(Console.msg("INFO: " + message))
python
def info(message): """ prints an informational message :param message: the message :return: """ message = message or "" if Console.color: Console.cprint('OKBLUE', "INFO: ", message) else: print(Console.msg("INFO: " + message))
[ "def", "info", "(", "message", ")", ":", "message", "=", "message", "or", "\"\"", "if", "Console", ".", "color", ":", "Console", ".", "cprint", "(", "'OKBLUE'", ",", "\"INFO: \"", ",", "message", ")", "else", ":", "print", "(", "Console", ".", "msg", ...
prints an informational message :param message: the message :return:
[ "prints", "an", "informational", "message", ":", "param", "message", ":", "the", "message", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/console.py#L212-L222
cloudmesh/cloudmesh-common
cloudmesh/common/console.py
Console.warning
def warning(message): """ prints a warning :param message: the message :return: """ message = message or "" if Console.color: Console.cprint('WARNING', "WARNING: ", message) else: print(Console.msg("WARNING: " + message))
python
def warning(message): """ prints a warning :param message: the message :return: """ message = message or "" if Console.color: Console.cprint('WARNING', "WARNING: ", message) else: print(Console.msg("WARNING: " + message))
[ "def", "warning", "(", "message", ")", ":", "message", "=", "message", "or", "\"\"", "if", "Console", ".", "color", ":", "Console", ".", "cprint", "(", "'WARNING'", ",", "\"WARNING: \"", ",", "message", ")", "else", ":", "print", "(", "Console", ".", "...
prints a warning :param message: the message :return:
[ "prints", "a", "warning", ":", "param", "message", ":", "the", "message", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/console.py#L225-L235
cloudmesh/cloudmesh-common
cloudmesh/common/console.py
Console.ok
def ok(message): """ prints an ok message :param message: the message< :return: """ message = message or "" if Console.color: Console.cprint('OKGREEN', "", message) else: print(Console.msg(message))
python
def ok(message): """ prints an ok message :param message: the message< :return: """ message = message or "" if Console.color: Console.cprint('OKGREEN', "", message) else: print(Console.msg(message))
[ "def", "ok", "(", "message", ")", ":", "message", "=", "message", "or", "\"\"", "if", "Console", ".", "color", ":", "Console", ".", "cprint", "(", "'OKGREEN'", ",", "\"\"", ",", "message", ")", "else", ":", "print", "(", "Console", ".", "msg", "(", ...
prints an ok message :param message: the message< :return:
[ "prints", "an", "ok", "message", ":", "param", "message", ":", "the", "message<", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/console.py#L238-L248
cloudmesh/cloudmesh-common
cloudmesh/common/console.py
Console.cprint
def cprint(color, prefix, message): """ prints a message in a given color :param color: the color as defined in the theme :param prefix: the prefix (a string) :param message: the message :return: """ message = message or "" prefix = prefix or "" ...
python
def cprint(color, prefix, message): """ prints a message in a given color :param color: the color as defined in the theme :param prefix: the prefix (a string) :param message: the message :return: """ message = message or "" prefix = prefix or "" ...
[ "def", "cprint", "(", "color", ",", "prefix", ",", "message", ")", ":", "message", "=", "message", "or", "\"\"", "prefix", "=", "prefix", "or", "\"\"", "print", "(", "(", "Console", ".", "theme", "[", "color", "]", "+", "prefix", "+", "message", "+",...
prints a message in a given color :param color: the color as defined in the theme :param prefix: the prefix (a string) :param message: the message :return:
[ "prints", "a", "message", "in", "a", "given", "color", ":", "param", "color", ":", "the", "color", "as", "defined", "in", "the", "theme", ":", "param", "prefix", ":", "the", "prefix", "(", "a", "string", ")", ":", "param", "message", ":", "the", "mes...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/console.py#L251-L264
cloudmesh/cloudmesh-common
cloudmesh/common/StopWatch.py
StopWatch.start
def start(cls, name): """ starts a timer with the given name. :param name: the name of the timer :type name: string """ if cls.debug: print("Timer", name, "started ...") cls.timer_start[name] = time.time()
python
def start(cls, name): """ starts a timer with the given name. :param name: the name of the timer :type name: string """ if cls.debug: print("Timer", name, "started ...") cls.timer_start[name] = time.time()
[ "def", "start", "(", "cls", ",", "name", ")", ":", "if", "cls", ".", "debug", ":", "print", "(", "\"Timer\"", ",", "name", ",", "\"started ...\"", ")", "cls", ".", "timer_start", "[", "name", "]", "=", "time", ".", "time", "(", ")" ]
starts a timer with the given name. :param name: the name of the timer :type name: string
[ "starts", "a", "timer", "with", "the", "given", "name", "." ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/StopWatch.py#L33-L42
cloudmesh/cloudmesh-common
cloudmesh/common/StopWatch.py
StopWatch.stop
def stop(cls, name): """ stops the timer with a given name. :param name: the name of the timer :type name: string """ cls.timer_end[name] = time.time() if cls.debug: print("Timer", name, "stopped ...")
python
def stop(cls, name): """ stops the timer with a given name. :param name: the name of the timer :type name: string """ cls.timer_end[name] = time.time() if cls.debug: print("Timer", name, "stopped ...")
[ "def", "stop", "(", "cls", ",", "name", ")", ":", "cls", ".", "timer_end", "[", "name", "]", "=", "time", ".", "time", "(", ")", "if", "cls", ".", "debug", ":", "print", "(", "\"Timer\"", ",", "name", ",", "\"stopped ...\"", ")" ]
stops the timer with a given name. :param name: the name of the timer :type name: string
[ "stops", "the", "timer", "with", "a", "given", "name", "." ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/StopWatch.py#L45-L54
cloudmesh/cloudmesh-common
cloudmesh/common/StopWatch.py
StopWatch.get
def get(cls, name): """ returns the time of the timer. :param name: the name of the timer :type name: string :rtype: the elapsed time """ if name in cls.timer_end: cls.timer_elapsed[name] = cls.timer_end[name] - \ ...
python
def get(cls, name): """ returns the time of the timer. :param name: the name of the timer :type name: string :rtype: the elapsed time """ if name in cls.timer_end: cls.timer_elapsed[name] = cls.timer_end[name] - \ ...
[ "def", "get", "(", "cls", ",", "name", ")", ":", "if", "name", "in", "cls", ".", "timer_end", ":", "cls", ".", "timer_elapsed", "[", "name", "]", "=", "cls", ".", "timer_end", "[", "name", "]", "-", "cls", ".", "timer_start", "[", "name", "]", "r...
returns the time of the timer. :param name: the name of the timer :type name: string :rtype: the elapsed time
[ "returns", "the", "time", "of", "the", "timer", "." ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/StopWatch.py#L57-L70
cloudmesh/cloudmesh-common
cloudmesh/common/StopWatch.py
StopWatch.print
def print(cls, *args): """ prints a timer. The first argument is the label if it exists, the last is the timer :param args: label, name :return: """ if cls.verbose: if len(args) == 2: print(args[0], str("{0:.2f}".format(cls.get(args[1]))), "s...
python
def print(cls, *args): """ prints a timer. The first argument is the label if it exists, the last is the timer :param args: label, name :return: """ if cls.verbose: if len(args) == 2: print(args[0], str("{0:.2f}".format(cls.get(args[1]))), "s...
[ "def", "print", "(", "cls", ",", "*", "args", ")", ":", "if", "cls", ".", "verbose", ":", "if", "len", "(", "args", ")", "==", "2", ":", "print", "(", "args", "[", "0", "]", ",", "str", "(", "\"{0:.2f}\"", ".", "format", "(", "cls", ".", "get...
prints a timer. The first argument is the label if it exists, the last is the timer :param args: label, name :return:
[ "prints", "a", "timer", ".", "The", "first", "argument", "is", "the", "label", "if", "it", "exists", "the", "last", "is", "the", "timer", ":", "param", "args", ":", "label", "name", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/StopWatch.py#L81-L91
cloudmesh/cloudmesh-common
cloudmesh/common/StopWatch.py
StopWatch.benchmark
def benchmark(cls, sysinfo=True): """ prints out all timers in a convenient benchmark tabble :return: :rtype: """ # # PRINT PLATFORM # if sysinfo: data_platform = systeminfo() print(Printer.attribute(data_platform, ...
python
def benchmark(cls, sysinfo=True): """ prints out all timers in a convenient benchmark tabble :return: :rtype: """ # # PRINT PLATFORM # if sysinfo: data_platform = systeminfo() print(Printer.attribute(data_platform, ...
[ "def", "benchmark", "(", "cls", ",", "sysinfo", "=", "True", ")", ":", "#", "# PRINT PLATFORM", "#", "if", "sysinfo", ":", "data_platform", "=", "systeminfo", "(", ")", "print", "(", "Printer", ".", "attribute", "(", "data_platform", ",", "[", "\"Machine A...
prints out all timers in a convenient benchmark tabble :return: :rtype:
[ "prints", "out", "all", "timers", "in", "a", "convenient", "benchmark", "tabble", ":", "return", ":", ":", "rtype", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/StopWatch.py#L106-L149
cloudmesh/cloudmesh-common
cloudmesh/common/ConfigDict.py
dprint
def dprint(OD, mode='dict', s="", indent=' ' * 4, level=0): """ a recursive dict printer method that adds indentations TODO: needs better explanation and test example :param OD: the ordered dict :param mode: the mode is dict :param s: TODO :param indent: the indentation characters. default i...
python
def dprint(OD, mode='dict', s="", indent=' ' * 4, level=0): """ a recursive dict printer method that adds indentations TODO: needs better explanation and test example :param OD: the ordered dict :param mode: the mode is dict :param s: TODO :param indent: the indentation characters. default i...
[ "def", "dprint", "(", "OD", ",", "mode", "=", "'dict'", ",", "s", "=", "\"\"", ",", "indent", "=", "' '", "*", "4", ",", "level", "=", "0", ")", ":", "def", "is_number", "(", "s", ")", ":", "\"\"\"\n checks if the type of s is a float\n :para...
a recursive dict printer method that adds indentations TODO: needs better explanation and test example :param OD: the ordered dict :param mode: the mode is dict :param s: TODO :param indent: the indentation characters. default is 4 :param level: the level :return:
[ "a", "recursive", "dict", "printer", "method", "that", "adds", "indentations", "TODO", ":", "needs", "better", "explanation", "and", "test", "example", ":", "param", "OD", ":", "the", "ordered", "dict", ":", "param", "mode", ":", "the", "mode", "is", "dict...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ConfigDict.py#L68-L121
cloudmesh/cloudmesh-common
cloudmesh/common/ConfigDict.py
main
def main(): """ TODO: A test which should actually be moved into a nosetest :return: """ d = ConfigDict("cloudmesh.yaml") print(d, end='') d.info() print(d["meta"]) print(d["meta.kind"]) print(d["meta"]["kind"]) # this does not yet work d.data["cloudmesh"]["profile"]["...
python
def main(): """ TODO: A test which should actually be moved into a nosetest :return: """ d = ConfigDict("cloudmesh.yaml") print(d, end='') d.info() print(d["meta"]) print(d["meta.kind"]) print(d["meta"]["kind"]) # this does not yet work d.data["cloudmesh"]["profile"]["...
[ "def", "main", "(", ")", ":", "d", "=", "ConfigDict", "(", "\"cloudmesh.yaml\"", ")", "print", "(", "d", ",", "end", "=", "''", ")", "d", ".", "info", "(", ")", "print", "(", "d", "[", "\"meta\"", "]", ")", "print", "(", "d", "[", "\"meta.kind\""...
TODO: A test which should actually be moved into a nosetest :return:
[ "TODO", ":", "A", "test", "which", "should", "actually", "be", "moved", "into", "a", "nosetest", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ConfigDict.py#L478-L503
cloudmesh/cloudmesh-common
cloudmesh/common/ConfigDict.py
Config.check_file_for_tabs
def check_file_for_tabs(cls, filename, verbose=True): """identifies if the file contains tabs and returns True if it does. It also prints the location of the lines and columns. If verbose is set to False, the location is not printed. :param verbose: if true prints issues :param ...
python
def check_file_for_tabs(cls, filename, verbose=True): """identifies if the file contains tabs and returns True if it does. It also prints the location of the lines and columns. If verbose is set to False, the location is not printed. :param verbose: if true prints issues :param ...
[ "def", "check_file_for_tabs", "(", "cls", ",", "filename", ",", "verbose", "=", "True", ")", ":", "filename", "=", "path_expand", "(", "filename", ")", "file_contains_tabs", "=", "False", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", ...
identifies if the file contains tabs and returns True if it does. It also prints the location of the lines and columns. If verbose is set to False, the location is not printed. :param verbose: if true prints issues :param filename: the filename :type filename: str :rtype...
[ "identifies", "if", "the", "file", "contains", "tabs", "and", "returns", "True", "if", "it", "does", ".", "It", "also", "prints", "the", "location", "of", "the", "lines", "and", "columns", ".", "If", "verbose", "is", "set", "to", "False", "the", "locatio...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ConfigDict.py#L130-L156
cloudmesh/cloudmesh-common
cloudmesh/common/ConfigDict.py
Config.path_expand
def path_expand(cls, path): """ expands the path while replacing environment variables, ./, and ~/ :param path: the path to be expanded :type path: string :return:the new path :rtype: string """ current_dir = "." + os.path.sep if path.startswith(cu...
python
def path_expand(cls, path): """ expands the path while replacing environment variables, ./, and ~/ :param path: the path to be expanded :type path: string :return:the new path :rtype: string """ current_dir = "." + os.path.sep if path.startswith(cu...
[ "def", "path_expand", "(", "cls", ",", "path", ")", ":", "current_dir", "=", "\".\"", "+", "os", ".", "path", ".", "sep", "if", "path", ".", "startswith", "(", "current_dir", ")", ":", "cwd", "=", "str", "(", "os", ".", "getcwd", "(", ")", ")", "...
expands the path while replacing environment variables, ./, and ~/ :param path: the path to be expanded :type path: string :return:the new path :rtype: string
[ "expands", "the", "path", "while", "replacing", "environment", "variables", ".", "/", "and", "~", "/", ":", "param", "path", ":", "the", "path", "to", "be", "expanded", ":", "type", "path", ":", "string", ":", "return", ":", "the", "new", "path", ":", ...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ConfigDict.py#L159-L172
cloudmesh/cloudmesh-common
cloudmesh/common/ConfigDict.py
Config.find_file
def find_file(cls, filename, load_order=None, verbose=False): """ find the specified file in the list of directories that are given in the array load_order :param filename: the file name :type filename: str :param load_order: an array with path names in with the filename ...
python
def find_file(cls, filename, load_order=None, verbose=False): """ find the specified file in the list of directories that are given in the array load_order :param filename: the file name :type filename: str :param load_order: an array with path names in with the filename ...
[ "def", "find_file", "(", "cls", ",", "filename", ",", "load_order", "=", "None", ",", "verbose", "=", "False", ")", ":", "if", "load_order", "is", "None", ":", "load_order", "=", "[", "\".\"", ",", "os", ".", "path", ".", "join", "(", "\"~\"", ",", ...
find the specified file in the list of directories that are given in the array load_order :param filename: the file name :type filename: str :param load_order: an array with path names in with the filename is looked for. :type load_order: list of str :param verbose: ...
[ "find", "the", "specified", "file", "in", "the", "list", "of", "directories", "that", "are", "given", "in", "the", "array", "load_order", ":", "param", "filename", ":", "the", "file", "name", ":", "type", "filename", ":", "str", ":", "param", "load_order",...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ConfigDict.py#L175-L198
cloudmesh/cloudmesh-common
cloudmesh/common/ConfigDict.py
ConfigDict.load
def load(self, filename): """ loads the configuration from the yaml filename :param filename: :type filename: string :return: """ # print ("LOAD CONFIGDICT", filename) self.data = BaseConfigDict(filename=Config.path_expand(filename)) try: ...
python
def load(self, filename): """ loads the configuration from the yaml filename :param filename: :type filename: string :return: """ # print ("LOAD CONFIGDICT", filename) self.data = BaseConfigDict(filename=Config.path_expand(filename)) try: ...
[ "def", "load", "(", "self", ",", "filename", ")", ":", "# print (\"LOAD CONFIGDICT\", filename)", "self", ".", "data", "=", "BaseConfigDict", "(", "filename", "=", "Config", ".", "path_expand", "(", "filename", ")", ")", "try", ":", "version", "=", "str", "(...
loads the configuration from the yaml filename :param filename: :type filename: string :return:
[ "loads", "the", "configuration", "from", "the", "yaml", "filename", ":", "param", "filename", ":", ":", "type", "filename", ":", "string", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ConfigDict.py#L264-L285
cloudmesh/cloudmesh-common
cloudmesh/common/ConfigDict.py
ConfigDict.write
def write(self, filename=None, output="dict", attribute_indent=4): """ This method writes the dict into various output formats. This includes a dict, json, and yaml :param filename: the file in which the dict is written :param output: is a string that is either "dict", "json", "y...
python
def write(self, filename=None, output="dict", attribute_indent=4): """ This method writes the dict into various output formats. This includes a dict, json, and yaml :param filename: the file in which the dict is written :param output: is a string that is either "dict", "json", "y...
[ "def", "write", "(", "self", ",", "filename", "=", "None", ",", "output", "=", "\"dict\"", ",", "attribute_indent", "=", "4", ")", ":", "if", "filename", "is", "not", "None", ":", "location", "=", "path_expand", "(", "filename", ")", "else", ":", "loca...
This method writes the dict into various output formats. This includes a dict, json, and yaml :param filename: the file in which the dict is written :param output: is a string that is either "dict", "json", "yaml" :param attribute_indent: character indentation of nested attributes in
[ "This", "method", "writes", "the", "dict", "into", "various", "output", "formats", ".", "This", "includes", "a", "dict", "json", "and", "yaml", ":", "param", "filename", ":", "the", "file", "in", "which", "the", "dict", "is", "written", ":", "param", "ou...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ConfigDict.py#L288-L322
cloudmesh/cloudmesh-common
cloudmesh/common/ConfigDict.py
ConfigDict.make_a_copy
def make_a_copy(self, location=None): """ Creates a backup of the file specified in the location. The backup filename appends a .bak.NO where number is a number that is not yet used in the backup directory. TODO: This function should be moved to another file maybe XShell ...
python
def make_a_copy(self, location=None): """ Creates a backup of the file specified in the location. The backup filename appends a .bak.NO where number is a number that is not yet used in the backup directory. TODO: This function should be moved to another file maybe XShell ...
[ "def", "make_a_copy", "(", "self", ",", "location", "=", "None", ")", ":", "import", "shutil", "destination", "=", "backup_name", "(", "location", ")", "shutil", ".", "copyfile", "(", "location", ",", "destination", ")" ]
Creates a backup of the file specified in the location. The backup filename appends a .bak.NO where number is a number that is not yet used in the backup directory. TODO: This function should be moved to another file maybe XShell :param location: the location of the file to be backed up
[ "Creates", "a", "backup", "of", "the", "file", "specified", "in", "the", "location", ".", "The", "backup", "filename", "appends", "a", ".", "bak", ".", "NO", "where", "number", "is", "a", "number", "that", "is", "not", "yet", "used", "in", "the", "back...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ConfigDict.py#L324-L334
cloudmesh/cloudmesh-common
cloudmesh/common/ConfigDict.py
ConfigDict.save
def save(self, filename=None): """ saves the configuration in the given filename, if it is none the filename at load time is used. :param filename: the file name :type filename: string :return: """ content = self.data.yaml() with open(Config.path_e...
python
def save(self, filename=None): """ saves the configuration in the given filename, if it is none the filename at load time is used. :param filename: the file name :type filename: string :return: """ content = self.data.yaml() with open(Config.path_e...
[ "def", "save", "(", "self", ",", "filename", "=", "None", ")", ":", "content", "=", "self", ".", "data", ".", "yaml", "(", ")", "with", "open", "(", "Config", ".", "path_expand", "(", "ConfigDict", ".", "filename", ")", ",", "'w'", ")", "as", "f", ...
saves the configuration in the given filename, if it is none the filename at load time is used. :param filename: the file name :type filename: string :return:
[ "saves", "the", "configuration", "in", "the", "given", "filename", "if", "it", "is", "none", "the", "filename", "at", "load", "time", "is", "used", ".", ":", "param", "filename", ":", "the", "file", "name", ":", "type", "filename", ":", "string", ":", ...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ConfigDict.py#L336-L346
cloudmesh/cloudmesh-common
cloudmesh/common/ConfigDict.py
ConfigDict.json
def json(self, start=None): """ :param start: start key in dot notation returns the dict in json format :return: json string version :rtype: string """ if start is not None: data = self.data[start] return json.dumps(self.data, indent=4)
python
def json(self, start=None): """ :param start: start key in dot notation returns the dict in json format :return: json string version :rtype: string """ if start is not None: data = self.data[start] return json.dumps(self.data, indent=4)
[ "def", "json", "(", "self", ",", "start", "=", "None", ")", ":", "if", "start", "is", "not", "None", ":", "data", "=", "self", ".", "data", "[", "start", "]", "return", "json", ".", "dumps", "(", "self", ".", "data", ",", "indent", "=", "4", ")...
:param start: start key in dot notation returns the dict in json format :return: json string version :rtype: string
[ ":", "param", "start", ":", "start", "key", "in", "dot", "notation", "returns", "the", "dict", "in", "json", "format", ":", "return", ":", "json", "string", "version", ":", "rtype", ":", "string" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ConfigDict.py#L411-L420
cloudmesh/cloudmesh-common
cloudmesh/common/ConfigDict.py
ConfigDict.getUser
def getUser(cls, cloud): """ gets the username for a specified cloud. TODO: works currently only for opensatck. :param cloud: the name of the cloud :return: """ try: config = d = ConfigDict("cloudmesh.yaml") d = ConfigDict("cloudmesh.yaml...
python
def getUser(cls, cloud): """ gets the username for a specified cloud. TODO: works currently only for opensatck. :param cloud: the name of the cloud :return: """ try: config = d = ConfigDict("cloudmesh.yaml") d = ConfigDict("cloudmesh.yaml...
[ "def", "getUser", "(", "cls", ",", "cloud", ")", ":", "try", ":", "config", "=", "d", "=", "ConfigDict", "(", "\"cloudmesh.yaml\"", ")", "d", "=", "ConfigDict", "(", "\"cloudmesh.yaml\"", ")", "#", "# bug: cloud is none when adding a group", "#", "config", "="...
gets the username for a specified cloud. TODO: works currently only for opensatck. :param cloud: the name of the cloud :return:
[ "gets", "the", "username", "for", "a", "specified", "cloud", ".", "TODO", ":", "works", "currently", "only", "for", "opensatck", ".", ":", "param", "cloud", ":", "the", "name", "of", "the", "cloud", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/ConfigDict.py#L434-L460
cloudmesh/cloudmesh-common
cloudmesh/common/locations.py
config_dir_setup
def config_dir_setup(filename): """ sets the config file and makes sure the directory exists if it has not yet been created. :param filename: :return: """ path = os.path.dirname(filename) if not os.path.isdir(path): Shell.mkdir(path)
python
def config_dir_setup(filename): """ sets the config file and makes sure the directory exists if it has not yet been created. :param filename: :return: """ path = os.path.dirname(filename) if not os.path.isdir(path): Shell.mkdir(path)
[ "def", "config_dir_setup", "(", "filename", ")", ":", "path", "=", "os", ".", "path", ".", "dirname", "(", "filename", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "Shell", ".", "mkdir", "(", "path", ")" ]
sets the config file and makes sure the directory exists if it has not yet been created. :param filename: :return:
[ "sets", "the", "config", "file", "and", "makes", "sure", "the", "directory", "exists", "if", "it", "has", "not", "yet", "been", "created", ".", ":", "param", "filename", ":", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/locations.py#L37-L45
cloudmesh/cloudmesh-common
cloudmesh/common/Shell.py
main
def main(): """ a test that should actually be added into a nosetest :return: """ shell = Shell() print(shell.terminal_type()) r = shell.execute('pwd') # copy line replace print(r) # shell.list() # print json.dumps(shell.command, indent=4) # test some commands without ...
python
def main(): """ a test that should actually be added into a nosetest :return: """ shell = Shell() print(shell.terminal_type()) r = shell.execute('pwd') # copy line replace print(r) # shell.list() # print json.dumps(shell.command, indent=4) # test some commands without ...
[ "def", "main", "(", ")", ":", "shell", "=", "Shell", "(", ")", "print", "(", "shell", ".", "terminal_type", "(", ")", ")", "r", "=", "shell", ".", "execute", "(", "'pwd'", ")", "# copy line replace", "print", "(", "r", ")", "# shell.list()", "# print j...
a test that should actually be added into a nosetest :return:
[ "a", "test", "that", "should", "actually", "be", "added", "into", "a", "nosetest", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/Shell.py#L790-L828
cloudmesh/cloudmesh-common
cloudmesh/common/Shell.py
Shell.get_python
def get_python(cls): """ returns the python and pip version :return: python version, pip version """ python_version = sys.version_info[:3] v_string = [str(i) for i in python_version] python_version_s = '.'.join(v_string) # pip_version = pip.__version__ ...
python
def get_python(cls): """ returns the python and pip version :return: python version, pip version """ python_version = sys.version_info[:3] v_string = [str(i) for i in python_version] python_version_s = '.'.join(v_string) # pip_version = pip.__version__ ...
[ "def", "get_python", "(", "cls", ")", ":", "python_version", "=", "sys", ".", "version_info", "[", ":", "3", "]", "v_string", "=", "[", "str", "(", "i", ")", "for", "i", "in", "python_version", "]", "python_version_s", "=", "'.'", ".", "join", "(", "...
returns the python and pip version :return: python version, pip version
[ "returns", "the", "python", "and", "pip", "version", ":", "return", ":", "python", "version", "pip", "version" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/Shell.py#L213-L224
cloudmesh/cloudmesh-common
cloudmesh/common/Shell.py
Shell.check_python
def check_python(cls): """ checks if the python version is supported :return: True if it is supported """ python_version = sys.version_info[:3] v_string = [str(i) for i in python_version] if python_version[0] == 2: python_version_s = '.'.join(v_stri...
python
def check_python(cls): """ checks if the python version is supported :return: True if it is supported """ python_version = sys.version_info[:3] v_string = [str(i) for i in python_version] if python_version[0] == 2: python_version_s = '.'.join(v_stri...
[ "def", "check_python", "(", "cls", ")", ":", "python_version", "=", "sys", ".", "version_info", "[", ":", "3", "]", "v_string", "=", "[", "str", "(", "i", ")", "for", "i", "in", "python_version", "]", "if", "python_version", "[", "0", "]", "==", "2",...
checks if the python version is supported :return: True if it is supported
[ "checks", "if", "the", "python", "version", "is", "supported", ":", "return", ":", "True", "if", "it", "is", "supported" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/Shell.py#L227-L276
cloudmesh/cloudmesh-common
cloudmesh/common/Shell.py
Shell.VBoxManage
def VBoxManage(cls, *args): """ executes VboxManage with the given arguments :param args: :return: """ if platform.system().lower() == "darwin": command = "/Applications/VirtualBox.app/Contents/MacOS/VBoxManage" else: command = 'VBoxMana...
python
def VBoxManage(cls, *args): """ executes VboxManage with the given arguments :param args: :return: """ if platform.system().lower() == "darwin": command = "/Applications/VirtualBox.app/Contents/MacOS/VBoxManage" else: command = 'VBoxMana...
[ "def", "VBoxManage", "(", "cls", ",", "*", "args", ")", ":", "if", "platform", ".", "system", "(", ")", ".", "lower", "(", ")", "==", "\"darwin\"", ":", "command", "=", "\"/Applications/VirtualBox.app/Contents/MacOS/VBoxManage\"", "else", ":", "command", "=", ...
executes VboxManage with the given arguments :param args: :return:
[ "executes", "VboxManage", "with", "the", "given", "arguments", ":", "param", "args", ":", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/Shell.py#L340-L351
cloudmesh/cloudmesh-common
cloudmesh/common/Shell.py
Shell.ping
def ping(cls, host=None, count=1): """ execute ping :param host: the host to ping :param count: the number of pings :return: """ option = '-n' if platform.system().lower() == 'windows' else '-c' return cls.execute('ping', "{opt...
python
def ping(cls, host=None, count=1): """ execute ping :param host: the host to ping :param count: the number of pings :return: """ option = '-n' if platform.system().lower() == 'windows' else '-c' return cls.execute('ping', "{opt...
[ "def", "ping", "(", "cls", ",", "host", "=", "None", ",", "count", "=", "1", ")", ":", "option", "=", "'-n'", "if", "platform", ".", "system", "(", ")", ".", "lower", "(", ")", "==", "'windows'", "else", "'-c'", "return", "cls", ".", "execute", "...
execute ping :param host: the host to ping :param count: the number of pings :return:
[ "execute", "ping", ":", "param", "host", ":", "the", "host", "to", "ping", ":", "param", "count", ":", "the", "number", "of", "pings", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/Shell.py#L435-L446
cloudmesh/cloudmesh-common
cloudmesh/common/Shell.py
Shell.remove_line_with
def remove_line_with(cls, lines, what): """ returns all lines that do not contain what :param lines: :param what: :return: """ result = [] for line in lines: if what not in line: result = result + [line] return result
python
def remove_line_with(cls, lines, what): """ returns all lines that do not contain what :param lines: :param what: :return: """ result = [] for line in lines: if what not in line: result = result + [line] return result
[ "def", "remove_line_with", "(", "cls", ",", "lines", ",", "what", ")", ":", "result", "=", "[", "]", "for", "line", "in", "lines", ":", "if", "what", "not", "in", "line", ":", "result", "=", "result", "+", "[", "line", "]", "return", "result" ]
returns all lines that do not contain what :param lines: :param what: :return:
[ "returns", "all", "lines", "that", "do", "not", "contain", "what", ":", "param", "lines", ":", ":", "param", "what", ":", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/Shell.py#L584-L595
cloudmesh/cloudmesh-common
cloudmesh/common/Shell.py
Shell.find_lines_with
def find_lines_with(cls, lines, what): """ returns all lines that contain what :param lines: :param what: :return: """ result = [] for line in lines: if what in line: result = result + [line] return result
python
def find_lines_with(cls, lines, what): """ returns all lines that contain what :param lines: :param what: :return: """ result = [] for line in lines: if what in line: result = result + [line] return result
[ "def", "find_lines_with", "(", "cls", ",", "lines", ",", "what", ")", ":", "result", "=", "[", "]", "for", "line", "in", "lines", ":", "if", "what", "in", "line", ":", "result", "=", "result", "+", "[", "line", "]", "return", "result" ]
returns all lines that contain what :param lines: :param what: :return:
[ "returns", "all", "lines", "that", "contain", "what", ":", "param", "lines", ":", ":", "param", "what", ":", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/Shell.py#L598-L609
cloudmesh/cloudmesh-common
cloudmesh/common/Shell.py
Shell.find_cygwin_executables
def find_cygwin_executables(cls): """ find the executables in cygwin """ exe_paths = glob.glob(cls.cygwin_path + r'\*.exe') # print cls.cygwin_path # list all *.exe in cygwin path, use glob for c in exe_paths: exe = c.split('\\') name = ex...
python
def find_cygwin_executables(cls): """ find the executables in cygwin """ exe_paths = glob.glob(cls.cygwin_path + r'\*.exe') # print cls.cygwin_path # list all *.exe in cygwin path, use glob for c in exe_paths: exe = c.split('\\') name = ex...
[ "def", "find_cygwin_executables", "(", "cls", ")", ":", "exe_paths", "=", "glob", ".", "glob", "(", "cls", ".", "cygwin_path", "+", "r'\\*.exe'", ")", "# print cls.cygwin_path", "# list all *.exe in cygwin path, use glob", "for", "c", "in", "exe_paths", ":", "exe",...
find the executables in cygwin
[ "find", "the", "executables", "in", "cygwin" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/Shell.py#L622-L633
cloudmesh/cloudmesh-common
cloudmesh/common/Shell.py
Shell.terminal_type
def terminal_type(cls): """ returns darwin, cygwin, cmd, or linux """ what = sys.platform kind = 'UNDEFINED_TERMINAL_TYPE' if 'linux' in what: kind = 'linux' elif 'darwin' in what: kind = 'darwin' elif 'cygwin' in what: ...
python
def terminal_type(cls): """ returns darwin, cygwin, cmd, or linux """ what = sys.platform kind = 'UNDEFINED_TERMINAL_TYPE' if 'linux' in what: kind = 'linux' elif 'darwin' in what: kind = 'darwin' elif 'cygwin' in what: ...
[ "def", "terminal_type", "(", "cls", ")", ":", "what", "=", "sys", ".", "platform", "kind", "=", "'UNDEFINED_TERMINAL_TYPE'", "if", "'linux'", "in", "what", ":", "kind", "=", "'linux'", "elif", "'darwin'", "in", "what", ":", "kind", "=", "'darwin'", "elif",...
returns darwin, cygwin, cmd, or linux
[ "returns", "darwin", "cygwin", "cmd", "or", "linux" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/Shell.py#L636-L652
cloudmesh/cloudmesh-common
cloudmesh/common/Shell.py
Shell.execute
def execute(cls, cmd, arguments="", shell=False, cwd=None, traceflag=True, witherror=True): """Run Shell command :param witherror: if set to False the error will not be printed :param traceflag: if s...
python
def execute(cls, cmd, arguments="", shell=False, cwd=None, traceflag=True, witherror=True): """Run Shell command :param witherror: if set to False the error will not be printed :param traceflag: if s...
[ "def", "execute", "(", "cls", ",", "cmd", ",", "arguments", "=", "\"\"", ",", "shell", "=", "False", ",", "cwd", "=", "None", ",", "traceflag", "=", "True", ",", "witherror", "=", "True", ")", ":", "# print \"--------------\"", "result", "=", "None", "...
Run Shell command :param witherror: if set to False the error will not be printed :param traceflag: if set to true the trace is printed in case of an error :param cwd: the current working directory in whcih the command is supposed to be executed. :param shell: if set to true the subproc...
[ "Run", "Shell", "command" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/Shell.py#L681-L742
cloudmesh/cloudmesh-common
cloudmesh/common/Shell.py
Shell.mkdir
def mkdir(cls, directory): """ creates a directory with all its parents in ots name :param directory: the path of the directory :return: """ directory = path_expand(directory) try: os.makedirs(directory) except OSError as e: # EEX...
python
def mkdir(cls, directory): """ creates a directory with all its parents in ots name :param directory: the path of the directory :return: """ directory = path_expand(directory) try: os.makedirs(directory) except OSError as e: # EEX...
[ "def", "mkdir", "(", "cls", ",", "directory", ")", ":", "directory", "=", "path_expand", "(", "directory", ")", "try", ":", "os", ".", "makedirs", "(", "directory", ")", "except", "OSError", "as", "e", ":", "# EEXIST (errno 17) occurs under two conditions when t...
creates a directory with all its parents in ots name :param directory: the path of the directory :return:
[ "creates", "a", "directory", "with", "all", "its", "parents", "in", "ots", "name", ":", "param", "directory", ":", "the", "path", "of", "the", "directory", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/Shell.py#L745-L765
cloudmesh/cloudmesh-common
cloudmesh/common/TableParser.py
TableParser.clean
def clean(self, line): """ :param line: cleans the string :return: """ # print ("-" + line + "-") if line == '': line = 'None' if self.is_lower: line = line.lower() if line == "user ": # for slurm which has "user" and "user " ...
python
def clean(self, line): """ :param line: cleans the string :return: """ # print ("-" + line + "-") if line == '': line = 'None' if self.is_lower: line = line.lower() if line == "user ": # for slurm which has "user" and "user " ...
[ "def", "clean", "(", "self", ",", "line", ")", ":", "# print (\"-\" + line + \"-\")", "if", "line", "==", "''", ":", "line", "=", "'None'", "if", "self", ".", "is_lower", ":", "line", "=", "line", ".", "lower", "(", ")", "if", "line", "==", "\"user \""...
:param line: cleans the string :return:
[ ":", "param", "line", ":", "cleans", "the", "string", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/TableParser.py#L76-L92
cloudmesh/cloudmesh-common
cloudmesh/common/TableParser.py
TableParser._get_headers
def _get_headers(self): """ assumes comment have been stripped with extract :return: """ header = self.lines[0] self.lines = self.lines[1:] self.headers = \ [self.clean(h) for h in header.split(self.seperator)] if self.is_strip: s...
python
def _get_headers(self): """ assumes comment have been stripped with extract :return: """ header = self.lines[0] self.lines = self.lines[1:] self.headers = \ [self.clean(h) for h in header.split(self.seperator)] if self.is_strip: s...
[ "def", "_get_headers", "(", "self", ")", ":", "header", "=", "self", ".", "lines", "[", "0", "]", "self", ".", "lines", "=", "self", ".", "lines", "[", "1", ":", "]", "self", ".", "headers", "=", "[", "self", ".", "clean", "(", "h", ")", "for",...
assumes comment have been stripped with extract :return:
[ "assumes", "comment", "have", "been", "stripped", "with", "extract", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/TableParser.py#L104-L117
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
tempdir
def tempdir(*args, **kwargs): """A contextmanager to work in an auto-removed temporary directory Arguments are passed through to tempfile.mkdtemp example: >>> with tempdir() as path: ... pass """ d = tempfile.mkdtemp(*args, **kwargs) try: yield d finally: shuti...
python
def tempdir(*args, **kwargs): """A contextmanager to work in an auto-removed temporary directory Arguments are passed through to tempfile.mkdtemp example: >>> with tempdir() as path: ... pass """ d = tempfile.mkdtemp(*args, **kwargs) try: yield d finally: shuti...
[ "def", "tempdir", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "d", "=", "tempfile", ".", "mkdtemp", "(", "*", "args", ",", "*", "*", "kwargs", ")", "try", ":", "yield", "d", "finally", ":", "shutil", ".", "rmtree", "(", "d", ")" ]
A contextmanager to work in an auto-removed temporary directory Arguments are passed through to tempfile.mkdtemp example: >>> with tempdir() as path: ... pass
[ "A", "contextmanager", "to", "work", "in", "an", "auto", "-", "removed", "temporary", "directory" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L34-L49
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
exponential_backoff
def exponential_backoff(fn, sleeptime_s_max=30 * 60): """Calls `fn` until it returns True, with an exponentially increasing wait time between calls""" sleeptime_ms = 500 while True: if fn(): return True else: print('Sleeping {} ms'.format(sleeptime_ms)) t...
python
def exponential_backoff(fn, sleeptime_s_max=30 * 60): """Calls `fn` until it returns True, with an exponentially increasing wait time between calls""" sleeptime_ms = 500 while True: if fn(): return True else: print('Sleeping {} ms'.format(sleeptime_ms)) t...
[ "def", "exponential_backoff", "(", "fn", ",", "sleeptime_s_max", "=", "30", "*", "60", ")", ":", "sleeptime_ms", "=", "500", "while", "True", ":", "if", "fn", "(", ")", ":", "return", "True", "else", ":", "print", "(", "'Sleeping {} ms'", ".", "format", ...
Calls `fn` until it returns True, with an exponentially increasing wait time between calls
[ "Calls", "fn", "until", "it", "returns", "True", "with", "an", "exponentially", "increasing", "wait", "time", "between", "calls" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L52-L65
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
search
def search(lines, pattern): """ return all lines that match the pattern #TODO: we need an example :param lines: :param pattern: :return: """ p = pattern.replace("*", ".*") test = re.compile(p) result = [] for l in lines: if test.search(l): result.a...
python
def search(lines, pattern): """ return all lines that match the pattern #TODO: we need an example :param lines: :param pattern: :return: """ p = pattern.replace("*", ".*") test = re.compile(p) result = [] for l in lines: if test.search(l): result.a...
[ "def", "search", "(", "lines", ",", "pattern", ")", ":", "p", "=", "pattern", ".", "replace", "(", "\"*\"", ",", "\".*\"", ")", "test", "=", "re", ".", "compile", "(", "p", ")", "result", "=", "[", "]", "for", "l", "in", "lines", ":", "if", "te...
return all lines that match the pattern #TODO: we need an example :param lines: :param pattern: :return:
[ "return", "all", "lines", "that", "match", "the", "pattern", "#TODO", ":", "we", "need", "an", "example", ":", "param", "lines", ":", ":", "param", "pattern", ":", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L68-L83
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
grep
def grep(pattern, filename): """Very simple grep that returns the first matching line in a file. String matching only, does not do REs as currently implemented. """ try: # for line in file # if line matches pattern: # return line return next((L for L in open(filename) ...
python
def grep(pattern, filename): """Very simple grep that returns the first matching line in a file. String matching only, does not do REs as currently implemented. """ try: # for line in file # if line matches pattern: # return line return next((L for L in open(filename) ...
[ "def", "grep", "(", "pattern", ",", "filename", ")", ":", "try", ":", "# for line in file", "# if line matches pattern:", "# return line", "return", "next", "(", "(", "L", "for", "L", "in", "open", "(", "filename", ")", "if", "L", ".", "find", "(", "pat...
Very simple grep that returns the first matching line in a file. String matching only, does not do REs as currently implemented.
[ "Very", "simple", "grep", "that", "returns", "the", "first", "matching", "line", "in", "a", "file", ".", "String", "matching", "only", "does", "not", "do", "REs", "as", "currently", "implemented", "." ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L86-L96
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
path_expand
def path_expand(text): """ returns a string with expanded variable. :param text: the path to be expanded, which can include ~ and environment $ variables :param text: string """ result = os.path.expandvars(os.path.expanduser(text)) # template = Template(text) # result = template.substitut...
python
def path_expand(text): """ returns a string with expanded variable. :param text: the path to be expanded, which can include ~ and environment $ variables :param text: string """ result = os.path.expandvars(os.path.expanduser(text)) # template = Template(text) # result = template.substitut...
[ "def", "path_expand", "(", "text", ")", ":", "result", "=", "os", ".", "path", ".", "expandvars", "(", "os", ".", "path", ".", "expanduser", "(", "text", ")", ")", "# template = Template(text)", "# result = template.substitute(os.environ)", "if", "result", ".", ...
returns a string with expanded variable. :param text: the path to be expanded, which can include ~ and environment $ variables :param text: string
[ "returns", "a", "string", "with", "expanded", "variable", "." ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L99-L114
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
convert_from_unicode
def convert_from_unicode(data): """ converts unicode data to a string :param data: the data to convert :return: """ # if isinstance(data, basestring): if isinstance(data, str): return str(data) elif isinstance(data, collectionsAbc.Mapping): return dict(map(convert_from_...
python
def convert_from_unicode(data): """ converts unicode data to a string :param data: the data to convert :return: """ # if isinstance(data, basestring): if isinstance(data, str): return str(data) elif isinstance(data, collectionsAbc.Mapping): return dict(map(convert_from_...
[ "def", "convert_from_unicode", "(", "data", ")", ":", "# if isinstance(data, basestring):", "if", "isinstance", "(", "data", ",", "str", ")", ":", "return", "str", "(", "data", ")", "elif", "isinstance", "(", "data", ",", "collectionsAbc", ".", "Mapping", ")",...
converts unicode data to a string :param data: the data to convert :return:
[ "converts", "unicode", "data", "to", "a", "string", ":", "param", "data", ":", "the", "data", "to", "convert", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L117-L132
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
yn_choice
def yn_choice(message, default='y', tries=None): """asks for a yes/no question. :param tries: the number of tries :param message: the message containing the question :param default: the default answer """ # http://stackoverflow.com/questions/3041986/python-command-line-yes-no-input""" choic...
python
def yn_choice(message, default='y', tries=None): """asks for a yes/no question. :param tries: the number of tries :param message: the message containing the question :param default: the default answer """ # http://stackoverflow.com/questions/3041986/python-command-line-yes-no-input""" choic...
[ "def", "yn_choice", "(", "message", ",", "default", "=", "'y'", ",", "tries", "=", "None", ")", ":", "# http://stackoverflow.com/questions/3041986/python-command-line-yes-no-input\"\"\"", "choices", "=", "'Y/n'", "if", "default", ".", "lower", "(", ")", "in", "(", ...
asks for a yes/no question. :param tries: the number of tries :param message: the message containing the question :param default: the default answer
[ "asks", "for", "a", "yes", "/", "no", "question", "." ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L135-L159
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
banner
def banner(txt=None, c="#", debug=True, label=None, color=None): """prints a banner of the form with a frame of # around the txt:: ############################ # txt ############################ :param color: prints in the given color :param label: adds a label :param debug: prints o...
python
def banner(txt=None, c="#", debug=True, label=None, color=None): """prints a banner of the form with a frame of # around the txt:: ############################ # txt ############################ :param color: prints in the given color :param label: adds a label :param debug: prints o...
[ "def", "banner", "(", "txt", "=", "None", ",", "c", "=", "\"#\"", ",", "debug", "=", "True", ",", "label", "=", "None", ",", "color", "=", "None", ")", ":", "output", "=", "\"\"", "if", "debug", ":", "output", "=", "\"\\n\"", "output", "+=", "\"#...
prints a banner of the form with a frame of # around the txt:: ############################ # txt ############################ :param color: prints in the given color :param label: adds a label :param debug: prints only if debug is true :param txt: a text message to be printed :t...
[ "prints", "a", "banner", "of", "the", "form", "with", "a", "frame", "of", "#", "around", "the", "txt", "::" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L162-L191
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
str_banner
def str_banner(txt=None, c="#", debug=True): """prints a banner of the form with a frame of # around the txt:: ############################ # txt ############################ :param debug: return "" if not in debug :type debug: boolean :param txt: a text message to be printed :ty...
python
def str_banner(txt=None, c="#", debug=True): """prints a banner of the form with a frame of # around the txt:: ############################ # txt ############################ :param debug: return "" if not in debug :type debug: boolean :param txt: a text message to be printed :ty...
[ "def", "str_banner", "(", "txt", "=", "None", ",", "c", "=", "\"#\"", ",", "debug", "=", "True", ")", ":", "line", "=", "\"\"", "if", "debug", ":", "line", "+=", "\"\\n\"", "line", "+=", "\"# \"", "+", "str", "(", "70", "*", "c", ")", "if", "tx...
prints a banner of the form with a frame of # around the txt:: ############################ # txt ############################ :param debug: return "" if not in debug :type debug: boolean :param txt: a text message to be printed :type txt: string :param c: the character used inst...
[ "prints", "a", "banner", "of", "the", "form", "with", "a", "frame", "of", "#", "around", "the", "txt", "::" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L194-L215
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
HEADING
def HEADING(txt=None, c="#"): """ Prints a message to stdout with #### surrounding it. This is useful for nosetests to better distinguish them. :param c: uses the given char to wrap the header :param txt: a text message to be printed :type txt: string """ frame = inspect.getouterframes(...
python
def HEADING(txt=None, c="#"): """ Prints a message to stdout with #### surrounding it. This is useful for nosetests to better distinguish them. :param c: uses the given char to wrap the header :param txt: a text message to be printed :type txt: string """ frame = inspect.getouterframes(...
[ "def", "HEADING", "(", "txt", "=", "None", ",", "c", "=", "\"#\"", ")", ":", "frame", "=", "inspect", ".", "getouterframes", "(", "inspect", ".", "currentframe", "(", ")", ")", "filename", "=", "frame", "[", "1", "]", "[", "1", "]", ".", "replace",...
Prints a message to stdout with #### surrounding it. This is useful for nosetests to better distinguish them. :param c: uses the given char to wrap the header :param txt: a text message to be printed :type txt: string
[ "Prints", "a", "message", "to", "stdout", "with", "####", "surrounding", "it", ".", "This", "is", "useful", "for", "nosetests", "to", "better", "distinguish", "them", "." ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L219-L236
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
backup_name
def backup_name(filename): """ :param filename: given a filename creates a backup name of the form filename.bak.1. If the filename already exists the number will be increased as much as needed so the file does not exist in the given location. ...
python
def backup_name(filename): """ :param filename: given a filename creates a backup name of the form filename.bak.1. If the filename already exists the number will be increased as much as needed so the file does not exist in the given location. ...
[ "def", "backup_name", "(", "filename", ")", ":", "location", "=", "path_expand", "(", "filename", ")", "n", "=", "0", "found", "=", "True", "backup", "=", "None", "while", "found", ":", "n", "+=", "1", "backup", "=", "\"{0}.bak.{1}\"", ".", "format", "...
:param filename: given a filename creates a backup name of the form filename.bak.1. If the filename already exists the number will be increased as much as needed so the file does not exist in the given location. The filename can consis...
[ ":", "param", "filename", ":", "given", "a", "filename", "creates", "a", "backup", "name", "of", "the", "form", "filename", ".", "bak", ".", "1", ".", "If", "the", "filename", "already", "exists", "the", "number", "will", "be", "increased", "as", "much",...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L239-L258
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
auto_create_version
def auto_create_version(class_name, version, filename="__init__.py"): """ creates a version number in the __init__.py file. it can be accessed with __version__ :param class_name: :param version: :param filename: :return: """ version_filename = Path( "{classname}/{filename...
python
def auto_create_version(class_name, version, filename="__init__.py"): """ creates a version number in the __init__.py file. it can be accessed with __version__ :param class_name: :param version: :param filename: :return: """ version_filename = Path( "{classname}/{filename...
[ "def", "auto_create_version", "(", "class_name", ",", "version", ",", "filename", "=", "\"__init__.py\"", ")", ":", "version_filename", "=", "Path", "(", "\"{classname}/{filename}\"", ".", "format", "(", "classname", "=", "class_name", ",", "filename", "=", "filen...
creates a version number in the __init__.py file. it can be accessed with __version__ :param class_name: :param version: :param filename: :return:
[ "creates", "a", "version", "number", "in", "the", "__init__", ".", "py", "file", ".", "it", "can", "be", "accessed", "with", "__version__", ":", "param", "class_name", ":", ":", "param", "version", ":", ":", "param", "filename", ":", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L261-L279
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
readfile
def readfile(filename): """ returns the content of a file :param filename: the filename :return: """ with open(path_expand(filename), 'r') as f: content = f.read() return content
python
def readfile(filename): """ returns the content of a file :param filename: the filename :return: """ with open(path_expand(filename), 'r') as f: content = f.read() return content
[ "def", "readfile", "(", "filename", ")", ":", "with", "open", "(", "path_expand", "(", "filename", ")", ",", "'r'", ")", "as", "f", ":", "content", "=", "f", ".", "read", "(", ")", "return", "content" ]
returns the content of a file :param filename: the filename :return:
[ "returns", "the", "content", "of", "a", "file", ":", "param", "filename", ":", "the", "filename", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L319-L327
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
writefile
def writefile(filename, content): """ writes the content into the file :param filename: the filename :param content: teh content :return: """ with open(path_expand(filename), 'w') as outfile: outfile.write(content)
python
def writefile(filename, content): """ writes the content into the file :param filename: the filename :param content: teh content :return: """ with open(path_expand(filename), 'w') as outfile: outfile.write(content)
[ "def", "writefile", "(", "filename", ",", "content", ")", ":", "with", "open", "(", "path_expand", "(", "filename", ")", ",", "'w'", ")", "as", "outfile", ":", "outfile", ".", "write", "(", "content", ")" ]
writes the content into the file :param filename: the filename :param content: teh content :return:
[ "writes", "the", "content", "into", "the", "file", ":", "param", "filename", ":", "the", "filename", ":", "param", "content", ":", "teh", "content", ":", "return", ":" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L330-L338
cloudmesh/cloudmesh-common
cloudmesh/common/util.py
generate_password
def generate_password(length=8, lower=True, upper=True, number=True): """ generates a simple password. We should not really use this in production. :param length: the length of the password :param lower: True of lower case characters are allowed :param upper: True if upper case characters are allowe...
python
def generate_password(length=8, lower=True, upper=True, number=True): """ generates a simple password. We should not really use this in production. :param length: the length of the password :param lower: True of lower case characters are allowed :param upper: True if upper case characters are allowe...
[ "def", "generate_password", "(", "length", "=", "8", ",", "lower", "=", "True", ",", "upper", "=", "True", ",", "number", "=", "True", ")", ":", "lletters", "=", "\"abcdefghijklmnopqrstuvwxyz\"", "uletters", "=", "\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"", "# This doesn't g...
generates a simple password. We should not really use this in production. :param length: the length of the password :param lower: True of lower case characters are allowed :param upper: True if upper case characters are allowed :param number: True if numbers are allowed :return:
[ "generates", "a", "simple", "password", ".", "We", "should", "not", "really", "use", "this", "in", "production", ".", ":", "param", "length", ":", "the", "length", "of", "the", "password", ":", "param", "lower", ":", "True", "of", "lower", "case", "chara...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/util.py#L342-L372
cloudmesh/cloudmesh-common
cloudmesh/common/BaseConfigDict.py
check_file_for_tabs
def check_file_for_tabs(filename, verbose=True): """identifies if the file contains tabs and returns True if it does. It also prints the location of the lines and columns. If verbose is set to False, the location is not printed. :param verbose: if true prints information about issues :param filenam...
python
def check_file_for_tabs(filename, verbose=True): """identifies if the file contains tabs and returns True if it does. It also prints the location of the lines and columns. If verbose is set to False, the location is not printed. :param verbose: if true prints information about issues :param filenam...
[ "def", "check_file_for_tabs", "(", "filename", ",", "verbose", "=", "True", ")", ":", "file_contains_tabs", "=", "False", "with", "open", "(", "filename", ")", "as", "f", ":", "lines", "=", "f", ".", "read", "(", ")", ".", "split", "(", "\"\\n\"", ")",...
identifies if the file contains tabs and returns True if it does. It also prints the location of the lines and columns. If verbose is set to False, the location is not printed. :param verbose: if true prints information about issues :param filename: the filename :rtype: True if there are tabs in th...
[ "identifies", "if", "the", "file", "contains", "tabs", "and", "returns", "True", "if", "it", "does", ".", "It", "also", "prints", "the", "location", "of", "the", "lines", "and", "columns", ".", "If", "verbose", "is", "set", "to", "False", "the", "locatio...
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/BaseConfigDict.py#L31-L57
cloudmesh/cloudmesh-common
cloudmesh/common/BaseConfigDict.py
ordered_load
def ordered_load(stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict): """ Loads an ordered dict into a yaml while preserving the order :param stream: the name of the stream :param Loader: the yam loader (such as yaml.SafeLoader) :param object_pairs_hook: the ordered dict """ # noins...
python
def ordered_load(stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict): """ Loads an ordered dict into a yaml while preserving the order :param stream: the name of the stream :param Loader: the yam loader (such as yaml.SafeLoader) :param object_pairs_hook: the ordered dict """ # noins...
[ "def", "ordered_load", "(", "stream", ",", "Loader", "=", "yaml", ".", "Loader", ",", "object_pairs_hook", "=", "OrderedDict", ")", ":", "# noinspection PyClassHasNoInit", "class", "OrderedLoader", "(", "Loader", ")", ":", "\"\"\"\n A helper class to define an Or...
Loads an ordered dict into a yaml while preserving the order :param stream: the name of the stream :param Loader: the yam loader (such as yaml.SafeLoader) :param object_pairs_hook: the ordered dict
[ "Loads", "an", "ordered", "dict", "into", "a", "yaml", "while", "preserving", "the", "order" ]
train
https://github.com/cloudmesh/cloudmesh-common/blob/ae4fae09cd78205d179ea692dc58f0b0c8fea2b8/cloudmesh/common/BaseConfigDict.py#L63-L92