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
test
noise_despike
Apply standard deviation filter to remove anomalous values. Parameters ---------- win : int The window used to calculate rolling statistics. nlim : float The number of standard deviations above the rolling mean above which data are considered outliers. Returns ------- ...
latools/processes/despiking.py
def noise_despike(sig, win=3, nlim=24., maxiter=4): """ Apply standard deviation filter to remove anomalous values. Parameters ---------- win : int The window used to calculate rolling statistics. nlim : float The number of standard deviations above the rolling mean abov...
def noise_despike(sig, win=3, nlim=24., maxiter=4): """ Apply standard deviation filter to remove anomalous values. Parameters ---------- win : int The window used to calculate rolling statistics. nlim : float The number of standard deviations above the rolling mean abov...
[ "Apply", "standard", "deviation", "filter", "to", "remove", "anomalous", "values", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/processes/despiking.py#L4-L47
[ "def", "noise_despike", "(", "sig", ",", "win", "=", "3", ",", "nlim", "=", "24.", ",", "maxiter", "=", "4", ")", ":", "if", "win", "%", "2", "!=", "1", ":", "win", "+=", "1", "# win must be odd", "kernel", "=", "np", ".", "ones", "(", "win", "...
cd25a650cfee318152f234d992708511f7047fbe
test
expdecay_despike
Apply exponential decay filter to remove physically impossible data based on instrumental washout. The filter is re-applied until no more points are removed, or maxiter is reached. Parameters ---------- exponent : float Exponent used in filter tstep : float The time increment betwe...
latools/processes/despiking.py
def expdecay_despike(sig, expdecay_coef, tstep, maxiter=3): """ Apply exponential decay filter to remove physically impossible data based on instrumental washout. The filter is re-applied until no more points are removed, or maxiter is reached. Parameters ---------- exponent : float Ex...
def expdecay_despike(sig, expdecay_coef, tstep, maxiter=3): """ Apply exponential decay filter to remove physically impossible data based on instrumental washout. The filter is re-applied until no more points are removed, or maxiter is reached. Parameters ---------- exponent : float Ex...
[ "Apply", "exponential", "decay", "filter", "to", "remove", "physically", "impossible", "data", "based", "on", "instrumental", "washout", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/processes/despiking.py#L50-L98
[ "def", "expdecay_despike", "(", "sig", ",", "expdecay_coef", ",", "tstep", ",", "maxiter", "=", "3", ")", ":", "# determine rms noise of data", "noise", "=", "np", ".", "std", "(", "sig", "[", ":", "5", "]", ")", "# initially, calculated based on first 5 points"...
cd25a650cfee318152f234d992708511f7047fbe
test
Eff._flat_map
**f** must return the same stack type as **self.value** has. Iterates over the effects, sequences the inner instance successively to the top and joins with the outer instance. Example: List(Right(Just(1))) => List(Right(Just(List(Right(Just(5)))))) => List(List(Right(Just(Right(J...
amino/eff.py
def _flat_map(self, f: Callable): ''' **f** must return the same stack type as **self.value** has. Iterates over the effects, sequences the inner instance successively to the top and joins with the outer instance. Example: List(Right(Just(1))) => List(Right(Just(List(Right(Just(5...
def _flat_map(self, f: Callable): ''' **f** must return the same stack type as **self.value** has. Iterates over the effects, sequences the inner instance successively to the top and joins with the outer instance. Example: List(Right(Just(1))) => List(Right(Just(List(Right(Just(5...
[ "**", "f", "**", "must", "return", "the", "same", "stack", "type", "as", "**", "self", ".", "value", "**", "has", ".", "Iterates", "over", "the", "effects", "sequences", "the", "inner", "instance", "successively", "to", "the", "top", "and", "joins", "wit...
tek/amino
python
https://github.com/tek/amino/blob/51b314933e047a45587a24ecff02c836706d27ff/amino/eff.py#L45-L68
[ "def", "_flat_map", "(", "self", ",", "f", ":", "Callable", ")", ":", "index", "=", "List", ".", "range", "(", "self", ".", "depth", "+", "1", ")", "g", "=", "index", ".", "fold_left", "(", "f", ")", "(", "lambda", "z", ",", "i", ":", "lambda",...
51b314933e047a45587a24ecff02c836706d27ff
test
filt.add
Add filter. Parameters ---------- name : str filter name filt : array_like boolean filter array info : str informative description of the filter params : tuple parameters used to make the filter Returns ---...
latools/filtering/filt_obj.py
def add(self, name, filt, info='', params=(), setn=None): """ Add filter. Parameters ---------- name : str filter name filt : array_like boolean filter array info : str informative description of the filter params : tup...
def add(self, name, filt, info='', params=(), setn=None): """ Add filter. Parameters ---------- name : str filter name filt : array_like boolean filter array info : str informative description of the filter params : tup...
[ "Add", "filter", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/filt_obj.py#L90-L129
[ "def", "add", "(", "self", ",", "name", ",", "filt", ",", "info", "=", "''", ",", "params", "=", "(", ")", ",", "setn", "=", "None", ")", ":", "iname", "=", "'{:.0f}_'", ".", "format", "(", "self", ".", "n", ")", "+", "name", "self", ".", "in...
cd25a650cfee318152f234d992708511f7047fbe
test
filt.remove
Remove filter. Parameters ---------- name : str name of the filter to remove setn : int or True int: number of set to remove True: remove all filters in set that 'name' belongs to Returns ------- None
latools/filtering/filt_obj.py
def remove(self, name=None, setn=None): """ Remove filter. Parameters ---------- name : str name of the filter to remove setn : int or True int: number of set to remove True: remove all filters in set that 'name' belongs to Re...
def remove(self, name=None, setn=None): """ Remove filter. Parameters ---------- name : str name of the filter to remove setn : int or True int: number of set to remove True: remove all filters in set that 'name' belongs to Re...
[ "Remove", "filter", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/filt_obj.py#L131-L172
[ "def", "remove", "(", "self", ",", "name", "=", "None", ",", "setn", "=", "None", ")", ":", "if", "isinstance", "(", "name", ",", "int", ")", ":", "name", "=", "self", ".", "index", "[", "name", "]", "if", "setn", "is", "not", "None", ":", "nam...
cd25a650cfee318152f234d992708511f7047fbe
test
filt.clear
Clear all filters.
latools/filtering/filt_obj.py
def clear(self): """ Clear all filters. """ self.components = {} self.info = {} self.params = {} self.switches = {} self.keys = {} self.index = {} self.sets = {} self.maxset = -1 self.n = 0 for a in self.analytes: ...
def clear(self): """ Clear all filters. """ self.components = {} self.info = {} self.params = {} self.switches = {} self.keys = {} self.index = {} self.sets = {} self.maxset = -1 self.n = 0 for a in self.analytes: ...
[ "Clear", "all", "filters", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/filt_obj.py#L174-L189
[ "def", "clear", "(", "self", ")", ":", "self", ".", "components", "=", "{", "}", "self", ".", "info", "=", "{", "}", "self", ".", "params", "=", "{", "}", "self", ".", "switches", "=", "{", "}", "self", ".", "keys", "=", "{", "}", "self", "."...
cd25a650cfee318152f234d992708511f7047fbe
test
filt.clean
Remove unused filters.
latools/filtering/filt_obj.py
def clean(self): """ Remove unused filters. """ for f in sorted(self.components.keys()): unused = not any(self.switches[a][f] for a in self.analytes) if unused: self.remove(f)
def clean(self): """ Remove unused filters. """ for f in sorted(self.components.keys()): unused = not any(self.switches[a][f] for a in self.analytes) if unused: self.remove(f)
[ "Remove", "unused", "filters", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/filt_obj.py#L191-L198
[ "def", "clean", "(", "self", ")", ":", "for", "f", "in", "sorted", "(", "self", ".", "components", ".", "keys", "(", ")", ")", ":", "unused", "=", "not", "any", "(", "self", ".", "switches", "[", "a", "]", "[", "f", "]", "for", "a", "in", "se...
cd25a650cfee318152f234d992708511f7047fbe
test
filt.on
Turn on specified filter(s) for specified analyte(s). Parameters ---------- analyte : optional, str or array_like Name or list of names of analytes. Defaults to all analytes. filt : optional. int, str or array_like Name/number or iterable names/number...
latools/filtering/filt_obj.py
def on(self, analyte=None, filt=None): """ Turn on specified filter(s) for specified analyte(s). Parameters ---------- analyte : optional, str or array_like Name or list of names of analytes. Defaults to all analytes. filt : optional. int, str or ...
def on(self, analyte=None, filt=None): """ Turn on specified filter(s) for specified analyte(s). Parameters ---------- analyte : optional, str or array_like Name or list of names of analytes. Defaults to all analytes. filt : optional. int, str or ...
[ "Turn", "on", "specified", "filter", "(", "s", ")", "for", "specified", "analyte", "(", "s", ")", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/filt_obj.py#L200-L242
[ "def", "on", "(", "self", ",", "analyte", "=", "None", ",", "filt", "=", "None", ")", ":", "if", "isinstance", "(", "analyte", ",", "str", ")", ":", "analyte", "=", "[", "analyte", "]", "if", "isinstance", "(", "filt", ",", "(", "int", ",", "floa...
cd25a650cfee318152f234d992708511f7047fbe
test
filt.make
Make filter for specified analyte(s). Filter specified in filt.switches. Parameters ---------- analyte : str or array_like Name or list of names of analytes. Returns ------- array_like boolean filter
latools/filtering/filt_obj.py
def make(self, analyte): """ Make filter for specified analyte(s). Filter specified in filt.switches. Parameters ---------- analyte : str or array_like Name or list of names of analytes. Returns ------- array_like boolean...
def make(self, analyte): """ Make filter for specified analyte(s). Filter specified in filt.switches. Parameters ---------- analyte : str or array_like Name or list of names of analytes. Returns ------- array_like boolean...
[ "Make", "filter", "for", "specified", "analyte", "(", "s", ")", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/filt_obj.py#L288-L317
[ "def", "make", "(", "self", ",", "analyte", ")", ":", "if", "analyte", "is", "None", ":", "analyte", "=", "self", ".", "analytes", "elif", "isinstance", "(", "analyte", ",", "str", ")", ":", "analyte", "=", "[", "analyte", "]", "out", "=", "[", "]"...
cd25a650cfee318152f234d992708511f7047fbe
test
filt.fuzzmatch
Identify a filter by fuzzy string matching. Partial ('fuzzy') matching performed by `fuzzywuzzy.fuzzy.ratio` Parameters ---------- fuzzkey : str A string that partially matches one filter name more than the others. Returns ------- The name of the mo...
latools/filtering/filt_obj.py
def fuzzmatch(self, fuzzkey, multi=False): """ Identify a filter by fuzzy string matching. Partial ('fuzzy') matching performed by `fuzzywuzzy.fuzzy.ratio` Parameters ---------- fuzzkey : str A string that partially matches one filter name more than the othe...
def fuzzmatch(self, fuzzkey, multi=False): """ Identify a filter by fuzzy string matching. Partial ('fuzzy') matching performed by `fuzzywuzzy.fuzzy.ratio` Parameters ---------- fuzzkey : str A string that partially matches one filter name more than the othe...
[ "Identify", "a", "filter", "by", "fuzzy", "string", "matching", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/filt_obj.py#L319-L344
[ "def", "fuzzmatch", "(", "self", ",", "fuzzkey", ",", "multi", "=", "False", ")", ":", "keys", ",", "ratios", "=", "np", ".", "array", "(", "[", "(", "f", ",", "seqm", "(", "None", ",", "fuzzkey", ",", "f", ")", ".", "ratio", "(", ")", ")", "...
cd25a650cfee318152f234d992708511f7047fbe
test
filt.make_fromkey
Make filter from logical expression. Takes a logical expression as an input, and returns a filter. Used for advanced filtering, where combinations of nested and/or filters are desired. Filter names must exactly match the names listed by print(filt). Example: ``key = '(Filter_1 | Filter...
latools/filtering/filt_obj.py
def make_fromkey(self, key): """ Make filter from logical expression. Takes a logical expression as an input, and returns a filter. Used for advanced filtering, where combinations of nested and/or filters are desired. Filter names must exactly match the names listed by print(fil...
def make_fromkey(self, key): """ Make filter from logical expression. Takes a logical expression as an input, and returns a filter. Used for advanced filtering, where combinations of nested and/or filters are desired. Filter names must exactly match the names listed by print(fil...
[ "Make", "filter", "from", "logical", "expression", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/filt_obj.py#L346-L377
[ "def", "make_fromkey", "(", "self", ",", "key", ")", ":", "if", "key", "!=", "''", ":", "def", "make_runable", "(", "match", ")", ":", "return", "\"self.components['\"", "+", "self", ".", "fuzzmatch", "(", "match", ".", "group", "(", "0", ")", ")", "...
cd25a650cfee318152f234d992708511f7047fbe
test
filt.make_keydict
Make logical expressions describing the filter(s) for specified analyte(s). Parameters ---------- analyte : optional, str or array_like Name or list of names of analytes. Defaults to all analytes. Returns ------- dict containing the l...
latools/filtering/filt_obj.py
def make_keydict(self, analyte=None): """ Make logical expressions describing the filter(s) for specified analyte(s). Parameters ---------- analyte : optional, str or array_like Name or list of names of analytes. Defaults to all analytes. Returns...
def make_keydict(self, analyte=None): """ Make logical expressions describing the filter(s) for specified analyte(s). Parameters ---------- analyte : optional, str or array_like Name or list of names of analytes. Defaults to all analytes. Returns...
[ "Make", "logical", "expressions", "describing", "the", "filter", "(", "s", ")", "for", "specified", "analyte", "(", "s", ")", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/filt_obj.py#L379-L407
[ "def", "make_keydict", "(", "self", ",", "analyte", "=", "None", ")", ":", "if", "analyte", "is", "None", ":", "analyte", "=", "self", ".", "analytes", "elif", "isinstance", "(", "analyte", ",", "str", ")", ":", "analyte", "=", "[", "analyte", "]", "...
cd25a650cfee318152f234d992708511f7047fbe
test
filt.grab_filt
Flexible access to specific filter using any key format. Parameters ---------- f : str, dict or bool either logical filter expression, dict of expressions, or a boolean analyte : str name of analyte the filter is for. Returns ------- ...
latools/filtering/filt_obj.py
def grab_filt(self, filt, analyte=None): """ Flexible access to specific filter using any key format. Parameters ---------- f : str, dict or bool either logical filter expression, dict of expressions, or a boolean analyte : str name of...
def grab_filt(self, filt, analyte=None): """ Flexible access to specific filter using any key format. Parameters ---------- f : str, dict or bool either logical filter expression, dict of expressions, or a boolean analyte : str name of...
[ "Flexible", "access", "to", "specific", "filter", "using", "any", "key", "format", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/filt_obj.py#L409-L450
[ "def", "grab_filt", "(", "self", ",", "filt", ",", "analyte", "=", "None", ")", ":", "if", "isinstance", "(", "filt", ",", "str", ")", ":", "if", "filt", "in", "self", ".", "components", ":", "if", "analyte", "is", "None", ":", "return", "self", "....
cd25a650cfee318152f234d992708511f7047fbe
test
filt.get_components
Extract filter components for specific analyte(s). Parameters ---------- key : str string present in one or more filter names. e.g. 'Al27' will return all filters with 'Al27' in their names. analyte : str name of analyte the filter is for ...
latools/filtering/filt_obj.py
def get_components(self, key, analyte=None): """ Extract filter components for specific analyte(s). Parameters ---------- key : str string present in one or more filter names. e.g. 'Al27' will return all filters with 'Al27' in their names. ...
def get_components(self, key, analyte=None): """ Extract filter components for specific analyte(s). Parameters ---------- key : str string present in one or more filter names. e.g. 'Al27' will return all filters with 'Al27' in their names. ...
[ "Extract", "filter", "components", "for", "specific", "analyte", "(", "s", ")", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/filt_obj.py#L452-L476
[ "def", "get_components", "(", "self", ",", "key", ",", "analyte", "=", "None", ")", ":", "out", "=", "{", "}", "for", "k", ",", "v", "in", "self", ".", "components", ".", "items", "(", ")", ":", "if", "key", "in", "k", ":", "if", "analyte", "is...
cd25a650cfee318152f234d992708511f7047fbe
test
filt.get_info
Get info for all filters.
latools/filtering/filt_obj.py
def get_info(self): """ Get info for all filters. """ out = '' for k in sorted(self.components.keys()): out += '{:s}: {:s}'.format(k, self.info[k]) + '\n' return(out)
def get_info(self): """ Get info for all filters. """ out = '' for k in sorted(self.components.keys()): out += '{:s}: {:s}'.format(k, self.info[k]) + '\n' return(out)
[ "Get", "info", "for", "all", "filters", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/filt_obj.py#L478-L485
[ "def", "get_info", "(", "self", ")", ":", "out", "=", "''", "for", "k", "in", "sorted", "(", "self", ".", "components", ".", "keys", "(", ")", ")", ":", "out", "+=", "'{:s}: {:s}'", ".", "format", "(", "k", ",", "self", ".", "info", "[", "k", "...
cd25a650cfee318152f234d992708511f7047fbe
test
read_data
Load data_file described by a dataformat dict. Parameters ---------- data_file : str Path to data file, including extension. dataformat : dict A dataformat dict, see example below. name_mode : str How to identyfy sample names. If 'file_names' uses the input name of t...
latools/processes/data_read.py
def read_data(data_file, dataformat, name_mode): """ Load data_file described by a dataformat dict. Parameters ---------- data_file : str Path to data file, including extension. dataformat : dict A dataformat dict, see example below. name_mode : str How to identyfy s...
def read_data(data_file, dataformat, name_mode): """ Load data_file described by a dataformat dict. Parameters ---------- data_file : str Path to data file, including extension. dataformat : dict A dataformat dict, see example below. name_mode : str How to identyfy s...
[ "Load", "data_file", "described", "by", "a", "dataformat", "dict", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/processes/data_read.py#L6-L120
[ "def", "read_data", "(", "data_file", ",", "dataformat", ",", "name_mode", ")", ":", "with", "open", "(", "data_file", ")", "as", "f", ":", "lines", "=", "f", ".", "readlines", "(", ")", "if", "'meta_regex'", "in", "dataformat", ".", "keys", "(", ")", ...
cd25a650cfee318152f234d992708511f7047fbe
test
residual_plots
Function for plotting Test User and LAtools data comparison. Parameters ---------- df : pandas.DataFrame A dataframe containing reference ('X/Ca_r'), test user ('X/Ca_t') and LAtools ('X123') data. rep_stats : dict Reproducibility stats of the reference data produced by ...
Supplement/comparison_tools/plots_1sample.py
def residual_plots(df, rep_stats=None, els=['Mg', 'Sr', 'Al', 'Mn', 'Fe', 'Cu', 'Zn', 'B']): """ Function for plotting Test User and LAtools data comparison. Parameters ---------- df : pandas.DataFrame A dataframe containing reference ('X/Ca_r'), test user ('X/Ca_t') and LAtools ('...
def residual_plots(df, rep_stats=None, els=['Mg', 'Sr', 'Al', 'Mn', 'Fe', 'Cu', 'Zn', 'B']): """ Function for plotting Test User and LAtools data comparison. Parameters ---------- df : pandas.DataFrame A dataframe containing reference ('X/Ca_r'), test user ('X/Ca_t') and LAtools ('...
[ "Function", "for", "plotting", "Test", "User", "and", "LAtools", "data", "comparison", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/Supplement/comparison_tools/plots_1sample.py#L94-L178
[ "def", "residual_plots", "(", "df", ",", "rep_stats", "=", "None", ",", "els", "=", "[", "'Mg'", ",", "'Sr'", ",", "'Al'", ",", "'Mn'", ",", "'Fe'", ",", "'Cu'", ",", "'Zn'", ",", "'B'", "]", ")", ":", "# get corresponding analyte and ratio names", "As",...
cd25a650cfee318152f234d992708511f7047fbe
test
comparison_stats
Compute comparison stats for test and LAtools data. Population-level similarity assessed by a Kolmogorov-Smirnov test. Individual similarity assessed by a pairwise Wilcoxon signed rank test. Trends in residuals assessed by regression analysis, where significance of the slope and intercept...
Supplement/comparison_tools/stats_zircon.py
def comparison_stats(df, els=None): """ Compute comparison stats for test and LAtools data. Population-level similarity assessed by a Kolmogorov-Smirnov test. Individual similarity assessed by a pairwise Wilcoxon signed rank test. Trends in residuals assessed by regression analysis, w...
def comparison_stats(df, els=None): """ Compute comparison stats for test and LAtools data. Population-level similarity assessed by a Kolmogorov-Smirnov test. Individual similarity assessed by a pairwise Wilcoxon signed rank test. Trends in residuals assessed by regression analysis, w...
[ "Compute", "comparison", "stats", "for", "test", "and", "LAtools", "data", ".", "Population", "-", "level", "similarity", "assessed", "by", "a", "Kolmogorov", "-", "Smirnov", "test", ".", "Individual", "similarity", "assessed", "by", "a", "pairwise", "Wilcoxon",...
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/Supplement/comparison_tools/stats_zircon.py#L8-L47
[ "def", "comparison_stats", "(", "df", ",", "els", "=", "None", ")", ":", "if", "els", "is", "None", ":", "els", "=", "[", "'Li'", ",", "'Mg'", ",", "'Al'", ",", "'P'", ",", "'Ti'", ",", "'Y'", ",", "'La'", ",", "'Ce'", ",", "'Pr'", ",", "'Nd'",...
cd25a650cfee318152f234d992708511f7047fbe
test
_log
Function for logging method calls and parameters
latools/helpers/logging.py
def _log(func): """ Function for logging method calls and parameters """ @wraps(func) def wrapper(self, *args, **kwargs): a = func(self, *args, **kwargs) self.log.append(func.__name__ + ' :: args={} kwargs={}'.format(args, kwargs)) return a return wrapper
def _log(func): """ Function for logging method calls and parameters """ @wraps(func) def wrapper(self, *args, **kwargs): a = func(self, *args, **kwargs) self.log.append(func.__name__ + ' :: args={} kwargs={}'.format(args, kwargs)) return a return wrapper
[ "Function", "for", "logging", "method", "calls", "and", "parameters" ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/helpers/logging.py#L6-L15
[ "def", "_log", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "a", "=", "func", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "self", ...
cd25a650cfee318152f234d992708511f7047fbe
test
write_logfile
Write and analysis log to a file. Parameters ---------- log : list latools.analyse analysis log header : list File header lines. file_name : str Destination file. If no file extension specified, uses '.lalog' Returns ------- None
latools/helpers/logging.py
def write_logfile(log, header, file_name): """ Write and analysis log to a file. Parameters ---------- log : list latools.analyse analysis log header : list File header lines. file_name : str Destination file. If no file extension specified, uses '.lalog' ...
def write_logfile(log, header, file_name): """ Write and analysis log to a file. Parameters ---------- log : list latools.analyse analysis log header : list File header lines. file_name : str Destination file. If no file extension specified, uses '.lalog' ...
[ "Write", "and", "analysis", "log", "to", "a", "file", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/helpers/logging.py#L17-L43
[ "def", "write_logfile", "(", "log", ",", "header", ",", "file_name", ")", ":", "path", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "file_name", ")", "if", "ext", "==", "''", ":", "ext", "=", "'.lalog'", "with", "open", "(", "path", "+...
cd25a650cfee318152f234d992708511f7047fbe
test
read_logfile
Reads an latools analysis.log file, and returns dicts of arguments. Parameters ---------- log_file : str Path to an analysis.log file produced by latools. Returns ------- runargs, paths : tuple Two dictionaries. runargs contains all the arguments required to run each step ...
latools/helpers/logging.py
def read_logfile(log_file): """ Reads an latools analysis.log file, and returns dicts of arguments. Parameters ---------- log_file : str Path to an analysis.log file produced by latools. Returns ------- runargs, paths : tuple Two dictionaries. runargs contains all t...
def read_logfile(log_file): """ Reads an latools analysis.log file, and returns dicts of arguments. Parameters ---------- log_file : str Path to an analysis.log file produced by latools. Returns ------- runargs, paths : tuple Two dictionaries. runargs contains all t...
[ "Reads", "an", "latools", "analysis", ".", "log", "file", "and", "returns", "dicts", "of", "arguments", "." ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/helpers/logging.py#L45-L86
[ "def", "read_logfile", "(", "log_file", ")", ":", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "log_file", ")", "+", "'/'", "with", "open", "(", "log_file", ",", "'r'", ")", "as", "f", ":", "rlog", "=", "f", ".", "readlines", "(", ")", ...
cd25a650cfee318152f234d992708511f7047fbe
test
zipdir
Compresses the target directory, and saves it to ../name.zip Parameters ---------- directory : str Path to the directory you want to compress. Compressed file will be saved at directory/../name.zip name : str (default=None) The name of the resulting zip file. If not specified, t...
latools/helpers/utils.py
def zipdir(directory, name=None, delete=False): """ Compresses the target directory, and saves it to ../name.zip Parameters ---------- directory : str Path to the directory you want to compress. Compressed file will be saved at directory/../name.zip name : str (default=None) ...
def zipdir(directory, name=None, delete=False): """ Compresses the target directory, and saves it to ../name.zip Parameters ---------- directory : str Path to the directory you want to compress. Compressed file will be saved at directory/../name.zip name : str (default=None) ...
[ "Compresses", "the", "target", "directory", "and", "saves", "it", "to", "..", "/", "name", ".", "zip" ]
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/helpers/utils.py#L6-L41
[ "def", "zipdir", "(", "directory", ",", "name", "=", "None", ",", "delete", "=", "False", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "directory", ")", "or", "not", "os", ".", "path", ".", "exists", "(", "directory", ")", ":", "r...
cd25a650cfee318152f234d992708511f7047fbe
test
extract_zipdir
Extract contents of zip file into subfolder in parent directory. Parameters ---------- zip_file : str Path to zip file Returns ------- str : folder where the zip was extracted
latools/helpers/utils.py
def extract_zipdir(zip_file): """ Extract contents of zip file into subfolder in parent directory. Parameters ---------- zip_file : str Path to zip file Returns ------- str : folder where the zip was extracted """ if not os.path.exists(zip_file): rai...
def extract_zipdir(zip_file): """ Extract contents of zip file into subfolder in parent directory. Parameters ---------- zip_file : str Path to zip file Returns ------- str : folder where the zip was extracted """ if not os.path.exists(zip_file): rai...
[ "Extract", "contents", "of", "zip", "file", "into", "subfolder", "in", "parent", "directory", ".", "Parameters", "----------", "zip_file", ":", "str", "Path", "to", "zip", "file", "Returns", "-------", "str", ":", "folder", "where", "the", "zip", "was", "ext...
oscarbranson/latools
python
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/helpers/utils.py#L43-L65
[ "def", "extract_zipdir", "(", "zip_file", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "zip_file", ")", ":", "raise", "ValueError", "(", "'{} does not exist'", ".", "format", "(", "zip_file", ")", ")", "directory", "=", "os", ".", "path"...
cd25a650cfee318152f234d992708511f7047fbe
test
autologin
Decorator that will try to login and redo an action before failing.
eternalegypt/eternalegypt.py
def autologin(function, timeout=TIMEOUT): """Decorator that will try to login and redo an action before failing.""" @wraps(function) async def wrapper(self, *args, **kwargs): """Wrap a function with timeout.""" try: async with async_timeout.timeout(timeout): retur...
def autologin(function, timeout=TIMEOUT): """Decorator that will try to login and redo an action before failing.""" @wraps(function) async def wrapper(self, *args, **kwargs): """Wrap a function with timeout.""" try: async with async_timeout.timeout(timeout): retur...
[ "Decorator", "that", "will", "try", "to", "login", "and", "redo", "an", "action", "before", "failing", "." ]
amelchio/eternalegypt
python
https://github.com/amelchio/eternalegypt/blob/895e0b235ceaf7f61458c620237c3ad397780e98/eternalegypt/eternalegypt.py#L52-L71
[ "def", "autologin", "(", "function", ",", "timeout", "=", "TIMEOUT", ")", ":", "@", "wraps", "(", "function", ")", "async", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrap a function with timeout.\"\"\"", "tr...
895e0b235ceaf7f61458c620237c3ad397780e98
test
get_information
Example of printing the inbox.
examples/inbox.py
async def get_information(): """Example of printing the inbox.""" jar = aiohttp.CookieJar(unsafe=True) websession = aiohttp.ClientSession(cookie_jar=jar) modem = eternalegypt.Modem(hostname=sys.argv[1], websession=websession) await modem.login(password=sys.argv[2]) result = await modem.informa...
async def get_information(): """Example of printing the inbox.""" jar = aiohttp.CookieJar(unsafe=True) websession = aiohttp.ClientSession(cookie_jar=jar) modem = eternalegypt.Modem(hostname=sys.argv[1], websession=websession) await modem.login(password=sys.argv[2]) result = await modem.informa...
[ "Example", "of", "printing", "the", "inbox", "." ]
amelchio/eternalegypt
python
https://github.com/amelchio/eternalegypt/blob/895e0b235ceaf7f61458c620237c3ad397780e98/examples/inbox.py#L16-L29
[ "async", "def", "get_information", "(", ")", ":", "jar", "=", "aiohttp", ".", "CookieJar", "(", "unsafe", "=", "True", ")", "websession", "=", "aiohttp", ".", "ClientSession", "(", "cookie_jar", "=", "jar", ")", "modem", "=", "eternalegypt", ".", "Modem", ...
895e0b235ceaf7f61458c620237c3ad397780e98
test
send_message
Example of sending a message.
examples/sms.py
async def send_message(): """Example of sending a message.""" jar = aiohttp.CookieJar(unsafe=True) websession = aiohttp.ClientSession(cookie_jar=jar) modem = eternalegypt.Modem(hostname=sys.argv[1], websession=websession) await modem.login(password=sys.argv[2]) await modem.sms(phone=sys.argv[3...
async def send_message(): """Example of sending a message.""" jar = aiohttp.CookieJar(unsafe=True) websession = aiohttp.ClientSession(cookie_jar=jar) modem = eternalegypt.Modem(hostname=sys.argv[1], websession=websession) await modem.login(password=sys.argv[2]) await modem.sms(phone=sys.argv[3...
[ "Example", "of", "sending", "a", "message", "." ]
amelchio/eternalegypt
python
https://github.com/amelchio/eternalegypt/blob/895e0b235ceaf7f61458c620237c3ad397780e98/examples/sms.py#L15-L26
[ "async", "def", "send_message", "(", ")", ":", "jar", "=", "aiohttp", ".", "CookieJar", "(", "unsafe", "=", "True", ")", "websession", "=", "aiohttp", ".", "ClientSession", "(", "cookie_jar", "=", "jar", ")", "modem", "=", "eternalegypt", ".", "Modem", "...
895e0b235ceaf7f61458c620237c3ad397780e98
test
get_information
Example of printing the current upstream.
examples/status.py
async def get_information(): """Example of printing the current upstream.""" jar = aiohttp.CookieJar(unsafe=True) websession = aiohttp.ClientSession(cookie_jar=jar) try: modem = eternalegypt.Modem(hostname=sys.argv[1], websession=websession) await modem.login(password=sys.argv[2]) ...
async def get_information(): """Example of printing the current upstream.""" jar = aiohttp.CookieJar(unsafe=True) websession = aiohttp.ClientSession(cookie_jar=jar) try: modem = eternalegypt.Modem(hostname=sys.argv[1], websession=websession) await modem.login(password=sys.argv[2]) ...
[ "Example", "of", "printing", "the", "current", "upstream", "." ]
amelchio/eternalegypt
python
https://github.com/amelchio/eternalegypt/blob/895e0b235ceaf7f61458c620237c3ad397780e98/examples/status.py#L11-L41
[ "async", "def", "get_information", "(", ")", ":", "jar", "=", "aiohttp", ".", "CookieJar", "(", "unsafe", "=", "True", ")", "websession", "=", "aiohttp", ".", "ClientSession", "(", "cookie_jar", "=", "jar", ")", "try", ":", "modem", "=", "eternalegypt", ...
895e0b235ceaf7f61458c620237c3ad397780e98
test
set_failover_mode
Example of printing the current upstream.
examples/failover.py
async def set_failover_mode(mode): """Example of printing the current upstream.""" jar = aiohttp.CookieJar(unsafe=True) websession = aiohttp.ClientSession(cookie_jar=jar) try: modem = eternalegypt.Modem(hostname=sys.argv[1], websession=websession) await modem.login(password=sys.argv[2])...
async def set_failover_mode(mode): """Example of printing the current upstream.""" jar = aiohttp.CookieJar(unsafe=True) websession = aiohttp.ClientSession(cookie_jar=jar) try: modem = eternalegypt.Modem(hostname=sys.argv[1], websession=websession) await modem.login(password=sys.argv[2])...
[ "Example", "of", "printing", "the", "current", "upstream", "." ]
amelchio/eternalegypt
python
https://github.com/amelchio/eternalegypt/blob/895e0b235ceaf7f61458c620237c3ad397780e98/examples/failover.py#L12-L27
[ "async", "def", "set_failover_mode", "(", "mode", ")", ":", "jar", "=", "aiohttp", ".", "CookieJar", "(", "unsafe", "=", "True", ")", "websession", "=", "aiohttp", ".", "ClientSession", "(", "cookie_jar", "=", "jar", ")", "try", ":", "modem", "=", "etern...
895e0b235ceaf7f61458c620237c3ad397780e98
test
parse
Parse a file-like object or string. Args: file_or_string (file, str): File-like object or string. Returns: ParseResults: instance of pyparsing parse results.
mysqlparse/__init__.py
def parse(file_or_string): """Parse a file-like object or string. Args: file_or_string (file, str): File-like object or string. Returns: ParseResults: instance of pyparsing parse results. """ from mysqlparse.grammar.sql_file import sql_file_syntax if hasattr(file_or_string, 'r...
def parse(file_or_string): """Parse a file-like object or string. Args: file_or_string (file, str): File-like object or string. Returns: ParseResults: instance of pyparsing parse results. """ from mysqlparse.grammar.sql_file import sql_file_syntax if hasattr(file_or_string, 'r...
[ "Parse", "a", "file", "-", "like", "object", "or", "string", "." ]
seporaitis/mysqlparse
python
https://github.com/seporaitis/mysqlparse/blob/c327c5a1d8d6d143b67f789be7dc80357a1a5556/mysqlparse/__init__.py#L11-L29
[ "def", "parse", "(", "file_or_string", ")", ":", "from", "mysqlparse", ".", "grammar", ".", "sql_file", "import", "sql_file_syntax", "if", "hasattr", "(", "file_or_string", ",", "'read'", ")", "and", "hasattr", "(", "file_or_string", ".", "read", ",", "'__call...
c327c5a1d8d6d143b67f789be7dc80357a1a5556
test
nbviewer_link
Return the link to the Jupyter nbviewer for the given notebook url
sphinx_nbexamples/__init__.py
def nbviewer_link(url): """Return the link to the Jupyter nbviewer for the given notebook url""" if six.PY2: from urlparse import urlparse as urlsplit else: from urllib.parse import urlsplit info = urlsplit(url) domain = info.netloc url_type = 'github' if domain == 'github.com' e...
def nbviewer_link(url): """Return the link to the Jupyter nbviewer for the given notebook url""" if six.PY2: from urlparse import urlparse as urlsplit else: from urllib.parse import urlsplit info = urlsplit(url) domain = info.netloc url_type = 'github' if domain == 'github.com' e...
[ "Return", "the", "link", "to", "the", "Jupyter", "nbviewer", "for", "the", "given", "notebook", "url" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L88-L97
[ "def", "nbviewer_link", "(", "url", ")", ":", "if", "six", ".", "PY2", ":", "from", "urlparse", "import", "urlparse", "as", "urlsplit", "else", ":", "from", "urllib", ".", "parse", "import", "urlsplit", "info", "=", "urlsplit", "(", "url", ")", "domain",...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.thumbnail_div
The string for creating the thumbnail of this example
sphinx_nbexamples/__init__.py
def thumbnail_div(self): """The string for creating the thumbnail of this example""" return self.THUMBNAIL_TEMPLATE.format( snippet=self.get_description()[1], thumbnail=self.thumb_file, ref_name=self.reference)
def thumbnail_div(self): """The string for creating the thumbnail of this example""" return self.THUMBNAIL_TEMPLATE.format( snippet=self.get_description()[1], thumbnail=self.thumb_file, ref_name=self.reference)
[ "The", "string", "for", "creating", "the", "thumbnail", "of", "this", "example" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L201-L205
[ "def", "thumbnail_div", "(", "self", ")", ":", "return", "self", ".", "THUMBNAIL_TEMPLATE", ".", "format", "(", "snippet", "=", "self", ".", "get_description", "(", ")", "[", "1", "]", ",", "thumbnail", "=", "self", ".", "thumb_file", ",", "ref_name", "=...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.code_div
The string for creating a code example for the gallery
sphinx_nbexamples/__init__.py
def code_div(self): """The string for creating a code example for the gallery""" code_example = self.code_example if code_example is None: return None return self.CODE_TEMPLATE.format( snippet=self.get_description()[1], code=code_example, ref_name=self...
def code_div(self): """The string for creating a code example for the gallery""" code_example = self.code_example if code_example is None: return None return self.CODE_TEMPLATE.format( snippet=self.get_description()[1], code=code_example, ref_name=self...
[ "The", "string", "for", "creating", "a", "code", "example", "for", "the", "gallery" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L208-L215
[ "def", "code_div", "(", "self", ")", ":", "code_example", "=", "self", ".", "code_example", "if", "code_example", "is", "None", ":", "return", "None", "return", "self", ".", "CODE_TEMPLATE", ".", "format", "(", "snippet", "=", "self", ".", "get_description",...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.code_example
The code example out of the notebook metadata
sphinx_nbexamples/__init__.py
def code_example(self): """The code example out of the notebook metadata""" if self._code_example is not None: return self._code_example return getattr(self.nb.metadata, 'code_example', None)
def code_example(self): """The code example out of the notebook metadata""" if self._code_example is not None: return self._code_example return getattr(self.nb.metadata, 'code_example', None)
[ "The", "code", "example", "out", "of", "the", "notebook", "metadata" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L218-L222
[ "def", "code_example", "(", "self", ")", ":", "if", "self", ".", "_code_example", "is", "not", "None", ":", "return", "self", ".", "_code_example", "return", "getattr", "(", "self", ".", "nb", ".", "metadata", ",", "'code_example'", ",", "None", ")" ]
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.supplementary_files
The supplementary files of this notebook
sphinx_nbexamples/__init__.py
def supplementary_files(self): """The supplementary files of this notebook""" if self._supplementary_files is not None: return self._supplementary_files return getattr(self.nb.metadata, 'supplementary_files', None)
def supplementary_files(self): """The supplementary files of this notebook""" if self._supplementary_files is not None: return self._supplementary_files return getattr(self.nb.metadata, 'supplementary_files', None)
[ "The", "supplementary", "files", "of", "this", "notebook" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L225-L229
[ "def", "supplementary_files", "(", "self", ")", ":", "if", "self", ".", "_supplementary_files", "is", "not", "None", ":", "return", "self", ".", "_supplementary_files", "return", "getattr", "(", "self", ".", "nb", ".", "metadata", ",", "'supplementary_files'", ...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.other_supplementary_files
The supplementary files of this notebook
sphinx_nbexamples/__init__.py
def other_supplementary_files(self): """The supplementary files of this notebook""" if self._other_supplementary_files is not None: return self._other_supplementary_files return getattr(self.nb.metadata, 'other_supplementary_files', None)
def other_supplementary_files(self): """The supplementary files of this notebook""" if self._other_supplementary_files is not None: return self._other_supplementary_files return getattr(self.nb.metadata, 'other_supplementary_files', None)
[ "The", "supplementary", "files", "of", "this", "notebook" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L232-L236
[ "def", "other_supplementary_files", "(", "self", ")", ":", "if", "self", ".", "_other_supplementary_files", "is", "not", "None", ":", "return", "self", ".", "_other_supplementary_files", "return", "getattr", "(", "self", ".", "nb", ".", "metadata", ",", "'other_...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.url
The url on jupyter nbviewer for this notebook or None if unknown
sphinx_nbexamples/__init__.py
def url(self): """The url on jupyter nbviewer for this notebook or None if unknown""" if self._url is not None: url = self._url else: url = getattr(self.nb.metadata, 'url', None) if url is not None: return nbviewer_link(url)
def url(self): """The url on jupyter nbviewer for this notebook or None if unknown""" if self._url is not None: url = self._url else: url = getattr(self.nb.metadata, 'url', None) if url is not None: return nbviewer_link(url)
[ "The", "url", "on", "jupyter", "nbviewer", "for", "this", "notebook", "or", "None", "if", "unknown" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L244-L251
[ "def", "url", "(", "self", ")", ":", "if", "self", ".", "_url", "is", "not", "None", ":", "url", "=", "self", ".", "_url", "else", ":", "url", "=", "getattr", "(", "self", ".", "nb", ".", "metadata", ",", "'url'", ",", "None", ")", "if", "url",...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.get_out_file
get the output file with the specified `ending`
sphinx_nbexamples/__init__.py
def get_out_file(self, ending='rst'): """get the output file with the specified `ending`""" return os.path.splitext(self.outfile)[0] + os.path.extsep + ending
def get_out_file(self, ending='rst'): """get the output file with the specified `ending`""" return os.path.splitext(self.outfile)[0] + os.path.extsep + ending
[ "get", "the", "output", "file", "with", "the", "specified", "ending" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L313-L315
[ "def", "get_out_file", "(", "self", ",", "ending", "=", "'rst'", ")", ":", "return", "os", ".", "path", ".", "splitext", "(", "self", ".", "outfile", ")", "[", "0", "]", "+", "os", ".", "path", ".", "extsep", "+", "ending" ]
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.process_notebook
Process the notebook and create all the pictures and files This method runs the notebook using the :mod:`nbconvert` and :mod:`nbformat` modules. It creates the :attr:`outfile` notebook, a python and a rst file
sphinx_nbexamples/__init__.py
def process_notebook(self, disable_warnings=True): """Process the notebook and create all the pictures and files This method runs the notebook using the :mod:`nbconvert` and :mod:`nbformat` modules. It creates the :attr:`outfile` notebook, a python and a rst file""" infile = sel...
def process_notebook(self, disable_warnings=True): """Process the notebook and create all the pictures and files This method runs the notebook using the :mod:`nbconvert` and :mod:`nbformat` modules. It creates the :attr:`outfile` notebook, a python and a rst file""" infile = sel...
[ "Process", "the", "notebook", "and", "create", "all", "the", "pictures", "and", "files" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L317-L379
[ "def", "process_notebook", "(", "self", ",", "disable_warnings", "=", "True", ")", ":", "infile", "=", "self", ".", "infile", "outfile", "=", "self", ".", "outfile", "in_dir", "=", "os", ".", "path", ".", "dirname", "(", "infile", ")", "+", "os", ".", ...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.create_rst
Create the rst file from the notebook node
sphinx_nbexamples/__init__.py
def create_rst(self, nb, in_dir, odir): """Create the rst file from the notebook node""" raw_rst, resources = nbconvert.export_by_name('rst', nb) # remove ipython magics rst_content = '' i0 = 0 m = None # HACK: we insert the bokeh style sheets here as well, since ...
def create_rst(self, nb, in_dir, odir): """Create the rst file from the notebook node""" raw_rst, resources = nbconvert.export_by_name('rst', nb) # remove ipython magics rst_content = '' i0 = 0 m = None # HACK: we insert the bokeh style sheets here as well, since ...
[ "Create", "the", "rst", "file", "from", "the", "notebook", "node" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L381-L458
[ "def", "create_rst", "(", "self", ",", "nb", ",", "in_dir", ",", "odir", ")", ":", "raw_rst", ",", "resources", "=", "nbconvert", ".", "export_by_name", "(", "'rst'", ",", "nb", ")", "# remove ipython magics", "rst_content", "=", "''", "i0", "=", "0", "m...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.create_py
Create the python script from the notebook node
sphinx_nbexamples/__init__.py
def create_py(self, nb, force=False): """Create the python script from the notebook node""" # Although we would love to simply use ``nbconvert.export_python(nb)`` # this causes troubles in other cells processed by the ipython # directive. Instead of getting something like ``Out [5]:``, w...
def create_py(self, nb, force=False): """Create the python script from the notebook node""" # Although we would love to simply use ``nbconvert.export_python(nb)`` # this causes troubles in other cells processed by the ipython # directive. Instead of getting something like ``Out [5]:``, w...
[ "Create", "the", "python", "script", "from", "the", "notebook", "node" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L460-L484
[ "def", "create_py", "(", "self", ",", "nb", ",", "force", "=", "False", ")", ":", "# Although we would love to simply use ``nbconvert.export_python(nb)``", "# this causes troubles in other cells processed by the ipython", "# directive. Instead of getting something like ``Out [5]:``, we g...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.data_download
Create the rst string to download supplementary data
sphinx_nbexamples/__init__.py
def data_download(self, files): """Create the rst string to download supplementary data""" if len(files) > 1: return self.DATA_DOWNLOAD % ( ('\n\n' + ' '*8) + ('\n' + ' '*8).join( '* :download:`%s`' % f for f in files)) return self.DATA_DOWNLOAD % ...
def data_download(self, files): """Create the rst string to download supplementary data""" if len(files) > 1: return self.DATA_DOWNLOAD % ( ('\n\n' + ' '*8) + ('\n' + ' '*8).join( '* :download:`%s`' % f for f in files)) return self.DATA_DOWNLOAD % ...
[ "Create", "the", "rst", "string", "to", "download", "supplementary", "data" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L486-L492
[ "def", "data_download", "(", "self", ",", "files", ")", ":", "if", "len", "(", "files", ")", ">", "1", ":", "return", "self", ".", "DATA_DOWNLOAD", "%", "(", "(", "'\\n\\n'", "+", "' '", "*", "8", ")", "+", "(", "'\\n'", "+", "' '", "*", "8", "...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.create_thumb
Create the thumbnail for html output
sphinx_nbexamples/__init__.py
def create_thumb(self): """Create the thumbnail for html output""" thumbnail_figure = self.copy_thumbnail_figure() if thumbnail_figure is not None: if isinstance(thumbnail_figure, six.string_types): pic = thumbnail_figure else: pic = self.p...
def create_thumb(self): """Create the thumbnail for html output""" thumbnail_figure = self.copy_thumbnail_figure() if thumbnail_figure is not None: if isinstance(thumbnail_figure, six.string_types): pic = thumbnail_figure else: pic = self.p...
[ "Create", "the", "thumbnail", "for", "html", "output" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L494-L507
[ "def", "create_thumb", "(", "self", ")", ":", "thumbnail_figure", "=", "self", ".", "copy_thumbnail_figure", "(", ")", "if", "thumbnail_figure", "is", "not", "None", ":", "if", "isinstance", "(", "thumbnail_figure", ",", "six", ".", "string_types", ")", ":", ...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.get_description
Get summary and description of this notebook
sphinx_nbexamples/__init__.py
def get_description(self): """Get summary and description of this notebook""" def split_header(s, get_header=True): s = s.lstrip().rstrip() parts = s.splitlines() if parts[0].startswith('#'): if get_header: header = re.sub('#+\s*', ...
def get_description(self): """Get summary and description of this notebook""" def split_header(s, get_header=True): s = s.lstrip().rstrip() parts = s.splitlines() if parts[0].startswith('#'): if get_header: header = re.sub('#+\s*', ...
[ "Get", "summary", "and", "description", "of", "this", "notebook" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L509-L548
[ "def", "get_description", "(", "self", ")", ":", "def", "split_header", "(", "s", ",", "get_header", "=", "True", ")", ":", "s", "=", "s", ".", "lstrip", "(", ")", ".", "rstrip", "(", ")", "parts", "=", "s", ".", "splitlines", "(", ")", "if", "pa...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.scale_image
Scales an image with the same aspect ratio centered in an image with a given max_width and max_height if in_fname == out_fname the image can only be scaled down
sphinx_nbexamples/__init__.py
def scale_image(self, in_fname, out_fname, max_width, max_height): """Scales an image with the same aspect ratio centered in an image with a given max_width and max_height if in_fname == out_fname the image can only be scaled down """ # local import to avoid testing depende...
def scale_image(self, in_fname, out_fname, max_width, max_height): """Scales an image with the same aspect ratio centered in an image with a given max_width and max_height if in_fname == out_fname the image can only be scaled down """ # local import to avoid testing depende...
[ "Scales", "an", "image", "with", "the", "same", "aspect", "ratio", "centered", "in", "an", "image", "with", "a", "given", "max_width", "and", "max_height", "if", "in_fname", "==", "out_fname", "the", "image", "can", "only", "be", "scaled", "down" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L550-L585
[ "def", "scale_image", "(", "self", ",", "in_fname", ",", "out_fname", ",", "max_width", ",", "max_height", ")", ":", "# local import to avoid testing dependency on PIL:", "try", ":", "from", "PIL", "import", "Image", "except", "ImportError", ":", "import", "Image", ...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.save_thumbnail
Save the thumbnail image
sphinx_nbexamples/__init__.py
def save_thumbnail(self, image_path): """Save the thumbnail image""" thumb_dir = os.path.join(os.path.dirname(image_path), 'thumb') create_dirs(thumb_dir) thumb_file = os.path.join(thumb_dir, '%s_thumb.png' % self.reference) if os.path.exists(im...
def save_thumbnail(self, image_path): """Save the thumbnail image""" thumb_dir = os.path.join(os.path.dirname(image_path), 'thumb') create_dirs(thumb_dir) thumb_file = os.path.join(thumb_dir, '%s_thumb.png' % self.reference) if os.path.exists(im...
[ "Save", "the", "thumbnail", "image" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L587-L597
[ "def", "save_thumbnail", "(", "self", ",", "image_path", ")", ":", "thumb_dir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "image_path", ")", ",", "'thumb'", ")", "create_dirs", "(", "thumb_dir", ")", "thumb_file", ...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
NotebookProcessor.copy_thumbnail_figure
The integer of the thumbnail figure
sphinx_nbexamples/__init__.py
def copy_thumbnail_figure(self): """The integer of the thumbnail figure""" ret = None if self._thumbnail_figure is not None: if not isstring(self._thumbnail_figure): ret = self._thumbnail_figure else: ret = osp.join(osp.dirname(self.outfile...
def copy_thumbnail_figure(self): """The integer of the thumbnail figure""" ret = None if self._thumbnail_figure is not None: if not isstring(self._thumbnail_figure): ret = self._thumbnail_figure else: ret = osp.join(osp.dirname(self.outfile...
[ "The", "integer", "of", "the", "thumbnail", "figure" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L603-L623
[ "def", "copy_thumbnail_figure", "(", "self", ")", ":", "ret", "=", "None", "if", "self", ".", "_thumbnail_figure", "is", "not", "None", ":", "if", "not", "isstring", "(", "self", ".", "_thumbnail_figure", ")", ":", "ret", "=", "self", ".", "_thumbnail_figu...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
Gallery.process_directories
Create the rst files from the input directories in the :attr:`in_dir` attribute
sphinx_nbexamples/__init__.py
def process_directories(self): """Create the rst files from the input directories in the :attr:`in_dir` attribute""" for i, (base_dir, target_dir, paths) in enumerate(zip( self.in_dir, self.out_dir, map(os.walk, self.in_dir))): self._in_dir_count = i self....
def process_directories(self): """Create the rst files from the input directories in the :attr:`in_dir` attribute""" for i, (base_dir, target_dir, paths) in enumerate(zip( self.in_dir, self.out_dir, map(os.walk, self.in_dir))): self._in_dir_count = i self....
[ "Create", "the", "rst", "files", "from", "the", "input", "directories", "in", "the", ":", "attr", ":", "in_dir", "attribute" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L778-L784
[ "def", "process_directories", "(", "self", ")", ":", "for", "i", ",", "(", "base_dir", ",", "target_dir", ",", "paths", ")", "in", "enumerate", "(", "zip", "(", "self", ".", "in_dir", ",", "self", ".", "out_dir", ",", "map", "(", "os", ".", "walk", ...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
Gallery.recursive_processing
Method to recursivly process the notebooks in the `base_dir` Parameters ---------- base_dir: str Path to the base example directory (see the `examples_dir` parameter for the :class:`Gallery` class) target_dir: str Path to the output directory for the ...
sphinx_nbexamples/__init__.py
def recursive_processing(self, base_dir, target_dir, it): """Method to recursivly process the notebooks in the `base_dir` Parameters ---------- base_dir: str Path to the base example directory (see the `examples_dir` parameter for the :class:`Gallery` class) ...
def recursive_processing(self, base_dir, target_dir, it): """Method to recursivly process the notebooks in the `base_dir` Parameters ---------- base_dir: str Path to the base example directory (see the `examples_dir` parameter for the :class:`Gallery` class) ...
[ "Method", "to", "recursivly", "process", "the", "notebooks", "in", "the", "base_dir" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L786-L875
[ "def", "recursive_processing", "(", "self", ",", "base_dir", ",", "target_dir", ",", "it", ")", ":", "try", ":", "file_dir", ",", "dirs", ",", "files", "=", "next", "(", "it", ")", "except", "StopIteration", ":", "return", "''", ",", "[", "]", "readme_...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
Gallery.from_sphinx
Class method to create a :class:`Gallery` instance from the configuration of a sphinx application
sphinx_nbexamples/__init__.py
def from_sphinx(cls, app): """Class method to create a :class:`Gallery` instance from the configuration of a sphinx application""" app.config.html_static_path.append(os.path.join( os.path.dirname(__file__), '_static')) config = app.config.example_gallery_config inser...
def from_sphinx(cls, app): """Class method to create a :class:`Gallery` instance from the configuration of a sphinx application""" app.config.html_static_path.append(os.path.join( os.path.dirname(__file__), '_static')) config = app.config.example_gallery_config inser...
[ "Class", "method", "to", "create", "a", ":", "class", ":", "Gallery", "instance", "from", "the", "configuration", "of", "a", "sphinx", "application" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L878-L910
[ "def", "from_sphinx", "(", "cls", ",", "app", ")", ":", "app", ".", "config", ".", "html_static_path", ".", "append", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'_static'", ")", ")", "co...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
Gallery.get_url
Return the url corresponding to the given notebook file Parameters ---------- nbfile: str The path of the notebook relative to the corresponding :attr:``in_dir`` Returns ------- str or None The url or None if no url has been specified
sphinx_nbexamples/__init__.py
def get_url(self, nbfile): """Return the url corresponding to the given notebook file Parameters ---------- nbfile: str The path of the notebook relative to the corresponding :attr:``in_dir`` Returns ------- str or None The ur...
def get_url(self, nbfile): """Return the url corresponding to the given notebook file Parameters ---------- nbfile: str The path of the notebook relative to the corresponding :attr:``in_dir`` Returns ------- str or None The ur...
[ "Return", "the", "url", "corresponding", "to", "the", "given", "notebook", "file" ]
Chilipp/sphinx-nbexamples
python
https://github.com/Chilipp/sphinx-nbexamples/blob/08e0319ff3c70f8a931dfa8890caf48add4d0470/sphinx_nbexamples/__init__.py#L912-L932
[ "def", "get_url", "(", "self", ",", "nbfile", ")", ":", "urls", "=", "self", ".", "urls", "if", "isinstance", "(", "urls", ",", "dict", ")", ":", "return", "urls", ".", "get", "(", "nbfile", ")", "elif", "isstring", "(", "urls", ")", ":", "if", "...
08e0319ff3c70f8a931dfa8890caf48add4d0470
test
Command.handle
command execution
transmeta/management/commands/sync_transmeta_db.py
def handle(self, *args, **options): """ command execution """ assume_yes = options.get('assume_yes', False) default_language = options.get('default_language', None) # set manual transaction management transaction.commit_unless_managed() transaction.enter_transaction_mana...
def handle(self, *args, **options): """ command execution """ assume_yes = options.get('assume_yes', False) default_language = options.get('default_language', None) # set manual transaction management transaction.commit_unless_managed() transaction.enter_transaction_mana...
[ "command", "execution" ]
Yaco-Sistemas/django-transmeta
python
https://github.com/Yaco-Sistemas/django-transmeta/blob/de070aae27770df046b4ba995f01f654db7ed1a2/transmeta/management/commands/sync_transmeta_db.py#L63-L117
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "assume_yes", "=", "options", ".", "get", "(", "'assume_yes'", ",", "False", ")", "default_language", "=", "options", ".", "get", "(", "'default_language'", ",", "None", ...
de070aae27770df046b4ba995f01f654db7ed1a2
test
Command.get_db_change_languages
get only db changes fields
transmeta/management/commands/sync_transmeta_db.py
def get_db_change_languages(self, field_name, db_table_fields): """ get only db changes fields """ for lang_code, lang_name in get_languages(): if get_real_fieldname(field_name, lang_code) not in db_table_fields: yield lang_code for db_table_field in db_table_fields: ...
def get_db_change_languages(self, field_name, db_table_fields): """ get only db changes fields """ for lang_code, lang_name in get_languages(): if get_real_fieldname(field_name, lang_code) not in db_table_fields: yield lang_code for db_table_field in db_table_fields: ...
[ "get", "only", "db", "changes", "fields" ]
Yaco-Sistemas/django-transmeta
python
https://github.com/Yaco-Sistemas/django-transmeta/blob/de070aae27770df046b4ba995f01f654db7ed1a2/transmeta/management/commands/sync_transmeta_db.py#L134-L145
[ "def", "get_db_change_languages", "(", "self", ",", "field_name", ",", "db_table_fields", ")", ":", "for", "lang_code", ",", "lang_name", "in", "get_languages", "(", ")", ":", "if", "get_real_fieldname", "(", "field_name", ",", "lang_code", ")", "not", "in", "...
de070aae27770df046b4ba995f01f654db7ed1a2
test
Command.get_sync_sql
returns SQL needed for sync schema for a new translatable field
transmeta/management/commands/sync_transmeta_db.py
def get_sync_sql(self, field_name, db_change_langs, model, db_table_fields): """ returns SQL needed for sync schema for a new translatable field """ qn = connection.ops.quote_name style = no_style() sql_output = [] db_table = model._meta.db_table was_translatable_before =...
def get_sync_sql(self, field_name, db_change_langs, model, db_table_fields): """ returns SQL needed for sync schema for a new translatable field """ qn = connection.ops.quote_name style = no_style() sql_output = [] db_table = model._meta.db_table was_translatable_before =...
[ "returns", "SQL", "needed", "for", "sync", "schema", "for", "a", "new", "translatable", "field" ]
Yaco-Sistemas/django-transmeta
python
https://github.com/Yaco-Sistemas/django-transmeta/blob/de070aae27770df046b4ba995f01f654db7ed1a2/transmeta/management/commands/sync_transmeta_db.py#L179-L256
[ "def", "get_sync_sql", "(", "self", ",", "field_name", ",", "db_change_langs", ",", "model", ",", "db_table_fields", ")", ":", "qn", "=", "connection", ".", "ops", ".", "quote_name", "style", "=", "no_style", "(", ")", "sql_output", "=", "[", "]", "db_tabl...
de070aae27770df046b4ba995f01f654db7ed1a2
test
get_all_translatable_fields
returns all translatable fields in a model (including superclasses ones)
transmeta/__init__.py
def get_all_translatable_fields(model, model_trans_fields=None, column_in_current_table=False): """ returns all translatable fields in a model (including superclasses ones) """ if model_trans_fields is None: model_trans_fields = set() model_trans_fields.update(set(getattr(model._meta, 'translatable_...
def get_all_translatable_fields(model, model_trans_fields=None, column_in_current_table=False): """ returns all translatable fields in a model (including superclasses ones) """ if model_trans_fields is None: model_trans_fields = set() model_trans_fields.update(set(getattr(model._meta, 'translatable_...
[ "returns", "all", "translatable", "fields", "in", "a", "model", "(", "including", "superclasses", "ones", ")" ]
Yaco-Sistemas/django-transmeta
python
https://github.com/Yaco-Sistemas/django-transmeta/blob/de070aae27770df046b4ba995f01f654db7ed1a2/transmeta/__init__.py#L59-L67
[ "def", "get_all_translatable_fields", "(", "model", ",", "model_trans_fields", "=", "None", ",", "column_in_current_table", "=", "False", ")", ":", "if", "model_trans_fields", "is", "None", ":", "model_trans_fields", "=", "set", "(", ")", "model_trans_fields", ".", ...
de070aae27770df046b4ba995f01f654db7ed1a2
test
default_value
When accessing to the name of the field itself, the value in the current language will be returned. Unless it's set, the value in the default language will be returned.
transmeta/__init__.py
def default_value(field): ''' When accessing to the name of the field itself, the value in the current language will be returned. Unless it's set, the value in the default language will be returned. ''' def default_value_func(self): attname = lambda x: get_real_fieldname(field, x) ...
def default_value(field): ''' When accessing to the name of the field itself, the value in the current language will be returned. Unless it's set, the value in the default language will be returned. ''' def default_value_func(self): attname = lambda x: get_real_fieldname(field, x) ...
[ "When", "accessing", "to", "the", "name", "of", "the", "field", "itself", "the", "value", "in", "the", "current", "language", "will", "be", "returned", ".", "Unless", "it", "s", "set", "the", "value", "in", "the", "default", "language", "will", "be", "re...
Yaco-Sistemas/django-transmeta
python
https://github.com/Yaco-Sistemas/django-transmeta/blob/de070aae27770df046b4ba995f01f654db7ed1a2/transmeta/__init__.py#L70-L92
[ "def", "default_value", "(", "field", ")", ":", "def", "default_value_func", "(", "self", ")", ":", "attname", "=", "lambda", "x", ":", "get_real_fieldname", "(", "field", ",", "x", ")", "if", "getattr", "(", "self", ",", "attname", "(", "get_language", ...
de070aae27770df046b4ba995f01f654db7ed1a2
test
process
Post processors are functions that receive file objects, performs necessary operations and return the results as file objects.
thumbnails/post_processors.py
def process(thumbnail_file, size, **kwargs): """ Post processors are functions that receive file objects, performs necessary operations and return the results as file objects. """ from . import conf size_dict = conf.SIZES[size] for processor in size_dict['POST_PROCESSORS']: processo...
def process(thumbnail_file, size, **kwargs): """ Post processors are functions that receive file objects, performs necessary operations and return the results as file objects. """ from . import conf size_dict = conf.SIZES[size] for processor in size_dict['POST_PROCESSORS']: processo...
[ "Post", "processors", "are", "functions", "that", "receive", "file", "objects", "performs", "necessary", "operations", "and", "return", "the", "results", "as", "file", "objects", "." ]
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/post_processors.py#L17-L28
[ "def", "process", "(", "thumbnail_file", ",", "size", ",", "*", "*", "kwargs", ")", ":", "from", ".", "import", "conf", "size_dict", "=", "conf", ".", "SIZES", "[", "size", "]", "for", "processor", "in", "size_dict", "[", "'POST_PROCESSORS'", "]", ":", ...
5cef55e7f167060458709ed760dd43981124796a
test
optimize
A post processing function to optimize file size. Accepts commands to optimize JPG, PNG and GIF images as arguments. Example: THUMBNAILS = { # Other options... 'POST_PROCESSORS': [ { 'processor': 'thumbnails.post_processors.optimize', 'png_command': '...
thumbnails/post_processors.py
def optimize(thumbnail_file, jpg_command=None, png_command=None, gif_command=None): """ A post processing function to optimize file size. Accepts commands to optimize JPG, PNG and GIF images as arguments. Example: THUMBNAILS = { # Other options... 'POST_PROCESSORS': [ ...
def optimize(thumbnail_file, jpg_command=None, png_command=None, gif_command=None): """ A post processing function to optimize file size. Accepts commands to optimize JPG, PNG and GIF images as arguments. Example: THUMBNAILS = { # Other options... 'POST_PROCESSORS': [ ...
[ "A", "post", "processing", "function", "to", "optimize", "file", "size", ".", "Accepts", "commands", "to", "optimize", "JPG", "PNG", "and", "GIF", "images", "as", "arguments", ".", "Example", ":" ]
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/post_processors.py#L31-L79
[ "def", "optimize", "(", "thumbnail_file", ",", "jpg_command", "=", "None", ",", "png_command", "=", "None", ",", "gif_command", "=", "None", ")", ":", "temp_dir", "=", "get_or_create_temp_dir", "(", ")", "thumbnail_filename", "=", "os", ".", "path", ".", "jo...
5cef55e7f167060458709ed760dd43981124796a
test
import_attribute
Return an attribute from a dotted path name (e.g. "path.to.func"). Copied from nvie's rq https://github.com/nvie/rq/blob/master/rq/utils.py
thumbnails/utils.py
def import_attribute(name): """ Return an attribute from a dotted path name (e.g. "path.to.func"). Copied from nvie's rq https://github.com/nvie/rq/blob/master/rq/utils.py """ if hasattr(name, '__call__'): return name module_name, attribute = name.rsplit('.', 1) module = importlib.im...
def import_attribute(name): """ Return an attribute from a dotted path name (e.g. "path.to.func"). Copied from nvie's rq https://github.com/nvie/rq/blob/master/rq/utils.py """ if hasattr(name, '__call__'): return name module_name, attribute = name.rsplit('.', 1) module = importlib.im...
[ "Return", "an", "attribute", "from", "a", "dotted", "path", "name", "(", "e", ".", "g", ".", "path", ".", "to", ".", "func", ")", ".", "Copied", "from", "nvie", "s", "rq", "https", ":", "//", "github", ".", "com", "/", "nvie", "/", "rq", "/", "...
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/utils.py#L9-L18
[ "def", "import_attribute", "(", "name", ")", ":", "if", "hasattr", "(", "name", ",", "'__call__'", ")", ":", "return", "name", "module_name", ",", "attribute", "=", "name", ".", "rsplit", "(", "'.'", ",", "1", ")", "module", "=", "importlib", ".", "imp...
5cef55e7f167060458709ed760dd43981124796a
test
parse_processors
Returns a dictionary that contains the imported processors and kwargs. For example, passing in: processors = [ {'processor': 'thumbnails.processors.resize', 'width': 10, 'height': 10}, {'processor': 'thumbnails.processors.crop', 'width': 10, 'height': 10}, ] Would return: [ ...
thumbnails/utils.py
def parse_processors(processor_definition): """ Returns a dictionary that contains the imported processors and kwargs. For example, passing in: processors = [ {'processor': 'thumbnails.processors.resize', 'width': 10, 'height': 10}, {'processor': 'thumbnails.processors.crop', 'width': 1...
def parse_processors(processor_definition): """ Returns a dictionary that contains the imported processors and kwargs. For example, passing in: processors = [ {'processor': 'thumbnails.processors.resize', 'width': 10, 'height': 10}, {'processor': 'thumbnails.processors.crop', 'width': 1...
[ "Returns", "a", "dictionary", "that", "contains", "the", "imported", "processors", "and", "kwargs", ".", "For", "example", "passing", "in", ":" ]
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/utils.py#L21-L48
[ "def", "parse_processors", "(", "processor_definition", ")", ":", "parsed_processors", "=", "[", "]", "for", "processor", "in", "processor_definition", ":", "processor_function", "=", "import_attribute", "(", "processor", "[", "'PATH'", "]", ")", "kwargs", "=", "d...
5cef55e7f167060458709ed760dd43981124796a
test
process
Process an image through its defined processors params :file: filename or file-like object params :size: string for size defined in settings return a ContentFile
thumbnails/processors.py
def process(file, size): """ Process an image through its defined processors params :file: filename or file-like object params :size: string for size defined in settings return a ContentFile """ from . import conf # open image in piccaso raw_image = images.from_file(file) # run ...
def process(file, size): """ Process an image through its defined processors params :file: filename or file-like object params :size: string for size defined in settings return a ContentFile """ from . import conf # open image in piccaso raw_image = images.from_file(file) # run ...
[ "Process", "an", "image", "through", "its", "defined", "processors", "params", ":", "file", ":", "filename", "or", "file", "-", "like", "object", "params", ":", "size", ":", "string", "for", "size", "defined", "in", "settings", "return", "a", "ContentFile" ]
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/processors.py#L48-L70
[ "def", "process", "(", "file", ",", "size", ")", ":", "from", ".", "import", "conf", "# open image in piccaso", "raw_image", "=", "images", ".", "from_file", "(", "file", ")", "# run through all processors, if defined", "size_dict", "=", "conf", ".", "SIZES", "[...
5cef55e7f167060458709ed760dd43981124796a
test
ImageField.pre_save
Process the source image through the defined processors.
thumbnails/fields.py
def pre_save(self, model_instance, add): """ Process the source image through the defined processors. """ file = getattr(model_instance, self.attname) if file and not file._committed: image_file = file if self.resize_source_to: file.seek(0...
def pre_save(self, model_instance, add): """ Process the source image through the defined processors. """ file = getattr(model_instance, self.attname) if file and not file._committed: image_file = file if self.resize_source_to: file.seek(0...
[ "Process", "the", "source", "image", "through", "the", "defined", "processors", "." ]
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/fields.py#L30-L44
[ "def", "pre_save", "(", "self", ",", "model_instance", ",", "add", ")", ":", "file", "=", "getattr", "(", "model_instance", ",", "self", ".", "attname", ")", "if", "file", "and", "not", "file", ".", "_committed", ":", "image_file", "=", "file", "if", "...
5cef55e7f167060458709ed760dd43981124796a
test
ThumbnailManager._refresh_cache
Populate self._thumbnails.
thumbnails/files.py
def _refresh_cache(self): """Populate self._thumbnails.""" self._thumbnails = {} metadatas = self.metadata_backend.get_thumbnails(self.source_image.name) for metadata in metadatas: self._thumbnails[metadata.size] = Thumbnail(metadata=metadata, storage=self.storage)
def _refresh_cache(self): """Populate self._thumbnails.""" self._thumbnails = {} metadatas = self.metadata_backend.get_thumbnails(self.source_image.name) for metadata in metadatas: self._thumbnails[metadata.size] = Thumbnail(metadata=metadata, storage=self.storage)
[ "Populate", "self", ".", "_thumbnails", "." ]
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/files.py#L53-L58
[ "def", "_refresh_cache", "(", "self", ")", ":", "self", ".", "_thumbnails", "=", "{", "}", "metadatas", "=", "self", ".", "metadata_backend", ".", "get_thumbnails", "(", "self", ".", "source_image", ".", "name", ")", "for", "metadata", "in", "metadatas", "...
5cef55e7f167060458709ed760dd43981124796a
test
ThumbnailManager.all
Return all thumbnails in a dict format.
thumbnails/files.py
def all(self): """ Return all thumbnails in a dict format. """ if self._thumbnails is not None: return self._thumbnails self._refresh_cache() return self._thumbnails
def all(self): """ Return all thumbnails in a dict format. """ if self._thumbnails is not None: return self._thumbnails self._refresh_cache() return self._thumbnails
[ "Return", "all", "thumbnails", "in", "a", "dict", "format", "." ]
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/files.py#L60-L67
[ "def", "all", "(", "self", ")", ":", "if", "self", ".", "_thumbnails", "is", "not", "None", ":", "return", "self", ".", "_thumbnails", "self", ".", "_refresh_cache", "(", ")", "return", "self", ".", "_thumbnails" ]
5cef55e7f167060458709ed760dd43981124796a
test
ThumbnailManager.get
Returns a Thumbnail instance. First check whether thumbnail is already cached. If it doesn't: 1. Try to fetch the thumbnail 2. Create thumbnail if it's not present 3. Cache the thumbnail for future use
thumbnails/files.py
def get(self, size, create=True): """ Returns a Thumbnail instance. First check whether thumbnail is already cached. If it doesn't: 1. Try to fetch the thumbnail 2. Create thumbnail if it's not present 3. Cache the thumbnail for future use """ if self._thu...
def get(self, size, create=True): """ Returns a Thumbnail instance. First check whether thumbnail is already cached. If it doesn't: 1. Try to fetch the thumbnail 2. Create thumbnail if it's not present 3. Cache the thumbnail for future use """ if self._thu...
[ "Returns", "a", "Thumbnail", "instance", ".", "First", "check", "whether", "thumbnail", "is", "already", "cached", ".", "If", "it", "doesn", "t", ":", "1", ".", "Try", "to", "fetch", "the", "thumbnail", "2", ".", "Create", "thumbnail", "if", "it", "s", ...
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/files.py#L69-L91
[ "def", "get", "(", "self", ",", "size", ",", "create", "=", "True", ")", ":", "if", "self", ".", "_thumbnails", "is", "None", ":", "self", ".", "_refresh_cache", "(", ")", "thumbnail", "=", "self", ".", "_thumbnails", ".", "get", "(", "size", ")", ...
5cef55e7f167060458709ed760dd43981124796a
test
ThumbnailManager.create
Creates and return a thumbnail of a given size.
thumbnails/files.py
def create(self, size): """ Creates and return a thumbnail of a given size. """ thumbnail = images.create(self.source_image.name, size, self.metadata_backend, self.storage) return thumbnail
def create(self, size): """ Creates and return a thumbnail of a given size. """ thumbnail = images.create(self.source_image.name, size, self.metadata_backend, self.storage) return thumbnail
[ "Creates", "and", "return", "a", "thumbnail", "of", "a", "given", "size", "." ]
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/files.py#L93-L99
[ "def", "create", "(", "self", ",", "size", ")", ":", "thumbnail", "=", "images", ".", "create", "(", "self", ".", "source_image", ".", "name", ",", "size", ",", "self", ".", "metadata_backend", ",", "self", ".", "storage", ")", "return", "thumbnail" ]
5cef55e7f167060458709ed760dd43981124796a
test
ThumbnailManager.delete
Deletes a thumbnail of a given size
thumbnails/files.py
def delete(self, size): """ Deletes a thumbnail of a given size """ images.delete(self.source_image.name, size, self.metadata_backend, self.storage) del(self._thumbnails[size])
def delete(self, size): """ Deletes a thumbnail of a given size """ images.delete(self.source_image.name, size, self.metadata_backend, self.storage) del(self._thumbnails[size])
[ "Deletes", "a", "thumbnail", "of", "a", "given", "size" ]
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/files.py#L101-L107
[ "def", "delete", "(", "self", ",", "size", ")", ":", "images", ".", "delete", "(", "self", ".", "source_image", ".", "name", ",", "size", ",", "self", ".", "metadata_backend", ",", "self", ".", "storage", ")", "del", "(", "self", ".", "_thumbnails", ...
5cef55e7f167060458709ed760dd43981124796a
test
create
Creates a thumbnail file and its relevant metadata. Returns a Thumbnail instance.
thumbnails/images.py
def create(source_name, size, metadata_backend=None, storage_backend=None): """ Creates a thumbnail file and its relevant metadata. Returns a Thumbnail instance. """ if storage_backend is None: storage_backend = backends.storage.get_backend() if metadata_backend is None: metadat...
def create(source_name, size, metadata_backend=None, storage_backend=None): """ Creates a thumbnail file and its relevant metadata. Returns a Thumbnail instance. """ if storage_backend is None: storage_backend = backends.storage.get_backend() if metadata_backend is None: metadat...
[ "Creates", "a", "thumbnail", "file", "and", "its", "relevant", "metadata", ".", "Returns", "a", "Thumbnail", "instance", "." ]
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/images.py#L68-L85
[ "def", "create", "(", "source_name", ",", "size", ",", "metadata_backend", "=", "None", ",", "storage_backend", "=", "None", ")", ":", "if", "storage_backend", "is", "None", ":", "storage_backend", "=", "backends", ".", "storage", ".", "get_backend", "(", ")...
5cef55e7f167060458709ed760dd43981124796a
test
get
Returns a Thumbnail instance, or None if thumbnail does not yet exist.
thumbnails/images.py
def get(source_name, size, metadata_backend=None, storage_backend=None): """ Returns a Thumbnail instance, or None if thumbnail does not yet exist. """ if storage_backend is None: storage_backend = backends.storage.get_backend() if metadata_backend is None: metadata_backend = backend...
def get(source_name, size, metadata_backend=None, storage_backend=None): """ Returns a Thumbnail instance, or None if thumbnail does not yet exist. """ if storage_backend is None: storage_backend = backends.storage.get_backend() if metadata_backend is None: metadata_backend = backend...
[ "Returns", "a", "Thumbnail", "instance", "or", "None", "if", "thumbnail", "does", "not", "yet", "exist", "." ]
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/images.py#L88-L101
[ "def", "get", "(", "source_name", ",", "size", ",", "metadata_backend", "=", "None", ",", "storage_backend", "=", "None", ")", ":", "if", "storage_backend", "is", "None", ":", "storage_backend", "=", "backends", ".", "storage", ".", "get_backend", "(", ")", ...
5cef55e7f167060458709ed760dd43981124796a
test
delete
Deletes a thumbnail file and its relevant metadata.
thumbnails/images.py
def delete(source_name, size, metadata_backend=None, storage_backend=None): """ Deletes a thumbnail file and its relevant metadata. """ if storage_backend is None: storage_backend = backends.storage.get_backend() if metadata_backend is None: metadata_backend = backends.metadata.get_b...
def delete(source_name, size, metadata_backend=None, storage_backend=None): """ Deletes a thumbnail file and its relevant metadata. """ if storage_backend is None: storage_backend = backends.storage.get_backend() if metadata_backend is None: metadata_backend = backends.metadata.get_b...
[ "Deletes", "a", "thumbnail", "file", "and", "its", "relevant", "metadata", "." ]
ui/django-thumbnails
python
https://github.com/ui/django-thumbnails/blob/5cef55e7f167060458709ed760dd43981124796a/thumbnails/images.py#L104-L113
[ "def", "delete", "(", "source_name", ",", "size", ",", "metadata_backend", "=", "None", ",", "storage_backend", "=", "None", ")", ":", "if", "storage_backend", "is", "None", ":", "storage_backend", "=", "backends", ".", "storage", ".", "get_backend", "(", ")...
5cef55e7f167060458709ed760dd43981124796a
test
LoopbackProvider.received
Simulate an incoming message :type src: str :param src: Message source :type boby: str | unicode :param body: Message body :rtype: IncomingMessage
smsframework/providers/loopback.py
def received(self, src, body): """ Simulate an incoming message :type src: str :param src: Message source :type boby: str | unicode :param body: Message body :rtype: IncomingMessage """ # Create the message self._msgid += 1 ...
def received(self, src, body): """ Simulate an incoming message :type src: str :param src: Message source :type boby: str | unicode :param body: Message body :rtype: IncomingMessage """ # Create the message self._msgid += 1 ...
[ "Simulate", "an", "incoming", "message" ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/providers/loopback.py#L46-L66
[ "def", "received", "(", "self", ",", "src", ",", "body", ")", ":", "# Create the message", "self", ".", "_msgid", "+=", "1", "message", "=", "IncomingMessage", "(", "src", ",", "body", ",", "self", ".", "_msgid", ")", "# Log traffic", "self", ".", "_traf...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
LoopbackProvider.subscribe
Register a virtual subscriber which receives messages to the matching number. :type number: str :param number: Subscriber phone number :type callback: callable :param callback: A callback(OutgoingMessage) which handles the messages directed to the subscriber. ...
smsframework/providers/loopback.py
def subscribe(self, number, callback): """ Register a virtual subscriber which receives messages to the matching number. :type number: str :param number: Subscriber phone number :type callback: callable :param callback: A callback(OutgoingMessage) which handles t...
def subscribe(self, number, callback): """ Register a virtual subscriber which receives messages to the matching number. :type number: str :param number: Subscriber phone number :type callback: callable :param callback: A callback(OutgoingMessage) which handles t...
[ "Register", "a", "virtual", "subscriber", "which", "receives", "messages", "to", "the", "matching", "number", "." ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/providers/loopback.py#L68-L79
[ "def", "subscribe", "(", "self", ",", "number", ",", "callback", ")", ":", "self", ".", "_subscribers", "[", "digits_only", "(", "number", ")", "]", "=", "callback", "return", "self" ]
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
MessageStatus.states
Get the set of states. Mostly used for pretty printing :rtype: set :returns: Set of 'accepted', 'delivered', 'expired', 'error'
smsframework/data/MessageStatus.py
def states(self): """ Get the set of states. Mostly used for pretty printing :rtype: set :returns: Set of 'accepted', 'delivered', 'expired', 'error' """ ret = set() if self.accepted: ret.add('accepted') if self.delivered: ret.add(...
def states(self): """ Get the set of states. Mostly used for pretty printing :rtype: set :returns: Set of 'accepted', 'delivered', 'expired', 'error' """ ret = set() if self.accepted: ret.add('accepted') if self.delivered: ret.add(...
[ "Get", "the", "set", "of", "states", ".", "Mostly", "used", "for", "pretty", "printing" ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/data/MessageStatus.py#L54-L69
[ "def", "states", "(", "self", ")", ":", "ret", "=", "set", "(", ")", "if", "self", ".", "accepted", ":", "ret", ".", "add", "(", "'accepted'", ")", "if", "self", ".", "delivered", ":", "ret", ".", "add", "(", "'delivered'", ")", "if", "self", "."...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
Gateway.add_provider
Register a provider on the gateway The first provider defined becomes the default one: used in case the routing function has no better idea. :type name: str :param name: Provider name that will be used to uniquely identify it :type Provider: type :param Prov...
smsframework/Gateway.py
def add_provider(self, name, Provider, **config): """ Register a provider on the gateway The first provider defined becomes the default one: used in case the routing function has no better idea. :type name: str :param name: Provider name that will be used to uniquely identi...
def add_provider(self, name, Provider, **config): """ Register a provider on the gateway The first provider defined becomes the default one: used in case the routing function has no better idea. :type name: str :param name: Provider name that will be used to uniquely identi...
[ "Register", "a", "provider", "on", "the", "gateway" ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/Gateway.py#L61-L89
[ "def", "add_provider", "(", "self", ",", "name", ",", "Provider", ",", "*", "*", "config", ")", ":", "assert", "issubclass", "(", "Provider", ",", "IProvider", ")", ",", "'Provider does not implement IProvider'", "assert", "isinstance", "(", "name", ",", "str"...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
Gateway.send
Send a message object :type message: data.OutgoingMessage :param message: The message to send :rtype: data.OutgoingMessage :returns: The sent message with populated fields :raises AssertionError: wrong provider name encountered (returned by the router, or pro...
smsframework/Gateway.py
def send(self, message): """ Send a message object :type message: data.OutgoingMessage :param message: The message to send :rtype: data.OutgoingMessage :returns: The sent message with populated fields :raises AssertionError: wrong provider name encoun...
def send(self, message): """ Send a message object :type message: data.OutgoingMessage :param message: The message to send :rtype: data.OutgoingMessage :returns: The sent message with populated fields :raises AssertionError: wrong provider name encoun...
[ "Send", "a", "message", "object" ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/Gateway.py#L139-L177
[ "def", "send", "(", "self", ",", "message", ")", ":", "# Which provider to use?", "provider_name", "=", "self", ".", "_default_provider", "# default", "if", "message", ".", "provider", "is", "not", "None", ":", "assert", "message", ".", "provider", "in", "self...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
Gateway.receiver_blueprint_for
Get a Flask blueprint for the named provider that handles incoming messages & status reports Note: this requires Flask microframework. :rtype: flask.blueprints.Blueprint :returns: Flask Blueprint, fully functional :raises KeyError: provider not found :raises...
smsframework/Gateway.py
def receiver_blueprint_for(self, name): """ Get a Flask blueprint for the named provider that handles incoming messages & status reports Note: this requires Flask microframework. :rtype: flask.blueprints.Blueprint :returns: Flask Blueprint, fully functional :rai...
def receiver_blueprint_for(self, name): """ Get a Flask blueprint for the named provider that handles incoming messages & status reports Note: this requires Flask microframework. :rtype: flask.blueprints.Blueprint :returns: Flask Blueprint, fully functional :rai...
[ "Get", "a", "Flask", "blueprint", "for", "the", "named", "provider", "that", "handles", "incoming", "messages", "&", "status", "reports" ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/Gateway.py#L184-L207
[ "def", "receiver_blueprint_for", "(", "self", ",", "name", ")", ":", "# Get the provider & blueprint", "provider", "=", "self", ".", "get_provider", "(", "name", ")", "bp", "=", "provider", ".", "make_receiver_blueprint", "(", ")", "# Register a Flask handler that ini...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
Gateway.receiver_blueprints
Get Flask blueprints for every provider that supports it Note: this requires Flask microframework. :rtype: dict :returns: A dict { provider-name: Blueprint }
smsframework/Gateway.py
def receiver_blueprints(self): """ Get Flask blueprints for every provider that supports it Note: this requires Flask microframework. :rtype: dict :returns: A dict { provider-name: Blueprint } """ blueprints = {} for name in self._providers: ...
def receiver_blueprints(self): """ Get Flask blueprints for every provider that supports it Note: this requires Flask microframework. :rtype: dict :returns: A dict { provider-name: Blueprint } """ blueprints = {} for name in self._providers: ...
[ "Get", "Flask", "blueprints", "for", "every", "provider", "that", "supports", "it" ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/Gateway.py#L209-L223
[ "def", "receiver_blueprints", "(", "self", ")", ":", "blueprints", "=", "{", "}", "for", "name", "in", "self", ".", "_providers", ":", "try", ":", "blueprints", "[", "name", "]", "=", "self", ".", "receiver_blueprint_for", "(", "name", ")", "except", "No...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
Gateway.receiver_blueprints_register
Register all provider receivers on the provided Flask application under '/{prefix}/provider-name' Note: this requires Flask microframework. :type app: flask.Flask :param app: Flask app to register the blueprints on :type prefix: str :param prefix: URL prefix...
smsframework/Gateway.py
def receiver_blueprints_register(self, app, prefix='/'): """ Register all provider receivers on the provided Flask application under '/{prefix}/provider-name' Note: this requires Flask microframework. :type app: flask.Flask :param app: Flask app to register the blueprints o...
def receiver_blueprints_register(self, app, prefix='/'): """ Register all provider receivers on the provided Flask application under '/{prefix}/provider-name' Note: this requires Flask microframework. :type app: flask.Flask :param app: Flask app to register the blueprints o...
[ "Register", "all", "provider", "receivers", "on", "the", "provided", "Flask", "application", "under", "/", "{", "prefix", "}", "/", "provider", "-", "name" ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/Gateway.py#L225-L248
[ "def", "receiver_blueprints_register", "(", "self", ",", "app", ",", "prefix", "=", "'/'", ")", ":", "# Register", "for", "name", ",", "bp", "in", "self", ".", "receiver_blueprints", "(", ")", ".", "items", "(", ")", ":", "app", ".", "register_blueprint", ...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
IProvider._receive_message
Incoming message callback Calls Gateway.onReceive event hook Providers are required to: * Cast phone numbers to digits-only * Support both ASCII and Unicode messages * Populate `message.msgid` and `message.meta` fields * If this method fails with...
smsframework/IProvider.py
def _receive_message(self, message): """ Incoming message callback Calls Gateway.onReceive event hook Providers are required to: * Cast phone numbers to digits-only * Support both ASCII and Unicode messages * Populate `message.msgid` and `message.met...
def _receive_message(self, message): """ Incoming message callback Calls Gateway.onReceive event hook Providers are required to: * Cast phone numbers to digits-only * Support both ASCII and Unicode messages * Populate `message.msgid` and `message.met...
[ "Incoming", "message", "callback" ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/IProvider.py#L52-L74
[ "def", "_receive_message", "(", "self", ",", "message", ")", ":", "# Populate fields", "message", ".", "provider", "=", "self", ".", "name", "# Fire the event hook", "self", ".", "gateway", ".", "onReceive", "(", "message", ")", "# Finish", "return", "message" ]
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
IProvider._receive_status
Incoming status callback Calls Gateway.onStatus event hook Providers are required to: * Cast phone numbers to digits-only * Use proper MessageStatus subclasses * Populate `status.msgid` and `status.meta` fields * If this method fails with an exce...
smsframework/IProvider.py
def _receive_status(self, status): """ Incoming status callback Calls Gateway.onStatus event hook Providers are required to: * Cast phone numbers to digits-only * Use proper MessageStatus subclasses * Populate `status.msgid` and `status.meta` fields ...
def _receive_status(self, status): """ Incoming status callback Calls Gateway.onStatus event hook Providers are required to: * Cast phone numbers to digits-only * Use proper MessageStatus subclasses * Populate `status.msgid` and `status.meta` fields ...
[ "Incoming", "status", "callback" ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/IProvider.py#L76-L98
[ "def", "_receive_status", "(", "self", ",", "status", ")", ":", "# Populate fields", "status", ".", "provider", "=", "self", ".", "name", "# Fire the event hook", "self", ".", "gateway", ".", "onStatus", "(", "status", ")", "# Finish", "return", "status" ]
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
im
Incoming message handler: forwarded by ForwardServerProvider
smsframework/providers/forward/receiver_client.py
def im(): """ Incoming message handler: forwarded by ForwardServerProvider """ req = jsonex_loads(request.get_data()) message = g.provider._receive_message(req['message']) return {'message': message}
def im(): """ Incoming message handler: forwarded by ForwardServerProvider """ req = jsonex_loads(request.get_data()) message = g.provider._receive_message(req['message']) return {'message': message}
[ "Incoming", "message", "handler", ":", "forwarded", "by", "ForwardServerProvider" ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/providers/forward/receiver_client.py#L11-L15
[ "def", "im", "(", ")", ":", "req", "=", "jsonex_loads", "(", "request", ".", "get_data", "(", ")", ")", "message", "=", "g", ".", "provider", ".", "_receive_message", "(", "req", "[", "'message'", "]", ")", "return", "{", "'message'", ":", "message", ...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
status
Incoming status handler: forwarded by ForwardServerProvider
smsframework/providers/forward/receiver_client.py
def status(): """ Incoming status handler: forwarded by ForwardServerProvider """ req = jsonex_loads(request.get_data()) status = g.provider._receive_status(req['status']) return {'status': status}
def status(): """ Incoming status handler: forwarded by ForwardServerProvider """ req = jsonex_loads(request.get_data()) status = g.provider._receive_status(req['status']) return {'status': status}
[ "Incoming", "status", "handler", ":", "forwarded", "by", "ForwardServerProvider" ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/providers/forward/receiver_client.py#L20-L24
[ "def", "status", "(", ")", ":", "req", "=", "jsonex_loads", "(", "request", ".", "get_data", "(", ")", ")", "status", "=", "g", ".", "provider", ".", "_receive_status", "(", "req", "[", "'status'", "]", ")", "return", "{", "'status'", ":", "status", ...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
jsonex_loads
Unserialize with JsonEx :rtype: dict
smsframework/providers/forward/provider.py
def jsonex_loads(s): """ Unserialize with JsonEx :rtype: dict """ return json.loads(s.decode('utf-8'), cls=JsonExDecoder, classes=classes, exceptions=exceptions)
def jsonex_loads(s): """ Unserialize with JsonEx :rtype: dict """ return json.loads(s.decode('utf-8'), cls=JsonExDecoder, classes=classes, exceptions=exceptions)
[ "Unserialize", "with", "JsonEx", ":", "rtype", ":", "dict" ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/providers/forward/provider.py#L51-L55
[ "def", "jsonex_loads", "(", "s", ")", ":", "return", "json", ".", "loads", "(", "s", ".", "decode", "(", "'utf-8'", ")", ",", "cls", "=", "JsonExDecoder", ",", "classes", "=", "classes", ",", "exceptions", "=", "exceptions", ")" ]
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
jsonex_api
View wrapper for JsonEx responses. Catches exceptions as well
smsframework/providers/forward/provider.py
def jsonex_api(f): """ View wrapper for JsonEx responses. Catches exceptions as well """ @wraps(f) def wrapper(*args, **kwargs): # Call, catch exceptions try: code, res = 200, f(*args, **kwargs) except HTTPException as e: code, res = e.code, {'error': e} ...
def jsonex_api(f): """ View wrapper for JsonEx responses. Catches exceptions as well """ @wraps(f) def wrapper(*args, **kwargs): # Call, catch exceptions try: code, res = 200, f(*args, **kwargs) except HTTPException as e: code, res = e.code, {'error': e} ...
[ "View", "wrapper", "for", "JsonEx", "responses", ".", "Catches", "exceptions", "as", "well" ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/providers/forward/provider.py#L58-L75
[ "def", "jsonex_api", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Call, catch exceptions", "try", ":", "code", ",", "res", "=", "200", ",", "f", "(", "*", "args", ",", ...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
_parse_authentication
Parse authentication data from the URL and put it in the `headers` dict. With caching behavior :param url: URL :type url: str :return: (URL without authentication info, headers dict) :rtype: str, dict
smsframework/providers/forward/provider.py
def _parse_authentication(url): """ Parse authentication data from the URL and put it in the `headers` dict. With caching behavior :param url: URL :type url: str :return: (URL without authentication info, headers dict) :rtype: str, dict """ u = url h = {} # New headers # Cache? ...
def _parse_authentication(url): """ Parse authentication data from the URL and put it in the `headers` dict. With caching behavior :param url: URL :type url: str :return: (URL without authentication info, headers dict) :rtype: str, dict """ u = url h = {} # New headers # Cache? ...
[ "Parse", "authentication", "data", "from", "the", "URL", "and", "put", "it", "in", "the", "headers", "dict", ".", "With", "caching", "behavior", ":", "param", "url", ":", "URL", ":", "type", "url", ":", "str", ":", "return", ":", "(", "URL", "without",...
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/providers/forward/provider.py#L78-L103
[ "def", "_parse_authentication", "(", "url", ")", ":", "u", "=", "url", "h", "=", "{", "}", "# New headers", "# Cache?", "if", "url", "in", "_parse_authentication", ".", "_memoize", ":", "u", ",", "h", "=", "_parse_authentication", ".", "_memoize", "[", "ur...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
jsonex_request
Make a request with JsonEx :param url: URL :type url: str :param data: Data to POST :type data: dict :return: Response :rtype: dict :raises exc.ConnectionError: Connection error :raises exc.ServerError: Remote server error (unknown) :raises exc.ProviderError: any errors reported by t...
smsframework/providers/forward/provider.py
def jsonex_request(url, data, headers=None): """ Make a request with JsonEx :param url: URL :type url: str :param data: Data to POST :type data: dict :return: Response :rtype: dict :raises exc.ConnectionError: Connection error :raises exc.ServerError: Remote server error (unknown) ...
def jsonex_request(url, data, headers=None): """ Make a request with JsonEx :param url: URL :type url: str :param data: Data to POST :type data: dict :return: Response :rtype: dict :raises exc.ConnectionError: Connection error :raises exc.ServerError: Remote server error (unknown) ...
[ "Make", "a", "request", "with", "JsonEx", ":", "param", "url", ":", "URL", ":", "type", "url", ":", "str", ":", "param", "data", ":", "Data", "to", "POST", ":", "type", "data", ":", "dict", ":", "return", ":", "Response", ":", "rtype", ":", "dict",...
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/providers/forward/provider.py#L107-L141
[ "def", "jsonex_request", "(", "url", ",", "data", ",", "headers", "=", "None", ")", ":", "# Authentication?", "url", ",", "headers", "=", "_parse_authentication", "(", "url", ")", "headers", "[", "'Content-Type'", "]", "=", "'application/json'", "# Request", "...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
ForwardClientProvider.send
Send a message by forwarding it to the server :param message: Message :type message: smsframework.data.OutgoingMessage :rtype: smsframework.data.OutgoingMessage :raise Exception: any exception reported by the other side :raise urllib2.URLError: Connection error
smsframework/providers/forward/provider.py
def send(self, message): """ Send a message by forwarding it to the server :param message: Message :type message: smsframework.data.OutgoingMessage :rtype: smsframework.data.OutgoingMessage :raise Exception: any exception reported by the other side :raise urllib2.URLError...
def send(self, message): """ Send a message by forwarding it to the server :param message: Message :type message: smsframework.data.OutgoingMessage :rtype: smsframework.data.OutgoingMessage :raise Exception: any exception reported by the other side :raise urllib2.URLError...
[ "Send", "a", "message", "by", "forwarding", "it", "to", "the", "server", ":", "param", "message", ":", "Message", ":", "type", "message", ":", "smsframework", ".", "data", ".", "OutgoingMessage", ":", "rtype", ":", "smsframework", ".", "data", ".", "Outgoi...
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/providers/forward/provider.py#L162-L176
[ "def", "send", "(", "self", ",", "message", ")", ":", "res", "=", "jsonex_request", "(", "self", ".", "server_url", "+", "'/im'", ".", "lstrip", "(", "'/'", ")", ",", "{", "'message'", ":", "message", "}", ")", "msg", "=", "res", "[", "'message'", ...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
ForwardServerProvider._forward_object_to_client
Forward an object to client :type client: str :type obj: smsframework.data.IncomingMessage|smsframework.data.MessageStatus :rtype: smsframework.data.IncomingMessage|smsframework.data.MessageStatus :raise Exception: any exception reported by the other side
smsframework/providers/forward/provider.py
def _forward_object_to_client(self, client, obj): """ Forward an object to client :type client: str :type obj: smsframework.data.IncomingMessage|smsframework.data.MessageStatus :rtype: smsframework.data.IncomingMessage|smsframework.data.MessageStatus :raise Exception: any excepti...
def _forward_object_to_client(self, client, obj): """ Forward an object to client :type client: str :type obj: smsframework.data.IncomingMessage|smsframework.data.MessageStatus :rtype: smsframework.data.IncomingMessage|smsframework.data.MessageStatus :raise Exception: any excepti...
[ "Forward", "an", "object", "to", "client", ":", "type", "client", ":", "str", ":", "type", "obj", ":", "smsframework", ".", "data", ".", "IncomingMessage|smsframework", ".", "data", ".", "MessageStatus", ":", "rtype", ":", "smsframework", ".", "data", ".", ...
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/providers/forward/provider.py#L228-L237
[ "def", "_forward_object_to_client", "(", "self", ",", "client", ",", "obj", ")", ":", "url", ",", "name", "=", "(", "'/im'", ",", "'message'", ")", "if", "isinstance", "(", "obj", ",", "IncomingMessage", ")", "else", "(", "'/status'", ",", "'status'", ")...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
ForwardServerProvider.forward
Forward an object to clients. :param obj: The object to be forwarded :type obj: smsframework.data.IncomingMessage|smsframework.data.MessageStatus :raises Exception: if any of the clients failed
smsframework/providers/forward/provider.py
def forward(self, obj): """ Forward an object to clients. :param obj: The object to be forwarded :type obj: smsframework.data.IncomingMessage|smsframework.data.MessageStatus :raises Exception: if any of the clients failed """ assert isinstance(obj, (IncomingMessage, Mess...
def forward(self, obj): """ Forward an object to clients. :param obj: The object to be forwarded :type obj: smsframework.data.IncomingMessage|smsframework.data.MessageStatus :raises Exception: if any of the clients failed """ assert isinstance(obj, (IncomingMessage, Mess...
[ "Forward", "an", "object", "to", "clients", "." ]
kolypto/py-smsframework
python
https://github.com/kolypto/py-smsframework/blob/4f3d812711f5e2e037dc80c4014c815fe2d68a0b/smsframework/providers/forward/provider.py#L239-L258
[ "def", "forward", "(", "self", ",", "obj", ")", ":", "assert", "isinstance", "(", "obj", ",", "(", "IncomingMessage", ",", "MessageStatus", ")", ")", ",", "'Tried to forward an object of an unsupported type: {}'", ".", "format", "(", "obj", ")", "clients", "=", ...
4f3d812711f5e2e037dc80c4014c815fe2d68a0b
test
Pytelemetry.stats
Returns a dictionnary of dictionnary that contains critical information about the transport and protocol behavior, such as: * amount of received frames * amount of badly delimited frames * amount of correctly delimited but still corrupted frames * etc
pytelemetry/pytelemetry.py
def stats(self): """ Returns a dictionnary of dictionnary that contains critical information about the transport and protocol behavior, such as: * amount of received frames * amount of badly delimited frames * amount of correctly delimited but still corrupted frames * etc """ d = dic...
def stats(self): """ Returns a dictionnary of dictionnary that contains critical information about the transport and protocol behavior, such as: * amount of received frames * amount of badly delimited frames * amount of correctly delimited but still corrupted frames * etc """ d = dic...
[ "Returns", "a", "dictionnary", "of", "dictionnary", "that", "contains", "critical", "information", "about", "the", "transport", "and", "protocol", "behavior", "such", "as", ":", "*", "amount", "of", "received", "frames", "*", "amount", "of", "badly", "delimited"...
Overdrivr/pytelemetry
python
https://github.com/Overdrivr/pytelemetry/blob/791b0129ddffc1832e1a8d90d9b97662422a40f0/pytelemetry/pytelemetry.py#L57-L70
[ "def", "stats", "(", "self", ")", ":", "d", "=", "dict", "(", ")", "d", "[", "'framing'", "]", "=", "self", ".", "api", ".", "delimiter", ".", "stats", "(", ")", "d", "[", "'protocol'", "]", "=", "self", ".", "api", ".", "stats", "(", ")", "r...
791b0129ddffc1832e1a8d90d9b97662422a40f0
test
Erc20Manager.get_balance
Get balance of address for `erc20_address` :param address: owner address :param erc20_address: erc20 token address :return: balance
gnosis/eth/ethereum_client.py
def get_balance(self, address: str, erc20_address: str) -> int: """ Get balance of address for `erc20_address` :param address: owner address :param erc20_address: erc20 token address :return: balance """ return get_erc20_contract(self.w3, erc20_address).functions....
def get_balance(self, address: str, erc20_address: str) -> int: """ Get balance of address for `erc20_address` :param address: owner address :param erc20_address: erc20 token address :return: balance """ return get_erc20_contract(self.w3, erc20_address).functions....
[ "Get", "balance", "of", "address", "for", "erc20_address", ":", "param", "address", ":", "owner", "address", ":", "param", "erc20_address", ":", "erc20", "token", "address", ":", "return", ":", "balance" ]
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/ethereum_client.py#L108-L115
[ "def", "get_balance", "(", "self", ",", "address", ":", "str", ",", "erc20_address", ":", "str", ")", "->", "int", ":", "return", "get_erc20_contract", "(", "self", ".", "w3", ",", "erc20_address", ")", ".", "functions", ".", "balanceOf", "(", "address", ...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
Erc20Manager.get_info
Get erc20 information (`name`, `symbol` and `decimals`) :param erc20_address: :return: Erc20_Info
gnosis/eth/ethereum_client.py
def get_info(self, erc20_address: str) -> Erc20_Info: """ Get erc20 information (`name`, `symbol` and `decimals`) :param erc20_address: :return: Erc20_Info """ # We use the `example erc20` as the `erc20 interface` doesn't have `name`, `symbol` nor `decimals` erc20...
def get_info(self, erc20_address: str) -> Erc20_Info: """ Get erc20 information (`name`, `symbol` and `decimals`) :param erc20_address: :return: Erc20_Info """ # We use the `example erc20` as the `erc20 interface` doesn't have `name`, `symbol` nor `decimals` erc20...
[ "Get", "erc20", "information", "(", "name", "symbol", "and", "decimals", ")", ":", "param", "erc20_address", ":", ":", "return", ":", "Erc20_Info" ]
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/ethereum_client.py#L117-L128
[ "def", "get_info", "(", "self", ",", "erc20_address", ":", "str", ")", "->", "Erc20_Info", ":", "# We use the `example erc20` as the `erc20 interface` doesn't have `name`, `symbol` nor `decimals`", "erc20", "=", "get_example_erc20_contract", "(", "self", ".", "w3", ",", "er...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
Erc20Manager.get_transfer_history
Get events for erc20 transfers. At least one of `from_address`, `to_address` or `token_address` must be defined An example of event: { "args": { "from": "0x1Ce67Ea59377A163D47DFFc9BaAB99423BE6EcF1", "to": "0xaE9E15896fd32E59C7d89ce7a95a9352D6ebD70E", ...
gnosis/eth/ethereum_client.py
def get_transfer_history(self, from_block: int, to_block: Optional[int] = None, from_address: Optional[str] = None, to_address: Optional[str] = None, token_address: Optional[str] = None) -> List[Dict[str, any]]: """ Get events for erc20 transfers...
def get_transfer_history(self, from_block: int, to_block: Optional[int] = None, from_address: Optional[str] = None, to_address: Optional[str] = None, token_address: Optional[str] = None) -> List[Dict[str, any]]: """ Get events for erc20 transfers...
[ "Get", "events", "for", "erc20", "transfers", ".", "At", "least", "one", "of", "from_address", "to_address", "or", "token_address", "must", "be", "defined", "An", "example", "of", "event", ":", "{", "args", ":", "{", "from", ":", "0x1Ce67Ea59377A163D47DFFc9BaA...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/ethereum_client.py#L130-L172
[ "def", "get_transfer_history", "(", "self", ",", "from_block", ":", "int", ",", "to_block", ":", "Optional", "[", "int", "]", "=", "None", ",", "from_address", ":", "Optional", "[", "str", "]", "=", "None", ",", "to_address", ":", "Optional", "[", "str",...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
Erc20Manager.send_tokens
Send tokens to address :param to: :param amount: :param erc20_address: :param private_key: :return: tx_hash
gnosis/eth/ethereum_client.py
def send_tokens(self, to: str, amount: int, erc20_address: str, private_key: str) -> bytes: """ Send tokens to address :param to: :param amount: :param erc20_address: :param private_key: :return: tx_hash """ erc20 = get_erc20_contract(self.w3, erc2...
def send_tokens(self, to: str, amount: int, erc20_address: str, private_key: str) -> bytes: """ Send tokens to address :param to: :param amount: :param erc20_address: :param private_key: :return: tx_hash """ erc20 = get_erc20_contract(self.w3, erc2...
[ "Send", "tokens", "to", "address", ":", "param", "to", ":", ":", "param", "amount", ":", ":", "param", "erc20_address", ":", ":", "param", "private_key", ":", ":", "return", ":", "tx_hash" ]
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/ethereum_client.py#L174-L186
[ "def", "send_tokens", "(", "self", ",", "to", ":", "str", ",", "amount", ":", "int", ",", "erc20_address", ":", "str", ",", "private_key", ":", "str", ")", "->", "bytes", ":", "erc20", "=", "get_erc20_contract", "(", "self", ".", "w3", ",", "erc20_addr...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
ParityManager.trace_filter
:param from_block: Quantity or Tag - (optional) From this block. `0` is not working, it needs to be `>= 1` :param to_block: Quantity or Tag - (optional) To this block. :param from_address: Array - (optional) Sent from these addresses. :param to_address: Address - (optional) Sent to these address...
gnosis/eth/ethereum_client.py
def trace_filter(self, from_block: int = 1, to_block: Optional[int] = None, from_address: Optional[List[str]] = None, to_address: Optional[List[str]] = None, after: Optional[int] = None, count: Optional[int] = None) -> List[Dict[str, any]]: """ :param from_block...
def trace_filter(self, from_block: int = 1, to_block: Optional[int] = None, from_address: Optional[List[str]] = None, to_address: Optional[List[str]] = None, after: Optional[int] = None, count: Optional[int] = None) -> List[Dict[str, any]]: """ :param from_block...
[ ":", "param", "from_block", ":", "Quantity", "or", "Tag", "-", "(", "optional", ")", "From", "this", "block", ".", "0", "is", "not", "working", "it", "needs", "to", "be", ">", "=", "1", ":", "param", "to_block", ":", "Quantity", "or", "Tag", "-", "...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/ethereum_client.py#L252-L327
[ "def", "trace_filter", "(", "self", ",", "from_block", ":", "int", "=", "1", ",", "to_block", ":", "Optional", "[", "int", "]", "=", "None", ",", "from_address", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ",", "to_address", ":",...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
EthereumClient.get_slow_provider
Get web3 provider for slow queries. Default `HTTPProvider` timeouts after 10 seconds :param provider: Configured Web3 provider :param timeout: Timeout to configure for internal requests (default is 10) :return: A new web3 provider with the `slow_provider_timeout`
gnosis/eth/ethereum_client.py
def get_slow_provider(self, timeout: int): """ Get web3 provider for slow queries. Default `HTTPProvider` timeouts after 10 seconds :param provider: Configured Web3 provider :param timeout: Timeout to configure for internal requests (default is 10) :return: A new web3 provider wi...
def get_slow_provider(self, timeout: int): """ Get web3 provider for slow queries. Default `HTTPProvider` timeouts after 10 seconds :param provider: Configured Web3 provider :param timeout: Timeout to configure for internal requests (default is 10) :return: A new web3 provider wi...
[ "Get", "web3", "provider", "for", "slow", "queries", ".", "Default", "HTTPProvider", "timeouts", "after", "10", "seconds", ":", "param", "provider", ":", "Configured", "Web3", "provider", ":", "param", "timeout", ":", "Timeout", "to", "configure", "for", "inte...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/ethereum_client.py#L350-L364
[ "def", "get_slow_provider", "(", "self", ",", "timeout", ":", "int", ")", ":", "if", "isinstance", "(", "self", ".", "w3_provider", ",", "AutoProvider", ")", ":", "return", "HTTPProvider", "(", "endpoint_uri", "=", "'http://localhost:8545'", ",", "request_kwargs...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
EthereumClient.send_unsigned_transaction
Send a tx using an unlocked public key in the node or a private key. Both `public_key` and `private_key` cannot be `None` :param tx: :param private_key: :param public_key: :param retry: Retry if a problem with nonce is found :param block_identifier: :return: tx ha...
gnosis/eth/ethereum_client.py
def send_unsigned_transaction(self, tx: Dict[str, any], private_key: Optional[str] = None, public_key: Optional[str] = None, retry: bool = False, block_identifier: Optional[str] = None) -> bytes: """ Send a tx using an unlocked public k...
def send_unsigned_transaction(self, tx: Dict[str, any], private_key: Optional[str] = None, public_key: Optional[str] = None, retry: bool = False, block_identifier: Optional[str] = None) -> bytes: """ Send a tx using an unlocked public k...
[ "Send", "a", "tx", "using", "an", "unlocked", "public", "key", "in", "the", "node", "or", "a", "private", "key", ".", "Both", "public_key", "and", "private_key", "cannot", "be", "None", ":", "param", "tx", ":", ":", "param", "private_key", ":", ":", "p...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/ethereum_client.py#L463-L516
[ "def", "send_unsigned_transaction", "(", "self", ",", "tx", ":", "Dict", "[", "str", ",", "any", "]", ",", "private_key", ":", "Optional", "[", "str", "]", "=", "None", ",", "public_key", ":", "Optional", "[", "str", "]", "=", "None", ",", "retry", "...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
EthereumClient.send_eth_to
Send ether using configured account :param to: to :param gas_price: gas_price :param value: value(wei) :param gas: gas, defaults to 22000 :param retry: Retry if a problem is found :param block_identifier: None default, 'pending' not confirmed txs :return: tx_hash
gnosis/eth/ethereum_client.py
def send_eth_to(self, private_key: str, to: str, gas_price: int, value: int, gas: int=22000, retry: bool = False, block_identifier=None, max_eth_to_send: int = 0) -> bytes: """ Send ether using configured account :param to: to :param gas_price: gas_price :para...
def send_eth_to(self, private_key: str, to: str, gas_price: int, value: int, gas: int=22000, retry: bool = False, block_identifier=None, max_eth_to_send: int = 0) -> bytes: """ Send ether using configured account :param to: to :param gas_price: gas_price :para...
[ "Send", "ether", "using", "configured", "account", ":", "param", "to", ":", "to", ":", "param", "gas_price", ":", "gas_price", ":", "param", "value", ":", "value", "(", "wei", ")", ":", "param", "gas", ":", "gas", "defaults", "to", "22000", ":", "param...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/ethereum_client.py#L518-L543
[ "def", "send_eth_to", "(", "self", ",", "private_key", ":", "str", ",", "to", ":", "str", ",", "gas_price", ":", "int", ",", "value", ":", "int", ",", "gas", ":", "int", "=", "22000", ",", "retry", ":", "bool", "=", "False", ",", "block_identifier", ...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
EthereumClient.check_tx_with_confirmations
Check tx hash and make sure it has the confirmations required :param w3: Web3 instance :param tx_hash: Hash of the tx :param confirmations: Minimum number of confirmations required :return: True if tx was mined with the number of confirmations required, False otherwise
gnosis/eth/ethereum_client.py
def check_tx_with_confirmations(self, tx_hash: str, confirmations: int) -> bool: """ Check tx hash and make sure it has the confirmations required :param w3: Web3 instance :param tx_hash: Hash of the tx :param confirmations: Minimum number of confirmations required :retur...
def check_tx_with_confirmations(self, tx_hash: str, confirmations: int) -> bool: """ Check tx hash and make sure it has the confirmations required :param w3: Web3 instance :param tx_hash: Hash of the tx :param confirmations: Minimum number of confirmations required :retur...
[ "Check", "tx", "hash", "and", "make", "sure", "it", "has", "the", "confirmations", "required", ":", "param", "w3", ":", "Web3", "instance", ":", "param", "tx_hash", ":", "Hash", "of", "the", "tx", ":", "param", "confirmations", ":", "Minimum", "number", ...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/ethereum_client.py#L545-L558
[ "def", "check_tx_with_confirmations", "(", "self", ",", "tx_hash", ":", "str", ",", "confirmations", ":", "int", ")", "->", "bool", ":", "tx_receipt", "=", "self", ".", "w3", ".", "eth", ".", "getTransactionReceipt", "(", "tx_hash", ")", "if", "not", "tx_r...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
EthereumClient.get_signing_address
:return: checksum encoded address starting by 0x, for example `0x568c93675A8dEb121700A6FAdDdfE7DFAb66Ae4A` :rtype: str
gnosis/eth/ethereum_client.py
def get_signing_address(hash: Union[bytes, str], v: int, r: int, s: int) -> str: """ :return: checksum encoded address starting by 0x, for example `0x568c93675A8dEb121700A6FAdDdfE7DFAb66Ae4A` :rtype: str """ encoded_64_address = ecrecover_to_pub(hash, v, r, s) address_byt...
def get_signing_address(hash: Union[bytes, str], v: int, r: int, s: int) -> str: """ :return: checksum encoded address starting by 0x, for example `0x568c93675A8dEb121700A6FAdDdfE7DFAb66Ae4A` :rtype: str """ encoded_64_address = ecrecover_to_pub(hash, v, r, s) address_byt...
[ ":", "return", ":", "checksum", "encoded", "address", "starting", "by", "0x", "for", "example", "0x568c93675A8dEb121700A6FAdDdfE7DFAb66Ae4A", ":", "rtype", ":", "str" ]
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/ethereum_client.py#L565-L572
[ "def", "get_signing_address", "(", "hash", ":", "Union", "[", "bytes", ",", "str", "]", ",", "v", ":", "int", ",", "r", ":", "int", ",", "s", ":", "int", ")", "->", "str", ":", "encoded_64_address", "=", "ecrecover_to_pub", "(", "hash", ",", "v", "...
2a9a5d75a375fc9813ac04df133e6910c82f9d49
test
generate_address_2
Generates an address for a contract created using CREATE2. :param from_: The address which is creating this new address (need to be 20 bytes) :param salt: A salt (32 bytes) :param init_code: A init code of the contract being created :return: Address of the new contract
gnosis/eth/utils.py
def generate_address_2(from_: Union[str, bytes], salt: Union[str, bytes], init_code: [str, bytes]) -> str: """ Generates an address for a contract created using CREATE2. :param from_: The address which is creating this new address (need to be 20 bytes) :param salt: A salt (32 bytes) :param init_code...
def generate_address_2(from_: Union[str, bytes], salt: Union[str, bytes], init_code: [str, bytes]) -> str: """ Generates an address for a contract created using CREATE2. :param from_: The address which is creating this new address (need to be 20 bytes) :param salt: A salt (32 bytes) :param init_code...
[ "Generates", "an", "address", "for", "a", "contract", "created", "using", "CREATE2", ".", ":", "param", "from_", ":", "The", "address", "which", "is", "creating", "this", "new", "address", "(", "need", "to", "be", "20", "bytes", ")", ":", "param", "salt"...
gnosis/gnosis-py
python
https://github.com/gnosis/gnosis-py/blob/2a9a5d75a375fc9813ac04df133e6910c82f9d49/gnosis/eth/utils.py#L25-L44
[ "def", "generate_address_2", "(", "from_", ":", "Union", "[", "str", ",", "bytes", "]", ",", "salt", ":", "Union", "[", "str", ",", "bytes", "]", ",", "init_code", ":", "[", "str", ",", "bytes", "]", ")", "->", "str", ":", "from_", "=", "HexBytes",...
2a9a5d75a375fc9813ac04df133e6910c82f9d49