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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
47,600 | insomnia-lab/libreant | libreantdb/api.py | DB.increment_download_count | def increment_download_count(self, id, attachmentID, doc_type='book'):
'''
Increment the download counter of a specific file
'''
body = self.es.get(index=self.index_name, id=id, doc_type='book', _source_include='_attachments')['_source']
for attachment in body['_attachments']:
... | python | def increment_download_count(self, id, attachmentID, doc_type='book'):
'''
Increment the download counter of a specific file
'''
body = self.es.get(index=self.index_name, id=id, doc_type='book', _source_include='_attachments')['_source']
for attachment in body['_attachments']:
... | [
"def",
"increment_download_count",
"(",
"self",
",",
"id",
",",
"attachmentID",
",",
"doc_type",
"=",
"'book'",
")",
":",
"body",
"=",
"self",
".",
"es",
".",
"get",
"(",
"index",
"=",
"self",
".",
"index_name",
",",
"id",
"=",
"id",
",",
"doc_type",
... | Increment the download counter of a specific file | [
"Increment",
"the",
"download",
"counter",
"of",
"a",
"specific",
"file"
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L428-L442 |
47,601 | chaoss/grimoirelab-manuscripts | manuscripts/config.py | Config.__add_types | def __add_types(self, raw_conf):
""" Convert to int, boolean, list, None types config items """
typed_conf = {}
for s in raw_conf.keys():
typed_conf[s] = {}
for option in raw_conf[s]:
val = raw_conf[s][option]
if len(val) > 1 and (val[0] ... | python | def __add_types(self, raw_conf):
""" Convert to int, boolean, list, None types config items """
typed_conf = {}
for s in raw_conf.keys():
typed_conf[s] = {}
for option in raw_conf[s]:
val = raw_conf[s][option]
if len(val) > 1 and (val[0] ... | [
"def",
"__add_types",
"(",
"self",
",",
"raw_conf",
")",
":",
"typed_conf",
"=",
"{",
"}",
"for",
"s",
"in",
"raw_conf",
".",
"keys",
"(",
")",
":",
"typed_conf",
"[",
"s",
"]",
"=",
"{",
"}",
"for",
"option",
"in",
"raw_conf",
"[",
"s",
"]",
":"... | Convert to int, boolean, list, None types config items | [
"Convert",
"to",
"int",
"boolean",
"list",
"None",
"types",
"config",
"items"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/config.py#L578-L607 |
47,602 | insomnia-lab/libreant | utils/es.py | Elasticsearch | def Elasticsearch(*args, **kwargs):
"""Elasticsearch wrapper function
Wrapper function around the official Elasticsearch class that adds
a simple version check upon initialization.
In particular it checks if the major version of the library in use
match the one of the cluster that we are tring to i... | python | def Elasticsearch(*args, **kwargs):
"""Elasticsearch wrapper function
Wrapper function around the official Elasticsearch class that adds
a simple version check upon initialization.
In particular it checks if the major version of the library in use
match the one of the cluster that we are tring to i... | [
"def",
"Elasticsearch",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"check_version",
"=",
"kwargs",
".",
"pop",
"(",
"'check_version'",
",",
"True",
")",
"es",
"=",
"Elasticsearch_official",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if"... | Elasticsearch wrapper function
Wrapper function around the official Elasticsearch class that adds
a simple version check upon initialization.
In particular it checks if the major version of the library in use
match the one of the cluster that we are tring to interact with.
The check can be skipped ... | [
"Elasticsearch",
"wrapper",
"function"
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/utils/es.py#L5-L22 |
47,603 | insomnia-lab/libreant | conf/config_utils.py | from_envvars | def from_envvars(prefix=None, environ=None, envvars=None, as_json=True):
"""Load environment variables in a dictionary
Values are parsed as JSON. If parsing fails with a ValueError,
values are instead used as verbatim strings.
:param prefix: If ``None`` is passed as envvars, all variables from
... | python | def from_envvars(prefix=None, environ=None, envvars=None, as_json=True):
"""Load environment variables in a dictionary
Values are parsed as JSON. If parsing fails with a ValueError,
values are instead used as verbatim strings.
:param prefix: If ``None`` is passed as envvars, all variables from
... | [
"def",
"from_envvars",
"(",
"prefix",
"=",
"None",
",",
"environ",
"=",
"None",
",",
"envvars",
"=",
"None",
",",
"as_json",
"=",
"True",
")",
":",
"conf",
"=",
"{",
"}",
"if",
"environ",
"is",
"None",
":",
"environ",
"=",
"os",
".",
"environ",
"if... | Load environment variables in a dictionary
Values are parsed as JSON. If parsing fails with a ValueError,
values are instead used as verbatim strings.
:param prefix: If ``None`` is passed as envvars, all variables from
``environ`` starting with this prefix are imported. The
... | [
"Load",
"environment",
"variables",
"in",
"a",
"dictionary"
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/conf/config_utils.py#L33-L76 |
47,604 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | calculate_bmi | def calculate_bmi(closed, submitted):
"""
BMI is the ratio of the number of closed items to the number of total items
submitted in a particular period of analysis. The items can be issues, pull
requests and such
:param closed: dataframe returned from get_timeseries() containing closed items
:pa... | python | def calculate_bmi(closed, submitted):
"""
BMI is the ratio of the number of closed items to the number of total items
submitted in a particular period of analysis. The items can be issues, pull
requests and such
:param closed: dataframe returned from get_timeseries() containing closed items
:pa... | [
"def",
"calculate_bmi",
"(",
"closed",
",",
"submitted",
")",
":",
"if",
"sorted",
"(",
"closed",
".",
"keys",
"(",
")",
")",
"!=",
"sorted",
"(",
"submitted",
".",
"keys",
"(",
")",
")",
":",
"raise",
"AttributeError",
"(",
"\"The buckets supplied are not... | BMI is the ratio of the number of closed items to the number of total items
submitted in a particular period of analysis. The items can be issues, pull
requests and such
:param closed: dataframe returned from get_timeseries() containing closed items
:param submitted: dataframe returned from get_timeser... | [
"BMI",
"is",
"the",
"ratio",
"of",
"the",
"number",
"of",
"closed",
"items",
"to",
"the",
"number",
"of",
"total",
"items",
"submitted",
"in",
"a",
"particular",
"period",
"of",
"analysis",
".",
"The",
"items",
"can",
"be",
"issues",
"pull",
"requests",
... | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L617-L645 |
47,605 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.add_query | def add_query(self, key_val={}):
"""
Add an es_dsl query object to the es_dsl Search object
:param key_val: a key-value pair(dict) containing the query to be added to the search object
:returns: self, which allows the method to be chainable with the other methods
"""
q ... | python | def add_query(self, key_val={}):
"""
Add an es_dsl query object to the es_dsl Search object
:param key_val: a key-value pair(dict) containing the query to be added to the search object
:returns: self, which allows the method to be chainable with the other methods
"""
q ... | [
"def",
"add_query",
"(",
"self",
",",
"key_val",
"=",
"{",
"}",
")",
":",
"q",
"=",
"Q",
"(",
"\"match\"",
",",
"*",
"*",
"key_val",
")",
"self",
".",
"search",
"=",
"self",
".",
"search",
".",
"query",
"(",
"q",
")",
"return",
"self"
] | Add an es_dsl query object to the es_dsl Search object
:param key_val: a key-value pair(dict) containing the query to be added to the search object
:returns: self, which allows the method to be chainable with the other methods | [
"Add",
"an",
"es_dsl",
"query",
"object",
"to",
"the",
"es_dsl",
"Search",
"object"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L86-L96 |
47,606 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.add_inverse_query | def add_inverse_query(self, key_val={}):
"""
Add an es_dsl inverse query object to the es_dsl Search object
:param key_val: a key-value pair(dict) containing the query to be added to the search object
:returns: self, which allows the method to be chainable with the other methods
... | python | def add_inverse_query(self, key_val={}):
"""
Add an es_dsl inverse query object to the es_dsl Search object
:param key_val: a key-value pair(dict) containing the query to be added to the search object
:returns: self, which allows the method to be chainable with the other methods
... | [
"def",
"add_inverse_query",
"(",
"self",
",",
"key_val",
"=",
"{",
"}",
")",
":",
"q",
"=",
"Q",
"(",
"\"match\"",
",",
"*",
"*",
"key_val",
")",
"self",
".",
"search",
"=",
"self",
".",
"search",
".",
"query",
"(",
"~",
"q",
")",
"return",
"self... | Add an es_dsl inverse query object to the es_dsl Search object
:param key_val: a key-value pair(dict) containing the query to be added to the search object
:returns: self, which allows the method to be chainable with the other methods | [
"Add",
"an",
"es_dsl",
"inverse",
"query",
"object",
"to",
"the",
"es_dsl",
"Search",
"object"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L98-L108 |
47,607 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.get_sum | def get_sum(self, field=None):
"""
Create a sum aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
if not field:
... | python | def get_sum(self, field=None):
"""
Create a sum aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
if not field:
... | [
"def",
"get_sum",
"(",
"self",
",",
"field",
"=",
"None",
")",
":",
"if",
"not",
"field",
":",
"raise",
"AttributeError",
"(",
"\"Please provide field to apply aggregation to!\"",
")",
"agg",
"=",
"A",
"(",
"\"sum\"",
",",
"field",
"=",
"field",
")",
"self",... | Create a sum aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods | [
"Create",
"a",
"sum",
"aggregation",
"object",
"and",
"add",
"it",
"to",
"the",
"aggregation",
"dict"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L130-L142 |
47,608 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.get_average | def get_average(self, field=None):
"""
Create an avg aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
if not fie... | python | def get_average(self, field=None):
"""
Create an avg aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
if not fie... | [
"def",
"get_average",
"(",
"self",
",",
"field",
"=",
"None",
")",
":",
"if",
"not",
"field",
":",
"raise",
"AttributeError",
"(",
"\"Please provide field to apply aggregation to!\"",
")",
"agg",
"=",
"A",
"(",
"\"avg\"",
",",
"field",
"=",
"field",
")",
"se... | Create an avg aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods | [
"Create",
"an",
"avg",
"aggregation",
"object",
"and",
"add",
"it",
"to",
"the",
"aggregation",
"dict"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L144-L156 |
47,609 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.get_percentiles | def get_percentiles(self, field=None, percents=None):
"""
Create a percentile aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:param percents: the specific percentiles to be calculated
d... | python | def get_percentiles(self, field=None, percents=None):
"""
Create a percentile aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:param percents: the specific percentiles to be calculated
d... | [
"def",
"get_percentiles",
"(",
"self",
",",
"field",
"=",
"None",
",",
"percents",
"=",
"None",
")",
":",
"if",
"not",
"field",
":",
"raise",
"AttributeError",
"(",
"\"Please provide field to apply aggregation to!\"",
")",
"if",
"not",
"percents",
":",
"percents... | Create a percentile aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:param percents: the specific percentiles to be calculated
default: [1.0, 5.0, 25.0, 50.0, 75.0, 95.0, 99.0]
:returns: self, w... | [
"Create",
"a",
"percentile",
"aggregation",
"object",
"and",
"add",
"it",
"to",
"the",
"aggregation",
"dict"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L158-L175 |
47,610 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.get_terms | def get_terms(self, field=None):
"""
Create a terms aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
if not fiel... | python | def get_terms(self, field=None):
"""
Create a terms aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
if not fiel... | [
"def",
"get_terms",
"(",
"self",
",",
"field",
"=",
"None",
")",
":",
"if",
"not",
"field",
":",
"raise",
"AttributeError",
"(",
"\"Please provide field to apply aggregation to!\"",
")",
"agg",
"=",
"A",
"(",
"\"terms\"",
",",
"field",
"=",
"field",
",",
"si... | Create a terms aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods | [
"Create",
"a",
"terms",
"aggregation",
"object",
"and",
"add",
"it",
"to",
"the",
"aggregation",
"dict"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L177-L189 |
47,611 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.get_min | def get_min(self, field=None):
"""
Create a min aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
if not field:
... | python | def get_min(self, field=None):
"""
Create a min aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
if not field:
... | [
"def",
"get_min",
"(",
"self",
",",
"field",
"=",
"None",
")",
":",
"if",
"not",
"field",
":",
"raise",
"AttributeError",
"(",
"\"Please provide field to apply aggregation to!\"",
")",
"agg",
"=",
"A",
"(",
"\"min\"",
",",
"field",
"=",
"field",
")",
"self",... | Create a min aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods | [
"Create",
"a",
"min",
"aggregation",
"object",
"and",
"add",
"it",
"to",
"the",
"aggregation",
"dict"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L191-L203 |
47,612 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.get_max | def get_max(self, field=None):
"""
Create a max aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
if not field:
... | python | def get_max(self, field=None):
"""
Create a max aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
if not field:
... | [
"def",
"get_max",
"(",
"self",
",",
"field",
"=",
"None",
")",
":",
"if",
"not",
"field",
":",
"raise",
"AttributeError",
"(",
"\"Please provide field to apply aggregation to!\"",
")",
"agg",
"=",
"A",
"(",
"\"max\"",
",",
"field",
"=",
"field",
")",
"self",... | Create a max aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods | [
"Create",
"a",
"max",
"aggregation",
"object",
"and",
"add",
"it",
"to",
"the",
"aggregation",
"dict"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L205-L217 |
47,613 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.get_cardinality | def get_cardinality(self, field=None):
"""
Create a cardinality aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
... | python | def get_cardinality(self, field=None):
"""
Create a cardinality aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
... | [
"def",
"get_cardinality",
"(",
"self",
",",
"field",
"=",
"None",
")",
":",
"if",
"not",
"field",
":",
"raise",
"AttributeError",
"(",
"\"Please provide field to apply aggregation to!\"",
")",
"agg",
"=",
"A",
"(",
"\"cardinality\"",
",",
"field",
"=",
"field",
... | Create a cardinality aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods | [
"Create",
"a",
"cardinality",
"aggregation",
"object",
"and",
"add",
"it",
"to",
"the",
"aggregation",
"dict"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L219-L231 |
47,614 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.get_extended_stats | def get_extended_stats(self, field=None):
"""
Create an extended_stats aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
... | python | def get_extended_stats(self, field=None):
"""
Create an extended_stats aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods
"""
... | [
"def",
"get_extended_stats",
"(",
"self",
",",
"field",
"=",
"None",
")",
":",
"if",
"not",
"field",
":",
"raise",
"AttributeError",
"(",
"\"Please provide field to apply aggregation to!\"",
")",
"agg",
"=",
"A",
"(",
"\"extended_stats\"",
",",
"field",
"=",
"fi... | Create an extended_stats aggregation object and add it to the aggregation dict
:param field: the field present in the index that is to be aggregated
:returns: self, which allows the method to be chainable with the other methods | [
"Create",
"an",
"extended_stats",
"aggregation",
"object",
"and",
"add",
"it",
"to",
"the",
"aggregation",
"dict"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L233-L245 |
47,615 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.add_custom_aggregation | def add_custom_aggregation(self, agg, name=None):
"""
Takes in an es_dsl Aggregation object and adds it to the aggregation dict.
Can be used to add custom aggregations such as moving averages
:param agg: aggregation to be added to the es_dsl search object
:param name: name of th... | python | def add_custom_aggregation(self, agg, name=None):
"""
Takes in an es_dsl Aggregation object and adds it to the aggregation dict.
Can be used to add custom aggregations such as moving averages
:param agg: aggregation to be added to the es_dsl search object
:param name: name of th... | [
"def",
"add_custom_aggregation",
"(",
"self",
",",
"agg",
",",
"name",
"=",
"None",
")",
":",
"agg_name",
"=",
"name",
"if",
"name",
"else",
"'custom_agg'",
"self",
".",
"aggregations",
"[",
"agg_name",
"]",
"=",
"agg",
"return",
"self"
] | Takes in an es_dsl Aggregation object and adds it to the aggregation dict.
Can be used to add custom aggregations such as moving averages
:param agg: aggregation to be added to the es_dsl search object
:param name: name of the aggregation object (optional)
:returns: self, which allows t... | [
"Takes",
"in",
"an",
"es_dsl",
"Aggregation",
"object",
"and",
"adds",
"it",
"to",
"the",
"aggregation",
"dict",
".",
"Can",
"be",
"used",
"to",
"add",
"custom",
"aggregations",
"such",
"as",
"moving",
"averages"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L247-L259 |
47,616 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.since | def since(self, start, field=None):
"""
Add the start date to query data starting from that date
sets the default start date for each query
:param start: date to start looking at the fields (from date)
:param field: specific field for the start date in range filter
... | python | def since(self, start, field=None):
"""
Add the start date to query data starting from that date
sets the default start date for each query
:param start: date to start looking at the fields (from date)
:param field: specific field for the start date in range filter
... | [
"def",
"since",
"(",
"self",
",",
"start",
",",
"field",
"=",
"None",
")",
":",
"if",
"not",
"field",
":",
"field",
"=",
"\"grimoire_creation_date\"",
"self",
".",
"start_date",
"=",
"start",
"date_dict",
"=",
"{",
"field",
":",
"{",
"\"gte\"",
":",
"\... | Add the start date to query data starting from that date
sets the default start date for each query
:param start: date to start looking at the fields (from date)
:param field: specific field for the start date in range filter
for the Search object
:returns: self, w... | [
"Add",
"the",
"start",
"date",
"to",
"query",
"data",
"starting",
"from",
"that",
"date",
"sets",
"the",
"default",
"start",
"date",
"for",
"each",
"query"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L261-L278 |
47,617 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.until | def until(self, end, field=None):
"""
Add the end date to query data upto that date
sets the default end date for each query
:param end: date to stop looking at the fields (to date)
:param field: specific field for the end date in range filter
for the Searc... | python | def until(self, end, field=None):
"""
Add the end date to query data upto that date
sets the default end date for each query
:param end: date to stop looking at the fields (to date)
:param field: specific field for the end date in range filter
for the Searc... | [
"def",
"until",
"(",
"self",
",",
"end",
",",
"field",
"=",
"None",
")",
":",
"if",
"not",
"field",
":",
"field",
"=",
"\"grimoire_creation_date\"",
"self",
".",
"end_date",
"=",
"end",
"date_dict",
"=",
"{",
"field",
":",
"{",
"\"lte\"",
":",
"\"{}\""... | Add the end date to query data upto that date
sets the default end date for each query
:param end: date to stop looking at the fields (to date)
:param field: specific field for the end date in range filter
for the Search object
:returns: self, which allows the meth... | [
"Add",
"the",
"end",
"date",
"to",
"query",
"data",
"upto",
"that",
"date",
"sets",
"the",
"default",
"end",
"date",
"for",
"each",
"query"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L280-L297 |
47,618 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.by_organizations | def by_organizations(self, field=None):
"""
Used to seggregate the data acording to organizations. This method
pops the latest aggregation from the self.aggregations dict and
adds it as a nested aggregation under itself
:param field: the field to create the parent agg (optional)... | python | def by_organizations(self, field=None):
"""
Used to seggregate the data acording to organizations. This method
pops the latest aggregation from the self.aggregations dict and
adds it as a nested aggregation under itself
:param field: the field to create the parent agg (optional)... | [
"def",
"by_organizations",
"(",
"self",
",",
"field",
"=",
"None",
")",
":",
"# this functions is currently only for issues and PRs",
"agg_field",
"=",
"field",
"if",
"field",
"else",
"\"author_org_name\"",
"agg_key",
"=",
"\"terms_\"",
"+",
"agg_field",
"if",
"agg_ke... | Used to seggregate the data acording to organizations. This method
pops the latest aggregation from the self.aggregations dict and
adds it as a nested aggregation under itself
:param field: the field to create the parent agg (optional)
default: author_org_name
:ret... | [
"Used",
"to",
"seggregate",
"the",
"data",
"acording",
"to",
"organizations",
".",
"This",
"method",
"pops",
"the",
"latest",
"aggregation",
"from",
"the",
"self",
".",
"aggregations",
"dict",
"and",
"adds",
"it",
"as",
"a",
"nested",
"aggregation",
"under",
... | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L329-L354 |
47,619 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.by_period | def by_period(self, field=None, period=None, timezone=None, start=None, end=None):
"""
Create a date histogram aggregation using the last added aggregation for the
current object. Add this date_histogram aggregation into self.aggregations
:param field: the index field to create the hist... | python | def by_period(self, field=None, period=None, timezone=None, start=None, end=None):
"""
Create a date histogram aggregation using the last added aggregation for the
current object. Add this date_histogram aggregation into self.aggregations
:param field: the index field to create the hist... | [
"def",
"by_period",
"(",
"self",
",",
"field",
"=",
"None",
",",
"period",
"=",
"None",
",",
"timezone",
"=",
"None",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"hist_period",
"=",
"period",
"if",
"period",
"else",
"self",
".",
"... | Create a date histogram aggregation using the last added aggregation for the
current object. Add this date_histogram aggregation into self.aggregations
:param field: the index field to create the histogram from
:param period: the interval which elasticsearch supports, ex: "month", "week" and su... | [
"Create",
"a",
"date",
"histogram",
"aggregation",
"using",
"the",
"last",
"added",
"aggregation",
"for",
"the",
"current",
"object",
".",
"Add",
"this",
"date_histogram",
"aggregation",
"into",
"self",
".",
"aggregations"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L356-L390 |
47,620 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.get_bounds | def get_bounds(self, start=None, end=None):
"""
Get bounds for the date_histogram method
:param start: start date to set the extended_bounds min field
:param end: end date to set the extended_bounds max field
:returns bounds: a dictionary containing the min and max fields
... | python | def get_bounds(self, start=None, end=None):
"""
Get bounds for the date_histogram method
:param start: start date to set the extended_bounds min field
:param end: end date to set the extended_bounds max field
:returns bounds: a dictionary containing the min and max fields
... | [
"def",
"get_bounds",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"bounds",
"=",
"{",
"}",
"if",
"start",
"or",
"end",
":",
"# Extend bounds so we have data until start and end",
"start_ts",
"=",
"None",
"end_ts",
"=",
"None",
... | Get bounds for the date_histogram method
:param start: start date to set the extended_bounds min field
:param end: end date to set the extended_bounds max field
:returns bounds: a dictionary containing the min and max fields
required to set the bounds in date_histogram ... | [
"Get",
"bounds",
"for",
"the",
"date_histogram",
"method"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L392-L424 |
47,621 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.reset_aggregations | def reset_aggregations(self):
"""
Remove all aggregations added to the search object
"""
temp_search = self.search.to_dict()
if 'aggs' in temp_search.keys():
del temp_search['aggs']
self.search.from_dict(temp_search)
self.parent_agg_counter = 0
... | python | def reset_aggregations(self):
"""
Remove all aggregations added to the search object
"""
temp_search = self.search.to_dict()
if 'aggs' in temp_search.keys():
del temp_search['aggs']
self.search.from_dict(temp_search)
self.parent_agg_counter = 0
... | [
"def",
"reset_aggregations",
"(",
"self",
")",
":",
"temp_search",
"=",
"self",
".",
"search",
".",
"to_dict",
"(",
")",
"if",
"'aggs'",
"in",
"temp_search",
".",
"keys",
"(",
")",
":",
"del",
"temp_search",
"[",
"'aggs'",
"]",
"self",
".",
"search",
"... | Remove all aggregations added to the search object | [
"Remove",
"all",
"aggregations",
"added",
"to",
"the",
"search",
"object"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L426-L437 |
47,622 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.fetch_aggregation_results | def fetch_aggregation_results(self):
"""
Loops though the self.aggregations dict and adds them to the Search object
in order in which they were created. Queries elasticsearch and returns a dict
containing the results
:returns: a dictionary containing the response from elasticsea... | python | def fetch_aggregation_results(self):
"""
Loops though the self.aggregations dict and adds them to the Search object
in order in which they were created. Queries elasticsearch and returns a dict
containing the results
:returns: a dictionary containing the response from elasticsea... | [
"def",
"fetch_aggregation_results",
"(",
"self",
")",
":",
"self",
".",
"reset_aggregations",
"(",
")",
"for",
"key",
",",
"val",
"in",
"self",
".",
"aggregations",
".",
"items",
"(",
")",
":",
"self",
".",
"search",
".",
"aggs",
".",
"bucket",
"(",
"s... | Loops though the self.aggregations dict and adds them to the Search object
in order in which they were created. Queries elasticsearch and returns a dict
containing the results
:returns: a dictionary containing the response from elasticsearch | [
"Loops",
"though",
"the",
"self",
".",
"aggregations",
"dict",
"and",
"adds",
"them",
"to",
"the",
"Search",
"object",
"in",
"order",
"in",
"which",
"they",
"were",
"created",
".",
"Queries",
"elasticsearch",
"and",
"returns",
"a",
"dict",
"containing",
"the... | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L446-L464 |
47,623 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.fetch_results_from_source | def fetch_results_from_source(self, *fields, dataframe=False):
"""
Get values for specific fields in the elasticsearch index, from source
:param fields: a list of fields that have to be retrieved from the index
:param dataframe: if true, will return the data in the form of a pandas.Data... | python | def fetch_results_from_source(self, *fields, dataframe=False):
"""
Get values for specific fields in the elasticsearch index, from source
:param fields: a list of fields that have to be retrieved from the index
:param dataframe: if true, will return the data in the form of a pandas.Data... | [
"def",
"fetch_results_from_source",
"(",
"self",
",",
"*",
"fields",
",",
"dataframe",
"=",
"False",
")",
":",
"if",
"not",
"fields",
":",
"raise",
"AttributeError",
"(",
"\"Please provide the fields to get from elasticsearch!\"",
")",
"self",
".",
"reset_aggregations... | Get values for specific fields in the elasticsearch index, from source
:param fields: a list of fields that have to be retrieved from the index
:param dataframe: if true, will return the data in the form of a pandas.DataFrame
:returns: a list of dicts(key_val pairs) containing the values for th... | [
"Get",
"values",
"for",
"specific",
"fields",
"in",
"the",
"elasticsearch",
"index",
"from",
"source"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L466-L491 |
47,624 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.get_timeseries | def get_timeseries(self, child_agg_count=0, dataframe=False):
"""
Get time series data for the specified fields and period of analysis
:param child_agg_count: the child aggregation count to be used
default = 0
:param dataframe: if dataframe=True, return a... | python | def get_timeseries(self, child_agg_count=0, dataframe=False):
"""
Get time series data for the specified fields and period of analysis
:param child_agg_count: the child aggregation count to be used
default = 0
:param dataframe: if dataframe=True, return a... | [
"def",
"get_timeseries",
"(",
"self",
",",
"child_agg_count",
"=",
"0",
",",
"dataframe",
"=",
"False",
")",
":",
"res",
"=",
"self",
".",
"fetch_aggregation_results",
"(",
")",
"ts",
"=",
"{",
"\"date\"",
":",
"[",
"]",
",",
"\"value\"",
":",
"[",
"]"... | Get time series data for the specified fields and period of analysis
:param child_agg_count: the child aggregation count to be used
default = 0
:param dataframe: if dataframe=True, return a pandas.DataFrame object
:returns: dictionary containing "date", "value" a... | [
"Get",
"time",
"series",
"data",
"for",
"the",
"specified",
"fields",
"and",
"period",
"of",
"analysis"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L493-L533 |
47,625 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.get_aggs | def get_aggs(self):
"""
Compute the values for single valued aggregations
:returns: the single aggregation value
"""
res = self.fetch_aggregation_results()
if 'aggregations' in res and 'values' in res['aggregations'][str(self.parent_agg_counter - 1)]:
try:
... | python | def get_aggs(self):
"""
Compute the values for single valued aggregations
:returns: the single aggregation value
"""
res = self.fetch_aggregation_results()
if 'aggregations' in res and 'values' in res['aggregations'][str(self.parent_agg_counter - 1)]:
try:
... | [
"def",
"get_aggs",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"fetch_aggregation_results",
"(",
")",
"if",
"'aggregations'",
"in",
"res",
"and",
"'values'",
"in",
"res",
"[",
"'aggregations'",
"]",
"[",
"str",
"(",
"self",
".",
"parent_agg_counter",
"... | Compute the values for single valued aggregations
:returns: the single aggregation value | [
"Compute",
"the",
"values",
"for",
"single",
"valued",
"aggregations"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L535-L558 |
47,626 | chaoss/grimoirelab-manuscripts | manuscripts2/elasticsearch.py | Query.get_list | def get_list(self, dataframe=False):
"""
Compute the value for multi-valued aggregations
:returns: a dict containing 'keys' and their corresponding 'values'
"""
res = self.fetch_aggregation_results()
keys = []
values = []
for bucket in res['aggregations'... | python | def get_list(self, dataframe=False):
"""
Compute the value for multi-valued aggregations
:returns: a dict containing 'keys' and their corresponding 'values'
"""
res = self.fetch_aggregation_results()
keys = []
values = []
for bucket in res['aggregations'... | [
"def",
"get_list",
"(",
"self",
",",
"dataframe",
"=",
"False",
")",
":",
"res",
"=",
"self",
".",
"fetch_aggregation_results",
"(",
")",
"keys",
"=",
"[",
"]",
"values",
"=",
"[",
"]",
"for",
"bucket",
"in",
"res",
"[",
"'aggregations'",
"]",
"[",
"... | Compute the value for multi-valued aggregations
:returns: a dict containing 'keys' and their corresponding 'values' | [
"Compute",
"the",
"value",
"for",
"multi",
"-",
"valued",
"aggregations"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/elasticsearch.py#L560-L577 |
47,627 | insomnia-lab/libreant | cli/libreant_db.py | upgrade | def upgrade(check_only, yes):
'''
Upgrade libreant database.
This command can be used after an update of libreant
in order to upgrade the database and make it aligned with the new version.
'''
from utils.es import Elasticsearch
from libreantdb import DB, migration
from libreantdb.except... | python | def upgrade(check_only, yes):
'''
Upgrade libreant database.
This command can be used after an update of libreant
in order to upgrade the database and make it aligned with the new version.
'''
from utils.es import Elasticsearch
from libreantdb import DB, migration
from libreantdb.except... | [
"def",
"upgrade",
"(",
"check_only",
",",
"yes",
")",
":",
"from",
"utils",
".",
"es",
"import",
"Elasticsearch",
"from",
"libreantdb",
"import",
"DB",
",",
"migration",
"from",
"libreantdb",
".",
"exceptions",
"import",
"MappingsException",
"try",
":",
"db",
... | Upgrade libreant database.
This command can be used after an update of libreant
in order to upgrade the database and make it aligned with the new version. | [
"Upgrade",
"libreant",
"database",
"."
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/cli/libreant_db.py#L58-L106 |
47,628 | insomnia-lab/libreant | cli/libreant_db.py | insert_volume | def insert_volume(language, filepath, notes, metadata):
'''
Add a new volume to libreant.
The metadata of the volume are taken from a json file whose path must be
passed as argument. Passing "-" as argument will read the file from stdin.
language is an exception, because it must be set using --lang... | python | def insert_volume(language, filepath, notes, metadata):
'''
Add a new volume to libreant.
The metadata of the volume are taken from a json file whose path must be
passed as argument. Passing "-" as argument will read the file from stdin.
language is an exception, because it must be set using --lang... | [
"def",
"insert_volume",
"(",
"language",
",",
"filepath",
",",
"notes",
",",
"metadata",
")",
":",
"meta",
"=",
"{",
"\"_language\"",
":",
"language",
"}",
"if",
"metadata",
":",
"meta",
".",
"update",
"(",
"json",
".",
"load",
"(",
"metadata",
")",
")... | Add a new volume to libreant.
The metadata of the volume are taken from a json file whose path must be
passed as argument. Passing "-" as argument will read the file from stdin.
language is an exception, because it must be set using --language
For every attachment you must add a --file AND a --notes.
... | [
"Add",
"a",
"new",
"volume",
"to",
"libreant",
"."
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/cli/libreant_db.py#L208-L243 |
47,629 | insomnia-lab/libreant | cli/libreant_db.py | attach_list | def attach_list(filepaths, notes):
'''
all the arguments are lists
returns a list of dictionaries; each dictionary "represent" an attachment
'''
assert type(filepaths) in (list, tuple)
assert type(notes) in (list, tuple)
# this if clause means "if those lists are not of the same length"
... | python | def attach_list(filepaths, notes):
'''
all the arguments are lists
returns a list of dictionaries; each dictionary "represent" an attachment
'''
assert type(filepaths) in (list, tuple)
assert type(notes) in (list, tuple)
# this if clause means "if those lists are not of the same length"
... | [
"def",
"attach_list",
"(",
"filepaths",
",",
"notes",
")",
":",
"assert",
"type",
"(",
"filepaths",
")",
"in",
"(",
"list",
",",
"tuple",
")",
"assert",
"type",
"(",
"notes",
")",
"in",
"(",
"list",
",",
"tuple",
")",
"# this if clause means \"if those lis... | all the arguments are lists
returns a list of dictionaries; each dictionary "represent" an attachment | [
"all",
"the",
"arguments",
"are",
"lists",
"returns",
"a",
"list",
"of",
"dictionaries",
";",
"each",
"dictionary",
"represent",
"an",
"attachment"
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/cli/libreant_db.py#L246-L271 |
47,630 | pricingassistant/mongokat | mongokat/collection.py | _param_fields | def _param_fields(kwargs, fields):
"""
Normalize the "fields" argument to most find methods
"""
if fields is None:
return
if type(fields) in [list, set, frozenset, tuple]:
fields = {x: True for x in fields}
if type(fields) == dict:
fields.setdefault("_id", False)
kwargs["projection"] = field... | python | def _param_fields(kwargs, fields):
"""
Normalize the "fields" argument to most find methods
"""
if fields is None:
return
if type(fields) in [list, set, frozenset, tuple]:
fields = {x: True for x in fields}
if type(fields) == dict:
fields.setdefault("_id", False)
kwargs["projection"] = field... | [
"def",
"_param_fields",
"(",
"kwargs",
",",
"fields",
")",
":",
"if",
"fields",
"is",
"None",
":",
"return",
"if",
"type",
"(",
"fields",
")",
"in",
"[",
"list",
",",
"set",
",",
"frozenset",
",",
"tuple",
"]",
":",
"fields",
"=",
"{",
"x",
":",
... | Normalize the "fields" argument to most find methods | [
"Normalize",
"the",
"fields",
"argument",
"to",
"most",
"find",
"methods"
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/collection.py#L11-L21 |
47,631 | pricingassistant/mongokat | mongokat/collection.py | patch_cursor | def patch_cursor(cursor, batch_size=None, limit=None, skip=None, sort=None, **kwargs):
"""
Adds batch_size, limit, sort parameters to a DB cursor
"""
if type(batch_size) == int:
cursor.batch_size(batch_size)
if limit is not None:
cursor.limit(limit)
if sort is not None:
cursor.sort(sort)
... | python | def patch_cursor(cursor, batch_size=None, limit=None, skip=None, sort=None, **kwargs):
"""
Adds batch_size, limit, sort parameters to a DB cursor
"""
if type(batch_size) == int:
cursor.batch_size(batch_size)
if limit is not None:
cursor.limit(limit)
if sort is not None:
cursor.sort(sort)
... | [
"def",
"patch_cursor",
"(",
"cursor",
",",
"batch_size",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"skip",
"=",
"None",
",",
"sort",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"type",
"(",
"batch_size",
")",
"==",
"int",
":",
"cursor"... | Adds batch_size, limit, sort parameters to a DB cursor | [
"Adds",
"batch_size",
"limit",
"sort",
"parameters",
"to",
"a",
"DB",
"cursor"
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/collection.py#L68-L83 |
47,632 | pricingassistant/mongokat | mongokat/collection.py | Collection.exists | def exists(self, query, **args):
"""
Returns True if the search matches at least one document
"""
return bool(self.find(query, **args).limit(1).count()) | python | def exists(self, query, **args):
"""
Returns True if the search matches at least one document
"""
return bool(self.find(query, **args).limit(1).count()) | [
"def",
"exists",
"(",
"self",
",",
"query",
",",
"*",
"*",
"args",
")",
":",
"return",
"bool",
"(",
"self",
".",
"find",
"(",
"query",
",",
"*",
"*",
"args",
")",
".",
"limit",
"(",
"1",
")",
".",
"count",
"(",
")",
")"
] | Returns True if the search matches at least one document | [
"Returns",
"True",
"if",
"the",
"search",
"matches",
"at",
"least",
"one",
"document"
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/collection.py#L127-L131 |
47,633 | pricingassistant/mongokat | mongokat/collection.py | Collection._collection_with_options | def _collection_with_options(self, kwargs):
""" Returns a copy of the pymongo collection with various options set up """
# class DocumentClassWithFields(self.document_class):
# _fetched_fields = kwargs.get("projection")
# mongokat_collection = self
read_preference = kwa... | python | def _collection_with_options(self, kwargs):
""" Returns a copy of the pymongo collection with various options set up """
# class DocumentClassWithFields(self.document_class):
# _fetched_fields = kwargs.get("projection")
# mongokat_collection = self
read_preference = kwa... | [
"def",
"_collection_with_options",
"(",
"self",
",",
"kwargs",
")",
":",
"# class DocumentClassWithFields(self.document_class):",
"# _fetched_fields = kwargs.get(\"projection\")",
"# mongokat_collection = self",
"read_preference",
"=",
"kwargs",
".",
"get",
"(",
"\"read_pre... | Returns a copy of the pymongo collection with various options set up | [
"Returns",
"a",
"copy",
"of",
"the",
"pymongo",
"collection",
"with",
"various",
"options",
"set",
"up"
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/collection.py#L156-L200 |
47,634 | pricingassistant/mongokat | mongokat/collection.py | Collection.find_by_b64id | def find_by_b64id(self, _id, **kwargs):
"""
Pass me a base64-encoded ObjectId
"""
return self.find_one({"_id": ObjectId(base64.b64decode(_id))}, **kwargs) | python | def find_by_b64id(self, _id, **kwargs):
"""
Pass me a base64-encoded ObjectId
"""
return self.find_one({"_id": ObjectId(base64.b64decode(_id))}, **kwargs) | [
"def",
"find_by_b64id",
"(",
"self",
",",
"_id",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"find_one",
"(",
"{",
"\"_id\"",
":",
"ObjectId",
"(",
"base64",
".",
"b64decode",
"(",
"_id",
")",
")",
"}",
",",
"*",
"*",
"kwargs",
")"
] | Pass me a base64-encoded ObjectId | [
"Pass",
"me",
"a",
"base64",
"-",
"encoded",
"ObjectId"
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/collection.py#L243-L248 |
47,635 | pricingassistant/mongokat | mongokat/collection.py | Collection.find_by_b64ids | def find_by_b64ids(self, _ids, **kwargs):
"""
Pass me a list of base64-encoded ObjectId
"""
return self.find_by_ids([ObjectId(base64.b64decode(_id)) for _id in _ids], **kwargs) | python | def find_by_b64ids(self, _ids, **kwargs):
"""
Pass me a list of base64-encoded ObjectId
"""
return self.find_by_ids([ObjectId(base64.b64decode(_id)) for _id in _ids], **kwargs) | [
"def",
"find_by_b64ids",
"(",
"self",
",",
"_ids",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"find_by_ids",
"(",
"[",
"ObjectId",
"(",
"base64",
".",
"b64decode",
"(",
"_id",
")",
")",
"for",
"_id",
"in",
"_ids",
"]",
",",
"*",
"*",... | Pass me a list of base64-encoded ObjectId | [
"Pass",
"me",
"a",
"list",
"of",
"base64",
"-",
"encoded",
"ObjectId"
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/collection.py#L251-L256 |
47,636 | pricingassistant/mongokat | mongokat/collection.py | Collection.iter_column | def iter_column(self, query=None, field="_id", **kwargs):
"""
Return one field as an iterator.
Beware that if your query returns records where the field is not set, it will raise a KeyError.
"""
find_kwargs = {
"projection": {"_id": False}
}
fi... | python | def iter_column(self, query=None, field="_id", **kwargs):
"""
Return one field as an iterator.
Beware that if your query returns records where the field is not set, it will raise a KeyError.
"""
find_kwargs = {
"projection": {"_id": False}
}
fi... | [
"def",
"iter_column",
"(",
"self",
",",
"query",
"=",
"None",
",",
"field",
"=",
"\"_id\"",
",",
"*",
"*",
"kwargs",
")",
":",
"find_kwargs",
"=",
"{",
"\"projection\"",
":",
"{",
"\"_id\"",
":",
"False",
"}",
"}",
"find_kwargs",
"[",
"\"projection\"",
... | Return one field as an iterator.
Beware that if your query returns records where the field is not set, it will raise a KeyError. | [
"Return",
"one",
"field",
"as",
"an",
"iterator",
".",
"Beware",
"that",
"if",
"your",
"query",
"returns",
"records",
"where",
"the",
"field",
"is",
"not",
"set",
"it",
"will",
"raise",
"a",
"KeyError",
"."
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/collection.py#L264-L278 |
47,637 | pricingassistant/mongokat | mongokat/collection.py | Collection.find_random | def find_random(self, **kwargs):
"""
return one random document from the collection
"""
import random
max = self.count(**kwargs)
if max:
num = random.randint(0, max - 1)
return next(self.find(**kwargs).skip(num)) | python | def find_random(self, **kwargs):
"""
return one random document from the collection
"""
import random
max = self.count(**kwargs)
if max:
num = random.randint(0, max - 1)
return next(self.find(**kwargs).skip(num)) | [
"def",
"find_random",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"random",
"max",
"=",
"self",
".",
"count",
"(",
"*",
"*",
"kwargs",
")",
"if",
"max",
":",
"num",
"=",
"random",
".",
"randint",
"(",
"0",
",",
"max",
"-",
"1",
")... | return one random document from the collection | [
"return",
"one",
"random",
"document",
"from",
"the",
"collection"
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/collection.py#L280-L288 |
47,638 | pricingassistant/mongokat | mongokat/collection.py | Collection.insert | def insert(self, data, return_object=False):
""" Inserts the data as a new document. """
obj = self(data) # pylint: disable=E1102
obj.save()
if return_object:
return obj
else:
return obj["_id"] | python | def insert(self, data, return_object=False):
""" Inserts the data as a new document. """
obj = self(data) # pylint: disable=E1102
obj.save()
if return_object:
return obj
else:
return obj["_id"] | [
"def",
"insert",
"(",
"self",
",",
"data",
",",
"return_object",
"=",
"False",
")",
":",
"obj",
"=",
"self",
"(",
"data",
")",
"# pylint: disable=E1102",
"obj",
".",
"save",
"(",
")",
"if",
"return_object",
":",
"return",
"obj",
"else",
":",
"return",
... | Inserts the data as a new document. | [
"Inserts",
"the",
"data",
"as",
"a",
"new",
"document",
"."
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/collection.py#L304-L313 |
47,639 | pricingassistant/mongokat | mongokat/collection.py | Collection.trigger | def trigger(self, event, filter=None, update=None, documents=None, ids=None, replacements=None):
""" Trigger the after_save hook on documents, if present. """
if not self.has_trigger(event):
return
if documents is not None:
pass
elif ids is not None:
... | python | def trigger(self, event, filter=None, update=None, documents=None, ids=None, replacements=None):
""" Trigger the after_save hook on documents, if present. """
if not self.has_trigger(event):
return
if documents is not None:
pass
elif ids is not None:
... | [
"def",
"trigger",
"(",
"self",
",",
"event",
",",
"filter",
"=",
"None",
",",
"update",
"=",
"None",
",",
"documents",
"=",
"None",
",",
"ids",
"=",
"None",
",",
"replacements",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"has_trigger",
"(",
"... | Trigger the after_save hook on documents, if present. | [
"Trigger",
"the",
"after_save",
"hook",
"on",
"documents",
"if",
"present",
"."
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/collection.py#L500-L516 |
47,640 | insomnia-lab/libreant | msgfmt.py | usage | def usage(ecode, msg=''):
"""
Print usage and msg and exit with given code.
"""
print >> sys.stderr, __doc__
if msg:
print >> sys.stderr, msg
sys.exit(ecode) | python | def usage(ecode, msg=''):
"""
Print usage and msg and exit with given code.
"""
print >> sys.stderr, __doc__
if msg:
print >> sys.stderr, msg
sys.exit(ecode) | [
"def",
"usage",
"(",
"ecode",
",",
"msg",
"=",
"''",
")",
":",
"print",
">>",
"sys",
".",
"stderr",
",",
"__doc__",
"if",
"msg",
":",
"print",
">>",
"sys",
".",
"stderr",
",",
"msg",
"sys",
".",
"exit",
"(",
"ecode",
")"
] | Print usage and msg and exit with given code. | [
"Print",
"usage",
"and",
"msg",
"and",
"exit",
"with",
"given",
"code",
"."
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/msgfmt.py#L40-L47 |
47,641 | insomnia-lab/libreant | msgfmt.py | add | def add(msgid, transtr, fuzzy):
"""
Add a non-fuzzy translation to the dictionary.
"""
global MESSAGES
if not fuzzy and transtr and not transtr.startswith('\0'):
MESSAGES[msgid] = transtr | python | def add(msgid, transtr, fuzzy):
"""
Add a non-fuzzy translation to the dictionary.
"""
global MESSAGES
if not fuzzy and transtr and not transtr.startswith('\0'):
MESSAGES[msgid] = transtr | [
"def",
"add",
"(",
"msgid",
",",
"transtr",
",",
"fuzzy",
")",
":",
"global",
"MESSAGES",
"if",
"not",
"fuzzy",
"and",
"transtr",
"and",
"not",
"transtr",
".",
"startswith",
"(",
"'\\0'",
")",
":",
"MESSAGES",
"[",
"msgid",
"]",
"=",
"transtr"
] | Add a non-fuzzy translation to the dictionary. | [
"Add",
"a",
"non",
"-",
"fuzzy",
"translation",
"to",
"the",
"dictionary",
"."
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/msgfmt.py#L50-L56 |
47,642 | insomnia-lab/libreant | msgfmt.py | generate | def generate():
"""
Return the generated output.
"""
global MESSAGES
keys = MESSAGES.keys()
# the keys are sorted in the .mo file
keys.sort()
offsets = []
ids = strs = ''
for _id in keys:
# For each string, we need size and file offset. Each string is NUL
# termi... | python | def generate():
"""
Return the generated output.
"""
global MESSAGES
keys = MESSAGES.keys()
# the keys are sorted in the .mo file
keys.sort()
offsets = []
ids = strs = ''
for _id in keys:
# For each string, we need size and file offset. Each string is NUL
# termi... | [
"def",
"generate",
"(",
")",
":",
"global",
"MESSAGES",
"keys",
"=",
"MESSAGES",
".",
"keys",
"(",
")",
"# the keys are sorted in the .mo file",
"keys",
".",
"sort",
"(",
")",
"offsets",
"=",
"[",
"]",
"ids",
"=",
"strs",
"=",
"''",
"for",
"_id",
"in",
... | Return the generated output. | [
"Return",
"the",
"generated",
"output",
"."
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/msgfmt.py#L59-L100 |
47,643 | insomnia-lab/libreant | setup.py | get_es_requirements | def get_es_requirements(es_version):
'''Get the requirements string for elasticsearch-py library
Returns a suitable requirements string for the elsaticsearch-py library
according to the elasticsearch version to be supported (es_version)'''
# accepts version range in the form `2.x`
es_version = es_... | python | def get_es_requirements(es_version):
'''Get the requirements string for elasticsearch-py library
Returns a suitable requirements string for the elsaticsearch-py library
according to the elasticsearch version to be supported (es_version)'''
# accepts version range in the form `2.x`
es_version = es_... | [
"def",
"get_es_requirements",
"(",
"es_version",
")",
":",
"# accepts version range in the form `2.x`",
"es_version",
"=",
"es_version",
".",
"replace",
"(",
"'x'",
",",
"'0'",
")",
"es_version",
"=",
"map",
"(",
"int",
",",
"es_version",
".",
"split",
"(",
"'.'... | Get the requirements string for elasticsearch-py library
Returns a suitable requirements string for the elsaticsearch-py library
according to the elasticsearch version to be supported (es_version) | [
"Get",
"the",
"requirements",
"string",
"for",
"elasticsearch",
"-",
"py",
"library"
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/setup.py#L88-L106 |
47,644 | insomnia-lab/libreant | setup.py | compile_translations.run | def run(self):
"""
Compile all message catalogs .po files into .mo files.
Skips not changed file based on source mtime.
"""
# thanks to deluge guys ;)
po_dir = os.path.join(os.path.dirname(__file__), 'webant', 'translations')
print('Compiling po files from "... | python | def run(self):
"""
Compile all message catalogs .po files into .mo files.
Skips not changed file based on source mtime.
"""
# thanks to deluge guys ;)
po_dir = os.path.join(os.path.dirname(__file__), 'webant', 'translations')
print('Compiling po files from "... | [
"def",
"run",
"(",
"self",
")",
":",
"# thanks to deluge guys ;)",
"po_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'webant'",
",",
"'translations'",
")",
"print",
"(",
"'Compiling po files ... | Compile all message catalogs .po files into .mo files.
Skips not changed file based on source mtime. | [
"Compile",
"all",
"message",
"catalogs",
".",
"po",
"files",
"into",
".",
"mo",
"files",
".",
"Skips",
"not",
"changed",
"file",
"based",
"on",
"source",
"mtime",
"."
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/setup.py#L24-L52 |
47,645 | argaen/python-google-distance-matrix | google_distance_matrix/core.py | DM.__get_response_element_data | def __get_response_element_data(self, key1, key2):
"""
For each origin an elements object is created in the ouput.
For each destination, an object is created inside elements object. For example, if there are
2 origins and 1 destination, 2 element objects with 1 object each are created. I... | python | def __get_response_element_data(self, key1, key2):
"""
For each origin an elements object is created in the ouput.
For each destination, an object is created inside elements object. For example, if there are
2 origins and 1 destination, 2 element objects with 1 object each are created. I... | [
"def",
"__get_response_element_data",
"(",
"self",
",",
"key1",
",",
"key2",
")",
":",
"if",
"not",
"self",
".",
"dict_response",
"[",
"key1",
"]",
"[",
"key2",
"]",
":",
"l",
"=",
"self",
".",
"response",
"for",
"i",
",",
"orig",
"in",
"enumerate",
... | For each origin an elements object is created in the ouput.
For each destination, an object is created inside elements object. For example, if there are
2 origins and 1 destination, 2 element objects with 1 object each are created. If there are
2 origins and 2 destinations, 2 element objects wit... | [
"For",
"each",
"origin",
"an",
"elements",
"object",
"is",
"created",
"in",
"the",
"ouput",
".",
"For",
"each",
"destination",
"an",
"object",
"is",
"created",
"inside",
"elements",
"object",
".",
"For",
"example",
"if",
"there",
"are",
"2",
"origins",
"an... | 20c07bf7d560180ef380b3148616f67f55246a5c | https://github.com/argaen/python-google-distance-matrix/blob/20c07bf7d560180ef380b3148616f67f55246a5c/google_distance_matrix/core.py#L69-L86 |
47,646 | argaen/python-google-distance-matrix | google_distance_matrix/core.py | DM.get_closest_points | def get_closest_points(self, max_distance=None, origin_index=0, origin_raw=None):
"""
Get closest points to a given origin. Returns a list of 2 element tuples where first element is the destination and the second is the distance.
"""
if not self.dict_response['distance']['value']:
... | python | def get_closest_points(self, max_distance=None, origin_index=0, origin_raw=None):
"""
Get closest points to a given origin. Returns a list of 2 element tuples where first element is the destination and the second is the distance.
"""
if not self.dict_response['distance']['value']:
... | [
"def",
"get_closest_points",
"(",
"self",
",",
"max_distance",
"=",
"None",
",",
"origin_index",
"=",
"0",
",",
"origin_raw",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"dict_response",
"[",
"'distance'",
"]",
"[",
"'value'",
"]",
":",
"self",
".",... | Get closest points to a given origin. Returns a list of 2 element tuples where first element is the destination and the second is the distance. | [
"Get",
"closest",
"points",
"to",
"a",
"given",
"origin",
".",
"Returns",
"a",
"list",
"of",
"2",
"element",
"tuples",
"where",
"first",
"element",
"is",
"the",
"destination",
"and",
"the",
"second",
"is",
"the",
"distance",
"."
] | 20c07bf7d560180ef380b3148616f67f55246a5c | https://github.com/argaen/python-google-distance-matrix/blob/20c07bf7d560180ef380b3148616f67f55246a5c/google_distance_matrix/core.py#L112-L130 |
47,647 | snowblink14/smatch | amr.py | AMR.rename_node | def rename_node(self, prefix):
"""
Rename AMR graph nodes to prefix + node_index to avoid nodes with the same name in two different AMRs.
"""
node_map_dict = {}
# map each node to its new name (e.g. "a1")
for i in range(0, len(self.nodes)):
node_map_dict[self... | python | def rename_node(self, prefix):
"""
Rename AMR graph nodes to prefix + node_index to avoid nodes with the same name in two different AMRs.
"""
node_map_dict = {}
# map each node to its new name (e.g. "a1")
for i in range(0, len(self.nodes)):
node_map_dict[self... | [
"def",
"rename_node",
"(",
"self",
",",
"prefix",
")",
":",
"node_map_dict",
"=",
"{",
"}",
"# map each node to its new name (e.g. \"a1\")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"self",
".",
"nodes",
")",
")",
":",
"node_map_dict",
"[",
"s... | Rename AMR graph nodes to prefix + node_index to avoid nodes with the same name in two different AMRs. | [
"Rename",
"AMR",
"graph",
"nodes",
"to",
"prefix",
"+",
"node_index",
"to",
"avoid",
"nodes",
"with",
"the",
"same",
"name",
"in",
"two",
"different",
"AMRs",
"."
] | ad7e6553a3d52e469b2eef69d7716c87a67eedac | https://github.com/snowblink14/smatch/blob/ad7e6553a3d52e469b2eef69d7716c87a67eedac/amr.py#L71-L86 |
47,648 | chaoss/grimoirelab-manuscripts | manuscripts/report.py | Report.bar3_chart | def bar3_chart(self, title, labels, data1, file_name, data2, data3, legend=["", ""]):
"""
Generate a bar plot with three columns in each x position and save it to file_name
:param title: title to be used in the chart
:param labels: list of labels for the x axis
:param data1: val... | python | def bar3_chart(self, title, labels, data1, file_name, data2, data3, legend=["", ""]):
"""
Generate a bar plot with three columns in each x position and save it to file_name
:param title: title to be used in the chart
:param labels: list of labels for the x axis
:param data1: val... | [
"def",
"bar3_chart",
"(",
"self",
",",
"title",
",",
"labels",
",",
"data1",
",",
"file_name",
",",
"data2",
",",
"data3",
",",
"legend",
"=",
"[",
"\"\"",
",",
"\"\"",
"]",
")",
":",
"colors",
"=",
"[",
"\"orange\"",
",",
"\"grey\"",
"]",
"data1",
... | Generate a bar plot with three columns in each x position and save it to file_name
:param title: title to be used in the chart
:param labels: list of labels for the x axis
:param data1: values for the first columns
:param file_name: name of the file in which to save the chart
:p... | [
"Generate",
"a",
"bar",
"plot",
"with",
"three",
"columns",
"in",
"each",
"x",
"position",
"and",
"save",
"it",
"to",
"file_name"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/report.py#L251-L286 |
47,649 | chaoss/grimoirelab-manuscripts | manuscripts/report.py | Report.sections | def sections(self):
"""
Get the sections of the report and howto build them.
:return: a dict with the method to be called to fill each section of the report
"""
secs = OrderedDict()
secs['Overview'] = self.sec_overview
secs['Communication Channels'] = self.sec_co... | python | def sections(self):
"""
Get the sections of the report and howto build them.
:return: a dict with the method to be called to fill each section of the report
"""
secs = OrderedDict()
secs['Overview'] = self.sec_overview
secs['Communication Channels'] = self.sec_co... | [
"def",
"sections",
"(",
"self",
")",
":",
"secs",
"=",
"OrderedDict",
"(",
")",
"secs",
"[",
"'Overview'",
"]",
"=",
"self",
".",
"sec_overview",
"secs",
"[",
"'Communication Channels'",
"]",
"=",
"self",
".",
"sec_com_channels",
"secs",
"[",
"'Detailed Acti... | Get the sections of the report and howto build them.
:return: a dict with the method to be called to fill each section of the report | [
"Get",
"the",
"sections",
"of",
"the",
"report",
"and",
"howto",
"build",
"them",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/report.py#L740-L751 |
47,650 | chaoss/grimoirelab-manuscripts | manuscripts/report.py | Report.replace_text | def replace_text(filepath, to_replace, replacement):
"""
Replaces a string in a given file with another string
:param file: the file in which the string has to be replaced
:param to_replace: the string to be replaced in the file
:param replacement: the string which replaces 'to_... | python | def replace_text(filepath, to_replace, replacement):
"""
Replaces a string in a given file with another string
:param file: the file in which the string has to be replaced
:param to_replace: the string to be replaced in the file
:param replacement: the string which replaces 'to_... | [
"def",
"replace_text",
"(",
"filepath",
",",
"to_replace",
",",
"replacement",
")",
":",
"with",
"open",
"(",
"filepath",
")",
"as",
"file",
":",
"s",
"=",
"file",
".",
"read",
"(",
")",
"s",
"=",
"s",
".",
"replace",
"(",
"to_replace",
",",
"replace... | Replaces a string in a given file with another string
:param file: the file in which the string has to be replaced
:param to_replace: the string to be replaced in the file
:param replacement: the string which replaces 'to_replace' in the file | [
"Replaces",
"a",
"string",
"in",
"a",
"given",
"file",
"with",
"another",
"string"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/report.py#L812-L824 |
47,651 | chaoss/grimoirelab-manuscripts | manuscripts/report.py | Report.replace_text_dir | def replace_text_dir(self, directory, to_replace, replacement, file_type=None):
"""
Replaces a string with its replacement in all the files in the directory
:param directory: the directory in which the files have to be modified
:param to_replace: the string to be replaced in the files
... | python | def replace_text_dir(self, directory, to_replace, replacement, file_type=None):
"""
Replaces a string with its replacement in all the files in the directory
:param directory: the directory in which the files have to be modified
:param to_replace: the string to be replaced in the files
... | [
"def",
"replace_text_dir",
"(",
"self",
",",
"directory",
",",
"to_replace",
",",
"replacement",
",",
"file_type",
"=",
"None",
")",
":",
"if",
"not",
"file_type",
":",
"file_type",
"=",
"\"*.tex\"",
"for",
"file",
"in",
"glob",
".",
"iglob",
"(",
"os",
... | Replaces a string with its replacement in all the files in the directory
:param directory: the directory in which the files have to be modified
:param to_replace: the string to be replaced in the files
:param replacement: the string which replaces 'to_replace' in the files
:param file_t... | [
"Replaces",
"a",
"string",
"with",
"its",
"replacement",
"in",
"all",
"the",
"files",
"in",
"the",
"directory"
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/report.py#L826-L838 |
47,652 | snowblink14/smatch | smatch-table.py | pprint_table | def pprint_table(table):
"""
Print a table in pretty format
"""
col_paddings = []
for i in range(len(table[0])):
col_paddings.append(get_max_width(table,i))
for row in table:
print(row[0].ljust(col_paddings[0] + 1), end="")
for i in range(1, len(row)):
col = ... | python | def pprint_table(table):
"""
Print a table in pretty format
"""
col_paddings = []
for i in range(len(table[0])):
col_paddings.append(get_max_width(table,i))
for row in table:
print(row[0].ljust(col_paddings[0] + 1), end="")
for i in range(1, len(row)):
col = ... | [
"def",
"pprint_table",
"(",
"table",
")",
":",
"col_paddings",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"table",
"[",
"0",
"]",
")",
")",
":",
"col_paddings",
".",
"append",
"(",
"get_max_width",
"(",
"table",
",",
"i",
")",
")",
... | Print a table in pretty format | [
"Print",
"a",
"table",
"in",
"pretty",
"format"
] | ad7e6553a3d52e469b2eef69d7716c87a67eedac | https://github.com/snowblink14/smatch/blob/ad7e6553a3d52e469b2eef69d7716c87a67eedac/smatch-table.py#L136-L149 |
47,653 | snowblink14/smatch | smatch-table.py | cb | def cb(option, value, parser):
"""
Callback function to handle variable number of arguments in optparse
"""
arguments = [value]
for arg in parser.rargs:
if arg[0] != "-":
arguments.append(arg)
else:
del parser.rargs[:len(arguments)]
break
if g... | python | def cb(option, value, parser):
"""
Callback function to handle variable number of arguments in optparse
"""
arguments = [value]
for arg in parser.rargs:
if arg[0] != "-":
arguments.append(arg)
else:
del parser.rargs[:len(arguments)]
break
if g... | [
"def",
"cb",
"(",
"option",
",",
"value",
",",
"parser",
")",
":",
"arguments",
"=",
"[",
"value",
"]",
"for",
"arg",
"in",
"parser",
".",
"rargs",
":",
"if",
"arg",
"[",
"0",
"]",
"!=",
"\"-\"",
":",
"arguments",
".",
"append",
"(",
"arg",
")",
... | Callback function to handle variable number of arguments in optparse | [
"Callback",
"function",
"to",
"handle",
"variable",
"number",
"of",
"arguments",
"in",
"optparse"
] | ad7e6553a3d52e469b2eef69d7716c87a67eedac | https://github.com/snowblink14/smatch/blob/ad7e6553a3d52e469b2eef69d7716c87a67eedac/smatch-table.py#L184-L198 |
47,654 | snowblink14/smatch | smatch-table.py | check_args | def check_args(args):
"""
Parse arguments and check if the arguments are valid
"""
if not os.path.exists(args.fd):
print("Not a valid path", args.fd, file=ERROR_LOG)
return [], [], False
if args.fl is not None:
# we already ensure the file can be opened and opened the file
... | python | def check_args(args):
"""
Parse arguments and check if the arguments are valid
"""
if not os.path.exists(args.fd):
print("Not a valid path", args.fd, file=ERROR_LOG)
return [], [], False
if args.fl is not None:
# we already ensure the file can be opened and opened the file
... | [
"def",
"check_args",
"(",
"args",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"args",
".",
"fd",
")",
":",
"print",
"(",
"\"Not a valid path\"",
",",
"args",
".",
"fd",
",",
"file",
"=",
"ERROR_LOG",
")",
"return",
"[",
"]",
",",
... | Parse arguments and check if the arguments are valid | [
"Parse",
"arguments",
"and",
"check",
"if",
"the",
"arguments",
"are",
"valid"
] | ad7e6553a3d52e469b2eef69d7716c87a67eedac | https://github.com/snowblink14/smatch/blob/ad7e6553a3d52e469b2eef69d7716c87a67eedac/smatch-table.py#L201-L258 |
47,655 | chaoss/grimoirelab-manuscripts | manuscripts2/report.py | create_csv | def create_csv(filename, csv_data, mode="w"):
"""
Create a CSV file with the given data and store it in the
file with the given name.
:param filename: name of the file to store the data in
:pram csv_data: the data to be stored in the file
:param mode: the mode in which we have to open the file.... | python | def create_csv(filename, csv_data, mode="w"):
"""
Create a CSV file with the given data and store it in the
file with the given name.
:param filename: name of the file to store the data in
:pram csv_data: the data to be stored in the file
:param mode: the mode in which we have to open the file.... | [
"def",
"create_csv",
"(",
"filename",
",",
"csv_data",
",",
"mode",
"=",
"\"w\"",
")",
":",
"with",
"open",
"(",
"filename",
",",
"mode",
")",
"as",
"f",
":",
"csv_data",
".",
"replace",
"(",
"\"_\"",
",",
"r\"\\_\"",
")",
"f",
".",
"write",
"(",
"... | Create a CSV file with the given data and store it in the
file with the given name.
:param filename: name of the file to store the data in
:pram csv_data: the data to be stored in the file
:param mode: the mode in which we have to open the file. It can
be 'w', 'a', etc. Default is 'w' | [
"Create",
"a",
"CSV",
"file",
"with",
"the",
"given",
"data",
"and",
"store",
"it",
"in",
"the",
"file",
"with",
"the",
"given",
"name",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/report.py#L58-L71 |
47,656 | chaoss/grimoirelab-manuscripts | manuscripts2/report.py | Report.get_metric_index | def get_metric_index(self, data_source):
"""
This function will return the elasticsearch index for a corresponding
data source. It chooses in between the default and the user inputed
es indices and returns the user inputed one if it is available.
:param data_source: the data sou... | python | def get_metric_index(self, data_source):
"""
This function will return the elasticsearch index for a corresponding
data source. It chooses in between the default and the user inputed
es indices and returns the user inputed one if it is available.
:param data_source: the data sou... | [
"def",
"get_metric_index",
"(",
"self",
",",
"data_source",
")",
":",
"if",
"data_source",
"in",
"self",
".",
"index_dict",
":",
"index",
"=",
"self",
".",
"index_dict",
"[",
"data_source",
"]",
"else",
":",
"index",
"=",
"self",
".",
"class2index",
"[",
... | This function will return the elasticsearch index for a corresponding
data source. It chooses in between the default and the user inputed
es indices and returns the user inputed one if it is available.
:param data_source: the data source for which the index has to be returned
:returns: ... | [
"This",
"function",
"will",
"return",
"the",
"elasticsearch",
"index",
"for",
"a",
"corresponding",
"data",
"source",
".",
"It",
"chooses",
"in",
"between",
"the",
"default",
"and",
"the",
"user",
"inputed",
"es",
"indices",
"and",
"returns",
"the",
"user",
... | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/report.py#L134-L148 |
47,657 | chaoss/grimoirelab-manuscripts | manuscripts2/report.py | Report.get_sec_overview | def get_sec_overview(self):
"""
Generate the "overview" section of the report.
"""
logger.debug("Calculating Overview metrics.")
data_path = os.path.join(self.data_dir, "overview")
if not os.path.exists(data_path):
os.makedirs(data_path)
overview_co... | python | def get_sec_overview(self):
"""
Generate the "overview" section of the report.
"""
logger.debug("Calculating Overview metrics.")
data_path = os.path.join(self.data_dir, "overview")
if not os.path.exists(data_path):
os.makedirs(data_path)
overview_co... | [
"def",
"get_sec_overview",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Calculating Overview metrics.\"",
")",
"data_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"data_dir",
",",
"\"overview\"",
")",
"if",
"not",
"os",
".",
"path... | Generate the "overview" section of the report. | [
"Generate",
"the",
"overview",
"section",
"of",
"the",
"report",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/report.py#L150-L239 |
47,658 | chaoss/grimoirelab-manuscripts | manuscripts2/report.py | Report.get_sec_project_activity | def get_sec_project_activity(self):
"""
Generate the "project activity" section of the report.
"""
logger.debug("Calculating Project Activity metrics.")
data_path = os.path.join(self.data_dir, "activity")
if not os.path.exists(data_path):
os.makedirs(data_pa... | python | def get_sec_project_activity(self):
"""
Generate the "project activity" section of the report.
"""
logger.debug("Calculating Project Activity metrics.")
data_path = os.path.join(self.data_dir, "activity")
if not os.path.exists(data_path):
os.makedirs(data_pa... | [
"def",
"get_sec_project_activity",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Calculating Project Activity metrics.\"",
")",
"data_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"data_dir",
",",
"\"activity\"",
")",
"if",
"not",
"os"... | Generate the "project activity" section of the report. | [
"Generate",
"the",
"project",
"activity",
"section",
"of",
"the",
"report",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/report.py#L241-L271 |
47,659 | chaoss/grimoirelab-manuscripts | manuscripts2/report.py | Report.get_sec_project_community | def get_sec_project_community(self):
"""
Generate the "project community" section of the report.
"""
logger.debug("Calculating Project Community metrics.")
data_path = os.path.join(self.data_dir, "community")
if not os.path.exists(data_path):
os.makedirs(dat... | python | def get_sec_project_community(self):
"""
Generate the "project community" section of the report.
"""
logger.debug("Calculating Project Community metrics.")
data_path = os.path.join(self.data_dir, "community")
if not os.path.exists(data_path):
os.makedirs(dat... | [
"def",
"get_sec_project_community",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Calculating Project Community metrics.\"",
")",
"data_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"data_dir",
",",
"\"community\"",
")",
"if",
"not",
"... | Generate the "project community" section of the report. | [
"Generate",
"the",
"project",
"community",
"section",
"of",
"the",
"report",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/report.py#L273-L324 |
47,660 | chaoss/grimoirelab-manuscripts | manuscripts2/report.py | Report.create_csv_fig_from_df | def create_csv_fig_from_df(self, data_frames=[], filename=None, headers=[], index_label=None,
fig_type=None, title=None, xlabel=None, ylabel=None, xfont=10,
yfont=10, titlefont=15, fig_size=(8, 10), image_type="eps"):
"""
Joins all the datafa... | python | def create_csv_fig_from_df(self, data_frames=[], filename=None, headers=[], index_label=None,
fig_type=None, title=None, xlabel=None, ylabel=None, xfont=10,
yfont=10, titlefont=15, fig_size=(8, 10), image_type="eps"):
"""
Joins all the datafa... | [
"def",
"create_csv_fig_from_df",
"(",
"self",
",",
"data_frames",
"=",
"[",
"]",
",",
"filename",
"=",
"None",
",",
"headers",
"=",
"[",
"]",
",",
"index_label",
"=",
"None",
",",
"fig_type",
"=",
"None",
",",
"title",
"=",
"None",
",",
"xlabel",
"=",
... | Joins all the datafarames horizontally and creates a CSV and an image file from
those dataframes.
:param data_frames: a list of dataframes containing timeseries data from various metrics
:param filename: the name of the csv and image file
:param headers: a list of headers to be applied ... | [
"Joins",
"all",
"the",
"datafarames",
"horizontally",
"and",
"creates",
"a",
"CSV",
"and",
"an",
"image",
"file",
"from",
"those",
"dataframes",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/report.py#L422-L494 |
47,661 | insomnia-lab/libreant | users/__init__.py | create_tables | def create_tables(database):
'''Create all tables in the given database'''
logging.getLogger(__name__).debug("Creating missing database tables")
database.connect()
database.create_tables([User,
Group,
UserToGroup,
GroupT... | python | def create_tables(database):
'''Create all tables in the given database'''
logging.getLogger(__name__).debug("Creating missing database tables")
database.connect()
database.create_tables([User,
Group,
UserToGroup,
GroupT... | [
"def",
"create_tables",
"(",
"database",
")",
":",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
".",
"debug",
"(",
"\"Creating missing database tables\"",
")",
"database",
".",
"connect",
"(",
")",
"database",
".",
"create_tables",
"(",
"[",
"User",
",",... | Create all tables in the given database | [
"Create",
"all",
"tables",
"in",
"the",
"given",
"database"
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/users/__init__.py#L72-L80 |
47,662 | insomnia-lab/libreant | users/__init__.py | populate_with_defaults | def populate_with_defaults():
'''Create user admin and grant him all permission
If the admin user already exists the function will simply return
'''
logging.getLogger(__name__).debug("Populating with default users")
if not User.select().where(User.name == 'admin').exists():
admin = User.cre... | python | def populate_with_defaults():
'''Create user admin and grant him all permission
If the admin user already exists the function will simply return
'''
logging.getLogger(__name__).debug("Populating with default users")
if not User.select().where(User.name == 'admin').exists():
admin = User.cre... | [
"def",
"populate_with_defaults",
"(",
")",
":",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
".",
"debug",
"(",
"\"Populating with default users\"",
")",
"if",
"not",
"User",
".",
"select",
"(",
")",
".",
"where",
"(",
"User",
".",
"name",
"==",
"'ad... | Create user admin and grant him all permission
If the admin user already exists the function will simply return | [
"Create",
"user",
"admin",
"and",
"grant",
"him",
"all",
"permission"
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/users/__init__.py#L83-L107 |
47,663 | insomnia-lab/libreant | users/__init__.py | init_db | def init_db(dbURL, pwd_salt_size=None, pwd_rounds=None):
'''Initialize users database
initialize database and create necessary tables
to handle users oprations.
:param dbURL: database url, as described in :func:`init_proxy`
'''
if not dbURL:
dbURL = 'sqlite:///:memory:'
logging.get... | python | def init_db(dbURL, pwd_salt_size=None, pwd_rounds=None):
'''Initialize users database
initialize database and create necessary tables
to handle users oprations.
:param dbURL: database url, as described in :func:`init_proxy`
'''
if not dbURL:
dbURL = 'sqlite:///:memory:'
logging.get... | [
"def",
"init_db",
"(",
"dbURL",
",",
"pwd_salt_size",
"=",
"None",
",",
"pwd_rounds",
"=",
"None",
")",
":",
"if",
"not",
"dbURL",
":",
"dbURL",
"=",
"'sqlite:///:memory:'",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
".",
"debug",
"(",
"\"Initializ... | Initialize users database
initialize database and create necessary tables
to handle users oprations.
:param dbURL: database url, as described in :func:`init_proxy` | [
"Initialize",
"users",
"database"
] | 55d529435baf4c05a86b8341899e9f5e14e50245 | https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/users/__init__.py#L110-L131 |
47,664 | collective/robotsuite | src/robotsuite/__init__.py | normalize | def normalize(s, replace_spaces=True):
"""Normalize non-ascii characters to their closest ascii counterparts
"""
whitelist = (' -' + string.ascii_letters + string.digits)
if type(s) == six.binary_type:
s = six.text_type(s, 'utf-8', 'ignore')
table = {}
for ch in [ch for ch in s if ch n... | python | def normalize(s, replace_spaces=True):
"""Normalize non-ascii characters to their closest ascii counterparts
"""
whitelist = (' -' + string.ascii_letters + string.digits)
if type(s) == six.binary_type:
s = six.text_type(s, 'utf-8', 'ignore')
table = {}
for ch in [ch for ch in s if ch n... | [
"def",
"normalize",
"(",
"s",
",",
"replace_spaces",
"=",
"True",
")",
":",
"whitelist",
"=",
"(",
"' -'",
"+",
"string",
".",
"ascii_letters",
"+",
"string",
".",
"digits",
")",
"if",
"type",
"(",
"s",
")",
"==",
"six",
".",
"binary_type",
":",
"s",... | Normalize non-ascii characters to their closest ascii counterparts | [
"Normalize",
"non",
"-",
"ascii",
"characters",
"to",
"their",
"closest",
"ascii",
"counterparts"
] | 58cdd13e12043ba51ab6073a568eddaa668bc49d | https://github.com/collective/robotsuite/blob/58cdd13e12043ba51ab6073a568eddaa668bc49d/src/robotsuite/__init__.py#L54-L77 |
47,665 | collective/robotsuite | src/robotsuite/__init__.py | get_robot_variables | def get_robot_variables():
"""Return list of Robot Framework -compatible cli-variables parsed
from ROBOT_-prefixed environment variable
"""
prefix = 'ROBOT_'
variables = []
def safe_str(s):
if isinstance(s, six.text_type):
return s
else:
return six.text_... | python | def get_robot_variables():
"""Return list of Robot Framework -compatible cli-variables parsed
from ROBOT_-prefixed environment variable
"""
prefix = 'ROBOT_'
variables = []
def safe_str(s):
if isinstance(s, six.text_type):
return s
else:
return six.text_... | [
"def",
"get_robot_variables",
"(",
")",
":",
"prefix",
"=",
"'ROBOT_'",
"variables",
"=",
"[",
"]",
"def",
"safe_str",
"(",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"six",
".",
"text_type",
")",
":",
"return",
"s",
"else",
":",
"return",
"si... | Return list of Robot Framework -compatible cli-variables parsed
from ROBOT_-prefixed environment variable | [
"Return",
"list",
"of",
"Robot",
"Framework",
"-",
"compatible",
"cli",
"-",
"variables",
"parsed",
"from",
"ROBOT_",
"-",
"prefixed",
"environment",
"variable"
] | 58cdd13e12043ba51ab6073a568eddaa668bc49d | https://github.com/collective/robotsuite/blob/58cdd13e12043ba51ab6073a568eddaa668bc49d/src/robotsuite/__init__.py#L80-L98 |
47,666 | stevemarple/python-MCP342x | MCP342x/__init__.py | MCP342x.convert | def convert(self):
"""Initiate one-shot conversion.
The current settings are used, with the exception of continuous mode."""
c = self.config
c &= (~MCP342x._continuous_mode_mask & 0x7f) # Force one-shot
c |= MCP342x._not_ready_mask # Convert
logger.debu... | python | def convert(self):
"""Initiate one-shot conversion.
The current settings are used, with the exception of continuous mode."""
c = self.config
c &= (~MCP342x._continuous_mode_mask & 0x7f) # Force one-shot
c |= MCP342x._not_ready_mask # Convert
logger.debu... | [
"def",
"convert",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"config",
"c",
"&=",
"(",
"~",
"MCP342x",
".",
"_continuous_mode_mask",
"&",
"0x7f",
")",
"# Force one-shot",
"c",
"|=",
"MCP342x",
".",
"_not_ready_mask",
"# Convert",
"logger",
".",
"debug",... | Initiate one-shot conversion.
The current settings are used, with the exception of continuous mode. | [
"Initiate",
"one",
"-",
"shot",
"conversion",
"."
] | d532e1079c221fc29098d229ddba460cc0ce22a7 | https://github.com/stevemarple/python-MCP342x/blob/d532e1079c221fc29098d229ddba460cc0ce22a7/MCP342x/__init__.py#L296-L304 |
47,667 | chaoss/grimoirelab-manuscripts | manuscripts/esquery.py | ElasticQuery.__get_query_range | def __get_query_range(cls, date_field, start=None, end=None):
"""
Create a filter dict with date_field from start to end dates.
:param date_field: field with the date value
:param start: date with the from value. Should be a datetime.datetime object
of the form: da... | python | def __get_query_range(cls, date_field, start=None, end=None):
"""
Create a filter dict with date_field from start to end dates.
:param date_field: field with the date value
:param start: date with the from value. Should be a datetime.datetime object
of the form: da... | [
"def",
"__get_query_range",
"(",
"cls",
",",
"date_field",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"if",
"not",
"start",
"and",
"not",
"end",
":",
"return",
"''",
"start_end",
"=",
"{",
"}",
"if",
"start",
":",
"start_end",
"[",... | Create a filter dict with date_field from start to end dates.
:param date_field: field with the date value
:param start: date with the from value. Should be a datetime.datetime object
of the form: datetime.datetime(2018, 5, 25, 15, 17, 39)
:param end: date with the to valu... | [
"Create",
"a",
"filter",
"dict",
"with",
"date_field",
"from",
"start",
"to",
"end",
"dates",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/esquery.py#L71-L93 |
47,668 | chaoss/grimoirelab-manuscripts | manuscripts/esquery.py | ElasticQuery.__get_query_basic | def __get_query_basic(cls, date_field=None, start=None, end=None,
filters={}):
"""
Create a es_dsl query object with the date range and filters.
:param date_field: field with the date value
:param start: date with the from value, should be a datetime.datetime o... | python | def __get_query_basic(cls, date_field=None, start=None, end=None,
filters={}):
"""
Create a es_dsl query object with the date range and filters.
:param date_field: field with the date value
:param start: date with the from value, should be a datetime.datetime o... | [
"def",
"__get_query_basic",
"(",
"cls",
",",
"date_field",
"=",
"None",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"filters",
"=",
"{",
"}",
")",
":",
"query_basic",
"=",
"Search",
"(",
")",
"query_filters",
"=",
"cls",
".",
"__get_query_... | Create a es_dsl query object with the date range and filters.
:param date_field: field with the date value
:param start: date with the from value, should be a datetime.datetime object
:param end: date with the to value, should be a datetime.datetime object
:param filters: dict with the ... | [
"Create",
"a",
"es_dsl",
"query",
"object",
"with",
"the",
"date",
"range",
"and",
"filters",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/esquery.py#L96-L133 |
47,669 | chaoss/grimoirelab-manuscripts | manuscripts/esquery.py | ElasticQuery.__get_query_agg_terms | def __get_query_agg_terms(cls, field, agg_id=None):
"""
Create a es_dsl aggregation object based on a term.
:param field: field to be used to aggregate
:return: a tuple with the aggregation id and es_dsl aggregation object. Ex:
{
"terms": {
... | python | def __get_query_agg_terms(cls, field, agg_id=None):
"""
Create a es_dsl aggregation object based on a term.
:param field: field to be used to aggregate
:return: a tuple with the aggregation id and es_dsl aggregation object. Ex:
{
"terms": {
... | [
"def",
"__get_query_agg_terms",
"(",
"cls",
",",
"field",
",",
"agg_id",
"=",
"None",
")",
":",
"if",
"not",
"agg_id",
":",
"agg_id",
"=",
"cls",
".",
"AGGREGATION_ID",
"query_agg",
"=",
"A",
"(",
"\"terms\"",
",",
"field",
"=",
"field",
",",
"size",
"... | Create a es_dsl aggregation object based on a term.
:param field: field to be used to aggregate
:return: a tuple with the aggregation id and es_dsl aggregation object. Ex:
{
"terms": {
"field": <field>,
"size:": <size>,... | [
"Create",
"a",
"es_dsl",
"aggregation",
"object",
"based",
"on",
"a",
"term",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/esquery.py#L136-L156 |
47,670 | chaoss/grimoirelab-manuscripts | manuscripts/esquery.py | ElasticQuery.__get_query_agg_max | def __get_query_agg_max(cls, field, agg_id=None):
"""
Create an es_dsl aggregation object for getting the max value of a field.
:param field: field from which the get the max value
:return: a tuple with the aggregation id and es_dsl aggregation object. Ex:
{
... | python | def __get_query_agg_max(cls, field, agg_id=None):
"""
Create an es_dsl aggregation object for getting the max value of a field.
:param field: field from which the get the max value
:return: a tuple with the aggregation id and es_dsl aggregation object. Ex:
{
... | [
"def",
"__get_query_agg_max",
"(",
"cls",
",",
"field",
",",
"agg_id",
"=",
"None",
")",
":",
"if",
"not",
"agg_id",
":",
"agg_id",
"=",
"cls",
".",
"AGGREGATION_ID",
"query_agg",
"=",
"A",
"(",
"\"max\"",
",",
"field",
"=",
"field",
")",
"return",
"("... | Create an es_dsl aggregation object for getting the max value of a field.
:param field: field from which the get the max value
:return: a tuple with the aggregation id and es_dsl aggregation object. Ex:
{
"max": {
"field": <field>
... | [
"Create",
"an",
"es_dsl",
"aggregation",
"object",
"for",
"getting",
"the",
"max",
"value",
"of",
"a",
"field",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/esquery.py#L159-L173 |
47,671 | chaoss/grimoirelab-manuscripts | manuscripts/esquery.py | ElasticQuery.__get_query_agg_avg | def __get_query_agg_avg(cls, field, agg_id=None):
"""
Create an es_dsl aggregation object for getting the average value of a field.
:param field: field from which the get the average value
:return: a tuple with the aggregation id and es_dsl aggregation object. Ex:
{
... | python | def __get_query_agg_avg(cls, field, agg_id=None):
"""
Create an es_dsl aggregation object for getting the average value of a field.
:param field: field from which the get the average value
:return: a tuple with the aggregation id and es_dsl aggregation object. Ex:
{
... | [
"def",
"__get_query_agg_avg",
"(",
"cls",
",",
"field",
",",
"agg_id",
"=",
"None",
")",
":",
"if",
"not",
"agg_id",
":",
"agg_id",
"=",
"cls",
".",
"AGGREGATION_ID",
"query_agg",
"=",
"A",
"(",
"\"avg\"",
",",
"field",
"=",
"field",
")",
"return",
"("... | Create an es_dsl aggregation object for getting the average value of a field.
:param field: field from which the get the average value
:return: a tuple with the aggregation id and es_dsl aggregation object. Ex:
{
"avg": {
"field": <field>
... | [
"Create",
"an",
"es_dsl",
"aggregation",
"object",
"for",
"getting",
"the",
"average",
"value",
"of",
"a",
"field",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/esquery.py#L194-L208 |
47,672 | chaoss/grimoirelab-manuscripts | manuscripts/esquery.py | ElasticQuery.__get_query_agg_cardinality | def __get_query_agg_cardinality(cls, field, agg_id=None):
"""
Create an es_dsl aggregation object for getting the approximate count of distinct values of a field.
:param field: field from which the get count of distinct values
:return: a tuple with the aggregation id and es_dsl aggregat... | python | def __get_query_agg_cardinality(cls, field, agg_id=None):
"""
Create an es_dsl aggregation object for getting the approximate count of distinct values of a field.
:param field: field from which the get count of distinct values
:return: a tuple with the aggregation id and es_dsl aggregat... | [
"def",
"__get_query_agg_cardinality",
"(",
"cls",
",",
"field",
",",
"agg_id",
"=",
"None",
")",
":",
"if",
"not",
"agg_id",
":",
"agg_id",
"=",
"cls",
".",
"AGGREGATION_ID",
"query_agg",
"=",
"A",
"(",
"\"cardinality\"",
",",
"field",
"=",
"field",
",",
... | Create an es_dsl aggregation object for getting the approximate count of distinct values of a field.
:param field: field from which the get count of distinct values
:return: a tuple with the aggregation id and es_dsl aggregation object. Ex:
{
"cardinality": {
... | [
"Create",
"an",
"es_dsl",
"aggregation",
"object",
"for",
"getting",
"the",
"approximate",
"count",
"of",
"distinct",
"values",
"of",
"a",
"field",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/esquery.py#L211-L226 |
47,673 | chaoss/grimoirelab-manuscripts | manuscripts/esquery.py | ElasticQuery.__get_bounds | def __get_bounds(cls, start=None, end=None):
"""
Return a dict with the bounds for a date_histogram agg.
:param start: date from for the date_histogram agg, should be a datetime.datetime object
:param end: date to for the date_histogram agg, should be a datetime.datetime object
... | python | def __get_bounds(cls, start=None, end=None):
"""
Return a dict with the bounds for a date_histogram agg.
:param start: date from for the date_histogram agg, should be a datetime.datetime object
:param end: date to for the date_histogram agg, should be a datetime.datetime object
... | [
"def",
"__get_bounds",
"(",
"cls",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"bounds",
"=",
"{",
"}",
"if",
"start",
"or",
"end",
":",
"# Extend bounds so we have data until start and end",
"start_ts",
"=",
"None",
"end_ts",
"=",
"None",
... | Return a dict with the bounds for a date_histogram agg.
:param start: date from for the date_histogram agg, should be a datetime.datetime object
:param end: date to for the date_histogram agg, should be a datetime.datetime object
:return: a dict with the DSL bounds for a date_histogram aggregat... | [
"Return",
"a",
"dict",
"with",
"the",
"bounds",
"for",
"a",
"date_histogram",
"agg",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/esquery.py#L229-L260 |
47,674 | chaoss/grimoirelab-manuscripts | manuscripts/esquery.py | ElasticQuery.__get_query_agg_ts | def __get_query_agg_ts(cls, field, time_field, interval=None,
time_zone=None, start=None, end=None,
agg_type='count', offset=None):
"""
Create an es_dsl aggregation object for getting the time series values for a field.
:param field: field t... | python | def __get_query_agg_ts(cls, field, time_field, interval=None,
time_zone=None, start=None, end=None,
agg_type='count', offset=None):
"""
Create an es_dsl aggregation object for getting the time series values for a field.
:param field: field t... | [
"def",
"__get_query_agg_ts",
"(",
"cls",
",",
"field",
",",
"time_field",
",",
"interval",
"=",
"None",
",",
"time_zone",
"=",
"None",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"agg_type",
"=",
"'count'",
",",
"offset",
"=",
"None",
")",... | Create an es_dsl aggregation object for getting the time series values for a field.
:param field: field to get the time series values
:param time_field: field with the date
:param interval: interval to be used to generate the time series values, such as:(year(y),
quarte... | [
"Create",
"an",
"es_dsl",
"aggregation",
"object",
"for",
"getting",
"the",
"time",
"series",
"values",
"for",
"a",
"field",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/esquery.py#L263-L314 |
47,675 | chaoss/grimoirelab-manuscripts | manuscripts/esquery.py | ElasticQuery.get_count | def get_count(cls, date_field=None, start=None, end=None, filters={}):
"""
Build the DSL query for counting the number of items.
:param date_field: field with the date
:param start: date from which to start counting, should be a datetime.datetime object
:param end: date until wh... | python | def get_count(cls, date_field=None, start=None, end=None, filters={}):
"""
Build the DSL query for counting the number of items.
:param date_field: field with the date
:param start: date from which to start counting, should be a datetime.datetime object
:param end: date until wh... | [
"def",
"get_count",
"(",
"cls",
",",
"date_field",
"=",
"None",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"filters",
"=",
"{",
"}",
")",
":",
"\"\"\" Total number of items \"\"\"",
"query_basic",
"=",
"cls",
".",
"__get_query_basic",
"(",
"d... | Build the DSL query for counting the number of items.
:param date_field: field with the date
:param start: date from which to start counting, should be a datetime.datetime object
:param end: date until which to count items, should be a datetime.datetime object
:param filters: dict with ... | [
"Build",
"the",
"DSL",
"query",
"for",
"counting",
"the",
"number",
"of",
"items",
"."
] | 94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9 | https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts/esquery.py#L317-L333 |
47,676 | pricingassistant/mongokat | mongokat/document.py | Document.ensure_fields | def ensure_fields(self, fields, force_refetch=False):
""" Makes sure we fetched the fields, and populate them if not. """
# We fetched with fields=None, we should have fetched them all
if self._fetched_fields is None or self._initialized_with_doc:
return
if force_refetch:
... | python | def ensure_fields(self, fields, force_refetch=False):
""" Makes sure we fetched the fields, and populate them if not. """
# We fetched with fields=None, we should have fetched them all
if self._fetched_fields is None or self._initialized_with_doc:
return
if force_refetch:
... | [
"def",
"ensure_fields",
"(",
"self",
",",
"fields",
",",
"force_refetch",
"=",
"False",
")",
":",
"# We fetched with fields=None, we should have fetched them all",
"if",
"self",
".",
"_fetched_fields",
"is",
"None",
"or",
"self",
".",
"_initialized_with_doc",
":",
"re... | Makes sure we fetched the fields, and populate them if not. | [
"Makes",
"sure",
"we",
"fetched",
"the",
"fields",
"and",
"populate",
"them",
"if",
"not",
"."
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/document.py#L82-L100 |
47,677 | pricingassistant/mongokat | mongokat/document.py | Document.refetch_fields | def refetch_fields(self, missing_fields):
""" Refetches a list of fields from the DB """
db_fields = self.mongokat_collection.find_one({"_id": self["_id"]}, fields={k: 1 for k in missing_fields})
self._fetched_fields += tuple(missing_fields)
if not db_fields:
return
... | python | def refetch_fields(self, missing_fields):
""" Refetches a list of fields from the DB """
db_fields = self.mongokat_collection.find_one({"_id": self["_id"]}, fields={k: 1 for k in missing_fields})
self._fetched_fields += tuple(missing_fields)
if not db_fields:
return
... | [
"def",
"refetch_fields",
"(",
"self",
",",
"missing_fields",
")",
":",
"db_fields",
"=",
"self",
".",
"mongokat_collection",
".",
"find_one",
"(",
"{",
"\"_id\"",
":",
"self",
"[",
"\"_id\"",
"]",
"}",
",",
"fields",
"=",
"{",
"k",
":",
"1",
"for",
"k"... | Refetches a list of fields from the DB | [
"Refetches",
"a",
"list",
"of",
"fields",
"from",
"the",
"DB"
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/document.py#L102-L112 |
47,678 | pricingassistant/mongokat | mongokat/document.py | Document.unset_fields | def unset_fields(self, fields):
""" Removes this list of fields from both the local object and the DB. """
self.mongokat_collection.update_one({"_id": self["_id"]}, {"$unset": {
f: 1 for f in fields
}})
for f in fields:
if f in self:
del self[f] | python | def unset_fields(self, fields):
""" Removes this list of fields from both the local object and the DB. """
self.mongokat_collection.update_one({"_id": self["_id"]}, {"$unset": {
f: 1 for f in fields
}})
for f in fields:
if f in self:
del self[f] | [
"def",
"unset_fields",
"(",
"self",
",",
"fields",
")",
":",
"self",
".",
"mongokat_collection",
".",
"update_one",
"(",
"{",
"\"_id\"",
":",
"self",
"[",
"\"_id\"",
"]",
"}",
",",
"{",
"\"$unset\"",
":",
"{",
"f",
":",
"1",
"for",
"f",
"in",
"fields... | Removes this list of fields from both the local object and the DB. | [
"Removes",
"this",
"list",
"of",
"fields",
"from",
"both",
"the",
"local",
"object",
"and",
"the",
"DB",
"."
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/document.py#L114-L123 |
47,679 | pricingassistant/mongokat | mongokat/document.py | Document.save_partial | def save_partial(self, data=None, allow_protected_fields=False, **kwargs):
""" Saves just the currently set fields in the database. """
# Backwards compat, deprecated argument
if "dotnotation" in kwargs:
del kwargs["dotnotation"]
if data is None:
data = dotdict... | python | def save_partial(self, data=None, allow_protected_fields=False, **kwargs):
""" Saves just the currently set fields in the database. """
# Backwards compat, deprecated argument
if "dotnotation" in kwargs:
del kwargs["dotnotation"]
if data is None:
data = dotdict... | [
"def",
"save_partial",
"(",
"self",
",",
"data",
"=",
"None",
",",
"allow_protected_fields",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# Backwards compat, deprecated argument",
"if",
"\"dotnotation\"",
"in",
"kwargs",
":",
"del",
"kwargs",
"[",
"\"dotnot... | Saves just the currently set fields in the database. | [
"Saves",
"just",
"the",
"currently",
"set",
"fields",
"in",
"the",
"database",
"."
] | 61eaf4bc1c4cc359c6f9592ec97b9a04d9561411 | https://github.com/pricingassistant/mongokat/blob/61eaf4bc1c4cc359c6f9592ec97b9a04d9561411/mongokat/document.py#L170-L199 |
47,680 | nccgroup/opinel | opinel/utils/cli_parser.py | read_default_args | def read_default_args(tool_name):
"""
Read default argument values for a given tool
:param tool_name: Name of the script to read the default arguments for
:return: Dictionary of default arguments (shared + tool-specific)
"""
global opinel_arg_dir
... | python | def read_default_args(tool_name):
"""
Read default argument values for a given tool
:param tool_name: Name of the script to read the default arguments for
:return: Dictionary of default arguments (shared + tool-specific)
"""
global opinel_arg_dir
... | [
"def",
"read_default_args",
"(",
"tool_name",
")",
":",
"global",
"opinel_arg_dir",
"profile_name",
"=",
"'default'",
"# h4ck to have an early read of the profile name",
"for",
"i",
",",
"arg",
"in",
"enumerate",
"(",
"sys",
".",
"argv",
")",
":",
"if",
"arg",
"==... | Read default argument values for a given tool
:param tool_name: Name of the script to read the default arguments for
:return: Dictionary of default arguments (shared + tool-specific) | [
"Read",
"default",
"argument",
"values",
"for",
"a",
"given",
"tool"
] | 2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606 | https://github.com/nccgroup/opinel/blob/2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606/opinel/utils/cli_parser.py#L143-L179 |
47,681 | nccgroup/opinel | opinel/utils/console.py | prompt | def prompt(test_input = None):
"""
Prompt function that works for Python2 and Python3
:param test_input: Value to be returned when testing
:return: Value typed by user (or passed in argument when testing)
"""
if test_input != None:
if type(te... | python | def prompt(test_input = None):
"""
Prompt function that works for Python2 and Python3
:param test_input: Value to be returned when testing
:return: Value typed by user (or passed in argument when testing)
"""
if test_input != None:
if type(te... | [
"def",
"prompt",
"(",
"test_input",
"=",
"None",
")",
":",
"if",
"test_input",
"!=",
"None",
":",
"if",
"type",
"(",
"test_input",
")",
"==",
"list",
"and",
"len",
"(",
"test_input",
")",
":",
"choice",
"=",
"test_input",
".",
"pop",
"(",
"0",
")",
... | Prompt function that works for Python2 and Python3
:param test_input: Value to be returned when testing
:return: Value typed by user (or passed in argument when testing) | [
"Prompt",
"function",
"that",
"works",
"for",
"Python2",
"and",
"Python3"
] | 2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606 | https://github.com/nccgroup/opinel/blob/2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606/opinel/utils/console.py#L73-L94 |
47,682 | nccgroup/opinel | opinel/utils/console.py | prompt_4_mfa_code | def prompt_4_mfa_code(activate = False, input = None):
"""
Prompt for an MFA code
:param activate: Set to true when prompting for the 2nd code when activating a new MFA device
:param input: Used for unit testing
:return: The MFA c... | python | def prompt_4_mfa_code(activate = False, input = None):
"""
Prompt for an MFA code
:param activate: Set to true when prompting for the 2nd code when activating a new MFA device
:param input: Used for unit testing
:return: The MFA c... | [
"def",
"prompt_4_mfa_code",
"(",
"activate",
"=",
"False",
",",
"input",
"=",
"None",
")",
":",
"while",
"True",
":",
"if",
"activate",
":",
"prompt_string",
"=",
"'Enter the next value: '",
"else",
":",
"prompt_string",
"=",
"'Enter your MFA code (or \\'q\\' to abo... | Prompt for an MFA code
:param activate: Set to true when prompting for the 2nd code when activating a new MFA device
:param input: Used for unit testing
:return: The MFA code | [
"Prompt",
"for",
"an",
"MFA",
"code"
] | 2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606 | https://github.com/nccgroup/opinel/blob/2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606/opinel/utils/console.py#L97-L120 |
47,683 | nccgroup/opinel | opinel/utils/console.py | prompt_4_mfa_serial | def prompt_4_mfa_serial(input = None):
"""
Prompt for an MFA serial number
:param input: Used for unit testing
:return: The MFA serial number
"""
return prompt_4_value('Enter your MFA serial:', required = False, regex = re_mfa_serial_format, reg... | python | def prompt_4_mfa_serial(input = None):
"""
Prompt for an MFA serial number
:param input: Used for unit testing
:return: The MFA serial number
"""
return prompt_4_value('Enter your MFA serial:', required = False, regex = re_mfa_serial_format, reg... | [
"def",
"prompt_4_mfa_serial",
"(",
"input",
"=",
"None",
")",
":",
"return",
"prompt_4_value",
"(",
"'Enter your MFA serial:'",
",",
"required",
"=",
"False",
",",
"regex",
"=",
"re_mfa_serial_format",
",",
"regex_format",
"=",
"mfa_serial_format",
",",
"input",
"... | Prompt for an MFA serial number
:param input: Used for unit testing
:return: The MFA serial number | [
"Prompt",
"for",
"an",
"MFA",
"serial",
"number"
] | 2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606 | https://github.com/nccgroup/opinel/blob/2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606/opinel/utils/console.py#L123-L131 |
47,684 | nccgroup/opinel | opinel/utils/console.py | prompt_4_overwrite | def prompt_4_overwrite(filename, force_write, input = None):
"""
Prompt whether the file should be overwritten
:param filename: Name of the file about to be written
:param force_write: Skip confirmation prompt if this flag is set
:param input: ... | python | def prompt_4_overwrite(filename, force_write, input = None):
"""
Prompt whether the file should be overwritten
:param filename: Name of the file about to be written
:param force_write: Skip confirmation prompt if this flag is set
:param input: ... | [
"def",
"prompt_4_overwrite",
"(",
"filename",
",",
"force_write",
",",
"input",
"=",
"None",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
"or",
"force_write",
":",
"return",
"True",
"return",
"prompt_4_yes_no",
"(",
"'File... | Prompt whether the file should be overwritten
:param filename: Name of the file about to be written
:param force_write: Skip confirmation prompt if this flag is set
:param input: Used for unit testing
:return: Boolean ... | [
"Prompt",
"whether",
"the",
"file",
"should",
"be",
"overwritten"
] | 2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606 | https://github.com/nccgroup/opinel/blob/2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606/opinel/utils/console.py#L134-L146 |
47,685 | sveetch/django-feedparser | django_feedparser/utils.py | get_feed_renderer | def get_feed_renderer(engines, name):
"""
From engine name, load the engine path and return the renderer class
Raise 'FeedparserError' if any loading error
"""
if name not in engines:
raise FeedparserError("Given feed name '{}' does not exists in 'settings.FEED_RENDER_ENGINES'".format(n... | python | def get_feed_renderer(engines, name):
"""
From engine name, load the engine path and return the renderer class
Raise 'FeedparserError' if any loading error
"""
if name not in engines:
raise FeedparserError("Given feed name '{}' does not exists in 'settings.FEED_RENDER_ENGINES'".format(n... | [
"def",
"get_feed_renderer",
"(",
"engines",
",",
"name",
")",
":",
"if",
"name",
"not",
"in",
"engines",
":",
"raise",
"FeedparserError",
"(",
"\"Given feed name '{}' does not exists in 'settings.FEED_RENDER_ENGINES'\"",
".",
"format",
"(",
"name",
")",
")",
"renderer... | From engine name, load the engine path and return the renderer class
Raise 'FeedparserError' if any loading error | [
"From",
"engine",
"name",
"load",
"the",
"engine",
"path",
"and",
"return",
"the",
"renderer",
"class",
"Raise",
"FeedparserError",
"if",
"any",
"loading",
"error"
] | 78be6a3ea095a90e4b28cad1b8893ddf1febf60e | https://github.com/sveetch/django-feedparser/blob/78be6a3ea095a90e4b28cad1b8893ddf1febf60e/django_feedparser/utils.py#L37-L48 |
47,686 | mixmastamyk/console | console/utils.py | clear_line | def clear_line(mode=2):
''' Clear the current line.
Arguments:
mode: | 0 | 'forward' | 'right' - Clear cursor to end of line.
| 1 | 'backward' | 'left' - Clear cursor to beginning of line.
| 2 | 'full' - Clear entire line.
Note:
... | python | def clear_line(mode=2):
''' Clear the current line.
Arguments:
mode: | 0 | 'forward' | 'right' - Clear cursor to end of line.
| 1 | 'backward' | 'left' - Clear cursor to beginning of line.
| 2 | 'full' - Clear entire line.
Note:
... | [
"def",
"clear_line",
"(",
"mode",
"=",
"2",
")",
":",
"text",
"=",
"sc",
".",
"erase_line",
"(",
"_mode_map",
".",
"get",
"(",
"mode",
",",
"mode",
")",
")",
"_write",
"(",
"text",
")",
"return",
"text"
] | Clear the current line.
Arguments:
mode: | 0 | 'forward' | 'right' - Clear cursor to end of line.
| 1 | 'backward' | 'left' - Clear cursor to beginning of line.
| 2 | 'full' - Clear entire line.
Note:
Cursor position does ... | [
"Clear",
"the",
"current",
"line",
"."
] | afe6c95d5a7b83d85376f450454e3769e4a5c3d0 | https://github.com/mixmastamyk/console/blob/afe6c95d5a7b83d85376f450454e3769e4a5c3d0/console/utils.py#L55-L69 |
47,687 | mixmastamyk/console | console/utils.py | wait_key | def wait_key(keys=None):
''' Waits for a keypress at the console and returns it.
"Where's the any key?"
Arguments:
keys - if passed, wait for this specific key, e.g. ESC.
may be a tuple.
Returns:
char or ESC - depending on key hit.
None... | python | def wait_key(keys=None):
''' Waits for a keypress at the console and returns it.
"Where's the any key?"
Arguments:
keys - if passed, wait for this specific key, e.g. ESC.
may be a tuple.
Returns:
char or ESC - depending on key hit.
None... | [
"def",
"wait_key",
"(",
"keys",
"=",
"None",
")",
":",
"if",
"is_a_tty",
"(",
")",
":",
"if",
"keys",
":",
"if",
"not",
"isinstance",
"(",
"keys",
",",
"tuple",
")",
":",
"keys",
"=",
"(",
"keys",
",",
")",
"while",
"True",
":",
"key",
"=",
"_g... | Waits for a keypress at the console and returns it.
"Where's the any key?"
Arguments:
keys - if passed, wait for this specific key, e.g. ESC.
may be a tuple.
Returns:
char or ESC - depending on key hit.
None - immediately under i/o redirect... | [
"Waits",
"for",
"a",
"keypress",
"at",
"the",
"console",
"and",
"returns",
"it",
".",
"Where",
"s",
"the",
"any",
"key?"
] | afe6c95d5a7b83d85376f450454e3769e4a5c3d0 | https://github.com/mixmastamyk/console/blob/afe6c95d5a7b83d85376f450454e3769e4a5c3d0/console/utils.py#L166-L186 |
47,688 | nccgroup/opinel | opinel/utils/aws.py | build_region_list | def build_region_list(service, chosen_regions = [], partition_name = 'aws'):
"""
Build the list of target region names
:param service:
:param chosen_regions:
:param partition_name:
:return:
"""
service = 'ec2containerservice' if service == 'ecs' else service # Of course things aren't t... | python | def build_region_list(service, chosen_regions = [], partition_name = 'aws'):
"""
Build the list of target region names
:param service:
:param chosen_regions:
:param partition_name:
:return:
"""
service = 'ec2containerservice' if service == 'ecs' else service # Of course things aren't t... | [
"def",
"build_region_list",
"(",
"service",
",",
"chosen_regions",
"=",
"[",
"]",
",",
"partition_name",
"=",
"'aws'",
")",
":",
"service",
"=",
"'ec2containerservice'",
"if",
"service",
"==",
"'ecs'",
"else",
"service",
"# Of course things aren't that easy...",
"# ... | Build the list of target region names
:param service:
:param chosen_regions:
:param partition_name:
:return: | [
"Build",
"the",
"list",
"of",
"target",
"region",
"names"
] | 2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606 | https://github.com/nccgroup/opinel/blob/2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606/opinel/utils/aws.py#L12-L28 |
47,689 | nccgroup/opinel | opinel/utils/aws.py | connect_service | def connect_service(service, credentials, region_name = None, config = None, silent = False):
"""
Instantiates an AWS API client
:param service:
:param credentials:
:param region_name:
:param config:
:param silent:
:return:
"""
api_client = None
try:
client_params =... | python | def connect_service(service, credentials, region_name = None, config = None, silent = False):
"""
Instantiates an AWS API client
:param service:
:param credentials:
:param region_name:
:param config:
:param silent:
:return:
"""
api_client = None
try:
client_params =... | [
"def",
"connect_service",
"(",
"service",
",",
"credentials",
",",
"region_name",
"=",
"None",
",",
"config",
"=",
"None",
",",
"silent",
"=",
"False",
")",
":",
"api_client",
"=",
"None",
"try",
":",
"client_params",
"=",
"{",
"}",
"client_params",
"[",
... | Instantiates an AWS API client
:param service:
:param credentials:
:param region_name:
:param config:
:param silent:
:return: | [
"Instantiates",
"an",
"AWS",
"API",
"client"
] | 2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606 | https://github.com/nccgroup/opinel/blob/2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606/opinel/utils/aws.py#L31-L65 |
47,690 | nccgroup/opinel | opinel/utils/aws.py | handle_truncated_response | def handle_truncated_response(callback, params, entities):
"""
Handle truncated responses
:param callback:
:param params:
:param entities:
:return:
"""
results = {}
for entity in entities:
results[entity] = []
while True:
try:
marker_found = False
... | python | def handle_truncated_response(callback, params, entities):
"""
Handle truncated responses
:param callback:
:param params:
:param entities:
:return:
"""
results = {}
for entity in entities:
results[entity] = []
while True:
try:
marker_found = False
... | [
"def",
"handle_truncated_response",
"(",
"callback",
",",
"params",
",",
"entities",
")",
":",
"results",
"=",
"{",
"}",
"for",
"entity",
"in",
"entities",
":",
"results",
"[",
"entity",
"]",
"=",
"[",
"]",
"while",
"True",
":",
"try",
":",
"marker_found... | Handle truncated responses
:param callback:
:param params:
:param entities:
:return: | [
"Handle",
"truncated",
"responses"
] | 2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606 | https://github.com/nccgroup/opinel/blob/2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606/opinel/utils/aws.py#L108-L139 |
47,691 | justanr/Flask-Transfer | examples/JPEGr/JPEGr/transfer.py | pdftojpg | def pdftojpg(filehandle, meta):
"""Converts a PDF to a JPG and places it back onto the FileStorage instance
passed to it as a BytesIO object.
Optional meta arguments are:
* resolution: int or (int, int) used for wand to determine resolution,
defaults to 300.
* width: new width of th... | python | def pdftojpg(filehandle, meta):
"""Converts a PDF to a JPG and places it back onto the FileStorage instance
passed to it as a BytesIO object.
Optional meta arguments are:
* resolution: int or (int, int) used for wand to determine resolution,
defaults to 300.
* width: new width of th... | [
"def",
"pdftojpg",
"(",
"filehandle",
",",
"meta",
")",
":",
"resolution",
"=",
"meta",
".",
"get",
"(",
"'resolution'",
",",
"300",
")",
"width",
"=",
"meta",
".",
"get",
"(",
"'width'",
",",
"1080",
")",
"bgcolor",
"=",
"Color",
"(",
"meta",
".",
... | Converts a PDF to a JPG and places it back onto the FileStorage instance
passed to it as a BytesIO object.
Optional meta arguments are:
* resolution: int or (int, int) used for wand to determine resolution,
defaults to 300.
* width: new width of the image for resizing, defaults to 1080
... | [
"Converts",
"a",
"PDF",
"to",
"a",
"JPG",
"and",
"places",
"it",
"back",
"onto",
"the",
"FileStorage",
"instance",
"passed",
"to",
"it",
"as",
"a",
"BytesIO",
"object",
"."
] | 075ba9edb8c8d0ea47619cc763394bbb717c2ead | https://github.com/justanr/Flask-Transfer/blob/075ba9edb8c8d0ea47619cc763394bbb717c2ead/examples/JPEGr/JPEGr/transfer.py#L15-L41 |
47,692 | justanr/Flask-Transfer | examples/JPEGr/JPEGr/transfer.py | change_filename | def change_filename(filehandle, meta):
"""Changes the filename to reflect the conversion from PDF to JPG.
This method will preserve the original filename in the meta dictionary.
"""
filename = secure_filename(meta.get('filename', filehandle.filename))
basename, _ = os.path.splitext(filename)
met... | python | def change_filename(filehandle, meta):
"""Changes the filename to reflect the conversion from PDF to JPG.
This method will preserve the original filename in the meta dictionary.
"""
filename = secure_filename(meta.get('filename', filehandle.filename))
basename, _ = os.path.splitext(filename)
met... | [
"def",
"change_filename",
"(",
"filehandle",
",",
"meta",
")",
":",
"filename",
"=",
"secure_filename",
"(",
"meta",
".",
"get",
"(",
"'filename'",
",",
"filehandle",
".",
"filename",
")",
")",
"basename",
",",
"_",
"=",
"os",
".",
"path",
".",
"splitext... | Changes the filename to reflect the conversion from PDF to JPG.
This method will preserve the original filename in the meta dictionary. | [
"Changes",
"the",
"filename",
"to",
"reflect",
"the",
"conversion",
"from",
"PDF",
"to",
"JPG",
".",
"This",
"method",
"will",
"preserve",
"the",
"original",
"filename",
"in",
"the",
"meta",
"dictionary",
"."
] | 075ba9edb8c8d0ea47619cc763394bbb717c2ead | https://github.com/justanr/Flask-Transfer/blob/075ba9edb8c8d0ea47619cc763394bbb717c2ead/examples/JPEGr/JPEGr/transfer.py#L45-L53 |
47,693 | justanr/Flask-Transfer | examples/JPEGr/JPEGr/transfer.py | pdf_saver | def pdf_saver(filehandle, *args, **kwargs):
"Uses werkzeug.FileStorage instance to save the converted image."
fullpath = get_save_path(filehandle.filename)
filehandle.save(fullpath, buffer_size=kwargs.get('buffer_size', 16384)) | python | def pdf_saver(filehandle, *args, **kwargs):
"Uses werkzeug.FileStorage instance to save the converted image."
fullpath = get_save_path(filehandle.filename)
filehandle.save(fullpath, buffer_size=kwargs.get('buffer_size', 16384)) | [
"def",
"pdf_saver",
"(",
"filehandle",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"fullpath",
"=",
"get_save_path",
"(",
"filehandle",
".",
"filename",
")",
"filehandle",
".",
"save",
"(",
"fullpath",
",",
"buffer_size",
"=",
"kwargs",
".",
"ge... | Uses werkzeug.FileStorage instance to save the converted image. | [
"Uses",
"werkzeug",
".",
"FileStorage",
"instance",
"to",
"save",
"the",
"converted",
"image",
"."
] | 075ba9edb8c8d0ea47619cc763394bbb717c2ead | https://github.com/justanr/Flask-Transfer/blob/075ba9edb8c8d0ea47619cc763394bbb717c2ead/examples/JPEGr/JPEGr/transfer.py#L80-L83 |
47,694 | nccgroup/opinel | opinel/utils/fs.py | load_data | def load_data(data_file, key_name = None, local_file = False, format = 'json'):
"""
Load a JSON data file
:param data_file:
:param key_name:
:param local_file:
:return:
"""
if local_file:
if data_file.startswith('/'):
src_file = data_file
else:
sr... | python | def load_data(data_file, key_name = None, local_file = False, format = 'json'):
"""
Load a JSON data file
:param data_file:
:param key_name:
:param local_file:
:return:
"""
if local_file:
if data_file.startswith('/'):
src_file = data_file
else:
sr... | [
"def",
"load_data",
"(",
"data_file",
",",
"key_name",
"=",
"None",
",",
"local_file",
"=",
"False",
",",
"format",
"=",
"'json'",
")",
":",
"if",
"local_file",
":",
"if",
"data_file",
".",
"startswith",
"(",
"'/'",
")",
":",
"src_file",
"=",
"data_file"... | Load a JSON data file
:param data_file:
:param key_name:
:param local_file:
:return: | [
"Load",
"a",
"JSON",
"data",
"file"
] | 2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606 | https://github.com/nccgroup/opinel/blob/2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606/opinel/utils/fs.py#L25-L57 |
47,695 | nccgroup/opinel | opinel/utils/fs.py | read_ip_ranges | def read_ip_ranges(filename, local_file = True, ip_only = False, conditions = []):
"""
Returns the list of IP prefixes from an ip-ranges file
:param filename:
:param local_file:
:param conditions:
:param ip_only:
:return:
"""
targets = []
data = load_data(filename, local_file = ... | python | def read_ip_ranges(filename, local_file = True, ip_only = False, conditions = []):
"""
Returns the list of IP prefixes from an ip-ranges file
:param filename:
:param local_file:
:param conditions:
:param ip_only:
:return:
"""
targets = []
data = load_data(filename, local_file = ... | [
"def",
"read_ip_ranges",
"(",
"filename",
",",
"local_file",
"=",
"True",
",",
"ip_only",
"=",
"False",
",",
"conditions",
"=",
"[",
"]",
")",
":",
"targets",
"=",
"[",
"]",
"data",
"=",
"load_data",
"(",
"filename",
",",
"local_file",
"=",
"local_file",... | Returns the list of IP prefixes from an ip-ranges file
:param filename:
:param local_file:
:param conditions:
:param ip_only:
:return: | [
"Returns",
"the",
"list",
"of",
"IP",
"prefixes",
"from",
"an",
"ip",
"-",
"ranges",
"file"
] | 2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606 | https://github.com/nccgroup/opinel/blob/2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606/opinel/utils/fs.py#L60-L96 |
47,696 | dag/flask-zodb | flask_zodb.py | ZODB.init_app | def init_app(self, app):
"""Configure a Flask application to use this ZODB extension."""
assert 'zodb' not in app.extensions, \
'app already initiated for zodb'
app.extensions['zodb'] = _ZODBState(self, app)
app.teardown_request(self.close_db) | python | def init_app(self, app):
"""Configure a Flask application to use this ZODB extension."""
assert 'zodb' not in app.extensions, \
'app already initiated for zodb'
app.extensions['zodb'] = _ZODBState(self, app)
app.teardown_request(self.close_db) | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"assert",
"'zodb'",
"not",
"in",
"app",
".",
"extensions",
",",
"'app already initiated for zodb'",
"app",
".",
"extensions",
"[",
"'zodb'",
"]",
"=",
"_ZODBState",
"(",
"self",
",",
"app",
")",
"app",
... | Configure a Flask application to use this ZODB extension. | [
"Configure",
"a",
"Flask",
"application",
"to",
"use",
"this",
"ZODB",
"extension",
"."
] | c5451aba28cd5b303c71654b7ef2b62edb08afe8 | https://github.com/dag/flask-zodb/blob/c5451aba28cd5b303c71654b7ef2b62edb08afe8/flask_zodb.py#L41-L46 |
47,697 | dag/flask-zodb | flask_zodb.py | ZODB.close_db | def close_db(self, exception):
"""Added as a `~flask.Flask.teardown_request` to applications to
commit the transaction and disconnect ZODB if it was used during
the request."""
if self.is_connected:
if exception is None and not transaction.isDoomed():
transact... | python | def close_db(self, exception):
"""Added as a `~flask.Flask.teardown_request` to applications to
commit the transaction and disconnect ZODB if it was used during
the request."""
if self.is_connected:
if exception is None and not transaction.isDoomed():
transact... | [
"def",
"close_db",
"(",
"self",
",",
"exception",
")",
":",
"if",
"self",
".",
"is_connected",
":",
"if",
"exception",
"is",
"None",
"and",
"not",
"transaction",
".",
"isDoomed",
"(",
")",
":",
"transaction",
".",
"commit",
"(",
")",
"else",
":",
"tran... | Added as a `~flask.Flask.teardown_request` to applications to
commit the transaction and disconnect ZODB if it was used during
the request. | [
"Added",
"as",
"a",
"~flask",
".",
"Flask",
".",
"teardown_request",
"to",
"applications",
"to",
"commit",
"the",
"transaction",
"and",
"disconnect",
"ZODB",
"if",
"it",
"was",
"used",
"during",
"the",
"request",
"."
] | c5451aba28cd5b303c71654b7ef2b62edb08afe8 | https://github.com/dag/flask-zodb/blob/c5451aba28cd5b303c71654b7ef2b62edb08afe8/flask_zodb.py#L48-L57 |
47,698 | dag/flask-zodb | flask_zodb.py | ZODB.connection | def connection(self):
"""Request-bound database connection."""
assert flask.has_request_context(), \
'tried to connect zodb outside request'
if not self.is_connected:
connector = flask.current_app.extensions['zodb']
flask._request_ctx_stack.top.zodb_connect... | python | def connection(self):
"""Request-bound database connection."""
assert flask.has_request_context(), \
'tried to connect zodb outside request'
if not self.is_connected:
connector = flask.current_app.extensions['zodb']
flask._request_ctx_stack.top.zodb_connect... | [
"def",
"connection",
"(",
"self",
")",
":",
"assert",
"flask",
".",
"has_request_context",
"(",
")",
",",
"'tried to connect zodb outside request'",
"if",
"not",
"self",
".",
"is_connected",
":",
"connector",
"=",
"flask",
".",
"current_app",
".",
"extensions",
... | Request-bound database connection. | [
"Request",
"-",
"bound",
"database",
"connection",
"."
] | c5451aba28cd5b303c71654b7ef2b62edb08afe8 | https://github.com/dag/flask-zodb/blob/c5451aba28cd5b303c71654b7ef2b62edb08afe8/flask_zodb.py#L79-L87 |
47,699 | nccgroup/opinel | opinel/services/iam.py | add_user_to_group | def add_user_to_group(iam_client, user, group, quiet = False):
"""
Add an IAM user to an IAM group
:param iam_client:
:param group:
:param user:
:param user_info:
:param dry_run:
:return:
"""
if not quiet:
printInfo('Adding user to group %s...' % group)
iam_client.ad... | python | def add_user_to_group(iam_client, user, group, quiet = False):
"""
Add an IAM user to an IAM group
:param iam_client:
:param group:
:param user:
:param user_info:
:param dry_run:
:return:
"""
if not quiet:
printInfo('Adding user to group %s...' % group)
iam_client.ad... | [
"def",
"add_user_to_group",
"(",
"iam_client",
",",
"user",
",",
"group",
",",
"quiet",
"=",
"False",
")",
":",
"if",
"not",
"quiet",
":",
"printInfo",
"(",
"'Adding user to group %s...'",
"%",
"group",
")",
"iam_client",
".",
"add_user_to_group",
"(",
"GroupN... | Add an IAM user to an IAM group
:param iam_client:
:param group:
:param user:
:param user_info:
:param dry_run:
:return: | [
"Add",
"an",
"IAM",
"user",
"to",
"an",
"IAM",
"group"
] | 2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606 | https://github.com/nccgroup/opinel/blob/2d4f5b96e0a1f9cb0356629f4f87e4ed99ce2606/opinel/services/iam.py#L11-L24 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.