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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
32,200 | elastic/elasticsearch-py | elasticsearch/client/utils.py | query_params | def query_params(*es_query_params):
"""
Decorator that pops all accepted parameters from method's kwargs and puts
them in the params argument.
"""
def _wrapper(func):
@wraps(func)
def _wrapped(*args, **kwargs):
params = {}
if "params" in kwargs:
... | python | def query_params(*es_query_params):
"""
Decorator that pops all accepted parameters from method's kwargs and puts
them in the params argument.
"""
def _wrapper(func):
@wraps(func)
def _wrapped(*args, **kwargs):
params = {}
if "params" in kwargs:
... | [
"def",
"query_params",
"(",
"*",
"es_query_params",
")",
":",
"def",
"_wrapper",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"_wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"}",
"if",
"\"params... | Decorator that pops all accepted parameters from method's kwargs and puts
them in the params argument. | [
"Decorator",
"that",
"pops",
"all",
"accepted",
"parameters",
"from",
"method",
"s",
"kwargs",
"and",
"puts",
"them",
"in",
"the",
"params",
"argument",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/utils.py#L62-L88 |
32,201 | elastic/elasticsearch-py | example/queries.py | print_hits | def print_hits(results):
" Simple utility function to print results of a search query. "
print_search_stats(results)
for hit in results['hits']['hits']:
# get created date for a repo and fallback to authored_date for a commit
created_at = parse_date(hit['_source'].get('created_at', hit['_sou... | python | def print_hits(results):
" Simple utility function to print results of a search query. "
print_search_stats(results)
for hit in results['hits']['hits']:
# get created date for a repo and fallback to authored_date for a commit
created_at = parse_date(hit['_source'].get('created_at', hit['_sou... | [
"def",
"print_hits",
"(",
"results",
")",
":",
"print_search_stats",
"(",
"results",
")",
"for",
"hit",
"in",
"results",
"[",
"'hits'",
"]",
"[",
"'hits'",
"]",
":",
"# get created date for a repo and fallback to authored_date for a commit",
"created_at",
"=",
"parse_... | Simple utility function to print results of a search query. | [
"Simple",
"utility",
"function",
"to",
"print",
"results",
"of",
"a",
"search",
"query",
"."
] | 2aab285c8f506f3863cbdaba3c90a685c510ba00 | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/example/queries.py#L14-L26 |
32,202 | fmfn/BayesianOptimization | examples/async_optimization.py | BayesianOptimizationHandler.post | def post(self):
"""Deal with incoming requests."""
body = tornado.escape.json_decode(self.request.body)
try:
self._bo.register(
params=body["params"],
target=body["target"],
)
print("BO has registered: {} points.".format(len(se... | python | def post(self):
"""Deal with incoming requests."""
body = tornado.escape.json_decode(self.request.body)
try:
self._bo.register(
params=body["params"],
target=body["target"],
)
print("BO has registered: {} points.".format(len(se... | [
"def",
"post",
"(",
"self",
")",
":",
"body",
"=",
"tornado",
".",
"escape",
".",
"json_decode",
"(",
"self",
".",
"request",
".",
"body",
")",
"try",
":",
"self",
".",
"_bo",
".",
"register",
"(",
"params",
"=",
"body",
"[",
"\"params\"",
"]",
","... | Deal with incoming requests. | [
"Deal",
"with",
"incoming",
"requests",
"."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/examples/async_optimization.py#L42-L57 |
32,203 | fmfn/BayesianOptimization | bayes_opt/bayesian_optimization.py | BayesianOptimization.register | def register(self, params, target):
"""Expect observation with known target"""
self._space.register(params, target)
self.dispatch(Events.OPTMIZATION_STEP) | python | def register(self, params, target):
"""Expect observation with known target"""
self._space.register(params, target)
self.dispatch(Events.OPTMIZATION_STEP) | [
"def",
"register",
"(",
"self",
",",
"params",
",",
"target",
")",
":",
"self",
".",
"_space",
".",
"register",
"(",
"params",
",",
"target",
")",
"self",
".",
"dispatch",
"(",
"Events",
".",
"OPTMIZATION_STEP",
")"
] | Expect observation with known target | [
"Expect",
"observation",
"with",
"known",
"target"
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/bayesian_optimization.py#L102-L105 |
32,204 | fmfn/BayesianOptimization | bayes_opt/bayesian_optimization.py | BayesianOptimization.probe | def probe(self, params, lazy=True):
"""Probe target of x"""
if lazy:
self._queue.add(params)
else:
self._space.probe(params)
self.dispatch(Events.OPTMIZATION_STEP) | python | def probe(self, params, lazy=True):
"""Probe target of x"""
if lazy:
self._queue.add(params)
else:
self._space.probe(params)
self.dispatch(Events.OPTMIZATION_STEP) | [
"def",
"probe",
"(",
"self",
",",
"params",
",",
"lazy",
"=",
"True",
")",
":",
"if",
"lazy",
":",
"self",
".",
"_queue",
".",
"add",
"(",
"params",
")",
"else",
":",
"self",
".",
"_space",
".",
"probe",
"(",
"params",
")",
"self",
".",
"dispatch... | Probe target of x | [
"Probe",
"target",
"of",
"x"
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/bayesian_optimization.py#L107-L113 |
32,205 | fmfn/BayesianOptimization | bayes_opt/bayesian_optimization.py | BayesianOptimization.suggest | def suggest(self, utility_function):
"""Most promissing point to probe next"""
if len(self._space) == 0:
return self._space.array_to_params(self._space.random_sample())
# Sklearn's GP throws a large number of warnings at times, but
# we don't really need to see them here.
... | python | def suggest(self, utility_function):
"""Most promissing point to probe next"""
if len(self._space) == 0:
return self._space.array_to_params(self._space.random_sample())
# Sklearn's GP throws a large number of warnings at times, but
# we don't really need to see them here.
... | [
"def",
"suggest",
"(",
"self",
",",
"utility_function",
")",
":",
"if",
"len",
"(",
"self",
".",
"_space",
")",
"==",
"0",
":",
"return",
"self",
".",
"_space",
".",
"array_to_params",
"(",
"self",
".",
"_space",
".",
"random_sample",
"(",
")",
")",
... | Most promissing point to probe next | [
"Most",
"promissing",
"point",
"to",
"probe",
"next"
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/bayesian_optimization.py#L115-L135 |
32,206 | fmfn/BayesianOptimization | bayes_opt/bayesian_optimization.py | BayesianOptimization._prime_queue | def _prime_queue(self, init_points):
"""Make sure there's something in the queue at the very beginning."""
if self._queue.empty and self._space.empty:
init_points = max(init_points, 1)
for _ in range(init_points):
self._queue.add(self._space.random_sample()) | python | def _prime_queue(self, init_points):
"""Make sure there's something in the queue at the very beginning."""
if self._queue.empty and self._space.empty:
init_points = max(init_points, 1)
for _ in range(init_points):
self._queue.add(self._space.random_sample()) | [
"def",
"_prime_queue",
"(",
"self",
",",
"init_points",
")",
":",
"if",
"self",
".",
"_queue",
".",
"empty",
"and",
"self",
".",
"_space",
".",
"empty",
":",
"init_points",
"=",
"max",
"(",
"init_points",
",",
"1",
")",
"for",
"_",
"in",
"range",
"("... | Make sure there's something in the queue at the very beginning. | [
"Make",
"sure",
"there",
"s",
"something",
"in",
"the",
"queue",
"at",
"the",
"very",
"beginning",
"."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/bayesian_optimization.py#L137-L143 |
32,207 | fmfn/BayesianOptimization | bayes_opt/bayesian_optimization.py | BayesianOptimization.maximize | def maximize(self,
init_points=5,
n_iter=25,
acq='ucb',
kappa=2.576,
xi=0.0,
**gp_params):
"""Mazimize your function"""
self._prime_subscriptions()
self.dispatch(Events.OPTMIZATION_START)
... | python | def maximize(self,
init_points=5,
n_iter=25,
acq='ucb',
kappa=2.576,
xi=0.0,
**gp_params):
"""Mazimize your function"""
self._prime_subscriptions()
self.dispatch(Events.OPTMIZATION_START)
... | [
"def",
"maximize",
"(",
"self",
",",
"init_points",
"=",
"5",
",",
"n_iter",
"=",
"25",
",",
"acq",
"=",
"'ucb'",
",",
"kappa",
"=",
"2.576",
",",
"xi",
"=",
"0.0",
",",
"*",
"*",
"gp_params",
")",
":",
"self",
".",
"_prime_subscriptions",
"(",
")"... | Mazimize your function | [
"Mazimize",
"your",
"function"
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/bayesian_optimization.py#L152-L176 |
32,208 | fmfn/BayesianOptimization | bayes_opt/target_space.py | TargetSpace.register | def register(self, params, target):
"""
Append a point and its target value to the known data.
Parameters
----------
x : ndarray
a single point, with len(x) == self.dim
y : float
target function value
Raises
------
KeyErr... | python | def register(self, params, target):
"""
Append a point and its target value to the known data.
Parameters
----------
x : ndarray
a single point, with len(x) == self.dim
y : float
target function value
Raises
------
KeyErr... | [
"def",
"register",
"(",
"self",
",",
"params",
",",
"target",
")",
":",
"x",
"=",
"self",
".",
"_as_array",
"(",
"params",
")",
"if",
"x",
"in",
"self",
":",
"raise",
"KeyError",
"(",
"'Data point {} is not unique'",
".",
"format",
"(",
"x",
")",
")",
... | Append a point and its target value to the known data.
Parameters
----------
x : ndarray
a single point, with len(x) == self.dim
y : float
target function value
Raises
------
KeyError:
if the point is not unique
Note... | [
"Append",
"a",
"point",
"and",
"its",
"target",
"value",
"to",
"the",
"known",
"data",
"."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/target_space.py#L126-L167 |
32,209 | fmfn/BayesianOptimization | bayes_opt/target_space.py | TargetSpace.probe | def probe(self, params):
"""
Evaulates a single point x, to obtain the value y and then records them
as observations.
Notes
-----
If x has been previously seen returns a cached value of y.
Parameters
----------
x : ndarray
a single po... | python | def probe(self, params):
"""
Evaulates a single point x, to obtain the value y and then records them
as observations.
Notes
-----
If x has been previously seen returns a cached value of y.
Parameters
----------
x : ndarray
a single po... | [
"def",
"probe",
"(",
"self",
",",
"params",
")",
":",
"x",
"=",
"self",
".",
"_as_array",
"(",
"params",
")",
"try",
":",
"target",
"=",
"self",
".",
"_cache",
"[",
"_hashable",
"(",
"x",
")",
"]",
"except",
"KeyError",
":",
"params",
"=",
"dict",
... | Evaulates a single point x, to obtain the value y and then records them
as observations.
Notes
-----
If x has been previously seen returns a cached value of y.
Parameters
----------
x : ndarray
a single point, with len(x) == self.dim
Returns... | [
"Evaulates",
"a",
"single",
"point",
"x",
"to",
"obtain",
"the",
"value",
"y",
"and",
"then",
"records",
"them",
"as",
"observations",
"."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/target_space.py#L169-L196 |
32,210 | fmfn/BayesianOptimization | bayes_opt/target_space.py | TargetSpace.random_sample | def random_sample(self):
"""
Creates random points within the bounds of the space.
Returns
----------
data: ndarray
[num x dim] array points with dimensions corresponding to `self._keys`
Example
-------
>>> target_func = lambda p1, p2: p1 + p... | python | def random_sample(self):
"""
Creates random points within the bounds of the space.
Returns
----------
data: ndarray
[num x dim] array points with dimensions corresponding to `self._keys`
Example
-------
>>> target_func = lambda p1, p2: p1 + p... | [
"def",
"random_sample",
"(",
"self",
")",
":",
"# TODO: support integer, category, and basic scipy.optimize constraints",
"data",
"=",
"np",
".",
"empty",
"(",
"(",
"1",
",",
"self",
".",
"dim",
")",
")",
"for",
"col",
",",
"(",
"lower",
",",
"upper",
")",
"... | Creates random points within the bounds of the space.
Returns
----------
data: ndarray
[num x dim] array points with dimensions corresponding to `self._keys`
Example
-------
>>> target_func = lambda p1, p2: p1 + p2
>>> pbounds = {'p1': (0, 1), 'p2': ... | [
"Creates",
"random",
"points",
"within",
"the",
"bounds",
"of",
"the",
"space",
"."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/target_space.py#L198-L219 |
32,211 | fmfn/BayesianOptimization | bayes_opt/target_space.py | TargetSpace.max | def max(self):
"""Get maximum target value found and corresponding parametes."""
try:
res = {
'target': self.target.max(),
'params': dict(
zip(self.keys, self.params[self.target.argmax()])
)
}
except Valu... | python | def max(self):
"""Get maximum target value found and corresponding parametes."""
try:
res = {
'target': self.target.max(),
'params': dict(
zip(self.keys, self.params[self.target.argmax()])
)
}
except Valu... | [
"def",
"max",
"(",
"self",
")",
":",
"try",
":",
"res",
"=",
"{",
"'target'",
":",
"self",
".",
"target",
".",
"max",
"(",
")",
",",
"'params'",
":",
"dict",
"(",
"zip",
"(",
"self",
".",
"keys",
",",
"self",
".",
"params",
"[",
"self",
".",
... | Get maximum target value found and corresponding parametes. | [
"Get",
"maximum",
"target",
"value",
"found",
"and",
"corresponding",
"parametes",
"."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/target_space.py#L221-L232 |
32,212 | fmfn/BayesianOptimization | bayes_opt/target_space.py | TargetSpace.res | def res(self):
"""Get all target values found and corresponding parametes."""
params = [dict(zip(self.keys, p)) for p in self.params]
return [
{"target": target, "params": param}
for target, param in zip(self.target, params)
] | python | def res(self):
"""Get all target values found and corresponding parametes."""
params = [dict(zip(self.keys, p)) for p in self.params]
return [
{"target": target, "params": param}
for target, param in zip(self.target, params)
] | [
"def",
"res",
"(",
"self",
")",
":",
"params",
"=",
"[",
"dict",
"(",
"zip",
"(",
"self",
".",
"keys",
",",
"p",
")",
")",
"for",
"p",
"in",
"self",
".",
"params",
"]",
"return",
"[",
"{",
"\"target\"",
":",
"target",
",",
"\"params\"",
":",
"p... | Get all target values found and corresponding parametes. | [
"Get",
"all",
"target",
"values",
"found",
"and",
"corresponding",
"parametes",
"."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/target_space.py#L234-L241 |
32,213 | fmfn/BayesianOptimization | bayes_opt/target_space.py | TargetSpace.set_bounds | def set_bounds(self, new_bounds):
"""
A method that allows changing the lower and upper searching bounds
Parameters
----------
new_bounds : dict
A dictionary with the parameter name and its new bounds
"""
for row, key in enumerate(self.keys):
... | python | def set_bounds(self, new_bounds):
"""
A method that allows changing the lower and upper searching bounds
Parameters
----------
new_bounds : dict
A dictionary with the parameter name and its new bounds
"""
for row, key in enumerate(self.keys):
... | [
"def",
"set_bounds",
"(",
"self",
",",
"new_bounds",
")",
":",
"for",
"row",
",",
"key",
"in",
"enumerate",
"(",
"self",
".",
"keys",
")",
":",
"if",
"key",
"in",
"new_bounds",
":",
"self",
".",
"_bounds",
"[",
"row",
"]",
"=",
"new_bounds",
"[",
"... | A method that allows changing the lower and upper searching bounds
Parameters
----------
new_bounds : dict
A dictionary with the parameter name and its new bounds | [
"A",
"method",
"that",
"allows",
"changing",
"the",
"lower",
"and",
"upper",
"searching",
"bounds"
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/target_space.py#L243-L254 |
32,214 | fmfn/BayesianOptimization | examples/sklearn_example.py | get_data | def get_data():
"""Synthetic binary classification dataset."""
data, targets = make_classification(
n_samples=1000,
n_features=45,
n_informative=12,
n_redundant=7,
random_state=134985745,
)
return data, targets | python | def get_data():
"""Synthetic binary classification dataset."""
data, targets = make_classification(
n_samples=1000,
n_features=45,
n_informative=12,
n_redundant=7,
random_state=134985745,
)
return data, targets | [
"def",
"get_data",
"(",
")",
":",
"data",
",",
"targets",
"=",
"make_classification",
"(",
"n_samples",
"=",
"1000",
",",
"n_features",
"=",
"45",
",",
"n_informative",
"=",
"12",
",",
"n_redundant",
"=",
"7",
",",
"random_state",
"=",
"134985745",
",",
... | Synthetic binary classification dataset. | [
"Synthetic",
"binary",
"classification",
"dataset",
"."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/examples/sklearn_example.py#L9-L18 |
32,215 | fmfn/BayesianOptimization | examples/sklearn_example.py | svc_cv | def svc_cv(C, gamma, data, targets):
"""SVC cross validation.
This function will instantiate a SVC classifier with parameters C and
gamma. Combined with data and targets this will in turn be used to perform
cross validation. The result of cross validation is returned.
Our goal is to find combinati... | python | def svc_cv(C, gamma, data, targets):
"""SVC cross validation.
This function will instantiate a SVC classifier with parameters C and
gamma. Combined with data and targets this will in turn be used to perform
cross validation. The result of cross validation is returned.
Our goal is to find combinati... | [
"def",
"svc_cv",
"(",
"C",
",",
"gamma",
",",
"data",
",",
"targets",
")",
":",
"estimator",
"=",
"SVC",
"(",
"C",
"=",
"C",
",",
"gamma",
"=",
"gamma",
",",
"random_state",
"=",
"2",
")",
"cval",
"=",
"cross_val_score",
"(",
"estimator",
",",
"dat... | SVC cross validation.
This function will instantiate a SVC classifier with parameters C and
gamma. Combined with data and targets this will in turn be used to perform
cross validation. The result of cross validation is returned.
Our goal is to find combinations of C and gamma that maximizes the roc_au... | [
"SVC",
"cross",
"validation",
"."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/examples/sklearn_example.py#L21-L33 |
32,216 | fmfn/BayesianOptimization | examples/sklearn_example.py | rfc_cv | def rfc_cv(n_estimators, min_samples_split, max_features, data, targets):
"""Random Forest cross validation.
This function will instantiate a random forest classifier with parameters
n_estimators, min_samples_split, and max_features. Combined with data and
targets this will in turn be used to perform c... | python | def rfc_cv(n_estimators, min_samples_split, max_features, data, targets):
"""Random Forest cross validation.
This function will instantiate a random forest classifier with parameters
n_estimators, min_samples_split, and max_features. Combined with data and
targets this will in turn be used to perform c... | [
"def",
"rfc_cv",
"(",
"n_estimators",
",",
"min_samples_split",
",",
"max_features",
",",
"data",
",",
"targets",
")",
":",
"estimator",
"=",
"RFC",
"(",
"n_estimators",
"=",
"n_estimators",
",",
"min_samples_split",
"=",
"min_samples_split",
",",
"max_features",
... | Random Forest cross validation.
This function will instantiate a random forest classifier with parameters
n_estimators, min_samples_split, and max_features. Combined with data and
targets this will in turn be used to perform cross validation. The result
of cross validation is returned.
Our goal is... | [
"Random",
"Forest",
"cross",
"validation",
"."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/examples/sklearn_example.py#L36-L55 |
32,217 | fmfn/BayesianOptimization | examples/sklearn_example.py | optimize_svc | def optimize_svc(data, targets):
"""Apply Bayesian Optimization to SVC parameters."""
def svc_crossval(expC, expGamma):
"""Wrapper of SVC cross validation.
Notice how we transform between regular and log scale. While this
is not technically necessary, it greatly improves the performance... | python | def optimize_svc(data, targets):
"""Apply Bayesian Optimization to SVC parameters."""
def svc_crossval(expC, expGamma):
"""Wrapper of SVC cross validation.
Notice how we transform between regular and log scale. While this
is not technically necessary, it greatly improves the performance... | [
"def",
"optimize_svc",
"(",
"data",
",",
"targets",
")",
":",
"def",
"svc_crossval",
"(",
"expC",
",",
"expGamma",
")",
":",
"\"\"\"Wrapper of SVC cross validation.\n\n Notice how we transform between regular and log scale. While this\n is not technically necessary, it ... | Apply Bayesian Optimization to SVC parameters. | [
"Apply",
"Bayesian",
"Optimization",
"to",
"SVC",
"parameters",
"."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/examples/sklearn_example.py#L58-L79 |
32,218 | fmfn/BayesianOptimization | examples/sklearn_example.py | optimize_rfc | def optimize_rfc(data, targets):
"""Apply Bayesian Optimization to Random Forest parameters."""
def rfc_crossval(n_estimators, min_samples_split, max_features):
"""Wrapper of RandomForest cross validation.
Notice how we ensure n_estimators and min_samples_split are casted
to integer bef... | python | def optimize_rfc(data, targets):
"""Apply Bayesian Optimization to Random Forest parameters."""
def rfc_crossval(n_estimators, min_samples_split, max_features):
"""Wrapper of RandomForest cross validation.
Notice how we ensure n_estimators and min_samples_split are casted
to integer bef... | [
"def",
"optimize_rfc",
"(",
"data",
",",
"targets",
")",
":",
"def",
"rfc_crossval",
"(",
"n_estimators",
",",
"min_samples_split",
",",
"max_features",
")",
":",
"\"\"\"Wrapper of RandomForest cross validation.\n\n Notice how we ensure n_estimators and min_samples_split a... | Apply Bayesian Optimization to Random Forest parameters. | [
"Apply",
"Bayesian",
"Optimization",
"to",
"Random",
"Forest",
"parameters",
"."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/examples/sklearn_example.py#L82-L112 |
32,219 | fmfn/BayesianOptimization | bayes_opt/util.py | load_logs | def load_logs(optimizer, logs):
"""Load previous ...
"""
import json
if isinstance(logs, str):
logs = [logs]
for log in logs:
with open(log, "r") as j:
while True:
try:
iteration = next(j)
except StopIteration:
... | python | def load_logs(optimizer, logs):
"""Load previous ...
"""
import json
if isinstance(logs, str):
logs = [logs]
for log in logs:
with open(log, "r") as j:
while True:
try:
iteration = next(j)
except StopIteration:
... | [
"def",
"load_logs",
"(",
"optimizer",
",",
"logs",
")",
":",
"import",
"json",
"if",
"isinstance",
"(",
"logs",
",",
"str",
")",
":",
"logs",
"=",
"[",
"logs",
"]",
"for",
"log",
"in",
"logs",
":",
"with",
"open",
"(",
"log",
",",
"\"r\"",
")",
"... | Load previous ... | [
"Load",
"previous",
"..."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/util.py#L130-L156 |
32,220 | fmfn/BayesianOptimization | bayes_opt/util.py | ensure_rng | def ensure_rng(random_state=None):
"""
Creates a random number generator based on an optional seed. This can be
an integer or another random state for a seeded rng, or None for an
unseeded rng.
"""
if random_state is None:
random_state = np.random.RandomState()
elif isinstance(rando... | python | def ensure_rng(random_state=None):
"""
Creates a random number generator based on an optional seed. This can be
an integer or another random state for a seeded rng, or None for an
unseeded rng.
"""
if random_state is None:
random_state = np.random.RandomState()
elif isinstance(rando... | [
"def",
"ensure_rng",
"(",
"random_state",
"=",
"None",
")",
":",
"if",
"random_state",
"is",
"None",
":",
"random_state",
"=",
"np",
".",
"random",
".",
"RandomState",
"(",
")",
"elif",
"isinstance",
"(",
"random_state",
",",
"int",
")",
":",
"random_state... | Creates a random number generator based on an optional seed. This can be
an integer or another random state for a seeded rng, or None for an
unseeded rng. | [
"Creates",
"a",
"random",
"number",
"generator",
"based",
"on",
"an",
"optional",
"seed",
".",
"This",
"can",
"be",
"an",
"integer",
"or",
"another",
"random",
"state",
"for",
"a",
"seeded",
"rng",
"or",
"None",
"for",
"an",
"unseeded",
"rng",
"."
] | 8ce2292895137477963cf1bafa4e71fa20b2ce49 | https://github.com/fmfn/BayesianOptimization/blob/8ce2292895137477963cf1bafa4e71fa20b2ce49/bayes_opt/util.py#L159-L171 |
32,221 | audreyr/cookiecutter | cookiecutter/repository.py | expand_abbreviations | def expand_abbreviations(template, abbreviations):
"""Expand abbreviations in a template name.
:param template: The project template name.
:param abbreviations: Abbreviation definitions.
"""
if template in abbreviations:
return abbreviations[template]
# Split on colon. If there is no c... | python | def expand_abbreviations(template, abbreviations):
"""Expand abbreviations in a template name.
:param template: The project template name.
:param abbreviations: Abbreviation definitions.
"""
if template in abbreviations:
return abbreviations[template]
# Split on colon. If there is no c... | [
"def",
"expand_abbreviations",
"(",
"template",
",",
"abbreviations",
")",
":",
"if",
"template",
"in",
"abbreviations",
":",
"return",
"abbreviations",
"[",
"template",
"]",
"# Split on colon. If there is no colon, rest will be empty",
"# and prefix will be the whole template"... | Expand abbreviations in a template name.
:param template: The project template name.
:param abbreviations: Abbreviation definitions. | [
"Expand",
"abbreviations",
"in",
"a",
"template",
"name",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/repository.py#L32-L47 |
32,222 | audreyr/cookiecutter | cookiecutter/repository.py | repository_has_cookiecutter_json | def repository_has_cookiecutter_json(repo_directory):
"""Determine if `repo_directory` contains a `cookiecutter.json` file.
:param repo_directory: The candidate repository directory.
:return: True if the `repo_directory` is valid, else False.
"""
repo_directory_exists = os.path.isdir(repo_directory... | python | def repository_has_cookiecutter_json(repo_directory):
"""Determine if `repo_directory` contains a `cookiecutter.json` file.
:param repo_directory: The candidate repository directory.
:return: True if the `repo_directory` is valid, else False.
"""
repo_directory_exists = os.path.isdir(repo_directory... | [
"def",
"repository_has_cookiecutter_json",
"(",
"repo_directory",
")",
":",
"repo_directory_exists",
"=",
"os",
".",
"path",
".",
"isdir",
"(",
"repo_directory",
")",
"repo_config_exists",
"=",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",
"jo... | Determine if `repo_directory` contains a `cookiecutter.json` file.
:param repo_directory: The candidate repository directory.
:return: True if the `repo_directory` is valid, else False. | [
"Determine",
"if",
"repo_directory",
"contains",
"a",
"cookiecutter",
".",
"json",
"file",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/repository.py#L50-L61 |
32,223 | audreyr/cookiecutter | cookiecutter/repository.py | determine_repo_dir | def determine_repo_dir(template, abbreviations, clone_to_dir, checkout,
no_input, password=None):
"""
Locate the repository directory from a template reference.
Applies repository abbreviations to the template reference.
If the template refers to a repository URL, clone it.
I... | python | def determine_repo_dir(template, abbreviations, clone_to_dir, checkout,
no_input, password=None):
"""
Locate the repository directory from a template reference.
Applies repository abbreviations to the template reference.
If the template refers to a repository URL, clone it.
I... | [
"def",
"determine_repo_dir",
"(",
"template",
",",
"abbreviations",
",",
"clone_to_dir",
",",
"checkout",
",",
"no_input",
",",
"password",
"=",
"None",
")",
":",
"template",
"=",
"expand_abbreviations",
"(",
"template",
",",
"abbreviations",
")",
"if",
"is_zip_... | Locate the repository directory from a template reference.
Applies repository abbreviations to the template reference.
If the template refers to a repository URL, clone it.
If the template is a path to a local repository, use it.
:param template: A directory containing a project template directory,
... | [
"Locate",
"the",
"repository",
"directory",
"from",
"a",
"template",
"reference",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/repository.py#L64-L124 |
32,224 | audreyr/cookiecutter | cookiecutter/find.py | find_template | def find_template(repo_dir):
"""Determine which child directory of `repo_dir` is the project template.
:param repo_dir: Local directory of newly cloned repo.
:returns project_template: Relative path to project template.
"""
logger.debug('Searching {} for the project template.'.format(repo_dir))
... | python | def find_template(repo_dir):
"""Determine which child directory of `repo_dir` is the project template.
:param repo_dir: Local directory of newly cloned repo.
:returns project_template: Relative path to project template.
"""
logger.debug('Searching {} for the project template.'.format(repo_dir))
... | [
"def",
"find_template",
"(",
"repo_dir",
")",
":",
"logger",
".",
"debug",
"(",
"'Searching {} for the project template.'",
".",
"format",
"(",
"repo_dir",
")",
")",
"repo_dir_contents",
"=",
"os",
".",
"listdir",
"(",
"repo_dir",
")",
"project_template",
"=",
"... | Determine which child directory of `repo_dir` is the project template.
:param repo_dir: Local directory of newly cloned repo.
:returns project_template: Relative path to project template. | [
"Determine",
"which",
"child",
"directory",
"of",
"repo_dir",
"is",
"the",
"project",
"template",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/find.py#L13-L36 |
32,225 | audreyr/cookiecutter | cookiecutter/generate.py | is_copy_only_path | def is_copy_only_path(path, context):
"""Check whether the given `path` should only be copied and not rendered.
Returns True if `path` matches a pattern in the given `context` dict,
otherwise False.
:param path: A file-system path referring to a file or dir that
should be rendered or just copi... | python | def is_copy_only_path(path, context):
"""Check whether the given `path` should only be copied and not rendered.
Returns True if `path` matches a pattern in the given `context` dict,
otherwise False.
:param path: A file-system path referring to a file or dir that
should be rendered or just copi... | [
"def",
"is_copy_only_path",
"(",
"path",
",",
"context",
")",
":",
"try",
":",
"for",
"dont_render",
"in",
"context",
"[",
"'cookiecutter'",
"]",
"[",
"'_copy_without_render'",
"]",
":",
"if",
"fnmatch",
".",
"fnmatch",
"(",
"path",
",",
"dont_render",
")",
... | Check whether the given `path` should only be copied and not rendered.
Returns True if `path` matches a pattern in the given `context` dict,
otherwise False.
:param path: A file-system path referring to a file or dir that
should be rendered or just copied.
:param context: cookiecutter context. | [
"Check",
"whether",
"the",
"given",
"path",
"should",
"only",
"be",
"copied",
"and",
"not",
"rendered",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/generate.py#L33-L50 |
32,226 | audreyr/cookiecutter | cookiecutter/generate.py | apply_overwrites_to_context | def apply_overwrites_to_context(context, overwrite_context):
"""Modify the given context in place based on the overwrite_context."""
for variable, overwrite in overwrite_context.items():
if variable not in context:
# Do not include variables which are not used in the template
con... | python | def apply_overwrites_to_context(context, overwrite_context):
"""Modify the given context in place based on the overwrite_context."""
for variable, overwrite in overwrite_context.items():
if variable not in context:
# Do not include variables which are not used in the template
con... | [
"def",
"apply_overwrites_to_context",
"(",
"context",
",",
"overwrite_context",
")",
":",
"for",
"variable",
",",
"overwrite",
"in",
"overwrite_context",
".",
"items",
"(",
")",
":",
"if",
"variable",
"not",
"in",
"context",
":",
"# Do not include variables which ar... | Modify the given context in place based on the overwrite_context. | [
"Modify",
"the",
"given",
"context",
"in",
"place",
"based",
"on",
"the",
"overwrite_context",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/generate.py#L53-L72 |
32,227 | audreyr/cookiecutter | cookiecutter/generate.py | generate_context | def generate_context(context_file='cookiecutter.json', default_context=None,
extra_context=None):
"""Generate the context for a Cookiecutter project template.
Loads the JSON file as a Python object, with key being the JSON filename.
:param context_file: JSON file containing key/value ... | python | def generate_context(context_file='cookiecutter.json', default_context=None,
extra_context=None):
"""Generate the context for a Cookiecutter project template.
Loads the JSON file as a Python object, with key being the JSON filename.
:param context_file: JSON file containing key/value ... | [
"def",
"generate_context",
"(",
"context_file",
"=",
"'cookiecutter.json'",
",",
"default_context",
"=",
"None",
",",
"extra_context",
"=",
"None",
")",
":",
"context",
"=",
"OrderedDict",
"(",
"[",
"]",
")",
"try",
":",
"with",
"open",
"(",
"context_file",
... | Generate the context for a Cookiecutter project template.
Loads the JSON file as a Python object, with key being the JSON filename.
:param context_file: JSON file containing key/value pairs for populating
the cookiecutter's variables.
:param default_context: Dictionary containing config to take in... | [
"Generate",
"the",
"context",
"for",
"a",
"Cookiecutter",
"project",
"template",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/generate.py#L75-L114 |
32,228 | audreyr/cookiecutter | cookiecutter/generate.py | generate_file | def generate_file(project_dir, infile, context, env):
"""Render filename of infile as name of outfile, handle infile correctly.
Dealing with infile appropriately:
a. If infile is a binary file, copy it over without rendering.
b. If infile is a text file, render its contents and write the
... | python | def generate_file(project_dir, infile, context, env):
"""Render filename of infile as name of outfile, handle infile correctly.
Dealing with infile appropriately:
a. If infile is a binary file, copy it over without rendering.
b. If infile is a text file, render its contents and write the
... | [
"def",
"generate_file",
"(",
"project_dir",
",",
"infile",
",",
"context",
",",
"env",
")",
":",
"logger",
".",
"debug",
"(",
"'Processing file {}'",
".",
"format",
"(",
"infile",
")",
")",
"# Render the path to the output file (not including the root project dir)",
"... | Render filename of infile as name of outfile, handle infile correctly.
Dealing with infile appropriately:
a. If infile is a binary file, copy it over without rendering.
b. If infile is a text file, render its contents and write the
rendered infile to outfile.
Precondition:
... | [
"Render",
"filename",
"of",
"infile",
"as",
"name",
"of",
"outfile",
"handle",
"infile",
"correctly",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/generate.py#L117-L180 |
32,229 | audreyr/cookiecutter | cookiecutter/generate.py | render_and_create_dir | def render_and_create_dir(dirname, context, output_dir, environment,
overwrite_if_exists=False):
"""Render name of a directory, create the directory, return its path."""
name_tmpl = environment.from_string(dirname)
rendered_dirname = name_tmpl.render(**context)
dir_to_create =... | python | def render_and_create_dir(dirname, context, output_dir, environment,
overwrite_if_exists=False):
"""Render name of a directory, create the directory, return its path."""
name_tmpl = environment.from_string(dirname)
rendered_dirname = name_tmpl.render(**context)
dir_to_create =... | [
"def",
"render_and_create_dir",
"(",
"dirname",
",",
"context",
",",
"output_dir",
",",
"environment",
",",
"overwrite_if_exists",
"=",
"False",
")",
":",
"name_tmpl",
"=",
"environment",
".",
"from_string",
"(",
"dirname",
")",
"rendered_dirname",
"=",
"name_tmpl... | Render name of a directory, create the directory, return its path. | [
"Render",
"name",
"of",
"a",
"directory",
"create",
"the",
"directory",
"return",
"its",
"path",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/generate.py#L183-L212 |
32,230 | audreyr/cookiecutter | cookiecutter/generate.py | _run_hook_from_repo_dir | def _run_hook_from_repo_dir(repo_dir, hook_name, project_dir, context,
delete_project_on_failure):
"""Run hook from repo directory, clean project directory if hook fails.
:param repo_dir: Project template input directory.
:param hook_name: The hook to execute.
:param project... | python | def _run_hook_from_repo_dir(repo_dir, hook_name, project_dir, context,
delete_project_on_failure):
"""Run hook from repo directory, clean project directory if hook fails.
:param repo_dir: Project template input directory.
:param hook_name: The hook to execute.
:param project... | [
"def",
"_run_hook_from_repo_dir",
"(",
"repo_dir",
",",
"hook_name",
",",
"project_dir",
",",
"context",
",",
"delete_project_on_failure",
")",
":",
"with",
"work_in",
"(",
"repo_dir",
")",
":",
"try",
":",
"run_hook",
"(",
"hook_name",
",",
"project_dir",
",",
... | Run hook from repo directory, clean project directory if hook fails.
:param repo_dir: Project template input directory.
:param hook_name: The hook to execute.
:param project_dir: The directory to execute the script from.
:param context: Cookiecutter project context.
:param delete_project_on_failure... | [
"Run",
"hook",
"from",
"repo",
"directory",
"clean",
"project",
"directory",
"if",
"hook",
"fails",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/generate.py#L223-L244 |
32,231 | audreyr/cookiecutter | cookiecutter/config.py | _expand_path | def _expand_path(path):
"""Expand both environment variables and user home in the given path."""
path = os.path.expandvars(path)
path = os.path.expanduser(path)
return path | python | def _expand_path(path):
"""Expand both environment variables and user home in the given path."""
path = os.path.expandvars(path)
path = os.path.expanduser(path)
return path | [
"def",
"_expand_path",
"(",
"path",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"expandvars",
"(",
"path",
")",
"path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"path",
")",
"return",
"path"
] | Expand both environment variables and user home in the given path. | [
"Expand",
"both",
"environment",
"variables",
"and",
"user",
"home",
"in",
"the",
"given",
"path",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/config.py#L36-L40 |
32,232 | audreyr/cookiecutter | cookiecutter/config.py | get_config | def get_config(config_path):
"""Retrieve the config from the specified path, returning a config dict."""
if not os.path.exists(config_path):
raise ConfigDoesNotExistException
logger.debug('config_path is {0}'.format(config_path))
with io.open(config_path, encoding='utf-8') as file_handle:
... | python | def get_config(config_path):
"""Retrieve the config from the specified path, returning a config dict."""
if not os.path.exists(config_path):
raise ConfigDoesNotExistException
logger.debug('config_path is {0}'.format(config_path))
with io.open(config_path, encoding='utf-8') as file_handle:
... | [
"def",
"get_config",
"(",
"config_path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"config_path",
")",
":",
"raise",
"ConfigDoesNotExistException",
"logger",
".",
"debug",
"(",
"'config_path is {0}'",
".",
"format",
"(",
"config_path",
")",... | Retrieve the config from the specified path, returning a config dict. | [
"Retrieve",
"the",
"config",
"from",
"the",
"specified",
"path",
"returning",
"a",
"config",
"dict",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/config.py#L62-L85 |
32,233 | audreyr/cookiecutter | cookiecutter/config.py | get_user_config | def get_user_config(config_file=None, default_config=False):
"""Return the user config as a dict.
If ``default_config`` is True, ignore ``config_file`` and return default
values for the config parameters.
If a path to a ``config_file`` is given, that is different from the default
location, load th... | python | def get_user_config(config_file=None, default_config=False):
"""Return the user config as a dict.
If ``default_config`` is True, ignore ``config_file`` and return default
values for the config parameters.
If a path to a ``config_file`` is given, that is different from the default
location, load th... | [
"def",
"get_user_config",
"(",
"config_file",
"=",
"None",
",",
"default_config",
"=",
"False",
")",
":",
"# Do NOT load a config. Return defaults instead.",
"if",
"default_config",
":",
"return",
"copy",
".",
"copy",
"(",
"DEFAULT_CONFIG",
")",
"# Load the given config... | Return the user config as a dict.
If ``default_config`` is True, ignore ``config_file`` and return default
values for the config parameters.
If a path to a ``config_file`` is given, that is different from the default
location, load the user config from that.
Otherwise look up the config file path... | [
"Return",
"the",
"user",
"config",
"as",
"a",
"dict",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/config.py#L88-L125 |
32,234 | audreyr/cookiecutter | cookiecutter/utils.py | make_sure_path_exists | def make_sure_path_exists(path):
"""Ensure that a directory exists.
:param path: A directory path.
"""
logger.debug('Making sure path exists: {}'.format(path))
try:
os.makedirs(path)
logger.debug('Created directory at: {}'.format(path))
except OSError as exception:
if ex... | python | def make_sure_path_exists(path):
"""Ensure that a directory exists.
:param path: A directory path.
"""
logger.debug('Making sure path exists: {}'.format(path))
try:
os.makedirs(path)
logger.debug('Created directory at: {}'.format(path))
except OSError as exception:
if ex... | [
"def",
"make_sure_path_exists",
"(",
"path",
")",
":",
"logger",
".",
"debug",
"(",
"'Making sure path exists: {}'",
".",
"format",
"(",
"path",
")",
")",
"try",
":",
"os",
".",
"makedirs",
"(",
"path",
")",
"logger",
".",
"debug",
"(",
"'Created directory a... | Ensure that a directory exists.
:param path: A directory path. | [
"Ensure",
"that",
"a",
"directory",
"exists",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/utils.py#L37-L49 |
32,235 | audreyr/cookiecutter | cookiecutter/utils.py | work_in | def work_in(dirname=None):
"""Context manager version of os.chdir.
When exited, returns to the working directory prior to entering.
"""
curdir = os.getcwd()
try:
if dirname is not None:
os.chdir(dirname)
yield
finally:
os.chdir(curdir) | python | def work_in(dirname=None):
"""Context manager version of os.chdir.
When exited, returns to the working directory prior to entering.
"""
curdir = os.getcwd()
try:
if dirname is not None:
os.chdir(dirname)
yield
finally:
os.chdir(curdir) | [
"def",
"work_in",
"(",
"dirname",
"=",
"None",
")",
":",
"curdir",
"=",
"os",
".",
"getcwd",
"(",
")",
"try",
":",
"if",
"dirname",
"is",
"not",
"None",
":",
"os",
".",
"chdir",
"(",
"dirname",
")",
"yield",
"finally",
":",
"os",
".",
"chdir",
"(... | Context manager version of os.chdir.
When exited, returns to the working directory prior to entering. | [
"Context",
"manager",
"version",
"of",
"os",
".",
"chdir",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/utils.py#L53-L64 |
32,236 | audreyr/cookiecutter | cookiecutter/utils.py | make_executable | def make_executable(script_path):
"""Make `script_path` executable.
:param script_path: The file to change
"""
status = os.stat(script_path)
os.chmod(script_path, status.st_mode | stat.S_IEXEC) | python | def make_executable(script_path):
"""Make `script_path` executable.
:param script_path: The file to change
"""
status = os.stat(script_path)
os.chmod(script_path, status.st_mode | stat.S_IEXEC) | [
"def",
"make_executable",
"(",
"script_path",
")",
":",
"status",
"=",
"os",
".",
"stat",
"(",
"script_path",
")",
"os",
".",
"chmod",
"(",
"script_path",
",",
"status",
".",
"st_mode",
"|",
"stat",
".",
"S_IEXEC",
")"
] | Make `script_path` executable.
:param script_path: The file to change | [
"Make",
"script_path",
"executable",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/utils.py#L67-L73 |
32,237 | audreyr/cookiecutter | cookiecutter/zipfile.py | unzip | def unzip(zip_uri, is_url, clone_to_dir='.', no_input=False, password=None):
"""Download and unpack a zipfile at a given URI.
This will download the zipfile to the cookiecutter repository,
and unpack into a temporary directory.
:param zip_uri: The URI for the zipfile.
:param is_url: Is the zip URI... | python | def unzip(zip_uri, is_url, clone_to_dir='.', no_input=False, password=None):
"""Download and unpack a zipfile at a given URI.
This will download the zipfile to the cookiecutter repository,
and unpack into a temporary directory.
:param zip_uri: The URI for the zipfile.
:param is_url: Is the zip URI... | [
"def",
"unzip",
"(",
"zip_uri",
",",
"is_url",
",",
"clone_to_dir",
"=",
"'.'",
",",
"no_input",
"=",
"False",
",",
"password",
"=",
"None",
")",
":",
"# Ensure that clone_to_dir exists",
"clone_to_dir",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"clone... | Download and unpack a zipfile at a given URI.
This will download the zipfile to the cookiecutter repository,
and unpack into a temporary directory.
:param zip_uri: The URI for the zipfile.
:param is_url: Is the zip URI a URL or a file?
:param clone_to_dir: The cookiecutter repository directory
... | [
"Download",
"and",
"unpack",
"a",
"zipfile",
"at",
"a",
"given",
"URI",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/zipfile.py#L18-L124 |
32,238 | audreyr/cookiecutter | cookiecutter/main.py | cookiecutter | def cookiecutter(
template, checkout=None, no_input=False, extra_context=None,
replay=False, overwrite_if_exists=False, output_dir='.',
config_file=None, default_config=False, password=None):
"""
Run Cookiecutter just as if using it from the command line.
:param template: A director... | python | def cookiecutter(
template, checkout=None, no_input=False, extra_context=None,
replay=False, overwrite_if_exists=False, output_dir='.',
config_file=None, default_config=False, password=None):
"""
Run Cookiecutter just as if using it from the command line.
:param template: A director... | [
"def",
"cookiecutter",
"(",
"template",
",",
"checkout",
"=",
"None",
",",
"no_input",
"=",
"False",
",",
"extra_context",
"=",
"None",
",",
"replay",
"=",
"False",
",",
"overwrite_if_exists",
"=",
"False",
",",
"output_dir",
"=",
"'.'",
",",
"config_file",
... | Run Cookiecutter just as if using it from the command line.
:param template: A directory containing a project template directory,
or a URL to a git repository.
:param checkout: The branch, tag or commit ID to checkout after clone.
:param no_input: Prompt the user at command line for manual configur... | [
"Run",
"Cookiecutter",
"just",
"as",
"if",
"using",
"it",
"from",
"the",
"command",
"line",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/main.py#L25-L101 |
32,239 | audreyr/cookiecutter | cookiecutter/prompt.py | read_user_choice | def read_user_choice(var_name, options):
"""Prompt the user to choose from several options for the given variable.
The first item will be returned if no input happens.
:param str var_name: Variable as specified in the context
:param list options: Sequence of options that are available to select from
... | python | def read_user_choice(var_name, options):
"""Prompt the user to choose from several options for the given variable.
The first item will be returned if no input happens.
:param str var_name: Variable as specified in the context
:param list options: Sequence of options that are available to select from
... | [
"def",
"read_user_choice",
"(",
"var_name",
",",
"options",
")",
":",
"# Please see http://click.pocoo.org/4/api/#click.prompt",
"if",
"not",
"isinstance",
"(",
"options",
",",
"list",
")",
":",
"raise",
"TypeError",
"if",
"not",
"options",
":",
"raise",
"ValueError... | Prompt the user to choose from several options for the given variable.
The first item will be returned if no input happens.
:param str var_name: Variable as specified in the context
:param list options: Sequence of options that are available to select from
:return: Exactly one item of ``options`` that... | [
"Prompt",
"the",
"user",
"to",
"choose",
"from",
"several",
"options",
"for",
"the",
"given",
"variable",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/prompt.py#L61-L93 |
32,240 | audreyr/cookiecutter | cookiecutter/prompt.py | read_user_dict | def read_user_dict(var_name, default_value):
"""Prompt the user to provide a dictionary of data.
:param str var_name: Variable as specified in the context
:param default_value: Value that will be returned if no input is provided
:return: A Python dictionary to use in the context.
"""
# Please s... | python | def read_user_dict(var_name, default_value):
"""Prompt the user to provide a dictionary of data.
:param str var_name: Variable as specified in the context
:param default_value: Value that will be returned if no input is provided
:return: A Python dictionary to use in the context.
"""
# Please s... | [
"def",
"read_user_dict",
"(",
"var_name",
",",
"default_value",
")",
":",
"# Please see http://click.pocoo.org/4/api/#click.prompt",
"if",
"not",
"isinstance",
"(",
"default_value",
",",
"dict",
")",
":",
"raise",
"TypeError",
"default_display",
"=",
"'default'",
"user_... | Prompt the user to provide a dictionary of data.
:param str var_name: Variable as specified in the context
:param default_value: Value that will be returned if no input is provided
:return: A Python dictionary to use in the context. | [
"Prompt",
"the",
"user",
"to",
"provide",
"a",
"dictionary",
"of",
"data",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/prompt.py#L113-L136 |
32,241 | audreyr/cookiecutter | cookiecutter/prompt.py | prompt_choice_for_config | def prompt_choice_for_config(cookiecutter_dict, env, key, options, no_input):
"""Prompt the user which option to choose from the given. Each of the
possible choices is rendered beforehand.
"""
rendered_options = [
render_variable(env, raw, cookiecutter_dict) for raw in options
]
if no_i... | python | def prompt_choice_for_config(cookiecutter_dict, env, key, options, no_input):
"""Prompt the user which option to choose from the given. Each of the
possible choices is rendered beforehand.
"""
rendered_options = [
render_variable(env, raw, cookiecutter_dict) for raw in options
]
if no_i... | [
"def",
"prompt_choice_for_config",
"(",
"cookiecutter_dict",
",",
"env",
",",
"key",
",",
"options",
",",
"no_input",
")",
":",
"rendered_options",
"=",
"[",
"render_variable",
"(",
"env",
",",
"raw",
",",
"cookiecutter_dict",
")",
"for",
"raw",
"in",
"options... | Prompt the user which option to choose from the given. Each of the
possible choices is rendered beforehand. | [
"Prompt",
"the",
"user",
"which",
"option",
"to",
"choose",
"from",
"the",
"given",
".",
"Each",
"of",
"the",
"possible",
"choices",
"is",
"rendered",
"beforehand",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/prompt.py#L176-L186 |
32,242 | audreyr/cookiecutter | cookiecutter/prompt.py | prompt_for_config | def prompt_for_config(context, no_input=False):
"""
Prompts the user to enter new config, using context as a source for the
field names and sample values.
:param no_input: Prompt the user at command line for manual configuration?
"""
cookiecutter_dict = OrderedDict([])
env = StrictEnvironme... | python | def prompt_for_config(context, no_input=False):
"""
Prompts the user to enter new config, using context as a source for the
field names and sample values.
:param no_input: Prompt the user at command line for manual configuration?
"""
cookiecutter_dict = OrderedDict([])
env = StrictEnvironme... | [
"def",
"prompt_for_config",
"(",
"context",
",",
"no_input",
"=",
"False",
")",
":",
"cookiecutter_dict",
"=",
"OrderedDict",
"(",
"[",
"]",
")",
"env",
"=",
"StrictEnvironment",
"(",
"context",
"=",
"context",
")",
"# First pass: Handle simple and raw variables, pl... | Prompts the user to enter new config, using context as a source for the
field names and sample values.
:param no_input: Prompt the user at command line for manual configuration? | [
"Prompts",
"the",
"user",
"to",
"enter",
"new",
"config",
"using",
"context",
"as",
"a",
"source",
"for",
"the",
"field",
"names",
"and",
"sample",
"values",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/prompt.py#L189-L242 |
32,243 | audreyr/cookiecutter | cookiecutter/environment.py | ExtensionLoaderMixin._read_extensions | def _read_extensions(self, context):
"""Return list of extensions as str to be passed on to the Jinja2 env.
If context does not contain the relevant info, return an empty
list instead.
"""
try:
extensions = context['cookiecutter']['_extensions']
except KeyErr... | python | def _read_extensions(self, context):
"""Return list of extensions as str to be passed on to the Jinja2 env.
If context does not contain the relevant info, return an empty
list instead.
"""
try:
extensions = context['cookiecutter']['_extensions']
except KeyErr... | [
"def",
"_read_extensions",
"(",
"self",
",",
"context",
")",
":",
"try",
":",
"extensions",
"=",
"context",
"[",
"'cookiecutter'",
"]",
"[",
"'_extensions'",
"]",
"except",
"KeyError",
":",
"return",
"[",
"]",
"else",
":",
"return",
"[",
"str",
"(",
"ext... | Return list of extensions as str to be passed on to the Jinja2 env.
If context does not contain the relevant info, return an empty
list instead. | [
"Return",
"list",
"of",
"extensions",
"as",
"str",
"to",
"be",
"passed",
"on",
"to",
"the",
"Jinja2",
"env",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/environment.py#L42-L53 |
32,244 | audreyr/cookiecutter | cookiecutter/log.py | configure_logger | def configure_logger(stream_level='DEBUG', debug_file=None):
"""Configure logging for cookiecutter.
Set up logging to stdout with given level. If ``debug_file`` is given set
up logging to file with DEBUG level.
"""
# Set up 'cookiecutter' logger
logger = logging.getLogger('cookiecutter')
lo... | python | def configure_logger(stream_level='DEBUG', debug_file=None):
"""Configure logging for cookiecutter.
Set up logging to stdout with given level. If ``debug_file`` is given set
up logging to file with DEBUG level.
"""
# Set up 'cookiecutter' logger
logger = logging.getLogger('cookiecutter')
lo... | [
"def",
"configure_logger",
"(",
"stream_level",
"=",
"'DEBUG'",
",",
"debug_file",
"=",
"None",
")",
":",
"# Set up 'cookiecutter' logger",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"'cookiecutter'",
")",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"D... | Configure logging for cookiecutter.
Set up logging to stdout with given level. If ``debug_file`` is given set
up logging to file with DEBUG level. | [
"Configure",
"logging",
"for",
"cookiecutter",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/log.py#L22-L54 |
32,245 | audreyr/cookiecutter | cookiecutter/vcs.py | identify_repo | def identify_repo(repo_url):
"""Determine if `repo_url` should be treated as a URL to a git or hg repo.
Repos can be identified by prepending "hg+" or "git+" to the repo URL.
:param repo_url: Repo URL of unknown type.
:returns: ('git', repo_url), ('hg', repo_url), or None.
"""
repo_url_values ... | python | def identify_repo(repo_url):
"""Determine if `repo_url` should be treated as a URL to a git or hg repo.
Repos can be identified by prepending "hg+" or "git+" to the repo URL.
:param repo_url: Repo URL of unknown type.
:returns: ('git', repo_url), ('hg', repo_url), or None.
"""
repo_url_values ... | [
"def",
"identify_repo",
"(",
"repo_url",
")",
":",
"repo_url_values",
"=",
"repo_url",
".",
"split",
"(",
"'+'",
")",
"if",
"len",
"(",
"repo_url_values",
")",
"==",
"2",
":",
"repo_type",
"=",
"repo_url_values",
"[",
"0",
"]",
"if",
"repo_type",
"in",
"... | Determine if `repo_url` should be treated as a URL to a git or hg repo.
Repos can be identified by prepending "hg+" or "git+" to the repo URL.
:param repo_url: Repo URL of unknown type.
:returns: ('git', repo_url), ('hg', repo_url), or None. | [
"Determine",
"if",
"repo_url",
"should",
"be",
"treated",
"as",
"a",
"URL",
"to",
"a",
"git",
"or",
"hg",
"repo",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/vcs.py#L26-L47 |
32,246 | audreyr/cookiecutter | cookiecutter/vcs.py | clone | def clone(repo_url, checkout=None, clone_to_dir='.', no_input=False):
"""Clone a repo to the current directory.
:param repo_url: Repo URL of unknown type.
:param checkout: The branch, tag or commit ID to checkout after clone.
:param clone_to_dir: The directory to clone to.
Defa... | python | def clone(repo_url, checkout=None, clone_to_dir='.', no_input=False):
"""Clone a repo to the current directory.
:param repo_url: Repo URL of unknown type.
:param checkout: The branch, tag or commit ID to checkout after clone.
:param clone_to_dir: The directory to clone to.
Defa... | [
"def",
"clone",
"(",
"repo_url",
",",
"checkout",
"=",
"None",
",",
"clone_to_dir",
"=",
"'.'",
",",
"no_input",
"=",
"False",
")",
":",
"# Ensure that clone_to_dir exists",
"clone_to_dir",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"clone_to_dir",
")",
... | Clone a repo to the current directory.
:param repo_url: Repo URL of unknown type.
:param checkout: The branch, tag or commit ID to checkout after clone.
:param clone_to_dir: The directory to clone to.
Defaults to the current directory.
:param no_input: Suppress all user prompts... | [
"Clone",
"a",
"repo",
"to",
"the",
"current",
"directory",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/vcs.py#L59-L121 |
32,247 | audreyr/cookiecutter | cookiecutter/hooks.py | valid_hook | def valid_hook(hook_file, hook_name):
"""Determine if a hook file is valid.
:param hook_file: The hook file to consider for validity
:param hook_name: The hook to find
:return: The hook file validity
"""
filename = os.path.basename(hook_file)
basename = os.path.splitext(filename)[0]
ma... | python | def valid_hook(hook_file, hook_name):
"""Determine if a hook file is valid.
:param hook_file: The hook file to consider for validity
:param hook_name: The hook to find
:return: The hook file validity
"""
filename = os.path.basename(hook_file)
basename = os.path.splitext(filename)[0]
ma... | [
"def",
"valid_hook",
"(",
"hook_file",
",",
"hook_name",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"hook_file",
")",
"basename",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"[",
"0",
"]",
"matching_hook",
"=... | Determine if a hook file is valid.
:param hook_file: The hook file to consider for validity
:param hook_name: The hook to find
:return: The hook file validity | [
"Determine",
"if",
"a",
"hook",
"file",
"is",
"valid",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/hooks.py#L26-L40 |
32,248 | audreyr/cookiecutter | cookiecutter/hooks.py | find_hook | def find_hook(hook_name, hooks_dir='hooks'):
"""Return a dict of all hook scripts provided.
Must be called with the project template as the current working directory.
Dict's key will be the hook/script's name, without extension, while values
will be the absolute path to the script. Missing scripts will... | python | def find_hook(hook_name, hooks_dir='hooks'):
"""Return a dict of all hook scripts provided.
Must be called with the project template as the current working directory.
Dict's key will be the hook/script's name, without extension, while values
will be the absolute path to the script. Missing scripts will... | [
"def",
"find_hook",
"(",
"hook_name",
",",
"hooks_dir",
"=",
"'hooks'",
")",
":",
"logger",
".",
"debug",
"(",
"'hooks_dir is {}'",
".",
"format",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"hooks_dir",
")",
")",
")",
"if",
"not",
"os",
".",
"path",
... | Return a dict of all hook scripts provided.
Must be called with the project template as the current working directory.
Dict's key will be the hook/script's name, without extension, while values
will be the absolute path to the script. Missing scripts will not be
included in the returned dict.
:par... | [
"Return",
"a",
"dict",
"of",
"all",
"hook",
"scripts",
"provided",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/hooks.py#L43-L65 |
32,249 | audreyr/cookiecutter | cookiecutter/hooks.py | run_script | def run_script(script_path, cwd='.'):
"""Execute a script from a working directory.
:param script_path: Absolute path to the script to run.
:param cwd: The directory to run the script from.
"""
run_thru_shell = sys.platform.startswith('win')
if script_path.endswith('.py'):
script_comman... | python | def run_script(script_path, cwd='.'):
"""Execute a script from a working directory.
:param script_path: Absolute path to the script to run.
:param cwd: The directory to run the script from.
"""
run_thru_shell = sys.platform.startswith('win')
if script_path.endswith('.py'):
script_comman... | [
"def",
"run_script",
"(",
"script_path",
",",
"cwd",
"=",
"'.'",
")",
":",
"run_thru_shell",
"=",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'win'",
")",
"if",
"script_path",
".",
"endswith",
"(",
"'.py'",
")",
":",
"script_command",
"=",
"[",
"sys... | Execute a script from a working directory.
:param script_path: Absolute path to the script to run.
:param cwd: The directory to run the script from. | [
"Execute",
"a",
"script",
"from",
"a",
"working",
"directory",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/hooks.py#L68-L101 |
32,250 | audreyr/cookiecutter | cookiecutter/hooks.py | run_script_with_context | def run_script_with_context(script_path, cwd, context):
"""Execute a script after rendering it with Jinja.
:param script_path: Absolute path to the script to run.
:param cwd: The directory to run the script from.
:param context: Cookiecutter project template context.
"""
_, extension = os.path.... | python | def run_script_with_context(script_path, cwd, context):
"""Execute a script after rendering it with Jinja.
:param script_path: Absolute path to the script to run.
:param cwd: The directory to run the script from.
:param context: Cookiecutter project template context.
"""
_, extension = os.path.... | [
"def",
"run_script_with_context",
"(",
"script_path",
",",
"cwd",
",",
"context",
")",
":",
"_",
",",
"extension",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"script_path",
")",
"contents",
"=",
"io",
".",
"open",
"(",
"script_path",
",",
"'r'",
",",
... | Execute a script after rendering it with Jinja.
:param script_path: Absolute path to the script to run.
:param cwd: The directory to run the script from.
:param context: Cookiecutter project template context. | [
"Execute",
"a",
"script",
"after",
"rendering",
"it",
"with",
"Jinja",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/hooks.py#L104-L128 |
32,251 | audreyr/cookiecutter | cookiecutter/hooks.py | run_hook | def run_hook(hook_name, project_dir, context):
"""
Try to find and execute a hook from the specified project directory.
:param hook_name: The hook to execute.
:param project_dir: The directory to execute the script from.
:param context: Cookiecutter project context.
"""
script = find_hook(h... | python | def run_hook(hook_name, project_dir, context):
"""
Try to find and execute a hook from the specified project directory.
:param hook_name: The hook to execute.
:param project_dir: The directory to execute the script from.
:param context: Cookiecutter project context.
"""
script = find_hook(h... | [
"def",
"run_hook",
"(",
"hook_name",
",",
"project_dir",
",",
"context",
")",
":",
"script",
"=",
"find_hook",
"(",
"hook_name",
")",
"if",
"script",
"is",
"None",
":",
"logger",
".",
"debug",
"(",
"'No {} hook found'",
".",
"format",
"(",
"hook_name",
")"... | Try to find and execute a hook from the specified project directory.
:param hook_name: The hook to execute.
:param project_dir: The directory to execute the script from.
:param context: Cookiecutter project context. | [
"Try",
"to",
"find",
"and",
"execute",
"a",
"hook",
"from",
"the",
"specified",
"project",
"directory",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/hooks.py#L131-L144 |
32,252 | audreyr/cookiecutter | cookiecutter/cli.py | version_msg | def version_msg():
"""Return the Cookiecutter version, location and Python powering it."""
python_version = sys.version[:3]
location = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
message = u'Cookiecutter %(version)s from {} (Python {})'
return message.format(location, python_version) | python | def version_msg():
"""Return the Cookiecutter version, location and Python powering it."""
python_version = sys.version[:3]
location = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
message = u'Cookiecutter %(version)s from {} (Python {})'
return message.format(location, python_version) | [
"def",
"version_msg",
"(",
")",
":",
"python_version",
"=",
"sys",
".",
"version",
"[",
":",
"3",
"]",
"location",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file_... | Return the Cookiecutter version, location and Python powering it. | [
"Return",
"the",
"Cookiecutter",
"version",
"location",
"and",
"Python",
"powering",
"it",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/cli.py#L27-L32 |
32,253 | audreyr/cookiecutter | cookiecutter/cli.py | validate_extra_context | def validate_extra_context(ctx, param, value):
"""Validate extra context."""
for s in value:
if '=' not in s:
raise click.BadParameter(
'EXTRA_CONTEXT should contain items of the form key=value; '
"'{}' doesn't match that form".format(s)
)
# C... | python | def validate_extra_context(ctx, param, value):
"""Validate extra context."""
for s in value:
if '=' not in s:
raise click.BadParameter(
'EXTRA_CONTEXT should contain items of the form key=value; '
"'{}' doesn't match that form".format(s)
)
# C... | [
"def",
"validate_extra_context",
"(",
"ctx",
",",
"param",
",",
"value",
")",
":",
"for",
"s",
"in",
"value",
":",
"if",
"'='",
"not",
"in",
"s",
":",
"raise",
"click",
".",
"BadParameter",
"(",
"'EXTRA_CONTEXT should contain items of the form key=value; '",
"\"... | Validate extra context. | [
"Validate",
"extra",
"context",
"."
] | 3bc7b987e4ae9dcee996ae0b00375c1325b8d866 | https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/cli.py#L35-L46 |
32,254 | graphql-python/graphene | graphene/types/mountedtype.py | MountedType.mounted | def mounted(cls, unmounted): # noqa: N802
"""
Mount the UnmountedType instance
"""
assert isinstance(unmounted, UnmountedType), ("{} can't mount {}").format(
cls.__name__, repr(unmounted)
)
return cls(
unmounted.get_type(),
*unmounted... | python | def mounted(cls, unmounted): # noqa: N802
"""
Mount the UnmountedType instance
"""
assert isinstance(unmounted, UnmountedType), ("{} can't mount {}").format(
cls.__name__, repr(unmounted)
)
return cls(
unmounted.get_type(),
*unmounted... | [
"def",
"mounted",
"(",
"cls",
",",
"unmounted",
")",
":",
"# noqa: N802",
"assert",
"isinstance",
"(",
"unmounted",
",",
"UnmountedType",
")",
",",
"(",
"\"{} can't mount {}\"",
")",
".",
"format",
"(",
"cls",
".",
"__name__",
",",
"repr",
"(",
"unmounted",
... | Mount the UnmountedType instance | [
"Mount",
"the",
"UnmountedType",
"instance"
] | abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6 | https://github.com/graphql-python/graphene/blob/abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6/graphene/types/mountedtype.py#L7-L20 |
32,255 | graphql-python/graphene | graphene/pyutils/signature.py | Parameter.replace | def replace(
self,
name=_void,
kind=_void,
annotation=_void,
default=_void,
_partial_kwarg=_void,
):
"""Creates a customized copy of the Parameter."""
if name is _void:
name = self._name
if kind is _void:
kind = self._... | python | def replace(
self,
name=_void,
kind=_void,
annotation=_void,
default=_void,
_partial_kwarg=_void,
):
"""Creates a customized copy of the Parameter."""
if name is _void:
name = self._name
if kind is _void:
kind = self._... | [
"def",
"replace",
"(",
"self",
",",
"name",
"=",
"_void",
",",
"kind",
"=",
"_void",
",",
"annotation",
"=",
"_void",
",",
"default",
"=",
"_void",
",",
"_partial_kwarg",
"=",
"_void",
",",
")",
":",
"if",
"name",
"is",
"_void",
":",
"name",
"=",
"... | Creates a customized copy of the Parameter. | [
"Creates",
"a",
"customized",
"copy",
"of",
"the",
"Parameter",
"."
] | abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6 | https://github.com/graphql-python/graphene/blob/abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6/graphene/pyutils/signature.py#L288-L319 |
32,256 | graphql-python/graphene | graphene/pyutils/signature.py | Signature.from_function | def from_function(cls, func):
"""Constructs Signature for the given python function"""
if not isinstance(func, types.FunctionType):
raise TypeError("{!r} is not a Python function".format(func))
Parameter = cls._parameter_cls
# Parameter information.
func_code = fun... | python | def from_function(cls, func):
"""Constructs Signature for the given python function"""
if not isinstance(func, types.FunctionType):
raise TypeError("{!r} is not a Python function".format(func))
Parameter = cls._parameter_cls
# Parameter information.
func_code = fun... | [
"def",
"from_function",
"(",
"cls",
",",
"func",
")",
":",
"if",
"not",
"isinstance",
"(",
"func",
",",
"types",
".",
"FunctionType",
")",
":",
"raise",
"TypeError",
"(",
"\"{!r} is not a Python function\"",
".",
"format",
"(",
"func",
")",
")",
"Parameter",... | Constructs Signature for the given python function | [
"Constructs",
"Signature",
"for",
"the",
"given",
"python",
"function"
] | abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6 | https://github.com/graphql-python/graphene/blob/abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6/graphene/pyutils/signature.py#L526-L606 |
32,257 | graphql-python/graphene | graphene/pyutils/signature.py | Signature._bind | def _bind(self, args, kwargs, partial=False):
"""Private method. Don't use directly."""
arguments = OrderedDict()
parameters = iter(self.parameters.values())
parameters_ex = ()
arg_vals = iter(args)
if partial:
# Support for binding arguments to 'functools... | python | def _bind(self, args, kwargs, partial=False):
"""Private method. Don't use directly."""
arguments = OrderedDict()
parameters = iter(self.parameters.values())
parameters_ex = ()
arg_vals = iter(args)
if partial:
# Support for binding arguments to 'functools... | [
"def",
"_bind",
"(",
"self",
",",
"args",
",",
"kwargs",
",",
"partial",
"=",
"False",
")",
":",
"arguments",
"=",
"OrderedDict",
"(",
")",
"parameters",
"=",
"iter",
"(",
"self",
".",
"parameters",
".",
"values",
"(",
")",
")",
"parameters_ex",
"=",
... | Private method. Don't use directly. | [
"Private",
"method",
".",
"Don",
"t",
"use",
"directly",
"."
] | abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6 | https://github.com/graphql-python/graphene/blob/abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6/graphene/pyutils/signature.py#L672-L806 |
32,258 | graphql-python/graphene | graphene/pyutils/signature.py | Signature.bind_partial | def bind_partial(self, *args, **kwargs):
"""Get a BoundArguments object, that partially maps the
passed `args` and `kwargs` to the function's signature.
Raises `TypeError` if the passed arguments can not be bound.
"""
return self._bind(args, kwargs, partial=True) | python | def bind_partial(self, *args, **kwargs):
"""Get a BoundArguments object, that partially maps the
passed `args` and `kwargs` to the function's signature.
Raises `TypeError` if the passed arguments can not be bound.
"""
return self._bind(args, kwargs, partial=True) | [
"def",
"bind_partial",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_bind",
"(",
"args",
",",
"kwargs",
",",
"partial",
"=",
"True",
")"
] | Get a BoundArguments object, that partially maps the
passed `args` and `kwargs` to the function's signature.
Raises `TypeError` if the passed arguments can not be bound. | [
"Get",
"a",
"BoundArguments",
"object",
"that",
"partially",
"maps",
"the",
"passed",
"args",
"and",
"kwargs",
"to",
"the",
"function",
"s",
"signature",
".",
"Raises",
"TypeError",
"if",
"the",
"passed",
"arguments",
"can",
"not",
"be",
"bound",
"."
] | abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6 | https://github.com/graphql-python/graphene/blob/abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6/graphene/pyutils/signature.py#L815-L820 |
32,259 | graphql-python/graphene | graphene/relay/node.py | is_node | def is_node(objecttype):
"""
Check if the given objecttype has Node as an interface
"""
if not isclass(objecttype):
return False
if not issubclass(objecttype, ObjectType):
return False
for i in objecttype._meta.interfaces:
if issubclass(i, Node):
return True... | python | def is_node(objecttype):
"""
Check if the given objecttype has Node as an interface
"""
if not isclass(objecttype):
return False
if not issubclass(objecttype, ObjectType):
return False
for i in objecttype._meta.interfaces:
if issubclass(i, Node):
return True... | [
"def",
"is_node",
"(",
"objecttype",
")",
":",
"if",
"not",
"isclass",
"(",
"objecttype",
")",
":",
"return",
"False",
"if",
"not",
"issubclass",
"(",
"objecttype",
",",
"ObjectType",
")",
":",
"return",
"False",
"for",
"i",
"in",
"objecttype",
".",
"_me... | Check if the given objecttype has Node as an interface | [
"Check",
"if",
"the",
"given",
"objecttype",
"has",
"Node",
"as",
"an",
"interface"
] | abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6 | https://github.com/graphql-python/graphene/blob/abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6/graphene/relay/node.py#L12-L26 |
32,260 | graphql-python/graphene | graphene/pyutils/version.py | get_complete_version | def get_complete_version(version=None):
"""Returns a tuple of the graphene version. If version argument is non-empty,
then checks for correctness of the tuple provided.
"""
if version is None:
from graphene import VERSION as version
else:
assert len(version) == 5
assert versi... | python | def get_complete_version(version=None):
"""Returns a tuple of the graphene version. If version argument is non-empty,
then checks for correctness of the tuple provided.
"""
if version is None:
from graphene import VERSION as version
else:
assert len(version) == 5
assert versi... | [
"def",
"get_complete_version",
"(",
"version",
"=",
"None",
")",
":",
"if",
"version",
"is",
"None",
":",
"from",
"graphene",
"import",
"VERSION",
"as",
"version",
"else",
":",
"assert",
"len",
"(",
"version",
")",
"==",
"5",
"assert",
"version",
"[",
"3... | Returns a tuple of the graphene version. If version argument is non-empty,
then checks for correctness of the tuple provided. | [
"Returns",
"a",
"tuple",
"of",
"the",
"graphene",
"version",
".",
"If",
"version",
"argument",
"is",
"non",
"-",
"empty",
"then",
"checks",
"for",
"correctness",
"of",
"the",
"tuple",
"provided",
"."
] | abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6 | https://github.com/graphql-python/graphene/blob/abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6/graphene/pyutils/version.py#L40-L50 |
32,261 | graphql-python/graphene | graphene/types/utils.py | get_field_as | def get_field_as(value, _as=None):
"""
Get type mounted
"""
if isinstance(value, MountedType):
return value
elif isinstance(value, UnmountedType):
if _as is None:
return value
return _as.mounted(value) | python | def get_field_as(value, _as=None):
"""
Get type mounted
"""
if isinstance(value, MountedType):
return value
elif isinstance(value, UnmountedType):
if _as is None:
return value
return _as.mounted(value) | [
"def",
"get_field_as",
"(",
"value",
",",
"_as",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"MountedType",
")",
":",
"return",
"value",
"elif",
"isinstance",
"(",
"value",
",",
"UnmountedType",
")",
":",
"if",
"_as",
"is",
"None",
":... | Get type mounted | [
"Get",
"type",
"mounted"
] | abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6 | https://github.com/graphql-python/graphene/blob/abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6/graphene/types/utils.py#L12-L21 |
32,262 | elastic/elasticsearch-dsl-py | examples/composite_agg.py | scan_aggs | def scan_aggs(search, source_aggs, inner_aggs={}, size=10):
"""
Helper function used to iterate over all possible bucket combinations of
``source_aggs``, returning results of ``inner_aggs`` for each. Uses the
``composite`` aggregation under the hood to perform this.
"""
def run_search(**kwargs):... | python | def scan_aggs(search, source_aggs, inner_aggs={}, size=10):
"""
Helper function used to iterate over all possible bucket combinations of
``source_aggs``, returning results of ``inner_aggs`` for each. Uses the
``composite`` aggregation under the hood to perform this.
"""
def run_search(**kwargs):... | [
"def",
"scan_aggs",
"(",
"search",
",",
"source_aggs",
",",
"inner_aggs",
"=",
"{",
"}",
",",
"size",
"=",
"10",
")",
":",
"def",
"run_search",
"(",
"*",
"*",
"kwargs",
")",
":",
"s",
"=",
"search",
"[",
":",
"0",
"]",
"s",
".",
"aggs",
".",
"b... | Helper function used to iterate over all possible bucket combinations of
``source_aggs``, returning results of ``inner_aggs`` for each. Uses the
``composite`` aggregation under the hood to perform this. | [
"Helper",
"function",
"used",
"to",
"iterate",
"over",
"all",
"possible",
"bucket",
"combinations",
"of",
"source_aggs",
"returning",
"results",
"of",
"inner_aggs",
"for",
"each",
".",
"Uses",
"the",
"composite",
"aggregation",
"under",
"the",
"hood",
"to",
"per... | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/examples/composite_agg.py#L5-L26 |
32,263 | elastic/elasticsearch-dsl-py | examples/completion.py | Person.clean | def clean(self):
"""
Automatically construct the suggestion input and weight by taking all
possible permutation of Person's name as ``input`` and taking their
popularity as ``weight``.
"""
self.suggest = {
'input': [' '.join(p) for p in permutations(self.name.... | python | def clean(self):
"""
Automatically construct the suggestion input and weight by taking all
possible permutation of Person's name as ``input`` and taking their
popularity as ``weight``.
"""
self.suggest = {
'input': [' '.join(p) for p in permutations(self.name.... | [
"def",
"clean",
"(",
"self",
")",
":",
"self",
".",
"suggest",
"=",
"{",
"'input'",
":",
"[",
"' '",
".",
"join",
"(",
"p",
")",
"for",
"p",
"in",
"permutations",
"(",
"self",
".",
"name",
".",
"split",
"(",
")",
")",
"]",
",",
"'weight'",
":",... | Automatically construct the suggestion input and weight by taking all
possible permutation of Person's name as ``input`` and taking their
popularity as ``weight``. | [
"Automatically",
"construct",
"the",
"suggestion",
"input",
"and",
"weight",
"by",
"taking",
"all",
"possible",
"permutation",
"of",
"Person",
"s",
"name",
"as",
"input",
"and",
"taking",
"their",
"popularity",
"as",
"weight",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/examples/completion.py#L38-L47 |
32,264 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/utils.py | ObjectBase.__list_fields | def __list_fields(cls):
"""
Get all the fields defined for our class, if we have an Index, try
looking at the index mappings as well, mark the fields from Index as
optional.
"""
for name in cls._doc_type.mapping:
field = cls._doc_type.mapping[name]
... | python | def __list_fields(cls):
"""
Get all the fields defined for our class, if we have an Index, try
looking at the index mappings as well, mark the fields from Index as
optional.
"""
for name in cls._doc_type.mapping:
field = cls._doc_type.mapping[name]
... | [
"def",
"__list_fields",
"(",
"cls",
")",
":",
"for",
"name",
"in",
"cls",
".",
"_doc_type",
".",
"mapping",
":",
"field",
"=",
"cls",
".",
"_doc_type",
".",
"mapping",
"[",
"name",
"]",
"yield",
"name",
",",
"field",
",",
"False",
"if",
"hasattr",
"(... | Get all the fields defined for our class, if we have an Index, try
looking at the index mappings as well, mark the fields from Index as
optional. | [
"Get",
"all",
"the",
"fields",
"defined",
"for",
"our",
"class",
"if",
"we",
"have",
"an",
"Index",
"try",
"looking",
"at",
"the",
"index",
"mappings",
"as",
"well",
"mark",
"the",
"fields",
"from",
"Index",
"as",
"optional",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/utils.py#L376-L394 |
32,265 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/update_by_query.py | UpdateByQuery.to_dict | def to_dict(self, **kwargs):
"""
Serialize the search into the dictionary that will be sent over as the
request'ubq body.
All additional keyword arguments will be included into the dictionary.
"""
d = {}
if self.query:
d["query"] = self.query.to_dict(... | python | def to_dict(self, **kwargs):
"""
Serialize the search into the dictionary that will be sent over as the
request'ubq body.
All additional keyword arguments will be included into the dictionary.
"""
d = {}
if self.query:
d["query"] = self.query.to_dict(... | [
"def",
"to_dict",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"d",
"=",
"{",
"}",
"if",
"self",
".",
"query",
":",
"d",
"[",
"\"query\"",
"]",
"=",
"self",
".",
"query",
".",
"to_dict",
"(",
")",
"if",
"self",
".",
"_script",
":",
"d",
"[... | Serialize the search into the dictionary that will be sent over as the
request'ubq body.
All additional keyword arguments will be included into the dictionary. | [
"Serialize",
"the",
"search",
"into",
"the",
"dictionary",
"that",
"will",
"be",
"sent",
"over",
"as",
"the",
"request",
"ubq",
"body",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/update_by_query.py#L113-L130 |
32,266 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/mapping.py | Properties._collect_fields | def _collect_fields(self):
""" Iterate over all Field objects within, including multi fields. """
for f in itervalues(self.properties.to_dict()):
yield f
# multi fields
if hasattr(f, 'fields'):
for inner_f in itervalues(f.fields.to_dict()):
... | python | def _collect_fields(self):
""" Iterate over all Field objects within, including multi fields. """
for f in itervalues(self.properties.to_dict()):
yield f
# multi fields
if hasattr(f, 'fields'):
for inner_f in itervalues(f.fields.to_dict()):
... | [
"def",
"_collect_fields",
"(",
"self",
")",
":",
"for",
"f",
"in",
"itervalues",
"(",
"self",
".",
"properties",
".",
"to_dict",
"(",
")",
")",
":",
"yield",
"f",
"# multi fields",
"if",
"hasattr",
"(",
"f",
",",
"'fields'",
")",
":",
"for",
"inner_f",... | Iterate over all Field objects within, including multi fields. | [
"Iterate",
"over",
"all",
"Field",
"objects",
"within",
"including",
"multi",
"fields",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/mapping.py#L40-L51 |
32,267 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.analyzer | def analyzer(self, *args, **kwargs):
"""
Explicitly add an analyzer to an index. Note that all custom analyzers
defined in mappings will also be created. This is useful for search analyzers.
Example::
from elasticsearch_dsl import analyzer, tokenizer
my_analyze... | python | def analyzer(self, *args, **kwargs):
"""
Explicitly add an analyzer to an index. Note that all custom analyzers
defined in mappings will also be created. This is useful for search analyzers.
Example::
from elasticsearch_dsl import analyzer, tokenizer
my_analyze... | [
"def",
"analyzer",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"analyzer",
"=",
"analysis",
".",
"analyzer",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"d",
"=",
"analyzer",
".",
"get_analysis_definition",
"(",
")",
"# empt... | Explicitly add an analyzer to an index. Note that all custom analyzers
defined in mappings will also be created. This is useful for search analyzers.
Example::
from elasticsearch_dsl import analyzer, tokenizer
my_analyzer = analyzer('my_analyzer',
tokenizer=tok... | [
"Explicitly",
"add",
"an",
"analyzer",
"to",
"an",
"index",
".",
"Note",
"that",
"all",
"custom",
"analyzers",
"defined",
"in",
"mappings",
"will",
"also",
"be",
"created",
".",
"This",
"is",
"useful",
"for",
"search",
"analyzers",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L175-L200 |
32,268 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.create | def create(self, using=None, **kwargs):
"""
Creates the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.create`` unchanged.
"""
self._get_connection(using).indices.create(index=self._name, body=self.to_dict(), **kwargs) | python | def create(self, using=None, **kwargs):
"""
Creates the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.create`` unchanged.
"""
self._get_connection(using).indices.create(index=self._name, body=self.to_dict(), **kwargs) | [
"def",
"create",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"create",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"body",
"=",
"self",
".",
... | Creates the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.create`` unchanged. | [
"Creates",
"the",
"index",
"in",
"elasticsearch",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L247-L254 |
32,269 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.save | def save(self, using=None):
"""
Sync the index definition with elasticsearch, creating the index if it
doesn't exist and updating its settings and mappings if it does.
Note some settings and mapping changes cannot be done on an open
index (or at all on an existing index) and for... | python | def save(self, using=None):
"""
Sync the index definition with elasticsearch, creating the index if it
doesn't exist and updating its settings and mappings if it does.
Note some settings and mapping changes cannot be done on an open
index (or at all on an existing index) and for... | [
"def",
"save",
"(",
"self",
",",
"using",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"exists",
"(",
"using",
"=",
"using",
")",
":",
"return",
"self",
".",
"create",
"(",
"using",
"=",
"using",
")",
"body",
"=",
"self",
".",
"to_dict",
"(",... | Sync the index definition with elasticsearch, creating the index if it
doesn't exist and updating its settings and mappings if it does.
Note some settings and mapping changes cannot be done on an open
index (or at all on an existing index) and for those this method will
fail with the un... | [
"Sync",
"the",
"index",
"definition",
"with",
"elasticsearch",
"creating",
"the",
"index",
"if",
"it",
"doesn",
"t",
"exist",
"and",
"updating",
"its",
"settings",
"and",
"mappings",
"if",
"it",
"does",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L260-L307 |
32,270 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.analyze | def analyze(self, using=None, **kwargs):
"""
Perform the analysis process on a text and return the tokens breakdown
of the text.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.analyze`` unchanged.
"""
return self._get_connection(using)... | python | def analyze(self, using=None, **kwargs):
"""
Perform the analysis process on a text and return the tokens breakdown
of the text.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.analyze`` unchanged.
"""
return self._get_connection(using)... | [
"def",
"analyze",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"analyze",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"kwarg... | Perform the analysis process on a text and return the tokens breakdown
of the text.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.analyze`` unchanged. | [
"Perform",
"the",
"analysis",
"process",
"on",
"a",
"text",
"and",
"return",
"the",
"tokens",
"breakdown",
"of",
"the",
"text",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L309-L317 |
32,271 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.refresh | def refresh(self, using=None, **kwargs):
"""
Preforms a refresh operation on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.refresh`` unchanged.
"""
return self._get_connection(using).indices.refresh(index=self._name, **kwargs) | python | def refresh(self, using=None, **kwargs):
"""
Preforms a refresh operation on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.refresh`` unchanged.
"""
return self._get_connection(using).indices.refresh(index=self._name, **kwargs) | [
"def",
"refresh",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"refresh",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"kwarg... | Preforms a refresh operation on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.refresh`` unchanged. | [
"Preforms",
"a",
"refresh",
"operation",
"on",
"the",
"index",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L319-L326 |
32,272 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.flush | def flush(self, using=None, **kwargs):
"""
Preforms a flush operation on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.flush`` unchanged.
"""
return self._get_connection(using).indices.flush(index=self._name, **kwargs) | python | def flush(self, using=None, **kwargs):
"""
Preforms a flush operation on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.flush`` unchanged.
"""
return self._get_connection(using).indices.flush(index=self._name, **kwargs) | [
"def",
"flush",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"flush",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"kwargs",
... | Preforms a flush operation on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.flush`` unchanged. | [
"Preforms",
"a",
"flush",
"operation",
"on",
"the",
"index",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L328-L335 |
32,273 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.get | def get(self, using=None, **kwargs):
"""
The get index API allows to retrieve information about the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get`` unchanged.
"""
return self._get_connection(using).indices.get(index=self._name, **k... | python | def get(self, using=None, **kwargs):
"""
The get index API allows to retrieve information about the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get`` unchanged.
"""
return self._get_connection(using).indices.get(index=self._name, **k... | [
"def",
"get",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"get",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"kwargs",
")... | The get index API allows to retrieve information about the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get`` unchanged. | [
"The",
"get",
"index",
"API",
"allows",
"to",
"retrieve",
"information",
"about",
"the",
"index",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L337-L344 |
32,274 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.open | def open(self, using=None, **kwargs):
"""
Opens the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.open`` unchanged.
"""
return self._get_connection(using).indices.open(index=self._name, **kwargs) | python | def open(self, using=None, **kwargs):
"""
Opens the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.open`` unchanged.
"""
return self._get_connection(using).indices.open(index=self._name, **kwargs) | [
"def",
"open",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"open",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"kwargs",
... | Opens the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.open`` unchanged. | [
"Opens",
"the",
"index",
"in",
"elasticsearch",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L346-L353 |
32,275 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.close | def close(self, using=None, **kwargs):
"""
Closes the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.close`` unchanged.
"""
return self._get_connection(using).indices.close(index=self._name, **kwargs) | python | def close(self, using=None, **kwargs):
"""
Closes the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.close`` unchanged.
"""
return self._get_connection(using).indices.close(index=self._name, **kwargs) | [
"def",
"close",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"close",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"kwargs",
... | Closes the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.close`` unchanged. | [
"Closes",
"the",
"index",
"in",
"elasticsearch",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L355-L362 |
32,276 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.delete | def delete(self, using=None, **kwargs):
"""
Deletes the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.delete`` unchanged.
"""
return self._get_connection(using).indices.delete(index=self._name, **kwargs) | python | def delete(self, using=None, **kwargs):
"""
Deletes the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.delete`` unchanged.
"""
return self._get_connection(using).indices.delete(index=self._name, **kwargs) | [
"def",
"delete",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"delete",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"kwargs"... | Deletes the index in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.delete`` unchanged. | [
"Deletes",
"the",
"index",
"in",
"elasticsearch",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L364-L371 |
32,277 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.exists | def exists(self, using=None, **kwargs):
"""
Returns ``True`` if the index already exists in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists`` unchanged.
"""
return self._get_connection(using).indices.exists(index=self._nam... | python | def exists(self, using=None, **kwargs):
"""
Returns ``True`` if the index already exists in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists`` unchanged.
"""
return self._get_connection(using).indices.exists(index=self._nam... | [
"def",
"exists",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"exists",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"kwargs"... | Returns ``True`` if the index already exists in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists`` unchanged. | [
"Returns",
"True",
"if",
"the",
"index",
"already",
"exists",
"in",
"elasticsearch",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L373-L380 |
32,278 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.put_mapping | def put_mapping(self, using=None, **kwargs):
"""
Register specific mapping definition for a specific type.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_mapping`` unchanged.
"""
return self._get_connection(using).indices.put_mapping(index... | python | def put_mapping(self, using=None, **kwargs):
"""
Register specific mapping definition for a specific type.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_mapping`` unchanged.
"""
return self._get_connection(using).indices.put_mapping(index... | [
"def",
"put_mapping",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"put_mapping",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
... | Register specific mapping definition for a specific type.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_mapping`` unchanged. | [
"Register",
"specific",
"mapping",
"definition",
"for",
"a",
"specific",
"type",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L391-L398 |
32,279 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.get_mapping | def get_mapping(self, using=None, **kwargs):
"""
Retrieve specific mapping definition for a specific type.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_mapping`` unchanged.
"""
return self._get_connection(using).indices.get_mapping(index... | python | def get_mapping(self, using=None, **kwargs):
"""
Retrieve specific mapping definition for a specific type.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_mapping`` unchanged.
"""
return self._get_connection(using).indices.get_mapping(index... | [
"def",
"get_mapping",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"get_mapping",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
... | Retrieve specific mapping definition for a specific type.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_mapping`` unchanged. | [
"Retrieve",
"specific",
"mapping",
"definition",
"for",
"a",
"specific",
"type",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L400-L407 |
32,280 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.get_field_mapping | def get_field_mapping(self, using=None, **kwargs):
"""
Retrieve mapping definition of a specific field.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_field_mapping`` unchanged.
"""
return self._get_connection(using).indices.get_field_mapp... | python | def get_field_mapping(self, using=None, **kwargs):
"""
Retrieve mapping definition of a specific field.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_field_mapping`` unchanged.
"""
return self._get_connection(using).indices.get_field_mapp... | [
"def",
"get_field_mapping",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"get_field_mapping",
"(",
"index",
"=",
"self",
".",
"_name",
",",
... | Retrieve mapping definition of a specific field.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_field_mapping`` unchanged. | [
"Retrieve",
"mapping",
"definition",
"of",
"a",
"specific",
"field",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L409-L416 |
32,281 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.put_alias | def put_alias(self, using=None, **kwargs):
"""
Create an alias for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_alias`` unchanged.
"""
return self._get_connection(using).indices.put_alias(index=self._name, **kwargs) | python | def put_alias(self, using=None, **kwargs):
"""
Create an alias for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_alias`` unchanged.
"""
return self._get_connection(using).indices.put_alias(index=self._name, **kwargs) | [
"def",
"put_alias",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"put_alias",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"k... | Create an alias for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_alias`` unchanged. | [
"Create",
"an",
"alias",
"for",
"the",
"index",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L418-L425 |
32,282 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.exists_alias | def exists_alias(self, using=None, **kwargs):
"""
Return a boolean indicating whether given alias exists for this index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists_alias`` unchanged.
"""
return self._get_connection(using).indices.ex... | python | def exists_alias(self, using=None, **kwargs):
"""
Return a boolean indicating whether given alias exists for this index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists_alias`` unchanged.
"""
return self._get_connection(using).indices.ex... | [
"def",
"exists_alias",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"exists_alias",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*"... | Return a boolean indicating whether given alias exists for this index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists_alias`` unchanged. | [
"Return",
"a",
"boolean",
"indicating",
"whether",
"given",
"alias",
"exists",
"for",
"this",
"index",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L427-L434 |
32,283 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.get_alias | def get_alias(self, using=None, **kwargs):
"""
Retrieve a specified alias.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_alias`` unchanged.
"""
return self._get_connection(using).indices.get_alias(index=self._name, **kwargs) | python | def get_alias(self, using=None, **kwargs):
"""
Retrieve a specified alias.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_alias`` unchanged.
"""
return self._get_connection(using).indices.get_alias(index=self._name, **kwargs) | [
"def",
"get_alias",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"get_alias",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"k... | Retrieve a specified alias.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_alias`` unchanged. | [
"Retrieve",
"a",
"specified",
"alias",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L436-L443 |
32,284 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.delete_alias | def delete_alias(self, using=None, **kwargs):
"""
Delete specific alias.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.delete_alias`` unchanged.
"""
return self._get_connection(using).indices.delete_alias(index=self._name, **kwargs) | python | def delete_alias(self, using=None, **kwargs):
"""
Delete specific alias.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.delete_alias`` unchanged.
"""
return self._get_connection(using).indices.delete_alias(index=self._name, **kwargs) | [
"def",
"delete_alias",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"delete_alias",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*"... | Delete specific alias.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.delete_alias`` unchanged. | [
"Delete",
"specific",
"alias",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L445-L452 |
32,285 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.get_settings | def get_settings(self, using=None, **kwargs):
"""
Retrieve settings for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_settings`` unchanged.
"""
return self._get_connection(using).indices.get_settings(index=self._name, **kwargs) | python | def get_settings(self, using=None, **kwargs):
"""
Retrieve settings for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_settings`` unchanged.
"""
return self._get_connection(using).indices.get_settings(index=self._name, **kwargs) | [
"def",
"get_settings",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"get_settings",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*"... | Retrieve settings for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_settings`` unchanged. | [
"Retrieve",
"settings",
"for",
"the",
"index",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L454-L461 |
32,286 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.put_settings | def put_settings(self, using=None, **kwargs):
"""
Change specific index level settings in real time.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_settings`` unchanged.
"""
return self._get_connection(using).indices.put_settings(index=sel... | python | def put_settings(self, using=None, **kwargs):
"""
Change specific index level settings in real time.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_settings`` unchanged.
"""
return self._get_connection(using).indices.put_settings(index=sel... | [
"def",
"put_settings",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"put_settings",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*"... | Change specific index level settings in real time.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.put_settings`` unchanged. | [
"Change",
"specific",
"index",
"level",
"settings",
"in",
"real",
"time",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L463-L470 |
32,287 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.stats | def stats(self, using=None, **kwargs):
"""
Retrieve statistics on different operations happening on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.stats`` unchanged.
"""
return self._get_connection(using).indices.stats(index=self._n... | python | def stats(self, using=None, **kwargs):
"""
Retrieve statistics on different operations happening on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.stats`` unchanged.
"""
return self._get_connection(using).indices.stats(index=self._n... | [
"def",
"stats",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"stats",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"kwargs",
... | Retrieve statistics on different operations happening on the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.stats`` unchanged. | [
"Retrieve",
"statistics",
"on",
"different",
"operations",
"happening",
"on",
"the",
"index",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L472-L479 |
32,288 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.validate_query | def validate_query(self, using=None, **kwargs):
"""
Validate a potentially expensive query without executing it.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.validate_query`` unchanged.
"""
return self._get_connection(using).indices.validate... | python | def validate_query(self, using=None, **kwargs):
"""
Validate a potentially expensive query without executing it.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.validate_query`` unchanged.
"""
return self._get_connection(using).indices.validate... | [
"def",
"validate_query",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"validate_query",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
... | Validate a potentially expensive query without executing it.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.validate_query`` unchanged. | [
"Validate",
"a",
"potentially",
"expensive",
"query",
"without",
"executing",
"it",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L491-L498 |
32,289 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.clear_cache | def clear_cache(self, using=None, **kwargs):
"""
Clear all caches or specific cached associated with the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.clear_cache`` unchanged.
"""
return self._get_connection(using).indices.clear_cache(... | python | def clear_cache(self, using=None, **kwargs):
"""
Clear all caches or specific cached associated with the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.clear_cache`` unchanged.
"""
return self._get_connection(using).indices.clear_cache(... | [
"def",
"clear_cache",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"clear_cache",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
... | Clear all caches or specific cached associated with the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.clear_cache`` unchanged. | [
"Clear",
"all",
"caches",
"or",
"specific",
"cached",
"associated",
"with",
"the",
"index",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L500-L507 |
32,290 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.recovery | def recovery(self, using=None, **kwargs):
"""
The indices recovery API provides insight into on-going shard
recoveries for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.recovery`` unchanged.
"""
return self._get_connection(... | python | def recovery(self, using=None, **kwargs):
"""
The indices recovery API provides insight into on-going shard
recoveries for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.recovery`` unchanged.
"""
return self._get_connection(... | [
"def",
"recovery",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"recovery",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"kwa... | The indices recovery API provides insight into on-going shard
recoveries for the index.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.recovery`` unchanged. | [
"The",
"indices",
"recovery",
"API",
"provides",
"insight",
"into",
"on",
"-",
"going",
"shard",
"recoveries",
"for",
"the",
"index",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L509-L517 |
32,291 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.upgrade | def upgrade(self, using=None, **kwargs):
"""
Upgrade the index to the latest format.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.upgrade`` unchanged.
"""
return self._get_connection(using).indices.upgrade(index=self._name, **kwargs) | python | def upgrade(self, using=None, **kwargs):
"""
Upgrade the index to the latest format.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.upgrade`` unchanged.
"""
return self._get_connection(using).indices.upgrade(index=self._name, **kwargs) | [
"def",
"upgrade",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"upgrade",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"kwarg... | Upgrade the index to the latest format.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.upgrade`` unchanged. | [
"Upgrade",
"the",
"index",
"to",
"the",
"latest",
"format",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L519-L526 |
32,292 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.get_upgrade | def get_upgrade(self, using=None, **kwargs):
"""
Monitor how much of the index is upgraded.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_upgrade`` unchanged.
"""
return self._get_connection(using).indices.get_upgrade(index=self._name, **... | python | def get_upgrade(self, using=None, **kwargs):
"""
Monitor how much of the index is upgraded.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_upgrade`` unchanged.
"""
return self._get_connection(using).indices.get_upgrade(index=self._name, **... | [
"def",
"get_upgrade",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"get_upgrade",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
... | Monitor how much of the index is upgraded.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.get_upgrade`` unchanged. | [
"Monitor",
"how",
"much",
"of",
"the",
"index",
"is",
"upgraded",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L528-L535 |
32,293 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.shard_stores | def shard_stores(self, using=None, **kwargs):
"""
Provides store information for shard copies of the index. Store
information reports on which nodes shard copies exist, the shard copy
version, indicating how recent they are, and any exceptions encountered
while opening the shard ... | python | def shard_stores(self, using=None, **kwargs):
"""
Provides store information for shard copies of the index. Store
information reports on which nodes shard copies exist, the shard copy
version, indicating how recent they are, and any exceptions encountered
while opening the shard ... | [
"def",
"shard_stores",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"shard_stores",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*"... | Provides store information for shard copies of the index. Store
information reports on which nodes shard copies exist, the shard copy
version, indicating how recent they are, and any exceptions encountered
while opening the shard index or from earlier engine failure.
Any additional keyw... | [
"Provides",
"store",
"information",
"for",
"shard",
"copies",
"of",
"the",
"index",
".",
"Store",
"information",
"reports",
"on",
"which",
"nodes",
"shard",
"copies",
"exist",
"the",
"shard",
"copy",
"version",
"indicating",
"how",
"recent",
"they",
"are",
"an... | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L547-L557 |
32,294 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | Index.forcemerge | def forcemerge(self, using=None, **kwargs):
"""
The force merge API allows to force merging of the index through an
API. The merge relates to the number of segments a Lucene index holds
within each shard. The force merge operation allows to reduce the
number of segments by mergin... | python | def forcemerge(self, using=None, **kwargs):
"""
The force merge API allows to force merging of the index through an
API. The merge relates to the number of segments a Lucene index holds
within each shard. The force merge operation allows to reduce the
number of segments by mergin... | [
"def",
"forcemerge",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"forcemerge",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
... | The force merge API allows to force merging of the index through an
API. The merge relates to the number of segments a Lucene index holds
within each shard. The force merge operation allows to reduce the
number of segments by merging them.
This call will block until the merge is complet... | [
"The",
"force",
"merge",
"API",
"allows",
"to",
"force",
"merging",
"of",
"the",
"index",
"through",
"an",
"API",
".",
"The",
"merge",
"relates",
"to",
"the",
"number",
"of",
"segments",
"a",
"Lucene",
"index",
"holds",
"within",
"each",
"shard",
".",
"T... | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L559-L573 |
32,295 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/connections.py | Connections.configure | def configure(self, **kwargs):
"""
Configure multiple connections at once, useful for passing in config
dictionaries obtained from other sources, like Django's settings or a
configuration management tool.
Example::
connections.configure(
default={'ho... | python | def configure(self, **kwargs):
"""
Configure multiple connections at once, useful for passing in config
dictionaries obtained from other sources, like Django's settings or a
configuration management tool.
Example::
connections.configure(
default={'ho... | [
"def",
"configure",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"k",
"in",
"list",
"(",
"self",
".",
"_conns",
")",
":",
"# try and preserve existing client to keep the persistent connections alive",
"if",
"k",
"in",
"self",
".",
"_kwargs",
"and",
"... | Configure multiple connections at once, useful for passing in config
dictionaries obtained from other sources, like Django's settings or a
configuration management tool.
Example::
connections.configure(
default={'hosts': 'localhost'},
dev={'hosts': [... | [
"Configure",
"multiple",
"connections",
"at",
"once",
"useful",
"for",
"passing",
"in",
"config",
"dictionaries",
"obtained",
"from",
"other",
"sources",
"like",
"Django",
"s",
"settings",
"or",
"a",
"configuration",
"management",
"tool",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/connections.py#L16-L37 |
32,296 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/connections.py | Connections.remove_connection | def remove_connection(self, alias):
"""
Remove connection from the registry. Raises ``KeyError`` if connection
wasn't found.
"""
errors = 0
for d in (self._conns, self._kwargs):
try:
del d[alias]
except KeyError:
err... | python | def remove_connection(self, alias):
"""
Remove connection from the registry. Raises ``KeyError`` if connection
wasn't found.
"""
errors = 0
for d in (self._conns, self._kwargs):
try:
del d[alias]
except KeyError:
err... | [
"def",
"remove_connection",
"(",
"self",
",",
"alias",
")",
":",
"errors",
"=",
"0",
"for",
"d",
"in",
"(",
"self",
".",
"_conns",
",",
"self",
".",
"_kwargs",
")",
":",
"try",
":",
"del",
"d",
"[",
"alias",
"]",
"except",
"KeyError",
":",
"errors"... | Remove connection from the registry. Raises ``KeyError`` if connection
wasn't found. | [
"Remove",
"connection",
"from",
"the",
"registry",
".",
"Raises",
"KeyError",
"if",
"connection",
"wasn",
"t",
"found",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/connections.py#L45-L58 |
32,297 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/connections.py | Connections.create_connection | def create_connection(self, alias='default', **kwargs):
"""
Construct an instance of ``elasticsearch.Elasticsearch`` and register
it under given alias.
"""
kwargs.setdefault('serializer', serializer)
conn = self._conns[alias] = Elasticsearch(**kwargs)
return conn | python | def create_connection(self, alias='default', **kwargs):
"""
Construct an instance of ``elasticsearch.Elasticsearch`` and register
it under given alias.
"""
kwargs.setdefault('serializer', serializer)
conn = self._conns[alias] = Elasticsearch(**kwargs)
return conn | [
"def",
"create_connection",
"(",
"self",
",",
"alias",
"=",
"'default'",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'serializer'",
",",
"serializer",
")",
"conn",
"=",
"self",
".",
"_conns",
"[",
"alias",
"]",
"=",
"Elasticsear... | Construct an instance of ``elasticsearch.Elasticsearch`` and register
it under given alias. | [
"Construct",
"an",
"instance",
"of",
"elasticsearch",
".",
"Elasticsearch",
"and",
"register",
"it",
"under",
"given",
"alias",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/connections.py#L60-L67 |
32,298 | elastic/elasticsearch-dsl-py | examples/alias_migration.py | setup | def setup():
"""
Create the index template in elasticsearch specifying the mappings and any
settings to be used. This can be run at any time, ideally at every new code
deploy.
"""
# create an index template
index_template = BlogPost._index.as_template(ALIAS, PATTERN)
# upload the templat... | python | def setup():
"""
Create the index template in elasticsearch specifying the mappings and any
settings to be used. This can be run at any time, ideally at every new code
deploy.
"""
# create an index template
index_template = BlogPost._index.as_template(ALIAS, PATTERN)
# upload the templat... | [
"def",
"setup",
"(",
")",
":",
"# create an index template",
"index_template",
"=",
"BlogPost",
".",
"_index",
".",
"as_template",
"(",
"ALIAS",
",",
"PATTERN",
")",
"# upload the template into elasticsearch",
"# potentially overriding the one already there",
"index_template"... | Create the index template in elasticsearch specifying the mappings and any
settings to be used. This can be run at any time, ideally at every new code
deploy. | [
"Create",
"the",
"index",
"template",
"in",
"elasticsearch",
"specifying",
"the",
"mappings",
"and",
"any",
"settings",
"to",
"be",
"used",
".",
"This",
"can",
"be",
"run",
"at",
"any",
"time",
"ideally",
"at",
"every",
"new",
"code",
"deploy",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/examples/alias_migration.py#L54-L68 |
32,299 | elastic/elasticsearch-dsl-py | elasticsearch_dsl/analysis.py | CustomAnalyzer.simulate | def simulate(self, text, using='default', explain=False, attributes=None):
"""
Use the Analyze API of elasticsearch to test the outcome of this analyzer.
:arg text: Text to be analyzed
:arg using: connection alias to use, defaults to ``'default'``
:arg explain: will output all t... | python | def simulate(self, text, using='default', explain=False, attributes=None):
"""
Use the Analyze API of elasticsearch to test the outcome of this analyzer.
:arg text: Text to be analyzed
:arg using: connection alias to use, defaults to ``'default'``
:arg explain: will output all t... | [
"def",
"simulate",
"(",
"self",
",",
"text",
",",
"using",
"=",
"'default'",
",",
"explain",
"=",
"False",
",",
"attributes",
"=",
"None",
")",
":",
"es",
"=",
"connections",
".",
"get_connection",
"(",
"using",
")",
"body",
"=",
"{",
"'text'",
":",
... | Use the Analyze API of elasticsearch to test the outcome of this analyzer.
:arg text: Text to be analyzed
:arg using: connection alias to use, defaults to ``'default'``
:arg explain: will output all token attributes for each token. You can
filter token attributes you want to output ... | [
"Use",
"the",
"Analyze",
"API",
"of",
"elasticsearch",
"to",
"test",
"the",
"outcome",
"of",
"this",
"analyzer",
"."
] | 874b52472fc47b601de0e5fa0e4300e21aff0085 | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/analysis.py#L85-L120 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.