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
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
chaoss/grimoirelab-manuscripts
setup.py
files_in_subdir
def files_in_subdir(dir, subdir): """Find all files in a directory.""" paths = [] for (path, dirs, files) in os.walk(os.path.join(dir, subdir)): for file in files: paths.append(os.path.relpath(os.path.join(path, file), dir)) return paths
python
def files_in_subdir(dir, subdir): """Find all files in a directory.""" paths = [] for (path, dirs, files) in os.walk(os.path.join(dir, subdir)): for file in files: paths.append(os.path.relpath(os.path.join(path, file), dir)) return paths
[ "def", "files_in_subdir", "(", "dir", ",", "subdir", ")", ":", "paths", "=", "[", "]", "for", "(", "path", ",", "dirs", ",", "files", ")", "in", "os", ".", "walk", "(", "os", ".", "path", ".", "join", "(", "dir", ",", "subdir", ")", ")", ":", ...
Find all files in a directory.
[ "Find", "all", "files", "in", "a", "directory", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/setup.py#L49-L55
train
64,500
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/git.py
overview
def overview(index, start, end): """Compute metrics in the overview section for enriched git indexes. Returns a dictionary. Each key in the dictionary is the name of a metric, the value is the value of that metric. Value can be a complex object (eg, a time series). :param index: index object :...
python
def overview(index, start, end): """Compute metrics in the overview section for enriched git indexes. Returns a dictionary. Each key in the dictionary is the name of a metric, the value is the value of that metric. Value can be a complex object (eg, a time series). :param index: index object :...
[ "def", "overview", "(", "index", ",", "start", ",", "end", ")", ":", "results", "=", "{", "\"activity_metrics\"", ":", "[", "Commits", "(", "index", ",", "start", ",", "end", ")", "]", ",", "\"author_metrics\"", ":", "[", "Authors", "(", "index", ",", ...
Compute metrics in the overview section for enriched git indexes. Returns a dictionary. Each key in the dictionary is the name of a metric, the value is the value of that metric. Value can be a complex object (eg, a time series). :param index: index object :param start: start date to get the data ...
[ "Compute", "metrics", "in", "the", "overview", "section", "for", "enriched", "git", "indexes", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/git.py#L145-L166
train
64,501
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/git.py
project_activity
def project_activity(index, start, end): """Compute the metrics for the project activity section of the enriched git index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to get the data from ...
python
def project_activity(index, start, end): """Compute the metrics for the project activity section of the enriched git index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to get the data from ...
[ "def", "project_activity", "(", "index", ",", "start", ",", "end", ")", ":", "results", "=", "{", "\"metrics\"", ":", "[", "Commits", "(", "index", ",", "start", ",", "end", ")", ",", "Authors", "(", "index", ",", "start", ",", "end", ")", "]", "}"...
Compute the metrics for the project activity section of the enriched git index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to get the data from :param end: end date to get the data upto ...
[ "Compute", "the", "metrics", "for", "the", "project", "activity", "section", "of", "the", "enriched", "git", "index", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/git.py#L169-L187
train
64,502
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/git.py
project_community
def project_community(index, start, end): """Compute the metrics for the project community section of the enriched git index. Returns a dictionary containing "author_metrics", "people_top_metrics" and "orgs_top_metrics" as the keys and the related Metrics as the values. :param index: index object ...
python
def project_community(index, start, end): """Compute the metrics for the project community section of the enriched git index. Returns a dictionary containing "author_metrics", "people_top_metrics" and "orgs_top_metrics" as the keys and the related Metrics as the values. :param index: index object ...
[ "def", "project_community", "(", "index", ",", "start", ",", "end", ")", ":", "results", "=", "{", "\"author_metrics\"", ":", "[", "Authors", "(", "index", ",", "start", ",", "end", ")", "]", ",", "\"people_top_metrics\"", ":", "[", "Authors", "(", "inde...
Compute the metrics for the project community section of the enriched git index. Returns a dictionary containing "author_metrics", "people_top_metrics" and "orgs_top_metrics" as the keys and the related Metrics as the values. :param index: index object :param start: start date to get the data from...
[ "Compute", "the", "metrics", "for", "the", "project", "community", "section", "of", "the", "enriched", "git", "index", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/git.py#L190-L209
train
64,503
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/git.py
Authors.aggregations
def aggregations(self): """ Override parent method. Obtain list of the terms and their corresponding values using "terms" aggregations for the previous time period. :returns: a data frame containing terms and their corresponding values """ prev_month_start = get_prev_mo...
python
def aggregations(self): """ Override parent method. Obtain list of the terms and their corresponding values using "terms" aggregations for the previous time period. :returns: a data frame containing terms and their corresponding values """ prev_month_start = get_prev_mo...
[ "def", "aggregations", "(", "self", ")", ":", "prev_month_start", "=", "get_prev_month", "(", "self", ".", "end", ",", "self", ".", "query", ".", "interval_", ")", "self", ".", "query", ".", "since", "(", "prev_month_start", ")", "self", ".", "query", "....
Override parent method. Obtain list of the terms and their corresponding values using "terms" aggregations for the previous time period. :returns: a data frame containing terms and their corresponding values
[ "Override", "parent", "method", ".", "Obtain", "list", "of", "the", "terms", "and", "their", "corresponding", "values", "using", "terms", "aggregations", "for", "the", "previous", "time", "period", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/git.py#L94-L105
train
64,504
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/github_issues.py
project_activity
def project_activity(index, start, end): """Compute the metrics for the project activity section of the enriched github issues index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to get the d...
python
def project_activity(index, start, end): """Compute the metrics for the project activity section of the enriched github issues index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to get the d...
[ "def", "project_activity", "(", "index", ",", "start", ",", "end", ")", ":", "results", "=", "{", "\"metrics\"", ":", "[", "OpenedIssues", "(", "index", ",", "start", ",", "end", ")", ",", "ClosedIssues", "(", "index", ",", "start", ",", "end", ")", ...
Compute the metrics for the project activity section of the enriched github issues index. Returns a dictionary containing a "metric" key. This key contains the metrics for this section. :param index: index object :param start: start date to get the data from :param end: end date to get the dat...
[ "Compute", "the", "metrics", "for", "the", "project", "activity", "section", "of", "the", "enriched", "github", "issues", "index", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/github_issues.py#L243-L261
train
64,505
chaoss/grimoirelab-manuscripts
manuscripts2/metrics/github_issues.py
BMI.aggregations
def aggregations(self): """Get the aggregation value for BMI with respect to the previous time interval.""" prev_month_start = get_prev_month(self.end, self.closed.query.interval_) self.closed.query.since(prev_month_start, ...
python
def aggregations(self): """Get the aggregation value for BMI with respect to the previous time interval.""" prev_month_start = get_prev_month(self.end, self.closed.query.interval_) self.closed.query.since(prev_month_start, ...
[ "def", "aggregations", "(", "self", ")", ":", "prev_month_start", "=", "get_prev_month", "(", "self", ".", "end", ",", "self", ".", "closed", ".", "query", ".", "interval_", ")", "self", ".", "closed", ".", "query", ".", "since", "(", "prev_month_start", ...
Get the aggregation value for BMI with respect to the previous time interval.
[ "Get", "the", "aggregation", "value", "for", "BMI", "with", "respect", "to", "the", "previous", "time", "interval", "." ]
94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9
https://github.com/chaoss/grimoirelab-manuscripts/blob/94a3ad4f11bfbcd6c5190e01cb5d3e47a5187cd9/manuscripts2/metrics/github_issues.py#L193-L208
train
64,506
openearth/bmi-python
bmi/wrapper.py
c_log
def c_log(level, message): """python logger to be called from fortran""" c_level = level level = LEVELS_F2PY[c_level] logger.log(level, message)
python
def c_log(level, message): """python logger to be called from fortran""" c_level = level level = LEVELS_F2PY[c_level] logger.log(level, message)
[ "def", "c_log", "(", "level", ",", "message", ")", ":", "c_level", "=", "level", "level", "=", "LEVELS_F2PY", "[", "c_level", "]", "logger", ".", "log", "(", "level", ",", "message", ")" ]
python logger to be called from fortran
[ "python", "logger", "to", "be", "called", "from", "fortran" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L79-L83
train
64,507
openearth/bmi-python
bmi/wrapper.py
struct2dict
def struct2dict(struct): """convert a ctypes structure to a dictionary""" return {x: getattr(struct, x) for x in dict(struct._fields_).keys()}
python
def struct2dict(struct): """convert a ctypes structure to a dictionary""" return {x: getattr(struct, x) for x in dict(struct._fields_).keys()}
[ "def", "struct2dict", "(", "struct", ")", ":", "return", "{", "x", ":", "getattr", "(", "struct", ",", "x", ")", "for", "x", "in", "dict", "(", "struct", ".", "_fields_", ")", ".", "keys", "(", ")", "}" ]
convert a ctypes structure to a dictionary
[ "convert", "a", "ctypes", "structure", "to", "a", "dictionary" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L113-L115
train
64,508
openearth/bmi-python
bmi/wrapper.py
structs2records
def structs2records(structs): """convert one or more structs and generate dictionaries""" try: n = len(structs) except TypeError: # no array yield struct2dict(structs) # just 1 return for i in range(n): struct = structs[i] yield struct2dict(struct)
python
def structs2records(structs): """convert one or more structs and generate dictionaries""" try: n = len(structs) except TypeError: # no array yield struct2dict(structs) # just 1 return for i in range(n): struct = structs[i] yield struct2dict(struct)
[ "def", "structs2records", "(", "structs", ")", ":", "try", ":", "n", "=", "len", "(", "structs", ")", "except", "TypeError", ":", "# no array", "yield", "struct2dict", "(", "structs", ")", "# just 1", "return", "for", "i", "in", "range", "(", "n", ")", ...
convert one or more structs and generate dictionaries
[ "convert", "one", "or", "more", "structs", "and", "generate", "dictionaries" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L118-L129
train
64,509
openearth/bmi-python
bmi/wrapper.py
structs2pandas
def structs2pandas(structs): """convert ctypes structure or structure array to pandas data frame""" try: import pandas records = list(structs2records(structs)) df = pandas.DataFrame.from_records(records) # TODO: do this for string columns, for now just for id # How can we...
python
def structs2pandas(structs): """convert ctypes structure or structure array to pandas data frame""" try: import pandas records = list(structs2records(structs)) df = pandas.DataFrame.from_records(records) # TODO: do this for string columns, for now just for id # How can we...
[ "def", "structs2pandas", "(", "structs", ")", ":", "try", ":", "import", "pandas", "records", "=", "list", "(", "structs2records", "(", "structs", ")", ")", "df", "=", "pandas", ".", "DataFrame", ".", "from_records", "(", "records", ")", "# TODO: do this for...
convert ctypes structure or structure array to pandas data frame
[ "convert", "ctypes", "structure", "or", "structure", "array", "to", "pandas", "data", "frame" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L132-L146
train
64,510
openearth/bmi-python
bmi/wrapper.py
wrap
def wrap(func): """Return wrapped function with type conversion and sanity checks. """ @functools.wraps(func, assigned=('restype', 'argtypes')) def wrapped(*args): if len(args) != len(func.argtypes): logger.warn("{} {} not of same length", args, func.argtypes)...
python
def wrap(func): """Return wrapped function with type conversion and sanity checks. """ @functools.wraps(func, assigned=('restype', 'argtypes')) def wrapped(*args): if len(args) != len(func.argtypes): logger.warn("{} {} not of same length", args, func.argtypes)...
[ "def", "wrap", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ",", "assigned", "=", "(", "'restype'", ",", "'argtypes'", ")", ")", "def", "wrapped", "(", "*", "args", ")", ":", "if", "len", "(", "args", ")", "!=", "len", "(",...
Return wrapped function with type conversion and sanity checks.
[ "Return", "wrapped", "function", "with", "type", "conversion", "and", "sanity", "checks", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L149-L176
train
64,511
openearth/bmi-python
bmi/wrapper.py
BMIWrapper._libname
def _libname(self): """Return platform-specific modelf90 shared library name.""" prefix = 'lib' suffix = '.so' if platform.system() == 'Darwin': suffix = '.dylib' if platform.system() == 'Windows': prefix = '' suffix = '.dll' return pre...
python
def _libname(self): """Return platform-specific modelf90 shared library name.""" prefix = 'lib' suffix = '.so' if platform.system() == 'Darwin': suffix = '.dylib' if platform.system() == 'Windows': prefix = '' suffix = '.dll' return pre...
[ "def", "_libname", "(", "self", ")", ":", "prefix", "=", "'lib'", "suffix", "=", "'.so'", "if", "platform", ".", "system", "(", ")", "==", "'Darwin'", ":", "suffix", "=", "'.dylib'", "if", "platform", ".", "system", "(", ")", "==", "'Windows'", ":", ...
Return platform-specific modelf90 shared library name.
[ "Return", "platform", "-", "specific", "modelf90", "shared", "library", "name", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L252-L261
train
64,512
openearth/bmi-python
bmi/wrapper.py
BMIWrapper._library_path
def _library_path(self): """Return full path to the shared library. A couple of regular unix paths like ``/usr/lib/`` is searched by default. If your library is not in one of those, set a ``LD_LIBRARY_PATH`` environment variable to the directory with your shared library. ...
python
def _library_path(self): """Return full path to the shared library. A couple of regular unix paths like ``/usr/lib/`` is searched by default. If your library is not in one of those, set a ``LD_LIBRARY_PATH`` environment variable to the directory with your shared library. ...
[ "def", "_library_path", "(", "self", ")", ":", "# engine is an existing library name", "# TODO change add directory to library path", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "engine", ")", ":", "return", "self", ".", "engine", "pathname", "=", "'...
Return full path to the shared library. A couple of regular unix paths like ``/usr/lib/`` is searched by default. If your library is not in one of those, set a ``LD_LIBRARY_PATH`` environment variable to the directory with your shared library. If the library cannot be found, a ...
[ "Return", "full", "path", "to", "the", "shared", "library", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L263-L307
train
64,513
openearth/bmi-python
bmi/wrapper.py
BMIWrapper._load_library
def _load_library(self): """Return the fortran library, loaded with """ path = self._library_path() logger.info("Loading library from path {}".format(path)) library_dir = os.path.dirname(path) if platform.system() == 'Windows': import win32api olddir = os....
python
def _load_library(self): """Return the fortran library, loaded with """ path = self._library_path() logger.info("Loading library from path {}".format(path)) library_dir = os.path.dirname(path) if platform.system() == 'Windows': import win32api olddir = os....
[ "def", "_load_library", "(", "self", ")", ":", "path", "=", "self", ".", "_library_path", "(", ")", "logger", ".", "info", "(", "\"Loading library from path {}\"", ".", "format", "(", "path", ")", ")", "library_dir", "=", "os", ".", "path", ".", "dirname",...
Return the fortran library, loaded with
[ "Return", "the", "fortran", "library", "loaded", "with" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L309-L325
train
64,514
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.finalize
def finalize(self): """Shutdown the library and clean up the model. Note that the Fortran library's cleanup code is not up to snuff yet, so the cleanup is not perfect. Note also that the working directory is changed back to the original one. """ self.library.finalize.ar...
python
def finalize(self): """Shutdown the library and clean up the model. Note that the Fortran library's cleanup code is not up to snuff yet, so the cleanup is not perfect. Note also that the working directory is changed back to the original one. """ self.library.finalize.ar...
[ "def", "finalize", "(", "self", ")", ":", "self", ".", "library", ".", "finalize", ".", "argtypes", "=", "[", "]", "self", ".", "library", ".", "finalize", ".", "restype", "=", "c_int", "ierr", "=", "wrap", "(", "self", ".", "library", ".", "finalize...
Shutdown the library and clean up the model. Note that the Fortran library's cleanup code is not up to snuff yet, so the cleanup is not perfect. Note also that the working directory is changed back to the original one.
[ "Shutdown", "the", "library", "and", "clean", "up", "the", "model", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L364-L381
train
64,515
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_var_count
def get_var_count(self): """ Return number of variables """ n = c_int() self.library.get_var_count.argtypes = [POINTER(c_int)] self.library.get_var_count(byref(n)) return n.value
python
def get_var_count(self): """ Return number of variables """ n = c_int() self.library.get_var_count.argtypes = [POINTER(c_int)] self.library.get_var_count(byref(n)) return n.value
[ "def", "get_var_count", "(", "self", ")", ":", "n", "=", "c_int", "(", ")", "self", ".", "library", ".", "get_var_count", ".", "argtypes", "=", "[", "POINTER", "(", "c_int", ")", "]", "self", ".", "library", ".", "get_var_count", "(", "byref", "(", "...
Return number of variables
[ "Return", "number", "of", "variables" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L400-L407
train
64,516
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.inq_compound_field
def inq_compound_field(self, name, index): """ Lookup the type,rank and shape of a compound field """ typename = create_string_buffer(name) index = c_int(index + 1) fieldname = create_string_buffer(MAXSTRLEN) fieldtype = create_string_buffer(MAXSTRLEN) ran...
python
def inq_compound_field(self, name, index): """ Lookup the type,rank and shape of a compound field """ typename = create_string_buffer(name) index = c_int(index + 1) fieldname = create_string_buffer(MAXSTRLEN) fieldtype = create_string_buffer(MAXSTRLEN) ran...
[ "def", "inq_compound_field", "(", "self", ",", "name", ",", "index", ")", ":", "typename", "=", "create_string_buffer", "(", "name", ")", "index", "=", "c_int", "(", "index", "+", "1", ")", "fieldname", "=", "create_string_buffer", "(", "MAXSTRLEN", ")", "...
Lookup the type,rank and shape of a compound field
[ "Lookup", "the", "type", "rank", "and", "shape", "of", "a", "compound", "field" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L440-L470
train
64,517
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.make_compound_ctype
def make_compound_ctype(self, varname): """ Create a ctypes type that corresponds to a compound type in memory. """ # look up the type name compoundname = self.get_var_type(varname) nfields = self.inq_compound(compoundname) # for all the fields look up the type, ...
python
def make_compound_ctype(self, varname): """ Create a ctypes type that corresponds to a compound type in memory. """ # look up the type name compoundname = self.get_var_type(varname) nfields = self.inq_compound(compoundname) # for all the fields look up the type, ...
[ "def", "make_compound_ctype", "(", "self", ",", "varname", ")", ":", "# look up the type name", "compoundname", "=", "self", ".", "get_var_type", "(", "varname", ")", "nfields", "=", "self", ".", "inq_compound", "(", "compoundname", ")", "# for all the fields look u...
Create a ctypes type that corresponds to a compound type in memory.
[ "Create", "a", "ctypes", "type", "that", "corresponds", "to", "a", "compound", "type", "in", "memory", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L472-L504
train
64,518
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_var_rank
def get_var_rank(self, name): """ Return array rank or 0 for scalar. """ name = create_string_buffer(name) rank = c_int() self.library.get_var_rank.argtypes = [c_char_p, POINTER(c_int)] self.library.get_var_rank.restype = None self.library.get_var_rank(nam...
python
def get_var_rank(self, name): """ Return array rank or 0 for scalar. """ name = create_string_buffer(name) rank = c_int() self.library.get_var_rank.argtypes = [c_char_p, POINTER(c_int)] self.library.get_var_rank.restype = None self.library.get_var_rank(nam...
[ "def", "get_var_rank", "(", "self", ",", "name", ")", ":", "name", "=", "create_string_buffer", "(", "name", ")", "rank", "=", "c_int", "(", ")", "self", ".", "library", ".", "get_var_rank", ".", "argtypes", "=", "[", "c_char_p", ",", "POINTER", "(", "...
Return array rank or 0 for scalar.
[ "Return", "array", "rank", "or", "0", "for", "scalar", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L506-L515
train
64,519
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_var_shape
def get_var_shape(self, name): """ Return shape of the array. """ rank = self.get_var_rank(name) name = create_string_buffer(name) arraytype = ndpointer(dtype='int32', ndim=1, shape=(MAXDIMS, ), ...
python
def get_var_shape(self, name): """ Return shape of the array. """ rank = self.get_var_rank(name) name = create_string_buffer(name) arraytype = ndpointer(dtype='int32', ndim=1, shape=(MAXDIMS, ), ...
[ "def", "get_var_shape", "(", "self", ",", "name", ")", ":", "rank", "=", "self", ".", "get_var_rank", "(", "name", ")", "name", "=", "create_string_buffer", "(", "name", ")", "arraytype", "=", "ndpointer", "(", "dtype", "=", "'int32'", ",", "ndim", "=", ...
Return shape of the array.
[ "Return", "shape", "of", "the", "array", "." ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L517-L530
train
64,520
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_start_time
def get_start_time(self): """ returns start time """ start_time = c_double() self.library.get_start_time.argtypes = [POINTER(c_double)] self.library.get_start_time.restype = None self.library.get_start_time(byref(start_time)) return start_time.value
python
def get_start_time(self): """ returns start time """ start_time = c_double() self.library.get_start_time.argtypes = [POINTER(c_double)] self.library.get_start_time.restype = None self.library.get_start_time(byref(start_time)) return start_time.value
[ "def", "get_start_time", "(", "self", ")", ":", "start_time", "=", "c_double", "(", ")", "self", ".", "library", ".", "get_start_time", ".", "argtypes", "=", "[", "POINTER", "(", "c_double", ")", "]", "self", ".", "library", ".", "get_start_time", ".", "...
returns start time
[ "returns", "start", "time" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L532-L540
train
64,521
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_end_time
def get_end_time(self): """ returns end time of simulation """ end_time = c_double() self.library.get_end_time.argtypes = [POINTER(c_double)] self.library.get_end_time.restype = None self.library.get_end_time(byref(end_time)) return end_time.value
python
def get_end_time(self): """ returns end time of simulation """ end_time = c_double() self.library.get_end_time.argtypes = [POINTER(c_double)] self.library.get_end_time.restype = None self.library.get_end_time(byref(end_time)) return end_time.value
[ "def", "get_end_time", "(", "self", ")", ":", "end_time", "=", "c_double", "(", ")", "self", ".", "library", ".", "get_end_time", ".", "argtypes", "=", "[", "POINTER", "(", "c_double", ")", "]", "self", ".", "library", ".", "get_end_time", ".", "restype"...
returns end time of simulation
[ "returns", "end", "time", "of", "simulation" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L542-L550
train
64,522
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_current_time
def get_current_time(self): """ returns current time of simulation """ current_time = c_double() self.library.get_current_time.argtypes = [POINTER(c_double)] self.library.get_current_time.restype = None self.library.get_current_time(byref(current_time)) re...
python
def get_current_time(self): """ returns current time of simulation """ current_time = c_double() self.library.get_current_time.argtypes = [POINTER(c_double)] self.library.get_current_time.restype = None self.library.get_current_time(byref(current_time)) re...
[ "def", "get_current_time", "(", "self", ")", ":", "current_time", "=", "c_double", "(", ")", "self", ".", "library", ".", "get_current_time", ".", "argtypes", "=", "[", "POINTER", "(", "c_double", ")", "]", "self", ".", "library", ".", "get_current_time", ...
returns current time of simulation
[ "returns", "current", "time", "of", "simulation" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L552-L560
train
64,523
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_time_step
def get_time_step(self): """ returns current time step of simulation """ time_step = c_double() self.library.get_time_step.argtypes = [POINTER(c_double)] self.library.get_time_step.restype = None self.library.get_time_step(byref(time_step)) return time_ste...
python
def get_time_step(self): """ returns current time step of simulation """ time_step = c_double() self.library.get_time_step.argtypes = [POINTER(c_double)] self.library.get_time_step.restype = None self.library.get_time_step(byref(time_step)) return time_ste...
[ "def", "get_time_step", "(", "self", ")", ":", "time_step", "=", "c_double", "(", ")", "self", ".", "library", ".", "get_time_step", ".", "argtypes", "=", "[", "POINTER", "(", "c_double", ")", "]", "self", ".", "library", ".", "get_time_step", ".", "rest...
returns current time step of simulation
[ "returns", "current", "time", "step", "of", "simulation" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L562-L570
train
64,524
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.get_var
def get_var(self, name): """Return an nd array from model library""" # How many dimensions. rank = self.get_var_rank(name) # The shape array is fixed size shape = np.empty((MAXDIMS, ), dtype='int32', order='F') shape = self.get_var_shape(name) # there should be no...
python
def get_var(self, name): """Return an nd array from model library""" # How many dimensions. rank = self.get_var_rank(name) # The shape array is fixed size shape = np.empty((MAXDIMS, ), dtype='int32', order='F') shape = self.get_var_shape(name) # there should be no...
[ "def", "get_var", "(", "self", ",", "name", ")", ":", "# How many dimensions.", "rank", "=", "self", ".", "get_var_rank", "(", "name", ")", "# The shape array is fixed size", "shape", "=", "np", ".", "empty", "(", "(", "MAXDIMS", ",", ")", ",", "dtype", "=...
Return an nd array from model library
[ "Return", "an", "nd", "array", "from", "model", "library" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L572-L617
train
64,525
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.set_logger
def set_logger(self, logger): """subscribe to fortran log messages""" # we don't expect anything back try: self.library.set_logger.restype = None except AttributeError: logger.warn("Tried to set logger but method is not implemented in %s", self.engine) ...
python
def set_logger(self, logger): """subscribe to fortran log messages""" # we don't expect anything back try: self.library.set_logger.restype = None except AttributeError: logger.warn("Tried to set logger but method is not implemented in %s", self.engine) ...
[ "def", "set_logger", "(", "self", ",", "logger", ")", ":", "# we don't expect anything back", "try", ":", "self", ".", "library", ".", "set_logger", ".", "restype", "=", "None", "except", "AttributeError", ":", "logger", ".", "warn", "(", "\"Tried to set logger ...
subscribe to fortran log messages
[ "subscribe", "to", "fortran", "log", "messages" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L686-L699
train
64,526
openearth/bmi-python
bmi/wrapper.py
BMIWrapper.set_current_time
def set_current_time(self, current_time): """ sets current time of simulation """ current_time = c_double(current_time) try: self.library.set_current_time.argtypes = [POINTER(c_double)] self.library.set_current_time.restype = None self.library....
python
def set_current_time(self, current_time): """ sets current time of simulation """ current_time = c_double(current_time) try: self.library.set_current_time.argtypes = [POINTER(c_double)] self.library.set_current_time.restype = None self.library....
[ "def", "set_current_time", "(", "self", ",", "current_time", ")", ":", "current_time", "=", "c_double", "(", "current_time", ")", "try", ":", "self", ".", "library", ".", "set_current_time", ".", "argtypes", "=", "[", "POINTER", "(", "c_double", ")", "]", ...
sets current time of simulation
[ "sets", "current", "time", "of", "simulation" ]
2f53f24d45515eb0711c2d28ddd6c1582045248f
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L701-L711
train
64,527
insomnia-lab/libreant
libreantdb/api.py
DB.setup_db
def setup_db(self, wait_for_ready=True): ''' Create and configure index If `wait_for_ready` is True, this function will block until status for `self.index_name` will be `yellow` ''' if self.es.indices.exists(self.index_name): try: self.update...
python
def setup_db(self, wait_for_ready=True): ''' Create and configure index If `wait_for_ready` is True, this function will block until status for `self.index_name` will be `yellow` ''' if self.es.indices.exists(self.index_name): try: self.update...
[ "def", "setup_db", "(", "self", ",", "wait_for_ready", "=", "True", ")", ":", "if", "self", ".", "es", ".", "indices", ".", "exists", "(", "self", ".", "index_name", ")", ":", "try", ":", "self", ".", "update_mappings", "(", ")", "except", "MappingsExc...
Create and configure index If `wait_for_ready` is True, this function will block until status for `self.index_name` will be `yellow`
[ "Create", "and", "configure", "index" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L148-L169
train
64,528
insomnia-lab/libreant
libreantdb/api.py
DB.create_index
def create_index(self, indexname=None, index_conf=None): ''' Create the index Create the index with given configuration. If `indexname` is provided it will be used as the new index name instead of the class one (:py:attr:`DB.index_name`) :param index_conf: confi...
python
def create_index(self, indexname=None, index_conf=None): ''' Create the index Create the index with given configuration. If `indexname` is provided it will be used as the new index name instead of the class one (:py:attr:`DB.index_name`) :param index_conf: confi...
[ "def", "create_index", "(", "self", ",", "indexname", "=", "None", ",", "index_conf", "=", "None", ")", ":", "if", "indexname", "is", "None", ":", "indexname", "=", "self", ".", "index_name", "log", ".", "debug", "(", "\"Creating new index: '{0}'\"", ".", ...
Create the index Create the index with given configuration. If `indexname` is provided it will be used as the new index name instead of the class one (:py:attr:`DB.index_name`) :param index_conf: configuration to be used in index creation. If this ...
[ "Create", "the", "index" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L186-L209
train
64,529
insomnia-lab/libreant
libreantdb/api.py
DB.clone_index
def clone_index(self, new_indexname, index_conf=None): '''Clone current index All entries of the current index will be copied into the newly created one named `new_indexname` :param index_conf: Configuration to be used in the new index creation. T...
python
def clone_index(self, new_indexname, index_conf=None): '''Clone current index All entries of the current index will be copied into the newly created one named `new_indexname` :param index_conf: Configuration to be used in the new index creation. T...
[ "def", "clone_index", "(", "self", ",", "new_indexname", ",", "index_conf", "=", "None", ")", ":", "log", ".", "debug", "(", "\"Cloning index '{}' into '{}'\"", ".", "format", "(", "self", ".", "index_name", ",", "new_indexname", ")", ")", "self", ".", "crea...
Clone current index All entries of the current index will be copied into the newly created one named `new_indexname` :param index_conf: Configuration to be used in the new index creation. This param will be passed directly to :py:func:`DB.create_index`
[ "Clone", "current", "index" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L211-L222
train
64,530
insomnia-lab/libreant
libreantdb/api.py
DB.reindex
def reindex(self, new_index=None, index_conf=None): '''Rebuilt the current index This function could be useful in the case you want to change some index settings/mappings and you don't want to loose all the entries belonging to that index. This function is built in such a way ...
python
def reindex(self, new_index=None, index_conf=None): '''Rebuilt the current index This function could be useful in the case you want to change some index settings/mappings and you don't want to loose all the entries belonging to that index. This function is built in such a way ...
[ "def", "reindex", "(", "self", ",", "new_index", "=", "None", ",", "index_conf", "=", "None", ")", ":", "alias", "=", "self", ".", "index_name", "if", "self", ".", "es", ".", "indices", ".", "exists_alias", "(", "name", "=", "self", ".", "index_name", ...
Rebuilt the current index This function could be useful in the case you want to change some index settings/mappings and you don't want to loose all the entries belonging to that index. This function is built in such a way that you can continue to use the old index name, thi...
[ "Rebuilt", "the", "current", "index" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L224-L277
train
64,531
insomnia-lab/libreant
libreantdb/api.py
DB.mlt
def mlt(self, _id): ''' High-level method to do "more like this". Its exact implementation can vary. ''' query = { 'query': {'more_like_this': { 'like': {'_id': _id}, 'min_term_freq': 1, 'min_doc_freq'...
python
def mlt(self, _id): ''' High-level method to do "more like this". Its exact implementation can vary. ''' query = { 'query': {'more_like_this': { 'like': {'_id': _id}, 'min_term_freq': 1, 'min_doc_freq'...
[ "def", "mlt", "(", "self", ",", "_id", ")", ":", "query", "=", "{", "'query'", ":", "{", "'more_like_this'", ":", "{", "'like'", ":", "{", "'_id'", ":", "_id", "}", ",", "'min_term_freq'", ":", "1", ",", "'min_doc_freq'", ":", "1", ",", "}", "}", ...
High-level method to do "more like this". Its exact implementation can vary.
[ "High", "-", "level", "method", "to", "do", "more", "like", "this", "." ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L296-L313
train
64,532
insomnia-lab/libreant
libreantdb/api.py
DB.file_is_attached
def file_is_attached(self, url): '''return true if at least one book has file with the given url as attachment ''' body = self._get_search_field('_attachments.url', url) return self.es.count(index=self.index_name, body=body)['count'] > 0
python
def file_is_attached(self, url): '''return true if at least one book has file with the given url as attachment ''' body = self._get_search_field('_attachments.url', url) return self.es.count(index=self.index_name, body=body)['count'] > 0
[ "def", "file_is_attached", "(", "self", ",", "url", ")", ":", "body", "=", "self", ".", "_get_search_field", "(", "'_attachments.url'", ",", "url", ")", "return", "self", ".", "es", ".", "count", "(", "index", "=", "self", ".", "index_name", ",", "body",...
return true if at least one book has file with the given url as attachment
[ "return", "true", "if", "at", "least", "one", "book", "has", "file", "with", "the", "given", "url", "as", "attachment" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L352-L357
train
64,533
insomnia-lab/libreant
libreantdb/api.py
DB.delete_all
def delete_all(self): '''Delete all books from the index''' def delete_action_gen(): scanner = scan(self.es, index=self.index_name, query={'query': {'match_all':{}}}) for v in scanner: yield { '_op_type': 'dele...
python
def delete_all(self): '''Delete all books from the index''' def delete_action_gen(): scanner = scan(self.es, index=self.index_name, query={'query': {'match_all':{}}}) for v in scanner: yield { '_op_type': 'dele...
[ "def", "delete_all", "(", "self", ")", ":", "def", "delete_action_gen", "(", ")", ":", "scanner", "=", "scan", "(", "self", ".", "es", ",", "index", "=", "self", ".", "index_name", ",", "query", "=", "{", "'query'", ":", "{", "'match_all'", ":", "{",...
Delete all books from the index
[ "Delete", "all", "books", "from", "the", "index" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L379-L391
train
64,534
insomnia-lab/libreant
libreantdb/api.py
DB.update_book
def update_book(self, id, body, doc_type='book'): ''' Update a book The "body" is merged with the current one. Yes, it is NOT overwritten. In case of concurrency conflict this function could raise `elasticsearch.ConflictError` ''' # note that we ...
python
def update_book(self, id, body, doc_type='book'): ''' Update a book The "body" is merged with the current one. Yes, it is NOT overwritten. In case of concurrency conflict this function could raise `elasticsearch.ConflictError` ''' # note that we ...
[ "def", "update_book", "(", "self", ",", "id", ",", "body", ",", "doc_type", "=", "'book'", ")", ":", "# note that we are NOT overwriting all the _source, just merging", "book", "=", "self", ".", "get_book_by_id", "(", "id", ")", "book", "[", "'_source'", "]", "....
Update a book The "body" is merged with the current one. Yes, it is NOT overwritten. In case of concurrency conflict this function could raise `elasticsearch.ConflictError`
[ "Update", "a", "book" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L393-L408
train
64,535
insomnia-lab/libreant
libreantdb/api.py
DB.modify_book
def modify_book(self, id, body, doc_type='book', version=None): ''' replace the entire book body Instead of `update_book` this function will overwrite the book content with param body If param `version` is given, it will be checked that the changes are applied u...
python
def modify_book(self, id, body, doc_type='book', version=None): ''' replace the entire book body Instead of `update_book` this function will overwrite the book content with param body If param `version` is given, it will be checked that the changes are applied u...
[ "def", "modify_book", "(", "self", ",", "id", ",", "body", ",", "doc_type", "=", "'book'", ",", "version", "=", "None", ")", ":", "validatedBody", "=", "validate_book", "(", "body", ")", "params", "=", "dict", "(", "index", "=", "self", ".", "index_nam...
replace the entire book body Instead of `update_book` this function will overwrite the book content with param body If param `version` is given, it will be checked that the changes are applied upon that document version. If the document version provided is d...
[ "replace", "the", "entire", "book", "body" ]
55d529435baf4c05a86b8341899e9f5e14e50245
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/libreantdb/api.py#L410-L426
train
64,536
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
train
64,537
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
train
64,538
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
train
64,539
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
train
64,540
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
train
64,541
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
train
64,542
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
train
64,543
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
train
64,544
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
train
64,545
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
train
64,546
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
train
64,547
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
train
64,548
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
train
64,549
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
train
64,550
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
train
64,551
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
train
64,552
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
train
64,553
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
train
64,554
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
train
64,555
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
train
64,556
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
train
64,557
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
train
64,558
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
train
64,559
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
train
64,560
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
train
64,561
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
train
64,562
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
train
64,563
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
train
64,564
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
train
64,565
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
train
64,566
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
train
64,567
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
train
64,568
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
train
64,569
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
train
64,570
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
train
64,571
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
train
64,572
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
train
64,573
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
train
64,574
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
train
64,575
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
train
64,576
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
train
64,577
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
train
64,578
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
train
64,579
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
train
64,580
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
train
64,581
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
train
64,582
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
train
64,583
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
train
64,584
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
train
64,585
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
train
64,586
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
train
64,587
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
train
64,588
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
train
64,589
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
train
64,590
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
train
64,591
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
train
64,592
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
train
64,593
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
train
64,594
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
train
64,595
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
train
64,596
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
train
64,597
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
train
64,598
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
train
64,599