id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
246,200 | ryanjdillon/pyotelem | pyotelem/dsp.py | findzc | def findzc(x, thresh, t_max=None):
'''
Find cues to each zero-crossing in vector x.
To be accepted as a zero-crossing, the signal must pass from below
-thresh to above thresh, or vice versa, in no more than t_max samples.
Args
----
thresh: (float)
magnitude threshold for detecting ... | python | def findzc(x, thresh, t_max=None):
'''
Find cues to each zero-crossing in vector x.
To be accepted as a zero-crossing, the signal must pass from below
-thresh to above thresh, or vice versa, in no more than t_max samples.
Args
----
thresh: (float)
magnitude threshold for detecting ... | [
"def",
"findzc",
"(",
"x",
",",
"thresh",
",",
"t_max",
"=",
"None",
")",
":",
"import",
"numpy",
"# positive threshold: p (over) n (under)",
"pt_p",
"=",
"x",
">",
"thresh",
"pt_n",
"=",
"~",
"pt_p",
"# negative threshold: p (over) n (under)",
"nt_n",
"=",
"x",... | Find cues to each zero-crossing in vector x.
To be accepted as a zero-crossing, the signal must pass from below
-thresh to above thresh, or vice versa, in no more than t_max samples.
Args
----
thresh: (float)
magnitude threshold for detecting a zero-crossing.
t_max: (int)
maxim... | [
"Find",
"cues",
"to",
"each",
"zero",
"-",
"crossing",
"in",
"vector",
"x",
"."
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dsp.py#L27-L113 |
246,201 | ryanjdillon/pyotelem | pyotelem/dsp.py | butter_filter | def butter_filter(cutoff, fs, order=5, btype='low'):
'''Create a digital butter fileter with cutoff frequency in Hz
Args
----
cutoff: float
Cutoff frequency where filter should separate signals
fs: float
sampling frequency
btype: str
Type of filter type to create. 'low' ... | python | def butter_filter(cutoff, fs, order=5, btype='low'):
'''Create a digital butter fileter with cutoff frequency in Hz
Args
----
cutoff: float
Cutoff frequency where filter should separate signals
fs: float
sampling frequency
btype: str
Type of filter type to create. 'low' ... | [
"def",
"butter_filter",
"(",
"cutoff",
",",
"fs",
",",
"order",
"=",
"5",
",",
"btype",
"=",
"'low'",
")",
":",
"import",
"scipy",
".",
"signal",
"nyq",
"=",
"0.5",
"*",
"fs",
"normal_cutoff",
"=",
"cutoff",
"/",
"nyq",
"b",
",",
"a",
"=",
"scipy",... | Create a digital butter fileter with cutoff frequency in Hz
Args
----
cutoff: float
Cutoff frequency where filter should separate signals
fs: float
sampling frequency
btype: str
Type of filter type to create. 'low' creates a low-frequency filter and
'high' creates a ... | [
"Create",
"a",
"digital",
"butter",
"fileter",
"with",
"cutoff",
"frequency",
"in",
"Hz"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dsp.py#L116-L147 |
246,202 | ryanjdillon/pyotelem | pyotelem/dsp.py | butter_apply | def butter_apply(b, a, data):
'''Apply filter with filtfilt to allign filtereted data with input
The filter is applied once forward and once backward to give it linear
phase, using Gustafsson's method to give the same length as the original
signal.
Args
----
b: ndarray
Numerator po... | python | def butter_apply(b, a, data):
'''Apply filter with filtfilt to allign filtereted data with input
The filter is applied once forward and once backward to give it linear
phase, using Gustafsson's method to give the same length as the original
signal.
Args
----
b: ndarray
Numerator po... | [
"def",
"butter_apply",
"(",
"b",
",",
"a",
",",
"data",
")",
":",
"import",
"scipy",
".",
"signal",
"return",
"scipy",
".",
"signal",
".",
"filtfilt",
"(",
"b",
",",
"a",
",",
"data",
",",
"method",
"=",
"'gust'",
")"
] | Apply filter with filtfilt to allign filtereted data with input
The filter is applied once forward and once backward to give it linear
phase, using Gustafsson's method to give the same length as the original
signal.
Args
----
b: ndarray
Numerator polynomials of the IIR butter filter
... | [
"Apply",
"filter",
"with",
"filtfilt",
"to",
"allign",
"filtereted",
"data",
"with",
"input"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dsp.py#L150-L176 |
246,203 | ryanjdillon/pyotelem | pyotelem/dsp.py | calc_PSD_welch | def calc_PSD_welch(x, fs, nperseg):
'''Caclulate power spectral density with Welch's method
Args
----
x: ndarray
sample array
fs: float
sampling frequency (1/dt)
Returns
-------
f_welch: ndarray
Discrete frequencies
S_xx_welch: ndarray
Estimated PSD ... | python | def calc_PSD_welch(x, fs, nperseg):
'''Caclulate power spectral density with Welch's method
Args
----
x: ndarray
sample array
fs: float
sampling frequency (1/dt)
Returns
-------
f_welch: ndarray
Discrete frequencies
S_xx_welch: ndarray
Estimated PSD ... | [
"def",
"calc_PSD_welch",
"(",
"x",
",",
"fs",
",",
"nperseg",
")",
":",
"import",
"numpy",
"import",
"scipy",
".",
"signal",
"# Code source and description of FFT, DFT, etc.",
"# http://stackoverflow.com/a/33251324/943773",
"dt",
"=",
"1",
"/",
"fs",
"N",
"=",
"len"... | Caclulate power spectral density with Welch's method
Args
----
x: ndarray
sample array
fs: float
sampling frequency (1/dt)
Returns
-------
f_welch: ndarray
Discrete frequencies
S_xx_welch: ndarray
Estimated PSD at discrete frequencies `f_welch`
P_wel... | [
"Caclulate",
"power",
"spectral",
"density",
"with",
"Welch",
"s",
"method"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dsp.py#L179-L217 |
246,204 | ryanjdillon/pyotelem | pyotelem/dsp.py | simple_peakfinder | def simple_peakfinder(x, y, delta):
'''Detect local maxima and minima in a vector
A point is considered a maximum peak if it has the maximal value, and was
preceded (to the left) by a value lower by `delta`.
Args
----
y: ndarray
array of values to find local maxima and minima in
de... | python | def simple_peakfinder(x, y, delta):
'''Detect local maxima and minima in a vector
A point is considered a maximum peak if it has the maximal value, and was
preceded (to the left) by a value lower by `delta`.
Args
----
y: ndarray
array of values to find local maxima and minima in
de... | [
"def",
"simple_peakfinder",
"(",
"x",
",",
"y",
",",
"delta",
")",
":",
"import",
"numpy",
"y",
"=",
"numpy",
".",
"asarray",
"(",
"y",
")",
"max_ind",
"=",
"list",
"(",
")",
"min_ind",
"=",
"list",
"(",
")",
"local_min",
"=",
"numpy",
".",
"inf",
... | Detect local maxima and minima in a vector
A point is considered a maximum peak if it has the maximal value, and was
preceded (to the left) by a value lower by `delta`.
Args
----
y: ndarray
array of values to find local maxima and minima in
delta: float
minimum change in `y` si... | [
"Detect",
"local",
"maxima",
"and",
"minima",
"in",
"a",
"vector"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dsp.py#L220-L293 |
246,205 | brews/carbonferret | carbonferret/core.py | find_near | def find_near(lat, lon, *, n=10, session=None):
"""Return n results for a given latitude and longitude"""
search_params = {'npoints': n, 'clat': lat, 'clon': lon,
'Columns[]': ['Subregion', 'Notes', 'CollectionYear',
'ReservoirAge', 'ReservoirErr', 'C14a... | python | def find_near(lat, lon, *, n=10, session=None):
"""Return n results for a given latitude and longitude"""
search_params = {'npoints': n, 'clat': lat, 'clon': lon,
'Columns[]': ['Subregion', 'Notes', 'CollectionYear',
'ReservoirAge', 'ReservoirErr', 'C14a... | [
"def",
"find_near",
"(",
"lat",
",",
"lon",
",",
"*",
",",
"n",
"=",
"10",
",",
"session",
"=",
"None",
")",
":",
"search_params",
"=",
"{",
"'npoints'",
":",
"n",
",",
"'clat'",
":",
"lat",
",",
"'clon'",
":",
"lon",
",",
"'Columns[]'",
":",
"["... | Return n results for a given latitude and longitude | [
"Return",
"n",
"results",
"for",
"a",
"given",
"latitude",
"and",
"longitude"
] | afbf901178b328bbc770129adc35c1403404b197 | https://github.com/brews/carbonferret/blob/afbf901178b328bbc770129adc35c1403404b197/carbonferret/core.py#L5-L15 |
246,206 | brews/carbonferret | carbonferret/core.py | _query_near | def _query_near(*, session=None, **kwargs):
"""Query marine database with given query string values and keys"""
url_endpoint = 'http://calib.org/marine/index.html'
if session is not None:
resp = session.get(url_endpoint, params=kwargs)
else:
with requests.Session() as s:
# Ne... | python | def _query_near(*, session=None, **kwargs):
"""Query marine database with given query string values and keys"""
url_endpoint = 'http://calib.org/marine/index.html'
if session is not None:
resp = session.get(url_endpoint, params=kwargs)
else:
with requests.Session() as s:
# Ne... | [
"def",
"_query_near",
"(",
"*",
",",
"session",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"url_endpoint",
"=",
"'http://calib.org/marine/index.html'",
"if",
"session",
"is",
"not",
"None",
":",
"resp",
"=",
"session",
".",
"get",
"(",
"url_endpoint",
... | Query marine database with given query string values and keys | [
"Query",
"marine",
"database",
"with",
"given",
"query",
"string",
"values",
"and",
"keys"
] | afbf901178b328bbc770129adc35c1403404b197 | https://github.com/brews/carbonferret/blob/afbf901178b328bbc770129adc35c1403404b197/carbonferret/core.py#L18-L28 |
246,207 | klen/muffin-debugtoolbar | muffin_debugtoolbar/panels.py | DebugPanel.render_content | def render_content(self):
"""Render the panel's content."""
if not self.has_content:
return ""
template = self.template
if isinstance(self.template, str):
template = self.app.ps.jinja2.env.get_template(self.template)
context = self.render_vars()
co... | python | def render_content(self):
"""Render the panel's content."""
if not self.has_content:
return ""
template = self.template
if isinstance(self.template, str):
template = self.app.ps.jinja2.env.get_template(self.template)
context = self.render_vars()
co... | [
"def",
"render_content",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"has_content",
":",
"return",
"\"\"",
"template",
"=",
"self",
".",
"template",
"if",
"isinstance",
"(",
"self",
".",
"template",
",",
"str",
")",
":",
"template",
"=",
"self",
"... | Render the panel's content. | [
"Render",
"the",
"panel",
"s",
"content",
"."
] | b650b35fbe2035888f6bba5dac3073ef01c94dc6 | https://github.com/klen/muffin-debugtoolbar/blob/b650b35fbe2035888f6bba5dac3073ef01c94dc6/muffin_debugtoolbar/panels.py#L57-L66 |
246,208 | klen/muffin-debugtoolbar | muffin_debugtoolbar/panels.py | HeaderDebugPanel.process_response | def process_response(self, response):
"""Store response headers."""
self.response_headers = [(k, v) for k, v in sorted(response.headers.items())] | python | def process_response(self, response):
"""Store response headers."""
self.response_headers = [(k, v) for k, v in sorted(response.headers.items())] | [
"def",
"process_response",
"(",
"self",
",",
"response",
")",
":",
"self",
".",
"response_headers",
"=",
"[",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"sorted",
"(",
"response",
".",
"headers",
".",
"items",
"(",
")",
")",
"]"
] | Store response headers. | [
"Store",
"response",
"headers",
"."
] | b650b35fbe2035888f6bba5dac3073ef01c94dc6 | https://github.com/klen/muffin-debugtoolbar/blob/b650b35fbe2035888f6bba5dac3073ef01c94dc6/muffin_debugtoolbar/panels.py#L88-L90 |
246,209 | tbobm/devscripts | devscripts/devscripts.py | retry | def retry(exception_to_check, tries=5, delay=5, multiplier=2):
'''Tries to call the wrapped function again, after an incremental delay
:param exception_to_check: Exception(s) to check for, before retrying.
:type exception_to_check: Exception
:param tries: Number of time to retry before failling.
:t... | python | def retry(exception_to_check, tries=5, delay=5, multiplier=2):
'''Tries to call the wrapped function again, after an incremental delay
:param exception_to_check: Exception(s) to check for, before retrying.
:type exception_to_check: Exception
:param tries: Number of time to retry before failling.
:t... | [
"def",
"retry",
"(",
"exception_to_check",
",",
"tries",
"=",
"5",
",",
"delay",
"=",
"5",
",",
"multiplier",
"=",
"2",
")",
":",
"def",
"deco_retry",
"(",
"func",
")",
":",
"'''Creates the retry decorator'''",
"@",
"wraps",
"(",
"func",
")",
"def",
"fun... | Tries to call the wrapped function again, after an incremental delay
:param exception_to_check: Exception(s) to check for, before retrying.
:type exception_to_check: Exception
:param tries: Number of time to retry before failling.
:type tries: int
:param delay: time in second to sleep before retryi... | [
"Tries",
"to",
"call",
"the",
"wrapped",
"function",
"again",
"after",
"an",
"incremental",
"delay"
] | beb23371ba80739afb5474766e8049ead3837925 | https://github.com/tbobm/devscripts/blob/beb23371ba80739afb5474766e8049ead3837925/devscripts/devscripts.py#L10-L49 |
246,210 | eddiejessup/agaro | agaro/measure_utils.py | get_average_measure | def get_average_measure(dirname, measure_func, t_steady=None):
"""
Calculate a measure of a model in an output directory, averaged over
all times when the model is at steady-state.
Parameters
----------
dirname: str
Output directory
measure_func: function
Function which take... | python | def get_average_measure(dirname, measure_func, t_steady=None):
"""
Calculate a measure of a model in an output directory, averaged over
all times when the model is at steady-state.
Parameters
----------
dirname: str
Output directory
measure_func: function
Function which take... | [
"def",
"get_average_measure",
"(",
"dirname",
",",
"measure_func",
",",
"t_steady",
"=",
"None",
")",
":",
"if",
"t_steady",
"is",
"None",
":",
"meas",
",",
"meas_err",
"=",
"measure_func",
"(",
"get_recent_model",
"(",
"dirname",
")",
")",
"return",
"meas",... | Calculate a measure of a model in an output directory, averaged over
all times when the model is at steady-state.
Parameters
----------
dirname: str
Output directory
measure_func: function
Function which takes a :class:`Model` instance as a single argument,
and returns the m... | [
"Calculate",
"a",
"measure",
"of",
"a",
"model",
"in",
"an",
"output",
"directory",
"averaged",
"over",
"all",
"times",
"when",
"the",
"model",
"is",
"at",
"steady",
"-",
"state",
"."
] | b2feb45d6129d749088c70b3e9290af7ca7c7d33 | https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/measure_utils.py#L9-L42 |
246,211 | eddiejessup/agaro | agaro/measure_utils.py | measures | def measures(dirnames, measure_func, t_steady=None):
"""Calculate a measure of a set of model output directories,
for a measure function which returns an associated uncertainty.
Parameters
----------
dirnames: list[str]
Model output directory paths.
measure_func: function
Functi... | python | def measures(dirnames, measure_func, t_steady=None):
"""Calculate a measure of a set of model output directories,
for a measure function which returns an associated uncertainty.
Parameters
----------
dirnames: list[str]
Model output directory paths.
measure_func: function
Functi... | [
"def",
"measures",
"(",
"dirnames",
",",
"measure_func",
",",
"t_steady",
"=",
"None",
")",
":",
"measures",
",",
"measure_errs",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"dirname",
"in",
"dirnames",
":",
"meas",
",",
"meas_err",
"=",
"get_average_measure",
... | Calculate a measure of a set of model output directories,
for a measure function which returns an associated uncertainty.
Parameters
----------
dirnames: list[str]
Model output directory paths.
measure_func: function
Function which takes a :class:`Model` instance as a single argumen... | [
"Calculate",
"a",
"measure",
"of",
"a",
"set",
"of",
"model",
"output",
"directories",
"for",
"a",
"measure",
"function",
"which",
"returns",
"an",
"associated",
"uncertainty",
"."
] | b2feb45d6129d749088c70b3e9290af7ca7c7d33 | https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/measure_utils.py#L45-L73 |
246,212 | eddiejessup/agaro | agaro/measure_utils.py | params | def params(dirnames, param_func, t_steady=None):
"""Calculate a parameter of a set of model output directories,
for a measure function which returns an associated uncertainty.
Parameters
----------
dirnames: list[str]
Model output directory paths.
param_func: function
Function w... | python | def params(dirnames, param_func, t_steady=None):
"""Calculate a parameter of a set of model output directories,
for a measure function which returns an associated uncertainty.
Parameters
----------
dirnames: list[str]
Model output directory paths.
param_func: function
Function w... | [
"def",
"params",
"(",
"dirnames",
",",
"param_func",
",",
"t_steady",
"=",
"None",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"param_func",
"(",
"get_recent_model",
"(",
"d",
")",
")",
"for",
"d",
"in",
"dirnames",
"]",
")"
] | Calculate a parameter of a set of model output directories,
for a measure function which returns an associated uncertainty.
Parameters
----------
dirnames: list[str]
Model output directory paths.
param_func: function
Function which takes a :class:`Model` instance as a single argumen... | [
"Calculate",
"a",
"parameter",
"of",
"a",
"set",
"of",
"model",
"output",
"directories",
"for",
"a",
"measure",
"function",
"which",
"returns",
"an",
"associated",
"uncertainty",
"."
] | b2feb45d6129d749088c70b3e9290af7ca7c7d33 | https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/measure_utils.py#L76-L93 |
246,213 | eddiejessup/agaro | agaro/measure_utils.py | t_measures | def t_measures(dirname, time_func, measure_func):
"""Calculate a measure over time for a single output directory,
and its uncertainty.
Parameters
----------
dirname: str
Path to a model output directory.
time_func: function
Function which takes a :class:`Model` instance as a sin... | python | def t_measures(dirname, time_func, measure_func):
"""Calculate a measure over time for a single output directory,
and its uncertainty.
Parameters
----------
dirname: str
Path to a model output directory.
time_func: function
Function which takes a :class:`Model` instance as a sin... | [
"def",
"t_measures",
"(",
"dirname",
",",
"time_func",
",",
"measure_func",
")",
":",
"ts",
",",
"measures",
",",
"measure_errs",
"=",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
"for",
"fname",
"in",
"get_filenames",
"(",
"dirname",
")",
":",
"m",
"=",
... | Calculate a measure over time for a single output directory,
and its uncertainty.
Parameters
----------
dirname: str
Path to a model output directory.
time_func: function
Function which takes a :class:`Model` instance as a single argument,
and returns its time.
measure_f... | [
"Calculate",
"a",
"measure",
"over",
"time",
"for",
"a",
"single",
"output",
"directory",
"and",
"its",
"uncertainty",
"."
] | b2feb45d6129d749088c70b3e9290af7ca7c7d33 | https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/measure_utils.py#L96-L127 |
246,214 | eddiejessup/agaro | agaro/measure_utils.py | group_by_key | def group_by_key(dirnames, key):
"""Group a set of output directories according to a model parameter.
Parameters
----------
dirnames: list[str]
Output directories
key: various
A field of a :class:`Model` instance.
Returns
-------
groups: dict[various: list[str]]
... | python | def group_by_key(dirnames, key):
"""Group a set of output directories according to a model parameter.
Parameters
----------
dirnames: list[str]
Output directories
key: various
A field of a :class:`Model` instance.
Returns
-------
groups: dict[various: list[str]]
... | [
"def",
"group_by_key",
"(",
"dirnames",
",",
"key",
")",
":",
"groups",
"=",
"defaultdict",
"(",
"lambda",
":",
"[",
"]",
")",
"for",
"dirname",
"in",
"dirnames",
":",
"m",
"=",
"get_recent_model",
"(",
"dirname",
")",
"groups",
"[",
"m",
".",
"__dict_... | Group a set of output directories according to a model parameter.
Parameters
----------
dirnames: list[str]
Output directories
key: various
A field of a :class:`Model` instance.
Returns
-------
groups: dict[various: list[str]]
For each value of `key` that is found a... | [
"Group",
"a",
"set",
"of",
"output",
"directories",
"according",
"to",
"a",
"model",
"parameter",
"."
] | b2feb45d6129d749088c70b3e9290af7ca7c7d33 | https://github.com/eddiejessup/agaro/blob/b2feb45d6129d749088c70b3e9290af7ca7c7d33/agaro/measure_utils.py#L130-L150 |
246,215 | limiear/soyprice | soyprice/bots/statistic.py | VariableRegression.pearson_correlation | def pearson_correlation(self):
x, y, dt = self.data
X, Y = np.array(x), np.array(y)
''' Compute Pearson Correlation Coefficient. '''
# Normalise X and Y
X -= X.mean(0)
Y -= Y.mean(0)
# Standardise X and Y
X /= X.std(0)
Y /= Y.std(0)
# Compu... | python | def pearson_correlation(self):
x, y, dt = self.data
X, Y = np.array(x), np.array(y)
''' Compute Pearson Correlation Coefficient. '''
# Normalise X and Y
X -= X.mean(0)
Y -= Y.mean(0)
# Standardise X and Y
X /= X.std(0)
Y /= Y.std(0)
# Compu... | [
"def",
"pearson_correlation",
"(",
"self",
")",
":",
"x",
",",
"y",
",",
"dt",
"=",
"self",
".",
"data",
"X",
",",
"Y",
"=",
"np",
".",
"array",
"(",
"x",
")",
",",
"np",
".",
"array",
"(",
"y",
")",
"# Normalise X and Y",
"X",
"-=",
"X",
".",
... | Compute Pearson Correlation Coefficient. | [
"Compute",
"Pearson",
"Correlation",
"Coefficient",
"."
] | b7f8847b1ab4ba7d9e654135321c5598c7d1aeb1 | https://github.com/limiear/soyprice/blob/b7f8847b1ab4ba7d9e654135321c5598c7d1aeb1/soyprice/bots/statistic.py#L147-L158 |
246,216 | pjuren/pyokit | src/pyokit/io/bedIterators.py | intervalTrees | def intervalTrees(reffh, scoreType=int, verbose=False):
"""
Build a dictionary of interval trees indexed by chrom from a BED stream or
file
:param reffh: This can be either a string, or a stream-like object. In the
former case, it is treated as a filename. The format of the
file... | python | def intervalTrees(reffh, scoreType=int, verbose=False):
"""
Build a dictionary of interval trees indexed by chrom from a BED stream or
file
:param reffh: This can be either a string, or a stream-like object. In the
former case, it is treated as a filename. The format of the
file... | [
"def",
"intervalTrees",
"(",
"reffh",
",",
"scoreType",
"=",
"int",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"type",
"(",
"reffh",
")",
".",
"__name__",
"==",
"\"str\"",
":",
"fh",
"=",
"open",
"(",
"reffh",
")",
"else",
":",
"fh",
"=",
"reffh... | Build a dictionary of interval trees indexed by chrom from a BED stream or
file
:param reffh: This can be either a string, or a stream-like object. In the
former case, it is treated as a filename. The format of the
file/stream must be BED.
:param scoreType: The data type for score... | [
"Build",
"a",
"dictionary",
"of",
"interval",
"trees",
"indexed",
"by",
"chrom",
"from",
"a",
"BED",
"stream",
"or",
"file"
] | fddae123b5d817daa39496183f19c000d9c3791f | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/bedIterators.py#L62-L107 |
246,217 | pjuren/pyokit | src/pyokit/io/bedIterators.py | BEDIterator | def BEDIterator(filehandle, sortedby=None, verbose=False, scoreType=int,
dropAfter=None):
"""
Get an iterator for a BED file
:param filehandle: this can be either a string, or a stream-like object. In
the former case, it is treated as a filename. The format
... | python | def BEDIterator(filehandle, sortedby=None, verbose=False, scoreType=int,
dropAfter=None):
"""
Get an iterator for a BED file
:param filehandle: this can be either a string, or a stream-like object. In
the former case, it is treated as a filename. The format
... | [
"def",
"BEDIterator",
"(",
"filehandle",
",",
"sortedby",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"scoreType",
"=",
"int",
",",
"dropAfter",
"=",
"None",
")",
":",
"chromsSeen",
"=",
"set",
"(",
")",
"prev",
"=",
"None",
"if",
"type",
"(",
"f... | Get an iterator for a BED file
:param filehandle: this can be either a string, or a stream-like object. In
the former case, it is treated as a filename. The format
of the file/stream must be BED.
:param sortedby: if None, order is not checked.
if == ITER... | [
"Get",
"an",
"iterator",
"for",
"a",
"BED",
"file"
] | fddae123b5d817daa39496183f19c000d9c3791f | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/bedIterators.py#L114-L204 |
246,218 | tBaxter/django-fretboard | fretboard/signals.py | update_forum_votes | def update_forum_votes(sender, **kwargs):
"""
When a Vote is added, re-saves the topic or post to update vote count.
Since Votes can be assigned
to any content type, first makes sure we are dealing with a forum post or topic.
Deprecated 1-6-14 by storing score as cached property
"""
... | python | def update_forum_votes(sender, **kwargs):
"""
When a Vote is added, re-saves the topic or post to update vote count.
Since Votes can be assigned
to any content type, first makes sure we are dealing with a forum post or topic.
Deprecated 1-6-14 by storing score as cached property
"""
... | [
"def",
"update_forum_votes",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"vote",
"=",
"kwargs",
"[",
"'instance'",
"]",
"if",
"vote",
".",
"content_type",
".",
"app_label",
"!=",
"\"fretboard\"",
":",
"return",
"if",
"vote",
".",
"content_type",
".",... | When a Vote is added, re-saves the topic or post to update vote count.
Since Votes can be assigned
to any content type, first makes sure we are dealing with a forum post or topic.
Deprecated 1-6-14 by storing score as cached property | [
"When",
"a",
"Vote",
"is",
"added",
"re",
"-",
"saves",
"the",
"topic",
"or",
"post",
"to",
"update",
"vote",
"count",
".",
"Since",
"Votes",
"can",
"be",
"assigned",
"to",
"any",
"content",
"type",
"first",
"makes",
"sure",
"we",
"are",
"dealing",
"wi... | 3c3f9557089821283f315a07f3e5a57a2725ab3b | https://github.com/tBaxter/django-fretboard/blob/3c3f9557089821283f315a07f3e5a57a2725ab3b/fretboard/signals.py#L7-L25 |
246,219 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/runner/connection_plugins/paramiko_ssh.py | Connection.close | def close(self):
''' terminate the connection '''
cache_key = self._cache_key()
SSH_CONNECTION_CACHE.pop(cache_key, None)
SFTP_CONNECTION_CACHE.pop(cache_key, None)
if self.sftp is not None:
self.sftp.close()
self.ssh.close() | python | def close(self):
''' terminate the connection '''
cache_key = self._cache_key()
SSH_CONNECTION_CACHE.pop(cache_key, None)
SFTP_CONNECTION_CACHE.pop(cache_key, None)
if self.sftp is not None:
self.sftp.close()
self.ssh.close() | [
"def",
"close",
"(",
"self",
")",
":",
"cache_key",
"=",
"self",
".",
"_cache_key",
"(",
")",
"SSH_CONNECTION_CACHE",
".",
"pop",
"(",
"cache_key",
",",
"None",
")",
"SFTP_CONNECTION_CACHE",
".",
"pop",
"(",
"cache_key",
",",
"None",
")",
"if",
"self",
"... | terminate the connection | [
"terminate",
"the",
"connection"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/runner/connection_plugins/paramiko_ssh.py#L190-L197 |
246,220 | thomas-maurice/clifactory | clifactory/clifactory.py | CommandLineInterface.parse | def parse(self, line=None):
"""parses the line provided, if None then uses sys.argv"""
args = self.parser.parse_args(args=line)
return args.func(args) | python | def parse(self, line=None):
"""parses the line provided, if None then uses sys.argv"""
args = self.parser.parse_args(args=line)
return args.func(args) | [
"def",
"parse",
"(",
"self",
",",
"line",
"=",
"None",
")",
":",
"args",
"=",
"self",
".",
"parser",
".",
"parse_args",
"(",
"args",
"=",
"line",
")",
"return",
"args",
".",
"func",
"(",
"args",
")"
] | parses the line provided, if None then uses sys.argv | [
"parses",
"the",
"line",
"provided",
"if",
"None",
"then",
"uses",
"sys",
".",
"argv"
] | b0649e3fe8901a3de7a3e3ecf4bf23499f6a87b3 | https://github.com/thomas-maurice/clifactory/blob/b0649e3fe8901a3de7a3e3ecf4bf23499f6a87b3/clifactory/clifactory.py#L65-L68 |
246,221 | openbermuda/ripl | ripl/slidelayout.py | SlideLayout.vertical_layout | def vertical_layout(self, draw, slide):
""" Augment slide with vertical layout info """
padding = self.padding
heading = slide['heading']
width, height = draw.textsize(heading['text'])
top = padding
left = padding
# Calculate size and location of heading
... | python | def vertical_layout(self, draw, slide):
""" Augment slide with vertical layout info """
padding = self.padding
heading = slide['heading']
width, height = draw.textsize(heading['text'])
top = padding
left = padding
# Calculate size and location of heading
... | [
"def",
"vertical_layout",
"(",
"self",
",",
"draw",
",",
"slide",
")",
":",
"padding",
"=",
"self",
".",
"padding",
"heading",
"=",
"slide",
"[",
"'heading'",
"]",
"width",
",",
"height",
"=",
"draw",
".",
"textsize",
"(",
"heading",
"[",
"'text'",
"]"... | Augment slide with vertical layout info | [
"Augment",
"slide",
"with",
"vertical",
"layout",
"info"
] | 4886b1a697e4b81c2202db9cb977609e034f8e70 | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/slidelayout.py#L59-L145 |
246,222 | openbermuda/ripl | ripl/slidelayout.py | SlideLayout.horizontal_layout | def horizontal_layout(self, draw, slide):
""" Augment slide with horizontal layout info """
padding = self.padding
heading = slide['heading']
top = padding
left = padding
top += heading['height'] + padding
rows = slide['rows']
for row in rows:
... | python | def horizontal_layout(self, draw, slide):
""" Augment slide with horizontal layout info """
padding = self.padding
heading = slide['heading']
top = padding
left = padding
top += heading['height'] + padding
rows = slide['rows']
for row in rows:
... | [
"def",
"horizontal_layout",
"(",
"self",
",",
"draw",
",",
"slide",
")",
":",
"padding",
"=",
"self",
".",
"padding",
"heading",
"=",
"slide",
"[",
"'heading'",
"]",
"top",
"=",
"padding",
"left",
"=",
"padding",
"top",
"+=",
"heading",
"[",
"'height'",
... | Augment slide with horizontal layout info | [
"Augment",
"slide",
"with",
"horizontal",
"layout",
"info"
] | 4886b1a697e4b81c2202db9cb977609e034f8e70 | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/slidelayout.py#L147-L184 |
246,223 | tschaume/ccsgp_get_started | ccsgp_get_started/examples/gp_xfac.py | gp_xfac | def gp_xfac():
"""example using QM12 enhancement factors
- uses `gpcalls` kwarg to reset xtics
- numpy.loadtxt needs reshaping for input files w/ only one datapoint
- according poster presentations see QM12_ & NSD_ review
.. _QM12: http://indico.cern.ch/getFile.py/access?contribId=268&sessionId=10&resId=0&m... | python | def gp_xfac():
"""example using QM12 enhancement factors
- uses `gpcalls` kwarg to reset xtics
- numpy.loadtxt needs reshaping for input files w/ only one datapoint
- according poster presentations see QM12_ & NSD_ review
.. _QM12: http://indico.cern.ch/getFile.py/access?contribId=268&sessionId=10&resId=0&m... | [
"def",
"gp_xfac",
"(",
")",
":",
"# prepare data",
"inDir",
",",
"outDir",
"=",
"getWorkDirs",
"(",
")",
"data",
"=",
"OrderedDict",
"(",
")",
"# TODO: \"really\" reproduce plot using spectral data",
"for",
"file",
"in",
"os",
".",
"listdir",
"(",
"inDir",
")",
... | example using QM12 enhancement factors
- uses `gpcalls` kwarg to reset xtics
- numpy.loadtxt needs reshaping for input files w/ only one datapoint
- according poster presentations see QM12_ & NSD_ review
.. _QM12: http://indico.cern.ch/getFile.py/access?contribId=268&sessionId=10&resId=0&materialId=slides&con... | [
"example",
"using",
"QM12",
"enhancement",
"factors"
] | e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2 | https://github.com/tschaume/ccsgp_get_started/blob/e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2/ccsgp_get_started/examples/gp_xfac.py#L12-L63 |
246,224 | ramrod-project/database-brain | schema/brain/checks.py | verify | def verify(value, msg):
"""
C-style validator
Keyword arguments:
value -- dictionary to validate (required)
msg -- the protobuf schema to validate against (required)
Returns:
True: If valid input
False: If invalid input
"""
return bool(value) and \
converts_t... | python | def verify(value, msg):
"""
C-style validator
Keyword arguments:
value -- dictionary to validate (required)
msg -- the protobuf schema to validate against (required)
Returns:
True: If valid input
False: If invalid input
"""
return bool(value) and \
converts_t... | [
"def",
"verify",
"(",
"value",
",",
"msg",
")",
":",
"return",
"bool",
"(",
"value",
")",
"and",
"converts_to_proto",
"(",
"value",
",",
"msg",
")",
"and",
"successfuly_encodes",
"(",
"msg",
")",
"and",
"special_typechecking",
"(",
"value",
",",
"msg",
"... | C-style validator
Keyword arguments:
value -- dictionary to validate (required)
msg -- the protobuf schema to validate against (required)
Returns:
True: If valid input
False: If invalid input | [
"C",
"-",
"style",
"validator"
] | b024cb44f34cabb9d80af38271ddb65c25767083 | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/checks.py#L13-L28 |
246,225 | ramrod-project/database-brain | schema/brain/checks.py | converts_to_proto | def converts_to_proto(value, msg, raise_err=False):
"""
Boolean response if a dictionary can convert into the proto's schema
:param value: <dict>
:param msg: <proto object>
:param raise_err: <bool> (default false) raise for troubleshooting
:return: <bool> whether the dict can covert
"""
... | python | def converts_to_proto(value, msg, raise_err=False):
"""
Boolean response if a dictionary can convert into the proto's schema
:param value: <dict>
:param msg: <proto object>
:param raise_err: <bool> (default false) raise for troubleshooting
:return: <bool> whether the dict can covert
"""
... | [
"def",
"converts_to_proto",
"(",
"value",
",",
"msg",
",",
"raise_err",
"=",
"False",
")",
":",
"result",
"=",
"True",
"try",
":",
"dict_to_protobuf",
".",
"dict_to_protobuf",
"(",
"value",
",",
"msg",
")",
"except",
"TypeError",
"as",
"type_error",
":",
"... | Boolean response if a dictionary can convert into the proto's schema
:param value: <dict>
:param msg: <proto object>
:param raise_err: <bool> (default false) raise for troubleshooting
:return: <bool> whether the dict can covert | [
"Boolean",
"response",
"if",
"a",
"dictionary",
"can",
"convert",
"into",
"the",
"proto",
"s",
"schema"
] | b024cb44f34cabb9d80af38271ddb65c25767083 | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/checks.py#L67-L83 |
246,226 | ramrod-project/database-brain | schema/brain/checks.py | successfuly_encodes | def successfuly_encodes(msg, raise_err=False):
"""
boolean response if a message contains correct information to serialize
:param msg: <proto object>
:param raise_err: <bool>
:return: <bool>
"""
result = True
try:
msg.SerializeToString()
except EncodeError as encode_error:
... | python | def successfuly_encodes(msg, raise_err=False):
"""
boolean response if a message contains correct information to serialize
:param msg: <proto object>
:param raise_err: <bool>
:return: <bool>
"""
result = True
try:
msg.SerializeToString()
except EncodeError as encode_error:
... | [
"def",
"successfuly_encodes",
"(",
"msg",
",",
"raise_err",
"=",
"False",
")",
":",
"result",
"=",
"True",
"try",
":",
"msg",
".",
"SerializeToString",
"(",
")",
"except",
"EncodeError",
"as",
"encode_error",
":",
"if",
"raise_err",
":",
"raise",
"encode_err... | boolean response if a message contains correct information to serialize
:param msg: <proto object>
:param raise_err: <bool>
:return: <bool> | [
"boolean",
"response",
"if",
"a",
"message",
"contains",
"correct",
"information",
"to",
"serialize"
] | b024cb44f34cabb9d80af38271ddb65c25767083 | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/checks.py#L86-L101 |
246,227 | ramrod-project/database-brain | schema/brain/checks.py | strip | def strip(value, msg):
"""
Strips all non-essential keys from the value dictionary
given the message format protobuf
raises ValueError exception if value does not have all required keys
:param value: <dict> with arbitrary keys
:param msg: <protobuf> with a defined schema
:return: NEW <dict... | python | def strip(value, msg):
"""
Strips all non-essential keys from the value dictionary
given the message format protobuf
raises ValueError exception if value does not have all required keys
:param value: <dict> with arbitrary keys
:param msg: <protobuf> with a defined schema
:return: NEW <dict... | [
"def",
"strip",
"(",
"value",
",",
"msg",
")",
":",
"dict_to_protobuf",
".",
"dict_to_protobuf",
"(",
"value",
",",
"msg",
")",
"try",
":",
"msg",
".",
"SerializeToString",
"(",
")",
"#raise error for insufficient input",
"except",
"EncodeError",
"as",
"encode_e... | Strips all non-essential keys from the value dictionary
given the message format protobuf
raises ValueError exception if value does not have all required keys
:param value: <dict> with arbitrary keys
:param msg: <protobuf> with a defined schema
:return: NEW <dict> with keys defined by msg, omits a... | [
"Strips",
"all",
"non",
"-",
"essential",
"keys",
"from",
"the",
"value",
"dictionary",
"given",
"the",
"message",
"format",
"protobuf"
] | b024cb44f34cabb9d80af38271ddb65c25767083 | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/checks.py#L104-L121 |
246,228 | ulf1/oxyba | oxyba/clean_german_number.py | clean_german_number | def clean_german_number(x):
"""Convert a string with a German number into a Decimal
Parameters
----------
x : str, list, tuple, numpy.ndarray, pandas.DataFrame
A string with a number with German formatting,
or an array of these strings, e.g. list, ndarray, df.
Returns
-------
... | python | def clean_german_number(x):
"""Convert a string with a German number into a Decimal
Parameters
----------
x : str, list, tuple, numpy.ndarray, pandas.DataFrame
A string with a number with German formatting,
or an array of these strings, e.g. list, ndarray, df.
Returns
-------
... | [
"def",
"clean_german_number",
"(",
"x",
")",
":",
"import",
"numpy",
"as",
"np",
"import",
"pandas",
"as",
"pd",
"import",
"re",
"def",
"proc_elem",
"(",
"e",
")",
":",
"# abort if it is not a string",
"if",
"not",
"isinstance",
"(",
"e",
",",
"str",
")",
... | Convert a string with a German number into a Decimal
Parameters
----------
x : str, list, tuple, numpy.ndarray, pandas.DataFrame
A string with a number with German formatting,
or an array of these strings, e.g. list, ndarray, df.
Returns
-------
y : str, list, tuple, numpy.ndar... | [
"Convert",
"a",
"string",
"with",
"a",
"German",
"number",
"into",
"a",
"Decimal"
] | b3043116050de275124365cb11e7df91fb40169d | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/clean_german_number.py#L2-L121 |
246,229 | dustinmm80/healthy | pylint_runner.py | score | def score(package_path):
"""
Runs pylint on a package and returns a score
Lower score is better
:param package_path: path of the package to score
:return: number of score
"""
python_files = find_files(package_path, '*.py')
total_counter = Counter()
for python_file in python_files:... | python | def score(package_path):
"""
Runs pylint on a package and returns a score
Lower score is better
:param package_path: path of the package to score
:return: number of score
"""
python_files = find_files(package_path, '*.py')
total_counter = Counter()
for python_file in python_files:... | [
"def",
"score",
"(",
"package_path",
")",
":",
"python_files",
"=",
"find_files",
"(",
"package_path",
",",
"'*.py'",
")",
"total_counter",
"=",
"Counter",
"(",
")",
"for",
"python_file",
"in",
"python_files",
":",
"output",
"=",
"run_pylint",
"(",
"python_fil... | Runs pylint on a package and returns a score
Lower score is better
:param package_path: path of the package to score
:return: number of score | [
"Runs",
"pylint",
"on",
"a",
"package",
"and",
"returns",
"a",
"score",
"Lower",
"score",
"is",
"better"
] | b59016c3f578ca45b6ce857a2d5c4584b8542288 | https://github.com/dustinmm80/healthy/blob/b59016c3f578ca45b6ce857a2d5c4584b8542288/pylint_runner.py#L22-L44 |
246,230 | patchboard/patchboard-py | patchboard/base.py | discover | def discover(url, options={}):
"""
Retrieve the API definition from the given URL and construct
a Patchboard to interface with it.
"""
try:
resp = requests.get(url, headers=Patchboard.default_headers)
except Exception as e:
raise PatchboardError("Problem discovering API: {0}".for... | python | def discover(url, options={}):
"""
Retrieve the API definition from the given URL and construct
a Patchboard to interface with it.
"""
try:
resp = requests.get(url, headers=Patchboard.default_headers)
except Exception as e:
raise PatchboardError("Problem discovering API: {0}".for... | [
"def",
"discover",
"(",
"url",
",",
"options",
"=",
"{",
"}",
")",
":",
"try",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"headers",
"=",
"Patchboard",
".",
"default_headers",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
"Patc... | Retrieve the API definition from the given URL and construct
a Patchboard to interface with it. | [
"Retrieve",
"the",
"API",
"definition",
"from",
"the",
"given",
"URL",
"and",
"construct",
"a",
"Patchboard",
"to",
"interface",
"with",
"it",
"."
] | 3d9f66f3f26d71e769cd3a578b760441a237ce4d | https://github.com/patchboard/patchboard-py/blob/3d9f66f3f26d71e769cd3a578b760441a237ce4d/patchboard/base.py#L27-L44 |
246,231 | patchboard/patchboard-py | patchboard/base.py | Patchboard.spawn | def spawn(self, context=None):
"""
context may be a callable or a dict.
"""
if context is None:
context = self.default_context
if isinstance(context, collections.Callable):
context = context()
if not isinstance(context, collections.Mapping):
... | python | def spawn(self, context=None):
"""
context may be a callable or a dict.
"""
if context is None:
context = self.default_context
if isinstance(context, collections.Callable):
context = context()
if not isinstance(context, collections.Mapping):
... | [
"def",
"spawn",
"(",
"self",
",",
"context",
"=",
"None",
")",
":",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"self",
".",
"default_context",
"if",
"isinstance",
"(",
"context",
",",
"collections",
".",
"Callable",
")",
":",
"context",
"=",
"... | context may be a callable or a dict. | [
"context",
"may",
"be",
"a",
"callable",
"or",
"a",
"dict",
"."
] | 3d9f66f3f26d71e769cd3a578b760441a237ce4d | https://github.com/patchboard/patchboard-py/blob/3d9f66f3f26d71e769cd3a578b760441a237ce4d/patchboard/base.py#L114-L127 |
246,232 | jmatt/threepio | threepio/version.py | get_version | def get_version(form='short'):
"""
Returns the version string.
Takes single argument ``form``, which should be one of the following
strings:
* ``short`` Returns major + minor branch version string with the format of
B.b.t.
* ``normal`` Returns human readable version string with the for... | python | def get_version(form='short'):
"""
Returns the version string.
Takes single argument ``form``, which should be one of the following
strings:
* ``short`` Returns major + minor branch version string with the format of
B.b.t.
* ``normal`` Returns human readable version string with the for... | [
"def",
"get_version",
"(",
"form",
"=",
"'short'",
")",
":",
"versions",
"=",
"{",
"}",
"branch",
"=",
"\"%s.%s\"",
"%",
"(",
"VERSION",
"[",
"0",
"]",
",",
"VERSION",
"[",
"1",
"]",
")",
"tertiary",
"=",
"VERSION",
"[",
"2",
"]",
"type_",
"=",
"... | Returns the version string.
Takes single argument ``form``, which should be one of the following
strings:
* ``short`` Returns major + minor branch version string with the format of
B.b.t.
* ``normal`` Returns human readable version string with the format of
B.b.t _type type_num.
* ``v... | [
"Returns",
"the",
"version",
"string",
"."
] | 91e2835c85c1618fcc4a1357dbb398353e662d1a | https://github.com/jmatt/threepio/blob/91e2835c85c1618fcc4a1357dbb398353e662d1a/threepio/version.py#L22-L60 |
246,233 | jjjake/giganews | giganews/giganews.py | NewsGroup._download_article | def _download_article(self, article_number, max_retries=10):
"""Download a given article.
:type article_number: str
:param article_number: the article number to download.
:type group: str
:param group: the group that contains the article to be downloaded.
:returns: nnt... | python | def _download_article(self, article_number, max_retries=10):
"""Download a given article.
:type article_number: str
:param article_number: the article number to download.
:type group: str
:param group: the group that contains the article to be downloaded.
:returns: nnt... | [
"def",
"_download_article",
"(",
"self",
",",
"article_number",
",",
"max_retries",
"=",
"10",
")",
":",
"log",
".",
"debug",
"(",
"'downloading article {0} from {1}'",
".",
"format",
"(",
"article_number",
",",
"self",
".",
"name",
")",
")",
"_connection",
"=... | Download a given article.
:type article_number: str
:param article_number: the article number to download.
:type group: str
:param group: the group that contains the article to be downloaded.
:returns: nntplib article response object if successful, else False. | [
"Download",
"a",
"given",
"article",
"."
] | 8cfb26de6c10c482a8da348d438f0ce19e477573 | https://github.com/jjjake/giganews/blob/8cfb26de6c10c482a8da348d438f0ce19e477573/giganews/giganews.py#L280-L331 |
246,234 | jjjake/giganews | giganews/giganews.py | NewsGroup.index_article | def index_article(self, msg_str, article_number, start, length):
"""Add article to index file.
:type msg_str: str
:param msg_str: the message string to index.
:type article_number: str
:param article_number: the article number to index.
:type start: int
:param ... | python | def index_article(self, msg_str, article_number, start, length):
"""Add article to index file.
:type msg_str: str
:param msg_str: the message string to index.
:type article_number: str
:param article_number: the article number to index.
:type start: int
:param ... | [
"def",
"index_article",
"(",
"self",
",",
"msg_str",
",",
"article_number",
",",
"start",
",",
"length",
")",
":",
"f",
"=",
"cStringIO",
".",
"StringIO",
"(",
"msg_str",
")",
"message",
"=",
"rfc822",
".",
"Message",
"(",
"f",
")",
"f",
".",
"close",
... | Add article to index file.
:type msg_str: str
:param msg_str: the message string to index.
:type article_number: str
:param article_number: the article number to index.
:type start: int
:param start: the byte-offset where a given message starts in the
... | [
"Add",
"article",
"to",
"index",
"file",
"."
] | 8cfb26de6c10c482a8da348d438f0ce19e477573 | https://github.com/jjjake/giganews/blob/8cfb26de6c10c482a8da348d438f0ce19e477573/giganews/giganews.py#L375-L429 |
246,235 | jjjake/giganews | giganews/giganews.py | NewsGroup.compress_and_sort_index | def compress_and_sort_index(self):
"""Sort index, add header, and compress.
:rtype: bool
:returns: True
"""
idx_fname = '{name}.{date}.mbox.csv'.format(**self.__dict__)
try:
reader = csv.reader(open(idx_fname), dialect='excel-tab')
except IOError:
... | python | def compress_and_sort_index(self):
"""Sort index, add header, and compress.
:rtype: bool
:returns: True
"""
idx_fname = '{name}.{date}.mbox.csv'.format(**self.__dict__)
try:
reader = csv.reader(open(idx_fname), dialect='excel-tab')
except IOError:
... | [
"def",
"compress_and_sort_index",
"(",
"self",
")",
":",
"idx_fname",
"=",
"'{name}.{date}.mbox.csv'",
".",
"format",
"(",
"*",
"*",
"self",
".",
"__dict__",
")",
"try",
":",
"reader",
"=",
"csv",
".",
"reader",
"(",
"open",
"(",
"idx_fname",
")",
",",
"... | Sort index, add header, and compress.
:rtype: bool
:returns: True | [
"Sort",
"index",
"add",
"header",
"and",
"compress",
"."
] | 8cfb26de6c10c482a8da348d438f0ce19e477573 | https://github.com/jjjake/giganews/blob/8cfb26de6c10c482a8da348d438f0ce19e477573/giganews/giganews.py#L434-L467 |
246,236 | seryl/Python-Couchdbhelper | couchdbhelper/__init__.py | CouchHelper.save | def save(self, data):
"""Save a document or list of documents"""
if not self.is_connected:
raise Exception("No database selected")
if not data:
return False
if isinstance(data, dict):
doc = couchdb.Document()
doc.update(data)
se... | python | def save(self, data):
"""Save a document or list of documents"""
if not self.is_connected:
raise Exception("No database selected")
if not data:
return False
if isinstance(data, dict):
doc = couchdb.Document()
doc.update(data)
se... | [
"def",
"save",
"(",
"self",
",",
"data",
")",
":",
"if",
"not",
"self",
".",
"is_connected",
":",
"raise",
"Exception",
"(",
"\"No database selected\"",
")",
"if",
"not",
"data",
":",
"return",
"False",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
... | Save a document or list of documents | [
"Save",
"a",
"document",
"or",
"list",
"of",
"documents"
] | 6783b777dd793da91ba6a2102f932492556ecbcd | https://github.com/seryl/Python-Couchdbhelper/blob/6783b777dd793da91ba6a2102f932492556ecbcd/couchdbhelper/__init__.py#L42-L56 |
246,237 | jrabbit/austere | austere.py | win_register | def win_register():
"need to be admin"
try:
with winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, "austere.HTTP") as k:
# winreg.SetValue(k, None, winreg.REG_SZ, "{} austere".format(sys.argv[0]))
logger.debug("\shell")
with winreg.CreateKey(k, "shell") as shellkey:
... | python | def win_register():
"need to be admin"
try:
with winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, "austere.HTTP") as k:
# winreg.SetValue(k, None, winreg.REG_SZ, "{} austere".format(sys.argv[0]))
logger.debug("\shell")
with winreg.CreateKey(k, "shell") as shellkey:
... | [
"def",
"win_register",
"(",
")",
":",
"try",
":",
"with",
"winreg",
".",
"CreateKey",
"(",
"winreg",
".",
"HKEY_CLASSES_ROOT",
",",
"\"austere.HTTP\"",
")",
"as",
"k",
":",
"# winreg.SetValue(k, None, winreg.REG_SZ, \"{} austere\".format(sys.argv[0]))",
"logger",
".",
... | need to be admin | [
"need",
"to",
"be",
"admin"
] | 3f062c70ae37ce9e63dd639f524cbb88247fc92c | https://github.com/jrabbit/austere/blob/3f062c70ae37ce9e63dd639f524cbb88247fc92c/austere.py#L102-L117 |
246,238 | GaretJax/irco | irco/conf.py | load_config | def load_config(path=None, defaults=None):
"""
Loads and parses an INI style configuration file using Python's built-in
ConfigParser module.
If path is specified, load it.
If ``defaults`` (a list of strings) is given, try to load each entry as a
file, without throwing any error if the operatio... | python | def load_config(path=None, defaults=None):
"""
Loads and parses an INI style configuration file using Python's built-in
ConfigParser module.
If path is specified, load it.
If ``defaults`` (a list of strings) is given, try to load each entry as a
file, without throwing any error if the operatio... | [
"def",
"load_config",
"(",
"path",
"=",
"None",
",",
"defaults",
"=",
"None",
")",
":",
"if",
"defaults",
"is",
"None",
":",
"defaults",
"=",
"DEFAULT_FILES",
"config",
"=",
"configparser",
".",
"SafeConfigParser",
"(",
"allow_no_value",
"=",
"True",
")",
... | Loads and parses an INI style configuration file using Python's built-in
ConfigParser module.
If path is specified, load it.
If ``defaults`` (a list of strings) is given, try to load each entry as a
file, without throwing any error if the operation fails.
If ``defaults`` is not given, the followi... | [
"Loads",
"and",
"parses",
"an",
"INI",
"style",
"configuration",
"file",
"using",
"Python",
"s",
"built",
"-",
"in",
"ConfigParser",
"module",
"."
] | e5df3cf1a608dc813011a1ee7e920637e5bd155c | https://github.com/GaretJax/irco/blob/e5df3cf1a608dc813011a1ee7e920637e5bd155c/irco/conf.py#L23-L53 |
246,239 | sys-git/certifiable | certifiable/cli_impl/utils.py | load_value_from_schema | def load_value_from_schema(v):
"""
Load a value from a schema defined string.
"""
x = urllib.parse.urlparse(v)
if x.scheme.lower() == 'decimal':
v = Decimal(x.netloc)
elif x.scheme.lower() in ['int', 'integer']:
v = int(x.netloc)
elif x.scheme.lower() == 'float':
v =... | python | def load_value_from_schema(v):
"""
Load a value from a schema defined string.
"""
x = urllib.parse.urlparse(v)
if x.scheme.lower() == 'decimal':
v = Decimal(x.netloc)
elif x.scheme.lower() in ['int', 'integer']:
v = int(x.netloc)
elif x.scheme.lower() == 'float':
v =... | [
"def",
"load_value_from_schema",
"(",
"v",
")",
":",
"x",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"v",
")",
"if",
"x",
".",
"scheme",
".",
"lower",
"(",
")",
"==",
"'decimal'",
":",
"v",
"=",
"Decimal",
"(",
"x",
".",
"netloc",
")",
"e... | Load a value from a schema defined string. | [
"Load",
"a",
"value",
"from",
"a",
"schema",
"defined",
"string",
"."
] | a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8 | https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/cli_impl/utils.py#L73-L110 |
246,240 | sys-git/certifiable | certifiable/cli_impl/utils.py | parse_value | def parse_value(v, parser, config, description):
"""
Convert a string received on the command-line into
a value or None.
:param str v:
The value to parse.
:param parser:
The fallback callable to load the value if loading
from scheme fails.
:param dict config:
The... | python | def parse_value(v, parser, config, description):
"""
Convert a string received on the command-line into
a value or None.
:param str v:
The value to parse.
:param parser:
The fallback callable to load the value if loading
from scheme fails.
:param dict config:
The... | [
"def",
"parse_value",
"(",
"v",
",",
"parser",
",",
"config",
",",
"description",
")",
":",
"val",
"=",
"None",
"if",
"v",
"==",
"''",
":",
"return",
"if",
"v",
"is",
"not",
"None",
":",
"try",
":",
"val",
"=",
"load_value_from_schema",
"(",
"v",
"... | Convert a string received on the command-line into
a value or None.
:param str v:
The value to parse.
:param parser:
The fallback callable to load the value if loading
from scheme fails.
:param dict config:
The config to use.
:param str description:
Descripti... | [
"Convert",
"a",
"string",
"received",
"on",
"the",
"command",
"-",
"line",
"into",
"a",
"value",
"or",
"None",
"."
] | a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8 | https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/cli_impl/utils.py#L113-L182 |
246,241 | coumbole/mailscanner | mailscanner/parser.py | get_simple_date | def get_simple_date(datestring):
"""Transforms a datestring into shorter date 7.9.2017 > 07.09
Expects the datestring to be format 07.09.2017. If this is not the
case, returns string "Failed".
Keyword arguments:
datestring -- a string
Returns:
String -- The date in format "dd.MM." or "Fai... | python | def get_simple_date(datestring):
"""Transforms a datestring into shorter date 7.9.2017 > 07.09
Expects the datestring to be format 07.09.2017. If this is not the
case, returns string "Failed".
Keyword arguments:
datestring -- a string
Returns:
String -- The date in format "dd.MM." or "Fai... | [
"def",
"get_simple_date",
"(",
"datestring",
")",
":",
"simple_date",
"=",
"re",
".",
"compile",
"(",
"r\"\\d{1,2}(\\.)\\d{1,2}\"",
")",
"date",
"=",
"simple_date",
".",
"search",
"(",
"datestring",
")",
"if",
"date",
":",
"dates",
"=",
"date",
".",
"group",... | Transforms a datestring into shorter date 7.9.2017 > 07.09
Expects the datestring to be format 07.09.2017. If this is not the
case, returns string "Failed".
Keyword arguments:
datestring -- a string
Returns:
String -- The date in format "dd.MM." or "Failed" | [
"Transforms",
"a",
"datestring",
"into",
"shorter",
"date",
"7",
".",
"9",
".",
"2017",
">",
"07",
".",
"09"
] | ead19ac8c7dee27e507c1593032863232c13f636 | https://github.com/coumbole/mailscanner/blob/ead19ac8c7dee27e507c1593032863232c13f636/mailscanner/parser.py#L32-L55 |
246,242 | coumbole/mailscanner | mailscanner/parser.py | get_month | def get_month(datestring):
"""Transforms a written month into corresponding month number.
E.g. November -> 11, or May -> 05.
Keyword arguments:
datestring -- a string
Returns:
String, or None if the transformation fails
"""
convert_written = re.compile(r"jan|feb|mar|apr|may|jun|jul|au... | python | def get_month(datestring):
"""Transforms a written month into corresponding month number.
E.g. November -> 11, or May -> 05.
Keyword arguments:
datestring -- a string
Returns:
String, or None if the transformation fails
"""
convert_written = re.compile(r"jan|feb|mar|apr|may|jun|jul|au... | [
"def",
"get_month",
"(",
"datestring",
")",
":",
"convert_written",
"=",
"re",
".",
"compile",
"(",
"r\"jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec\"",
",",
"re",
".",
"IGNORECASE",
")",
"month",
"=",
"convert_written",
".",
"search",
"(",
"datestring",
")",
"... | Transforms a written month into corresponding month number.
E.g. November -> 11, or May -> 05.
Keyword arguments:
datestring -- a string
Returns:
String, or None if the transformation fails | [
"Transforms",
"a",
"written",
"month",
"into",
"corresponding",
"month",
"number",
"."
] | ead19ac8c7dee27e507c1593032863232c13f636 | https://github.com/coumbole/mailscanner/blob/ead19ac8c7dee27e507c1593032863232c13f636/mailscanner/parser.py#L58-L79 |
246,243 | coumbole/mailscanner | mailscanner/parser.py | get_day_of_month | def get_day_of_month(datestring):
"""Transforms an ordinal number into plain number with padding zero.
E.g. 3rd -> 03, or 12th -> 12
Keyword arguments:
datestring -- a string
Returns:
String, or None if the transformation fails
"""
get_day = re.compile(r"\d{1,2}(st|nd|rd|th)?", re.IGN... | python | def get_day_of_month(datestring):
"""Transforms an ordinal number into plain number with padding zero.
E.g. 3rd -> 03, or 12th -> 12
Keyword arguments:
datestring -- a string
Returns:
String, or None if the transformation fails
"""
get_day = re.compile(r"\d{1,2}(st|nd|rd|th)?", re.IGN... | [
"def",
"get_day_of_month",
"(",
"datestring",
")",
":",
"get_day",
"=",
"re",
".",
"compile",
"(",
"r\"\\d{1,2}(st|nd|rd|th)?\"",
",",
"re",
".",
"IGNORECASE",
")",
"day",
"=",
"get_day",
".",
"search",
"(",
"datestring",
")",
"the_day",
"=",
"None",
"if",
... | Transforms an ordinal number into plain number with padding zero.
E.g. 3rd -> 03, or 12th -> 12
Keyword arguments:
datestring -- a string
Returns:
String, or None if the transformation fails | [
"Transforms",
"an",
"ordinal",
"number",
"into",
"plain",
"number",
"with",
"padding",
"zero",
"."
] | ead19ac8c7dee27e507c1593032863232c13f636 | https://github.com/coumbole/mailscanner/blob/ead19ac8c7dee27e507c1593032863232c13f636/mailscanner/parser.py#L81-L104 |
246,244 | coumbole/mailscanner | mailscanner/parser.py | Parser.strip_string | def strip_string(self, string, *args):
"""Strips matching regular expressions from string
Keyword arguments:
string -- The given string, that will be stripped
*args -- List of regex strings, that are used in parsing
Returns:
String with *args removed from string
... | python | def strip_string(self, string, *args):
"""Strips matching regular expressions from string
Keyword arguments:
string -- The given string, that will be stripped
*args -- List of regex strings, that are used in parsing
Returns:
String with *args removed from string
... | [
"def",
"strip_string",
"(",
"self",
",",
"string",
",",
"*",
"args",
")",
":",
"res",
"=",
"string",
"for",
"r",
"in",
"args",
":",
"res",
"=",
"re",
".",
"sub",
"(",
"r",
",",
"\"\"",
",",
"res",
".",
"strip",
"(",
")",
",",
"flags",
"=",
"r... | Strips matching regular expressions from string
Keyword arguments:
string -- The given string, that will be stripped
*args -- List of regex strings, that are used in parsing
Returns:
String with *args removed from string | [
"Strips",
"matching",
"regular",
"expressions",
"from",
"string"
] | ead19ac8c7dee27e507c1593032863232c13f636 | https://github.com/coumbole/mailscanner/blob/ead19ac8c7dee27e507c1593032863232c13f636/mailscanner/parser.py#L112-L126 |
246,245 | coumbole/mailscanner | mailscanner/parser.py | Parser.strip_between | def strip_between(self, string, start, end):
"""Deletes everything between regexes start and end from string"""
regex = start + r'.*?' + end + r'\s*'
res = re.sub(regex, '', string,
flags=re.DOTALL|re.IGNORECASE|re.MULTILINE)
return res | python | def strip_between(self, string, start, end):
"""Deletes everything between regexes start and end from string"""
regex = start + r'.*?' + end + r'\s*'
res = re.sub(regex, '', string,
flags=re.DOTALL|re.IGNORECASE|re.MULTILINE)
return res | [
"def",
"strip_between",
"(",
"self",
",",
"string",
",",
"start",
",",
"end",
")",
":",
"regex",
"=",
"start",
"+",
"r'.*?'",
"+",
"end",
"+",
"r'\\s*'",
"res",
"=",
"re",
".",
"sub",
"(",
"regex",
",",
"''",
",",
"string",
",",
"flags",
"=",
"re... | Deletes everything between regexes start and end from string | [
"Deletes",
"everything",
"between",
"regexes",
"start",
"and",
"end",
"from",
"string"
] | ead19ac8c7dee27e507c1593032863232c13f636 | https://github.com/coumbole/mailscanner/blob/ead19ac8c7dee27e507c1593032863232c13f636/mailscanner/parser.py#L128-L133 |
246,246 | coumbole/mailscanner | mailscanner/parser.py | Parser.distance_between | def distance_between(self, string, start, end):
"""Returns number of lines between start and end"""
count = 0
started = False
for line in string.split("\n"):
if self.scan_line(line, start) and not started:
started = True
if self.scan_line(line, ... | python | def distance_between(self, string, start, end):
"""Returns number of lines between start and end"""
count = 0
started = False
for line in string.split("\n"):
if self.scan_line(line, start) and not started:
started = True
if self.scan_line(line, ... | [
"def",
"distance_between",
"(",
"self",
",",
"string",
",",
"start",
",",
"end",
")",
":",
"count",
"=",
"0",
"started",
"=",
"False",
"for",
"line",
"in",
"string",
".",
"split",
"(",
"\"\\n\"",
")",
":",
"if",
"self",
".",
"scan_line",
"(",
"line",... | Returns number of lines between start and end | [
"Returns",
"number",
"of",
"lines",
"between",
"start",
"and",
"end"
] | ead19ac8c7dee27e507c1593032863232c13f636 | https://github.com/coumbole/mailscanner/blob/ead19ac8c7dee27e507c1593032863232c13f636/mailscanner/parser.py#L135-L151 |
246,247 | coumbole/mailscanner | mailscanner/parser.py | Parser.scan_line | def scan_line(self, line, regex):
"""Checks if regex is in line, returns bool"""
return bool(re.search(regex, line, flags=re.IGNORECASE)) | python | def scan_line(self, line, regex):
"""Checks if regex is in line, returns bool"""
return bool(re.search(regex, line, flags=re.IGNORECASE)) | [
"def",
"scan_line",
"(",
"self",
",",
"line",
",",
"regex",
")",
":",
"return",
"bool",
"(",
"re",
".",
"search",
"(",
"regex",
",",
"line",
",",
"flags",
"=",
"re",
".",
"IGNORECASE",
")",
")"
] | Checks if regex is in line, returns bool | [
"Checks",
"if",
"regex",
"is",
"in",
"line",
"returns",
"bool"
] | ead19ac8c7dee27e507c1593032863232c13f636 | https://github.com/coumbole/mailscanner/blob/ead19ac8c7dee27e507c1593032863232c13f636/mailscanner/parser.py#L153-L155 |
246,248 | coumbole/mailscanner | mailscanner/parser.py | Parser.scan_message | def scan_message(self, message, regex):
"""Scans regex from msg and returns the line that matches
Keyword arguments:
message -- A (long) string, e.g. email body that will be
scanned.
regex -- A regular expression string that the message will be
scanned against.
... | python | def scan_message(self, message, regex):
"""Scans regex from msg and returns the line that matches
Keyword arguments:
message -- A (long) string, e.g. email body that will be
scanned.
regex -- A regular expression string that the message will be
scanned against.
... | [
"def",
"scan_message",
"(",
"self",
",",
"message",
",",
"regex",
")",
":",
"for",
"line",
"in",
"message",
".",
"split",
"(",
"\"\\n\"",
")",
":",
"if",
"bool",
"(",
"re",
".",
"search",
"(",
"regex",
",",
"line",
",",
"flags",
"=",
"re",
".",
"... | Scans regex from msg and returns the line that matches
Keyword arguments:
message -- A (long) string, e.g. email body that will be
scanned.
regex -- A regular expression string that the message will be
scanned against.
Returns:
Matching line or empty string | [
"Scans",
"regex",
"from",
"msg",
"and",
"returns",
"the",
"line",
"that",
"matches"
] | ead19ac8c7dee27e507c1593032863232c13f636 | https://github.com/coumbole/mailscanner/blob/ead19ac8c7dee27e507c1593032863232c13f636/mailscanner/parser.py#L157-L176 |
246,249 | coumbole/mailscanner | mailscanner/parser.py | Parser.format_date | def format_date(self, dl_string):
"""Formats various date formats to dd.MM.
Examples
- January 15th --> 15.01.
- 15.01.2017 --> 15.01.
- 15th of January --> 15.01.
- 15.1. --> 15.01.
Keyword arguments:
dl_string -- a string to b... | python | def format_date(self, dl_string):
"""Formats various date formats to dd.MM.
Examples
- January 15th --> 15.01.
- 15.01.2017 --> 15.01.
- 15th of January --> 15.01.
- 15.1. --> 15.01.
Keyword arguments:
dl_string -- a string to b... | [
"def",
"format_date",
"(",
"self",
",",
"dl_string",
")",
":",
"thedate",
"=",
"get_simple_date",
"(",
"dl_string",
")",
"if",
"thedate",
"!=",
"\"Failed\"",
"and",
"thedate",
":",
"return",
"thedate",
"day",
"=",
"get_day_of_month",
"(",
"dl_string",
")",
"... | Formats various date formats to dd.MM.
Examples
- January 15th --> 15.01.
- 15.01.2017 --> 15.01.
- 15th of January --> 15.01.
- 15.1. --> 15.01.
Keyword arguments:
dl_string -- a string to be formatted
Returns:
Date st... | [
"Formats",
"various",
"date",
"formats",
"to",
"dd",
".",
"MM",
"."
] | ead19ac8c7dee27e507c1593032863232c13f636 | https://github.com/coumbole/mailscanner/blob/ead19ac8c7dee27e507c1593032863232c13f636/mailscanner/parser.py#L182-L204 |
246,250 | kilometer-io/kilometer-python | kilometer/__init__.py | EventsAPIClient.add_user | def add_user(self, user_id, custom_properties=None, headers=None, endpoint_url=None):
"""
Creates a new identified user if he doesn't exist.
:param str user_id: identified user's ID
:param dict custom_properties: user properties
:param dict headers: custom request headers (if is... | python | def add_user(self, user_id, custom_properties=None, headers=None, endpoint_url=None):
"""
Creates a new identified user if he doesn't exist.
:param str user_id: identified user's ID
:param dict custom_properties: user properties
:param dict headers: custom request headers (if is... | [
"def",
"add_user",
"(",
"self",
",",
"user_id",
",",
"custom_properties",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"endpoint_url",
"=",
"None",
")",
":",
"endpoint_url",
"=",
"endpoint_url",
"or",
"self",
".",
"_endpoint_url",
"url",
"=",
"endpoint_url... | Creates a new identified user if he doesn't exist.
:param str user_id: identified user's ID
:param dict custom_properties: user properties
:param dict headers: custom request headers (if isn't set default values are used)
:param str endpoint_url: where to send the request (if isn't set ... | [
"Creates",
"a",
"new",
"identified",
"user",
"if",
"he",
"doesn",
"t",
"exist",
"."
] | 22a720cfed5aa74d4957b4597f224cede2e7c0e5 | https://github.com/kilometer-io/kilometer-python/blob/22a720cfed5aa74d4957b4597f224cede2e7c0e5/kilometer/__init__.py#L44-L66 |
246,251 | kilometer-io/kilometer-python | kilometer/__init__.py | EventsAPIClient.add_event | def add_event(self, user_id, event_name, event_properties=None, headers=None, endpoint_url=None):
"""
Send an identified event. If a user doesn't exist it will create one.
:param str user_id: identified user's ID
:param str event_name: event name (e.g. "visit_website")
:param di... | python | def add_event(self, user_id, event_name, event_properties=None, headers=None, endpoint_url=None):
"""
Send an identified event. If a user doesn't exist it will create one.
:param str user_id: identified user's ID
:param str event_name: event name (e.g. "visit_website")
:param di... | [
"def",
"add_event",
"(",
"self",
",",
"user_id",
",",
"event_name",
",",
"event_properties",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"endpoint_url",
"=",
"None",
")",
":",
"endpoint_url",
"=",
"endpoint_url",
"or",
"self",
".",
"_endpoint_url",
"url",... | Send an identified event. If a user doesn't exist it will create one.
:param str user_id: identified user's ID
:param str event_name: event name (e.g. "visit_website")
:param dict event_properties: properties that describe the event's details
:param dict headers: custom request headers ... | [
"Send",
"an",
"identified",
"event",
".",
"If",
"a",
"user",
"doesn",
"t",
"exist",
"it",
"will",
"create",
"one",
"."
] | 22a720cfed5aa74d4957b4597f224cede2e7c0e5 | https://github.com/kilometer-io/kilometer-python/blob/22a720cfed5aa74d4957b4597f224cede2e7c0e5/kilometer/__init__.py#L68-L92 |
246,252 | kilometer-io/kilometer-python | kilometer/__init__.py | EventsAPIClient.decrease_user_property | def decrease_user_property(self, user_id, property_name, value=0, headers=None, endpoint_url=None):
"""
Decrease a user's property by a value.
:param str user_id: identified user's ID
:param str property_name: user property name to increase
:param number value: amount by which t... | python | def decrease_user_property(self, user_id, property_name, value=0, headers=None, endpoint_url=None):
"""
Decrease a user's property by a value.
:param str user_id: identified user's ID
:param str property_name: user property name to increase
:param number value: amount by which t... | [
"def",
"decrease_user_property",
"(",
"self",
",",
"user_id",
",",
"property_name",
",",
"value",
"=",
"0",
",",
"headers",
"=",
"None",
",",
"endpoint_url",
"=",
"None",
")",
":",
"endpoint_url",
"=",
"endpoint_url",
"or",
"self",
".",
"_endpoint_url",
"url... | Decrease a user's property by a value.
:param str user_id: identified user's ID
:param str property_name: user property name to increase
:param number value: amount by which to decrease the property
:param dict headers: custom request headers (if isn't set default values are used)
... | [
"Decrease",
"a",
"user",
"s",
"property",
"by",
"a",
"value",
"."
] | 22a720cfed5aa74d4957b4597f224cede2e7c0e5 | https://github.com/kilometer-io/kilometer-python/blob/22a720cfed5aa74d4957b4597f224cede2e7c0e5/kilometer/__init__.py#L114-L132 |
246,253 | kilometer-io/kilometer-python | kilometer/__init__.py | EventsAPIClient.update_user_properties | def update_user_properties(self, user_id, user_properties, headers=None, endpoint_url=None):
"""
Update a user's properties with values provided in "user_properties" dictionary
:param str user_id: identified user's ID
:param dict user_properties: user properties to update with a new val... | python | def update_user_properties(self, user_id, user_properties, headers=None, endpoint_url=None):
"""
Update a user's properties with values provided in "user_properties" dictionary
:param str user_id: identified user's ID
:param dict user_properties: user properties to update with a new val... | [
"def",
"update_user_properties",
"(",
"self",
",",
"user_id",
",",
"user_properties",
",",
"headers",
"=",
"None",
",",
"endpoint_url",
"=",
"None",
")",
":",
"endpoint_url",
"=",
"endpoint_url",
"or",
"self",
".",
"_endpoint_url",
"url",
"=",
"endpoint_url",
... | Update a user's properties with values provided in "user_properties" dictionary
:param str user_id: identified user's ID
:param dict user_properties: user properties to update with a new values
:param dict headers: custom request headers (if isn't set default values are used)
:param str... | [
"Update",
"a",
"user",
"s",
"properties",
"with",
"values",
"provided",
"in",
"user_properties",
"dictionary"
] | 22a720cfed5aa74d4957b4597f224cede2e7c0e5 | https://github.com/kilometer-io/kilometer-python/blob/22a720cfed5aa74d4957b4597f224cede2e7c0e5/kilometer/__init__.py#L134-L152 |
246,254 | kilometer-io/kilometer-python | kilometer/__init__.py | EventsAPIClient.link_user_to_group | def link_user_to_group(self, user_id, group_id, headers=None, endpoint_url=None):
"""
Links a user to a group
:param str user_id: identified user's ID
:param str group_id: group ID
:param dict headers: custom request headers (if isn't set default values are used)
:param ... | python | def link_user_to_group(self, user_id, group_id, headers=None, endpoint_url=None):
"""
Links a user to a group
:param str user_id: identified user's ID
:param str group_id: group ID
:param dict headers: custom request headers (if isn't set default values are used)
:param ... | [
"def",
"link_user_to_group",
"(",
"self",
",",
"user_id",
",",
"group_id",
",",
"headers",
"=",
"None",
",",
"endpoint_url",
"=",
"None",
")",
":",
"endpoint_url",
"=",
"endpoint_url",
"or",
"self",
".",
"_endpoint_url",
"url",
"=",
"endpoint_url",
"+",
"'/g... | Links a user to a group
:param str user_id: identified user's ID
:param str group_id: group ID
:param dict headers: custom request headers (if isn't set default values are used)
:param str endpoint_url: where to send the request (if isn't set default value is used)
:return: Resp... | [
"Links",
"a",
"user",
"to",
"a",
"group"
] | 22a720cfed5aa74d4957b4597f224cede2e7c0e5 | https://github.com/kilometer-io/kilometer-python/blob/22a720cfed5aa74d4957b4597f224cede2e7c0e5/kilometer/__init__.py#L154-L171 |
246,255 | kilometer-io/kilometer-python | kilometer/__init__.py | EventsAPIClient.update_group_properties | def update_group_properties(self, group_id, group_properties, headers=None, endpoint_url=None):
"""
Update a group's properties with values provided in "group_properties" dictionary
:param str group_id: group ID
:param dict group_properties: group properties to update with a new values
... | python | def update_group_properties(self, group_id, group_properties, headers=None, endpoint_url=None):
"""
Update a group's properties with values provided in "group_properties" dictionary
:param str group_id: group ID
:param dict group_properties: group properties to update with a new values
... | [
"def",
"update_group_properties",
"(",
"self",
",",
"group_id",
",",
"group_properties",
",",
"headers",
"=",
"None",
",",
"endpoint_url",
"=",
"None",
")",
":",
"endpoint_url",
"=",
"endpoint_url",
"or",
"self",
".",
"_endpoint_url",
"url",
"=",
"endpoint_url",... | Update a group's properties with values provided in "group_properties" dictionary
:param str group_id: group ID
:param dict group_properties: group properties to update with a new values
:param dict headers: custom request headers (if isn't set default values are used)
:param str endpoi... | [
"Update",
"a",
"group",
"s",
"properties",
"with",
"values",
"provided",
"in",
"group_properties",
"dictionary"
] | 22a720cfed5aa74d4957b4597f224cede2e7c0e5 | https://github.com/kilometer-io/kilometer-python/blob/22a720cfed5aa74d4957b4597f224cede2e7c0e5/kilometer/__init__.py#L173-L191 |
246,256 | langloisjp/pysvcmetrics | statsdclient.py | StatsdClient.timing | def timing(self, stats, value):
"""
Log timing information
>>> client = StatsdClient()
>>> client.timing('example.timing', 500)
>>> client.timing(('example.timing23', 'example.timing29'), 500)
"""
self.update_stats(stats, value, self.SC_TIMING) | python | def timing(self, stats, value):
"""
Log timing information
>>> client = StatsdClient()
>>> client.timing('example.timing', 500)
>>> client.timing(('example.timing23', 'example.timing29'), 500)
"""
self.update_stats(stats, value, self.SC_TIMING) | [
"def",
"timing",
"(",
"self",
",",
"stats",
",",
"value",
")",
":",
"self",
".",
"update_stats",
"(",
"stats",
",",
"value",
",",
"self",
".",
"SC_TIMING",
")"
] | Log timing information
>>> client = StatsdClient()
>>> client.timing('example.timing', 500)
>>> client.timing(('example.timing23', 'example.timing29'), 500) | [
"Log",
"timing",
"information"
] | a126fc029ab645d9db46c0f5712c416cdf80e370 | https://github.com/langloisjp/pysvcmetrics/blob/a126fc029ab645d9db46c0f5712c416cdf80e370/statsdclient.py#L30-L38 |
246,257 | langloisjp/pysvcmetrics | statsdclient.py | StatsdClient.count | def count(self, stats, value, sample_rate=1):
"""
Updates one or more stats counters by arbitrary value
>>> client = StatsdClient()
>>> client.count('example.counter', 17)
"""
self.update_stats(stats, value, self.SC_COUNT, sample_rate) | python | def count(self, stats, value, sample_rate=1):
"""
Updates one or more stats counters by arbitrary value
>>> client = StatsdClient()
>>> client.count('example.counter', 17)
"""
self.update_stats(stats, value, self.SC_COUNT, sample_rate) | [
"def",
"count",
"(",
"self",
",",
"stats",
",",
"value",
",",
"sample_rate",
"=",
"1",
")",
":",
"self",
".",
"update_stats",
"(",
"stats",
",",
"value",
",",
"self",
".",
"SC_COUNT",
",",
"sample_rate",
")"
] | Updates one or more stats counters by arbitrary value
>>> client = StatsdClient()
>>> client.count('example.counter', 17) | [
"Updates",
"one",
"or",
"more",
"stats",
"counters",
"by",
"arbitrary",
"value"
] | a126fc029ab645d9db46c0f5712c416cdf80e370 | https://github.com/langloisjp/pysvcmetrics/blob/a126fc029ab645d9db46c0f5712c416cdf80e370/statsdclient.py#L79-L86 |
246,258 | langloisjp/pysvcmetrics | statsdclient.py | StatsdClient.timeit | def timeit(self, metric, func, *args, **kwargs):
"""
Times given function and log metric in ms for duration of execution.
>>> import time
>>> client = StatsdClient()
>>> client.timeit("latency", time.sleep, 0.5)
"""
(res, seconds) = timeit(func, *args, **kwargs)
... | python | def timeit(self, metric, func, *args, **kwargs):
"""
Times given function and log metric in ms for duration of execution.
>>> import time
>>> client = StatsdClient()
>>> client.timeit("latency", time.sleep, 0.5)
"""
(res, seconds) = timeit(func, *args, **kwargs)
... | [
"def",
"timeit",
"(",
"self",
",",
"metric",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"(",
"res",
",",
"seconds",
")",
"=",
"timeit",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"timing",
... | Times given function and log metric in ms for duration of execution.
>>> import time
>>> client = StatsdClient()
>>> client.timeit("latency", time.sleep, 0.5) | [
"Times",
"given",
"function",
"and",
"log",
"metric",
"in",
"ms",
"for",
"duration",
"of",
"execution",
"."
] | a126fc029ab645d9db46c0f5712c416cdf80e370 | https://github.com/langloisjp/pysvcmetrics/blob/a126fc029ab645d9db46c0f5712c416cdf80e370/statsdclient.py#L88-L98 |
246,259 | langloisjp/pysvcmetrics | statsdclient.py | StatsdClient.format | def format(keys, value, _type, prefix=""):
"""
General format function.
>>> StatsdClient.format("example.format", 2, "T")
{'example.format': '2|T'}
>>> StatsdClient.format(("example.format31", "example.format37"), "2",
... "T")
{'example.format31': '2|T', 'exampl... | python | def format(keys, value, _type, prefix=""):
"""
General format function.
>>> StatsdClient.format("example.format", 2, "T")
{'example.format': '2|T'}
>>> StatsdClient.format(("example.format31", "example.format37"), "2",
... "T")
{'example.format31': '2|T', 'exampl... | [
"def",
"format",
"(",
"keys",
",",
"value",
",",
"_type",
",",
"prefix",
"=",
"\"\"",
")",
":",
"data",
"=",
"{",
"}",
"value",
"=",
"\"{0}|{1}\"",
".",
"format",
"(",
"value",
",",
"_type",
")",
"# TODO: Allow any iterable except strings",
"if",
"not",
... | General format function.
>>> StatsdClient.format("example.format", 2, "T")
{'example.format': '2|T'}
>>> StatsdClient.format(("example.format31", "example.format37"), "2",
... "T")
{'example.format31': '2|T', 'example.format37': '2|T'}
>>> StatsdClient.format("example.fo... | [
"General",
"format",
"function",
"."
] | a126fc029ab645d9db46c0f5712c416cdf80e370 | https://github.com/langloisjp/pysvcmetrics/blob/a126fc029ab645d9db46c0f5712c416cdf80e370/statsdclient.py#L111-L130 |
246,260 | nivardus/kclboot | kclboot/bootstrapper.py | Bootstrapper.jars | def jars(self, absolute=True):
'''
List of jars in the jar path
'''
jars = glob(os.path.join(self._jar_path, '*.jar'))
return jars if absolute else map(lambda j: os.path.abspath(j), jars) | python | def jars(self, absolute=True):
'''
List of jars in the jar path
'''
jars = glob(os.path.join(self._jar_path, '*.jar'))
return jars if absolute else map(lambda j: os.path.abspath(j), jars) | [
"def",
"jars",
"(",
"self",
",",
"absolute",
"=",
"True",
")",
":",
"jars",
"=",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_jar_path",
",",
"'*.jar'",
")",
")",
"return",
"jars",
"if",
"absolute",
"else",
"map",
"(",
"lambda",... | List of jars in the jar path | [
"List",
"of",
"jars",
"in",
"the",
"jar",
"path"
] | aee054d9186938bec51f19e9ed8deed6ac6fe492 | https://github.com/nivardus/kclboot/blob/aee054d9186938bec51f19e9ed8deed6ac6fe492/kclboot/bootstrapper.py#L61-L66 |
246,261 | nivardus/kclboot | kclboot/bootstrapper.py | Bootstrapper.download_jars_to | def download_jars_to(cls, folder):
'''
Download missing jars to a specific folder
'''
if not os.path.exists(folder):
os.makedirs(folder)
for info in JARS:
jar = MavenJar(info[0], info[1], info[2])
path = os.path.join(folder, jar.filename)
... | python | def download_jars_to(cls, folder):
'''
Download missing jars to a specific folder
'''
if not os.path.exists(folder):
os.makedirs(folder)
for info in JARS:
jar = MavenJar(info[0], info[1], info[2])
path = os.path.join(folder, jar.filename)
... | [
"def",
"download_jars_to",
"(",
"cls",
",",
"folder",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"folder",
")",
":",
"os",
".",
"makedirs",
"(",
"folder",
")",
"for",
"info",
"in",
"JARS",
":",
"jar",
"=",
"MavenJar",
"(",
"info"... | Download missing jars to a specific folder | [
"Download",
"missing",
"jars",
"to",
"a",
"specific",
"folder"
] | aee054d9186938bec51f19e9ed8deed6ac6fe492 | https://github.com/nivardus/kclboot/blob/aee054d9186938bec51f19e9ed8deed6ac6fe492/kclboot/bootstrapper.py#L82-L97 |
246,262 | KelSolaar/Oncilla | oncilla/reStructuredText_to_html.py | reStructuredText_to_html | def reStructuredText_to_html(input, output, css_file):
"""
Outputs a reStructuredText file to html.
:param input: Input reStructuredText file to convert.
:type input: unicode
:param output: Output html file.
:type output: unicode
:param css_file: Css file.
:type css_file: unicode
:r... | python | def reStructuredText_to_html(input, output, css_file):
"""
Outputs a reStructuredText file to html.
:param input: Input reStructuredText file to convert.
:type input: unicode
:param output: Output html file.
:type output: unicode
:param css_file: Css file.
:type css_file: unicode
:r... | [
"def",
"reStructuredText_to_html",
"(",
"input",
",",
"output",
",",
"css_file",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"{0} | Converting '{1}' reStructuredText file to html!\"",
".",
"format",
"(",
"reStructuredText_to_html",
".",
"__name__",
",",
"input",
")",
")",... | Outputs a reStructuredText file to html.
:param input: Input reStructuredText file to convert.
:type input: unicode
:param output: Output html file.
:type output: unicode
:param css_file: Css file.
:type css_file: unicode
:return: Definition success.
:rtype: bool | [
"Outputs",
"a",
"reStructuredText",
"file",
"to",
"html",
"."
] | 2b4db3704cf2c22a09a207681cb041fff555a994 | https://github.com/KelSolaar/Oncilla/blob/2b4db3704cf2c22a09a207681cb041fff555a994/oncilla/reStructuredText_to_html.py#L56-L86 |
246,263 | heikomuller/sco-datastore | scodata/attribute.py | attributes_from_dict | def attributes_from_dict(document):
"""Convert a Json representation of a set of attribute instances into a
dictionary.
Parameters
----------
document : Json object
Json serialization of attribute instances
Returns
-------
dict(Attribute)
Dictionary of attribute instanc... | python | def attributes_from_dict(document):
"""Convert a Json representation of a set of attribute instances into a
dictionary.
Parameters
----------
document : Json object
Json serialization of attribute instances
Returns
-------
dict(Attribute)
Dictionary of attribute instanc... | [
"def",
"attributes_from_dict",
"(",
"document",
")",
":",
"attributes",
"=",
"dict",
"(",
")",
"for",
"attr",
"in",
"document",
":",
"name",
"=",
"str",
"(",
"attr",
"[",
"'name'",
"]",
")",
"attributes",
"[",
"name",
"]",
"=",
"Attribute",
"(",
"name"... | Convert a Json representation of a set of attribute instances into a
dictionary.
Parameters
----------
document : Json object
Json serialization of attribute instances
Returns
-------
dict(Attribute)
Dictionary of attribute instance objects keyed by their name | [
"Convert",
"a",
"Json",
"representation",
"of",
"a",
"set",
"of",
"attribute",
"instances",
"into",
"a",
"dictionary",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/attribute.py#L369-L390 |
246,264 | heikomuller/sco-datastore | scodata/attribute.py | attributes_to_dict | def attributes_to_dict(attributes):
"""Transform a dictionary of attribute instances into a list of Json
objects, i.e., list of key-value pairs.
Parameters
----------
attributes : dict(Attribute)
Dictionary of attribute instances
Returns
-------
list(dict(name:..., value:...))
... | python | def attributes_to_dict(attributes):
"""Transform a dictionary of attribute instances into a list of Json
objects, i.e., list of key-value pairs.
Parameters
----------
attributes : dict(Attribute)
Dictionary of attribute instances
Returns
-------
list(dict(name:..., value:...))
... | [
"def",
"attributes_to_dict",
"(",
"attributes",
")",
":",
"result",
"=",
"[",
"]",
"for",
"key",
"in",
"attributes",
":",
"result",
".",
"append",
"(",
"{",
"'name'",
":",
"key",
",",
"'value'",
":",
"attributes",
"[",
"key",
"]",
".",
"value",
"}",
... | Transform a dictionary of attribute instances into a list of Json
objects, i.e., list of key-value pairs.
Parameters
----------
attributes : dict(Attribute)
Dictionary of attribute instances
Returns
-------
list(dict(name:..., value:...))
List of key-value pairs. | [
"Transform",
"a",
"dictionary",
"of",
"attribute",
"instances",
"into",
"a",
"list",
"of",
"Json",
"objects",
"i",
".",
"e",
".",
"list",
"of",
"key",
"-",
"value",
"pairs",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/attribute.py#L393-L413 |
246,265 | heikomuller/sco-datastore | scodata/attribute.py | to_dict | def to_dict(attributes, definitions):
"""Create a dictionary of attributes from a given list of key-value pairs.
Detects duplicate definitions of the same attribute and raises an exception.
Expects a list of dictionaries (e.g., Json object) objects having 'name'
and 'value' keys. The type of the elemen... | python | def to_dict(attributes, definitions):
"""Create a dictionary of attributes from a given list of key-value pairs.
Detects duplicate definitions of the same attribute and raises an exception.
Expects a list of dictionaries (e.g., Json object) objects having 'name'
and 'value' keys. The type of the elemen... | [
"def",
"to_dict",
"(",
"attributes",
",",
"definitions",
")",
":",
"# Create a list of valis parameter names",
"valid_names",
"=",
"{",
"}",
"for",
"para",
"in",
"definitions",
":",
"valid_names",
"[",
"para",
".",
"identifier",
"]",
"=",
"para",
"result",
"=",
... | Create a dictionary of attributes from a given list of key-value pairs.
Detects duplicate definitions of the same attribute and raises an exception.
Expects a list of dictionaries (e.g., Json object) objects having 'name'
and 'value' keys. The type of the element associated with the 'value' key is
arbi... | [
"Create",
"a",
"dictionary",
"of",
"attributes",
"from",
"a",
"given",
"list",
"of",
"key",
"-",
"value",
"pairs",
".",
"Detects",
"duplicate",
"definitions",
"of",
"the",
"same",
"attribute",
"and",
"raises",
"an",
"exception",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/attribute.py#L416-L478 |
246,266 | heikomuller/sco-datastore | scodata/attribute.py | AttributeDefinition.from_dict | def from_dict(document):
"""Create attribute definition form Json-like object represenation.
Parameters
----------
document : dict
Json-like object represenation
Returns
-------
AttributeDefinition
"""
if 'default' in document:
... | python | def from_dict(document):
"""Create attribute definition form Json-like object represenation.
Parameters
----------
document : dict
Json-like object represenation
Returns
-------
AttributeDefinition
"""
if 'default' in document:
... | [
"def",
"from_dict",
"(",
"document",
")",
":",
"if",
"'default'",
"in",
"document",
":",
"default",
"=",
"document",
"[",
"'default'",
"]",
"else",
":",
"default",
"=",
"None",
"return",
"AttributeDefinition",
"(",
"document",
"[",
"'id'",
"]",
",",
"docum... | Create attribute definition form Json-like object represenation.
Parameters
----------
document : dict
Json-like object represenation
Returns
-------
AttributeDefinition | [
"Create",
"attribute",
"definition",
"form",
"Json",
"-",
"like",
"object",
"represenation",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/attribute.py#L90-L112 |
246,267 | heikomuller/sco-datastore | scodata/attribute.py | AttributeDefinition.to_dict | def to_dict(self):
"""Convert attribute definition into a dictionary.
Returns
-------
dict
Json-like dictionary representation of the attribute definition
"""
obj = {
'id' : self.identifier,
'name' : self.name,
'description... | python | def to_dict(self):
"""Convert attribute definition into a dictionary.
Returns
-------
dict
Json-like dictionary representation of the attribute definition
"""
obj = {
'id' : self.identifier,
'name' : self.name,
'description... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"obj",
"=",
"{",
"'id'",
":",
"self",
".",
"identifier",
",",
"'name'",
":",
"self",
".",
"name",
",",
"'description'",
":",
"self",
".",
"description",
",",
"'type'",
":",
"self",
".",
"data_type",
".",
"to_d... | Convert attribute definition into a dictionary.
Returns
-------
dict
Json-like dictionary representation of the attribute definition | [
"Convert",
"attribute",
"definition",
"into",
"a",
"dictionary",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/attribute.py#L114-L130 |
246,268 | heikomuller/sco-datastore | scodata/attribute.py | AttributeType.from_dict | def from_dict(document):
"""Create data type definition form Json-like object represenation.
Parameters
----------
document : dict
Json-like object represenation
Returns
-------
AttributeType
"""
# Get the type name from the document
... | python | def from_dict(document):
"""Create data type definition form Json-like object represenation.
Parameters
----------
document : dict
Json-like object represenation
Returns
-------
AttributeType
"""
# Get the type name from the document
... | [
"def",
"from_dict",
"(",
"document",
")",
":",
"# Get the type name from the document",
"type_name",
"=",
"document",
"[",
"'name'",
"]",
"if",
"type_name",
"==",
"ATTR_TYPE_INT",
":",
"return",
"IntType",
"(",
")",
"elif",
"type_name",
"==",
"ATTR_TYPE_FLOAT",
":... | Create data type definition form Json-like object represenation.
Parameters
----------
document : dict
Json-like object represenation
Returns
-------
AttributeType | [
"Create",
"data",
"type",
"definition",
"form",
"Json",
"-",
"like",
"object",
"represenation",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/attribute.py#L153-L178 |
246,269 | heikomuller/sco-datastore | scodata/attribute.py | DictType.from_string | def from_string(self, value):
"""Convert string to dictionary."""
# Remove optional {}
if value.startswith('{') and value.endswith('}'):
text = value[1:-1].strip()
else:
text = value.strip()
# Result is a dictionary
result = {}
# Convert ea... | python | def from_string(self, value):
"""Convert string to dictionary."""
# Remove optional {}
if value.startswith('{') and value.endswith('}'):
text = value[1:-1].strip()
else:
text = value.strip()
# Result is a dictionary
result = {}
# Convert ea... | [
"def",
"from_string",
"(",
"self",
",",
"value",
")",
":",
"# Remove optional {}",
"if",
"value",
".",
"startswith",
"(",
"'{'",
")",
"and",
"value",
".",
"endswith",
"(",
"'}'",
")",
":",
"text",
"=",
"value",
"[",
"1",
":",
"-",
"1",
"]",
".",
"s... | Convert string to dictionary. | [
"Convert",
"string",
"to",
"dictionary",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/attribute.py#L227-L242 |
246,270 | heikomuller/sco-datastore | scodata/attribute.py | EnumType.from_string | def from_string(self, value):
"""Convert string to enum value."""
if not isinstance(value, basestring):
raise ValueError('expected string value: ' + str(type(value)))
self.test_value(value)
return value | python | def from_string(self, value):
"""Convert string to enum value."""
if not isinstance(value, basestring):
raise ValueError('expected string value: ' + str(type(value)))
self.test_value(value)
return value | [
"def",
"from_string",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"basestring",
")",
":",
"raise",
"ValueError",
"(",
"'expected string value: '",
"+",
"str",
"(",
"type",
"(",
"value",
")",
")",
")",
"self",
".",
... | Convert string to enum value. | [
"Convert",
"string",
"to",
"enum",
"value",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/attribute.py#L264-L269 |
246,271 | heikomuller/sco-datastore | scodata/attribute.py | EnumType.to_dict | def to_dict(self):
"""Convert enum data type definition into a dictionary. Overrides the
super class method to add list of enumeration values.
Returns
-------
dict
Json-like dictionary representation of the attribute data type
"""
obj = super(EnumType... | python | def to_dict(self):
"""Convert enum data type definition into a dictionary. Overrides the
super class method to add list of enumeration values.
Returns
-------
dict
Json-like dictionary representation of the attribute data type
"""
obj = super(EnumType... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"obj",
"=",
"super",
"(",
"EnumType",
",",
"self",
")",
".",
"to_dict",
"(",
")",
"obj",
"[",
"'values'",
"]",
"=",
"self",
".",
"values",
"return",
"obj"
] | Convert enum data type definition into a dictionary. Overrides the
super class method to add list of enumeration values.
Returns
-------
dict
Json-like dictionary representation of the attribute data type | [
"Convert",
"enum",
"data",
"type",
"definition",
"into",
"a",
"dictionary",
".",
"Overrides",
"the",
"super",
"class",
"method",
"to",
"add",
"list",
"of",
"enumeration",
"values",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/attribute.py#L277-L288 |
246,272 | heikomuller/sco-datastore | scodata/attribute.py | ListType.from_string | def from_string(self, value):
"""Convert string to list."""
# Remove optional []
if value.startswith('[') and value.endswith(']'):
text = value[1:-1].strip()
else:
text = value.strip()
# Result is a list
result = []
# If value starts with '... | python | def from_string(self, value):
"""Convert string to list."""
# Remove optional []
if value.startswith('[') and value.endswith(']'):
text = value[1:-1].strip()
else:
text = value.strip()
# Result is a list
result = []
# If value starts with '... | [
"def",
"from_string",
"(",
"self",
",",
"value",
")",
":",
"# Remove optional []",
"if",
"value",
".",
"startswith",
"(",
"'['",
")",
"and",
"value",
".",
"endswith",
"(",
"']'",
")",
":",
"text",
"=",
"value",
"[",
"1",
":",
"-",
"1",
"]",
".",
"s... | Convert string to list. | [
"Convert",
"string",
"to",
"list",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/attribute.py#L329-L355 |
246,273 | minhhoit/yacms | yacms/generic/managers.py | KeywordManager.get_or_create_iexact | def get_or_create_iexact(self, **kwargs):
"""
Case insensitive title version of ``get_or_create``. Also
allows for multiple existing results.
"""
lookup = dict(**kwargs)
try:
lookup["title__iexact"] = lookup.pop("title")
except KeyError:
pa... | python | def get_or_create_iexact(self, **kwargs):
"""
Case insensitive title version of ``get_or_create``. Also
allows for multiple existing results.
"""
lookup = dict(**kwargs)
try:
lookup["title__iexact"] = lookup.pop("title")
except KeyError:
pa... | [
"def",
"get_or_create_iexact",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"lookup",
"=",
"dict",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"lookup",
"[",
"\"title__iexact\"",
"]",
"=",
"lookup",
".",
"pop",
"(",
"\"title\"",
")",
"except",
"KeyErr... | Case insensitive title version of ``get_or_create``. Also
allows for multiple existing results. | [
"Case",
"insensitive",
"title",
"version",
"of",
"get_or_create",
".",
"Also",
"allows",
"for",
"multiple",
"existing",
"results",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/managers.py#L46-L59 |
246,274 | minhhoit/yacms | yacms/generic/managers.py | KeywordManager.delete_unused | def delete_unused(self, keyword_ids=None):
"""
Removes all instances that are not assigned to any object. Limits
processing to ``keyword_ids`` if given.
"""
if keyword_ids is None:
keywords = self.all()
else:
keywords = self.filter(id__in=keyword_i... | python | def delete_unused(self, keyword_ids=None):
"""
Removes all instances that are not assigned to any object. Limits
processing to ``keyword_ids`` if given.
"""
if keyword_ids is None:
keywords = self.all()
else:
keywords = self.filter(id__in=keyword_i... | [
"def",
"delete_unused",
"(",
"self",
",",
"keyword_ids",
"=",
"None",
")",
":",
"if",
"keyword_ids",
"is",
"None",
":",
"keywords",
"=",
"self",
".",
"all",
"(",
")",
"else",
":",
"keywords",
"=",
"self",
".",
"filter",
"(",
"id__in",
"=",
"keyword_ids... | Removes all instances that are not assigned to any object. Limits
processing to ``keyword_ids`` if given. | [
"Removes",
"all",
"instances",
"that",
"are",
"not",
"assigned",
"to",
"any",
"object",
".",
"Limits",
"processing",
"to",
"keyword_ids",
"if",
"given",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/managers.py#L61-L70 |
246,275 | hirokiky/uiro | uiro/template.py | setup_lookup | def setup_lookup(apps, lookup_class=TemplateLookup):
""" Registering template directories of apps to Lookup.
Lookups will be set up as dictionary, app name
as key and lookup for this app will be it's value.
Each lookups is correspond to each template directories of apps._lookups.
The directory shou... | python | def setup_lookup(apps, lookup_class=TemplateLookup):
""" Registering template directories of apps to Lookup.
Lookups will be set up as dictionary, app name
as key and lookup for this app will be it's value.
Each lookups is correspond to each template directories of apps._lookups.
The directory shou... | [
"def",
"setup_lookup",
"(",
"apps",
",",
"lookup_class",
"=",
"TemplateLookup",
")",
":",
"global",
"_lookups",
"_lookups",
"=",
"{",
"}",
"for",
"app",
"in",
"apps",
":",
"app_template_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
... | Registering template directories of apps to Lookup.
Lookups will be set up as dictionary, app name
as key and lookup for this app will be it's value.
Each lookups is correspond to each template directories of apps._lookups.
The directory should be named 'templates', and put under app directory. | [
"Registering",
"template",
"directories",
"of",
"apps",
"to",
"Lookup",
"."
] | 8436976b21ac9b0eac4243768f5ada12479b9e00 | https://github.com/hirokiky/uiro/blob/8436976b21ac9b0eac4243768f5ada12479b9e00/uiro/template.py#L8-L25 |
246,276 | hirokiky/uiro | uiro/template.py | get_app_template | def get_app_template(name):
""" Getter function of templates for each applications.
Argument `name` will be interpreted as colon separated, the left value
means application name, right value means a template name.
get_app_template('blog:dashboarb.mako')
It will return a template for dashboard... | python | def get_app_template(name):
""" Getter function of templates for each applications.
Argument `name` will be interpreted as colon separated, the left value
means application name, right value means a template name.
get_app_template('blog:dashboarb.mako')
It will return a template for dashboard... | [
"def",
"get_app_template",
"(",
"name",
")",
":",
"app_name",
",",
"template_name",
"=",
"name",
".",
"split",
"(",
"':'",
")",
"return",
"get_lookups",
"(",
")",
"[",
"app_name",
"]",
".",
"get_template",
"(",
"template_name",
")"
] | Getter function of templates for each applications.
Argument `name` will be interpreted as colon separated, the left value
means application name, right value means a template name.
get_app_template('blog:dashboarb.mako')
It will return a template for dashboard page of `blog` application. | [
"Getter",
"function",
"of",
"templates",
"for",
"each",
"applications",
"."
] | 8436976b21ac9b0eac4243768f5ada12479b9e00 | https://github.com/hirokiky/uiro/blob/8436976b21ac9b0eac4243768f5ada12479b9e00/uiro/template.py#L38-L49 |
246,277 | ActiveState/simplealchemy | simplealchemy.py | setup | def setup(db_class, simple_object_cls, primary_keys):
"""A simple API to configure the metadata"""
table_name = simple_object_cls.__name__
column_names = simple_object_cls.FIELDS
metadata = MetaData()
table = Table(table_name, metadata,
*[Column(cname, _get_best_column_type(cname)... | python | def setup(db_class, simple_object_cls, primary_keys):
"""A simple API to configure the metadata"""
table_name = simple_object_cls.__name__
column_names = simple_object_cls.FIELDS
metadata = MetaData()
table = Table(table_name, metadata,
*[Column(cname, _get_best_column_type(cname)... | [
"def",
"setup",
"(",
"db_class",
",",
"simple_object_cls",
",",
"primary_keys",
")",
":",
"table_name",
"=",
"simple_object_cls",
".",
"__name__",
"column_names",
"=",
"simple_object_cls",
".",
"FIELDS",
"metadata",
"=",
"MetaData",
"(",
")",
"table",
"=",
"Tabl... | A simple API to configure the metadata | [
"A",
"simple",
"API",
"to",
"configure",
"the",
"metadata"
] | f745847793f57701776a804ec74791a1f6a66947 | https://github.com/ActiveState/simplealchemy/blob/f745847793f57701776a804ec74791a1f6a66947/simplealchemy.py#L26-L41 |
246,278 | ActiveState/simplealchemy | simplealchemy.py | sqlalchemy_escape | def sqlalchemy_escape(val, escape_char, special_chars):
"""Escape a string according for use in LIKE operator
>>> sqlalchemy_escape("text_table", "\\", "%_")
'text\_table'
"""
if sys.version_info[:2] >= (3, 0):
assert isinstance(val, str)
else:
assert isinstance(val, basestring)... | python | def sqlalchemy_escape(val, escape_char, special_chars):
"""Escape a string according for use in LIKE operator
>>> sqlalchemy_escape("text_table", "\\", "%_")
'text\_table'
"""
if sys.version_info[:2] >= (3, 0):
assert isinstance(val, str)
else:
assert isinstance(val, basestring)... | [
"def",
"sqlalchemy_escape",
"(",
"val",
",",
"escape_char",
",",
"special_chars",
")",
":",
"if",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
">=",
"(",
"3",
",",
"0",
")",
":",
"assert",
"isinstance",
"(",
"val",
",",
"str",
")",
"else",
":",
... | Escape a string according for use in LIKE operator
>>> sqlalchemy_escape("text_table", "\\", "%_")
'text\_table' | [
"Escape",
"a",
"string",
"according",
"for",
"use",
"in",
"LIKE",
"operator"
] | f745847793f57701776a804ec74791a1f6a66947 | https://github.com/ActiveState/simplealchemy/blob/f745847793f57701776a804ec74791a1f6a66947/simplealchemy.py#L44-L60 |
246,279 | ActiveState/simplealchemy | simplealchemy.py | _remove_unicode_keys | def _remove_unicode_keys(dictobj):
"""Convert keys from 'unicode' to 'str' type.
workaround for <http://bugs.python.org/issue2646>
"""
if sys.version_info[:2] >= (3, 0): return dictobj
assert isinstance(dictobj, dict)
newdict = {}
for key, value in dictobj.items():
if type(key) is... | python | def _remove_unicode_keys(dictobj):
"""Convert keys from 'unicode' to 'str' type.
workaround for <http://bugs.python.org/issue2646>
"""
if sys.version_info[:2] >= (3, 0): return dictobj
assert isinstance(dictobj, dict)
newdict = {}
for key, value in dictobj.items():
if type(key) is... | [
"def",
"_remove_unicode_keys",
"(",
"dictobj",
")",
":",
"if",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
">=",
"(",
"3",
",",
"0",
")",
":",
"return",
"dictobj",
"assert",
"isinstance",
"(",
"dictobj",
",",
"dict",
")",
"newdict",
"=",
"{",
"}"... | Convert keys from 'unicode' to 'str' type.
workaround for <http://bugs.python.org/issue2646> | [
"Convert",
"keys",
"from",
"unicode",
"to",
"str",
"type",
"."
] | f745847793f57701776a804ec74791a1f6a66947 | https://github.com/ActiveState/simplealchemy/blob/f745847793f57701776a804ec74791a1f6a66947/simplealchemy.py#L239-L253 |
246,280 | ActiveState/simplealchemy | simplealchemy.py | SimpleDatabase.reset | def reset(self):
"""Reset the database
Drop all tables and recreate them
"""
self.metadata.drop_all(self.engine)
self.metadata.create_all(self.engine) | python | def reset(self):
"""Reset the database
Drop all tables and recreate them
"""
self.metadata.drop_all(self.engine)
self.metadata.create_all(self.engine) | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"metadata",
".",
"drop_all",
"(",
"self",
".",
"engine",
")",
"self",
".",
"metadata",
".",
"create_all",
"(",
"self",
".",
"engine",
")"
] | Reset the database
Drop all tables and recreate them | [
"Reset",
"the",
"database"
] | f745847793f57701776a804ec74791a1f6a66947 | https://github.com/ActiveState/simplealchemy/blob/f745847793f57701776a804ec74791a1f6a66947/simplealchemy.py#L95-L101 |
246,281 | ActiveState/simplealchemy | simplealchemy.py | SimpleDatabase.transaction | def transaction(self, session=None):
"""Start a new transaction based on the passed session object. If session
is not passed, then create one and make sure of closing it finally.
"""
local_session = None
if session is None:
local_session = session = self.create_scoped... | python | def transaction(self, session=None):
"""Start a new transaction based on the passed session object. If session
is not passed, then create one and make sure of closing it finally.
"""
local_session = None
if session is None:
local_session = session = self.create_scoped... | [
"def",
"transaction",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"local_session",
"=",
"None",
"if",
"session",
"is",
"None",
":",
"local_session",
"=",
"session",
"=",
"self",
".",
"create_scoped_session",
"(",
")",
"try",
":",
"yield",
"session"... | Start a new transaction based on the passed session object. If session
is not passed, then create one and make sure of closing it finally. | [
"Start",
"a",
"new",
"transaction",
"based",
"on",
"the",
"passed",
"session",
"object",
".",
"If",
"session",
"is",
"not",
"passed",
"then",
"create",
"one",
"and",
"make",
"sure",
"of",
"closing",
"it",
"finally",
"."
] | f745847793f57701776a804ec74791a1f6a66947 | https://github.com/ActiveState/simplealchemy/blob/f745847793f57701776a804ec74791a1f6a66947/simplealchemy.py#L107-L127 |
246,282 | ActiveState/simplealchemy | simplealchemy.py | SimpleObject.create_from | def create_from(cls, another, **kwargs):
"""Create from another object of different type.
Another object must be from a derived class of SimpleObject (which
contains FIELDS)
"""
reused_fields = {}
for field, value in another.get_fields():
if field in cls.FIEL... | python | def create_from(cls, another, **kwargs):
"""Create from another object of different type.
Another object must be from a derived class of SimpleObject (which
contains FIELDS)
"""
reused_fields = {}
for field, value in another.get_fields():
if field in cls.FIEL... | [
"def",
"create_from",
"(",
"cls",
",",
"another",
",",
"*",
"*",
"kwargs",
")",
":",
"reused_fields",
"=",
"{",
"}",
"for",
"field",
",",
"value",
"in",
"another",
".",
"get_fields",
"(",
")",
":",
"if",
"field",
"in",
"cls",
".",
"FIELDS",
":",
"r... | Create from another object of different type.
Another object must be from a derived class of SimpleObject (which
contains FIELDS) | [
"Create",
"from",
"another",
"object",
"of",
"different",
"type",
"."
] | f745847793f57701776a804ec74791a1f6a66947 | https://github.com/ActiveState/simplealchemy/blob/f745847793f57701776a804ec74791a1f6a66947/simplealchemy.py#L154-L165 |
246,283 | zaturox/glin | glin/zmq/messages.py | MessageBuilder.brightness | def brightness(sequence_number, brightness):
"""Create a brightness message"""
return MessageWriter().string("brightness").uint64(sequence_number).uint8(int(brightness*255)).get() | python | def brightness(sequence_number, brightness):
"""Create a brightness message"""
return MessageWriter().string("brightness").uint64(sequence_number).uint8(int(brightness*255)).get() | [
"def",
"brightness",
"(",
"sequence_number",
",",
"brightness",
")",
":",
"return",
"MessageWriter",
"(",
")",
".",
"string",
"(",
"\"brightness\"",
")",
".",
"uint64",
"(",
"sequence_number",
")",
".",
"uint8",
"(",
"int",
"(",
"brightness",
"*",
"255",
"... | Create a brightness message | [
"Create",
"a",
"brightness",
"message"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L11-L13 |
246,284 | zaturox/glin | glin/zmq/messages.py | MessageBuilder.mainswitch_state | def mainswitch_state(sequence_number, state):
"""Create a mainswitch.state message"""
return MessageWriter().string("mainswitch.state").uint64(sequence_number).bool(state).get() | python | def mainswitch_state(sequence_number, state):
"""Create a mainswitch.state message"""
return MessageWriter().string("mainswitch.state").uint64(sequence_number).bool(state).get() | [
"def",
"mainswitch_state",
"(",
"sequence_number",
",",
"state",
")",
":",
"return",
"MessageWriter",
"(",
")",
".",
"string",
"(",
"\"mainswitch.state\"",
")",
".",
"uint64",
"(",
"sequence_number",
")",
".",
"bool",
"(",
"state",
")",
".",
"get",
"(",
")... | Create a mainswitch.state message | [
"Create",
"a",
"mainswitch",
".",
"state",
"message"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L15-L17 |
246,285 | zaturox/glin | glin/zmq/messages.py | MessageBuilder.animation_add | def animation_add(sequence_number, animation_id, name):
"""Create a animation.add message"""
return MessageWriter().string("animation.add").uint64(sequence_number).uint32(animation_id).string(name).get() | python | def animation_add(sequence_number, animation_id, name):
"""Create a animation.add message"""
return MessageWriter().string("animation.add").uint64(sequence_number).uint32(animation_id).string(name).get() | [
"def",
"animation_add",
"(",
"sequence_number",
",",
"animation_id",
",",
"name",
")",
":",
"return",
"MessageWriter",
"(",
")",
".",
"string",
"(",
"\"animation.add\"",
")",
".",
"uint64",
"(",
"sequence_number",
")",
".",
"uint32",
"(",
"animation_id",
")",
... | Create a animation.add message | [
"Create",
"a",
"animation",
".",
"add",
"message"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L19-L21 |
246,286 | zaturox/glin | glin/zmq/messages.py | MessageBuilder.scene_active | def scene_active(sequence_number, scene_id):
"""Create a scene.setactive message"""
return MessageWriter().string("scene.setactive").uint64(sequence_number).uint32(scene_id).get() | python | def scene_active(sequence_number, scene_id):
"""Create a scene.setactive message"""
return MessageWriter().string("scene.setactive").uint64(sequence_number).uint32(scene_id).get() | [
"def",
"scene_active",
"(",
"sequence_number",
",",
"scene_id",
")",
":",
"return",
"MessageWriter",
"(",
")",
".",
"string",
"(",
"\"scene.setactive\"",
")",
".",
"uint64",
"(",
"sequence_number",
")",
".",
"uint32",
"(",
"scene_id",
")",
".",
"get",
"(",
... | Create a scene.setactive message | [
"Create",
"a",
"scene",
".",
"setactive",
"message"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L23-L25 |
246,287 | zaturox/glin | glin/zmq/messages.py | MessageBuilder.scene_add | def scene_add(sequence_number, scene_id, animation_id, name, color, velocity, config):
"""Create a scene.add message"""
(red, green, blue) = (int(color[0]*255), int(color[1]*255), int(color[2]*255))
return MessageWriter().string("scene.add").uint64(sequence_number).uint32(scene_id).uint32(animat... | python | def scene_add(sequence_number, scene_id, animation_id, name, color, velocity, config):
"""Create a scene.add message"""
(red, green, blue) = (int(color[0]*255), int(color[1]*255), int(color[2]*255))
return MessageWriter().string("scene.add").uint64(sequence_number).uint32(scene_id).uint32(animat... | [
"def",
"scene_add",
"(",
"sequence_number",
",",
"scene_id",
",",
"animation_id",
",",
"name",
",",
"color",
",",
"velocity",
",",
"config",
")",
":",
"(",
"red",
",",
"green",
",",
"blue",
")",
"=",
"(",
"int",
"(",
"color",
"[",
"0",
"]",
"*",
"2... | Create a scene.add message | [
"Create",
"a",
"scene",
".",
"add",
"message"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L27-L31 |
246,288 | zaturox/glin | glin/zmq/messages.py | MessageBuilder.scene_remove | def scene_remove(sequence_number, scene_id):
"""Create a scene.rm message"""
return MessageWriter().string("scene.rm").uint64(sequence_number).uint32(scene_id).get() | python | def scene_remove(sequence_number, scene_id):
"""Create a scene.rm message"""
return MessageWriter().string("scene.rm").uint64(sequence_number).uint32(scene_id).get() | [
"def",
"scene_remove",
"(",
"sequence_number",
",",
"scene_id",
")",
":",
"return",
"MessageWriter",
"(",
")",
".",
"string",
"(",
"\"scene.rm\"",
")",
".",
"uint64",
"(",
"sequence_number",
")",
".",
"uint32",
"(",
"scene_id",
")",
".",
"get",
"(",
")"
] | Create a scene.rm message | [
"Create",
"a",
"scene",
".",
"rm",
"message"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L33-L35 |
246,289 | zaturox/glin | glin/zmq/messages.py | MessageBuilder.scene_name | def scene_name(sequence_number, scene_id, name):
"""Create a scene.name message"""
return MessageWriter().string("scene.name").uint64(sequence_number).uint32(scene_id).string(name).get() | python | def scene_name(sequence_number, scene_id, name):
"""Create a scene.name message"""
return MessageWriter().string("scene.name").uint64(sequence_number).uint32(scene_id).string(name).get() | [
"def",
"scene_name",
"(",
"sequence_number",
",",
"scene_id",
",",
"name",
")",
":",
"return",
"MessageWriter",
"(",
")",
".",
"string",
"(",
"\"scene.name\"",
")",
".",
"uint64",
"(",
"sequence_number",
")",
".",
"uint32",
"(",
"scene_id",
")",
".",
"stri... | Create a scene.name message | [
"Create",
"a",
"scene",
".",
"name",
"message"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L37-L39 |
246,290 | zaturox/glin | glin/zmq/messages.py | MessageBuilder.scene_config | def scene_config(sequence_number, scene_id, config):
"""Create a scene.config message"""
return MessageWriter().string("scene.config").uint64(sequence_number).uint32(scene_id).string(config).get() | python | def scene_config(sequence_number, scene_id, config):
"""Create a scene.config message"""
return MessageWriter().string("scene.config").uint64(sequence_number).uint32(scene_id).string(config).get() | [
"def",
"scene_config",
"(",
"sequence_number",
",",
"scene_id",
",",
"config",
")",
":",
"return",
"MessageWriter",
"(",
")",
".",
"string",
"(",
"\"scene.config\"",
")",
".",
"uint64",
"(",
"sequence_number",
")",
".",
"uint32",
"(",
"scene_id",
")",
".",
... | Create a scene.config message | [
"Create",
"a",
"scene",
".",
"config",
"message"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L41-L43 |
246,291 | zaturox/glin | glin/zmq/messages.py | MessageBuilder.scene_color | def scene_color(sequence_number, scene_id, color):
"""Create a scene.color message"""
return MessageWriter().string("scene.color").uint64(sequence_number).uint32(scene_id) \
.uint8_3(int(color[0]*255), int(color[1]*255), int(color[2]*255)).get() | python | def scene_color(sequence_number, scene_id, color):
"""Create a scene.color message"""
return MessageWriter().string("scene.color").uint64(sequence_number).uint32(scene_id) \
.uint8_3(int(color[0]*255), int(color[1]*255), int(color[2]*255)).get() | [
"def",
"scene_color",
"(",
"sequence_number",
",",
"scene_id",
",",
"color",
")",
":",
"return",
"MessageWriter",
"(",
")",
".",
"string",
"(",
"\"scene.color\"",
")",
".",
"uint64",
"(",
"sequence_number",
")",
".",
"uint32",
"(",
"scene_id",
")",
".",
"u... | Create a scene.color message | [
"Create",
"a",
"scene",
".",
"color",
"message"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L45-L48 |
246,292 | zaturox/glin | glin/zmq/messages.py | MessageBuilder.scene_velocity | def scene_velocity(sequence_number, scene_id, velocity):
"""Create a scene.velocity message"""
return MessageWriter().string("scene.velocity").uint64(sequence_number).uint32(scene_id).uint32(int(velocity*1000)).get() | python | def scene_velocity(sequence_number, scene_id, velocity):
"""Create a scene.velocity message"""
return MessageWriter().string("scene.velocity").uint64(sequence_number).uint32(scene_id).uint32(int(velocity*1000)).get() | [
"def",
"scene_velocity",
"(",
"sequence_number",
",",
"scene_id",
",",
"velocity",
")",
":",
"return",
"MessageWriter",
"(",
")",
".",
"string",
"(",
"\"scene.velocity\"",
")",
".",
"uint64",
"(",
"sequence_number",
")",
".",
"uint32",
"(",
"scene_id",
")",
... | Create a scene.velocity message | [
"Create",
"a",
"scene",
".",
"velocity",
"message"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L50-L52 |
246,293 | zaturox/glin | glin/zmq/messages.py | MessageWriter.uint8 | def uint8(self, val):
"""append a frame containing a uint8"""
try:
self.msg += [pack("B", val)]
except struct.error:
raise ValueError("Expected uint32")
return self | python | def uint8(self, val):
"""append a frame containing a uint8"""
try:
self.msg += [pack("B", val)]
except struct.error:
raise ValueError("Expected uint32")
return self | [
"def",
"uint8",
"(",
"self",
",",
"val",
")",
":",
"try",
":",
"self",
".",
"msg",
"+=",
"[",
"pack",
"(",
"\"B\"",
",",
"val",
")",
"]",
"except",
"struct",
".",
"error",
":",
"raise",
"ValueError",
"(",
"\"Expected uint32\"",
")",
"return",
"self"
... | append a frame containing a uint8 | [
"append",
"a",
"frame",
"containing",
"a",
"uint8"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L72-L78 |
246,294 | zaturox/glin | glin/zmq/messages.py | MessageWriter.uint8_3 | def uint8_3(self, val1, val2, val3):
"""append a frame containing 3 uint8"""
try:
self.msg += [pack("BBB", val1, val2, val3)]
except struct.error:
raise ValueError("Expected uint8")
return self | python | def uint8_3(self, val1, val2, val3):
"""append a frame containing 3 uint8"""
try:
self.msg += [pack("BBB", val1, val2, val3)]
except struct.error:
raise ValueError("Expected uint8")
return self | [
"def",
"uint8_3",
"(",
"self",
",",
"val1",
",",
"val2",
",",
"val3",
")",
":",
"try",
":",
"self",
".",
"msg",
"+=",
"[",
"pack",
"(",
"\"BBB\"",
",",
"val1",
",",
"val2",
",",
"val3",
")",
"]",
"except",
"struct",
".",
"error",
":",
"raise",
... | append a frame containing 3 uint8 | [
"append",
"a",
"frame",
"containing",
"3",
"uint8"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L79-L85 |
246,295 | zaturox/glin | glin/zmq/messages.py | MessageWriter.uint32 | def uint32(self, val):
"""append a frame containing a uint32"""
try:
self.msg += [pack("!I", val)]
except struct.error:
raise ValueError("Expected uint32")
return self | python | def uint32(self, val):
"""append a frame containing a uint32"""
try:
self.msg += [pack("!I", val)]
except struct.error:
raise ValueError("Expected uint32")
return self | [
"def",
"uint32",
"(",
"self",
",",
"val",
")",
":",
"try",
":",
"self",
".",
"msg",
"+=",
"[",
"pack",
"(",
"\"!I\"",
",",
"val",
")",
"]",
"except",
"struct",
".",
"error",
":",
"raise",
"ValueError",
"(",
"\"Expected uint32\"",
")",
"return",
"self... | append a frame containing a uint32 | [
"append",
"a",
"frame",
"containing",
"a",
"uint32"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L86-L92 |
246,296 | zaturox/glin | glin/zmq/messages.py | MessageWriter.uint64 | def uint64(self, val):
"""append a frame containing a uint64"""
try:
self.msg += [pack("!Q", val)]
except struct.error:
raise ValueError("Expected uint64")
return self | python | def uint64(self, val):
"""append a frame containing a uint64"""
try:
self.msg += [pack("!Q", val)]
except struct.error:
raise ValueError("Expected uint64")
return self | [
"def",
"uint64",
"(",
"self",
",",
"val",
")",
":",
"try",
":",
"self",
".",
"msg",
"+=",
"[",
"pack",
"(",
"\"!Q\"",
",",
"val",
")",
"]",
"except",
"struct",
".",
"error",
":",
"raise",
"ValueError",
"(",
"\"Expected uint64\"",
")",
"return",
"self... | append a frame containing a uint64 | [
"append",
"a",
"frame",
"containing",
"a",
"uint64"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L93-L99 |
246,297 | zaturox/glin | glin/zmq/messages.py | MessageParser.brightness | def brightness(frames):
"""parse a brightness message"""
reader = MessageReader(frames)
res = reader.string("command").uint32("brightness").assert_end().get()
if res.command != "brightness":
raise MessageParserError("Command is not 'brightness'")
return (res.brightnes... | python | def brightness(frames):
"""parse a brightness message"""
reader = MessageReader(frames)
res = reader.string("command").uint32("brightness").assert_end().get()
if res.command != "brightness":
raise MessageParserError("Command is not 'brightness'")
return (res.brightnes... | [
"def",
"brightness",
"(",
"frames",
")",
":",
"reader",
"=",
"MessageReader",
"(",
"frames",
")",
"res",
"=",
"reader",
".",
"string",
"(",
"\"command\"",
")",
".",
"uint32",
"(",
"\"brightness\"",
")",
".",
"assert_end",
"(",
")",
".",
"get",
"(",
")"... | parse a brightness message | [
"parse",
"a",
"brightness",
"message"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L108-L114 |
246,298 | zaturox/glin | glin/zmq/messages.py | MessageParser.mainswitch_state | def mainswitch_state(frames):
"""parse a mainswitch.state message"""
reader = MessageReader(frames)
res = reader.string("command").bool("state").assert_end().get()
if res.command != "mainswitch.state":
raise MessageParserError("Command is not 'mainswitch.state'")
retu... | python | def mainswitch_state(frames):
"""parse a mainswitch.state message"""
reader = MessageReader(frames)
res = reader.string("command").bool("state").assert_end().get()
if res.command != "mainswitch.state":
raise MessageParserError("Command is not 'mainswitch.state'")
retu... | [
"def",
"mainswitch_state",
"(",
"frames",
")",
":",
"reader",
"=",
"MessageReader",
"(",
"frames",
")",
"res",
"=",
"reader",
".",
"string",
"(",
"\"command\"",
")",
".",
"bool",
"(",
"\"state\"",
")",
".",
"assert_end",
"(",
")",
".",
"get",
"(",
")",... | parse a mainswitch.state message | [
"parse",
"a",
"mainswitch",
".",
"state",
"message"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L117-L123 |
246,299 | zaturox/glin | glin/zmq/messages.py | MessageParser.scene_add | def scene_add(frames):
"""parse a scene.add message"""
reader = MessageReader(frames)
results = reader.string("command").uint32("animation_id").string("name").uint8_3("color").uint32("velocity").string("config").get()
if results.command != "scene.add":
raise MessageParserErro... | python | def scene_add(frames):
"""parse a scene.add message"""
reader = MessageReader(frames)
results = reader.string("command").uint32("animation_id").string("name").uint8_3("color").uint32("velocity").string("config").get()
if results.command != "scene.add":
raise MessageParserErro... | [
"def",
"scene_add",
"(",
"frames",
")",
":",
"reader",
"=",
"MessageReader",
"(",
"frames",
")",
"results",
"=",
"reader",
".",
"string",
"(",
"\"command\"",
")",
".",
"uint32",
"(",
"\"animation_id\"",
")",
".",
"string",
"(",
"\"name\"",
")",
".",
"uin... | parse a scene.add message | [
"parse",
"a",
"scene",
".",
"add",
"message"
] | 55214a579c4e4b4d74765f3f6aa2eb815bac1c3b | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L126-L133 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.