partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
PyTorchWrapperRNN.begin_update
Return the output of the wrapped PyTorch model for the given input, along with a callback to handle the backward pass.
thinc/extra/wrappers.py
def begin_update(self, x_data, h_0=None, drop=0.0): """Return the output of the wrapped PyTorch model for the given input, along with a callback to handle the backward pass. """ x_var = torch.autograd.Variable(xp2torch(x_data), requires_grad=True) # Make prediction out, ...
def begin_update(self, x_data, h_0=None, drop=0.0): """Return the output of the wrapped PyTorch model for the given input, along with a callback to handle the backward pass. """ x_var = torch.autograd.Variable(xp2torch(x_data), requires_grad=True) # Make prediction out, ...
[ "Return", "the", "output", "of", "the", "wrapped", "PyTorch", "model", "for", "the", "given", "input", "along", "with", "a", "callback", "to", "handle", "the", "backward", "pass", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/extra/wrappers.py#L135-L158
[ "def", "begin_update", "(", "self", ",", "x_data", ",", "h_0", "=", "None", ",", "drop", "=", "0.0", ")", ":", "x_var", "=", "torch", ".", "autograd", ".", "Variable", "(", "xp2torch", "(", "x_data", ")", ",", "requires_grad", "=", "True", ")", "# Ma...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
layerize
Wrap a function into a layer
thinc/api.py
def layerize(begin_update=None, predict=None, *args, **kwargs): """Wrap a function into a layer""" if begin_update is not None: return FunctionLayer(begin_update, predict=predict, *args, **kwargs) def wrapper(begin_update): return FunctionLayer(begin_update, *args, **kwargs) return wra...
def layerize(begin_update=None, predict=None, *args, **kwargs): """Wrap a function into a layer""" if begin_update is not None: return FunctionLayer(begin_update, predict=predict, *args, **kwargs) def wrapper(begin_update): return FunctionLayer(begin_update, *args, **kwargs) return wra...
[ "Wrap", "a", "function", "into", "a", "layer" ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/api.py#L12-L20
[ "def", "layerize", "(", "begin_update", "=", "None", ",", "predict", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "begin_update", "is", "not", "None", ":", "return", "FunctionLayer", "(", "begin_update", ",", "predict", "=", ...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
metalayerize
Wrap a function over a sequence of layers and an input into a layer.
thinc/api.py
def metalayerize(user_func): """Wrap a function over a sequence of layers and an input into a layer.""" def returned(layers, *args, **kwargs): def begin_update(X, *args, **kwargs): return user_func(layers, X, *args, **kwargs) return FunctionLayer(begin_update, *args, **kwargs) ...
def metalayerize(user_func): """Wrap a function over a sequence of layers and an input into a layer.""" def returned(layers, *args, **kwargs): def begin_update(X, *args, **kwargs): return user_func(layers, X, *args, **kwargs) return FunctionLayer(begin_update, *args, **kwargs) ...
[ "Wrap", "a", "function", "over", "a", "sequence", "of", "layers", "and", "an", "input", "into", "a", "layer", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/api.py#L23-L32
[ "def", "metalayerize", "(", "user_func", ")", ":", "def", "returned", "(", "layers", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "begin_update", "(", "X", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "user_func", "...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
noop
Transform a sequences of layers into a null operation.
thinc/api.py
def noop(*layers): """Transform a sequences of layers into a null operation.""" def begin_update(X, drop=0.0): return X, lambda D, *a, **k: D return begin_update
def noop(*layers): """Transform a sequences of layers into a null operation.""" def begin_update(X, drop=0.0): return X, lambda D, *a, **k: D return begin_update
[ "Transform", "a", "sequences", "of", "layers", "into", "a", "null", "operation", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/api.py#L85-L91
[ "def", "noop", "(", "*", "layers", ")", ":", "def", "begin_update", "(", "X", ",", "drop", "=", "0.0", ")", ":", "return", "X", ",", "lambda", "D", ",", "*", "a", ",", "*", "*", "k", ":", "D", "return", "begin_update" ]
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
chain
Compose two models `f` and `g` such that they become layers of a single feed-forward model that computes `g(f(x))`. Raises exception if their dimensions don't match.
thinc/api.py
def chain(*layers): """Compose two models `f` and `g` such that they become layers of a single feed-forward model that computes `g(f(x))`. Raises exception if their dimensions don't match. """ if len(layers) == 0: return FeedForward([]) elif len(layers) == 1: return layers[0] ...
def chain(*layers): """Compose two models `f` and `g` such that they become layers of a single feed-forward model that computes `g(f(x))`. Raises exception if their dimensions don't match. """ if len(layers) == 0: return FeedForward([]) elif len(layers) == 1: return layers[0] ...
[ "Compose", "two", "models", "f", "and", "g", "such", "that", "they", "become", "layers", "of", "a", "single", "feed", "-", "forward", "model", "that", "computes", "g", "(", "f", "(", "x", "))", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/api.py#L94-L105
[ "def", "chain", "(", "*", "layers", ")", ":", "if", "len", "(", "layers", ")", "==", "0", ":", "return", "FeedForward", "(", "[", "]", ")", "elif", "len", "(", "layers", ")", "==", "1", ":", "return", "layers", "[", "0", "]", "else", ":", "retu...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
clone
Construct `n` copies of a layer, with distinct weights. i.e. `clone(f, 3)(x)` computes `f(f'(f''(x)))`.
thinc/api.py
def clone(orig, n): """Construct `n` copies of a layer, with distinct weights. i.e. `clone(f, 3)(x)` computes `f(f'(f''(x)))`. """ if n == 0: return layerize(noop()) layers = [orig] for i in range(n - 1): layers.append(copy.deepcopy(orig)) layers[-1].set_id() return ...
def clone(orig, n): """Construct `n` copies of a layer, with distinct weights. i.e. `clone(f, 3)(x)` computes `f(f'(f''(x)))`. """ if n == 0: return layerize(noop()) layers = [orig] for i in range(n - 1): layers.append(copy.deepcopy(orig)) layers[-1].set_id() return ...
[ "Construct", "n", "copies", "of", "a", "layer", "with", "distinct", "weights", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/api.py#L108-L119
[ "def", "clone", "(", "orig", ",", "n", ")", ":", "if", "n", "==", "0", ":", "return", "layerize", "(", "noop", "(", ")", ")", "layers", "=", "[", "orig", "]", "for", "i", "in", "range", "(", "n", "-", "1", ")", ":", "layers", ".", "append", ...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
concatenate
Compose two or more models `f`, `g`, etc, such that their outputs are concatenated, i.e. `concatenate(f, g)(x)` computes `hstack(f(x), g(x))`
thinc/api.py
def concatenate(*layers): # pragma: no cover """Compose two or more models `f`, `g`, etc, such that their outputs are concatenated, i.e. `concatenate(f, g)(x)` computes `hstack(f(x), g(x))` """ if not layers: return noop() ops = layers[0].ops def begin_update(X, *a, **k): forwa...
def concatenate(*layers): # pragma: no cover """Compose two or more models `f`, `g`, etc, such that their outputs are concatenated, i.e. `concatenate(f, g)(x)` computes `hstack(f(x), g(x))` """ if not layers: return noop() ops = layers[0].ops def begin_update(X, *a, **k): forwa...
[ "Compose", "two", "or", "more", "models", "f", "g", "etc", "such", "that", "their", "outputs", "are", "concatenated", "i", ".", "e", ".", "concatenate", "(", "f", "g", ")", "(", "x", ")", "computes", "hstack", "(", "f", "(", "x", ")", "g", "(", "...
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/api.py#L122-L170
[ "def", "concatenate", "(", "*", "layers", ")", ":", "# pragma: no cover", "if", "not", "layers", ":", "return", "noop", "(", ")", "ops", "=", "layers", "[", "0", "]", ".", "ops", "def", "begin_update", "(", "X", ",", "*", "a", ",", "*", "*", "k", ...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
split_backward
Separate a sequence of layers' `begin_update` methods into two lists of functions: one that computes the forward values, and the other that completes the backward pass. The backward sequence is only populated after the forward functions have been applied.
thinc/api.py
def split_backward(layers): # pragma: no cover """Separate a sequence of layers' `begin_update` methods into two lists of functions: one that computes the forward values, and the other that completes the backward pass. The backward sequence is only populated after the forward functions have been applie...
def split_backward(layers): # pragma: no cover """Separate a sequence of layers' `begin_update` methods into two lists of functions: one that computes the forward values, and the other that completes the backward pass. The backward sequence is only populated after the forward functions have been applie...
[ "Separate", "a", "sequence", "of", "layers", "begin_update", "methods", "into", "two", "lists", "of", "functions", ":", "one", "that", "computes", "the", "forward", "values", "and", "the", "other", "that", "completes", "the", "backward", "pass", ".", "The", ...
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/api.py#L208-L216
[ "def", "split_backward", "(", "layers", ")", ":", "# pragma: no cover", "backward", "=", "[", "]", "forward", "=", "[", "sink_return", "(", "op", ".", "begin_update", ",", "backward", ".", "append", ")", "for", "op", "in", "layers", "]", "return", "forward...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
sink_return
Transform a function `func` that returns tuples into a function that returns single values. Call a function `sink` on the unused values.
thinc/api.py
def sink_return(func, sink, splitter=None): # pragma: no cover """Transform a function `func` that returns tuples into a function that returns single values. Call a function `sink` on the unused values. """ def wrap(*args, **kwargs): output = func(*args, **kwargs) if splitter is None: ...
def sink_return(func, sink, splitter=None): # pragma: no cover """Transform a function `func` that returns tuples into a function that returns single values. Call a function `sink` on the unused values. """ def wrap(*args, **kwargs): output = func(*args, **kwargs) if splitter is None: ...
[ "Transform", "a", "function", "func", "that", "returns", "tuples", "into", "a", "function", "that", "returns", "single", "values", ".", "Call", "a", "function", "sink", "on", "the", "unused", "values", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/api.py#L219-L233
[ "def", "sink_return", "(", "func", ",", "sink", ",", "splitter", "=", "None", ")", ":", "# pragma: no cover", "def", "wrap", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "output", "=", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")",...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
uniqued
Group inputs to a layer, so that the layer only has to compute for the unique values. The data is transformed back before output, and the same transformation is applied for the gradient. Effectively, this is a cache local to each minibatch. The uniqued wrapper is useful for word inputs, because common ...
thinc/api.py
def uniqued(layer, column=0): """Group inputs to a layer, so that the layer only has to compute for the unique values. The data is transformed back before output, and the same transformation is applied for the gradient. Effectively, this is a cache local to each minibatch. The uniqued wrapper is us...
def uniqued(layer, column=0): """Group inputs to a layer, so that the layer only has to compute for the unique values. The data is transformed back before output, and the same transformation is applied for the gradient. Effectively, this is a cache local to each minibatch. The uniqued wrapper is us...
[ "Group", "inputs", "to", "a", "layer", "so", "that", "the", "layer", "only", "has", "to", "compute", "for", "the", "unique", "values", ".", "The", "data", "is", "transformed", "back", "before", "output", "and", "the", "same", "transformation", "is", "appli...
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/api.py#L328-L364
[ "def", "uniqued", "(", "layer", ",", "column", "=", "0", ")", ":", "def", "uniqued_fwd", "(", "X", ",", "drop", "=", "0.0", ")", ":", "keys", "=", "X", "[", ":", ",", "column", "]", "keys", "=", "layer", ".", "ops", ".", "xp", ".", "ascontiguou...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
foreach
Map a layer across list items
thinc/api.py
def foreach(layer, drop_factor=1.0): """Map a layer across list items""" def foreach_fwd(docs, drop=0.0): sents = [] lengths = [] for doc in docs: doc_sents = [sent for sent in doc if len(sent)] subset = [ s for s in doc_sents if numpy.random.rand...
def foreach(layer, drop_factor=1.0): """Map a layer across list items""" def foreach_fwd(docs, drop=0.0): sents = [] lengths = [] for doc in docs: doc_sents = [sent for sent in doc if len(sent)] subset = [ s for s in doc_sents if numpy.random.rand...
[ "Map", "a", "layer", "across", "list", "items" ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/api.py#L367-L407
[ "def", "foreach", "(", "layer", ",", "drop_factor", "=", "1.0", ")", ":", "def", "foreach_fwd", "(", "docs", ",", "drop", "=", "0.0", ")", ":", "sents", "=", "[", "]", "lengths", "=", "[", "]", "for", "doc", "in", "docs", ":", "doc_sents", "=", "...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
foreach_sentence
Map a layer across sentences (assumes spaCy-esque .sents interface)
thinc/api.py
def foreach_sentence(layer, drop_factor=1.0): """Map a layer across sentences (assumes spaCy-esque .sents interface)""" def sentence_fwd(docs, drop=0.0): sents = [] lengths = [] for doc in docs: doc_sents = [sent for sent in doc.sents if len(sent)] subset = [ ...
def foreach_sentence(layer, drop_factor=1.0): """Map a layer across sentences (assumes spaCy-esque .sents interface)""" def sentence_fwd(docs, drop=0.0): sents = [] lengths = [] for doc in docs: doc_sents = [sent for sent in doc.sents if len(sent)] subset = [ ...
[ "Map", "a", "layer", "across", "sentences", "(", "assumes", "spaCy", "-", "esque", ".", "sents", "interface", ")" ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/api.py#L410-L442
[ "def", "foreach_sentence", "(", "layer", ",", "drop_factor", "=", "1.0", ")", ":", "def", "sentence_fwd", "(", "docs", ",", "drop", "=", "0.0", ")", ":", "sents", "=", "[", "]", "lengths", "=", "[", "]", "for", "doc", "in", "docs", ":", "doc_sents", ...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
func_dump
Serialize user defined function.
thinc/extra/_vendorized/keras_generic_utils.py
def func_dump(func): '''Serialize user defined function.''' code = marshal.dumps(func.__code__).decode('raw_unicode_escape') defaults = func.__defaults__ if func.__closure__: closure = tuple(c.cell_contents for c in func.__closure__) else: closure = None return code, defaults, cl...
def func_dump(func): '''Serialize user defined function.''' code = marshal.dumps(func.__code__).decode('raw_unicode_escape') defaults = func.__defaults__ if func.__closure__: closure = tuple(c.cell_contents for c in func.__closure__) else: closure = None return code, defaults, cl...
[ "Serialize", "user", "defined", "function", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/extra/_vendorized/keras_generic_utils.py#L42-L50
[ "def", "func_dump", "(", "func", ")", ":", "code", "=", "marshal", ".", "dumps", "(", "func", ".", "__code__", ")", ".", "decode", "(", "'raw_unicode_escape'", ")", "defaults", "=", "func", ".", "__defaults__", "if", "func", ".", "__closure__", ":", "clo...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
func_load
Deserialize user defined function.
thinc/extra/_vendorized/keras_generic_utils.py
def func_load(code, defaults=None, closure=None, globs=None): '''Deserialize user defined function.''' if isinstance(code, (tuple, list)): # unpack previous dump code, defaults, closure = code code = marshal.loads(code.encode('raw_unicode_escape')) if globs is None: globs = globals() ...
def func_load(code, defaults=None, closure=None, globs=None): '''Deserialize user defined function.''' if isinstance(code, (tuple, list)): # unpack previous dump code, defaults, closure = code code = marshal.loads(code.encode('raw_unicode_escape')) if globs is None: globs = globals() ...
[ "Deserialize", "user", "defined", "function", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/extra/_vendorized/keras_generic_utils.py#L53-L63
[ "def", "func_load", "(", "code", ",", "defaults", "=", "None", ",", "closure", "=", "None", ",", "globs", "=", "None", ")", ":", "if", "isinstance", "(", "code", ",", "(", "tuple", ",", "list", ")", ")", ":", "# unpack previous dump", "code", ",", "d...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
preprocess
Parse the texts with spaCy. Make one-hot vectors for the labels.
examples/text-pair/glove_mwe_multipool_predict.py
def preprocess(ops, nlp, rows, get_ids): """Parse the texts with spaCy. Make one-hot vectors for the labels.""" Xs = [] ys = [] for (text1, text2), label in rows: Xs.append((get_ids([nlp(text1)])[0], get_ids([nlp(text2)])[0])) ys.append(label) return Xs, to_categorical(ys, nb_classes...
def preprocess(ops, nlp, rows, get_ids): """Parse the texts with spaCy. Make one-hot vectors for the labels.""" Xs = [] ys = [] for (text1, text2), label in rows: Xs.append((get_ids([nlp(text1)])[0], get_ids([nlp(text2)])[0])) ys.append(label) return Xs, to_categorical(ys, nb_classes...
[ "Parse", "the", "texts", "with", "spaCy", ".", "Make", "one", "-", "hot", "vectors", "for", "the", "labels", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/examples/text-pair/glove_mwe_multipool_predict.py#L57-L64
[ "def", "preprocess", "(", "ops", ",", "nlp", ",", "rows", ",", "get_ids", ")", ":", "Xs", "=", "[", "]", "ys", "=", "[", "]", "for", "(", "text1", ",", "text2", ")", ",", "label", "in", "rows", ":", "Xs", ".", "append", "(", "(", "get_ids", "...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
BiLSTM
Create a bidirectional LSTM layer. Args: number out, number in
thinc/neural/_classes/rnn.py
def BiLSTM(nO, nI): """Create a bidirectional LSTM layer. Args: number out, number in""" return Bidirectional(LSTM(nO // 2, nI), LSTM(nO // 2, nI))
def BiLSTM(nO, nI): """Create a bidirectional LSTM layer. Args: number out, number in""" return Bidirectional(LSTM(nO // 2, nI), LSTM(nO // 2, nI))
[ "Create", "a", "bidirectional", "LSTM", "layer", ".", "Args", ":", "number", "out", "number", "in" ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/neural/_classes/rnn.py#L12-L14
[ "def", "BiLSTM", "(", "nO", ",", "nI", ")", ":", "return", "Bidirectional", "(", "LSTM", "(", "nO", "//", "2", ",", "nI", ")", ",", "LSTM", "(", "nO", "//", "2", ",", "nI", ")", ")" ]
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
LSTM
Create an LSTM layer. Args: number out, number in
thinc/neural/_classes/rnn.py
def LSTM(nO, nI): """Create an LSTM layer. Args: number out, number in""" weights = LSTM_weights(nO, nI) gates = LSTM_gates(weights.ops) return Recurrent(RNN_step(weights, gates))
def LSTM(nO, nI): """Create an LSTM layer. Args: number out, number in""" weights = LSTM_weights(nO, nI) gates = LSTM_gates(weights.ops) return Recurrent(RNN_step(weights, gates))
[ "Create", "an", "LSTM", "layer", ".", "Args", ":", "number", "out", "number", "in" ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/neural/_classes/rnn.py#L17-L21
[ "def", "LSTM", "(", "nO", ",", "nI", ")", ":", "weights", "=", "LSTM_weights", "(", "nO", ",", "nI", ")", "gates", "=", "LSTM_gates", "(", "weights", ".", "ops", ")", "return", "Recurrent", "(", "RNN_step", "(", "weights", ",", "gates", ")", ")" ]
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
Bidirectional
Stitch two RNN models into a bidirectional layer.
thinc/neural/_classes/rnn.py
def Bidirectional(l2r, r2l): """Stitch two RNN models into a bidirectional layer.""" nO = l2r.nO def birnn_fwd(Xs, drop=0.0): l2r_Zs, bp_l2r_Zs = l2r.begin_update(Xs, drop=drop) r2l_Zs, bp_r2l_Zs = r2l.begin_update( [l2r.ops.xp.ascontiguousarray(X[::-1]) for X in Xs] ) ...
def Bidirectional(l2r, r2l): """Stitch two RNN models into a bidirectional layer.""" nO = l2r.nO def birnn_fwd(Xs, drop=0.0): l2r_Zs, bp_l2r_Zs = l2r.begin_update(Xs, drop=drop) r2l_Zs, bp_r2l_Zs = r2l.begin_update( [l2r.ops.xp.ascontiguousarray(X[::-1]) for X in Xs] ) ...
[ "Stitch", "two", "RNN", "models", "into", "a", "bidirectional", "layer", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/neural/_classes/rnn.py#L24-L50
[ "def", "Bidirectional", "(", "l2r", ",", "r2l", ")", ":", "nO", "=", "l2r", ".", "nO", "def", "birnn_fwd", "(", "Xs", ",", "drop", "=", "0.0", ")", ":", "l2r_Zs", ",", "bp_l2r_Zs", "=", "l2r", ".", "begin_update", "(", "Xs", ",", "drop", "=", "dr...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
Recurrent
Apply a stepwise model over a sequence, maintaining state. For RNNs
thinc/neural/_classes/rnn.py
def Recurrent(step_model): """Apply a stepwise model over a sequence, maintaining state. For RNNs""" ops = step_model.ops def recurrent_fwd(seqs, drop=0.0): lengths = [len(X) for X in seqs] X, size_at_t, unpad = ops.square_sequences(seqs) Y = ops.allocate((X.shape[0], X.shape[1], st...
def Recurrent(step_model): """Apply a stepwise model over a sequence, maintaining state. For RNNs""" ops = step_model.ops def recurrent_fwd(seqs, drop=0.0): lengths = [len(X) for X in seqs] X, size_at_t, unpad = ops.square_sequences(seqs) Y = ops.allocate((X.shape[0], X.shape[1], st...
[ "Apply", "a", "stepwise", "model", "over", "a", "sequence", "maintaining", "state", ".", "For", "RNNs" ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/neural/_classes/rnn.py#L53-L119
[ "def", "Recurrent", "(", "step_model", ")", ":", "ops", "=", "step_model", ".", "ops", "def", "recurrent_fwd", "(", "seqs", ",", "drop", "=", "0.0", ")", ":", "lengths", "=", "[", "len", "(", "X", ")", "for", "X", "in", "seqs", "]", "X", ",", "si...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
RNN_step
Create a step model for an RNN, given weights and gates functions.
thinc/neural/_classes/rnn.py
def RNN_step(weights, gates): """Create a step model for an RNN, given weights and gates functions.""" def rnn_step_fwd(prevstate_inputs, drop=0.0): prevstate, inputs = prevstate_inputs cell_tm1, hidden_tm1 = prevstate acts, bp_acts = weights.begin_update((inputs, hidden_tm1), drop=dro...
def RNN_step(weights, gates): """Create a step model for an RNN, given weights and gates functions.""" def rnn_step_fwd(prevstate_inputs, drop=0.0): prevstate, inputs = prevstate_inputs cell_tm1, hidden_tm1 = prevstate acts, bp_acts = weights.begin_update((inputs, hidden_tm1), drop=dro...
[ "Create", "a", "step", "model", "for", "an", "RNN", "given", "weights", "and", "gates", "functions", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/neural/_classes/rnn.py#L122-L145
[ "def", "RNN_step", "(", "weights", ",", "gates", ")", ":", "def", "rnn_step_fwd", "(", "prevstate_inputs", ",", "drop", "=", "0.0", ")", ":", "prevstate", ",", "inputs", "=", "prevstate_inputs", "cell_tm1", ",", "hidden_tm1", "=", "prevstate", "acts", ",", ...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
get_file
Downloads a file from a URL if it not already in the cache. Passing the MD5 hash will verify the file after download as well as if it is already present in the cache. # Arguments fname: name of the file origin: original URL of the file untar: boolean, whether the file should be decompr...
thinc/extra/_vendorized/keras_data_utils.py
def get_file(fname, origin, untar=False, unzip=False, md5_hash=None, cache_subdir='datasets'): '''Downloads a file from a URL if it not already in the cache. Passing the MD5 hash will verify the file after download as well as if it is already present in the cache. # Arguments fname: n...
def get_file(fname, origin, untar=False, unzip=False, md5_hash=None, cache_subdir='datasets'): '''Downloads a file from a URL if it not already in the cache. Passing the MD5 hash will verify the file after download as well as if it is already present in the cache. # Arguments fname: n...
[ "Downloads", "a", "file", "from", "a", "URL", "if", "it", "not", "already", "in", "the", "cache", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/extra/_vendorized/keras_data_utils.py#L44-L143
[ "def", "get_file", "(", "fname", ",", "origin", ",", "untar", "=", "False", ",", "unzip", "=", "False", ",", "md5_hash", "=", "None", ",", "cache_subdir", "=", "'datasets'", ")", ":", "datadir_base", "=", "os", ".", "path", ".", "expanduser", "(", "os"...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
validate_file
Validates a file against a MD5 hash # Arguments fpath: path to the file being validated md5_hash: the MD5 hash being validated against # Returns Whether the file is valid
thinc/extra/_vendorized/keras_data_utils.py
def validate_file(fpath, md5_hash): '''Validates a file against a MD5 hash # Arguments fpath: path to the file being validated md5_hash: the MD5 hash being validated against # Returns Whether the file is valid ''' hasher = hashlib.md5() with open(fpath, 'rb') as f: ...
def validate_file(fpath, md5_hash): '''Validates a file against a MD5 hash # Arguments fpath: path to the file being validated md5_hash: the MD5 hash being validated against # Returns Whether the file is valid ''' hasher = hashlib.md5() with open(fpath, 'rb') as f: ...
[ "Validates", "a", "file", "against", "a", "MD5", "hash" ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/extra/_vendorized/keras_data_utils.py#L146-L163
[ "def", "validate_file", "(", "fpath", ",", "md5_hash", ")", ":", "hasher", "=", "hashlib", ".", "md5", "(", ")", "with", "open", "(", "fpath", ",", "'rb'", ")", "as", "f", ":", "buf", "=", "f", ".", "read", "(", ")", "hasher", ".", "update", "(",...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
Orth
Get word forms.
examples/spacy_tagger.py
def Orth(docs, drop=0.0): """Get word forms.""" ids = numpy.zeros((sum(len(doc) for doc in docs),), dtype="i") i = 0 for doc in docs: for token in doc: ids[i] = token.orth i += 1 return ids, None
def Orth(docs, drop=0.0): """Get word forms.""" ids = numpy.zeros((sum(len(doc) for doc in docs),), dtype="i") i = 0 for doc in docs: for token in doc: ids[i] = token.orth i += 1 return ids, None
[ "Get", "word", "forms", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/examples/spacy_tagger.py#L24-L32
[ "def", "Orth", "(", "docs", ",", "drop", "=", "0.0", ")", ":", "ids", "=", "numpy", ".", "zeros", "(", "(", "sum", "(", "len", "(", "doc", ")", "for", "doc", "in", "docs", ")", ",", ")", ",", "dtype", "=", "\"i\"", ")", "i", "=", "0", "for"...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
Shape
Get word shapes.
examples/spacy_tagger.py
def Shape(docs, drop=0.0): """Get word shapes.""" ids = numpy.zeros((sum(len(doc) for doc in docs),), dtype="i") i = 0 for doc in docs: for token in doc: ids[i] = token.shape i += 1 return ids, None
def Shape(docs, drop=0.0): """Get word shapes.""" ids = numpy.zeros((sum(len(doc) for doc in docs),), dtype="i") i = 0 for doc in docs: for token in doc: ids[i] = token.shape i += 1 return ids, None
[ "Get", "word", "shapes", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/examples/spacy_tagger.py#L58-L66
[ "def", "Shape", "(", "docs", ",", "drop", "=", "0.0", ")", ":", "ids", "=", "numpy", ".", "zeros", "(", "(", "sum", "(", "len", "(", "doc", ")", "for", "doc", "in", "docs", ")", ",", ")", ",", "dtype", "=", "\"i\"", ")", "i", "=", "0", "for...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
Prefix
Get prefixes.
examples/spacy_tagger.py
def Prefix(docs, drop=0.0): """Get prefixes.""" ids = numpy.zeros((sum(len(doc) for doc in docs),), dtype="i") i = 0 for doc in docs: for token in doc: ids[i] = token.prefix i += 1 return ids, None
def Prefix(docs, drop=0.0): """Get prefixes.""" ids = numpy.zeros((sum(len(doc) for doc in docs),), dtype="i") i = 0 for doc in docs: for token in doc: ids[i] = token.prefix i += 1 return ids, None
[ "Get", "prefixes", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/examples/spacy_tagger.py#L70-L78
[ "def", "Prefix", "(", "docs", ",", "drop", "=", "0.0", ")", ":", "ids", "=", "numpy", ".", "zeros", "(", "(", "sum", "(", "len", "(", "doc", ")", "for", "doc", "in", "docs", ")", ",", ")", ",", "dtype", "=", "\"i\"", ")", "i", "=", "0", "fo...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
Suffix
Get suffixes.
examples/spacy_tagger.py
def Suffix(docs, drop=0.0): """Get suffixes.""" ids = numpy.zeros((sum(len(doc) for doc in docs),), dtype="i") i = 0 for doc in docs: for token in doc: ids[i] = token.suffix i += 1 return ids, None
def Suffix(docs, drop=0.0): """Get suffixes.""" ids = numpy.zeros((sum(len(doc) for doc in docs),), dtype="i") i = 0 for doc in docs: for token in doc: ids[i] = token.suffix i += 1 return ids, None
[ "Get", "suffixes", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/examples/spacy_tagger.py#L82-L90
[ "def", "Suffix", "(", "docs", ",", "drop", "=", "0.0", ")", ":", "ids", "=", "numpy", ".", "zeros", "(", "(", "sum", "(", "len", "(", "doc", ")", "for", "doc", "in", "docs", ")", ",", ")", ",", "dtype", "=", "\"i\"", ")", "i", "=", "0", "fo...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
track_progress
Print training progress. Called after each epoch.
examples/text-pair/glove_mwe_multipool_siamese.py
def track_progress(**context): """Print training progress. Called after each epoch.""" model = context["model"] train_X = context["train_X"] dev_X = context["dev_X"] dev_y = context["dev_y"] n_train = len(train_X) trainer = context["trainer"] def each_epoch(): global epoch_train...
def track_progress(**context): """Print training progress. Called after each epoch.""" model = context["model"] train_X = context["train_X"] dev_X = context["dev_X"] dev_y = context["dev_y"] n_train = len(train_X) trainer = context["trainer"] def each_epoch(): global epoch_train...
[ "Print", "training", "progress", ".", "Called", "after", "each", "epoch", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/examples/text-pair/glove_mwe_multipool_siamese.py#L46-L64
[ "def", "track_progress", "(", "*", "*", "context", ")", ":", "model", "=", "context", "[", "\"model\"", "]", "train_X", "=", "context", "[", "\"train_X\"", "]", "dev_X", "=", "context", "[", "\"dev_X\"", "]", "dev_y", "=", "context", "[", "\"dev_y\"", "]...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
preprocess
Parse the texts with spaCy. Make one-hot vectors for the labels.
examples/text-pair/glove_mwe_multipool_siamese.py
def preprocess(ops, nlp, rows, get_ids): """Parse the texts with spaCy. Make one-hot vectors for the labels.""" Xs = [] ys = [] for (text1, text2), label in rows: Xs.append((get_ids([nlp(text1)])[0], get_ids([nlp(text2)])[0])) ys.append(label) return Xs, ops.asarray(ys, dtype="float3...
def preprocess(ops, nlp, rows, get_ids): """Parse the texts with spaCy. Make one-hot vectors for the labels.""" Xs = [] ys = [] for (text1, text2), label in rows: Xs.append((get_ids([nlp(text1)])[0], get_ids([nlp(text2)])[0])) ys.append(label) return Xs, ops.asarray(ys, dtype="float3...
[ "Parse", "the", "texts", "with", "spaCy", ".", "Make", "one", "-", "hot", "vectors", "for", "the", "labels", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/examples/text-pair/glove_mwe_multipool_siamese.py#L67-L74
[ "def", "preprocess", "(", "ops", ",", "nlp", ",", "rows", ",", "get_ids", ")", ":", "Xs", "=", "[", "]", "ys", "=", "[", "]", "for", "(", "text1", ",", "text2", ")", ",", "label", "in", "rows", ":", "Xs", ".", "append", "(", "(", "get_ids", "...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
is_cupy_array
Check whether an array is a cupy array
thinc/neural/util.py
def is_cupy_array(arr): """Check whether an array is a cupy array""" if cupy is None: return False elif isinstance(arr, cupy.ndarray): return True else: return False
def is_cupy_array(arr): """Check whether an array is a cupy array""" if cupy is None: return False elif isinstance(arr, cupy.ndarray): return True else: return False
[ "Check", "whether", "an", "array", "is", "a", "cupy", "array" ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/neural/util.py#L27-L34
[ "def", "is_cupy_array", "(", "arr", ")", ":", "if", "cupy", "is", "None", ":", "return", "False", "elif", "isinstance", "(", "arr", ",", "cupy", ".", "ndarray", ")", ":", "return", "True", "else", ":", "return", "False" ]
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
prefer_gpu
Use GPU if it's available. Returns True if so, False otherwise.
thinc/neural/util.py
def prefer_gpu(): """Use GPU if it's available. Returns True if so, False otherwise.""" from ._classes.model import Model from .ops import CupyOps if CupyOps.xp is not None: Model.Ops = CupyOps Model.ops = CupyOps() return True else: return False
def prefer_gpu(): """Use GPU if it's available. Returns True if so, False otherwise.""" from ._classes.model import Model from .ops import CupyOps if CupyOps.xp is not None: Model.Ops = CupyOps Model.ops = CupyOps() return True else: return False
[ "Use", "GPU", "if", "it", "s", "available", ".", "Returns", "True", "if", "so", "False", "otherwise", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/neural/util.py#L56-L66
[ "def", "prefer_gpu", "(", ")", ":", "from", ".", "_classes", ".", "model", "import", "Model", "from", ".", "ops", "import", "CupyOps", "if", "CupyOps", ".", "xp", "is", "not", "None", ":", "Model", ".", "Ops", "=", "CupyOps", "Model", ".", "ops", "="...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
mark_sentence_boundaries
Pad sentence sequences with EOL markers.
thinc/neural/util.py
def mark_sentence_boundaries(sequences, drop=0.0): # pragma: no cover """Pad sentence sequences with EOL markers.""" for sequence in sequences: sequence.insert(0, "-EOL-") sequence.insert(0, "-EOL-") sequence.append("-EOL-") sequence.append("-EOL-") return sequences, None
def mark_sentence_boundaries(sequences, drop=0.0): # pragma: no cover """Pad sentence sequences with EOL markers.""" for sequence in sequences: sequence.insert(0, "-EOL-") sequence.insert(0, "-EOL-") sequence.append("-EOL-") sequence.append("-EOL-") return sequences, None
[ "Pad", "sentence", "sequences", "with", "EOL", "markers", "." ]
explosion/thinc
python
https://github.com/explosion/thinc/blob/90129be5f0d6c665344245a7c37dbe1b8afceea2/thinc/neural/util.py#L97-L104
[ "def", "mark_sentence_boundaries", "(", "sequences", ",", "drop", "=", "0.0", ")", ":", "# pragma: no cover", "for", "sequence", "in", "sequences", ":", "sequence", ".", "insert", "(", "0", ",", "\"-EOL-\"", ")", "sequence", ".", "insert", "(", "0", ",", "...
90129be5f0d6c665344245a7c37dbe1b8afceea2
train
WebSocketHandler.send_text
Important: Fragmented(=continuation) messages are not supported since their usage cases are limited - when we don't know the payload length.
websocket_server/websocket_server.py
def send_text(self, message, opcode=OPCODE_TEXT): """ Important: Fragmented(=continuation) messages are not supported since their usage cases are limited - when we don't know the payload length. """ # Validate message if isinstance(message, bytes): message = ...
def send_text(self, message, opcode=OPCODE_TEXT): """ Important: Fragmented(=continuation) messages are not supported since their usage cases are limited - when we don't know the payload length. """ # Validate message if isinstance(message, bytes): message = ...
[ "Important", ":", "Fragmented", "(", "=", "continuation", ")", "messages", "are", "not", "supported", "since", "their", "usage", "cases", "are", "limited", "-", "when", "we", "don", "t", "know", "the", "payload", "length", "." ]
Pithikos/python-websocket-server
python
https://github.com/Pithikos/python-websocket-server/blob/ae6ee7f5d400cde43e2cb89b8c5aec812e927082/websocket_server/websocket_server.py#L252-L297
[ "def", "send_text", "(", "self", ",", "message", ",", "opcode", "=", "OPCODE_TEXT", ")", ":", "# Validate message", "if", "isinstance", "(", "message", ",", "bytes", ")", ":", "message", "=", "try_decode_UTF8", "(", "message", ")", "# this is slower but ensures ...
ae6ee7f5d400cde43e2cb89b8c5aec812e927082
train
main
Main function.
mackup/main.py
def main(): """Main function.""" # Get the command line arg args = docopt(__doc__, version="Mackup {}".format(VERSION)) mckp = Mackup() app_db = ApplicationsDatabase() def printAppHeader(app_name): if verbose: print(("\n{0} {1} {0}").format(header("---"), bold(app_name))) ...
def main(): """Main function.""" # Get the command line arg args = docopt(__doc__, version="Mackup {}".format(VERSION)) mckp = Mackup() app_db = ApplicationsDatabase() def printAppHeader(app_name): if verbose: print(("\n{0} {1} {0}").format(header("---"), bold(app_name))) ...
[ "Main", "function", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/main.py#L59-L178
[ "def", "main", "(", ")", ":", "# Get the command line arg", "args", "=", "docopt", "(", "__doc__", ",", "version", "=", "\"Mackup {}\"", ".", "format", "(", "VERSION", ")", ")", "mckp", "=", "Mackup", "(", ")", "app_db", "=", "ApplicationsDatabase", "(", "...
ed0b5626b033f232868900bfd5108df448873725
train
ApplicationProfile.getFilepaths
Get home and mackup filepaths for given file Args: filename (str) Returns: home_filepath, mackup_filepath (str, str)
mackup/application.py
def getFilepaths(self, filename): """ Get home and mackup filepaths for given file Args: filename (str) Returns: home_filepath, mackup_filepath (str, str) """ return (os.path.join(os.environ['HOME'], filename), os.path.join(self.m...
def getFilepaths(self, filename): """ Get home and mackup filepaths for given file Args: filename (str) Returns: home_filepath, mackup_filepath (str, str) """ return (os.path.join(os.environ['HOME'], filename), os.path.join(self.m...
[ "Get", "home", "and", "mackup", "filepaths", "for", "given", "file" ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/application.py#L33-L44
[ "def", "getFilepaths", "(", "self", ",", "filename", ")", ":", "return", "(", "os", ".", "path", ".", "join", "(", "os", ".", "environ", "[", "'HOME'", "]", ",", "filename", ")", ",", "os", ".", "path", ".", "join", "(", "self", ".", "mackup", "....
ed0b5626b033f232868900bfd5108df448873725
train
ApplicationProfile.backup
Backup the application config files. Algorithm: if exists home/file if home/file is a real file if exists mackup/file are you sure ? if sure rm mackup/file mv home/file mackup/file ...
mackup/application.py
def backup(self): """ Backup the application config files. Algorithm: if exists home/file if home/file is a real file if exists mackup/file are you sure ? if sure rm mackup/file ...
def backup(self): """ Backup the application config files. Algorithm: if exists home/file if home/file is a real file if exists mackup/file are you sure ? if sure rm mackup/file ...
[ "Backup", "the", "application", "config", "files", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/application.py#L46-L130
[ "def", "backup", "(", "self", ")", ":", "# For each file used by the application", "for", "filename", "in", "self", ".", "files", ":", "(", "home_filepath", ",", "mackup_filepath", ")", "=", "self", ".", "getFilepaths", "(", "filename", ")", "# If the file exists ...
ed0b5626b033f232868900bfd5108df448873725
train
ApplicationProfile.restore
Restore the application config files. Algorithm: if exists mackup/file if exists home/file are you sure ? if sure rm home/file link mackup/file home/file else link mackup/file home/file
mackup/application.py
def restore(self): """ Restore the application config files. Algorithm: if exists mackup/file if exists home/file are you sure ? if sure rm home/file link mackup/file home/file else ...
def restore(self): """ Restore the application config files. Algorithm: if exists mackup/file if exists home/file are you sure ? if sure rm home/file link mackup/file home/file else ...
[ "Restore", "the", "application", "config", "files", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/application.py#L132-L202
[ "def", "restore", "(", "self", ")", ":", "# For each file used by the application", "for", "filename", "in", "self", ".", "files", ":", "(", "home_filepath", ",", "mackup_filepath", ")", "=", "self", ".", "getFilepaths", "(", "filename", ")", "# If the file exists...
ed0b5626b033f232868900bfd5108df448873725
train
ApplicationProfile.uninstall
Uninstall Mackup. Restore any file where it was before the 1st Mackup backup. Algorithm: for each file in config if mackup/file exists if home/file exists delete home/file copy mackup/file home/file ...
mackup/application.py
def uninstall(self): """ Uninstall Mackup. Restore any file where it was before the 1st Mackup backup. Algorithm: for each file in config if mackup/file exists if home/file exists delete home/file ...
def uninstall(self): """ Uninstall Mackup. Restore any file where it was before the 1st Mackup backup. Algorithm: for each file in config if mackup/file exists if home/file exists delete home/file ...
[ "Uninstall", "Mackup", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/application.py#L204-L245
[ "def", "uninstall", "(", "self", ")", ":", "# For each file used by the application", "for", "filename", "in", "self", ".", "files", ":", "(", "home_filepath", ",", "mackup_filepath", ")", "=", "self", ".", "getFilepaths", "(", "filename", ")", "# If the mackup fi...
ed0b5626b033f232868900bfd5108df448873725
train
Mackup.check_for_usable_environment
Check if the current env is usable and has everything's required.
mackup/mackup.py
def check_for_usable_environment(self): """Check if the current env is usable and has everything's required.""" # Do not let the user run Mackup as root if os.geteuid() == 0: utils.error("Running Mackup as a superuser is useless and" " dangerous. Don't do it!"...
def check_for_usable_environment(self): """Check if the current env is usable and has everything's required.""" # Do not let the user run Mackup as root if os.geteuid() == 0: utils.error("Running Mackup as a superuser is useless and" " dangerous. Don't do it!"...
[ "Check", "if", "the", "current", "env", "is", "usable", "and", "has", "everything", "s", "required", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/mackup.py#L29-L39
[ "def", "check_for_usable_environment", "(", "self", ")", ":", "# Do not let the user run Mackup as root", "if", "os", ".", "geteuid", "(", ")", "==", "0", ":", "utils", ".", "error", "(", "\"Running Mackup as a superuser is useless and\"", "\" dangerous. Don't do it!\"", ...
ed0b5626b033f232868900bfd5108df448873725
train
Mackup.check_for_usable_restore_env
Check if the current env can be used to restore files.
mackup/mackup.py
def check_for_usable_restore_env(self): """Check if the current env can be used to restore files.""" self.check_for_usable_environment() if not os.path.isdir(self.mackup_folder): utils.error("Unable to find the Mackup folder: {}\n" "You might want to back up ...
def check_for_usable_restore_env(self): """Check if the current env can be used to restore files.""" self.check_for_usable_environment() if not os.path.isdir(self.mackup_folder): utils.error("Unable to find the Mackup folder: {}\n" "You might want to back up ...
[ "Check", "if", "the", "current", "env", "can", "be", "used", "to", "restore", "files", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/mackup.py#L53-L61
[ "def", "check_for_usable_restore_env", "(", "self", ")", ":", "self", ".", "check_for_usable_environment", "(", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "mackup_folder", ")", ":", "utils", ".", "error", "(", "\"Unable to find the Ma...
ed0b5626b033f232868900bfd5108df448873725
train
Mackup.create_mackup_home
If the Mackup home folder does not exist, create it.
mackup/mackup.py
def create_mackup_home(self): """If the Mackup home folder does not exist, create it.""" if not os.path.isdir(self.mackup_folder): if utils.confirm("Mackup needs a directory to store your" " configuration files\n" "Do you want to crea...
def create_mackup_home(self): """If the Mackup home folder does not exist, create it.""" if not os.path.isdir(self.mackup_folder): if utils.confirm("Mackup needs a directory to store your" " configuration files\n" "Do you want to crea...
[ "If", "the", "Mackup", "home", "folder", "does", "not", "exist", "create", "it", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/mackup.py#L67-L76
[ "def", "create_mackup_home", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "mackup_folder", ")", ":", "if", "utils", ".", "confirm", "(", "\"Mackup needs a directory to store your\"", "\" configuration files\\n\"", "\"Do yo...
ed0b5626b033f232868900bfd5108df448873725
train
Mackup.get_apps_to_backup
Get the list of applications that should be backed up by Mackup. It's the list of allowed apps minus the list of ignored apps. Returns: (set) List of application names to back up
mackup/mackup.py
def get_apps_to_backup(self): """ Get the list of applications that should be backed up by Mackup. It's the list of allowed apps minus the list of ignored apps. Returns: (set) List of application names to back up """ # Instantiate the app db app_db =...
def get_apps_to_backup(self): """ Get the list of applications that should be backed up by Mackup. It's the list of allowed apps minus the list of ignored apps. Returns: (set) List of application names to back up """ # Instantiate the app db app_db =...
[ "Get", "the", "list", "of", "applications", "that", "should", "be", "backed", "up", "by", "Mackup", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/mackup.py#L78-L98
[ "def", "get_apps_to_backup", "(", "self", ")", ":", "# Instantiate the app db", "app_db", "=", "appsdb", ".", "ApplicationsDatabase", "(", ")", "# If a list of apps to sync is specify, we only allow those", "# Or we allow every supported app by default", "apps_to_backup", "=", "s...
ed0b5626b033f232868900bfd5108df448873725
train
ApplicationsDatabase.get_config_files
Return the application configuration files. Return a list of configuration files describing the apps supported by Mackup. The files return are absolute full path to those files. e.g. /usr/lib/mackup/applications/bash.cfg Only one config file per application should be returned, custom c...
mackup/appsdb.py
def get_config_files(): """ Return the application configuration files. Return a list of configuration files describing the apps supported by Mackup. The files return are absolute full path to those files. e.g. /usr/lib/mackup/applications/bash.cfg Only one config file ...
def get_config_files(): """ Return the application configuration files. Return a list of configuration files describing the apps supported by Mackup. The files return are absolute full path to those files. e.g. /usr/lib/mackup/applications/bash.cfg Only one config file ...
[ "Return", "the", "application", "configuration", "files", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/appsdb.py#L77-L118
[ "def", "get_config_files", "(", ")", ":", "# Configure the config parser", "apps_dir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "(", "__file__", ")", ")", ",", "APPS_DIR", ")", ...
ed0b5626b033f232868900bfd5108df448873725
train
ApplicationsDatabase.get_app_names
Return application names. Return the list of application names that are available in the database. Returns: set of str.
mackup/appsdb.py
def get_app_names(self): """ Return application names. Return the list of application names that are available in the database. Returns: set of str. """ app_names = set() for name in self.apps: app_names.add(name) return ...
def get_app_names(self): """ Return application names. Return the list of application names that are available in the database. Returns: set of str. """ app_names = set() for name in self.apps: app_names.add(name) return ...
[ "Return", "application", "names", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/appsdb.py#L144-L158
[ "def", "get_app_names", "(", "self", ")", ":", "app_names", "=", "set", "(", ")", "for", "name", "in", "self", ".", "apps", ":", "app_names", ".", "add", "(", "name", ")", "return", "app_names" ]
ed0b5626b033f232868900bfd5108df448873725
train
ApplicationsDatabase.get_pretty_app_names
Return the list of pretty app names that are available in the database. Returns: set of str.
mackup/appsdb.py
def get_pretty_app_names(self): """ Return the list of pretty app names that are available in the database. Returns: set of str. """ pretty_app_names = set() for app_name in self.get_app_names(): pretty_app_names.add(self.get_name(app_name)) ...
def get_pretty_app_names(self): """ Return the list of pretty app names that are available in the database. Returns: set of str. """ pretty_app_names = set() for app_name in self.get_app_names(): pretty_app_names.add(self.get_name(app_name)) ...
[ "Return", "the", "list", "of", "pretty", "app", "names", "that", "are", "available", "in", "the", "database", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/appsdb.py#L160-L171
[ "def", "get_pretty_app_names", "(", "self", ")", ":", "pretty_app_names", "=", "set", "(", ")", "for", "app_name", "in", "self", ".", "get_app_names", "(", ")", ":", "pretty_app_names", ".", "add", "(", "self", ".", "get_name", "(", "app_name", ")", ")", ...
ed0b5626b033f232868900bfd5108df448873725
train
confirm
Ask the user if he really want something to happen. Args: question(str): What can happen Returns: (boolean): Confirmed or not
mackup/utils.py
def confirm(question): """ Ask the user if he really want something to happen. Args: question(str): What can happen Returns: (boolean): Confirmed or not """ if FORCE_YES: return True while True: answer = input(question + ' <Yes|No>').lower() if ans...
def confirm(question): """ Ask the user if he really want something to happen. Args: question(str): What can happen Returns: (boolean): Confirmed or not """ if FORCE_YES: return True while True: answer = input(question + ' <Yes|No>').lower() if ans...
[ "Ask", "the", "user", "if", "he", "really", "want", "something", "to", "happen", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L20-L43
[ "def", "confirm", "(", "question", ")", ":", "if", "FORCE_YES", ":", "return", "True", "while", "True", ":", "answer", "=", "input", "(", "question", "+", "' <Yes|No>'", ")", ".", "lower", "(", ")", "if", "answer", "==", "'yes'", "or", "answer", "==", ...
ed0b5626b033f232868900bfd5108df448873725
train
delete
Delete the given file, directory or link. It Should support undelete later on. Args: filepath (str): Absolute full path to a file. e.g. /path/to/file
mackup/utils.py
def delete(filepath): """ Delete the given file, directory or link. It Should support undelete later on. Args: filepath (str): Absolute full path to a file. e.g. /path/to/file """ # Some files have ACLs, let's remove them recursively remove_acl(filepath) # Some files have immu...
def delete(filepath): """ Delete the given file, directory or link. It Should support undelete later on. Args: filepath (str): Absolute full path to a file. e.g. /path/to/file """ # Some files have ACLs, let's remove them recursively remove_acl(filepath) # Some files have immu...
[ "Delete", "the", "given", "file", "directory", "or", "link", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L46-L65
[ "def", "delete", "(", "filepath", ")", ":", "# Some files have ACLs, let's remove them recursively", "remove_acl", "(", "filepath", ")", "# Some files have immutable attributes, let's remove them recursively", "remove_immutable_attribute", "(", "filepath", ")", "# Finally remove the ...
ed0b5626b033f232868900bfd5108df448873725
train
copy
Copy a file or a folder (recursively) from src to dst. For simplicity sake, both src and dst must be absolute path and must include the filename of the file or folder. Also do not include any trailing slash. e.g. copy('/path/to/src_file', '/path/to/dst_file') or copy('/path/to/src_folder', '/path/...
mackup/utils.py
def copy(src, dst): """ Copy a file or a folder (recursively) from src to dst. For simplicity sake, both src and dst must be absolute path and must include the filename of the file or folder. Also do not include any trailing slash. e.g. copy('/path/to/src_file', '/path/to/dst_file') or cop...
def copy(src, dst): """ Copy a file or a folder (recursively) from src to dst. For simplicity sake, both src and dst must be absolute path and must include the filename of the file or folder. Also do not include any trailing slash. e.g. copy('/path/to/src_file', '/path/to/dst_file') or cop...
[ "Copy", "a", "file", "or", "a", "folder", "(", "recursively", ")", "from", "src", "to", "dst", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L68-L109
[ "def", "copy", "(", "src", ",", "dst", ")", ":", "assert", "isinstance", "(", "src", ",", "str", ")", "assert", "os", ".", "path", ".", "exists", "(", "src", ")", "assert", "isinstance", "(", "dst", ",", "str", ")", "# Create the path to the dst file if ...
ed0b5626b033f232868900bfd5108df448873725
train
link
Create a link to a target file or a folder. For simplicity sake, both target and link_to must be absolute path and must include the filename of the file or folder. Also do not include any trailing slash. e.g. link('/path/to/file', '/path/to/link') But not: link('/path/to/file', 'path/to/') or...
mackup/utils.py
def link(target, link_to): """ Create a link to a target file or a folder. For simplicity sake, both target and link_to must be absolute path and must include the filename of the file or folder. Also do not include any trailing slash. e.g. link('/path/to/file', '/path/to/link') But not: l...
def link(target, link_to): """ Create a link to a target file or a folder. For simplicity sake, both target and link_to must be absolute path and must include the filename of the file or folder. Also do not include any trailing slash. e.g. link('/path/to/file', '/path/to/link') But not: l...
[ "Create", "a", "link", "to", "a", "target", "file", "or", "a", "folder", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L112-L142
[ "def", "link", "(", "target", ",", "link_to", ")", ":", "assert", "isinstance", "(", "target", ",", "str", ")", "assert", "os", ".", "path", ".", "exists", "(", "target", ")", "assert", "isinstance", "(", "link_to", ",", "str", ")", "# Create the path to...
ed0b5626b033f232868900bfd5108df448873725
train
chmod
Recursively set the chmod for files to 0600 and 0700 for folders. It's ok unless we need something more specific. Args: target (str): Root file or folder
mackup/utils.py
def chmod(target): """ Recursively set the chmod for files to 0600 and 0700 for folders. It's ok unless we need something more specific. Args: target (str): Root file or folder """ assert isinstance(target, str) assert os.path.exists(target) file_mode = stat.S_IRUSR | stat.S_I...
def chmod(target): """ Recursively set the chmod for files to 0600 and 0700 for folders. It's ok unless we need something more specific. Args: target (str): Root file or folder """ assert isinstance(target, str) assert os.path.exists(target) file_mode = stat.S_IRUSR | stat.S_I...
[ "Recursively", "set", "the", "chmod", "for", "files", "to", "0600", "and", "0700", "for", "folders", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L145-L178
[ "def", "chmod", "(", "target", ")", ":", "assert", "isinstance", "(", "target", ",", "str", ")", "assert", "os", ".", "path", ".", "exists", "(", "target", ")", "file_mode", "=", "stat", ".", "S_IRUSR", "|", "stat", ".", "S_IWUSR", "folder_mode", "=", ...
ed0b5626b033f232868900bfd5108df448873725
train
error
Throw an error with the given message and immediately quit. Args: message(str): The message to display.
mackup/utils.py
def error(message): """ Throw an error with the given message and immediately quit. Args: message(str): The message to display. """ fail = '\033[91m' end = '\033[0m' sys.exit(fail + "Error: {}".format(message) + end)
def error(message): """ Throw an error with the given message and immediately quit. Args: message(str): The message to display. """ fail = '\033[91m' end = '\033[0m' sys.exit(fail + "Error: {}".format(message) + end)
[ "Throw", "an", "error", "with", "the", "given", "message", "and", "immediately", "quit", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L181-L190
[ "def", "error", "(", "message", ")", ":", "fail", "=", "'\\033[91m'", "end", "=", "'\\033[0m'", "sys", ".", "exit", "(", "fail", "+", "\"Error: {}\"", ".", "format", "(", "message", ")", "+", "end", ")" ]
ed0b5626b033f232868900bfd5108df448873725
train
get_dropbox_folder_location
Try to locate the Dropbox folder. Returns: (str) Full path to the current Dropbox folder
mackup/utils.py
def get_dropbox_folder_location(): """ Try to locate the Dropbox folder. Returns: (str) Full path to the current Dropbox folder """ host_db_path = os.path.join(os.environ['HOME'], '.dropbox/host.db') try: with open(host_db_path, 'r') as f_hostdb: data = f_hostdb.read...
def get_dropbox_folder_location(): """ Try to locate the Dropbox folder. Returns: (str) Full path to the current Dropbox folder """ host_db_path = os.path.join(os.environ['HOME'], '.dropbox/host.db') try: with open(host_db_path, 'r') as f_hostdb: data = f_hostdb.read...
[ "Try", "to", "locate", "the", "Dropbox", "folder", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L193-L208
[ "def", "get_dropbox_folder_location", "(", ")", ":", "host_db_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "environ", "[", "'HOME'", "]", ",", "'.dropbox/host.db'", ")", "try", ":", "with", "open", "(", "host_db_path", ",", "'r'", ")", "as...
ed0b5626b033f232868900bfd5108df448873725
train
get_google_drive_folder_location
Try to locate the Google Drive folder. Returns: (str) Full path to the current Google Drive folder
mackup/utils.py
def get_google_drive_folder_location(): """ Try to locate the Google Drive folder. Returns: (str) Full path to the current Google Drive folder """ gdrive_db_path = 'Library/Application Support/Google/Drive/sync_config.db' yosemite_gdrive_db_path = ('Library/Application Support/Google/Dr...
def get_google_drive_folder_location(): """ Try to locate the Google Drive folder. Returns: (str) Full path to the current Google Drive folder """ gdrive_db_path = 'Library/Application Support/Google/Drive/sync_config.db' yosemite_gdrive_db_path = ('Library/Application Support/Google/Dr...
[ "Try", "to", "locate", "the", "Google", "Drive", "folder", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L211-L244
[ "def", "get_google_drive_folder_location", "(", ")", ":", "gdrive_db_path", "=", "'Library/Application Support/Google/Drive/sync_config.db'", "yosemite_gdrive_db_path", "=", "(", "'Library/Application Support/Google/Drive/'", "'user_default/sync_config.db'", ")", "yosemite_gdrive_db", ...
ed0b5626b033f232868900bfd5108df448873725
train
get_box_folder_location
Try to locate the Box folder. Returns: (str) Full path to the current Box folder
mackup/utils.py
def get_box_folder_location(): """ Try to locate the Box folder. Returns: (str) Full path to the current Box folder """ box_prefs_path = ('Library/Application Support/Box/Box Sync/' 'sync_root_folder.txt') box_home = None box_prefs = os.path.join(os.environ['H...
def get_box_folder_location(): """ Try to locate the Box folder. Returns: (str) Full path to the current Box folder """ box_prefs_path = ('Library/Application Support/Box/Box Sync/' 'sync_root_folder.txt') box_home = None box_prefs = os.path.join(os.environ['H...
[ "Try", "to", "locate", "the", "Box", "folder", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L247-L266
[ "def", "get_box_folder_location", "(", ")", ":", "box_prefs_path", "=", "(", "'Library/Application Support/Box/Box Sync/'", "'sync_root_folder.txt'", ")", "box_home", "=", "None", "box_prefs", "=", "os", ".", "path", ".", "join", "(", "os", ".", "environ", "[", "'...
ed0b5626b033f232868900bfd5108df448873725
train
get_copy_folder_location
Try to locate the Copy folder. Returns: (str) Full path to the current Copy folder
mackup/utils.py
def get_copy_folder_location(): """ Try to locate the Copy folder. Returns: (str) Full path to the current Copy folder """ copy_settings_path = 'Library/Application Support/Copy Agent/config.db' copy_home = None copy_settings = os.path.join(os.environ['HOME'], copy_settings_path) ...
def get_copy_folder_location(): """ Try to locate the Copy folder. Returns: (str) Full path to the current Copy folder """ copy_settings_path = 'Library/Application Support/Copy Agent/config.db' copy_home = None copy_settings = os.path.join(os.environ['HOME'], copy_settings_path) ...
[ "Try", "to", "locate", "the", "Copy", "folder", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L269-L296
[ "def", "get_copy_folder_location", "(", ")", ":", "copy_settings_path", "=", "'Library/Application Support/Copy Agent/config.db'", "copy_home", "=", "None", "copy_settings", "=", "os", ".", "path", ".", "join", "(", "os", ".", "environ", "[", "'HOME'", "]", ",", "...
ed0b5626b033f232868900bfd5108df448873725
train
get_icloud_folder_location
Try to locate the iCloud Drive folder. Returns: (str) Full path to the iCloud Drive folder.
mackup/utils.py
def get_icloud_folder_location(): """ Try to locate the iCloud Drive folder. Returns: (str) Full path to the iCloud Drive folder. """ yosemite_icloud_path = '~/Library/Mobile Documents/com~apple~CloudDocs/' icloud_home = os.path.expanduser(yosemite_icloud_path) if not os.path.isdi...
def get_icloud_folder_location(): """ Try to locate the iCloud Drive folder. Returns: (str) Full path to the iCloud Drive folder. """ yosemite_icloud_path = '~/Library/Mobile Documents/com~apple~CloudDocs/' icloud_home = os.path.expanduser(yosemite_icloud_path) if not os.path.isdi...
[ "Try", "to", "locate", "the", "iCloud", "Drive", "folder", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L299-L313
[ "def", "get_icloud_folder_location", "(", ")", ":", "yosemite_icloud_path", "=", "'~/Library/Mobile Documents/com~apple~CloudDocs/'", "icloud_home", "=", "os", ".", "path", ".", "expanduser", "(", "yosemite_icloud_path", ")", "if", "not", "os", ".", "path", ".", "isdi...
ed0b5626b033f232868900bfd5108df448873725
train
is_process_running
Check if a process with the given name is running. Args: (str): Process name, e.g. "Sublime Text" Returns: (bool): True if the process is running
mackup/utils.py
def is_process_running(process_name): """ Check if a process with the given name is running. Args: (str): Process name, e.g. "Sublime Text" Returns: (bool): True if the process is running """ is_running = False # On systems with pgrep, check if the given process is running...
def is_process_running(process_name): """ Check if a process with the given name is running. Args: (str): Process name, e.g. "Sublime Text" Returns: (bool): True if the process is running """ is_running = False # On systems with pgrep, check if the given process is running...
[ "Check", "if", "a", "process", "with", "the", "given", "name", "is", "running", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L316-L335
[ "def", "is_process_running", "(", "process_name", ")", ":", "is_running", "=", "False", "# On systems with pgrep, check if the given process is running", "if", "os", ".", "path", ".", "isfile", "(", "'/usr/bin/pgrep'", ")", ":", "dev_null", "=", "open", "(", "os", "...
ed0b5626b033f232868900bfd5108df448873725
train
remove_acl
Remove the ACL of the file or folder located on the given path. Also remove the ACL of any file and folder below the given one, recursively. Args: path (str): Path to the file or folder to remove the ACL for, recursively.
mackup/utils.py
def remove_acl(path): """ Remove the ACL of the file or folder located on the given path. Also remove the ACL of any file and folder below the given one, recursively. Args: path (str): Path to the file or folder to remove the ACL for, recursively. """ # Some fil...
def remove_acl(path): """ Remove the ACL of the file or folder located on the given path. Also remove the ACL of any file and folder below the given one, recursively. Args: path (str): Path to the file or folder to remove the ACL for, recursively. """ # Some fil...
[ "Remove", "the", "ACL", "of", "the", "file", "or", "folder", "located", "on", "the", "given", "path", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L338-L355
[ "def", "remove_acl", "(", "path", ")", ":", "# Some files have ACLs, let's remove them recursively", "if", "(", "platform", ".", "system", "(", ")", "==", "constants", ".", "PLATFORM_DARWIN", "and", "os", ".", "path", ".", "isfile", "(", "'/bin/chmod'", ")", ")"...
ed0b5626b033f232868900bfd5108df448873725
train
can_file_be_synced_on_current_platform
Check if the given path can be synced locally. Check if it makes sense to sync the file at the given path on the current platform. For now we don't sync any file in the ~/Library folder on GNU/Linux. There might be other exceptions in the future. Args: (str): Path to the file or folder to ...
mackup/utils.py
def can_file_be_synced_on_current_platform(path): """ Check if the given path can be synced locally. Check if it makes sense to sync the file at the given path on the current platform. For now we don't sync any file in the ~/Library folder on GNU/Linux. There might be other exceptions in the fu...
def can_file_be_synced_on_current_platform(path): """ Check if the given path can be synced locally. Check if it makes sense to sync the file at the given path on the current platform. For now we don't sync any file in the ~/Library folder on GNU/Linux. There might be other exceptions in the fu...
[ "Check", "if", "the", "given", "path", "can", "be", "synced", "locally", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/utils.py#L379-L411
[ "def", "can_file_be_synced_on_current_platform", "(", "path", ")", ":", "can_be_synced", "=", "True", "# If the given path is relative, prepend home", "fullpath", "=", "os", ".", "path", ".", "join", "(", "os", ".", "environ", "[", "'HOME'", "]", ",", "path", ")",...
ed0b5626b033f232868900bfd5108df448873725
train
Config.fullpath
Full path to the Mackup configuration files. The full path to the directory when Mackup is storing the configuration files. Returns: str
mackup/config.py
def fullpath(self): """ Full path to the Mackup configuration files. The full path to the directory when Mackup is storing the configuration files. Returns: str """ return str(os.path.join(self.path, self.directory))
def fullpath(self): """ Full path to the Mackup configuration files. The full path to the directory when Mackup is storing the configuration files. Returns: str """ return str(os.path.join(self.path, self.directory))
[ "Full", "path", "to", "the", "Mackup", "configuration", "files", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/config.py#L100-L110
[ "def", "fullpath", "(", "self", ")", ":", "return", "str", "(", "os", ".", "path", ".", "join", "(", "self", ".", "path", ",", "self", ".", "directory", ")", ")" ]
ed0b5626b033f232868900bfd5108df448873725
train
Config._setup_parser
Configure the ConfigParser instance the way we want it. Args: filename (str) or None Returns: SafeConfigParser
mackup/config.py
def _setup_parser(self, filename=None): """ Configure the ConfigParser instance the way we want it. Args: filename (str) or None Returns: SafeConfigParser """ assert isinstance(filename, str) or filename is None # If we are not overridin...
def _setup_parser(self, filename=None): """ Configure the ConfigParser instance the way we want it. Args: filename (str) or None Returns: SafeConfigParser """ assert isinstance(filename, str) or filename is None # If we are not overridin...
[ "Configure", "the", "ConfigParser", "instance", "the", "way", "we", "want", "it", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/config.py#L132-L151
[ "def", "_setup_parser", "(", "self", ",", "filename", "=", "None", ")", ":", "assert", "isinstance", "(", "filename", ",", "str", ")", "or", "filename", "is", "None", "# If we are not overriding the config filename", "if", "not", "filename", ":", "filename", "="...
ed0b5626b033f232868900bfd5108df448873725
train
Config._warn_on_old_config
Warn the user if an old config format is detected.
mackup/config.py
def _warn_on_old_config(self): """Warn the user if an old config format is detected.""" # Is an old setion is in the config file ? old_sections = ['Allowed Applications', 'Ignored Applications'] for old_section in old_sections: if self._parser.has_section(old_section): ...
def _warn_on_old_config(self): """Warn the user if an old config format is detected.""" # Is an old setion is in the config file ? old_sections = ['Allowed Applications', 'Ignored Applications'] for old_section in old_sections: if self._parser.has_section(old_section): ...
[ "Warn", "the", "user", "if", "an", "old", "config", "format", "is", "detected", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/config.py#L153-L170
[ "def", "_warn_on_old_config", "(", "self", ")", ":", "# Is an old setion is in the config file ?", "old_sections", "=", "[", "'Allowed Applications'", ",", "'Ignored Applications'", "]", "for", "old_section", "in", "old_sections", ":", "if", "self", ".", "_parser", ".",...
ed0b5626b033f232868900bfd5108df448873725
train
Config._parse_engine
Parse the storage engine in the config. Returns: str
mackup/config.py
def _parse_engine(self): """ Parse the storage engine in the config. Returns: str """ if self._parser.has_option('storage', 'engine'): engine = str(self._parser.get('storage', 'engine')) else: engine = ENGINE_DROPBOX assert is...
def _parse_engine(self): """ Parse the storage engine in the config. Returns: str """ if self._parser.has_option('storage', 'engine'): engine = str(self._parser.get('storage', 'engine')) else: engine = ENGINE_DROPBOX assert is...
[ "Parse", "the", "storage", "engine", "in", "the", "config", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/config.py#L172-L194
[ "def", "_parse_engine", "(", "self", ")", ":", "if", "self", ".", "_parser", ".", "has_option", "(", "'storage'", ",", "'engine'", ")", ":", "engine", "=", "str", "(", "self", ".", "_parser", ".", "get", "(", "'storage'", ",", "'engine'", ")", ")", "...
ed0b5626b033f232868900bfd5108df448873725
train
Config._parse_path
Parse the storage path in the config. Returns: str
mackup/config.py
def _parse_path(self): """ Parse the storage path in the config. Returns: str """ if self.engine == ENGINE_DROPBOX: path = get_dropbox_folder_location() elif self.engine == ENGINE_GDRIVE: path = get_google_drive_folder_location() ...
def _parse_path(self): """ Parse the storage path in the config. Returns: str """ if self.engine == ENGINE_DROPBOX: path = get_dropbox_folder_location() elif self.engine == ENGINE_GDRIVE: path = get_google_drive_folder_location() ...
[ "Parse", "the", "storage", "path", "in", "the", "config", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/config.py#L196-L221
[ "def", "_parse_path", "(", "self", ")", ":", "if", "self", ".", "engine", "==", "ENGINE_DROPBOX", ":", "path", "=", "get_dropbox_folder_location", "(", ")", "elif", "self", ".", "engine", "==", "ENGINE_GDRIVE", ":", "path", "=", "get_google_drive_folder_location...
ed0b5626b033f232868900bfd5108df448873725
train
Config._parse_directory
Parse the storage directory in the config. Returns: str
mackup/config.py
def _parse_directory(self): """ Parse the storage directory in the config. Returns: str """ if self._parser.has_option('storage', 'directory'): directory = self._parser.get('storage', 'directory') # Don't allow CUSTOM_APPS_DIR as a storage dir...
def _parse_directory(self): """ Parse the storage directory in the config. Returns: str """ if self._parser.has_option('storage', 'directory'): directory = self._parser.get('storage', 'directory') # Don't allow CUSTOM_APPS_DIR as a storage dir...
[ "Parse", "the", "storage", "directory", "in", "the", "config", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/config.py#L223-L239
[ "def", "_parse_directory", "(", "self", ")", ":", "if", "self", ".", "_parser", ".", "has_option", "(", "'storage'", ",", "'directory'", ")", ":", "directory", "=", "self", ".", "_parser", ".", "get", "(", "'storage'", ",", "'directory'", ")", "# Don't all...
ed0b5626b033f232868900bfd5108df448873725
train
Config._parse_apps_to_ignore
Parse the applications to ignore in the config. Returns: set
mackup/config.py
def _parse_apps_to_ignore(self): """ Parse the applications to ignore in the config. Returns: set """ # We ignore nothing by default apps_to_ignore = set() # Is the "[applications_to_ignore]" in the cfg file ? section_title = 'applications_to...
def _parse_apps_to_ignore(self): """ Parse the applications to ignore in the config. Returns: set """ # We ignore nothing by default apps_to_ignore = set() # Is the "[applications_to_ignore]" in the cfg file ? section_title = 'applications_to...
[ "Parse", "the", "applications", "to", "ignore", "in", "the", "config", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/config.py#L241-L256
[ "def", "_parse_apps_to_ignore", "(", "self", ")", ":", "# We ignore nothing by default", "apps_to_ignore", "=", "set", "(", ")", "# Is the \"[applications_to_ignore]\" in the cfg file ?", "section_title", "=", "'applications_to_ignore'", "if", "self", ".", "_parser", ".", "...
ed0b5626b033f232868900bfd5108df448873725
train
Config._parse_apps_to_sync
Parse the applications to backup in the config. Returns: set
mackup/config.py
def _parse_apps_to_sync(self): """ Parse the applications to backup in the config. Returns: set """ # We allow nothing by default apps_to_sync = set() # Is the "[applications_to_sync]" section in the cfg file ? section_title = 'applications_t...
def _parse_apps_to_sync(self): """ Parse the applications to backup in the config. Returns: set """ # We allow nothing by default apps_to_sync = set() # Is the "[applications_to_sync]" section in the cfg file ? section_title = 'applications_t...
[ "Parse", "the", "applications", "to", "backup", "in", "the", "config", "." ]
lra/mackup
python
https://github.com/lra/mackup/blob/ed0b5626b033f232868900bfd5108df448873725/mackup/config.py#L258-L273
[ "def", "_parse_apps_to_sync", "(", "self", ")", ":", "# We allow nothing by default", "apps_to_sync", "=", "set", "(", ")", "# Is the \"[applications_to_sync]\" section in the cfg file ?", "section_title", "=", "'applications_to_sync'", "if", "self", ".", "_parser", ".", "h...
ed0b5626b033f232868900bfd5108df448873725
train
load_template
Build tabula-py option from template file Args: file_like_obj: File like object of Tabula app template Returns: `obj`:dict: tabula-py options
tabula/template.py
def load_template(path_or_buffer): '''Build tabula-py option from template file Args: file_like_obj: File like object of Tabula app template Returns: `obj`:dict: tabula-py options ''' from itertools import groupby from operator import itemgetter path_or_buffer = _stringif...
def load_template(path_or_buffer): '''Build tabula-py option from template file Args: file_like_obj: File like object of Tabula app template Returns: `obj`:dict: tabula-py options ''' from itertools import groupby from operator import itemgetter path_or_buffer = _stringif...
[ "Build", "tabula", "-", "py", "option", "from", "template", "file" ]
chezou/tabula-py
python
https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/template.py#L6-L44
[ "def", "load_template", "(", "path_or_buffer", ")", ":", "from", "itertools", "import", "groupby", "from", "operator", "import", "itemgetter", "path_or_buffer", "=", "_stringify_path", "(", "path_or_buffer", ")", "if", "is_file_like", "(", "path_or_buffer", ")", ":"...
e61d46ee3c93bb40396e48dac5a9493e898f561a
train
_convert_template_option
Convert Tabula app template to tabula-py option Args: template (dict): Tabula app template Returns: `obj`:dict: tabula-py option
tabula/template.py
def _convert_template_option(template): '''Convert Tabula app template to tabula-py option Args: template (dict): Tabula app template Returns: `obj`:dict: tabula-py option ''' option = {} extraction_method = template.get('extraction_method') if extraction_method == 'guess'...
def _convert_template_option(template): '''Convert Tabula app template to tabula-py option Args: template (dict): Tabula app template Returns: `obj`:dict: tabula-py option ''' option = {} extraction_method = template.get('extraction_method') if extraction_method == 'guess'...
[ "Convert", "Tabula", "app", "template", "to", "tabula", "-", "py", "option" ]
chezou/tabula-py
python
https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/template.py#L47-L69
[ "def", "_convert_template_option", "(", "template", ")", ":", "option", "=", "{", "}", "extraction_method", "=", "template", ".", "get", "(", "'extraction_method'", ")", "if", "extraction_method", "==", "'guess'", ":", "option", "[", "'guess'", "]", "=", "True...
e61d46ee3c93bb40396e48dac5a9493e898f561a
train
deprecated
This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emmitted when the function is used.
tabula/util.py
def deprecated(func): """This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emmitted when the function is used.""" def newFunc(*args, **kwargs): warnings.warn("Call to deprecated function {}.".format(func.__name__), cate...
def deprecated(func): """This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emmitted when the function is used.""" def newFunc(*args, **kwargs): warnings.warn("Call to deprecated function {}.".format(func.__name__), cate...
[ "This", "is", "a", "decorator", "which", "can", "be", "used", "to", "mark", "functions", "as", "deprecated", ".", "It", "will", "result", "in", "a", "warning", "being", "emmitted", "when", "the", "function", "is", "used", "." ]
chezou/tabula-py
python
https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/util.py#L5-L16
[ "def", "deprecated", "(", "func", ")", ":", "def", "newFunc", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "warnings", ".", "warn", "(", "\"Call to deprecated function {}.\"", ".", "format", "(", "func", ".", "__name__", ")", ",", "category", "="...
e61d46ee3c93bb40396e48dac5a9493e898f561a
train
_run
Call tabula-java with the given lists of Java options and tabula-py options, as well as an optional path to pass to tabula-java as a regular argument and an optional encoding to use for any required output sent to stderr. tabula-py options are translated into tabula-java options, see :func:`build_o...
tabula/wrapper.py
def _run(java_options, options, path=None, encoding='utf-8'): """Call tabula-java with the given lists of Java options and tabula-py options, as well as an optional path to pass to tabula-java as a regular argument and an optional encoding to use for any required output sent to stderr. tabula-py op...
def _run(java_options, options, path=None, encoding='utf-8'): """Call tabula-java with the given lists of Java options and tabula-py options, as well as an optional path to pass to tabula-java as a regular argument and an optional encoding to use for any required output sent to stderr. tabula-py op...
[ "Call", "tabula", "-", "java", "with", "the", "given", "lists", "of", "Java", "options", "and", "tabula", "-", "py", "options", "as", "well", "as", "an", "optional", "path", "to", "pass", "to", "tabula", "-", "java", "as", "a", "regular", "argument", "...
chezou/tabula-py
python
https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/wrapper.py#L43-L71
[ "def", "_run", "(", "java_options", ",", "options", ",", "path", "=", "None", ",", "encoding", "=", "'utf-8'", ")", ":", "# Workaround to enforce the silent option. See:", "# https://github.com/tabulapdf/tabula-java/issues/231#issuecomment-397281157", "if", "'silent'", "in", ...
e61d46ee3c93bb40396e48dac5a9493e898f561a
train
read_pdf
Read tables in PDF. Args: input_path (file like obj): File like object of tareget PDF file. output_format (str, optional): Output format of this function (dataframe or json) encoding (str, optional): Encoding type for pandas. Default is 'utf-8' ja...
tabula/wrapper.py
def read_pdf(input_path, output_format='dataframe', encoding='utf-8', java_options=None, pandas_options=None, multiple_tables=False, **kwargs): '''Read tables in PDF. Args: input_path (file like obj): File like object of tareg...
def read_pdf(input_path, output_format='dataframe', encoding='utf-8', java_options=None, pandas_options=None, multiple_tables=False, **kwargs): '''Read tables in PDF. Args: input_path (file like obj): File like object of tareg...
[ "Read", "tables", "in", "PDF", "." ]
chezou/tabula-py
python
https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/wrapper.py#L74-L165
[ "def", "read_pdf", "(", "input_path", ",", "output_format", "=", "'dataframe'", ",", "encoding", "=", "'utf-8'", ",", "java_options", "=", "None", ",", "pandas_options", "=", "None", ",", "multiple_tables", "=", "False", ",", "*", "*", "kwargs", ")", ":", ...
e61d46ee3c93bb40396e48dac5a9493e898f561a
train
read_pdf_with_template
Read tables in PDF. Args: input_path (file like obj): File like object of tareget PDF file. template_path (file_like_obj): File like object for Tabula app template. pandas_options (dict, optional): Set pandas options like {'header': None}. encodin...
tabula/wrapper.py
def read_pdf_with_template( input_path, template_path, pandas_options=None, encoding='utf-8', java_options=None, **kwargs): '''Read tables in PDF. Args: input_path (file like obj): File like object of tareget PDF file. template_path (f...
def read_pdf_with_template( input_path, template_path, pandas_options=None, encoding='utf-8', java_options=None, **kwargs): '''Read tables in PDF. Args: input_path (file like obj): File like object of tareget PDF file. template_path (f...
[ "Read", "tables", "in", "PDF", "." ]
chezou/tabula-py
python
https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/wrapper.py#L168-L210
[ "def", "read_pdf_with_template", "(", "input_path", ",", "template_path", ",", "pandas_options", "=", "None", ",", "encoding", "=", "'utf-8'", ",", "java_options", "=", "None", ",", "*", "*", "kwargs", ")", ":", "from", "itertools", "import", "chain", "options...
e61d46ee3c93bb40396e48dac5a9493e898f561a
train
convert_into
Convert tables from PDF into a file. Args: input_path (file like obj): File like object of tareget PDF file. output_path (str): File path of output file. output_format (str, optional): Output format of this function (csv, json or tsv). Default: csv ...
tabula/wrapper.py
def convert_into(input_path, output_path, output_format='csv', java_options=None, **kwargs): '''Convert tables from PDF into a file. Args: input_path (file like obj): File like object of tareget PDF file. output_path (str): File path of output file. output_format...
def convert_into(input_path, output_path, output_format='csv', java_options=None, **kwargs): '''Convert tables from PDF into a file. Args: input_path (file like obj): File like object of tareget PDF file. output_path (str): File path of output file. output_format...
[ "Convert", "tables", "from", "PDF", "into", "a", "file", "." ]
chezou/tabula-py
python
https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/wrapper.py#L213-L253
[ "def", "convert_into", "(", "input_path", ",", "output_path", ",", "output_format", "=", "'csv'", ",", "java_options", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "output_path", "is", "None", "or", "len", "(", "output_path", ")", "is", "0", ":"...
e61d46ee3c93bb40396e48dac5a9493e898f561a
train
convert_into_by_batch
Convert tables from PDFs in a directory. Args: input_dir (str): Directory path. output_format (str, optional): Output format of this function (csv, json or tsv) java_options (list, optional): Set java options like `-Xmx256m`. kwargs (dict): ...
tabula/wrapper.py
def convert_into_by_batch(input_dir, output_format='csv', java_options=None, **kwargs): '''Convert tables from PDFs in a directory. Args: input_dir (str): Directory path. output_format (str, optional): Output format of this function (csv, json or tsv) java_option...
def convert_into_by_batch(input_dir, output_format='csv', java_options=None, **kwargs): '''Convert tables from PDFs in a directory. Args: input_dir (str): Directory path. output_format (str, optional): Output format of this function (csv, json or tsv) java_option...
[ "Convert", "tables", "from", "PDFs", "in", "a", "directory", "." ]
chezou/tabula-py
python
https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/wrapper.py#L256-L287
[ "def", "convert_into_by_batch", "(", "input_dir", ",", "output_format", "=", "'csv'", ",", "java_options", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "input_dir", "is", "None", "or", "not", "os", ".", "path", ".", "isdir", "(", "input_dir", ")...
e61d46ee3c93bb40396e48dac5a9493e898f561a
train
_extract_from
Extract tables from json. Args: raw_json (list): Decoded list from tabula-java JSON. pandas_options (dict optional): pandas options for `pd.DataFrame()`
tabula/wrapper.py
def _extract_from(raw_json, pandas_options=None): '''Extract tables from json. Args: raw_json (list): Decoded list from tabula-java JSON. pandas_options (dict optional): pandas options for `pd.DataFrame()` ''' data_frames = [] if pandas_options is None: ...
def _extract_from(raw_json, pandas_options=None): '''Extract tables from json. Args: raw_json (list): Decoded list from tabula-java JSON. pandas_options (dict optional): pandas options for `pd.DataFrame()` ''' data_frames = [] if pandas_options is None: ...
[ "Extract", "tables", "from", "json", "." ]
chezou/tabula-py
python
https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/wrapper.py#L304-L331
[ "def", "_extract_from", "(", "raw_json", ",", "pandas_options", "=", "None", ")", ":", "data_frames", "=", "[", "]", "if", "pandas_options", "is", "None", ":", "pandas_options", "=", "{", "}", "columns", "=", "pandas_options", ".", "pop", "(", "'columns'", ...
e61d46ee3c93bb40396e48dac5a9493e898f561a
train
_convert_pandas_csv_options
Translate `pd.read_csv()` options into `pd.DataFrame()` especially for header. Args: pandas_option (dict): pandas options like {'header': None}. columns (list): list of column name.
tabula/wrapper.py
def _convert_pandas_csv_options(pandas_options, columns): ''' Translate `pd.read_csv()` options into `pd.DataFrame()` especially for header. Args: pandas_option (dict): pandas options like {'header': None}. columns (list): list of column name. ''' _columns = pan...
def _convert_pandas_csv_options(pandas_options, columns): ''' Translate `pd.read_csv()` options into `pd.DataFrame()` especially for header. Args: pandas_option (dict): pandas options like {'header': None}. columns (list): list of column name. ''' _columns = pan...
[ "Translate", "pd", ".", "read_csv", "()", "options", "into", "pd", ".", "DataFrame", "()", "especially", "for", "header", "." ]
chezou/tabula-py
python
https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/wrapper.py#L334-L353
[ "def", "_convert_pandas_csv_options", "(", "pandas_options", ",", "columns", ")", ":", "_columns", "=", "pandas_options", ".", "pop", "(", "'names'", ",", "columns", ")", "header", "=", "pandas_options", ".", "pop", "(", "'header'", ",", "None", ")", "pandas_o...
e61d46ee3c93bb40396e48dac5a9493e898f561a
train
build_options
Build options for tabula-java Args: options (str, optional): Raw option string for tabula-java. pages (str, int, :obj:`list` of :obj:`int`, optional): An optional values specifying pages to extract from. It allows `str`,`int`, :obj:`list` of :obj:`int`. ...
tabula/wrapper.py
def build_options(kwargs=None): '''Build options for tabula-java Args: options (str, optional): Raw option string for tabula-java. pages (str, int, :obj:`list` of :obj:`int`, optional): An optional values specifying pages to extract from. It allows `str`,`int...
def build_options(kwargs=None): '''Build options for tabula-java Args: options (str, optional): Raw option string for tabula-java. pages (str, int, :obj:`list` of :obj:`int`, optional): An optional values specifying pages to extract from. It allows `str`,`int...
[ "Build", "options", "for", "tabula", "-", "java" ]
chezou/tabula-py
python
https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/wrapper.py#L356-L481
[ "def", "build_options", "(", "kwargs", "=", "None", ")", ":", "__options", "=", "[", "]", "if", "kwargs", "is", "None", ":", "kwargs", "=", "{", "}", "options", "=", "kwargs", ".", "get", "(", "'options'", ",", "''", ")", "# handle options described in s...
e61d46ee3c93bb40396e48dac5a9493e898f561a
train
localize_file
Ensure localize target file. If the target file is remote, this function fetches into local storage. Args: path (str): File path or file like object or URL of target file. Returns: filename (str): file name in local storage temporary_file_flag (bool): temporary file fl...
tabula/file_util.py
def localize_file(path_or_buffer): '''Ensure localize target file. If the target file is remote, this function fetches into local storage. Args: path (str): File path or file like object or URL of target file. Returns: filename (str): file name in local storage tem...
def localize_file(path_or_buffer): '''Ensure localize target file. If the target file is remote, this function fetches into local storage. Args: path (str): File path or file like object or URL of target file. Returns: filename (str): file name in local storage tem...
[ "Ensure", "localize", "target", "file", "." ]
chezou/tabula-py
python
https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/file_util.py#L24-L63
[ "def", "localize_file", "(", "path_or_buffer", ")", ":", "path_or_buffer", "=", "_stringify_path", "(", "path_or_buffer", ")", "if", "_is_url", "(", "path_or_buffer", ")", ":", "req", "=", "urlopen", "(", "path_or_buffer", ")", "filename", "=", "os", ".", "pat...
e61d46ee3c93bb40396e48dac5a9493e898f561a
train
_stringify_path
Convert path like object to string Args: path_or_buffer: object to be converted Returns: string_path_or_buffer: maybe string version of path_or_buffer
tabula/file_util.py
def _stringify_path(path_or_buffer): '''Convert path like object to string Args: path_or_buffer: object to be converted Returns: string_path_or_buffer: maybe string version of path_or_buffer ''' try: import pathlib _PATHLIB_INSTALLED = True except ImportError: ...
def _stringify_path(path_or_buffer): '''Convert path like object to string Args: path_or_buffer: object to be converted Returns: string_path_or_buffer: maybe string version of path_or_buffer ''' try: import pathlib _PATHLIB_INSTALLED = True except ImportError: ...
[ "Convert", "path", "like", "object", "to", "string" ]
chezou/tabula-py
python
https://github.com/chezou/tabula-py/blob/e61d46ee3c93bb40396e48dac5a9493e898f561a/tabula/file_util.py#L94-L116
[ "def", "_stringify_path", "(", "path_or_buffer", ")", ":", "try", ":", "import", "pathlib", "_PATHLIB_INSTALLED", "=", "True", "except", "ImportError", ":", "_PATHLIB_INSTALLED", "=", "False", "if", "hasattr", "(", "path_or_buffer", ",", "'__fspath__'", ")", ":", ...
e61d46ee3c93bb40396e48dac5a9493e898f561a
train
receive
I implement 'wormhole receive'. I return a Deferred that fires with None (for success), or signals one of the following errors: * WrongPasswordError: the two sides didn't use matching passwords * Timeout: something didn't happen fast enough for our tastes * TransferError: the sender rejected the transfe...
src/wormhole/cli/cmd_receive.py
def receive(args, reactor=reactor, _debug_stash_wormhole=None): """I implement 'wormhole receive'. I return a Deferred that fires with None (for success), or signals one of the following errors: * WrongPasswordError: the two sides didn't use matching passwords * Timeout: something didn't happen fast eno...
def receive(args, reactor=reactor, _debug_stash_wormhole=None): """I implement 'wormhole receive'. I return a Deferred that fires with None (for success), or signals one of the following errors: * WrongPasswordError: the two sides didn't use matching passwords * Timeout: something didn't happen fast eno...
[ "I", "implement", "wormhole", "receive", ".", "I", "return", "a", "Deferred", "that", "fires", "with", "None", "(", "for", "success", ")", "or", "signals", "one", "of", "the", "following", "errors", ":", "*", "WrongPasswordError", ":", "the", "two", "sides...
warner/magic-wormhole
python
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/cli/cmd_receive.py#L40-L52
[ "def", "receive", "(", "args", ",", "reactor", "=", "reactor", ",", "_debug_stash_wormhole", "=", "None", ")", ":", "r", "=", "Receiver", "(", "args", ",", "reactor", ")", "d", "=", "r", ".", "go", "(", ")", "if", "_debug_stash_wormhole", "is", "not", ...
995d3f546a33eec4f64df929848d86937d2003a7
train
Receiver._extract_file
the zipfile module does not restore file permissions so we'll do it manually
src/wormhole/cli/cmd_receive.py
def _extract_file(self, zf, info, extract_dir): """ the zipfile module does not restore file permissions so we'll do it manually """ out_path = os.path.join(extract_dir, info.filename) out_path = os.path.abspath(out_path) if not out_path.startswith(extract_dir): ...
def _extract_file(self, zf, info, extract_dir): """ the zipfile module does not restore file permissions so we'll do it manually """ out_path = os.path.join(extract_dir, info.filename) out_path = os.path.abspath(out_path) if not out_path.startswith(extract_dir): ...
[ "the", "zipfile", "module", "does", "not", "restore", "file", "permissions", "so", "we", "ll", "do", "it", "manually" ]
warner/magic-wormhole
python
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/cli/cmd_receive.py#L425-L441
[ "def", "_extract_file", "(", "self", ",", "zf", ",", "info", ",", "extract_dir", ")", ":", "out_path", "=", "os", ".", "path", ".", "join", "(", "extract_dir", ",", "info", ".", "filename", ")", "out_path", "=", "os", ".", "path", ".", "abspath", "("...
995d3f546a33eec4f64df929848d86937d2003a7
train
get_tor
If launch_tor=True, I will try to launch a new Tor process, ask it for its SOCKS and control ports, and use those for outbound connections (and inbound onion-service listeners, if necessary). Otherwise if tor_control_port is provided, I will attempt to connect to an existing Tor's control port at the e...
src/wormhole/tor_manager.py
def get_tor(reactor, launch_tor=False, tor_control_port=None, timing=None, stderr=sys.stderr): """ If launch_tor=True, I will try to launch a new Tor process, ask it for its SOCKS and control ports, and use those for outbound connections (and inbound onion...
def get_tor(reactor, launch_tor=False, tor_control_port=None, timing=None, stderr=sys.stderr): """ If launch_tor=True, I will try to launch a new Tor process, ask it for its SOCKS and control ports, and use those for outbound connections (and inbound onion...
[ "If", "launch_tor", "=", "True", "I", "will", "try", "to", "launch", "a", "new", "Tor", "process", "ask", "it", "for", "its", "SOCKS", "and", "control", "ports", "and", "use", "those", "for", "outbound", "connections", "(", "and", "inbound", "onion", "-"...
warner/magic-wormhole
python
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/tor_manager.py#L34-L118
[ "def", "get_tor", "(", "reactor", ",", "launch_tor", "=", "False", ",", "tor_control_port", "=", "None", ",", "timing", "=", "None", ",", "stderr", "=", "sys", ".", "stderr", ")", ":", "# rationale: launching a new Tor takes a long time, so only do it if", "# the us...
995d3f546a33eec4f64df929848d86937d2003a7
train
find_public_key
This looks for an appropriate SSH key to send, possibly querying the user in the meantime. DO NOT CALL after reactor.run as this (possibly) does blocking stuff like asking the user questions (via click.prompt()) Returns a 3-tuple: kind, keyid, pubkey_data
src/wormhole/cli/cmd_ssh.py
def find_public_key(hint=None): """ This looks for an appropriate SSH key to send, possibly querying the user in the meantime. DO NOT CALL after reactor.run as this (possibly) does blocking stuff like asking the user questions (via click.prompt()) Returns a 3-tuple: kind, keyid, pubkey_data ...
def find_public_key(hint=None): """ This looks for an appropriate SSH key to send, possibly querying the user in the meantime. DO NOT CALL after reactor.run as this (possibly) does blocking stuff like asking the user questions (via click.prompt()) Returns a 3-tuple: kind, keyid, pubkey_data ...
[ "This", "looks", "for", "an", "appropriate", "SSH", "key", "to", "send", "possibly", "querying", "the", "user", "in", "the", "meantime", ".", "DO", "NOT", "CALL", "after", "reactor", ".", "run", "as", "this", "(", "possibly", ")", "does", "blocking", "st...
warner/magic-wormhole
python
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/cli/cmd_ssh.py#L17-L63
[ "def", "find_public_key", "(", "hint", "=", "None", ")", ":", "if", "hint", "is", "None", ":", "hint", "=", "expanduser", "(", "'~/.ssh/'", ")", "else", ":", "if", "not", "exists", "(", "hint", ")", ":", "raise", "PubkeyError", "(", "\"Can't find '{}'\""...
995d3f546a33eec4f64df929848d86937d2003a7
train
wormhole
Create a Magic Wormhole and communicate through it. Wormholes are created by speaking the same magic CODE in two different places at the same time. Wormholes are secure against anyone who doesn't use the same code.
src/wormhole/cli/cli.py
def wormhole(context, dump_timing, transit_helper, relay_url, appid): """ Create a Magic Wormhole and communicate through it. Wormholes are created by speaking the same magic CODE in two different places at the same time. Wormholes are secure against anyone who doesn't use the same code. """ ...
def wormhole(context, dump_timing, transit_helper, relay_url, appid): """ Create a Magic Wormhole and communicate through it. Wormholes are created by speaking the same magic CODE in two different places at the same time. Wormholes are secure against anyone who doesn't use the same code. """ ...
[ "Create", "a", "Magic", "Wormhole", "and", "communicate", "through", "it", "." ]
warner/magic-wormhole
python
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/cli/cli.py#L95-L107
[ "def", "wormhole", "(", "context", ",", "dump_timing", ",", "transit_helper", ",", "relay_url", ",", "appid", ")", ":", "context", ".", "obj", "=", "cfg", "=", "Config", "(", ")", "cfg", ".", "appid", "=", "appid", "cfg", ".", "relay_url", "=", "relay_...
995d3f546a33eec4f64df929848d86937d2003a7
train
_dispatch_command
Internal helper. This calls the given command (a no-argument callable) with the Config instance in cfg and interprets any errors for the user.
src/wormhole/cli/cli.py
def _dispatch_command(reactor, cfg, command): """ Internal helper. This calls the given command (a no-argument callable) with the Config instance in cfg and interprets any errors for the user. """ cfg.timing.add("command dispatch") cfg.timing.add( "import", when=start, which="top").f...
def _dispatch_command(reactor, cfg, command): """ Internal helper. This calls the given command (a no-argument callable) with the Config instance in cfg and interprets any errors for the user. """ cfg.timing.add("command dispatch") cfg.timing.add( "import", when=start, which="top").f...
[ "Internal", "helper", ".", "This", "calls", "the", "given", "command", "(", "a", "no", "-", "argument", "callable", ")", "with", "the", "Config", "instance", "in", "cfg", "and", "interprets", "any", "errors", "for", "the", "user", "." ]
warner/magic-wormhole
python
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/cli/cli.py#L111-L152
[ "def", "_dispatch_command", "(", "reactor", ",", "cfg", ",", "command", ")", ":", "cfg", ".", "timing", ".", "add", "(", "\"command dispatch\"", ")", "cfg", ".", "timing", ".", "add", "(", "\"import\"", ",", "when", "=", "start", ",", "which", "=", "\"...
995d3f546a33eec4f64df929848d86937d2003a7
train
send
Send a text message, file, or directory
src/wormhole/cli/cli.py
def send(cfg, **kwargs): """Send a text message, file, or directory""" for name, value in kwargs.items(): setattr(cfg, name, value) with cfg.timing.add("import", which="cmd_send"): from . import cmd_send return go(cmd_send.send, cfg)
def send(cfg, **kwargs): """Send a text message, file, or directory""" for name, value in kwargs.items(): setattr(cfg, name, value) with cfg.timing.add("import", which="cmd_send"): from . import cmd_send return go(cmd_send.send, cfg)
[ "Send", "a", "text", "message", "file", "or", "directory" ]
warner/magic-wormhole
python
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/cli/cli.py#L241-L248
[ "def", "send", "(", "cfg", ",", "*", "*", "kwargs", ")", ":", "for", "name", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "setattr", "(", "cfg", ",", "name", ",", "value", ")", "with", "cfg", ".", "timing", ".", "add", "(", "\"imp...
995d3f546a33eec4f64df929848d86937d2003a7
train
receive
Receive a text message, file, or directory (from 'wormhole send')
src/wormhole/cli/cli.py
def receive(cfg, code, **kwargs): """ Receive a text message, file, or directory (from 'wormhole send') """ for name, value in kwargs.items(): setattr(cfg, name, value) with cfg.timing.add("import", which="cmd_receive"): from . import cmd_receive if len(code) == 1: cfg.co...
def receive(cfg, code, **kwargs): """ Receive a text message, file, or directory (from 'wormhole send') """ for name, value in kwargs.items(): setattr(cfg, name, value) with cfg.timing.add("import", which="cmd_receive"): from . import cmd_receive if len(code) == 1: cfg.co...
[ "Receive", "a", "text", "message", "file", "or", "directory", "(", "from", "wormhole", "send", ")" ]
warner/magic-wormhole
python
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/cli/cli.py#L288-L305
[ "def", "receive", "(", "cfg", ",", "code", ",", "*", "*", "kwargs", ")", ":", "for", "name", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "setattr", "(", "cfg", ",", "name", ",", "value", ")", "with", "cfg", ".", "timing", ".", "a...
995d3f546a33eec4f64df929848d86937d2003a7
train
ssh_invite
Add a public-key to a ~/.ssh/authorized_keys file
src/wormhole/cli/cli.py
def ssh_invite(ctx, code_length, user, **kwargs): """ Add a public-key to a ~/.ssh/authorized_keys file """ for name, value in kwargs.items(): setattr(ctx.obj, name, value) from . import cmd_ssh ctx.obj.code_length = code_length ctx.obj.ssh_user = user return go(cmd_ssh.invite, c...
def ssh_invite(ctx, code_length, user, **kwargs): """ Add a public-key to a ~/.ssh/authorized_keys file """ for name, value in kwargs.items(): setattr(ctx.obj, name, value) from . import cmd_ssh ctx.obj.code_length = code_length ctx.obj.ssh_user = user return go(cmd_ssh.invite, c...
[ "Add", "a", "public", "-", "key", "to", "a", "~", "/", ".", "ssh", "/", "authorized_keys", "file" ]
warner/magic-wormhole
python
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/cli/cli.py#L332-L341
[ "def", "ssh_invite", "(", "ctx", ",", "code_length", ",", "user", ",", "*", "*", "kwargs", ")", ":", "for", "name", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "setattr", "(", "ctx", ".", "obj", ",", "name", ",", "value", ")", "fro...
995d3f546a33eec4f64df929848d86937d2003a7
train
ssh_accept
Send your SSH public-key In response to a 'wormhole ssh invite' this will send public-key you specify (if there's only one in ~/.ssh/* that will be sent).
src/wormhole/cli/cli.py
def ssh_accept(cfg, code, key_file, yes, **kwargs): """ Send your SSH public-key In response to a 'wormhole ssh invite' this will send public-key you specify (if there's only one in ~/.ssh/* that will be sent). """ for name, value in kwargs.items(): setattr(cfg, name, value) from ....
def ssh_accept(cfg, code, key_file, yes, **kwargs): """ Send your SSH public-key In response to a 'wormhole ssh invite' this will send public-key you specify (if there's only one in ~/.ssh/* that will be sent). """ for name, value in kwargs.items(): setattr(cfg, name, value) from ....
[ "Send", "your", "SSH", "public", "-", "key" ]
warner/magic-wormhole
python
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/cli/cli.py#L364-L383
[ "def", "ssh_accept", "(", "cfg", ",", "code", ",", "key_file", ",", "yes", ",", "*", "*", "kwargs", ")", ":", "for", "name", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "setattr", "(", "cfg", ",", "name", ",", "value", ")", "from",...
995d3f546a33eec4f64df929848d86937d2003a7
train
allocate_tcp_port
Return an (integer) available TCP port on localhost. This briefly listens on the port in question, then closes it right away.
src/wormhole/transit.py
def allocate_tcp_port(): """Return an (integer) available TCP port on localhost. This briefly listens on the port in question, then closes it right away.""" # We want to bind() the socket but not listen(). Twisted (in # tcp.Port.createInternetSocket) would do several other things: # non-blocking, cl...
def allocate_tcp_port(): """Return an (integer) available TCP port on localhost. This briefly listens on the port in question, then closes it right away.""" # We want to bind() the socket but not listen(). Twisted (in # tcp.Port.createInternetSocket) would do several other things: # non-blocking, cl...
[ "Return", "an", "(", "integer", ")", "available", "TCP", "port", "on", "localhost", ".", "This", "briefly", "listens", "on", "the", "port", "in", "question", "then", "closes", "it", "right", "away", "." ]
warner/magic-wormhole
python
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/transit.py#L477-L491
[ "def", "allocate_tcp_port", "(", ")", ":", "# We want to bind() the socket but not listen(). Twisted (in", "# tcp.Port.createInternetSocket) would do several other things:", "# non-blocking, close-on-exec, and SO_REUSEADDR. We don't need", "# non-blocking because we never listen on it, and we don't ...
995d3f546a33eec4f64df929848d86937d2003a7
train
Common._not_forever
If the timer fires first, cancel the deferred. If the deferred fires first, cancel the timer.
src/wormhole/transit.py
def _not_forever(self, timeout, d): """If the timer fires first, cancel the deferred. If the deferred fires first, cancel the timer.""" t = self._reactor.callLater(timeout, d.cancel) def _done(res): if t.active(): t.cancel() return res d....
def _not_forever(self, timeout, d): """If the timer fires first, cancel the deferred. If the deferred fires first, cancel the timer.""" t = self._reactor.callLater(timeout, d.cancel) def _done(res): if t.active(): t.cancel() return res d....
[ "If", "the", "timer", "fires", "first", "cancel", "the", "deferred", ".", "If", "the", "deferred", "fires", "first", "cancel", "the", "timer", "." ]
warner/magic-wormhole
python
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/transit.py#L834-L845
[ "def", "_not_forever", "(", "self", ",", "timeout", ",", "d", ")", ":", "t", "=", "self", ".", "_reactor", ".", "callLater", "(", "timeout", ",", "d", ".", "cancel", ")", "def", "_done", "(", "res", ")", ":", "if", "t", ".", "active", "(", ")", ...
995d3f546a33eec4f64df929848d86937d2003a7
train
receive
This is a convenience API which returns a Deferred that callbacks with a single chunk of data from another wormhole (and then closes the wormhole). Under the hood, it's just using an instance returned from :func:`wormhole.wormhole`. This is similar to the `wormhole receive` command. :param unicode ...
src/wormhole/xfer_util.py
def receive(reactor, appid, relay_url, code, use_tor=False, launch_tor=False, tor_control_port=None, on_code=None): """ This is a convenience API which returns a Deferred that callbacks with a single chunk of data from anoth...
def receive(reactor, appid, relay_url, code, use_tor=False, launch_tor=False, tor_control_port=None, on_code=None): """ This is a convenience API which returns a Deferred that callbacks with a single chunk of data from anoth...
[ "This", "is", "a", "convenience", "API", "which", "returns", "a", "Deferred", "that", "callbacks", "with", "a", "single", "chunk", "of", "data", "from", "another", "wormhole", "(", "and", "then", "closes", "the", "wormhole", ")", ".", "Under", "the", "hood...
warner/magic-wormhole
python
https://github.com/warner/magic-wormhole/blob/995d3f546a33eec4f64df929848d86937d2003a7/src/wormhole/xfer_util.py#L10-L75
[ "def", "receive", "(", "reactor", ",", "appid", ",", "relay_url", ",", "code", ",", "use_tor", "=", "False", ",", "launch_tor", "=", "False", ",", "tor_control_port", "=", "None", ",", "on_code", "=", "None", ")", ":", "tor", "=", "None", "if", "use_to...
995d3f546a33eec4f64df929848d86937d2003a7
train
TinyDB.table
Get access to a specific table. Creates a new table, if it hasn't been created before, otherwise it returns the cached :class:`~tinydb.Table` object. :param name: The name of the table. :type name: str :param cache_size: How many query results to cache. :param table_cla...
tinydb/database.py
def table(self, name=DEFAULT_TABLE, **options): """ Get access to a specific table. Creates a new table, if it hasn't been created before, otherwise it returns the cached :class:`~tinydb.Table` object. :param name: The name of the table. :type name: str :param c...
def table(self, name=DEFAULT_TABLE, **options): """ Get access to a specific table. Creates a new table, if it hasn't been created before, otherwise it returns the cached :class:`~tinydb.Table` object. :param name: The name of the table. :type name: str :param c...
[ "Get", "access", "to", "a", "specific", "table", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/database.py#L179-L200
[ "def", "table", "(", "self", ",", "name", "=", "DEFAULT_TABLE", ",", "*", "*", "options", ")", ":", "if", "name", "in", "self", ".", "_table_cache", ":", "return", "self", ".", "_table_cache", "[", "name", "]", "table_class", "=", "options", ".", "pop"...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
TinyDB.purge_table
Purge a specific table from the database. **CANNOT BE REVERSED!** :param name: The name of the table. :type name: str
tinydb/database.py
def purge_table(self, name): """ Purge a specific table from the database. **CANNOT BE REVERSED!** :param name: The name of the table. :type name: str """ if name in self._table_cache: del self._table_cache[name] proxy = StorageProxy(self._storage, n...
def purge_table(self, name): """ Purge a specific table from the database. **CANNOT BE REVERSED!** :param name: The name of the table. :type name: str """ if name in self._table_cache: del self._table_cache[name] proxy = StorageProxy(self._storage, n...
[ "Purge", "a", "specific", "table", "from", "the", "database", ".", "**", "CANNOT", "BE", "REVERSED!", "**" ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/database.py#L220-L231
[ "def", "purge_table", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_table_cache", ":", "del", "self", ".", "_table_cache", "[", "name", "]", "proxy", "=", "StorageProxy", "(", "self", ".", "_storage", ",", "name", ")", "proxy",...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
Table.process_elements
Helper function for processing all documents specified by condition or IDs. A repeating pattern in TinyDB is to run some code on all documents that match a condition or are specified by their ID. This is implemented in this function. The function passed as ``func`` has to be a c...
tinydb/database.py
def process_elements(self, func, cond=None, doc_ids=None, eids=None): """ Helper function for processing all documents specified by condition or IDs. A repeating pattern in TinyDB is to run some code on all documents that match a condition or are specified by their ID. This is ...
def process_elements(self, func, cond=None, doc_ids=None, eids=None): """ Helper function for processing all documents specified by condition or IDs. A repeating pattern in TinyDB is to run some code on all documents that match a condition or are specified by their ID. This is ...
[ "Helper", "function", "for", "processing", "all", "documents", "specified", "by", "condition", "or", "IDs", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/database.py#L327-L376
[ "def", "process_elements", "(", "self", ",", "func", ",", "cond", "=", "None", ",", "doc_ids", "=", "None", ",", "eids", "=", "None", ")", ":", "doc_ids", "=", "_get_doc_ids", "(", "doc_ids", ",", "eids", ")", "data", "=", "self", ".", "_read", "(", ...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
Table.insert
Insert a new document into the table. :param document: the document to insert :returns: the inserted document's ID
tinydb/database.py
def insert(self, document): """ Insert a new document into the table. :param document: the document to insert :returns: the inserted document's ID """ doc_id = self._get_doc_id(document) data = self._read() data[doc_id] = dict(document) self._wri...
def insert(self, document): """ Insert a new document into the table. :param document: the document to insert :returns: the inserted document's ID """ doc_id = self._get_doc_id(document) data = self._read() data[doc_id] = dict(document) self._wri...
[ "Insert", "a", "new", "document", "into", "the", "table", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/database.py#L449-L462
[ "def", "insert", "(", "self", ",", "document", ")", ":", "doc_id", "=", "self", ".", "_get_doc_id", "(", "document", ")", "data", "=", "self", ".", "_read", "(", ")", "data", "[", "doc_id", "]", "=", "dict", "(", "document", ")", "self", ".", "_wri...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
Table.insert_multiple
Insert multiple documents into the table. :param documents: a list of documents to insert :returns: a list containing the inserted documents' IDs
tinydb/database.py
def insert_multiple(self, documents): """ Insert multiple documents into the table. :param documents: a list of documents to insert :returns: a list containing the inserted documents' IDs """ doc_ids = [] data = self._read() for doc in documents: ...
def insert_multiple(self, documents): """ Insert multiple documents into the table. :param documents: a list of documents to insert :returns: a list containing the inserted documents' IDs """ doc_ids = [] data = self._read() for doc in documents: ...
[ "Insert", "multiple", "documents", "into", "the", "table", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/database.py#L464-L483
[ "def", "insert_multiple", "(", "self", ",", "documents", ")", ":", "doc_ids", "=", "[", "]", "data", "=", "self", ".", "_read", "(", ")", "for", "doc", "in", "documents", ":", "doc_id", "=", "self", ".", "_get_doc_id", "(", "doc", ")", "doc_ids", "."...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
Table.remove
Remove all matching documents. :param cond: the condition to check against :type cond: query :param doc_ids: a list of document IDs :type doc_ids: list :returns: a list containing the removed document's ID
tinydb/database.py
def remove(self, cond=None, doc_ids=None, eids=None): """ Remove all matching documents. :param cond: the condition to check against :type cond: query :param doc_ids: a list of document IDs :type doc_ids: list :returns: a list containing the removed document's ID...
def remove(self, cond=None, doc_ids=None, eids=None): """ Remove all matching documents. :param cond: the condition to check against :type cond: query :param doc_ids: a list of document IDs :type doc_ids: list :returns: a list containing the removed document's ID...
[ "Remove", "all", "matching", "documents", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/database.py#L485-L503
[ "def", "remove", "(", "self", ",", "cond", "=", "None", ",", "doc_ids", "=", "None", ",", "eids", "=", "None", ")", ":", "doc_ids", "=", "_get_doc_ids", "(", "doc_ids", ",", "eids", ")", "if", "cond", "is", "None", "and", "doc_ids", "is", "None", "...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
Table.update
Update all matching documents to have a given set of fields. :param fields: the fields that the matching documents will have or a method that will update the documents :type fields: dict | dict -> None :param cond: which documents to update :type cond: query ...
tinydb/database.py
def update(self, fields, cond=None, doc_ids=None, eids=None): """ Update all matching documents to have a given set of fields. :param fields: the fields that the matching documents will have or a method that will update the documents :type fields: dict | dict -> N...
def update(self, fields, cond=None, doc_ids=None, eids=None): """ Update all matching documents to have a given set of fields. :param fields: the fields that the matching documents will have or a method that will update the documents :type fields: dict | dict -> N...
[ "Update", "all", "matching", "documents", "to", "have", "a", "given", "set", "of", "fields", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/database.py#L505-L529
[ "def", "update", "(", "self", ",", "fields", ",", "cond", "=", "None", ",", "doc_ids", "=", "None", ",", "eids", "=", "None", ")", ":", "doc_ids", "=", "_get_doc_ids", "(", "doc_ids", ",", "eids", ")", "if", "callable", "(", "fields", ")", ":", "re...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
Table.write_back
Write back documents by doc_id :param documents: a list of document to write back :param doc_ids: a list of document IDs which need to be written back :returns: a list of document IDs that have been written
tinydb/database.py
def write_back(self, documents, doc_ids=None, eids=None): """ Write back documents by doc_id :param documents: a list of document to write back :param doc_ids: a list of document IDs which need to be written back :returns: a list of document IDs that have been written ""...
def write_back(self, documents, doc_ids=None, eids=None): """ Write back documents by doc_id :param documents: a list of document to write back :param doc_ids: a list of document IDs which need to be written back :returns: a list of document IDs that have been written ""...
[ "Write", "back", "documents", "by", "doc_id" ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/database.py#L531-L564
[ "def", "write_back", "(", "self", ",", "documents", ",", "doc_ids", "=", "None", ",", "eids", "=", "None", ")", ":", "doc_ids", "=", "_get_doc_ids", "(", "doc_ids", ",", "eids", ")", "if", "doc_ids", "is", "not", "None", "and", "not", "len", "(", "do...
10052cb1ae6a3682d26eb4272c44e3b020aa5877