repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
qubell/contrib-python-qubell-client
qubell/api/private/instance.py
ActivityLog.find
def find(self, item, description='', event_type=''): """ Find regexp in activitylog find record as if type are in description. """ # TODO: should be refactored, dumb logic if ': ' in item: splited = item.split(': ', 1) if splited[0] in self.TYPES: ...
python
def find(self, item, description='', event_type=''): """ Find regexp in activitylog find record as if type are in description. """ # TODO: should be refactored, dumb logic if ': ' in item: splited = item.split(': ', 1) if splited[0] in self.TYPES: ...
[ "def", "find", "(", "self", ",", "item", ",", "description", "=", "''", ",", "event_type", "=", "''", ")", ":", "# TODO: should be refactored, dumb logic", "if", "': '", "in", "item", ":", "splited", "=", "item", ".", "split", "(", "': '", ",", "1", ")",...
Find regexp in activitylog find record as if type are in description.
[ "Find", "regexp", "in", "activitylog", "find", "record", "as", "if", "type", "are", "in", "description", "." ]
4586ea11d5103c2ff9607d3ed922b5a0991b8845
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/instance.py#L621-L647
train
jamescooke/flake8-aaa
src/flake8_aaa/command_line.py
do_command_line
def do_command_line(infile: typing.IO[str]) -> int: """ Currently a small stub to create an instance of Checker for the passed ``infile`` and run its test functions through linting. Args: infile Returns: int: Number of flake8 errors raised. """ lines = infile.readlines() ...
python
def do_command_line(infile: typing.IO[str]) -> int: """ Currently a small stub to create an instance of Checker for the passed ``infile`` and run its test functions through linting. Args: infile Returns: int: Number of flake8 errors raised. """ lines = infile.readlines() ...
[ "def", "do_command_line", "(", "infile", ":", "typing", ".", "IO", "[", "str", "]", ")", "->", "int", ":", "lines", "=", "infile", ".", "readlines", "(", ")", "tree", "=", "ast", ".", "parse", "(", "''", ".", "join", "(", "lines", ")", ")", "chec...
Currently a small stub to create an instance of Checker for the passed ``infile`` and run its test functions through linting. Args: infile Returns: int: Number of flake8 errors raised.
[ "Currently", "a", "small", "stub", "to", "create", "an", "instance", "of", "Checker", "for", "the", "passed", "infile", "and", "run", "its", "test", "functions", "through", "linting", "." ]
29938b96845fe32ced4358ba66af3b3be2a37794
https://github.com/jamescooke/flake8-aaa/blob/29938b96845fe32ced4358ba66af3b3be2a37794/src/flake8_aaa/command_line.py#L8-L30
train
aroberge/experimental
experimental/core/import_hook.py
MyMetaFinder.find_spec
def find_spec(self, fullname, path, target=None): '''finds the appropriate properties (spec) of a module, and sets its loader.''' if not path: path = [os.getcwd()] if "." in fullname: name = fullname.split(".")[-1] else: name = fullname ...
python
def find_spec(self, fullname, path, target=None): '''finds the appropriate properties (spec) of a module, and sets its loader.''' if not path: path = [os.getcwd()] if "." in fullname: name = fullname.split(".")[-1] else: name = fullname ...
[ "def", "find_spec", "(", "self", ",", "fullname", ",", "path", ",", "target", "=", "None", ")", ":", "if", "not", "path", ":", "path", "=", "[", "os", ".", "getcwd", "(", ")", "]", "if", "\".\"", "in", "fullname", ":", "name", "=", "fullname", "....
finds the appropriate properties (spec) of a module, and sets its loader.
[ "finds", "the", "appropriate", "properties", "(", "spec", ")", "of", "a", "module", "and", "sets", "its", "loader", "." ]
031a9be10698b429998436da748b8fdb86f18b47
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/core/import_hook.py#L47-L70
train
aroberge/experimental
experimental/core/import_hook.py
MyLoader.exec_module
def exec_module(self, module): '''import the source code, transforma it before executing it so that it is known to Python.''' global MAIN_MODULE_NAME if module.__name__ == MAIN_MODULE_NAME: module.__name__ = "__main__" MAIN_MODULE_NAME = None with open...
python
def exec_module(self, module): '''import the source code, transforma it before executing it so that it is known to Python.''' global MAIN_MODULE_NAME if module.__name__ == MAIN_MODULE_NAME: module.__name__ = "__main__" MAIN_MODULE_NAME = None with open...
[ "def", "exec_module", "(", "self", ",", "module", ")", ":", "global", "MAIN_MODULE_NAME", "if", "module", ".", "__name__", "==", "MAIN_MODULE_NAME", ":", "module", ".", "__name__", "=", "\"__main__\"", "MAIN_MODULE_NAME", "=", "None", "with", "open", "(", "sel...
import the source code, transforma it before executing it so that it is known to Python.
[ "import", "the", "source", "code", "transforma", "it", "before", "executing", "it", "so", "that", "it", "is", "known", "to", "Python", "." ]
031a9be10698b429998436da748b8fdb86f18b47
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/core/import_hook.py#L83-L103
train
astroduff/commah
commah/commah.py
_izip
def _izip(*iterables): """ Iterate through multiple lists or arrays of equal size """ # This izip routine is from itertools # izip('ABCD', 'xy') --> Ax By iterators = map(iter, iterables) while iterators: yield tuple(map(next, iterators))
python
def _izip(*iterables): """ Iterate through multiple lists or arrays of equal size """ # This izip routine is from itertools # izip('ABCD', 'xy') --> Ax By iterators = map(iter, iterables) while iterators: yield tuple(map(next, iterators))
[ "def", "_izip", "(", "*", "iterables", ")", ":", "# This izip routine is from itertools", "# izip('ABCD', 'xy') --> Ax By", "iterators", "=", "map", "(", "iter", ",", "iterables", ")", "while", "iterators", ":", "yield", "tuple", "(", "map", "(", "next", ",", "i...
Iterate through multiple lists or arrays of equal size
[ "Iterate", "through", "multiple", "lists", "or", "arrays", "of", "equal", "size" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L17-L24
train
astroduff/commah
commah/commah.py
_checkinput
def _checkinput(zi, Mi, z=False, verbose=None): """ Check and convert any input scalar or array to numpy array """ # How many halo redshifts provided? zi = np.array(zi, ndmin=1, dtype=float) # How many halo masses provided? Mi = np.array(Mi, ndmin=1, dtype=float) # Check the input sizes for zi...
python
def _checkinput(zi, Mi, z=False, verbose=None): """ Check and convert any input scalar or array to numpy array """ # How many halo redshifts provided? zi = np.array(zi, ndmin=1, dtype=float) # How many halo masses provided? Mi = np.array(Mi, ndmin=1, dtype=float) # Check the input sizes for zi...
[ "def", "_checkinput", "(", "zi", ",", "Mi", ",", "z", "=", "False", ",", "verbose", "=", "None", ")", ":", "# How many halo redshifts provided?", "zi", "=", "np", ".", "array", "(", "zi", ",", "ndmin", "=", "1", ",", "dtype", "=", "float", ")", "# Ho...
Check and convert any input scalar or array to numpy array
[ "Check", "and", "convert", "any", "input", "scalar", "or", "array", "to", "numpy", "array" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L27-L67
train
astroduff/commah
commah/commah.py
getcosmo
def getcosmo(cosmology): """ Find cosmological parameters for named cosmo in cosmology.py list """ defaultcosmologies = {'dragons': cg.DRAGONS(), 'wmap1': cg.WMAP1_Mill(), 'wmap3': cg.WMAP3_ML(), 'wmap5': cg.WMAP5_mean(), 'wmap7': cg.WMAP7_ML(), 'wmap9': cg.W...
python
def getcosmo(cosmology): """ Find cosmological parameters for named cosmo in cosmology.py list """ defaultcosmologies = {'dragons': cg.DRAGONS(), 'wmap1': cg.WMAP1_Mill(), 'wmap3': cg.WMAP3_ML(), 'wmap5': cg.WMAP5_mean(), 'wmap7': cg.WMAP7_ML(), 'wmap9': cg.W...
[ "def", "getcosmo", "(", "cosmology", ")", ":", "defaultcosmologies", "=", "{", "'dragons'", ":", "cg", ".", "DRAGONS", "(", ")", ",", "'wmap1'", ":", "cg", ".", "WMAP1_Mill", "(", ")", ",", "'wmap3'", ":", "cg", ".", "WMAP3_ML", "(", ")", ",", "'wmap...
Find cosmological parameters for named cosmo in cosmology.py list
[ "Find", "cosmological", "parameters", "for", "named", "cosmo", "in", "cosmology", ".", "py", "list" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L70-L108
train
astroduff/commah
commah/commah.py
_getcosmoheader
def _getcosmoheader(cosmo): """ Output the cosmology to a string for writing to file """ cosmoheader = ("# Cosmology (flat) Om:{0:.3f}, Ol:{1:.3f}, h:{2:.2f}, " "sigma8:{3:.3f}, ns:{4:.2f}".format( cosmo['omega_M_0'], cosmo['omega_lambda_0'], cosmo['h'], ...
python
def _getcosmoheader(cosmo): """ Output the cosmology to a string for writing to file """ cosmoheader = ("# Cosmology (flat) Om:{0:.3f}, Ol:{1:.3f}, h:{2:.2f}, " "sigma8:{3:.3f}, ns:{4:.2f}".format( cosmo['omega_M_0'], cosmo['omega_lambda_0'], cosmo['h'], ...
[ "def", "_getcosmoheader", "(", "cosmo", ")", ":", "cosmoheader", "=", "(", "\"# Cosmology (flat) Om:{0:.3f}, Ol:{1:.3f}, h:{2:.2f}, \"", "\"sigma8:{3:.3f}, ns:{4:.2f}\"", ".", "format", "(", "cosmo", "[", "'omega_M_0'", "]", ",", "cosmo", "[", "'omega_lambda_0'", "]", "...
Output the cosmology to a string for writing to file
[ "Output", "the", "cosmology", "to", "a", "string", "for", "writing", "to", "file" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L111-L119
train
astroduff/commah
commah/commah.py
cduffy
def cduffy(z, M, vir='200crit', relaxed=True): """ NFW conc from Duffy 08 Table 1 for halo mass and redshift""" if(vir == '200crit'): if relaxed: params = [6.71, -0.091, -0.44] else: params = [5.71, -0.084, -0.47] elif(vir == 'tophat'): if relaxed: ...
python
def cduffy(z, M, vir='200crit', relaxed=True): """ NFW conc from Duffy 08 Table 1 for halo mass and redshift""" if(vir == '200crit'): if relaxed: params = [6.71, -0.091, -0.44] else: params = [5.71, -0.084, -0.47] elif(vir == 'tophat'): if relaxed: ...
[ "def", "cduffy", "(", "z", ",", "M", ",", "vir", "=", "'200crit'", ",", "relaxed", "=", "True", ")", ":", "if", "(", "vir", "==", "'200crit'", ")", ":", "if", "relaxed", ":", "params", "=", "[", "6.71", ",", "-", "0.091", ",", "-", "0.44", "]",...
NFW conc from Duffy 08 Table 1 for halo mass and redshift
[ "NFW", "conc", "from", "Duffy", "08", "Table", "1", "for", "halo", "mass", "and", "redshift" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L122-L144
train
astroduff/commah
commah/commah.py
_delta_sigma
def _delta_sigma(**cosmo): """ Perturb best-fit constant of proportionality Ascaling for rho_crit - rho_2 relation for unknown cosmology (Correa et al 2015c) Parameters ---------- cosmo : dict Dictionary of cosmological parameters, similar in format to: {'N_nu': 0,'Y_He': 0.24, ...
python
def _delta_sigma(**cosmo): """ Perturb best-fit constant of proportionality Ascaling for rho_crit - rho_2 relation for unknown cosmology (Correa et al 2015c) Parameters ---------- cosmo : dict Dictionary of cosmological parameters, similar in format to: {'N_nu': 0,'Y_He': 0.24, ...
[ "def", "_delta_sigma", "(", "*", "*", "cosmo", ")", ":", "M8_cosmo", "=", "cp", ".", "perturbation", ".", "radius_to_mass", "(", "8", ",", "*", "*", "cosmo", ")", "perturbed_A", "=", "(", "0.796", "/", "cosmo", "[", "'sigma_8'", "]", ")", "*", "(", ...
Perturb best-fit constant of proportionality Ascaling for rho_crit - rho_2 relation for unknown cosmology (Correa et al 2015c) Parameters ---------- cosmo : dict Dictionary of cosmological parameters, similar in format to: {'N_nu': 0,'Y_He': 0.24, 'h': 0.702, 'n': 0.963,'omega_M_0':...
[ "Perturb", "best", "-", "fit", "constant", "of", "proportionality", "Ascaling", "for", "rho_crit", "-", "rho_2", "relation", "for", "unknown", "cosmology", "(", "Correa", "et", "al", "2015c", ")" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L147-L172
train
astroduff/commah
commah/commah.py
getAscaling
def getAscaling(cosmology, newcosmo=None): """ Returns the normalisation constant between Rho_-2 and Rho_mean(z_formation) for a given cosmology Parameters ---------- cosmology : str or dict Can be named cosmology, default WMAP7 (aka DRAGONS), or DRAGONS, WMAP1, WMAP3, WMAP5, WM...
python
def getAscaling(cosmology, newcosmo=None): """ Returns the normalisation constant between Rho_-2 and Rho_mean(z_formation) for a given cosmology Parameters ---------- cosmology : str or dict Can be named cosmology, default WMAP7 (aka DRAGONS), or DRAGONS, WMAP1, WMAP3, WMAP5, WM...
[ "def", "getAscaling", "(", "cosmology", ",", "newcosmo", "=", "None", ")", ":", "# Values from Correa 15c", "defaultcosmologies", "=", "{", "'dragons'", ":", "887", ",", "'wmap1'", ":", "853", ",", "'wmap3'", ":", "850", ",", "'wmap5'", ":", "887", ",", "'...
Returns the normalisation constant between Rho_-2 and Rho_mean(z_formation) for a given cosmology Parameters ---------- cosmology : str or dict Can be named cosmology, default WMAP7 (aka DRAGONS), or DRAGONS, WMAP1, WMAP3, WMAP5, WMAP7, WMAP9, Planck13, Planck15 or dictionar...
[ "Returns", "the", "normalisation", "constant", "between", "Rho_", "-", "2", "and", "Rho_mean", "(", "z_formation", ")", "for", "a", "given", "cosmology" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L175-L216
train
astroduff/commah
commah/commah.py
_int_growth
def _int_growth(z, **cosmo): """ Returns integral of the linear growth factor from z=200 to z=z """ zmax = 200 if hasattr(z, "__len__"): for zval in z: assert(zval < zmax) else: assert(z < zmax) y, yerr = scipy.integrate.quad( lambda z: (1 + z)/(cosmo['omega_M_...
python
def _int_growth(z, **cosmo): """ Returns integral of the linear growth factor from z=200 to z=z """ zmax = 200 if hasattr(z, "__len__"): for zval in z: assert(zval < zmax) else: assert(z < zmax) y, yerr = scipy.integrate.quad( lambda z: (1 + z)/(cosmo['omega_M_...
[ "def", "_int_growth", "(", "z", ",", "*", "*", "cosmo", ")", ":", "zmax", "=", "200", "if", "hasattr", "(", "z", ",", "\"__len__\"", ")", ":", "for", "zval", "in", "z", ":", "assert", "(", "zval", "<", "zmax", ")", "else", ":", "assert", "(", "...
Returns integral of the linear growth factor from z=200 to z=z
[ "Returns", "integral", "of", "the", "linear", "growth", "factor", "from", "z", "=", "200", "to", "z", "=", "z" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L219-L235
train
astroduff/commah
commah/commah.py
_deriv_growth
def _deriv_growth(z, **cosmo): """ Returns derivative of the linear growth factor at z for a given cosmology **cosmo """ inv_h = (cosmo['omega_M_0']*(1 + z)**3 + cosmo['omega_lambda_0'])**(-0.5) fz = (1 + z) * inv_h**3 deriv_g = growthfactor(z, norm=True, **cosmo)*(inv_h**2) *\ 1.5 * c...
python
def _deriv_growth(z, **cosmo): """ Returns derivative of the linear growth factor at z for a given cosmology **cosmo """ inv_h = (cosmo['omega_M_0']*(1 + z)**3 + cosmo['omega_lambda_0'])**(-0.5) fz = (1 + z) * inv_h**3 deriv_g = growthfactor(z, norm=True, **cosmo)*(inv_h**2) *\ 1.5 * c...
[ "def", "_deriv_growth", "(", "z", ",", "*", "*", "cosmo", ")", ":", "inv_h", "=", "(", "cosmo", "[", "'omega_M_0'", "]", "*", "(", "1", "+", "z", ")", "**", "3", "+", "cosmo", "[", "'omega_lambda_0'", "]", ")", "**", "(", "-", "0.5", ")", "fz",...
Returns derivative of the linear growth factor at z for a given cosmology **cosmo
[ "Returns", "derivative", "of", "the", "linear", "growth", "factor", "at", "z", "for", "a", "given", "cosmology", "**", "cosmo" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L238-L249
train
astroduff/commah
commah/commah.py
growthfactor
def growthfactor(z, norm=True, **cosmo): """ Returns linear growth factor at a given redshift, normalised to z=0 by default, for a given cosmology Parameters ---------- z : float or numpy array The redshift at which the growth factor should be calculated norm : boolean, optional ...
python
def growthfactor(z, norm=True, **cosmo): """ Returns linear growth factor at a given redshift, normalised to z=0 by default, for a given cosmology Parameters ---------- z : float or numpy array The redshift at which the growth factor should be calculated norm : boolean, optional ...
[ "def", "growthfactor", "(", "z", ",", "norm", "=", "True", ",", "*", "*", "cosmo", ")", ":", "H", "=", "np", ".", "sqrt", "(", "cosmo", "[", "'omega_M_0'", "]", "*", "(", "1", "+", "z", ")", "**", "3", "+", "cosmo", "[", "'omega_lambda_0'", "]"...
Returns linear growth factor at a given redshift, normalised to z=0 by default, for a given cosmology Parameters ---------- z : float or numpy array The redshift at which the growth factor should be calculated norm : boolean, optional If true then normalise the growth factor to...
[ "Returns", "linear", "growth", "factor", "at", "a", "given", "redshift", "normalised", "to", "z", "=", "0", "by", "default", "for", "a", "given", "cosmology" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L252-L284
train
astroduff/commah
commah/commah.py
_minimize_c
def _minimize_c(c, z=0, a_tilde=1, b_tilde=-1, Ascaling=900, omega_M_0=0.25, omega_lambda_0=0.75): """ Trial function to solve 2 eqns (17 and 18) from Correa et al. (2015c) for 1 unknown, i.e. concentration, returned by a minimisation call """ # Fn 1 (LHS of Eqn 18) Y1 = np.log(2) ...
python
def _minimize_c(c, z=0, a_tilde=1, b_tilde=-1, Ascaling=900, omega_M_0=0.25, omega_lambda_0=0.75): """ Trial function to solve 2 eqns (17 and 18) from Correa et al. (2015c) for 1 unknown, i.e. concentration, returned by a minimisation call """ # Fn 1 (LHS of Eqn 18) Y1 = np.log(2) ...
[ "def", "_minimize_c", "(", "c", ",", "z", "=", "0", ",", "a_tilde", "=", "1", ",", "b_tilde", "=", "-", "1", ",", "Ascaling", "=", "900", ",", "omega_M_0", "=", "0.25", ",", "omega_lambda_0", "=", "0.75", ")", ":", "# Fn 1 (LHS of Eqn 18)", "Y1", "="...
Trial function to solve 2 eqns (17 and 18) from Correa et al. (2015c) for 1 unknown, i.e. concentration, returned by a minimisation call
[ "Trial", "function", "to", "solve", "2", "eqns", "(", "17", "and", "18", ")", "from", "Correa", "et", "al", ".", "(", "2015c", ")", "for", "1", "unknown", "i", ".", "e", ".", "concentration", "returned", "by", "a", "minimisation", "call" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L287-L312
train
astroduff/commah
commah/commah.py
formationz
def formationz(c, z, Ascaling=900, omega_M_0=0.25, omega_lambda_0=0.75): """ Rearrange eqn 18 from Correa et al (2015c) to return formation redshift for a concentration at a given redshift Parameters ---------- c : float / numpy array Concentration of halo z : float / numpy array ...
python
def formationz(c, z, Ascaling=900, omega_M_0=0.25, omega_lambda_0=0.75): """ Rearrange eqn 18 from Correa et al (2015c) to return formation redshift for a concentration at a given redshift Parameters ---------- c : float / numpy array Concentration of halo z : float / numpy array ...
[ "def", "formationz", "(", "c", ",", "z", ",", "Ascaling", "=", "900", ",", "omega_M_0", "=", "0.25", ",", "omega_lambda_0", "=", "0.75", ")", ":", "Y1", "=", "np", ".", "log", "(", "2", ")", "-", "0.5", "Yc", "=", "np", ".", "log", "(", "1", ...
Rearrange eqn 18 from Correa et al (2015c) to return formation redshift for a concentration at a given redshift Parameters ---------- c : float / numpy array Concentration of halo z : float / numpy array Redshift of halo with concentration c Ascaling : float Cosmolog...
[ "Rearrange", "eqn", "18", "from", "Correa", "et", "al", "(", "2015c", ")", "to", "return", "formation", "redshift", "for", "a", "concentration", "at", "a", "given", "redshift" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L315-L346
train
astroduff/commah
commah/commah.py
calc_ab
def calc_ab(zi, Mi, **cosmo): """ Calculate growth rate indices a_tilde and b_tilde Parameters ---------- zi : float Redshift Mi : float Halo mass at redshift 'zi' cosmo : dict Dictionary of cosmological parameters, similar in format to: {'N_nu': 0,'Y_He': 0.24, ...
python
def calc_ab(zi, Mi, **cosmo): """ Calculate growth rate indices a_tilde and b_tilde Parameters ---------- zi : float Redshift Mi : float Halo mass at redshift 'zi' cosmo : dict Dictionary of cosmological parameters, similar in format to: {'N_nu': 0,'Y_He': 0.24, ...
[ "def", "calc_ab", "(", "zi", ",", "Mi", ",", "*", "*", "cosmo", ")", ":", "# When zi = 0, the a_tilde becomes alpha and b_tilde becomes beta", "# Eqn 23 of Correa et al 2015a (analytically solve from Eqn 16 and 17)", "# Arbitray formation redshift, z_-2 in COM is more physically motivate...
Calculate growth rate indices a_tilde and b_tilde Parameters ---------- zi : float Redshift Mi : float Halo mass at redshift 'zi' cosmo : dict Dictionary of cosmological parameters, similar in format to: {'N_nu': 0,'Y_He': 0.24, 'h': 0.702, 'n': 0.963,'omega_M_0': 0....
[ "Calculate", "growth", "rate", "indices", "a_tilde", "and", "b_tilde" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L349-L397
train
astroduff/commah
commah/commah.py
acc_rate
def acc_rate(z, zi, Mi, **cosmo): """ Calculate accretion rate and mass history of a halo at any redshift 'z' with mass 'Mi' at a lower redshift 'z' Parameters ---------- z : float Redshift to solve acc_rate / mass history. Note zi<z zi : float Redshift Mi : float ...
python
def acc_rate(z, zi, Mi, **cosmo): """ Calculate accretion rate and mass history of a halo at any redshift 'z' with mass 'Mi' at a lower redshift 'z' Parameters ---------- z : float Redshift to solve acc_rate / mass history. Note zi<z zi : float Redshift Mi : float ...
[ "def", "acc_rate", "(", "z", ",", "zi", ",", "Mi", ",", "*", "*", "cosmo", ")", ":", "# Find parameters a_tilde and b_tilde for initial redshift", "# use Eqn 9 and 10 of Correa et al. (2015c)", "a_tilde", ",", "b_tilde", "=", "calc_ab", "(", "zi", ",", "Mi", ",", ...
Calculate accretion rate and mass history of a halo at any redshift 'z' with mass 'Mi' at a lower redshift 'z' Parameters ---------- z : float Redshift to solve acc_rate / mass history. Note zi<z zi : float Redshift Mi : float Halo mass at redshift 'zi' cosmo : d...
[ "Calculate", "accretion", "rate", "and", "mass", "history", "of", "a", "halo", "at", "any", "redshift", "z", "with", "mass", "Mi", "at", "a", "lower", "redshift", "z" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L400-L438
train
astroduff/commah
commah/commah.py
MAH
def MAH(z, zi, Mi, **cosmo): """ Calculate mass accretion history by looping function acc_rate over redshift steps 'z' for halo of mass 'Mi' at redshift 'zi' Parameters ---------- z : float / numpy array Redshift to output MAH over. Note zi<z always zi : float Redshift M...
python
def MAH(z, zi, Mi, **cosmo): """ Calculate mass accretion history by looping function acc_rate over redshift steps 'z' for halo of mass 'Mi' at redshift 'zi' Parameters ---------- z : float / numpy array Redshift to output MAH over. Note zi<z always zi : float Redshift M...
[ "def", "MAH", "(", "z", ",", "zi", ",", "Mi", ",", "*", "*", "cosmo", ")", ":", "# Ensure that z is a 1D NumPy array", "z", "=", "np", ".", "array", "(", "z", ",", "ndmin", "=", "1", ",", "dtype", "=", "float", ")", "# Create a full array", "dMdt_array...
Calculate mass accretion history by looping function acc_rate over redshift steps 'z' for halo of mass 'Mi' at redshift 'zi' Parameters ---------- z : float / numpy array Redshift to output MAH over. Note zi<z always zi : float Redshift Mi : float Halo mass at redshi...
[ "Calculate", "mass", "accretion", "history", "by", "looping", "function", "acc_rate", "over", "redshift", "steps", "z", "for", "halo", "of", "mass", "Mi", "at", "redshift", "zi" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L441-L480
train
astroduff/commah
commah/commah.py
COM
def COM(z, M, **cosmo): """ Calculate concentration for halo of mass 'M' at redshift 'z' Parameters ---------- z : float / numpy array Redshift to find concentration of halo M : float / numpy array Halo mass at redshift 'z'. Must be same size as 'z' cosmo : dict Dictiona...
python
def COM(z, M, **cosmo): """ Calculate concentration for halo of mass 'M' at redshift 'z' Parameters ---------- z : float / numpy array Redshift to find concentration of halo M : float / numpy array Halo mass at redshift 'z'. Must be same size as 'z' cosmo : dict Dictiona...
[ "def", "COM", "(", "z", ",", "M", ",", "*", "*", "cosmo", ")", ":", "# Check that z and M are arrays", "z", "=", "np", ".", "array", "(", "z", ",", "ndmin", "=", "1", ",", "dtype", "=", "float", ")", "M", "=", "np", ".", "array", "(", "M", ",",...
Calculate concentration for halo of mass 'M' at redshift 'z' Parameters ---------- z : float / numpy array Redshift to find concentration of halo M : float / numpy array Halo mass at redshift 'z'. Must be same size as 'z' cosmo : dict Dictionary of cosmological parameters, s...
[ "Calculate", "concentration", "for", "halo", "of", "mass", "M", "at", "redshift", "z" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L483-L552
train
astroduff/commah
commah/commah.py
run
def run(cosmology, zi=0, Mi=1e12, z=False, com=True, mah=True, filename=None, verbose=None, retcosmo=None): """ Run commah code on halo of mass 'Mi' at redshift 'zi' with accretion and profile history at higher redshifts 'z' This is based on Correa et al. (2015a,b,c) Parameters ----...
python
def run(cosmology, zi=0, Mi=1e12, z=False, com=True, mah=True, filename=None, verbose=None, retcosmo=None): """ Run commah code on halo of mass 'Mi' at redshift 'zi' with accretion and profile history at higher redshifts 'z' This is based on Correa et al. (2015a,b,c) Parameters ----...
[ "def", "run", "(", "cosmology", ",", "zi", "=", "0", ",", "Mi", "=", "1e12", ",", "z", "=", "False", ",", "com", "=", "True", ",", "mah", "=", "True", ",", "filename", "=", "None", ",", "verbose", "=", "None", ",", "retcosmo", "=", "None", ")",...
Run commah code on halo of mass 'Mi' at redshift 'zi' with accretion and profile history at higher redshifts 'z' This is based on Correa et al. (2015a,b,c) Parameters ---------- cosmology : str or dict Can be named cosmology, default WMAP7 (aka DRAGONS), or DRAGONS, WMAP1, W...
[ "Run", "commah", "code", "on", "halo", "of", "mass", "Mi", "at", "redshift", "zi", "with", "accretion", "and", "profile", "history", "at", "higher", "redshifts", "z", "This", "is", "based", "on", "Correa", "et", "al", ".", "(", "2015a", "b", "c", ")" ]
3ec70338c5123a053c79ddcf2cb3beac26bc9137
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L555-L799
train
MatterMiners/cobald
cobald/daemon/core/config.py
load
def load(config_path: str): """ Load a configuration and keep it alive for the given context :param config_path: path to a configuration file """ # we bind the config to _ to keep it alive if os.path.splitext(config_path)[1] in ('.yaml', '.yml'): _ = load_yaml_configuration(config_path,...
python
def load(config_path: str): """ Load a configuration and keep it alive for the given context :param config_path: path to a configuration file """ # we bind the config to _ to keep it alive if os.path.splitext(config_path)[1] in ('.yaml', '.yml'): _ = load_yaml_configuration(config_path,...
[ "def", "load", "(", "config_path", ":", "str", ")", ":", "# we bind the config to _ to keep it alive", "if", "os", ".", "path", ".", "splitext", "(", "config_path", ")", "[", "1", "]", "in", "(", "'.yaml'", ",", "'.yml'", ")", ":", "_", "=", "load_yaml_con...
Load a configuration and keep it alive for the given context :param config_path: path to a configuration file
[ "Load", "a", "configuration", "and", "keep", "it", "alive", "for", "the", "given", "context" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/core/config.py#L10-L23
train
aroberge/experimental
experimental/transformers/repeat_keyword.py
transform_source
def transform_source(text): '''Replaces instances of repeat n: by for __VAR_i in range(n): where __VAR_i is a string that does not appear elsewhere in the code sample. ''' loop_keyword = 'repeat' nb = text.count(loop_keyword) if nb == 0: return text var_...
python
def transform_source(text): '''Replaces instances of repeat n: by for __VAR_i in range(n): where __VAR_i is a string that does not appear elsewhere in the code sample. ''' loop_keyword = 'repeat' nb = text.count(loop_keyword) if nb == 0: return text var_...
[ "def", "transform_source", "(", "text", ")", ":", "loop_keyword", "=", "'repeat'", "nb", "=", "text", ".", "count", "(", "loop_keyword", ")", "if", "nb", "==", "0", ":", "return", "text", "var_names", "=", "get_unique_variable_names", "(", "text", ",", "nb...
Replaces instances of repeat n: by for __VAR_i in range(n): where __VAR_i is a string that does not appear elsewhere in the code sample.
[ "Replaces", "instances", "of" ]
031a9be10698b429998436da748b8fdb86f18b47
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/transformers/repeat_keyword.py#L29-L70
train
aroberge/experimental
experimental/transformers/repeat_keyword.py
get_unique_variable_names
def get_unique_variable_names(text, nb): '''returns a list of possible variables names that are not found in the original text.''' base_name = '__VAR_' var_names = [] i = 0 j = 0 while j < nb: tentative_name = base_name + str(i) if text.count(tentative_name) == 0 and tenta...
python
def get_unique_variable_names(text, nb): '''returns a list of possible variables names that are not found in the original text.''' base_name = '__VAR_' var_names = [] i = 0 j = 0 while j < nb: tentative_name = base_name + str(i) if text.count(tentative_name) == 0 and tenta...
[ "def", "get_unique_variable_names", "(", "text", ",", "nb", ")", ":", "base_name", "=", "'__VAR_'", "var_names", "=", "[", "]", "i", "=", "0", "j", "=", "0", "while", "j", "<", "nb", ":", "tentative_name", "=", "base_name", "+", "str", "(", "i", ")",...
returns a list of possible variables names that are not found in the original text.
[ "returns", "a", "list", "of", "possible", "variables", "names", "that", "are", "not", "found", "in", "the", "original", "text", "." ]
031a9be10698b429998436da748b8fdb86f18b47
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/transformers/repeat_keyword.py#L75-L89
train
quantmind/agile-toolkit
agiletoolkit/api/releases.py
Releases.tag
def tag(self, tag): """Get a release by tag """ url = '%s/tags/%s' % (self, tag) response = self.http.get(url, auth=self.auth) response.raise_for_status() return response.json()
python
def tag(self, tag): """Get a release by tag """ url = '%s/tags/%s' % (self, tag) response = self.http.get(url, auth=self.auth) response.raise_for_status() return response.json()
[ "def", "tag", "(", "self", ",", "tag", ")", ":", "url", "=", "'%s/tags/%s'", "%", "(", "self", ",", "tag", ")", "response", "=", "self", ".", "http", ".", "get", "(", "url", ",", "auth", "=", "self", ".", "auth", ")", "response", ".", "raise_for_...
Get a release by tag
[ "Get", "a", "release", "by", "tag" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/releases.py#L37-L43
train
quantmind/agile-toolkit
agiletoolkit/api/releases.py
Releases.release_assets
def release_assets(self, release): """Assets for a given release """ release = self.as_id(release) return self.get_list(url='%s/%s/assets' % (self, release))
python
def release_assets(self, release): """Assets for a given release """ release = self.as_id(release) return self.get_list(url='%s/%s/assets' % (self, release))
[ "def", "release_assets", "(", "self", ",", "release", ")", ":", "release", "=", "self", ".", "as_id", "(", "release", ")", "return", "self", ".", "get_list", "(", "url", "=", "'%s/%s/assets'", "%", "(", "self", ",", "release", ")", ")" ]
Assets for a given release
[ "Assets", "for", "a", "given", "release" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/releases.py#L53-L57
train
quantmind/agile-toolkit
agiletoolkit/api/releases.py
Releases.upload
def upload(self, release, filename, content_type=None): """Upload a file to a release :param filename: filename to upload :param content_type: optional content type :return: json object from github """ release = self.as_id(release) name = os.path.basename(filenam...
python
def upload(self, release, filename, content_type=None): """Upload a file to a release :param filename: filename to upload :param content_type: optional content type :return: json object from github """ release = self.as_id(release) name = os.path.basename(filenam...
[ "def", "upload", "(", "self", ",", "release", ",", "filename", ",", "content_type", "=", "None", ")", ":", "release", "=", "self", ".", "as_id", "(", "release", ")", "name", "=", "os", ".", "path", ".", "basename", "(", "filename", ")", "if", "not", ...
Upload a file to a release :param filename: filename to upload :param content_type: optional content type :return: json object from github
[ "Upload", "a", "file", "to", "a", "release" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/releases.py#L59-L84
train
quantmind/agile-toolkit
agiletoolkit/api/releases.py
Releases.validate_tag
def validate_tag(self, tag_name, prefix=None): """Validate ``tag_name`` with the latest tag from github If ``tag_name`` is a valid candidate, return the latest tag from github """ new_version = semantic_version(tag_name) current = self.latest() if current: ta...
python
def validate_tag(self, tag_name, prefix=None): """Validate ``tag_name`` with the latest tag from github If ``tag_name`` is a valid candidate, return the latest tag from github """ new_version = semantic_version(tag_name) current = self.latest() if current: ta...
[ "def", "validate_tag", "(", "self", ",", "tag_name", ",", "prefix", "=", "None", ")", ":", "new_version", "=", "semantic_version", "(", "tag_name", ")", "current", "=", "self", ".", "latest", "(", ")", "if", "current", ":", "tag_name", "=", "current", "[...
Validate ``tag_name`` with the latest tag from github If ``tag_name`` is a valid candidate, return the latest tag from github
[ "Validate", "tag_name", "with", "the", "latest", "tag", "from", "github" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/releases.py#L86-L111
train
teaearlgraycold/puni
puni/base.py
Note.full_url
def full_url(self): """Return the full reddit URL associated with the usernote. Arguments: subreddit: the subreddit name for the note (PRAW Subreddit object) """ if self.link == '': return None else: return Note._expand_url(self.link, self.sub...
python
def full_url(self): """Return the full reddit URL associated with the usernote. Arguments: subreddit: the subreddit name for the note (PRAW Subreddit object) """ if self.link == '': return None else: return Note._expand_url(self.link, self.sub...
[ "def", "full_url", "(", "self", ")", ":", "if", "self", ".", "link", "==", "''", ":", "return", "None", "else", ":", "return", "Note", ".", "_expand_url", "(", "self", ".", "link", ",", "self", ".", "subreddit", ")" ]
Return the full reddit URL associated with the usernote. Arguments: subreddit: the subreddit name for the note (PRAW Subreddit object)
[ "Return", "the", "full", "reddit", "URL", "associated", "with", "the", "usernote", "." ]
f6d0bfde99942b29a6f91273e48abcd2d7a94c93
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L87-L96
train
teaearlgraycold/puni
puni/base.py
Note._compress_url
def _compress_url(link): """Convert a reddit URL into the short-hand used by usernotes. Arguments: link: a link to a comment, submission, or message (str) Returns a String of the shorthand URL """ comment_re = re.compile(r'/comments/([A-Za-z\d]{2,})(?:/[^\s]+/([A-Za...
python
def _compress_url(link): """Convert a reddit URL into the short-hand used by usernotes. Arguments: link: a link to a comment, submission, or message (str) Returns a String of the shorthand URL """ comment_re = re.compile(r'/comments/([A-Za-z\d]{2,})(?:/[^\s]+/([A-Za...
[ "def", "_compress_url", "(", "link", ")", ":", "comment_re", "=", "re", ".", "compile", "(", "r'/comments/([A-Za-z\\d]{2,})(?:/[^\\s]+/([A-Za-z\\d]+))?'", ")", "message_re", "=", "re", ".", "compile", "(", "r'/message/messages/([A-Za-z\\d]+)'", ")", "matches", "=", "r...
Convert a reddit URL into the short-hand used by usernotes. Arguments: link: a link to a comment, submission, or message (str) Returns a String of the shorthand URL
[ "Convert", "a", "reddit", "URL", "into", "the", "short", "-", "hand", "used", "by", "usernotes", "." ]
f6d0bfde99942b29a6f91273e48abcd2d7a94c93
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L99-L122
train
teaearlgraycold/puni
puni/base.py
Note._expand_url
def _expand_url(short_link, subreddit=None): """Convert a usernote's URL short-hand into a full reddit URL. Arguments: subreddit: the subreddit the URL is for (PRAW Subreddit object or str) short_link: the compressed link from a usernote (str) Returns a String of the fu...
python
def _expand_url(short_link, subreddit=None): """Convert a usernote's URL short-hand into a full reddit URL. Arguments: subreddit: the subreddit the URL is for (PRAW Subreddit object or str) short_link: the compressed link from a usernote (str) Returns a String of the fu...
[ "def", "_expand_url", "(", "short_link", ",", "subreddit", "=", "None", ")", ":", "# Some URL structures for notes", "message_scheme", "=", "'https://reddit.com/message/messages/{}'", "comment_scheme", "=", "'https://reddit.com/r/{}/comments/{}/-/{}'", "post_scheme", "=", "'htt...
Convert a usernote's URL short-hand into a full reddit URL. Arguments: subreddit: the subreddit the URL is for (PRAW Subreddit object or str) short_link: the compressed link from a usernote (str) Returns a String of the full URL.
[ "Convert", "a", "usernote", "s", "URL", "short", "-", "hand", "into", "a", "full", "reddit", "URL", "." ]
f6d0bfde99942b29a6f91273e48abcd2d7a94c93
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L125-L154
train
teaearlgraycold/puni
puni/base.py
UserNotes.get_json
def get_json(self): """Get the JSON stored on the usernotes wiki page. Returns a dict representation of the usernotes (with the notes BLOB decoded). Raises: RuntimeError if the usernotes version is incompatible with this version of puni. """ ...
python
def get_json(self): """Get the JSON stored on the usernotes wiki page. Returns a dict representation of the usernotes (with the notes BLOB decoded). Raises: RuntimeError if the usernotes version is incompatible with this version of puni. """ ...
[ "def", "get_json", "(", "self", ")", ":", "try", ":", "usernotes", "=", "self", ".", "subreddit", ".", "wiki", "[", "self", ".", "page_name", "]", ".", "content_md", "notes", "=", "json", ".", "loads", "(", "usernotes", ")", "except", "NotFound", ":", ...
Get the JSON stored on the usernotes wiki page. Returns a dict representation of the usernotes (with the notes BLOB decoded). Raises: RuntimeError if the usernotes version is incompatible with this version of puni.
[ "Get", "the", "JSON", "stored", "on", "the", "usernotes", "wiki", "page", "." ]
f6d0bfde99942b29a6f91273e48abcd2d7a94c93
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L186-L210
train
teaearlgraycold/puni
puni/base.py
UserNotes._init_notes
def _init_notes(self): """Set up the UserNotes page with the initial JSON schema.""" self.cached_json = { 'ver': self.schema, 'users': {}, 'constants': { 'users': [x.name for x in self.subreddit.moderator()], 'warnings': Note.warnings ...
python
def _init_notes(self): """Set up the UserNotes page with the initial JSON schema.""" self.cached_json = { 'ver': self.schema, 'users': {}, 'constants': { 'users': [x.name for x in self.subreddit.moderator()], 'warnings': Note.warnings ...
[ "def", "_init_notes", "(", "self", ")", ":", "self", ".", "cached_json", "=", "{", "'ver'", ":", "self", ".", "schema", ",", "'users'", ":", "{", "}", ",", "'constants'", ":", "{", "'users'", ":", "[", "x", ".", "name", "for", "x", "in", "self", ...
Set up the UserNotes page with the initial JSON schema.
[ "Set", "up", "the", "UserNotes", "page", "with", "the", "initial", "JSON", "schema", "." ]
f6d0bfde99942b29a6f91273e48abcd2d7a94c93
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L212-L223
train
teaearlgraycold/puni
puni/base.py
UserNotes.set_json
def set_json(self, reason='', new_page=False): """Send the JSON from the cache to the usernotes wiki page. Arguments: reason: the change reason that will be posted to the wiki changelog (str) Raises: OverflowError if the new JSON data is greater than max_...
python
def set_json(self, reason='', new_page=False): """Send the JSON from the cache to the usernotes wiki page. Arguments: reason: the change reason that will be posted to the wiki changelog (str) Raises: OverflowError if the new JSON data is greater than max_...
[ "def", "set_json", "(", "self", ",", "reason", "=", "''", ",", "new_page", "=", "False", ")", ":", "compressed_json", "=", "json", ".", "dumps", "(", "self", ".", "_compress_json", "(", "self", ".", "cached_json", ")", ")", "if", "len", "(", "compresse...
Send the JSON from the cache to the usernotes wiki page. Arguments: reason: the change reason that will be posted to the wiki changelog (str) Raises: OverflowError if the new JSON data is greater than max_page_size
[ "Send", "the", "JSON", "from", "the", "cache", "to", "the", "usernotes", "wiki", "page", "." ]
f6d0bfde99942b29a6f91273e48abcd2d7a94c93
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L225-L254
train
teaearlgraycold/puni
puni/base.py
UserNotes.get_notes
def get_notes(self, user): """Return a list of Note objects for the given user. Return an empty list if no notes are found. Arguments: user: the user to search for in the usernotes (str) """ # Try to search for all notes on a user, return an empty list if none ...
python
def get_notes(self, user): """Return a list of Note objects for the given user. Return an empty list if no notes are found. Arguments: user: the user to search for in the usernotes (str) """ # Try to search for all notes on a user, return an empty list if none ...
[ "def", "get_notes", "(", "self", ",", "user", ")", ":", "# Try to search for all notes on a user, return an empty list if none", "# are found.", "try", ":", "users_notes", "=", "[", "]", "for", "note", "in", "self", ".", "cached_json", "[", "'users'", "]", "[", "u...
Return a list of Note objects for the given user. Return an empty list if no notes are found. Arguments: user: the user to search for in the usernotes (str)
[ "Return", "a", "list", "of", "Note", "objects", "for", "the", "given", "user", "." ]
f6d0bfde99942b29a6f91273e48abcd2d7a94c93
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L257-L284
train
teaearlgraycold/puni
puni/base.py
UserNotes._expand_json
def _expand_json(self, j): """Decompress the BLOB portion of the usernotes. Arguments: j: the JSON returned from the wiki page (dict) Returns a Dict with the 'blob' key removed and a 'users' key added """ decompressed_json = copy.copy(j) decompressed_json.po...
python
def _expand_json(self, j): """Decompress the BLOB portion of the usernotes. Arguments: j: the JSON returned from the wiki page (dict) Returns a Dict with the 'blob' key removed and a 'users' key added """ decompressed_json = copy.copy(j) decompressed_json.po...
[ "def", "_expand_json", "(", "self", ",", "j", ")", ":", "decompressed_json", "=", "copy", ".", "copy", "(", "j", ")", "decompressed_json", ".", "pop", "(", "'blob'", ",", "None", ")", "# Remove BLOB portion of JSON", "# Decode and decompress JSON", "compressed_dat...
Decompress the BLOB portion of the usernotes. Arguments: j: the JSON returned from the wiki page (dict) Returns a Dict with the 'blob' key removed and a 'users' key added
[ "Decompress", "the", "BLOB", "portion", "of", "the", "usernotes", "." ]
f6d0bfde99942b29a6f91273e48abcd2d7a94c93
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L307-L324
train
teaearlgraycold/puni
puni/base.py
UserNotes._compress_json
def _compress_json(self, j): """Compress the BLOB data portion of the usernotes. Arguments: j: the JSON in Schema v5 format (dict) Returns a dict with the 'users' key removed and 'blob' key added """ compressed_json = copy.copy(j) compressed_json.pop('users'...
python
def _compress_json(self, j): """Compress the BLOB data portion of the usernotes. Arguments: j: the JSON in Schema v5 format (dict) Returns a dict with the 'users' key removed and 'blob' key added """ compressed_json = copy.copy(j) compressed_json.pop('users'...
[ "def", "_compress_json", "(", "self", ",", "j", ")", ":", "compressed_json", "=", "copy", ".", "copy", "(", "j", ")", "compressed_json", ".", "pop", "(", "'users'", ",", "None", ")", "compressed_data", "=", "zlib", ".", "compress", "(", "json", ".", "d...
Compress the BLOB data portion of the usernotes. Arguments: j: the JSON in Schema v5 format (dict) Returns a dict with the 'users' key removed and 'blob' key added
[ "Compress", "the", "BLOB", "data", "portion", "of", "the", "usernotes", "." ]
f6d0bfde99942b29a6f91273e48abcd2d7a94c93
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L326-L345
train
teaearlgraycold/puni
puni/base.py
UserNotes.add_note
def add_note(self, note): """Add a note to the usernotes wiki page. Arguments: note: the note to be added (Note) Returns the update message for the usernotes wiki Raises: ValueError when the warning type of the note can not be found in the store...
python
def add_note(self, note): """Add a note to the usernotes wiki page. Arguments: note: the note to be added (Note) Returns the update message for the usernotes wiki Raises: ValueError when the warning type of the note can not be found in the store...
[ "def", "add_note", "(", "self", ",", "note", ")", ":", "notes", "=", "self", ".", "cached_json", "if", "not", "note", ".", "moderator", ":", "note", ".", "moderator", "=", "self", ".", "r", ".", "user", ".", "me", "(", ")", ".", "name", "# Get inde...
Add a note to the usernotes wiki page. Arguments: note: the note to be added (Note) Returns the update message for the usernotes wiki Raises: ValueError when the warning type of the note can not be found in the stored list of warnings.
[ "Add", "a", "note", "to", "the", "usernotes", "wiki", "page", "." ]
f6d0bfde99942b29a6f91273e48abcd2d7a94c93
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L348-L397
train
teaearlgraycold/puni
puni/base.py
UserNotes.remove_note
def remove_note(self, username, index): """Remove a single usernote from the usernotes. Arguments: username: the user that for whom you're removing a note (str) index: the index of the note which is to be removed (int) Returns the update message for the usernotes wiki ...
python
def remove_note(self, username, index): """Remove a single usernote from the usernotes. Arguments: username: the user that for whom you're removing a note (str) index: the index of the note which is to be removed (int) Returns the update message for the usernotes wiki ...
[ "def", "remove_note", "(", "self", ",", "username", ",", "index", ")", ":", "self", ".", "cached_json", "[", "'users'", "]", "[", "username", "]", "[", "'ns'", "]", ".", "pop", "(", "index", ")", "# Go ahead and remove the user's entry if they have no more notes...
Remove a single usernote from the usernotes. Arguments: username: the user that for whom you're removing a note (str) index: the index of the note which is to be removed (int) Returns the update message for the usernotes wiki
[ "Remove", "a", "single", "usernote", "from", "the", "usernotes", "." ]
f6d0bfde99942b29a6f91273e48abcd2d7a94c93
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L400-L415
train
davidblaisonneau-orange/foreman
foreman/puppetClasses.py
PuppetClasses.load
def load(self): """ Function load Get the list of all objects @return RETURN: A ForemanItem list """ cl_tmp = self.api.list(self.objName, limit=self.searchLimit).values() cl = [] for i in cl_tmp: cl.extend(i) return {x[self.index]: ItemPuppetC...
python
def load(self): """ Function load Get the list of all objects @return RETURN: A ForemanItem list """ cl_tmp = self.api.list(self.objName, limit=self.searchLimit).values() cl = [] for i in cl_tmp: cl.extend(i) return {x[self.index]: ItemPuppetC...
[ "def", "load", "(", "self", ")", ":", "cl_tmp", "=", "self", ".", "api", ".", "list", "(", "self", ".", "objName", ",", "limit", "=", "self", ".", "searchLimit", ")", ".", "values", "(", ")", "cl", "=", "[", "]", "for", "i", "in", "cl_tmp", ":"...
Function load Get the list of all objects @return RETURN: A ForemanItem list
[ "Function", "load", "Get", "the", "list", "of", "all", "objects" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/puppetClasses.py#L32-L45
train
mozilla-services/amo2kinto
amo2kinto/exporter.py
is_related_to
def is_related_to(item, app_id, app_ver=None): """Return True if the item relates to the given app_id (and app_ver, if passed).""" versionRange = item.get('versionRange') if not versionRange: return True for vR in versionRange: if not vR.get('targetApplication'): return True...
python
def is_related_to(item, app_id, app_ver=None): """Return True if the item relates to the given app_id (and app_ver, if passed).""" versionRange = item.get('versionRange') if not versionRange: return True for vR in versionRange: if not vR.get('targetApplication'): return True...
[ "def", "is_related_to", "(", "item", ",", "app_id", ",", "app_ver", "=", "None", ")", ":", "versionRange", "=", "item", ".", "get", "(", "'versionRange'", ")", "if", "not", "versionRange", ":", "return", "True", "for", "vR", "in", "versionRange", ":", "i...
Return True if the item relates to the given app_id (and app_ver, if passed).
[ "Return", "True", "if", "the", "item", "relates", "to", "the", "given", "app_id", "(", "and", "app_ver", "if", "passed", ")", "." ]
1ec40647e77cf89badbea4a58d328243daed49a9
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L46-L57
train
mozilla-services/amo2kinto
amo2kinto/exporter.py
get_related_targetApplication
def get_related_targetApplication(vR, app_id, app_ver): """Return the first matching target application in this version range. Returns None if there are no target applications or no matching ones.""" targetApplication = vR.get('targetApplication') if not targetApplication: return None for t...
python
def get_related_targetApplication(vR, app_id, app_ver): """Return the first matching target application in this version range. Returns None if there are no target applications or no matching ones.""" targetApplication = vR.get('targetApplication') if not targetApplication: return None for t...
[ "def", "get_related_targetApplication", "(", "vR", ",", "app_id", ",", "app_ver", ")", ":", "targetApplication", "=", "vR", ".", "get", "(", "'targetApplication'", ")", "if", "not", "targetApplication", ":", "return", "None", "for", "tA", "in", "targetApplicatio...
Return the first matching target application in this version range. Returns None if there are no target applications or no matching ones.
[ "Return", "the", "first", "matching", "target", "application", "in", "this", "version", "range", ".", "Returns", "None", "if", "there", "are", "no", "target", "applications", "or", "no", "matching", "ones", "." ]
1ec40647e77cf89badbea4a58d328243daed49a9
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L60-L78
train
mozilla-services/amo2kinto
amo2kinto/exporter.py
write_addons_items
def write_addons_items(xml_tree, records, app_id, api_ver=3, app_ver=None): """Generate the addons blocklists. <emItem blockID="i372" id="5nc3QHFgcb@r06Ws9gvNNVRfH.com"> <versionRange minVersion="0" maxVersion="*" severity="3"> <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"> ...
python
def write_addons_items(xml_tree, records, app_id, api_ver=3, app_ver=None): """Generate the addons blocklists. <emItem blockID="i372" id="5nc3QHFgcb@r06Ws9gvNNVRfH.com"> <versionRange minVersion="0" maxVersion="*" severity="3"> <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"> ...
[ "def", "write_addons_items", "(", "xml_tree", ",", "records", ",", "app_id", ",", "api_ver", "=", "3", ",", "app_ver", "=", "None", ")", ":", "if", "not", "records", ":", "return", "emItems", "=", "etree", ".", "SubElement", "(", "xml_tree", ",", "'emIte...
Generate the addons blocklists. <emItem blockID="i372" id="5nc3QHFgcb@r06Ws9gvNNVRfH.com"> <versionRange minVersion="0" maxVersion="*" severity="3"> <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"> <versionRange minVersion="39.0a1" maxVersion="*"/> </targetApplication...
[ "Generate", "the", "addons", "blocklists", "." ]
1ec40647e77cf89badbea4a58d328243daed49a9
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L88-L143
train
mozilla-services/amo2kinto
amo2kinto/exporter.py
write_plugin_items
def write_plugin_items(xml_tree, records, app_id, api_ver=3, app_ver=None): """Generate the plugin blocklists. <pluginItem blockID="p422"> <match name="filename" exp="JavaAppletPlugin\\.plugin"/> <versionRange minVersion="Java 7 Update 16" maxVersion="Java 7 Update 24" ...
python
def write_plugin_items(xml_tree, records, app_id, api_ver=3, app_ver=None): """Generate the plugin blocklists. <pluginItem blockID="p422"> <match name="filename" exp="JavaAppletPlugin\\.plugin"/> <versionRange minVersion="Java 7 Update 16" maxVersion="Java 7 Update 24" ...
[ "def", "write_plugin_items", "(", "xml_tree", ",", "records", ",", "app_id", ",", "api_ver", "=", "3", ",", "app_ver", "=", "None", ")", ":", "if", "not", "records", ":", "return", "pluginItems", "=", "etree", ".", "SubElement", "(", "xml_tree", ",", "'p...
Generate the plugin blocklists. <pluginItem blockID="p422"> <match name="filename" exp="JavaAppletPlugin\\.plugin"/> <versionRange minVersion="Java 7 Update 16" maxVersion="Java 7 Update 24" severity="0" vulnerabilitystatus="1"> <targetApplica...
[ "Generate", "the", "plugin", "blocklists", "." ]
1ec40647e77cf89badbea4a58d328243daed49a9
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L152-L182
train
mozilla-services/amo2kinto
amo2kinto/exporter.py
write_gfx_items
def write_gfx_items(xml_tree, records, app_id, api_ver=3): """Generate the gfxBlacklistEntry. <gfxBlacklistEntry blockID="g35"> <os>WINNT 6.1</os> <vendor>0x10de</vendor> <devices> <device>0x0a6c</device> </devices> <feature>DIRECT2D</feature> <featur...
python
def write_gfx_items(xml_tree, records, app_id, api_ver=3): """Generate the gfxBlacklistEntry. <gfxBlacklistEntry blockID="g35"> <os>WINNT 6.1</os> <vendor>0x10de</vendor> <devices> <device>0x0a6c</device> </devices> <feature>DIRECT2D</feature> <featur...
[ "def", "write_gfx_items", "(", "xml_tree", ",", "records", ",", "app_id", ",", "api_ver", "=", "3", ")", ":", "if", "not", "records", ":", "return", "gfxItems", "=", "etree", ".", "SubElement", "(", "xml_tree", ",", "'gfxItems'", ")", "for", "item", "in"...
Generate the gfxBlacklistEntry. <gfxBlacklistEntry blockID="g35"> <os>WINNT 6.1</os> <vendor>0x10de</vendor> <devices> <device>0x0a6c</device> </devices> <feature>DIRECT2D</feature> <featureStatus>BLOCKED_DRIVER_VERSION</featureStatus> <driverVers...
[ "Generate", "the", "gfxBlacklistEntry", "." ]
1ec40647e77cf89badbea4a58d328243daed49a9
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L276-L323
train
mozilla-services/amo2kinto
amo2kinto/exporter.py
write_cert_items
def write_cert_items(xml_tree, records, api_ver=3, app_id=None, app_ver=None): """Generate the certificate blocklists. <certItem issuerName="MIGQMQswCQYD...IENB"> <serialNumber>UoRGnb96CUDTxIqVry6LBg==</serialNumber> </certItem> or <certItem subject='MCIxIDAeBgNVBAMMF0Fub3RoZXIgVGVzdCBFbmQt...
python
def write_cert_items(xml_tree, records, api_ver=3, app_id=None, app_ver=None): """Generate the certificate blocklists. <certItem issuerName="MIGQMQswCQYD...IENB"> <serialNumber>UoRGnb96CUDTxIqVry6LBg==</serialNumber> </certItem> or <certItem subject='MCIxIDAeBgNVBAMMF0Fub3RoZXIgVGVzdCBFbmQt...
[ "def", "write_cert_items", "(", "xml_tree", ",", "records", ",", "api_ver", "=", "3", ",", "app_id", "=", "None", ",", "app_ver", "=", "None", ")", ":", "if", "not", "records", "or", "not", "should_include_certs", "(", "app_id", ",", "app_ver", ")", ":",...
Generate the certificate blocklists. <certItem issuerName="MIGQMQswCQYD...IENB"> <serialNumber>UoRGnb96CUDTxIqVry6LBg==</serialNumber> </certItem> or <certItem subject='MCIxIDAeBgNVBAMMF0Fub3RoZXIgVGVzdCBFbmQtZW50aXR5' pubKeyHash='VCIlmPM9NkgFQtrs4Oa5TeFcDu6MWRTKSNdePEhOgD8='> ...
[ "Generate", "the", "certificate", "blocklists", "." ]
1ec40647e77cf89badbea4a58d328243daed49a9
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L326-L352
train
quantmind/agile-toolkit
agiletoolkit/api/repo.py
GitRepo.label
def label(self, name, color, update=True): """Create or update a label """ url = '%s/labels' % self data = dict(name=name, color=color) response = self.http.post( url, json=data, auth=self.auth, headers=self.headers ) if response.status_code == 201: ...
python
def label(self, name, color, update=True): """Create or update a label """ url = '%s/labels' % self data = dict(name=name, color=color) response = self.http.post( url, json=data, auth=self.auth, headers=self.headers ) if response.status_code == 201: ...
[ "def", "label", "(", "self", ",", "name", ",", "color", ",", "update", "=", "True", ")", ":", "url", "=", "'%s/labels'", "%", "self", "data", "=", "dict", "(", "name", "=", "name", ",", "color", "=", "color", ")", "response", "=", "self", ".", "h...
Create or update a label
[ "Create", "or", "update", "a", "label" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/repo.py#L25-L41
train
aroberge/experimental
experimental/transformers/utils/one2one.py
translate
def translate(source, dictionary): '''A dictionary with a one-to-one translation of keywords is used to provide the transformation. ''' toks = tokenize.generate_tokens(StringIO(source).readline) result = [] for toktype, tokvalue, _, _, _ in toks: if toktype == tokenize.NAME and tokvalue ...
python
def translate(source, dictionary): '''A dictionary with a one-to-one translation of keywords is used to provide the transformation. ''' toks = tokenize.generate_tokens(StringIO(source).readline) result = [] for toktype, tokvalue, _, _, _ in toks: if toktype == tokenize.NAME and tokvalue ...
[ "def", "translate", "(", "source", ",", "dictionary", ")", ":", "toks", "=", "tokenize", ".", "generate_tokens", "(", "StringIO", "(", "source", ")", ".", "readline", ")", "result", "=", "[", "]", "for", "toktype", ",", "tokvalue", ",", "_", ",", "_", ...
A dictionary with a one-to-one translation of keywords is used to provide the transformation.
[ "A", "dictionary", "with", "a", "one", "-", "to", "-", "one", "translation", "of", "keywords", "is", "used", "to", "provide", "the", "transformation", "." ]
031a9be10698b429998436da748b8fdb86f18b47
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/transformers/utils/one2one.py#L12-L23
train
davidblaisonneau-orange/foreman
foreman/itemComputeRessource.py
ItemComputeRessource.enhance
def enhance(self): """ Function enhance Enhance the object with new item or enhanced items """ self.update({'images': SubDict(self.api, self.objName, self.payloadObj, self.key, SubItemImages)})
python
def enhance(self): """ Function enhance Enhance the object with new item or enhanced items """ self.update({'images': SubDict(self.api, self.objName, self.payloadObj, self.key, SubItemImages)})
[ "def", "enhance", "(", "self", ")", ":", "self", ".", "update", "(", "{", "'images'", ":", "SubDict", "(", "self", ".", "api", ",", "self", ".", "objName", ",", "self", ".", "payloadObj", ",", "self", ".", "key", ",", "SubItemImages", ")", "}", ")"...
Function enhance Enhance the object with new item or enhanced items
[ "Function", "enhance", "Enhance", "the", "object", "with", "new", "item", "or", "enhanced", "items" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/itemComputeRessource.py#L34-L41
train
MatterMiners/cobald
cobald/daemon/runners/asyncio_runner.py
AsyncioRunner._run_payloads
async def _run_payloads(self): """Async component of _run""" delay = 0.0 try: while self.running.is_set(): await self._start_payloads() await self._reap_payloads() await asyncio.sleep(delay) delay = min(delay + 0.1, 1.0)...
python
async def _run_payloads(self): """Async component of _run""" delay = 0.0 try: while self.running.is_set(): await self._start_payloads() await self._reap_payloads() await asyncio.sleep(delay) delay = min(delay + 0.1, 1.0)...
[ "async", "def", "_run_payloads", "(", "self", ")", ":", "delay", "=", "0.0", "try", ":", "while", "self", ".", "running", ".", "is_set", "(", ")", ":", "await", "self", ".", "_start_payloads", "(", ")", "await", "self", ".", "_reap_payloads", "(", ")",...
Async component of _run
[ "Async", "component", "of", "_run" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/asyncio_runner.py#L29-L40
train
MatterMiners/cobald
cobald/daemon/runners/asyncio_runner.py
AsyncioRunner._start_payloads
async def _start_payloads(self): """Start all queued payloads""" with self._lock: for coroutine in self._payloads: task = self.event_loop.create_task(coroutine()) self._tasks.add(task) self._payloads.clear() await asyncio.sleep(0)
python
async def _start_payloads(self): """Start all queued payloads""" with self._lock: for coroutine in self._payloads: task = self.event_loop.create_task(coroutine()) self._tasks.add(task) self._payloads.clear() await asyncio.sleep(0)
[ "async", "def", "_start_payloads", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "for", "coroutine", "in", "self", ".", "_payloads", ":", "task", "=", "self", ".", "event_loop", ".", "create_task", "(", "coroutine", "(", ")", ")", "self", "...
Start all queued payloads
[ "Start", "all", "queued", "payloads" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/asyncio_runner.py#L42-L49
train
MatterMiners/cobald
cobald/daemon/runners/asyncio_runner.py
AsyncioRunner._reap_payloads
async def _reap_payloads(self): """Clean up all finished payloads""" for task in self._tasks.copy(): if task.done(): self._tasks.remove(task) if task.exception() is not None: raise task.exception() await asyncio.sleep(0)
python
async def _reap_payloads(self): """Clean up all finished payloads""" for task in self._tasks.copy(): if task.done(): self._tasks.remove(task) if task.exception() is not None: raise task.exception() await asyncio.sleep(0)
[ "async", "def", "_reap_payloads", "(", "self", ")", ":", "for", "task", "in", "self", ".", "_tasks", ".", "copy", "(", ")", ":", "if", "task", ".", "done", "(", ")", ":", "self", ".", "_tasks", ".", "remove", "(", "task", ")", "if", "task", ".", ...
Clean up all finished payloads
[ "Clean", "up", "all", "finished", "payloads" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/asyncio_runner.py#L51-L58
train
MatterMiners/cobald
cobald/daemon/runners/asyncio_runner.py
AsyncioRunner._cancel_payloads
async def _cancel_payloads(self): """Cancel all remaining payloads""" for task in self._tasks: task.cancel() await asyncio.sleep(0) for task in self._tasks: while not task.done(): await asyncio.sleep(0.1) task.cancel()
python
async def _cancel_payloads(self): """Cancel all remaining payloads""" for task in self._tasks: task.cancel() await asyncio.sleep(0) for task in self._tasks: while not task.done(): await asyncio.sleep(0.1) task.cancel()
[ "async", "def", "_cancel_payloads", "(", "self", ")", ":", "for", "task", "in", "self", ".", "_tasks", ":", "task", ".", "cancel", "(", ")", "await", "asyncio", ".", "sleep", "(", "0", ")", "for", "task", "in", "self", ".", "_tasks", ":", "while", ...
Cancel all remaining payloads
[ "Cancel", "all", "remaining", "payloads" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/asyncio_runner.py#L60-L68
train
Karaage-Cluster/python-tldap
tldap/ldap_passwd.py
check_password
def check_password(password: str, encrypted: str) -> bool: """ Check a plaintext password against a hashed password. """ # some old passwords have {crypt} in lower case, and passlib wants it to be # in upper case. if encrypted.startswith("{crypt}"): encrypted = "{CRYPT}" + encrypted[7:] retu...
python
def check_password(password: str, encrypted: str) -> bool: """ Check a plaintext password against a hashed password. """ # some old passwords have {crypt} in lower case, and passlib wants it to be # in upper case. if encrypted.startswith("{crypt}"): encrypted = "{CRYPT}" + encrypted[7:] retu...
[ "def", "check_password", "(", "password", ":", "str", ",", "encrypted", ":", "str", ")", "->", "bool", ":", "# some old passwords have {crypt} in lower case, and passlib wants it to be", "# in upper case.", "if", "encrypted", ".", "startswith", "(", "\"{crypt}\"", ")", ...
Check a plaintext password against a hashed password.
[ "Check", "a", "plaintext", "password", "against", "a", "hashed", "password", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/ldap_passwd.py#L36-L42
train
quantmind/agile-toolkit
agiletoolkit/github/validate.py
validate
def validate(ctx, sandbox): """Check if version of repository is semantic """ m = RepoManager(ctx.obj['agile']) if not sandbox or m.can_release('sandbox'): click.echo(m.validate_version())
python
def validate(ctx, sandbox): """Check if version of repository is semantic """ m = RepoManager(ctx.obj['agile']) if not sandbox or m.can_release('sandbox'): click.echo(m.validate_version())
[ "def", "validate", "(", "ctx", ",", "sandbox", ")", ":", "m", "=", "RepoManager", "(", "ctx", ".", "obj", "[", "'agile'", "]", ")", "if", "not", "sandbox", "or", "m", ".", "can_release", "(", "'sandbox'", ")", ":", "click", ".", "echo", "(", "m", ...
Check if version of repository is semantic
[ "Check", "if", "version", "of", "repository", "is", "semantic" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/github/validate.py#L11-L16
train
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.reset
def reset(self, force_flush_cache: bool = False) -> None: """ Reset transaction back to original state, discarding all uncompleted transactions. """ super(LDAPwrapper, self).reset() if len(self._transactions) == 0: raise RuntimeError("reset called outside a tr...
python
def reset(self, force_flush_cache: bool = False) -> None: """ Reset transaction back to original state, discarding all uncompleted transactions. """ super(LDAPwrapper, self).reset() if len(self._transactions) == 0: raise RuntimeError("reset called outside a tr...
[ "def", "reset", "(", "self", ",", "force_flush_cache", ":", "bool", "=", "False", ")", "->", "None", ":", "super", "(", "LDAPwrapper", ",", "self", ")", ".", "reset", "(", ")", "if", "len", "(", "self", ".", "_transactions", ")", "==", "0", ":", "r...
Reset transaction back to original state, discarding all uncompleted transactions.
[ "Reset", "transaction", "back", "to", "original", "state", "discarding", "all", "uncompleted", "transactions", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L68-L76
train
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper._cache_get_for_dn
def _cache_get_for_dn(self, dn: str) -> Dict[str, bytes]: """ Object state is cached. When an update is required the update will be simulated on this cache, so that rollback information can be correct. This function retrieves the cached data. """ # no cached item, retrie...
python
def _cache_get_for_dn(self, dn: str) -> Dict[str, bytes]: """ Object state is cached. When an update is required the update will be simulated on this cache, so that rollback information can be correct. This function retrieves the cached data. """ # no cached item, retrie...
[ "def", "_cache_get_for_dn", "(", "self", ",", "dn", ":", "str", ")", "->", "Dict", "[", "str", ",", "bytes", "]", ":", "# no cached item, retrieve from ldap", "self", ".", "_do_with_retry", "(", "lambda", "obj", ":", "obj", ".", "search", "(", "dn", ",", ...
Object state is cached. When an update is required the update will be simulated on this cache, so that rollback information can be correct. This function retrieves the cached data.
[ "Object", "state", "is", "cached", ".", "When", "an", "update", "is", "required", "the", "update", "will", "be", "simulated", "on", "this", "cache", "so", "that", "rollback", "information", "can", "be", "correct", ".", "This", "function", "retrieves", "the",...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L78-L98
train
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.is_dirty
def is_dirty(self) -> bool: """ Are there uncommitted changes? """ if len(self._transactions) == 0: raise RuntimeError("is_dirty called outside a transaction.") if len(self._transactions[-1]) > 0: return True return False
python
def is_dirty(self) -> bool: """ Are there uncommitted changes? """ if len(self._transactions) == 0: raise RuntimeError("is_dirty called outside a transaction.") if len(self._transactions[-1]) > 0: return True return False
[ "def", "is_dirty", "(", "self", ")", "->", "bool", ":", "if", "len", "(", "self", ".", "_transactions", ")", "==", "0", ":", "raise", "RuntimeError", "(", "\"is_dirty called outside a transaction.\"", ")", "if", "len", "(", "self", ".", "_transactions", "[",...
Are there uncommitted changes?
[ "Are", "there", "uncommitted", "changes?" ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L104-L110
train
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.leave_transaction_management
def leave_transaction_management(self) -> None: """ End a transaction. Must not be dirty when doing so. ie. commit() or rollback() must be called if changes made. If dirty, changes will be discarded. """ if len(self._transactions) == 0: raise RuntimeError("lea...
python
def leave_transaction_management(self) -> None: """ End a transaction. Must not be dirty when doing so. ie. commit() or rollback() must be called if changes made. If dirty, changes will be discarded. """ if len(self._transactions) == 0: raise RuntimeError("lea...
[ "def", "leave_transaction_management", "(", "self", ")", "->", "None", ":", "if", "len", "(", "self", ".", "_transactions", ")", "==", "0", ":", "raise", "RuntimeError", "(", "\"leave_transaction_management called outside transaction\"", ")", "elif", "len", "(", "...
End a transaction. Must not be dirty when doing so. ie. commit() or rollback() must be called if changes made. If dirty, changes will be discarded.
[ "End", "a", "transaction", ".", "Must", "not", "be", "dirty", "when", "doing", "so", ".", "ie", ".", "commit", "()", "or", "rollback", "()", "must", "be", "called", "if", "changes", "made", ".", "If", "dirty", "changes", "will", "be", "discarded", "." ...
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L120-L131
train
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.commit
def commit(self) -> None: """ Attempt to commit all changes to LDAP database. i.e. forget all rollbacks. However stay inside transaction management. """ if len(self._transactions) == 0: raise RuntimeError("commit called outside transaction") # If we have nes...
python
def commit(self) -> None: """ Attempt to commit all changes to LDAP database. i.e. forget all rollbacks. However stay inside transaction management. """ if len(self._transactions) == 0: raise RuntimeError("commit called outside transaction") # If we have nes...
[ "def", "commit", "(", "self", ")", "->", "None", ":", "if", "len", "(", "self", ".", "_transactions", ")", "==", "0", ":", "raise", "RuntimeError", "(", "\"commit called outside transaction\"", ")", "# If we have nested transactions, we don't actually commit, but push",...
Attempt to commit all changes to LDAP database. i.e. forget all rollbacks. However stay inside transaction management.
[ "Attempt", "to", "commit", "all", "changes", "to", "LDAP", "database", ".", "i", ".", "e", ".", "forget", "all", "rollbacks", ".", "However", "stay", "inside", "transaction", "management", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L133-L148
train
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.rollback
def rollback(self) -> None: """ Roll back to previous database state. However stay inside transaction management. """ if len(self._transactions) == 0: raise RuntimeError("rollback called outside transaction") _debug("rollback:", self._transactions[-1]) ...
python
def rollback(self) -> None: """ Roll back to previous database state. However stay inside transaction management. """ if len(self._transactions) == 0: raise RuntimeError("rollback called outside transaction") _debug("rollback:", self._transactions[-1]) ...
[ "def", "rollback", "(", "self", ")", "->", "None", ":", "if", "len", "(", "self", ".", "_transactions", ")", "==", "0", ":", "raise", "RuntimeError", "(", "\"rollback called outside transaction\"", ")", "_debug", "(", "\"rollback:\"", ",", "self", ".", "_tra...
Roll back to previous database state. However stay inside transaction management.
[ "Roll", "back", "to", "previous", "database", "state", ".", "However", "stay", "inside", "transaction", "management", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L150-L175
train
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper._process
def _process(self, on_commit: UpdateCallable, on_rollback: UpdateCallable) -> Any: """ Process action. oncommit is a callback to execute action, onrollback is a callback to execute if the oncommit() has been called and a rollback is required """ _debug("---> commiting", ...
python
def _process(self, on_commit: UpdateCallable, on_rollback: UpdateCallable) -> Any: """ Process action. oncommit is a callback to execute action, onrollback is a callback to execute if the oncommit() has been called and a rollback is required """ _debug("---> commiting", ...
[ "def", "_process", "(", "self", ",", "on_commit", ":", "UpdateCallable", ",", "on_rollback", ":", "UpdateCallable", ")", "->", "Any", ":", "_debug", "(", "\"---> commiting\"", ",", "on_commit", ")", "result", "=", "self", ".", "_do_with_retry", "(", "on_commit...
Process action. oncommit is a callback to execute action, onrollback is a callback to execute if the oncommit() has been called and a rollback is required
[ "Process", "action", ".", "oncommit", "is", "a", "callback", "to", "execute", "action", "onrollback", "is", "a", "callback", "to", "execute", "if", "the", "oncommit", "()", "has", "been", "called", "and", "a", "rollback", "is", "required" ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L177-L191
train
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.add
def add(self, dn: str, mod_list: dict) -> None: """ Add a DN to the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ _debug("add", self, dn, mod_list) # if rollback of add required, delete it def on_commit(obj): ob...
python
def add(self, dn: str, mod_list: dict) -> None: """ Add a DN to the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ _debug("add", self, dn, mod_list) # if rollback of add required, delete it def on_commit(obj): ob...
[ "def", "add", "(", "self", ",", "dn", ":", "str", ",", "mod_list", ":", "dict", ")", "->", "None", ":", "_debug", "(", "\"add\"", ",", "self", ",", "dn", ",", "mod_list", ")", "# if rollback of add required, delete it", "def", "on_commit", "(", "obj", ")...
Add a DN to the LDAP database; See ldap module. Doesn't return a result if transactions enabled.
[ "Add", "a", "DN", "to", "the", "LDAP", "database", ";", "See", "ldap", "module", ".", "Doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L197-L213
train
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.modify
def modify(self, dn: str, mod_list: dict) -> None: """ Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ _debug("modify", self, dn, mod_list) # need to work out how to reverse changes in mod_list; result in revlist ...
python
def modify(self, dn: str, mod_list: dict) -> None: """ Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ _debug("modify", self, dn, mod_list) # need to work out how to reverse changes in mod_list; result in revlist ...
[ "def", "modify", "(", "self", ",", "dn", ":", "str", ",", "mod_list", ":", "dict", ")", "->", "None", ":", "_debug", "(", "\"modify\"", ",", "self", ",", "dn", ",", "mod_list", ")", "# need to work out how to reverse changes in mod_list; result in revlist", "rev...
Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled.
[ "Modify", "a", "DN", "in", "the", "LDAP", "database", ";", "See", "ldap", "module", ".", "Doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L215-L294
train
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.modify_no_rollback
def modify_no_rollback(self, dn: str, mod_list: dict): """ Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ _debug("modify_no_rollback", self, dn, mod_list) result = self._do_with_retry(lambda obj: obj.modify_s(dn, m...
python
def modify_no_rollback(self, dn: str, mod_list: dict): """ Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ _debug("modify_no_rollback", self, dn, mod_list) result = self._do_with_retry(lambda obj: obj.modify_s(dn, m...
[ "def", "modify_no_rollback", "(", "self", ",", "dn", ":", "str", ",", "mod_list", ":", "dict", ")", ":", "_debug", "(", "\"modify_no_rollback\"", ",", "self", ",", "dn", ",", "mod_list", ")", "result", "=", "self", ".", "_do_with_retry", "(", "lambda", "...
Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled.
[ "Modify", "a", "DN", "in", "the", "LDAP", "database", ";", "See", "ldap", "module", ".", "Doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L296-L306
train
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.delete
def delete(self, dn: str) -> None: """ delete a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ _debug("delete", self) # get copy of cache result = self._cache_get_for_dn(dn) # remove special values that ca...
python
def delete(self, dn: str) -> None: """ delete a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ _debug("delete", self) # get copy of cache result = self._cache_get_for_dn(dn) # remove special values that ca...
[ "def", "delete", "(", "self", ",", "dn", ":", "str", ")", "->", "None", ":", "_debug", "(", "\"delete\"", ",", "self", ")", "# get copy of cache", "result", "=", "self", ".", "_cache_get_for_dn", "(", "dn", ")", "# remove special values that can't be added", "...
delete a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled.
[ "delete", "a", "dn", "in", "the", "ldap", "database", ";", "see", "ldap", "module", ".", "doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L308-L347
train
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.rename
def rename(self, dn: str, new_rdn: str, new_base_dn: Optional[str] = None) -> None: """ rename a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ _debug("rename", self, dn, new_rdn, new_base_dn) # split up the parameters ...
python
def rename(self, dn: str, new_rdn: str, new_base_dn: Optional[str] = None) -> None: """ rename a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ _debug("rename", self, dn, new_rdn, new_base_dn) # split up the parameters ...
[ "def", "rename", "(", "self", ",", "dn", ":", "str", ",", "new_rdn", ":", "str", ",", "new_base_dn", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "_debug", "(", "\"rename\"", ",", "self", ",", "dn", ",", "new_rdn", ",", ...
rename a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled.
[ "rename", "a", "dn", "in", "the", "ldap", "database", ";", "see", "ldap", "module", ".", "doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L349-L385
train
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.fail
def fail(self) -> None: """ for testing purposes only. always fail in commit """ _debug("fail") # on commit carry out action; on rollback reverse rename def on_commit(_obj): raise_testfailure("commit") def on_rollback(_obj): raise_testfailure("rollback"...
python
def fail(self) -> None: """ for testing purposes only. always fail in commit """ _debug("fail") # on commit carry out action; on rollback reverse rename def on_commit(_obj): raise_testfailure("commit") def on_rollback(_obj): raise_testfailure("rollback"...
[ "def", "fail", "(", "self", ")", "->", "None", ":", "_debug", "(", "\"fail\"", ")", "# on commit carry out action; on rollback reverse rename", "def", "on_commit", "(", "_obj", ")", ":", "raise_testfailure", "(", "\"commit\"", ")", "def", "on_rollback", "(", "_obj...
for testing purposes only. always fail in commit
[ "for", "testing", "purposes", "only", ".", "always", "fail", "in", "commit" ]
61f1af74a3648cb6491e7eeb1ee2eb395d67bf59
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L387-L399
train
aroberge/experimental
experimental/transformers/int_seq.py
__experimental_range
def __experimental_range(start, stop, var, cond, loc={}): '''Utility function made to reproduce range() with unit integer step but with the added possibility of specifying a condition on the looping variable (e.g. var % 2 == 0) ''' locals().update(loc) if start < stop: for __ in ...
python
def __experimental_range(start, stop, var, cond, loc={}): '''Utility function made to reproduce range() with unit integer step but with the added possibility of specifying a condition on the looping variable (e.g. var % 2 == 0) ''' locals().update(loc) if start < stop: for __ in ...
[ "def", "__experimental_range", "(", "start", ",", "stop", ",", "var", ",", "cond", ",", "loc", "=", "{", "}", ")", ":", "locals", "(", ")", ".", "update", "(", "loc", ")", "if", "start", "<", "stop", ":", "for", "__", "in", "range", "(", "start",...
Utility function made to reproduce range() with unit integer step but with the added possibility of specifying a condition on the looping variable (e.g. var % 2 == 0)
[ "Utility", "function", "made", "to", "reproduce", "range", "()", "with", "unit", "integer", "step", "but", "with", "the", "added", "possibility", "of", "specifying", "a", "condition", "on", "the", "looping", "variable", "(", "e", ".", "g", ".", "var", "%",...
031a9be10698b429998436da748b8fdb86f18b47
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/transformers/int_seq.py#L51-L66
train
aroberge/experimental
experimental/transformers/int_seq.py
create_for
def create_for(line, search_result): '''Create a new "for loop" line as a replacement for the original code. ''' try: return line.format(search_result.group("indented_for"), search_result.group("var"), search_result.group("start"), ...
python
def create_for(line, search_result): '''Create a new "for loop" line as a replacement for the original code. ''' try: return line.format(search_result.group("indented_for"), search_result.group("var"), search_result.group("start"), ...
[ "def", "create_for", "(", "line", ",", "search_result", ")", ":", "try", ":", "return", "line", ".", "format", "(", "search_result", ".", "group", "(", "\"indented_for\"", ")", ",", "search_result", ".", "group", "(", "\"var\"", ")", ",", "search_result", ...
Create a new "for loop" line as a replacement for the original code.
[ "Create", "a", "new", "for", "loop", "line", "as", "a", "replacement", "for", "the", "original", "code", "." ]
031a9be10698b429998436da748b8fdb86f18b47
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/transformers/int_seq.py#L180-L193
train
davidblaisonneau-orange/foreman
foreman/itemSmartClassParameter.py
ItemSmartClassParameter.setOverrideValue
def setOverrideValue(self, attributes, hostName): """ Function __setitem__ Set a parameter of a foreman object as a dict @param key: The key to modify @param attribute: The data @return RETURN: The API result """ self['override'] = True attrType = type(at...
python
def setOverrideValue(self, attributes, hostName): """ Function __setitem__ Set a parameter of a foreman object as a dict @param key: The key to modify @param attribute: The data @return RETURN: The API result """ self['override'] = True attrType = type(at...
[ "def", "setOverrideValue", "(", "self", ",", "attributes", ",", "hostName", ")", ":", "self", "[", "'override'", "]", "=", "True", "attrType", "=", "type", "(", "attributes", ")", "if", "attrType", "is", "dict", ":", "self", "[", "'parameter_type'", "]", ...
Function __setitem__ Set a parameter of a foreman object as a dict @param key: The key to modify @param attribute: The data @return RETURN: The API result
[ "Function", "__setitem__", "Set", "a", "parameter", "of", "a", "foreman", "object", "as", "a", "dict" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/itemSmartClassParameter.py#L87-L113
train
developersociety/django-glitter
glitter/reminders/models.py
Reminder.get_interval_timedelta
def get_interval_timedelta(self): """ Spits out the timedelta in days. """ now_datetime = timezone.now() current_month_days = monthrange(now_datetime.year, now_datetime.month)[1] # Two weeks if self.interval == reminders_choices.INTERVAL_2_WEEKS: interval_timedelta ...
python
def get_interval_timedelta(self): """ Spits out the timedelta in days. """ now_datetime = timezone.now() current_month_days = monthrange(now_datetime.year, now_datetime.month)[1] # Two weeks if self.interval == reminders_choices.INTERVAL_2_WEEKS: interval_timedelta ...
[ "def", "get_interval_timedelta", "(", "self", ")", ":", "now_datetime", "=", "timezone", ".", "now", "(", ")", "current_month_days", "=", "monthrange", "(", "now_datetime", ".", "year", ",", "now_datetime", ".", "month", ")", "[", "1", "]", "# Two weeks", "i...
Spits out the timedelta in days.
[ "Spits", "out", "the", "timedelta", "in", "days", "." ]
2c0280ec83afee80deee94ee3934fc54239c2e87
https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/reminders/models.py#L34-L63
train
MatterMiners/cobald
cobald/daemon/runners/asyncio_watcher.py
awaitable_runner
async def awaitable_runner(runner: BaseRunner): """Execute a runner without blocking the event loop""" runner_thread = CapturingThread(target=runner.run) runner_thread.start() delay = 0.0 while not runner_thread.join(timeout=0): await asyncio.sleep(delay) delay = min(delay + 0.1, 1.0...
python
async def awaitable_runner(runner: BaseRunner): """Execute a runner without blocking the event loop""" runner_thread = CapturingThread(target=runner.run) runner_thread.start() delay = 0.0 while not runner_thread.join(timeout=0): await asyncio.sleep(delay) delay = min(delay + 0.1, 1.0...
[ "async", "def", "awaitable_runner", "(", "runner", ":", "BaseRunner", ")", ":", "runner_thread", "=", "CapturingThread", "(", "target", "=", "runner", ".", "run", ")", "runner_thread", ".", "start", "(", ")", "delay", "=", "0.0", "while", "not", "runner_thre...
Execute a runner without blocking the event loop
[ "Execute", "a", "runner", "without", "blocking", "the", "event", "loop" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/asyncio_watcher.py#L9-L16
train
MatterMiners/cobald
cobald/daemon/runners/asyncio_watcher.py
asyncio_main_run
def asyncio_main_run(root_runner: BaseRunner): """ Create an ``asyncio`` event loop running in the main thread and watching runners Using ``asyncio`` to handle suprocesses requires a specific loop type to run in the main thread. This function sets up and runs the correct loop in a portable way. In ...
python
def asyncio_main_run(root_runner: BaseRunner): """ Create an ``asyncio`` event loop running in the main thread and watching runners Using ``asyncio`` to handle suprocesses requires a specific loop type to run in the main thread. This function sets up and runs the correct loop in a portable way. In ...
[ "def", "asyncio_main_run", "(", "root_runner", ":", "BaseRunner", ")", ":", "assert", "threading", ".", "current_thread", "(", ")", "==", "threading", ".", "main_thread", "(", ")", ",", "'only main thread can accept asyncio subprocesses'", "if", "sys", ".", "platfor...
Create an ``asyncio`` event loop running in the main thread and watching runners Using ``asyncio`` to handle suprocesses requires a specific loop type to run in the main thread. This function sets up and runs the correct loop in a portable way. In addition, it runs a single :py:class:`~.BaseRunner` until c...
[ "Create", "an", "asyncio", "event", "loop", "running", "in", "the", "main", "thread", "and", "watching", "runners" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/asyncio_watcher.py#L19-L36
train
davidblaisonneau-orange/foreman
foreman/itemConfigTemplate.py
ItemConfigTemplate.enhance
def enhance(self): """ Function enhance Enhance the object with new item or enhanced items """ self.update({'os_default_templates': SubDict(self.api, self.objName, self.payloadObj, self.key, SubItemOsDefaultTe...
python
def enhance(self): """ Function enhance Enhance the object with new item or enhanced items """ self.update({'os_default_templates': SubDict(self.api, self.objName, self.payloadObj, self.key, SubItemOsDefaultTe...
[ "def", "enhance", "(", "self", ")", ":", "self", ".", "update", "(", "{", "'os_default_templates'", ":", "SubDict", "(", "self", ".", "api", ",", "self", ".", "objName", ",", "self", ".", "payloadObj", ",", "self", ".", "key", ",", "SubItemOsDefaultTempl...
Function enhance Enhance the object with new item or enhanced items
[ "Function", "enhance", "Enhance", "the", "object", "with", "new", "item", "or", "enhanced", "items" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/itemConfigTemplate.py#L37-L48
train
qubell/contrib-python-qubell-client
qubell/api/tools/__init__.py
retry
def retry(tries=10, delay=1, backoff=2, retry_exception=None): """ Retry "tries" times, with initial "delay", increasing delay "delay*backoff" each time. Without exception success means when function returns valid object. With exception success when no exceptions """ assert tries > 0, "tries mus...
python
def retry(tries=10, delay=1, backoff=2, retry_exception=None): """ Retry "tries" times, with initial "delay", increasing delay "delay*backoff" each time. Without exception success means when function returns valid object. With exception success when no exceptions """ assert tries > 0, "tries mus...
[ "def", "retry", "(", "tries", "=", "10", ",", "delay", "=", "1", ",", "backoff", "=", "2", ",", "retry_exception", "=", "None", ")", ":", "assert", "tries", ">", "0", ",", "\"tries must be 1 or greater\"", "catching_mode", "=", "bool", "(", "retry_exceptio...
Retry "tries" times, with initial "delay", increasing delay "delay*backoff" each time. Without exception success means when function returns valid object. With exception success when no exceptions
[ "Retry", "tries", "times", "with", "initial", "delay", "increasing", "delay", "delay", "*", "backoff", "each", "time", ".", "Without", "exception", "success", "means", "when", "function", "returns", "valid", "object", ".", "With", "exception", "success", "when",...
4586ea11d5103c2ff9607d3ed922b5a0991b8845
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/tools/__init__.py#L37-L71
train
qubell/contrib-python-qubell-client
qubell/api/tools/__init__.py
dump
def dump(node): """ Dump initialized object structure to yaml """ from qubell.api.private.platform import Auth, QubellPlatform from qubell.api.private.organization import Organization from qubell.api.private.application import Application from qubell.api.private.instance import Instance fro...
python
def dump(node): """ Dump initialized object structure to yaml """ from qubell.api.private.platform import Auth, QubellPlatform from qubell.api.private.organization import Organization from qubell.api.private.application import Application from qubell.api.private.instance import Instance fro...
[ "def", "dump", "(", "node", ")", ":", "from", "qubell", ".", "api", ".", "private", ".", "platform", "import", "Auth", ",", "QubellPlatform", "from", "qubell", ".", "api", ".", "private", ".", "organization", "import", "Organization", "from", "qubell", "."...
Dump initialized object structure to yaml
[ "Dump", "initialized", "object", "structure", "to", "yaml" ]
4586ea11d5103c2ff9607d3ed922b5a0991b8845
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/tools/__init__.py#L145-L191
train
qubell/contrib-python-qubell-client
qubell/api/tools/__init__.py
load_env
def load_env(file): """ Generate environment used for 'org.restore' method :param file: env file :return: env """ env = yaml.load(open(file)) for org in env.get('organizations', []): if not org.get('applications'): org['applications'] = [] if org.get('starter-k...
python
def load_env(file): """ Generate environment used for 'org.restore' method :param file: env file :return: env """ env = yaml.load(open(file)) for org in env.get('organizations', []): if not org.get('applications'): org['applications'] = [] if org.get('starter-k...
[ "def", "load_env", "(", "file", ")", ":", "env", "=", "yaml", ".", "load", "(", "open", "(", "file", ")", ")", "for", "org", "in", "env", ".", "get", "(", "'organizations'", ",", "[", "]", ")", ":", "if", "not", "org", ".", "get", "(", "'applic...
Generate environment used for 'org.restore' method :param file: env file :return: env
[ "Generate", "environment", "used", "for", "org", ".", "restore", "method", ":", "param", "file", ":", "env", "file", ":", "return", ":", "env" ]
4586ea11d5103c2ff9607d3ed922b5a0991b8845
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/tools/__init__.py#L198-L223
train
qubell/contrib-python-qubell-client
qubell/api/tools/__init__.py
patch_env
def patch_env(env, path, value): """ Set specified value to yaml path. Example: patch('application/components/child/configuration/__locator.application-id','777') Will change child app ID to 777 """ def pathGet(dictionary, path): for item in path.split("/"): ...
python
def patch_env(env, path, value): """ Set specified value to yaml path. Example: patch('application/components/child/configuration/__locator.application-id','777') Will change child app ID to 777 """ def pathGet(dictionary, path): for item in path.split("/"): ...
[ "def", "patch_env", "(", "env", ",", "path", ",", "value", ")", ":", "def", "pathGet", "(", "dictionary", ",", "path", ")", ":", "for", "item", "in", "path", ".", "split", "(", "\"/\"", ")", ":", "dictionary", "=", "dictionary", "[", "item", "]", "...
Set specified value to yaml path. Example: patch('application/components/child/configuration/__locator.application-id','777') Will change child app ID to 777
[ "Set", "specified", "value", "to", "yaml", "path", ".", "Example", ":", "patch", "(", "application", "/", "components", "/", "child", "/", "configuration", "/", "__locator", ".", "application", "-", "id", "777", ")", "Will", "change", "child", "app", "ID",...
4586ea11d5103c2ff9607d3ed922b5a0991b8845
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/tools/__init__.py#L248-L266
train
qubell/contrib-python-qubell-client
qubell/api/tools/__init__.py
get_starter_kit_meta
def get_starter_kit_meta(name): """ Extract metadata link for starter kit from platform configs. Starter kit available on add component - starter kit menu. Beware, config could be changed by deploy scripts during deploy. :param name: Name of starter kit :return: Link to metadata """ kits = y...
python
def get_starter_kit_meta(name): """ Extract metadata link for starter kit from platform configs. Starter kit available on add component - starter kit menu. Beware, config could be changed by deploy scripts during deploy. :param name: Name of starter kit :return: Link to metadata """ kits = y...
[ "def", "get_starter_kit_meta", "(", "name", ")", ":", "kits", "=", "yaml", ".", "safe_load", "(", "requests", ".", "get", "(", "url", "=", "starter_kits_url", ")", ".", "content", ")", "[", "'kits'", "]", "kits_meta_url", "=", "[", "x", "[", "'metaUrl'",...
Extract metadata link for starter kit from platform configs. Starter kit available on add component - starter kit menu. Beware, config could be changed by deploy scripts during deploy. :param name: Name of starter kit :return: Link to metadata
[ "Extract", "metadata", "link", "for", "starter", "kit", "from", "platform", "configs", ".", "Starter", "kit", "available", "on", "add", "component", "-", "starter", "kit", "menu", ".", "Beware", "config", "could", "be", "changed", "by", "deploy", "scripts", ...
4586ea11d5103c2ff9607d3ed922b5a0991b8845
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/tools/__init__.py#L298-L310
train
qubell/contrib-python-qubell-client
qubell/api/tools/__init__.py
get_manifest_from_meta
def get_manifest_from_meta(metaurl, name): """ Extact manifest url from metadata url :param metaurl: Url to metadata :param name: Name of application to extract :return: """ if 'http' in metaurl: kit = yaml.safe_load(requests.get(url=metaurl).content)['kit']['applications'] else:...
python
def get_manifest_from_meta(metaurl, name): """ Extact manifest url from metadata url :param metaurl: Url to metadata :param name: Name of application to extract :return: """ if 'http' in metaurl: kit = yaml.safe_load(requests.get(url=metaurl).content)['kit']['applications'] else:...
[ "def", "get_manifest_from_meta", "(", "metaurl", ",", "name", ")", ":", "if", "'http'", "in", "metaurl", ":", "kit", "=", "yaml", ".", "safe_load", "(", "requests", ".", "get", "(", "url", "=", "metaurl", ")", ".", "content", ")", "[", "'kit'", "]", ...
Extact manifest url from metadata url :param metaurl: Url to metadata :param name: Name of application to extract :return:
[ "Extact", "manifest", "url", "from", "metadata", "url", ":", "param", "metaurl", ":", "Url", "to", "metadata", ":", "param", "name", ":", "Name", "of", "application", "to", "extract", ":", "return", ":" ]
4586ea11d5103c2ff9607d3ed922b5a0991b8845
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/tools/__init__.py#L312-L325
train
davidblaisonneau-orange/foreman
foreman/subItem.py
SubItem.getPayloadStruct
def getPayloadStruct(self, attributes, objType=None): """ Function getPayloadStruct Get the payload structure to do a creation or a modification @param key: The key to modify @param attribute: The data @param objType: NOT USED in this class @return RETURN: The API result...
python
def getPayloadStruct(self, attributes, objType=None): """ Function getPayloadStruct Get the payload structure to do a creation or a modification @param key: The key to modify @param attribute: The data @param objType: NOT USED in this class @return RETURN: The API result...
[ "def", "getPayloadStruct", "(", "self", ",", "attributes", ",", "objType", "=", "None", ")", ":", "if", "self", ".", "setInParentPayload", ":", "return", "{", "self", ".", "parentPayloadObject", ":", "{", "self", ".", "payloadObj", ":", "attributes", "}", ...
Function getPayloadStruct Get the payload structure to do a creation or a modification @param key: The key to modify @param attribute: The data @param objType: NOT USED in this class @return RETURN: The API result
[ "Function", "getPayloadStruct", "Get", "the", "payload", "structure", "to", "do", "a", "creation", "or", "a", "modification" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/subItem.py#L50-L63
train
davidblaisonneau-orange/foreman
foreman/api.py
Api.log
def log(function): """ Function log Decorator to log lasts request before sending a new one @return RETURN: None """ def _log(self, *args, **kwargs): ret = function(self, *args, **kwargs) if len(self.history) > self.maxHistory: self.histor...
python
def log(function): """ Function log Decorator to log lasts request before sending a new one @return RETURN: None """ def _log(self, *args, **kwargs): ret = function(self, *args, **kwargs) if len(self.history) > self.maxHistory: self.histor...
[ "def", "log", "(", "function", ")", ":", "def", "_log", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "function", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "if", "len", "(", "self", ".", "his...
Function log Decorator to log lasts request before sending a new one @return RETURN: None
[ "Function", "log", "Decorator", "to", "log", "lasts", "request", "before", "sending", "a", "new", "one" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/api.py#L50-L69
train
davidblaisonneau-orange/foreman
foreman/api.py
Api.clearReqVars
def clearReqVars(self): """ Function clearHistVars Clear the variables used to get history of all vars @return RETURN: None """ self.errorMsg = None self.payload = None self.url = None self.resp = None self.res = None self.method = None ...
python
def clearReqVars(self): """ Function clearHistVars Clear the variables used to get history of all vars @return RETURN: None """ self.errorMsg = None self.payload = None self.url = None self.resp = None self.res = None self.method = None ...
[ "def", "clearReqVars", "(", "self", ")", ":", "self", ".", "errorMsg", "=", "None", "self", ".", "payload", "=", "None", "self", ".", "url", "=", "None", "self", ".", "resp", "=", "None", "self", ".", "res", "=", "None", "self", ".", "method", "=",...
Function clearHistVars Clear the variables used to get history of all vars @return RETURN: None
[ "Function", "clearHistVars", "Clear", "the", "variables", "used", "to", "get", "history", "of", "all", "vars" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/api.py#L71-L83
train
davidblaisonneau-orange/foreman
foreman/api.py
Api.list
def list(self, obj, filter=False, only_id=False, limit=20): """ Function list Get the list of an object @param obj: object name ('hosts', 'puppetclasses'...) @param filter: filter for objects @param only_id: boolean to only return dict with name/id @return RETURN: the li...
python
def list(self, obj, filter=False, only_id=False, limit=20): """ Function list Get the list of an object @param obj: object name ('hosts', 'puppetclasses'...) @param filter: filter for objects @param only_id: boolean to only return dict with name/id @return RETURN: the li...
[ "def", "list", "(", "self", ",", "obj", ",", "filter", "=", "False", ",", "only_id", "=", "False", ",", "limit", "=", "20", ")", ":", "self", ".", "url", "=", "'{}{}/?per_page={}'", ".", "format", "(", "self", ".", "base_url", ",", "obj", ",", "lim...
Function list Get the list of an object @param obj: object name ('hosts', 'puppetclasses'...) @param filter: filter for objects @param only_id: boolean to only return dict with name/id @return RETURN: the list of the object
[ "Function", "list", "Get", "the", "list", "of", "an", "object" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/api.py#L86-L115
train
davidblaisonneau-orange/foreman
foreman/api.py
Api.get
def get(self, obj, id, sub_object=None): """ Function get Get an object by id @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @return RETURN: the targeted object """ self.url = '{}{}/{}'.format(self.base_url, obj...
python
def get(self, obj, id, sub_object=None): """ Function get Get an object by id @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @return RETURN: the targeted object """ self.url = '{}{}/{}'.format(self.base_url, obj...
[ "def", "get", "(", "self", ",", "obj", ",", "id", ",", "sub_object", "=", "None", ")", ":", "self", ".", "url", "=", "'{}{}/{}'", ".", "format", "(", "self", ".", "base_url", ",", "obj", ",", "id", ")", "self", ".", "method", "=", "'GET'", "if", ...
Function get Get an object by id @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @return RETURN: the targeted object
[ "Function", "get", "Get", "an", "object", "by", "id" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/api.py#L118-L134
train
davidblaisonneau-orange/foreman
foreman/api.py
Api.get_id_by_name
def get_id_by_name(self, obj, name): """ Function get_id_by_name Get the id of an object @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @return RETURN: the targeted object """ list = self.list(obj, filter='name ...
python
def get_id_by_name(self, obj, name): """ Function get_id_by_name Get the id of an object @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @return RETURN: the targeted object """ list = self.list(obj, filter='name ...
[ "def", "get_id_by_name", "(", "self", ",", "obj", ",", "name", ")", ":", "list", "=", "self", ".", "list", "(", "obj", ",", "filter", "=", "'name = \"{}\"'", ".", "format", "(", "name", ")", ",", "only_id", "=", "True", ",", "limit", "=", "1", ")",...
Function get_id_by_name Get the id of an object @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @return RETURN: the targeted object
[ "Function", "get_id_by_name", "Get", "the", "id", "of", "an", "object" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/api.py#L137-L147
train
davidblaisonneau-orange/foreman
foreman/api.py
Api.set
def set(self, obj, id, payload, action='', async=False): """ Function set Set an object by id @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @param action: specific action of an object ('power'...) @param payload: the d...
python
def set(self, obj, id, payload, action='', async=False): """ Function set Set an object by id @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @param action: specific action of an object ('power'...) @param payload: the d...
[ "def", "set", "(", "self", ",", "obj", ",", "id", ",", "payload", ",", "action", "=", "''", ",", "async", "=", "False", ")", ":", "self", ".", "url", "=", "'{}{}/{}'", ".", "format", "(", "self", ".", "base_url", ",", "obj", ",", "id", ")", "se...
Function set Set an object by id @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @param action: specific action of an object ('power'...) @param payload: the dict of the payload @param async: should this request be async...
[ "Function", "set", "Set", "an", "object", "by", "id" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/api.py#L150-L178
train
davidblaisonneau-orange/foreman
foreman/api.py
Api.create
def create(self, obj, payload, async=False): """ Function create Create an new object @param obj: object name ('hosts', 'puppetclasses'...) @param payload: the dict of the payload @param async: should this request be async, if true use return.result() to ...
python
def create(self, obj, payload, async=False): """ Function create Create an new object @param obj: object name ('hosts', 'puppetclasses'...) @param payload: the dict of the payload @param async: should this request be async, if true use return.result() to ...
[ "def", "create", "(", "self", ",", "obj", ",", "payload", ",", "async", "=", "False", ")", ":", "self", ".", "url", "=", "self", ".", "base_url", "+", "obj", "self", ".", "method", "=", "'POST'", "self", ".", "payload", "=", "json", ".", "dumps", ...
Function create Create an new object @param obj: object name ('hosts', 'puppetclasses'...) @param payload: the dict of the payload @param async: should this request be async, if true use return.result() to get the response @return RETURN: the server respo...
[ "Function", "create", "Create", "an", "new", "object" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/api.py#L181-L205
train
davidblaisonneau-orange/foreman
foreman/api.py
Api.delete
def delete(self, obj, id): """ Function delete Delete an object by id @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @return RETURN: the server response """ self.url = '{}{}/{}'.format(self.base_url, obj, id) ...
python
def delete(self, obj, id): """ Function delete Delete an object by id @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @return RETURN: the server response """ self.url = '{}{}/{}'.format(self.base_url, obj, id) ...
[ "def", "delete", "(", "self", ",", "obj", ",", "id", ")", ":", "self", ".", "url", "=", "'{}{}/{}'", ".", "format", "(", "self", ".", "base_url", ",", "obj", ",", "id", ")", "self", ".", "method", "=", "'DELETE'", "self", ".", "resp", "=", "reque...
Function delete Delete an object by id @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @return RETURN: the server response
[ "Function", "delete", "Delete", "an", "object", "by", "id" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/api.py#L208-L221
train
MatterMiners/cobald
cobald/daemon/runners/thread_runner.py
CapturingThread.run
def run(self): """Modified ``run`` that captures return value and exceptions from ``target``""" try: if self._target: return_value = self._target(*self._args, **self._kwargs) if return_value is not None: self._exception = OrphanedReturn(sel...
python
def run(self): """Modified ``run`` that captures return value and exceptions from ``target``""" try: if self._target: return_value = self._target(*self._args, **self._kwargs) if return_value is not None: self._exception = OrphanedReturn(sel...
[ "def", "run", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_target", ":", "return_value", "=", "self", ".", "_target", "(", "*", "self", ".", "_args", ",", "*", "*", "self", ".", "_kwargs", ")", "if", "return_value", "is", "not", "None", ...
Modified ``run`` that captures return value and exceptions from ``target``
[ "Modified", "run", "that", "captures", "return", "value", "and", "exceptions", "from", "target" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/thread_runner.py#L24-L36
train
MatterMiners/cobald
cobald/daemon/runners/thread_runner.py
ThreadRunner._start_payloads
def _start_payloads(self): """Start all queued payloads""" with self._lock: payloads = self._payloads.copy() self._payloads.clear() for subroutine in payloads: thread = CapturingThread(target=subroutine) thread.start() self._threads.add...
python
def _start_payloads(self): """Start all queued payloads""" with self._lock: payloads = self._payloads.copy() self._payloads.clear() for subroutine in payloads: thread = CapturingThread(target=subroutine) thread.start() self._threads.add...
[ "def", "_start_payloads", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "payloads", "=", "self", ".", "_payloads", ".", "copy", "(", ")", "self", ".", "_payloads", ".", "clear", "(", ")", "for", "subroutine", "in", "payloads", ":", "thread"...
Start all queued payloads
[ "Start", "all", "queued", "payloads" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/thread_runner.py#L61-L71
train
MatterMiners/cobald
cobald/daemon/runners/thread_runner.py
ThreadRunner._reap_payloads
def _reap_payloads(self): """Clean up all finished payloads""" for thread in self._threads.copy(): # CapturingThread.join will throw if thread.join(timeout=0): self._threads.remove(thread) self._logger.debug('reaped thread %s', thread)
python
def _reap_payloads(self): """Clean up all finished payloads""" for thread in self._threads.copy(): # CapturingThread.join will throw if thread.join(timeout=0): self._threads.remove(thread) self._logger.debug('reaped thread %s', thread)
[ "def", "_reap_payloads", "(", "self", ")", ":", "for", "thread", "in", "self", ".", "_threads", ".", "copy", "(", ")", ":", "# CapturingThread.join will throw", "if", "thread", ".", "join", "(", "timeout", "=", "0", ")", ":", "self", ".", "_threads", "."...
Clean up all finished payloads
[ "Clean", "up", "all", "finished", "payloads" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/thread_runner.py#L73-L79
train
teaearlgraycold/puni
puni/decorators.py
update_cache
def update_cache(func): """Decorate functions that modify the internally stored usernotes JSON. Ensures that updates are mirrored onto reddit. Arguments: func: the function being decorated """ @wraps(func) def wrapper(self, *args, **kwargs): """The wrapper function.""" ...
python
def update_cache(func): """Decorate functions that modify the internally stored usernotes JSON. Ensures that updates are mirrored onto reddit. Arguments: func: the function being decorated """ @wraps(func) def wrapper(self, *args, **kwargs): """The wrapper function.""" ...
[ "def", "update_cache", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"The wrapper function.\"\"\"", "lazy", "=", "kwargs", ".", "get", "(", "'lazy'", ","...
Decorate functions that modify the internally stored usernotes JSON. Ensures that updates are mirrored onto reddit. Arguments: func: the function being decorated
[ "Decorate", "functions", "that", "modify", "the", "internally", "stored", "usernotes", "JSON", "." ]
f6d0bfde99942b29a6f91273e48abcd2d7a94c93
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/decorators.py#L21-L46
train
MatterMiners/cobald
cobald/interfaces/_controller.py
Controller.s
def s(cls: Type[C], *args, **kwargs) -> Partial[C]: """ Create an unbound prototype of this class, partially applying arguments .. code:: python controller = Controller.s(interval=20) pipeline = controller(rate=10) >> pool """ return Partial(cls, *args,...
python
def s(cls: Type[C], *args, **kwargs) -> Partial[C]: """ Create an unbound prototype of this class, partially applying arguments .. code:: python controller = Controller.s(interval=20) pipeline = controller(rate=10) >> pool """ return Partial(cls, *args,...
[ "def", "s", "(", "cls", ":", "Type", "[", "C", "]", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "Partial", "[", "C", "]", ":", "return", "Partial", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Create an unbound prototype of this class, partially applying arguments .. code:: python controller = Controller.s(interval=20) pipeline = controller(rate=10) >> pool
[ "Create", "an", "unbound", "prototype", "of", "this", "class", "partially", "applying", "arguments" ]
264138de4382d1c9b53fabcbc6660e10b33a914d
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/interfaces/_controller.py#L21-L31
train
josiah-wolf-oberholtzer/uqbar
uqbar/apis/InheritanceGraph.py
InheritanceGraph._build_mappings
def _build_mappings( self, classes: Sequence[type] ) -> Tuple[Mapping[type, Sequence[type]], Mapping[type, Sequence[type]]]: """ Collect all bases and organize into parent/child mappings. """ parents_to_children: MutableMapping[type, Set[type]] = {} children_to_parent...
python
def _build_mappings( self, classes: Sequence[type] ) -> Tuple[Mapping[type, Sequence[type]], Mapping[type, Sequence[type]]]: """ Collect all bases and organize into parent/child mappings. """ parents_to_children: MutableMapping[type, Set[type]] = {} children_to_parent...
[ "def", "_build_mappings", "(", "self", ",", "classes", ":", "Sequence", "[", "type", "]", ")", "->", "Tuple", "[", "Mapping", "[", "type", ",", "Sequence", "[", "type", "]", "]", ",", "Mapping", "[", "type", ",", "Sequence", "[", "type", "]", "]", ...
Collect all bases and organize into parent/child mappings.
[ "Collect", "all", "bases", "and", "organize", "into", "parent", "/", "child", "mappings", "." ]
eca7fefebbbee1e2ae13bf5d6baa838be66b1db6
https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/apis/InheritanceGraph.py#L347-L385
train
josiah-wolf-oberholtzer/uqbar
uqbar/apis/InheritanceGraph.py
InheritanceGraph._collect_classes
def _collect_classes( self, package_paths: Sequence[str], recurse_subpackages: bool = True ) -> Sequence[type]: """ Collect all classes defined in/under ``package_paths``. """ import uqbar.apis classes = [] initial_source_paths: Set[str] = set() # Gra...
python
def _collect_classes( self, package_paths: Sequence[str], recurse_subpackages: bool = True ) -> Sequence[type]: """ Collect all classes defined in/under ``package_paths``. """ import uqbar.apis classes = [] initial_source_paths: Set[str] = set() # Gra...
[ "def", "_collect_classes", "(", "self", ",", "package_paths", ":", "Sequence", "[", "str", "]", ",", "recurse_subpackages", ":", "bool", "=", "True", ")", "->", "Sequence", "[", "type", "]", ":", "import", "uqbar", ".", "apis", "classes", "=", "[", "]", ...
Collect all classes defined in/under ``package_paths``.
[ "Collect", "all", "classes", "defined", "in", "/", "under", "package_paths", "." ]
eca7fefebbbee1e2ae13bf5d6baa838be66b1db6
https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/apis/InheritanceGraph.py#L387-L422
train
quantmind/agile-toolkit
agiletoolkit/api/__init__.py
get_auth
def get_auth(): """Return a tuple for authenticating a user If not successful raise ``AgileError``. """ auth = get_auth_from_env() if auth[0] and auth[1]: return auth home = os.path.expanduser("~") config = os.path.join(home, '.gitconfig') if not os.path.isfile(config): ...
python
def get_auth(): """Return a tuple for authenticating a user If not successful raise ``AgileError``. """ auth = get_auth_from_env() if auth[0] and auth[1]: return auth home = os.path.expanduser("~") config = os.path.join(home, '.gitconfig') if not os.path.isfile(config): ...
[ "def", "get_auth", "(", ")", ":", "auth", "=", "get_auth_from_env", "(", ")", "if", "auth", "[", "0", "]", "and", "auth", "[", "1", "]", ":", "return", "auth", "home", "=", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", "config", "=", "...
Return a tuple for authenticating a user If not successful raise ``AgileError``.
[ "Return", "a", "tuple", "for", "authenticating", "a", "user" ]
96028e36a842c57b171907c20583a60d1045fec1
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/__init__.py#L40-L66
train
davidblaisonneau-orange/foreman
foreman/architectures.py
Architectures.checkAndCreate
def checkAndCreate(self, key, payload, osIds): """ Function checkAndCreate Check if an architectures exists and create it if not @param key: The targeted architectures @param payload: The targeted architectures description @param osIds: The list of os ids liked with this archite...
python
def checkAndCreate(self, key, payload, osIds): """ Function checkAndCreate Check if an architectures exists and create it if not @param key: The targeted architectures @param payload: The targeted architectures description @param osIds: The list of os ids liked with this archite...
[ "def", "checkAndCreate", "(", "self", ",", "key", ",", "payload", ",", "osIds", ")", ":", "if", "key", "not", "in", "self", ":", "self", "[", "key", "]", "=", "payload", "oid", "=", "self", "[", "key", "]", "[", "'id'", "]", "if", "not", "oid", ...
Function checkAndCreate Check if an architectures exists and create it if not @param key: The targeted architectures @param payload: The targeted architectures description @param osIds: The list of os ids liked with this architecture @return RETURN: The id of the object
[ "Function", "checkAndCreate", "Check", "if", "an", "architectures", "exists", "and", "create", "it", "if", "not" ]
acb8fd8d74657cfac3b25c82e9c6028b93eb6c92
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/architectures.py#L29-L49
train
DataMedSci/mcpartools
setup.py
pip_command_output
def pip_command_output(pip_args): """ Get output (as a string) from pip command :param pip_args: list o pip switches to pass :return: string with results """ import sys import pip from io import StringIO # as pip will write to stdout we use some nasty hacks # to substitute system...
python
def pip_command_output(pip_args): """ Get output (as a string) from pip command :param pip_args: list o pip switches to pass :return: string with results """ import sys import pip from io import StringIO # as pip will write to stdout we use some nasty hacks # to substitute system...
[ "def", "pip_command_output", "(", "pip_args", ")", ":", "import", "sys", "import", "pip", "from", "io", "import", "StringIO", "# as pip will write to stdout we use some nasty hacks", "# to substitute system stdout with our own", "old_stdout", "=", "sys", ".", "stdout", "sys...
Get output (as a string) from pip command :param pip_args: list o pip switches to pass :return: string with results
[ "Get", "output", "(", "as", "a", "string", ")", "from", "pip", "command", ":", "param", "pip_args", ":", "list", "o", "pip", "switches", "to", "pass", ":", "return", ":", "string", "with", "results" ]
84f869094d05bf70f09e8aaeca671ddaa1c56ec4
https://github.com/DataMedSci/mcpartools/blob/84f869094d05bf70f09e8aaeca671ddaa1c56ec4/setup.py#L5-L22
train