repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
pedrotgn/pyactor | pyactor/green_thread/future.py | Future.result | def result(self, timeout=None):
"""Returns the result of the call that the future represents.
:param timeout: The number of seconds to wait for the result
if the future has not been completed. None, the default,
sets no limit.
:returns: The result of the call that the fu... | python | def result(self, timeout=None):
"""Returns the result of the call that the future represents.
:param timeout: The number of seconds to wait for the result
if the future has not been completed. None, the default,
sets no limit.
:returns: The result of the call that the fu... | [
"def",
"result",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"# with self.__condition:",
"if",
"self",
".",
"__state",
"==",
"FINISHED",
":",
"return",
"self",
".",
"__get__result",
"(",
")",
"self",
".",
"__condition",
".",
"wait",
"(",
"timeout",... | Returns the result of the call that the future represents.
:param timeout: The number of seconds to wait for the result
if the future has not been completed. None, the default,
sets no limit.
:returns: The result of the call that the future represents.
:raises: TimeoutEr... | [
"Returns",
"the",
"result",
"of",
"the",
"call",
"that",
"the",
"future",
"represents",
"."
] | 24d98d134dd4228f2ba38e83611e9c3f50ec2fd4 | https://github.com/pedrotgn/pyactor/blob/24d98d134dd4228f2ba38e83611e9c3f50ec2fd4/pyactor/green_thread/future.py#L92-L112 | train | Returns the result of the call that the future represents. |
pedrotgn/pyactor | pyactor/green_thread/future.py | Future.exception | def exception(self, timeout=None):
"""Return a exception raised by the call that the future
represents.
:param timeout: The number of seconds to wait for the exception
if the future has not been completed. None, the default,
sets no limit.
:returns: The exception ... | python | def exception(self, timeout=None):
"""Return a exception raised by the call that the future
represents.
:param timeout: The number of seconds to wait for the exception
if the future has not been completed. None, the default,
sets no limit.
:returns: The exception ... | [
"def",
"exception",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"# with self.__condition:",
"if",
"self",
".",
"__state",
"==",
"FINISHED",
":",
"return",
"self",
".",
"__exception",
"self",
".",
"__condition",
".",
"wait",
"(",
"timeout",
")",
"if... | Return a exception raised by the call that the future
represents.
:param timeout: The number of seconds to wait for the exception
if the future has not been completed. None, the default,
sets no limit.
:returns: The exception raised by the call that the future
... | [
"Return",
"a",
"exception",
"raised",
"by",
"the",
"call",
"that",
"the",
"future",
"represents",
".",
":",
"param",
"timeout",
":",
"The",
"number",
"of",
"seconds",
"to",
"wait",
"for",
"the",
"exception",
"if",
"the",
"future",
"has",
"not",
"been",
"... | 24d98d134dd4228f2ba38e83611e9c3f50ec2fd4 | https://github.com/pedrotgn/pyactor/blob/24d98d134dd4228f2ba38e83611e9c3f50ec2fd4/pyactor/green_thread/future.py#L114-L134 | train | Return a exception raised by the future that the future has not completed. |
CI-WATER/gsshapy | gsshapy/orm/msk.py | WatershedMaskFile.generateFromWatershedShapefile | def generateFromWatershedShapefile(self,
shapefile_path,
cell_size,
out_raster_path=None,
load_raster_to_db=True):
"""
Generates a mask from a water... | python | def generateFromWatershedShapefile(self,
shapefile_path,
cell_size,
out_raster_path=None,
load_raster_to_db=True):
"""
Generates a mask from a water... | [
"def",
"generateFromWatershedShapefile",
"(",
"self",
",",
"shapefile_path",
",",
"cell_size",
",",
"out_raster_path",
"=",
"None",
",",
"load_raster_to_db",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"projectFile",
":",
"raise",
"ValueError",
"(",
"\"Must... | Generates a mask from a watershed_shapefile
Example::
from gsshapy.orm import ProjectFile, WatershedMaskFile
from gsshapy.lib import db_tools as dbt
gssha_directory = '/gsshapy/tests/grid_standard/gssha_project'
shapefile_path = 'watershed_boundary.shp'
... | [
"Generates",
"a",
"mask",
"from",
"a",
"watershed_shapefile"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/msk.py#L45-L143 | train | Generate a mask from a watershed shapefile. |
CI-WATER/gsshapy | gsshapy/util/context.py | tmp_chdir | def tmp_chdir(new_path):
"""Change directory temporarily and return when done."""
prev_cwd = os.getcwd()
os.chdir(new_path)
try:
yield
finally:
os.chdir(prev_cwd) | python | def tmp_chdir(new_path):
"""Change directory temporarily and return when done."""
prev_cwd = os.getcwd()
os.chdir(new_path)
try:
yield
finally:
os.chdir(prev_cwd) | [
"def",
"tmp_chdir",
"(",
"new_path",
")",
":",
"prev_cwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"new_path",
")",
"try",
":",
"yield",
"finally",
":",
"os",
".",
"chdir",
"(",
"prev_cwd",
")"
] | Change directory temporarily and return when done. | [
"Change",
"directory",
"temporarily",
"and",
"return",
"when",
"done",
"."
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/util/context.py#L13-L20 | train | Change directory temporarily and return when done. |
CI-WATER/gsshapy | gsshapy/grid/era_to_gssha.py | download_era5_for_gssha | def download_era5_for_gssha(main_directory,
start_datetime,
end_datetime,
leftlon=-180,
rightlon=180,
toplat=90,
bottomlat=-90,
... | python | def download_era5_for_gssha(main_directory,
start_datetime,
end_datetime,
leftlon=-180,
rightlon=180,
toplat=90,
bottomlat=-90,
... | [
"def",
"download_era5_for_gssha",
"(",
"main_directory",
",",
"start_datetime",
",",
"end_datetime",
",",
"leftlon",
"=",
"-",
"180",
",",
"rightlon",
"=",
"180",
",",
"toplat",
"=",
"90",
",",
"bottomlat",
"=",
"-",
"90",
",",
"precip_only",
"=",
"False",
... | Function to download ERA5 data for GSSHA
.. note:: https://software.ecmwf.int/wiki/display/WEBAPI/Access+ECMWF+Public+Datasets
Args:
main_directory(:obj:`str`): Location of the output for the forecast data.
start_datetime(:obj:`str`): Datetime for download start.
end_datetime(:obj:`str... | [
"Function",
"to",
"download",
"ERA5",
"data",
"for",
"GSSHA"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/grid/era_to_gssha.py#L22-L146 | train | Function to download ERA5 data for GSSHA specific time range. |
CI-WATER/gsshapy | gsshapy/grid/era_to_gssha.py | download_interim_for_gssha | def download_interim_for_gssha(main_directory,
start_datetime,
end_datetime,
leftlon=-180,
rightlon=180,
toplat=90,
bottomlat=-90,
... | python | def download_interim_for_gssha(main_directory,
start_datetime,
end_datetime,
leftlon=-180,
rightlon=180,
toplat=90,
bottomlat=-90,
... | [
"def",
"download_interim_for_gssha",
"(",
"main_directory",
",",
"start_datetime",
",",
"end_datetime",
",",
"leftlon",
"=",
"-",
"180",
",",
"rightlon",
"=",
"180",
",",
"toplat",
"=",
"90",
",",
"bottomlat",
"=",
"-",
"90",
",",
"precip_only",
"=",
"False"... | Function to download ERA5 data for GSSHA
.. note:: https://software.ecmwf.int/wiki/display/WEBAPI/Access+ECMWF+Public+Datasets
Args:
main_directory(:obj:`str`): Location of the output for the forecast data.
start_datetime(:obj:`str`): Datetime for download start.
end_datetime(:obj:`str... | [
"Function",
"to",
"download",
"ERA5",
"data",
"for",
"GSSHA"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/grid/era_to_gssha.py#L149-L283 | train | Function to download ERA5 data for GSSHA and return a list of the objects in the main_directory. |
CI-WATER/gsshapy | gsshapy/grid/era_to_gssha.py | ERAtoGSSHA._download | def _download(self):
"""download ERA5 data for GSSHA domain"""
# reproject GSSHA grid and get bounds
min_x, max_x, min_y, max_y = self.gssha_grid.bounds(as_geographic=True)
if self.era_download_data == 'era5':
log.info("Downloading ERA5 data ...")
download_era5_fo... | python | def _download(self):
"""download ERA5 data for GSSHA domain"""
# reproject GSSHA grid and get bounds
min_x, max_x, min_y, max_y = self.gssha_grid.bounds(as_geographic=True)
if self.era_download_data == 'era5':
log.info("Downloading ERA5 data ...")
download_era5_fo... | [
"def",
"_download",
"(",
"self",
")",
":",
"# reproject GSSHA grid and get bounds",
"min_x",
",",
"max_x",
",",
"min_y",
",",
"max_y",
"=",
"self",
".",
"gssha_grid",
".",
"bounds",
"(",
"as_geographic",
"=",
"True",
")",
"if",
"self",
".",
"era_download_data"... | download ERA5 data for GSSHA domain | [
"download",
"ERA5",
"data",
"for",
"GSSHA",
"domain"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/grid/era_to_gssha.py#L381-L402 | train | Download ERA5 data for GSSHA domain. |
CI-WATER/gsshapy | gsshapy/grid/era_to_gssha.py | ERAtoGSSHA.xd | def xd(self):
"""get xarray dataset file handle to LSM files"""
if self._xd is None:
# download files if the user requests
if None not in (self.download_start_datetime, self.download_end_datetime):
self._download()
self._xd = super(ERAtoGSSHA, self).x... | python | def xd(self):
"""get xarray dataset file handle to LSM files"""
if self._xd is None:
# download files if the user requests
if None not in (self.download_start_datetime, self.download_end_datetime):
self._download()
self._xd = super(ERAtoGSSHA, self).x... | [
"def",
"xd",
"(",
"self",
")",
":",
"if",
"self",
".",
"_xd",
"is",
"None",
":",
"# download files if the user requests",
"if",
"None",
"not",
"in",
"(",
"self",
".",
"download_start_datetime",
",",
"self",
".",
"download_end_datetime",
")",
":",
"self",
"."... | get xarray dataset file handle to LSM files | [
"get",
"xarray",
"dataset",
"file",
"handle",
"to",
"LSM",
"files"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/grid/era_to_gssha.py#L405-L414 | train | get xarray dataset file handle to LSM files |
CI-WATER/gsshapy | gsshapy/grid/era_to_gssha.py | ERAtoGSSHA._load_converted_gssha_data_from_lsm | def _load_converted_gssha_data_from_lsm(self, gssha_var, lsm_var, load_type, time_step=None):
"""
This function loads data from LSM and converts to GSSHA format
"""
super(ERAtoGSSHA, self).\
_load_converted_gssha_data_from_lsm(gssha_var, lsm_var, load_type, time_step)
... | python | def _load_converted_gssha_data_from_lsm(self, gssha_var, lsm_var, load_type, time_step=None):
"""
This function loads data from LSM and converts to GSSHA format
"""
super(ERAtoGSSHA, self).\
_load_converted_gssha_data_from_lsm(gssha_var, lsm_var, load_type, time_step)
... | [
"def",
"_load_converted_gssha_data_from_lsm",
"(",
"self",
",",
"gssha_var",
",",
"lsm_var",
",",
"load_type",
",",
"time_step",
"=",
"None",
")",
":",
"super",
"(",
"ERAtoGSSHA",
",",
"self",
")",
".",
"_load_converted_gssha_data_from_lsm",
"(",
"gssha_var",
",",... | This function loads data from LSM and converts to GSSHA format | [
"This",
"function",
"loads",
"data",
"from",
"LSM",
"and",
"converts",
"to",
"GSSHA",
"format"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/grid/era_to_gssha.py#L416-L422 | train | This function loads data from LSM and converts to GSSHA format |
pedrotgn/pyactor | pyactor/green_thread/intervals.py | later | def later(timeout, f, *args, **kwargs):
'''
Sets a timer that will call the *f* function past *timeout* seconds.
See example in :ref:`sample_inter`
:return: :class:`Greenlet` new 'thread' which will perform the call
when specified.
'''
def wrap(*args, **kwargs):
sleep(timeout)
... | python | def later(timeout, f, *args, **kwargs):
'''
Sets a timer that will call the *f* function past *timeout* seconds.
See example in :ref:`sample_inter`
:return: :class:`Greenlet` new 'thread' which will perform the call
when specified.
'''
def wrap(*args, **kwargs):
sleep(timeout)
... | [
"def",
"later",
"(",
"timeout",
",",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"wrap",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"sleep",
"(",
"timeout",
")",
"return",
"f",
"(",
"*",
"args",
",",
"*",
"*",
... | Sets a timer that will call the *f* function past *timeout* seconds.
See example in :ref:`sample_inter`
:return: :class:`Greenlet` new 'thread' which will perform the call
when specified. | [
"Sets",
"a",
"timer",
"that",
"will",
"call",
"the",
"*",
"f",
"*",
"function",
"past",
"*",
"timeout",
"*",
"seconds",
"."
] | 24d98d134dd4228f2ba38e83611e9c3f50ec2fd4 | https://github.com/pedrotgn/pyactor/blob/24d98d134dd4228f2ba38e83611e9c3f50ec2fd4/pyactor/green_thread/intervals.py#L14-L27 | train | Sets a timer that will call the f function past timeout seconds. |
pedrotgn/pyactor | pyactor/green_thread/intervals.py | interval_host | def interval_host(host, time, f, *args, **kwargs):
'''
Creates an Event attached to the *host* for management that will
execute the *f* function every *time* seconds.
See example in :ref:`sample_inter`
:param Proxy host: proxy of the host. Can be obtained from inside a
class with ``self.ho... | python | def interval_host(host, time, f, *args, **kwargs):
'''
Creates an Event attached to the *host* for management that will
execute the *f* function every *time* seconds.
See example in :ref:`sample_inter`
:param Proxy host: proxy of the host. Can be obtained from inside a
class with ``self.ho... | [
"def",
"interval_host",
"(",
"host",
",",
"time",
",",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"wrap",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"thread",
"=",
"getcurrent",
"(",
")",
"args",
"=",
"list",
"("... | Creates an Event attached to the *host* for management that will
execute the *f* function every *time* seconds.
See example in :ref:`sample_inter`
:param Proxy host: proxy of the host. Can be obtained from inside a
class with ``self.host``.
:param int time: seconds for the intervals.
:para... | [
"Creates",
"an",
"Event",
"attached",
"to",
"the",
"*",
"host",
"*",
"for",
"management",
"that",
"will",
"execute",
"the",
"*",
"f",
"*",
"function",
"every",
"*",
"time",
"*",
"seconds",
"."
] | 24d98d134dd4228f2ba38e83611e9c3f50ec2fd4 | https://github.com/pedrotgn/pyactor/blob/24d98d134dd4228f2ba38e83611e9c3f50ec2fd4/pyactor/green_thread/intervals.py#L30-L61 | train | Create an Event attached to the host for management that will execute the function f every time seconds. |
hellupline/flask-manager | flask_manager/views.py | View.dispatch_request | def dispatch_request(self, *args, **kwargs):
"""Dispatch the request.
Its the actual ``view`` flask will use.
"""
if request.method in ('POST', 'PUT'):
return_url, context = self.post(*args, **kwargs)
if return_url is not None:
return redirect(retu... | python | def dispatch_request(self, *args, **kwargs):
"""Dispatch the request.
Its the actual ``view`` flask will use.
"""
if request.method in ('POST', 'PUT'):
return_url, context = self.post(*args, **kwargs)
if return_url is not None:
return redirect(retu... | [
"def",
"dispatch_request",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"request",
".",
"method",
"in",
"(",
"'POST'",
",",
"'PUT'",
")",
":",
"return_url",
",",
"context",
"=",
"self",
".",
"post",
"(",
"*",
"args",
",",... | Dispatch the request.
Its the actual ``view`` flask will use. | [
"Dispatch",
"the",
"request",
".",
"Its",
"the",
"actual",
"view",
"flask",
"will",
"use",
"."
] | 70e48309f73aacf55f5c37b43165791ae1cf6861 | https://github.com/hellupline/flask-manager/blob/70e48309f73aacf55f5c37b43165791ae1cf6861/flask_manager/views.py#L21-L31 | train | Dispatch the request. |
bayesimpact/fex | fex/runner.py | _run_cmd_get_output | def _run_cmd_get_output(cmd):
"""Runs a shell command, returns console output.
Mimics python3's subprocess.getoutput
"""
process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
out, err = process.communicate()
return out or err | python | def _run_cmd_get_output(cmd):
"""Runs a shell command, returns console output.
Mimics python3's subprocess.getoutput
"""
process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
out, err = process.communicate()
return out or err | [
"def",
"_run_cmd_get_output",
"(",
"cmd",
")",
":",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"cmd",
".",
"split",
"(",
")",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
"out",
",",
"err",
"=",
"process",
".",
"communicate",
"(",
")",
"... | Runs a shell command, returns console output.
Mimics python3's subprocess.getoutput | [
"Runs",
"a",
"shell",
"command",
"returns",
"console",
"output",
"."
] | 2d9b4e9be2bf98847a36055b907411fd5557eb77 | https://github.com/bayesimpact/fex/blob/2d9b4e9be2bf98847a36055b907411fd5557eb77/fex/runner.py#L15-L22 | train | Runs a shell command returns console output. |
bayesimpact/fex | fex/runner.py | _remote_github_url_to_string | def _remote_github_url_to_string(remote_url):
"""Parse out the repository identifier from a github URL."""
# TODO: make this work with https URLs
match = re.search('git@github\.com:(.*)\.git', remote_url)
if not match:
raise EnvironmentError('Remote is not a valid github URL')
identifier = m... | python | def _remote_github_url_to_string(remote_url):
"""Parse out the repository identifier from a github URL."""
# TODO: make this work with https URLs
match = re.search('git@github\.com:(.*)\.git', remote_url)
if not match:
raise EnvironmentError('Remote is not a valid github URL')
identifier = m... | [
"def",
"_remote_github_url_to_string",
"(",
"remote_url",
")",
":",
"# TODO: make this work with https URLs",
"match",
"=",
"re",
".",
"search",
"(",
"'git@github\\.com:(.*)\\.git'",
",",
"remote_url",
")",
"if",
"not",
"match",
":",
"raise",
"EnvironmentError",
"(",
... | Parse out the repository identifier from a github URL. | [
"Parse",
"out",
"the",
"repository",
"identifier",
"from",
"a",
"github",
"URL",
"."
] | 2d9b4e9be2bf98847a36055b907411fd5557eb77 | https://github.com/bayesimpact/fex/blob/2d9b4e9be2bf98847a36055b907411fd5557eb77/fex/runner.py#L25-L32 | train | Parse out the repository identifier from a github URL. |
bayesimpact/fex | fex/runner.py | _get_args | def _get_args(args):
"""Argparse logic lives here.
returns: parsed arguments.
"""
parser = argparse.ArgumentParser(
description='A tool to extract features into a simple format.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument('--no-cache', action=... | python | def _get_args(args):
"""Argparse logic lives here.
returns: parsed arguments.
"""
parser = argparse.ArgumentParser(
description='A tool to extract features into a simple format.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument('--no-cache', action=... | [
"def",
"_get_args",
"(",
"args",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'A tool to extract features into a simple format.'",
",",
"formatter_class",
"=",
"argparse",
".",
"ArgumentDefaultsHelpFormatter",
",",
")",
"parser",... | Argparse logic lives here.
returns: parsed arguments. | [
"Argparse",
"logic",
"lives",
"here",
"."
] | 2d9b4e9be2bf98847a36055b907411fd5557eb77 | https://github.com/bayesimpact/fex/blob/2d9b4e9be2bf98847a36055b907411fd5557eb77/fex/runner.py#L75-L93 | train | Parse command line arguments. |
bayesimpact/fex | fex/runner.py | run | def run(*extractor_list, **kwargs):
"""Parse arguments provided on the commandline and execute extractors."""
args = _get_args(kwargs.get('args'))
n_extractors = len(extractor_list)
log.info('Going to run list of {} FeatureExtractors'.format(n_extractors))
collection = fex.Collection(cache_path=args... | python | def run(*extractor_list, **kwargs):
"""Parse arguments provided on the commandline and execute extractors."""
args = _get_args(kwargs.get('args'))
n_extractors = len(extractor_list)
log.info('Going to run list of {} FeatureExtractors'.format(n_extractors))
collection = fex.Collection(cache_path=args... | [
"def",
"run",
"(",
"*",
"extractor_list",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"_get_args",
"(",
"kwargs",
".",
"get",
"(",
"'args'",
")",
")",
"n_extractors",
"=",
"len",
"(",
"extractor_list",
")",
"log",
".",
"info",
"(",
"'Going to run l... | Parse arguments provided on the commandline and execute extractors. | [
"Parse",
"arguments",
"provided",
"on",
"the",
"commandline",
"and",
"execute",
"extractors",
"."
] | 2d9b4e9be2bf98847a36055b907411fd5557eb77 | https://github.com/bayesimpact/fex/blob/2d9b4e9be2bf98847a36055b907411fd5557eb77/fex/runner.py#L110-L122 | train | Parse arguments provided on the commandline and execute extractors. |
CI-WATER/gsshapy | gsshapy/orm/map.py | RasterMapFile._delete_existing | def _delete_existing(self, project_file, session):
"""
This will delete existing instances with the same extension
"""
# remove existing grid if exists
existing_elev = session.query(RasterMapFile).\
filter(RasterMapFile.projectFile == project... | python | def _delete_existing(self, project_file, session):
"""
This will delete existing instances with the same extension
"""
# remove existing grid if exists
existing_elev = session.query(RasterMapFile).\
filter(RasterMapFile.projectFile == project... | [
"def",
"_delete_existing",
"(",
"self",
",",
"project_file",
",",
"session",
")",
":",
"# remove existing grid if exists",
"existing_elev",
"=",
"session",
".",
"query",
"(",
"RasterMapFile",
")",
".",
"filter",
"(",
"RasterMapFile",
".",
"projectFile",
"==",
"pro... | This will delete existing instances with the same extension | [
"This",
"will",
"delete",
"existing",
"instances",
"with",
"the",
"same",
"extension"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/map.py#L81-L92 | train | This will delete existing instances with the same extension |
CI-WATER/gsshapy | gsshapy/orm/map.py | RasterMapFile._load_raster_text | def _load_raster_text(self, raster_path):
"""
Loads grass ASCII to object
"""
# Open file and read plain text into text field
with open(raster_path, 'r') as f:
self.rasterText = f.read()
# Retrieve metadata from header
lines = self.rasterText.split('\... | python | def _load_raster_text(self, raster_path):
"""
Loads grass ASCII to object
"""
# Open file and read plain text into text field
with open(raster_path, 'r') as f:
self.rasterText = f.read()
# Retrieve metadata from header
lines = self.rasterText.split('\... | [
"def",
"_load_raster_text",
"(",
"self",
",",
"raster_path",
")",
":",
"# Open file and read plain text into text field",
"with",
"open",
"(",
"raster_path",
",",
"'r'",
")",
"as",
"f",
":",
"self",
".",
"rasterText",
"=",
"f",
".",
"read",
"(",
")",
"# Retrie... | Loads grass ASCII to object | [
"Loads",
"grass",
"ASCII",
"to",
"object"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/map.py#L94-L118 | train | Loads the raster text into the object. |
CI-WATER/gsshapy | gsshapy/orm/map.py | RasterMapFile._read | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
"""
Raster Map File Read from File Method
"""
# Assign file extension attribute to file object
self.fileExtension = extension
self.filename = filename
... | python | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
"""
Raster Map File Read from File Method
"""
# Assign file extension attribute to file object
self.fileExtension = extension
self.filename = filename
... | [
"def",
"_read",
"(",
"self",
",",
"directory",
",",
"filename",
",",
"session",
",",
"path",
",",
"name",
",",
"extension",
",",
"spatial",
",",
"spatialReferenceID",
",",
"replaceParamFile",
")",
":",
"# Assign file extension attribute to file object",
"self",
".... | Raster Map File Read from File Method | [
"Raster",
"Map",
"File",
"Read",
"from",
"File",
"Method"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/map.py#L120-L136 | train | Read from File Method |
CI-WATER/gsshapy | gsshapy/orm/map.py | RasterMapFile._write | def _write(self, session, openFile, replaceParamFile):
"""
Raster Map File Write to File Method
"""
# If the raster field is not empty, write from this field
if self.raster is not None:
# Configure RasterConverter
converter = RasterConverter(session)
... | python | def _write(self, session, openFile, replaceParamFile):
"""
Raster Map File Write to File Method
"""
# If the raster field is not empty, write from this field
if self.raster is not None:
# Configure RasterConverter
converter = RasterConverter(session)
... | [
"def",
"_write",
"(",
"self",
",",
"session",
",",
"openFile",
",",
"replaceParamFile",
")",
":",
"# If the raster field is not empty, write from this field",
"if",
"self",
".",
"raster",
"is",
"not",
"None",
":",
"# Configure RasterConverter",
"converter",
"=",
"Rast... | Raster Map File Write to File Method | [
"Raster",
"Map",
"File",
"Write",
"to",
"File",
"Method"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/map.py#L138-L157 | train | Method to write to the Raster Map File Method to write to File Method to replace paramFile |
hellupline/flask-manager | flask_manager/utils.py | concat_urls | def concat_urls(*urls):
"""Concat Urls
Args:
*args: (str)
Returns:
str: urls starting and ending with / merged with /
"""
normalized_urls = filter(bool, [url.strip('/') for url in urls])
joined_urls = '/'.join(normalized_urls)
if not joined_urls:
return '/'
retur... | python | def concat_urls(*urls):
"""Concat Urls
Args:
*args: (str)
Returns:
str: urls starting and ending with / merged with /
"""
normalized_urls = filter(bool, [url.strip('/') for url in urls])
joined_urls = '/'.join(normalized_urls)
if not joined_urls:
return '/'
retur... | [
"def",
"concat_urls",
"(",
"*",
"urls",
")",
":",
"normalized_urls",
"=",
"filter",
"(",
"bool",
",",
"[",
"url",
".",
"strip",
"(",
"'/'",
")",
"for",
"url",
"in",
"urls",
"]",
")",
"joined_urls",
"=",
"'/'",
".",
"join",
"(",
"normalized_urls",
")"... | Concat Urls
Args:
*args: (str)
Returns:
str: urls starting and ending with / merged with / | [
"Concat",
"Urls",
"Args",
":",
"*",
"args",
":",
"(",
"str",
")"
] | 70e48309f73aacf55f5c37b43165791ae1cf6861 | https://github.com/hellupline/flask-manager/blob/70e48309f73aacf55f5c37b43165791ae1cf6861/flask_manager/utils.py#L8-L20 | train | Concat urls with a single slash |
hellupline/flask-manager | flask_manager/utils.py | slugify | def slugify(value):
"""Simple Slugify."""
s1 = first_cap_re.sub(r'\1_\2', value)
s2 = all_cap_re.sub(r'\1_\2', s1)
return s2.lower().replace(' _', '_').replace(' ', '_') | python | def slugify(value):
"""Simple Slugify."""
s1 = first_cap_re.sub(r'\1_\2', value)
s2 = all_cap_re.sub(r'\1_\2', s1)
return s2.lower().replace(' _', '_').replace(' ', '_') | [
"def",
"slugify",
"(",
"value",
")",
":",
"s1",
"=",
"first_cap_re",
".",
"sub",
"(",
"r'\\1_\\2'",
",",
"value",
")",
"s2",
"=",
"all_cap_re",
".",
"sub",
"(",
"r'\\1_\\2'",
",",
"s1",
")",
"return",
"s2",
".",
"lower",
"(",
")",
".",
"replace",
"... | Simple Slugify. | [
"Simple",
"Slugify",
"."
] | 70e48309f73aacf55f5c37b43165791ae1cf6861 | https://github.com/hellupline/flask-manager/blob/70e48309f73aacf55f5c37b43165791ae1cf6861/flask_manager/utils.py#L23-L27 | train | Simple Slugify. |
dssg/argcmdr | src/argcmdr.py | init_package | def init_package(path=None, name='manage'):
"""Initialize (import) the submodules, and recursively the
subpackages, of a "manage" package at ``path``.
``path`` may be specified as either a system directory path or a
list of these.
If ``path`` is unspecified, it is inferred from the already-importe... | python | def init_package(path=None, name='manage'):
"""Initialize (import) the submodules, and recursively the
subpackages, of a "manage" package at ``path``.
``path`` may be specified as either a system directory path or a
list of these.
If ``path`` is unspecified, it is inferred from the already-importe... | [
"def",
"init_package",
"(",
"path",
"=",
"None",
",",
"name",
"=",
"'manage'",
")",
":",
"if",
"path",
"is",
"None",
":",
"manager",
"=",
"sys",
".",
"modules",
"[",
"name",
"]",
"init_package",
"(",
"manager",
".",
"__path__",
",",
"name",
")",
"ret... | Initialize (import) the submodules, and recursively the
subpackages, of a "manage" package at ``path``.
``path`` may be specified as either a system directory path or a
list of these.
If ``path`` is unspecified, it is inferred from the already-imported
"manage" top-level module. | [
"Initialize",
"(",
"import",
")",
"the",
"submodules",
"and",
"recursively",
"the",
"subpackages",
"of",
"a",
"manage",
"package",
"at",
"path",
"."
] | 346b6158987464c3d3a32d315f3800a4807744b4 | https://github.com/dssg/argcmdr/blob/346b6158987464c3d3a32d315f3800a4807744b4/src/argcmdr.py#L97-L119 | train | Initialize the submodules of a manage package at path. |
dssg/argcmdr | src/argcmdr.py | cmd | def cmd(*args, **kwargs):
"""Decorate a callable to replace it with a manufactured command
class.
Extends the interface of ``CommandDecorator``, allowing the same
``cmd`` to be used as a decorator or as a decorator factory::
@cmd(root=True)
def build():
...
@build.... | python | def cmd(*args, **kwargs):
"""Decorate a callable to replace it with a manufactured command
class.
Extends the interface of ``CommandDecorator``, allowing the same
``cmd`` to be used as a decorator or as a decorator factory::
@cmd(root=True)
def build():
...
@build.... | [
"def",
"cmd",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"(",
"first",
",",
"*",
"remainder",
")",
"=",
"args",
"except",
"ValueError",
":",
"pass",
"else",
":",
"if",
"callable",
"(",
"first",
")",
":",
"return",
"CommandDeco... | Decorate a callable to replace it with a manufactured command
class.
Extends the interface of ``CommandDecorator``, allowing the same
``cmd`` to be used as a decorator or as a decorator factory::
@cmd(root=True)
def build():
...
@build.register
@cmd
def... | [
"Decorate",
"a",
"callable",
"to",
"replace",
"it",
"with",
"a",
"manufactured",
"command",
"class",
"."
] | 346b6158987464c3d3a32d315f3800a4807744b4 | https://github.com/dssg/argcmdr/blob/346b6158987464c3d3a32d315f3800a4807744b4/src/argcmdr.py#L729-L757 | train | Decorator to replace a callable to replace it with a manufactured command
class. |
dssg/argcmdr | src/argcmdr.py | entrypoint | def entrypoint(cls):
"""Mark the decorated command as the intended entrypoint of the
command module.
"""
if not isinstance(cls, type) or not issubclass(cls, Command):
raise TypeError(f"inappropriate entrypoint instance of type {cls.__class__}")
cls._argcmdr_entrypoint_ = True
return cls | python | def entrypoint(cls):
"""Mark the decorated command as the intended entrypoint of the
command module.
"""
if not isinstance(cls, type) or not issubclass(cls, Command):
raise TypeError(f"inappropriate entrypoint instance of type {cls.__class__}")
cls._argcmdr_entrypoint_ = True
return cls | [
"def",
"entrypoint",
"(",
"cls",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
",",
"type",
")",
"or",
"not",
"issubclass",
"(",
"cls",
",",
"Command",
")",
":",
"raise",
"TypeError",
"(",
"f\"inappropriate entrypoint instance of type {cls.__class__}\"",
")",... | Mark the decorated command as the intended entrypoint of the
command module. | [
"Mark",
"the",
"decorated",
"command",
"as",
"the",
"intended",
"entrypoint",
"of",
"the",
"command",
"module",
"."
] | 346b6158987464c3d3a32d315f3800a4807744b4 | https://github.com/dssg/argcmdr/blob/346b6158987464c3d3a32d315f3800a4807744b4/src/argcmdr.py#L767-L775 | train | Mark the decorated command as the intended entrypoint of the
command module. |
dssg/argcmdr | src/argcmdr.py | store_env_override | def store_env_override(option_strings,
dest,
envvar,
nargs=None,
default=None,
type=None,
choices=None,
description=None,
help=None,
... | python | def store_env_override(option_strings,
dest,
envvar,
nargs=None,
default=None,
type=None,
choices=None,
description=None,
help=None,
... | [
"def",
"store_env_override",
"(",
"option_strings",
",",
"dest",
",",
"envvar",
",",
"nargs",
"=",
"None",
",",
"default",
"=",
"None",
",",
"type",
"=",
"None",
",",
"choices",
"=",
"None",
",",
"description",
"=",
"None",
",",
"help",
"=",
"None",
",... | Construct an argparse action which stores the value of a command
line option to override a corresponding value in the process
environment.
If the environment variable is not empty, then no override is
required. If the environment variable is empty, and no default is
provided, then the "option" is r... | [
"Construct",
"an",
"argparse",
"action",
"which",
"stores",
"the",
"value",
"of",
"a",
"command",
"line",
"option",
"to",
"override",
"a",
"corresponding",
"value",
"in",
"the",
"process",
"environment",
"."
] | 346b6158987464c3d3a32d315f3800a4807744b4 | https://github.com/dssg/argcmdr/blob/346b6158987464c3d3a32d315f3800a4807744b4/src/argcmdr.py#L785-L852 | train | Construct an argparse action which stores the value of a command - line option to override a corresponding value in the process
environment variable. |
robinandeer/puzzle | puzzle/plugins/base.py | Plugin.individual_dict | def individual_dict(self, ind_ids):
"""Return a dict with ind_id as key and Individual as values."""
ind_dict = {ind.ind_id: ind for ind in self.individuals(ind_ids=ind_ids)}
return ind_dict | python | def individual_dict(self, ind_ids):
"""Return a dict with ind_id as key and Individual as values."""
ind_dict = {ind.ind_id: ind for ind in self.individuals(ind_ids=ind_ids)}
return ind_dict | [
"def",
"individual_dict",
"(",
"self",
",",
"ind_ids",
")",
":",
"ind_dict",
"=",
"{",
"ind",
".",
"ind_id",
":",
"ind",
"for",
"ind",
"in",
"self",
".",
"individuals",
"(",
"ind_ids",
"=",
"ind_ids",
")",
"}",
"return",
"ind_dict"
] | Return a dict with ind_id as key and Individual as values. | [
"Return",
"a",
"dict",
"with",
"ind_id",
"as",
"key",
"and",
"Individual",
"as",
"values",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/base.py#L35-L38 | train | Return a dict with ind_id as key and Individual as values. |
robinandeer/puzzle | puzzle/plugins/base.py | GeneInfoMixin._get_genes | def _get_genes(self, variant):
"""Add the genes for a variant
Get the hgnc symbols from all transcripts and add them
to the variant.
Args:
variant (dict): A variant dictionary
Returns:
genes (list): A list of Genes
"""
transcripts = vari... | python | def _get_genes(self, variant):
"""Add the genes for a variant
Get the hgnc symbols from all transcripts and add them
to the variant.
Args:
variant (dict): A variant dictionary
Returns:
genes (list): A list of Genes
"""
transcripts = vari... | [
"def",
"_get_genes",
"(",
"self",
",",
"variant",
")",
":",
"transcripts",
"=",
"variant",
"[",
"'transcripts'",
"]",
"ensembl_ids",
"=",
"[",
"transcript",
"[",
"'ensembl_id'",
"]",
"for",
"transcript",
"in",
"transcripts",
"if",
"transcript",
"[",
"'ensembl_... | Add the genes for a variant
Get the hgnc symbols from all transcripts and add them
to the variant.
Args:
variant (dict): A variant dictionary
Returns:
genes (list): A list of Genes | [
"Add",
"the",
"genes",
"for",
"a",
"variant"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/base.py#L42-L60 | train | Get the genes from all transcripts and add them
to the variant. |
robinandeer/puzzle | tasks.py | clean | def clean():
"""clean - remove build artifacts."""
run('rm -rf build/')
run('rm -rf dist/')
run('rm -rf puzzle.egg-info')
run('find . -name __pycache__ -delete')
run('find . -name *.pyc -delete')
run('find . -name *.pyo -delete')
run('find . -name *~ -delete')
log.info('cleaned up') | python | def clean():
"""clean - remove build artifacts."""
run('rm -rf build/')
run('rm -rf dist/')
run('rm -rf puzzle.egg-info')
run('find . -name __pycache__ -delete')
run('find . -name *.pyc -delete')
run('find . -name *.pyo -delete')
run('find . -name *~ -delete')
log.info('cleaned up') | [
"def",
"clean",
"(",
")",
":",
"run",
"(",
"'rm -rf build/'",
")",
"run",
"(",
"'rm -rf dist/'",
")",
"run",
"(",
"'rm -rf puzzle.egg-info'",
")",
"run",
"(",
"'find . -name __pycache__ -delete'",
")",
"run",
"(",
"'find . -name *.pyc -delete'",
")",
"run",
"(",
... | clean - remove build artifacts. | [
"clean",
"-",
"remove",
"build",
"artifacts",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/tasks.py#L10-L20 | train | clean - remove build artifacts |
eleme/meepo | meepo/sub/zmq.py | zmq_sub | def zmq_sub(bind, tables, forwarder=False, green=False):
"""0mq fanout sub.
This sub will use zeromq to fanout the events.
:param bind: the zmq pub socket or zmq device socket.
:param tables: the events of tables to follow.
:param forwarder: set to True if zmq pub to a forwarder device.
:param... | python | def zmq_sub(bind, tables, forwarder=False, green=False):
"""0mq fanout sub.
This sub will use zeromq to fanout the events.
:param bind: the zmq pub socket or zmq device socket.
:param tables: the events of tables to follow.
:param forwarder: set to True if zmq pub to a forwarder device.
:param... | [
"def",
"zmq_sub",
"(",
"bind",
",",
"tables",
",",
"forwarder",
"=",
"False",
",",
"green",
"=",
"False",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"\"meepo.sub.zmq_sub\"",
")",
"if",
"not",
"isinstance",
"(",
"tables",
",",
"(",
"list",... | 0mq fanout sub.
This sub will use zeromq to fanout the events.
:param bind: the zmq pub socket or zmq device socket.
:param tables: the events of tables to follow.
:param forwarder: set to True if zmq pub to a forwarder device.
:param green: weather to use a greenlet compat zmq | [
"0mq",
"fanout",
"sub",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/sub/zmq.py#L11-L48 | train | 0mq fanout sub. |
Shinichi-Nakagawa/pitchpx | pitchpx/game/game.py | Game.row | def row(self):
"""
Game Dataset(Row)
:return: {
'retro_game_id': Retrosheet Game id
'game_type': Game Type(S/R/F/D/L/W)
'game_type_des': Game Type Description
(Spring Training or Regular Season or Wild-card Game or Divisional Series or LCS or World... | python | def row(self):
"""
Game Dataset(Row)
:return: {
'retro_game_id': Retrosheet Game id
'game_type': Game Type(S/R/F/D/L/W)
'game_type_des': Game Type Description
(Spring Training or Regular Season or Wild-card Game or Divisional Series or LCS or World... | [
"def",
"row",
"(",
"self",
")",
":",
"row",
"=",
"OrderedDict",
"(",
")",
"row",
"[",
"'retro_game_id'",
"]",
"=",
"self",
".",
"retro_game_id",
"row",
"[",
"'game_type'",
"]",
"=",
"self",
".",
"game_type",
"row",
"[",
"'game_type_des'",
"]",
"=",
"se... | Game Dataset(Row)
:return: {
'retro_game_id': Retrosheet Game id
'game_type': Game Type(S/R/F/D/L/W)
'game_type_des': Game Type Description
(Spring Training or Regular Season or Wild-card Game or Divisional Series or LCS or World Series)
'st_fl': Sprin... | [
"Game",
"Dataset",
"(",
"Row",
")",
":",
"return",
":",
"{",
"retro_game_id",
":",
"Retrosheet",
"Game",
"id",
"game_type",
":",
"Game",
"Type",
"(",
"S",
"/",
"R",
"/",
"F",
"/",
"D",
"/",
"L",
"/",
"W",
")",
"game_type_des",
":",
"Game",
"Type",
... | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/game.py#L47-L95 | train | Return OrderedDict of all the keys that are not None |
Shinichi-Nakagawa/pitchpx | pitchpx/game/game.py | Game.read_xml | def read_xml(cls, url, features, timestamp, game_number):
"""
read xml object
:param url: contents url
:param features: markup provider
:param timestamp: game day
:param game_number: game number
:return: pitchpx.game.game.Game object
"""
soup = Mlb... | python | def read_xml(cls, url, features, timestamp, game_number):
"""
read xml object
:param url: contents url
:param features: markup provider
:param timestamp: game day
:param game_number: game number
:return: pitchpx.game.game.Game object
"""
soup = Mlb... | [
"def",
"read_xml",
"(",
"cls",
",",
"url",
",",
"features",
",",
"timestamp",
",",
"game_number",
")",
":",
"soup",
"=",
"MlbamUtil",
".",
"find_xml",
"(",
"\"\"",
".",
"join",
"(",
"[",
"url",
",",
"cls",
".",
"FILENAME",
"]",
")",
",",
"features",
... | read xml object
:param url: contents url
:param features: markup provider
:param timestamp: game day
:param game_number: game number
:return: pitchpx.game.game.Game object | [
"read",
"xml",
"object",
":",
"param",
"url",
":",
"contents",
"url",
":",
"param",
"features",
":",
"markup",
"provider",
":",
"param",
"timestamp",
":",
"game",
"day",
":",
"param",
"game_number",
":",
"game",
"number",
":",
"return",
":",
"pitchpx",
"... | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/game.py#L98-L108 | train | read xml object |
Shinichi-Nakagawa/pitchpx | pitchpx/game/game.py | Game._generate_game_object | def _generate_game_object(cls, soup, timestamp, game_number):
"""
get game data
:param soup: Beautifulsoup object
:param timestamp: game day
:param game_number: game number
:return: pitchpx.game.game.Game object
"""
game = Game(timestamp)
# Base G... | python | def _generate_game_object(cls, soup, timestamp, game_number):
"""
get game data
:param soup: Beautifulsoup object
:param timestamp: game day
:param game_number: game number
:return: pitchpx.game.game.Game object
"""
game = Game(timestamp)
# Base G... | [
"def",
"_generate_game_object",
"(",
"cls",
",",
"soup",
",",
"timestamp",
",",
"game_number",
")",
":",
"game",
"=",
"Game",
"(",
"timestamp",
")",
"# Base Game Data(Spring Training, Regular Season, Play Off, etc...)",
"game",
".",
"game_type",
"=",
"MlbamUtil",
".",... | get game data
:param soup: Beautifulsoup object
:param timestamp: game day
:param game_number: game number
:return: pitchpx.game.game.Game object | [
"get",
"game",
"data",
":",
"param",
"soup",
":",
"Beautifulsoup",
"object",
":",
"param",
"timestamp",
":",
"game",
"day",
":",
"param",
"game_number",
":",
"game",
"number",
":",
"return",
":",
"pitchpx",
".",
"game",
".",
"game",
".",
"Game",
"object"... | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/game.py#L111-L149 | train | generate game object from soup |
Shinichi-Nakagawa/pitchpx | pitchpx/game/game.py | Game._get_game_type_des | def _get_game_type_des(cls, game_type):
"""
get game type description
:param game_type: game type
:return: game type description
"""
if game_type == 'S':
return 'Spring Training'
elif game_type == 'R':
return 'Regular Season'
elif g... | python | def _get_game_type_des(cls, game_type):
"""
get game type description
:param game_type: game type
:return: game type description
"""
if game_type == 'S':
return 'Spring Training'
elif game_type == 'R':
return 'Regular Season'
elif g... | [
"def",
"_get_game_type_des",
"(",
"cls",
",",
"game_type",
")",
":",
"if",
"game_type",
"==",
"'S'",
":",
"return",
"'Spring Training'",
"elif",
"game_type",
"==",
"'R'",
":",
"return",
"'Regular Season'",
"elif",
"game_type",
"==",
"'F'",
":",
"return",
"'Wil... | get game type description
:param game_type: game type
:return: game type description | [
"get",
"game",
"type",
"description",
":",
"param",
"game_type",
":",
"game",
"type",
":",
"return",
":",
"game",
"type",
"description"
] | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/game.py#L152-L170 | train | get game type description |
Shinichi-Nakagawa/pitchpx | pitchpx/game/game.py | Game._get_team_attribute | def _get_team_attribute(cls, soup, team_type, name):
"""
get team attribute
:param soup: Beautifulsoup object
:param team_type: team type(home or away)
:param name: attribute name
:return: attribute value
"""
if soup.find('team'):
return soup.f... | python | def _get_team_attribute(cls, soup, team_type, name):
"""
get team attribute
:param soup: Beautifulsoup object
:param team_type: team type(home or away)
:param name: attribute name
:return: attribute value
"""
if soup.find('team'):
return soup.f... | [
"def",
"_get_team_attribute",
"(",
"cls",
",",
"soup",
",",
"team_type",
",",
"name",
")",
":",
"if",
"soup",
".",
"find",
"(",
"'team'",
")",
":",
"return",
"soup",
".",
"find",
"(",
"\"team\"",
",",
"type",
"=",
"team_type",
")",
"[",
"name",
"]",
... | get team attribute
:param soup: Beautifulsoup object
:param team_type: team type(home or away)
:param name: attribute name
:return: attribute value | [
"get",
"team",
"attribute",
":",
"param",
"soup",
":",
"Beautifulsoup",
"object",
":",
"param",
"team_type",
":",
"team",
"type",
"(",
"home",
"or",
"away",
")",
":",
"param",
"name",
":",
"attribute",
"name",
":",
"return",
":",
"attribute",
"value"
] | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/game.py#L206-L216 | train | get team attribute |
Shinichi-Nakagawa/pitchpx | pitchpx/game/game.py | Game._get_stadium_attribute | def _get_stadium_attribute(cls, soup, name):
"""
get stadium attribute
:param soup: Beautifulsoup object
:param name: attribute name
:return: attribute value
"""
if soup.find('stadium'):
return soup.stadium[name]
return MlbamConst.UNKNOWN_FULL | python | def _get_stadium_attribute(cls, soup, name):
"""
get stadium attribute
:param soup: Beautifulsoup object
:param name: attribute name
:return: attribute value
"""
if soup.find('stadium'):
return soup.stadium[name]
return MlbamConst.UNKNOWN_FULL | [
"def",
"_get_stadium_attribute",
"(",
"cls",
",",
"soup",
",",
"name",
")",
":",
"if",
"soup",
".",
"find",
"(",
"'stadium'",
")",
":",
"return",
"soup",
".",
"stadium",
"[",
"name",
"]",
"return",
"MlbamConst",
".",
"UNKNOWN_FULL"
] | get stadium attribute
:param soup: Beautifulsoup object
:param name: attribute name
:return: attribute value | [
"get",
"stadium",
"attribute",
":",
"param",
"soup",
":",
"Beautifulsoup",
"object",
":",
"param",
"name",
":",
"attribute",
"name",
":",
"return",
":",
"attribute",
"value"
] | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/game.py#L219-L228 | train | get stadium attribute |
Shinichi-Nakagawa/pitchpx | pitchpx/game/game.py | Game._get_interleague_fl | def _get_interleague_fl(cls, home_team_lg, away_team_lg):
"""
get inter league flg
:param home_team_lg: home team league
:param away_team_lg: away team league
:return: inter league flg(T or F or U)
"""
if (home_team_lg == MlbamConst.UNKNOWN_SHORT) or (away_team_lg... | python | def _get_interleague_fl(cls, home_team_lg, away_team_lg):
"""
get inter league flg
:param home_team_lg: home team league
:param away_team_lg: away team league
:return: inter league flg(T or F or U)
"""
if (home_team_lg == MlbamConst.UNKNOWN_SHORT) or (away_team_lg... | [
"def",
"_get_interleague_fl",
"(",
"cls",
",",
"home_team_lg",
",",
"away_team_lg",
")",
":",
"if",
"(",
"home_team_lg",
"==",
"MlbamConst",
".",
"UNKNOWN_SHORT",
")",
"or",
"(",
"away_team_lg",
"==",
"MlbamConst",
".",
"UNKNOWN_SHORT",
")",
":",
"return",
"Ml... | get inter league flg
:param home_team_lg: home team league
:param away_team_lg: away team league
:return: inter league flg(T or F or U) | [
"get",
"inter",
"league",
"flg",
":",
"param",
"home_team_lg",
":",
"home",
"team",
"league",
":",
"param",
"away_team_lg",
":",
"away",
"team",
"league",
":",
"return",
":",
"inter",
"league",
"flg",
"(",
"T",
"or",
"F",
"or",
"U",
")"
] | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/game.py#L231-L242 | train | get inter league flg |
Shinichi-Nakagawa/pitchpx | pitchpx/game/game.py | Game._get_retro_id | def _get_retro_id(cls, home_team_id, timestamp, game_number):
"""
get retro id
:param home_team_id: home team id
:param timestamp: game day
:param game_number: game number
:return: retro id
"""
return '{home_team_id}{year}{month}{day}{game_number}'.format(... | python | def _get_retro_id(cls, home_team_id, timestamp, game_number):
"""
get retro id
:param home_team_id: home team id
:param timestamp: game day
:param game_number: game number
:return: retro id
"""
return '{home_team_id}{year}{month}{day}{game_number}'.format(... | [
"def",
"_get_retro_id",
"(",
"cls",
",",
"home_team_id",
",",
"timestamp",
",",
"game_number",
")",
":",
"return",
"'{home_team_id}{year}{month}{day}{game_number}'",
".",
"format",
"(",
"*",
"*",
"{",
"'home_team_id'",
":",
"home_team_id",
".",
"upper",
"(",
")",
... | get retro id
:param home_team_id: home team id
:param timestamp: game day
:param game_number: game number
:return: retro id | [
"get",
"retro",
"id",
":",
"param",
"home_team_id",
":",
"home",
"team",
"id",
":",
"param",
"timestamp",
":",
"game",
"day",
":",
"param",
"game_number",
":",
"game",
"number",
":",
"return",
":",
"retro",
"id"
] | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/game.py#L245-L261 | train | get retro id from home team id timestamp and game number |
robinandeer/puzzle | puzzle/plugins/sql/mixins/case.py | CaseMixin.add_case | def add_case(self, case_obj, vtype='snv', mode='vcf', ped_svg=None):
"""Load a case with individuals.
Args:
case_obj (puzzle.models.Case): initialized case model
"""
new_case = Case(case_id=case_obj.case_id,
name=case_obj.name,
... | python | def add_case(self, case_obj, vtype='snv', mode='vcf', ped_svg=None):
"""Load a case with individuals.
Args:
case_obj (puzzle.models.Case): initialized case model
"""
new_case = Case(case_id=case_obj.case_id,
name=case_obj.name,
... | [
"def",
"add_case",
"(",
"self",
",",
"case_obj",
",",
"vtype",
"=",
"'snv'",
",",
"mode",
"=",
"'vcf'",
",",
"ped_svg",
"=",
"None",
")",
":",
"new_case",
"=",
"Case",
"(",
"case_id",
"=",
"case_obj",
".",
"case_id",
",",
"name",
"=",
"case_obj",
"."... | Load a case with individuals.
Args:
case_obj (puzzle.models.Case): initialized case model | [
"Load",
"a",
"case",
"with",
"individuals",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/case.py#L15-L49 | train | Load a case with individuals and save it in the database. |
robinandeer/puzzle | puzzle/plugins/sql/mixins/case.py | CaseMixin.delete_case | def delete_case(self, case_obj):
"""Delete a case from the database
Args:
case_obj (puzzle.models.Case): initialized case model
"""
for ind_obj in case_obj.individuals:
self.delete_individual(ind_obj)
logger.info("Deleting case {0} from database".format(c... | python | def delete_case(self, case_obj):
"""Delete a case from the database
Args:
case_obj (puzzle.models.Case): initialized case model
"""
for ind_obj in case_obj.individuals:
self.delete_individual(ind_obj)
logger.info("Deleting case {0} from database".format(c... | [
"def",
"delete_case",
"(",
"self",
",",
"case_obj",
")",
":",
"for",
"ind_obj",
"in",
"case_obj",
".",
"individuals",
":",
"self",
".",
"delete_individual",
"(",
"ind_obj",
")",
"logger",
".",
"info",
"(",
"\"Deleting case {0} from database\"",
".",
"format",
... | Delete a case from the database
Args:
case_obj (puzzle.models.Case): initialized case model | [
"Delete",
"a",
"case",
"from",
"the",
"database"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/case.py#L51-L62 | train | Delete a case from the database. |
robinandeer/puzzle | puzzle/plugins/sql/mixins/case.py | CaseMixin.delete_individual | def delete_individual(self, ind_obj):
"""Delete a case from the database
Args:
ind_obj (puzzle.models.Individual): initialized individual model
"""
logger.info("Deleting individual {0} from database"
.format(ind_obj.ind_id))
self.session.delete(in... | python | def delete_individual(self, ind_obj):
"""Delete a case from the database
Args:
ind_obj (puzzle.models.Individual): initialized individual model
"""
logger.info("Deleting individual {0} from database"
.format(ind_obj.ind_id))
self.session.delete(in... | [
"def",
"delete_individual",
"(",
"self",
",",
"ind_obj",
")",
":",
"logger",
".",
"info",
"(",
"\"Deleting individual {0} from database\"",
".",
"format",
"(",
"ind_obj",
".",
"ind_id",
")",
")",
"self",
".",
"session",
".",
"delete",
"(",
"ind_obj",
")",
"s... | Delete a case from the database
Args:
ind_obj (puzzle.models.Individual): initialized individual model | [
"Delete",
"a",
"case",
"from",
"the",
"database"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/case.py#L64-L74 | train | Delete an individual from the database |
robinandeer/puzzle | puzzle/plugins/sql/mixins/case.py | CaseMixin.case | def case(self, case_id):
"""Fetch a case from the database."""
case_obj = self.query(Case).filter_by(case_id=case_id).first()
return case_obj | python | def case(self, case_id):
"""Fetch a case from the database."""
case_obj = self.query(Case).filter_by(case_id=case_id).first()
return case_obj | [
"def",
"case",
"(",
"self",
",",
"case_id",
")",
":",
"case_obj",
"=",
"self",
".",
"query",
"(",
"Case",
")",
".",
"filter_by",
"(",
"case_id",
"=",
"case_id",
")",
".",
"first",
"(",
")",
"return",
"case_obj"
] | Fetch a case from the database. | [
"Fetch",
"a",
"case",
"from",
"the",
"database",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/case.py#L76-L79 | train | Fetch a case from the database. |
robinandeer/puzzle | puzzle/plugins/sql/mixins/case.py | CaseMixin.individual | def individual(self, ind_id):
"""Fetch a case from the database."""
ind_obj = self.query(Individual).filter_by(ind_id=ind_id).first()
if ind_obj is None:
ind_obj = BaseIndividual(ind_id='unknown')
return ind_obj | python | def individual(self, ind_id):
"""Fetch a case from the database."""
ind_obj = self.query(Individual).filter_by(ind_id=ind_id).first()
if ind_obj is None:
ind_obj = BaseIndividual(ind_id='unknown')
return ind_obj | [
"def",
"individual",
"(",
"self",
",",
"ind_id",
")",
":",
"ind_obj",
"=",
"self",
".",
"query",
"(",
"Individual",
")",
".",
"filter_by",
"(",
"ind_id",
"=",
"ind_id",
")",
".",
"first",
"(",
")",
"if",
"ind_obj",
"is",
"None",
":",
"ind_obj",
"=",
... | Fetch a case from the database. | [
"Fetch",
"a",
"case",
"from",
"the",
"database",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/case.py#L81-L86 | train | Fetch a case from the database. |
robinandeer/puzzle | puzzle/plugins/sql/mixins/case.py | CaseMixin.individuals | def individuals(self, ind_ids=None):
"""Fetch all individuals from the database."""
query = self.query(Individual)
if ind_ids:
query = query.filter(Individual.ind_id.in_(ind_ids))
return query | python | def individuals(self, ind_ids=None):
"""Fetch all individuals from the database."""
query = self.query(Individual)
if ind_ids:
query = query.filter(Individual.ind_id.in_(ind_ids))
return query | [
"def",
"individuals",
"(",
"self",
",",
"ind_ids",
"=",
"None",
")",
":",
"query",
"=",
"self",
".",
"query",
"(",
"Individual",
")",
"if",
"ind_ids",
":",
"query",
"=",
"query",
".",
"filter",
"(",
"Individual",
".",
"ind_id",
".",
"in_",
"(",
"ind_... | Fetch all individuals from the database. | [
"Fetch",
"all",
"individuals",
"from",
"the",
"database",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/case.py#L92-L97 | train | Fetch all individuals from the database. |
robinandeer/puzzle | puzzle/models/sql/models.py | Case.case_comments | def case_comments(self):
"""Return only comments made on the case."""
comments = (comment for comment in self.comments if
comment.variant_id is None)
return comments | python | def case_comments(self):
"""Return only comments made on the case."""
comments = (comment for comment in self.comments if
comment.variant_id is None)
return comments | [
"def",
"case_comments",
"(",
"self",
")",
":",
"comments",
"=",
"(",
"comment",
"for",
"comment",
"in",
"self",
".",
"comments",
"if",
"comment",
".",
"variant_id",
"is",
"None",
")",
"return",
"comments"
] | Return only comments made on the case. | [
"Return",
"only",
"comments",
"made",
"on",
"the",
"case",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/sql/models.py#L55-L59 | train | Return only comments made on the case. |
basecrm/basecrm-python | basecrm/http_client.py | HttpClient.post | def post(self, url, body=None, **kwargs):
"""
Send a POST request.
:param str url: Sub URL for the request. You MUST not specify neither base url nor api version prefix.
:param dict body: (optional) Dictionary of body attributes that will be wrapped with envelope and json encoded.
... | python | def post(self, url, body=None, **kwargs):
"""
Send a POST request.
:param str url: Sub URL for the request. You MUST not specify neither base url nor api version prefix.
:param dict body: (optional) Dictionary of body attributes that will be wrapped with envelope and json encoded.
... | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"body",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'post'",
",",
"url",
",",
"body",
"=",
"body",
",",
"*",
"*",
"kwargs",
")"
] | Send a POST request.
:param str url: Sub URL for the request. You MUST not specify neither base url nor api version prefix.
:param dict body: (optional) Dictionary of body attributes that will be wrapped with envelope and json encoded.
:param dict **kwargs: (optional) Other parameters which are... | [
"Send",
"a",
"POST",
"request",
"."
] | 7c1cf97dbaba8aeb9ff89f8a54f945a8702349f6 | https://github.com/basecrm/basecrm-python/blob/7c1cf97dbaba8aeb9ff89f8a54f945a8702349f6/basecrm/http_client.py#L49-L60 | train | Send a POST request. |
basecrm/basecrm-python | basecrm/http_client.py | HttpClient.put | def put(self, url, body=None, **kwargs):
"""
Send a PUT request.
:param str url: Sub URL for the request. You MUST not specify neither base url nor api version prefix.
:param dict body: (optional) Dictionary of body attributes that will be wrapped with envelope and json encoded.
... | python | def put(self, url, body=None, **kwargs):
"""
Send a PUT request.
:param str url: Sub URL for the request. You MUST not specify neither base url nor api version prefix.
:param dict body: (optional) Dictionary of body attributes that will be wrapped with envelope and json encoded.
... | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"body",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'put'",
",",
"url",
",",
"body",
"=",
"body",
",",
"*",
"*",
"kwargs",
")"
] | Send a PUT request.
:param str url: Sub URL for the request. You MUST not specify neither base url nor api version prefix.
:param dict body: (optional) Dictionary of body attributes that will be wrapped with envelope and json encoded.
:param dict **kwargs: (optional) Other parameters which are ... | [
"Send",
"a",
"PUT",
"request",
"."
] | 7c1cf97dbaba8aeb9ff89f8a54f945a8702349f6 | https://github.com/basecrm/basecrm-python/blob/7c1cf97dbaba8aeb9ff89f8a54f945a8702349f6/basecrm/http_client.py#L62-L73 | train | Send a PUT request. |
basecrm/basecrm-python | basecrm/http_client.py | HttpClient.delete | def delete(self, url, params=None, **kwargs):
"""
Send a DELETE request.
:param str url: Sub URL for the request. You MUST not specify neither base url nor api version prefix.
:param dict params: (optional) Dictionary of query parameters.
:param dict **kwargs: (optional) Other p... | python | def delete(self, url, params=None, **kwargs):
"""
Send a DELETE request.
:param str url: Sub URL for the request. You MUST not specify neither base url nor api version prefix.
:param dict params: (optional) Dictionary of query parameters.
:param dict **kwargs: (optional) Other p... | [
"def",
"delete",
"(",
"self",
",",
"url",
",",
"params",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'delete'",
",",
"url",
",",
"params",
"=",
"params",
",",
"*",
"*",
"kwargs",
")"
] | Send a DELETE request.
:param str url: Sub URL for the request. You MUST not specify neither base url nor api version prefix.
:param dict params: (optional) Dictionary of query parameters.
:param dict **kwargs: (optional) Other parameters which are directly passed to :func:`requests.request`.
... | [
"Send",
"a",
"DELETE",
"request",
"."
] | 7c1cf97dbaba8aeb9ff89f8a54f945a8702349f6 | https://github.com/basecrm/basecrm-python/blob/7c1cf97dbaba8aeb9ff89f8a54f945a8702349f6/basecrm/http_client.py#L75-L86 | train | Send a DELETE request. |
basecrm/basecrm-python | basecrm/http_client.py | HttpClient.request | def request(self, method, url, params=None, body=None, **kwargs):
"""
Send an HTTP request.
The :param:`params` will be properly encoded, as well as :param:`body` which
will be wrapped with envelope the API expects and json encoded.
When you get a reponse the method will try to... | python | def request(self, method, url, params=None, body=None, **kwargs):
"""
Send an HTTP request.
The :param:`params` will be properly encoded, as well as :param:`body` which
will be wrapped with envelope the API expects and json encoded.
When you get a reponse the method will try to... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"params",
"=",
"None",
",",
"body",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"\"{base_url}{version}{resource}\"",
".",
"format",
"(",
"base_url",
"=",
"self",
".",
"confi... | Send an HTTP request.
The :param:`params` will be properly encoded, as well as :param:`body` which
will be wrapped with envelope the API expects and json encoded.
When you get a reponse the method will try to json decode the response,
if the media type represents json, unwrap the envel... | [
"Send",
"an",
"HTTP",
"request",
"."
] | 7c1cf97dbaba8aeb9ff89f8a54f945a8702349f6 | https://github.com/basecrm/basecrm-python/blob/7c1cf97dbaba8aeb9ff89f8a54f945a8702349f6/basecrm/http_client.py#L88-L152 | train | Send an HTTP request to the CRM API. |
eleme/meepo | meepo/apps/replicator/queue.py | QueueReplicator.event | def event(self, *topics, **kwargs):
"""Topic callback registry.
callback func should receive two args: topic and pk, and then process
the replication job.
Note: The callback func must return True/False. When passed a list of
pks, the func should return a list of True/False with... | python | def event(self, *topics, **kwargs):
"""Topic callback registry.
callback func should receive two args: topic and pk, and then process
the replication job.
Note: The callback func must return True/False. When passed a list of
pks, the func should return a list of True/False with... | [
"def",
"event",
"(",
"self",
",",
"*",
"topics",
",",
"*",
"*",
"kwargs",
")",
":",
"workers",
"=",
"kwargs",
".",
"pop",
"(",
"\"workers\"",
",",
"1",
")",
"multi",
"=",
"kwargs",
".",
"pop",
"(",
"\"multi\"",
",",
"False",
")",
"queue_limit",
"="... | Topic callback registry.
callback func should receive two args: topic and pk, and then process
the replication job.
Note: The callback func must return True/False. When passed a list of
pks, the func should return a list of True/False with the same length
of pks.
:para... | [
"Topic",
"callback",
"registry",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/replicator/queue.py#L31-L63 | train | This is a callback function that is used to register a callback function for a topic. |
eleme/meepo | meepo/apps/replicator/queue.py | QueueReplicator.run | def run(self):
"""Run the replicator.
Main process receive messages and distribute them to worker queues.
"""
for worker_pool in self.workers.values():
worker_pool.start()
if isinstance(self.listen, list):
for i in self.listen:
self.socke... | python | def run(self):
"""Run the replicator.
Main process receive messages and distribute them to worker queues.
"""
for worker_pool in self.workers.values():
worker_pool.start()
if isinstance(self.listen, list):
for i in self.listen:
self.socke... | [
"def",
"run",
"(",
"self",
")",
":",
"for",
"worker_pool",
"in",
"self",
".",
"workers",
".",
"values",
"(",
")",
":",
"worker_pool",
".",
"start",
"(",
")",
"if",
"isinstance",
"(",
"self",
".",
"listen",
",",
"list",
")",
":",
"for",
"i",
"in",
... | Run the replicator.
Main process receive messages and distribute them to worker queues. | [
"Run",
"the",
"replicator",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/replicator/queue.py#L65-L98 | train | Main process receive messages and distribute them to worker queues. |
thautwarm/Redy | Redy/Collections/Traversal.py | map_by | def map_by(fn: Callable[[T1], T2]) -> Callable[[ActualIterable[T1]], Iterable[T2]]:
"""
when pycharm supports type hinting for any implementation of currying,
map_with and map_on would be deprecated.
>>> from Redy.Collections import Traversal, Flow
>>> def double(x: int) -> int: return x * 2
>>>... | python | def map_by(fn: Callable[[T1], T2]) -> Callable[[ActualIterable[T1]], Iterable[T2]]:
"""
when pycharm supports type hinting for any implementation of currying,
map_with and map_on would be deprecated.
>>> from Redy.Collections import Traversal, Flow
>>> def double(x: int) -> int: return x * 2
>>>... | [
"def",
"map_by",
"(",
"fn",
":",
"Callable",
"[",
"[",
"T1",
"]",
",",
"T2",
"]",
")",
"->",
"Callable",
"[",
"[",
"ActualIterable",
"[",
"T1",
"]",
"]",
",",
"Iterable",
"[",
"T2",
"]",
"]",
":",
"return",
"lambda",
"collection",
":",
"builtins",
... | when pycharm supports type hinting for any implementation of currying,
map_with and map_on would be deprecated.
>>> from Redy.Collections import Traversal, Flow
>>> def double(x: int) -> int: return x * 2
>>> lst: Iterable[int] = [1, 2, 3]
>>> x = Flow(lst)[Traversal.map_by(double)][Traversal.sum_fr... | [
"when",
"pycharm",
"supports",
"type",
"hinting",
"for",
"any",
"implementation",
"of",
"currying",
"map_with",
"and",
"map_on",
"would",
"be",
"deprecated",
".",
">>>",
"from",
"Redy",
".",
"Collections",
"import",
"Traversal",
"Flow",
">>>",
"def",
"double",
... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Collections/Traversal.py#L12-L23 | train | Returns a function that returns the elements of the iterable that match the given function. |
thautwarm/Redy | Redy/Collections/Traversal.py | reduce_by | def reduce_by(fn: Callable[[T1, T1], T1]) -> Callable[[ActualIterable[T1]], T1]:
"""
>>> from Redy.Collections import Traversal, Flow
>>> def mul(a: int, b: int): return a * b
>>> lst: Iterable[int] = [1, 2, 3]
>>> x = Flow(lst)[Traversal.reduce_by(mul)].unbox
>>> assert x is 6
"""
retur... | python | def reduce_by(fn: Callable[[T1, T1], T1]) -> Callable[[ActualIterable[T1]], T1]:
"""
>>> from Redy.Collections import Traversal, Flow
>>> def mul(a: int, b: int): return a * b
>>> lst: Iterable[int] = [1, 2, 3]
>>> x = Flow(lst)[Traversal.reduce_by(mul)].unbox
>>> assert x is 6
"""
retur... | [
"def",
"reduce_by",
"(",
"fn",
":",
"Callable",
"[",
"[",
"T1",
",",
"T1",
"]",
",",
"T1",
"]",
")",
"->",
"Callable",
"[",
"[",
"ActualIterable",
"[",
"T1",
"]",
"]",
",",
"T1",
"]",
":",
"return",
"lambda",
"collection",
":",
"functools",
".",
... | >>> from Redy.Collections import Traversal, Flow
>>> def mul(a: int, b: int): return a * b
>>> lst: Iterable[int] = [1, 2, 3]
>>> x = Flow(lst)[Traversal.reduce_by(mul)].unbox
>>> assert x is 6 | [
">>>",
"from",
"Redy",
".",
"Collections",
"import",
"Traversal",
"Flow",
">>>",
"def",
"mul",
"(",
"a",
":",
"int",
"b",
":",
"int",
")",
":",
"return",
"a",
"*",
"b",
">>>",
"lst",
":",
"Iterable",
"[",
"int",
"]",
"=",
"[",
"1",
"2",
"3",
"]... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Collections/Traversal.py#L26-L34 | train | Reduce the elements of a collection by a function. |
thautwarm/Redy | Redy/Collections/Traversal.py | fold_by | def fold_by(fn: Callable[[T1, T2], T1], start: T1) -> Callable[[ActualIterable[T2]], T1]:
"""
>>> from Redy.Collections import Traversal, Flow
>>> def mul(a: int, b: int): return a * b
>>> lst: Iterable[int] = [1, 2, 3]
>>> x = Flow(lst)[Traversal.fold_by(mul, 1)].unbox
>>> assert x is 6
"""... | python | def fold_by(fn: Callable[[T1, T2], T1], start: T1) -> Callable[[ActualIterable[T2]], T1]:
"""
>>> from Redy.Collections import Traversal, Flow
>>> def mul(a: int, b: int): return a * b
>>> lst: Iterable[int] = [1, 2, 3]
>>> x = Flow(lst)[Traversal.fold_by(mul, 1)].unbox
>>> assert x is 6
"""... | [
"def",
"fold_by",
"(",
"fn",
":",
"Callable",
"[",
"[",
"T1",
",",
"T2",
"]",
",",
"T1",
"]",
",",
"start",
":",
"T1",
")",
"->",
"Callable",
"[",
"[",
"ActualIterable",
"[",
"T2",
"]",
"]",
",",
"T1",
"]",
":",
"return",
"lambda",
"collection",
... | >>> from Redy.Collections import Traversal, Flow
>>> def mul(a: int, b: int): return a * b
>>> lst: Iterable[int] = [1, 2, 3]
>>> x = Flow(lst)[Traversal.fold_by(mul, 1)].unbox
>>> assert x is 6 | [
">>>",
"from",
"Redy",
".",
"Collections",
"import",
"Traversal",
"Flow",
">>>",
"def",
"mul",
"(",
"a",
":",
"int",
"b",
":",
"int",
")",
":",
"return",
"a",
"*",
"b",
">>>",
"lst",
":",
"Iterable",
"[",
"int",
"]",
"=",
"[",
"1",
"2",
"3",
"]... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Collections/Traversal.py#L37-L45 | train | Folds a function into a sequence of elements. |
thautwarm/Redy | Redy/Collections/Traversal.py | filter_by | def filter_by(fn: Callable[[T], bool]) -> Callable[[ActualIterable[T]], Iterable[T]]:
"""
>>> from Redy.Collections import Traversal, Flow
>>> def even(a: int) -> bool: return a % 2 == 0
>>> lst: Iterable[int] = [1, 2, 3]
>>> x = Flow(lst)[Traversal.filter_by(even)].unbox
>>> assert list(x) == [... | python | def filter_by(fn: Callable[[T], bool]) -> Callable[[ActualIterable[T]], Iterable[T]]:
"""
>>> from Redy.Collections import Traversal, Flow
>>> def even(a: int) -> bool: return a % 2 == 0
>>> lst: Iterable[int] = [1, 2, 3]
>>> x = Flow(lst)[Traversal.filter_by(even)].unbox
>>> assert list(x) == [... | [
"def",
"filter_by",
"(",
"fn",
":",
"Callable",
"[",
"[",
"T",
"]",
",",
"bool",
"]",
")",
"->",
"Callable",
"[",
"[",
"ActualIterable",
"[",
"T",
"]",
"]",
",",
"Iterable",
"[",
"T",
"]",
"]",
":",
"return",
"lambda",
"collection",
":",
"builtins"... | >>> from Redy.Collections import Traversal, Flow
>>> def even(a: int) -> bool: return a % 2 == 0
>>> lst: Iterable[int] = [1, 2, 3]
>>> x = Flow(lst)[Traversal.filter_by(even)].unbox
>>> assert list(x) == [2] | [
">>>",
"from",
"Redy",
".",
"Collections",
"import",
"Traversal",
"Flow",
">>>",
"def",
"even",
"(",
"a",
":",
"int",
")",
"-",
">",
"bool",
":",
"return",
"a",
"%",
"2",
"==",
"0",
">>>",
"lst",
":",
"Iterable",
"[",
"int",
"]",
"=",
"[",
"1",
... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Collections/Traversal.py#L48-L56 | train | Filter the elements of a iterable by a function. |
thautwarm/Redy | Redy/Collections/Traversal.py | sum_from | def sum_from(zero: T1 = None) -> Callable[[ActualIterable[T1]], T1]:
"""
>>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [1, 2, 3]
>>> x = Flow(lst)[Traversal.sum_from(0)].unbox
>>> assert x is 6
>>> x = Flow(lst)[Traversal.sum_from()].unbox
>>> assert x is 6
"... | python | def sum_from(zero: T1 = None) -> Callable[[ActualIterable[T1]], T1]:
"""
>>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [1, 2, 3]
>>> x = Flow(lst)[Traversal.sum_from(0)].unbox
>>> assert x is 6
>>> x = Flow(lst)[Traversal.sum_from()].unbox
>>> assert x is 6
"... | [
"def",
"sum_from",
"(",
"zero",
":",
"T1",
"=",
"None",
")",
"->",
"Callable",
"[",
"[",
"ActualIterable",
"[",
"T1",
"]",
"]",
",",
"T1",
"]",
":",
"def",
"_",
"(",
"collection",
":",
"Iterable",
"[",
"T1",
"]",
")",
"->",
"T1",
":",
"if",
"ze... | >>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [1, 2, 3]
>>> x = Flow(lst)[Traversal.sum_from(0)].unbox
>>> assert x is 6
>>> x = Flow(lst)[Traversal.sum_from()].unbox
>>> assert x is 6 | [
">>>",
"from",
"Redy",
".",
"Collections",
"import",
"Traversal",
"Flow",
">>>",
"lst",
":",
"Iterable",
"[",
"int",
"]",
"=",
"[",
"1",
"2",
"3",
"]",
">>>",
"x",
"=",
"Flow",
"(",
"lst",
")",
"[",
"Traversal",
".",
"sum_from",
"(",
"0",
")",
"]... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Collections/Traversal.py#L59-L78 | train | Returns a function that sums the elements of a sequence of items. |
thautwarm/Redy | Redy/Collections/Traversal.py | each_do | def each_do(action: Callable[[T], None]):
"""
>>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [1, 2, 3]
>>> def action(x: int) -> None: print(x)
>>> x = Flow(lst)[Traversal.each_do(action)]
>>> assert x.unbox is None
"""
def inner(collection: ActualIterable[T])... | python | def each_do(action: Callable[[T], None]):
"""
>>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [1, 2, 3]
>>> def action(x: int) -> None: print(x)
>>> x = Flow(lst)[Traversal.each_do(action)]
>>> assert x.unbox is None
"""
def inner(collection: ActualIterable[T])... | [
"def",
"each_do",
"(",
"action",
":",
"Callable",
"[",
"[",
"T",
"]",
",",
"None",
"]",
")",
":",
"def",
"inner",
"(",
"collection",
":",
"ActualIterable",
"[",
"T",
"]",
")",
":",
"for",
"each",
"in",
"collection",
":",
"action",
"(",
"each",
")",... | >>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [1, 2, 3]
>>> def action(x: int) -> None: print(x)
>>> x = Flow(lst)[Traversal.each_do(action)]
>>> assert x.unbox is None | [
">>>",
"from",
"Redy",
".",
"Collections",
"import",
"Traversal",
"Flow",
">>>",
"lst",
":",
"Iterable",
"[",
"int",
"]",
"=",
"[",
"1",
"2",
"3",
"]",
">>>",
"def",
"action",
"(",
"x",
":",
"int",
")",
"-",
">",
"None",
":",
"print",
"(",
"x",
... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Collections/Traversal.py#L81-L94 | train | A recursive function that calls the action function on each item in the iterable. |
thautwarm/Redy | Redy/Collections/Traversal.py | flatten_to | def flatten_to(atom: Union[Tuple[Type[T]], Type[T]]):
"""
>>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [[1, 2, 3]]
>>> x = Flow(lst)[Traversal.flatten_to(int)]
>>> assert isinstance(x.unbox, Generator) and list(x.unbox) == [1, 2, 3]
"""
def inner(nested: ActualI... | python | def flatten_to(atom: Union[Tuple[Type[T]], Type[T]]):
"""
>>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [[1, 2, 3]]
>>> x = Flow(lst)[Traversal.flatten_to(int)]
>>> assert isinstance(x.unbox, Generator) and list(x.unbox) == [1, 2, 3]
"""
def inner(nested: ActualI... | [
"def",
"flatten_to",
"(",
"atom",
":",
"Union",
"[",
"Tuple",
"[",
"Type",
"[",
"T",
"]",
"]",
",",
"Type",
"[",
"T",
"]",
"]",
")",
":",
"def",
"inner",
"(",
"nested",
":",
"ActualIterable",
"[",
"Union",
"[",
"T",
",",
"ActualIterable",
"[",
"T... | >>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [[1, 2, 3]]
>>> x = Flow(lst)[Traversal.flatten_to(int)]
>>> assert isinstance(x.unbox, Generator) and list(x.unbox) == [1, 2, 3] | [
">>>",
"from",
"Redy",
".",
"Collections",
"import",
"Traversal",
"Flow",
">>>",
"lst",
":",
"Iterable",
"[",
"int",
"]",
"=",
"[[",
"1",
"2",
"3",
"]]",
">>>",
"x",
"=",
"Flow",
"(",
"lst",
")",
"[",
"Traversal",
".",
"flatten_to",
"(",
"int",
")"... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Collections/Traversal.py#L97-L112 | train | Flattens a list of items into a single element. |
thautwarm/Redy | Redy/Collections/Traversal.py | flatten_if | def flatten_if(cond: Callable[[Union[T, ActualIterable[T]]], bool]):
"""
>>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [[1, 2, 3]]
>>> x = Flow(lst)[Traversal.flatten_if(lambda _: isinstance(_, list))]
>>> assert isinstance(x.unbox, Generator) and list(x.unbox) == [1, 2, ... | python | def flatten_if(cond: Callable[[Union[T, ActualIterable[T]]], bool]):
"""
>>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [[1, 2, 3]]
>>> x = Flow(lst)[Traversal.flatten_if(lambda _: isinstance(_, list))]
>>> assert isinstance(x.unbox, Generator) and list(x.unbox) == [1, 2, ... | [
"def",
"flatten_if",
"(",
"cond",
":",
"Callable",
"[",
"[",
"Union",
"[",
"T",
",",
"ActualIterable",
"[",
"T",
"]",
"]",
"]",
",",
"bool",
"]",
")",
":",
"def",
"inner",
"(",
"nested",
":",
"ActualIterable",
"[",
"Union",
"[",
"T",
",",
"ActualIt... | >>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [[1, 2, 3]]
>>> x = Flow(lst)[Traversal.flatten_if(lambda _: isinstance(_, list))]
>>> assert isinstance(x.unbox, Generator) and list(x.unbox) == [1, 2, 3] | [
">>>",
"from",
"Redy",
".",
"Collections",
"import",
"Traversal",
"Flow",
">>>",
"lst",
":",
"Iterable",
"[",
"int",
"]",
"=",
"[[",
"1",
"2",
"3",
"]]",
">>>",
"x",
"=",
"Flow",
"(",
"lst",
")",
"[",
"Traversal",
".",
"flatten_if",
"(",
"lambda",
... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Collections/Traversal.py#L115-L130 | train | Flattens the entire list of items into one nested list. |
thautwarm/Redy | Redy/Collections/Traversal.py | chunk_by | def chunk_by(fn: Callable[[T], object]):
"""
>>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [0, 1, 2, 3, 4, 5, 6]
>>> x = Flow(lst)[Traversal.chunk_by(lambda x: x // 3)]
>>> assert list(x.unbox) == [[0, 1, 2], [3, 4, 5], [6]]
>>> x = Flow([])[Traversal.chunk_by(lambda ... | python | def chunk_by(fn: Callable[[T], object]):
"""
>>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [0, 1, 2, 3, 4, 5, 6]
>>> x = Flow(lst)[Traversal.chunk_by(lambda x: x // 3)]
>>> assert list(x.unbox) == [[0, 1, 2], [3, 4, 5], [6]]
>>> x = Flow([])[Traversal.chunk_by(lambda ... | [
"def",
"chunk_by",
"(",
"fn",
":",
"Callable",
"[",
"[",
"T",
"]",
",",
"object",
"]",
")",
":",
"def",
"inner",
"(",
"seq",
":",
"ActualIterable",
"[",
"T",
"]",
")",
"->",
"ActualIterable",
"[",
"ActualIterable",
"[",
"T",
"]",
"]",
":",
"seq",
... | >>> from Redy.Collections import Traversal, Flow
>>> lst: Iterable[int] = [0, 1, 2, 3, 4, 5, 6]
>>> x = Flow(lst)[Traversal.chunk_by(lambda x: x // 3)]
>>> assert list(x.unbox) == [[0, 1, 2], [3, 4, 5], [6]]
>>> x = Flow([])[Traversal.chunk_by(lambda x: x)]
>>> assert list(x.unbox) == [] | [
">>>",
"from",
"Redy",
".",
"Collections",
"import",
"Traversal",
"Flow",
">>>",
"lst",
":",
"Iterable",
"[",
"int",
"]",
"=",
"[",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"]",
">>>",
"x",
"=",
"Flow",
"(",
"lst",
")",
"[",
"Traversal",
".",
"chunk_by... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Collections/Traversal.py#L133-L163 | train | Returns an iterable that returns items from a single iteration of the main sequence in order of their status. |
thautwarm/Redy | Redy/Collections/Traversal.py | chunk | def chunk(seq: ActualIterable[T]) -> ActualIterable[ActualIterable[T]]:
"""
>>> from Redy.Collections import Traversal, Flow
>>> x = [1, 1, 2]
>>> assert Flow(x)[Traversal.chunk][list].unbox == [[1, 1], [2]]
>>> assert Flow([])[Traversal.chunk][list].unbox == []
"""
seq = iter(seq)
try:
... | python | def chunk(seq: ActualIterable[T]) -> ActualIterable[ActualIterable[T]]:
"""
>>> from Redy.Collections import Traversal, Flow
>>> x = [1, 1, 2]
>>> assert Flow(x)[Traversal.chunk][list].unbox == [[1, 1], [2]]
>>> assert Flow([])[Traversal.chunk][list].unbox == []
"""
seq = iter(seq)
try:
... | [
"def",
"chunk",
"(",
"seq",
":",
"ActualIterable",
"[",
"T",
"]",
")",
"->",
"ActualIterable",
"[",
"ActualIterable",
"[",
"T",
"]",
"]",
":",
"seq",
"=",
"iter",
"(",
"seq",
")",
"try",
":",
"head",
"=",
"next",
"(",
"seq",
")",
"except",
"StopIte... | >>> from Redy.Collections import Traversal, Flow
>>> x = [1, 1, 2]
>>> assert Flow(x)[Traversal.chunk][list].unbox == [[1, 1], [2]]
>>> assert Flow([])[Traversal.chunk][list].unbox == [] | [
">>>",
"from",
"Redy",
".",
"Collections",
"import",
"Traversal",
"Flow",
">>>",
"x",
"=",
"[",
"1",
"1",
"2",
"]",
">>>",
"assert",
"Flow",
"(",
"x",
")",
"[",
"Traversal",
".",
"chunk",
"]",
"[",
"list",
"]",
".",
"unbox",
"==",
"[[",
"1",
"1",... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Collections/Traversal.py#L166-L190 | train | Yields the items from the given iterable in order. |
thautwarm/Redy | Redy/Collections/Traversal.py | group_by | def group_by(fn: Callable[[T], TR]):
"""
>>> from Redy.Collections import Flow, Traversal
>>> x = [1, '1', 1.0]
>>> Flow(x)[Traversal.group_by(type)]
"""
def inner(seq: ActualIterable[T]) -> Dict[TR, List[T]]:
ret = defaultdict(list)
for each in seq:
ret[fn(each)].ap... | python | def group_by(fn: Callable[[T], TR]):
"""
>>> from Redy.Collections import Flow, Traversal
>>> x = [1, '1', 1.0]
>>> Flow(x)[Traversal.group_by(type)]
"""
def inner(seq: ActualIterable[T]) -> Dict[TR, List[T]]:
ret = defaultdict(list)
for each in seq:
ret[fn(each)].ap... | [
"def",
"group_by",
"(",
"fn",
":",
"Callable",
"[",
"[",
"T",
"]",
",",
"TR",
"]",
")",
":",
"def",
"inner",
"(",
"seq",
":",
"ActualIterable",
"[",
"T",
"]",
")",
"->",
"Dict",
"[",
"TR",
",",
"List",
"[",
"T",
"]",
"]",
":",
"ret",
"=",
"... | >>> from Redy.Collections import Flow, Traversal
>>> x = [1, '1', 1.0]
>>> Flow(x)[Traversal.group_by(type)] | [
">>>",
"from",
"Redy",
".",
"Collections",
"import",
"Flow",
"Traversal",
">>>",
"x",
"=",
"[",
"1",
"1",
"1",
".",
"0",
"]",
">>>",
"Flow",
"(",
"x",
")",
"[",
"Traversal",
".",
"group_by",
"(",
"type",
")",
"]"
] | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Collections/Traversal.py#L193-L207 | train | Group items by a function. |
thautwarm/Redy | Redy/Collections/Traversal.py | group | def group(seq: ActualIterable[T]) -> Dict[TR, List[T]]:
"""
>>> from Redy.Collections import Flow, Traversal
>>> x = [1, 1, 2]
>>> Flow(x)[Traversal.group].unbox
"""
ret = defaultdict(list)
for each in seq:
ret[each].append(each)
return ret | python | def group(seq: ActualIterable[T]) -> Dict[TR, List[T]]:
"""
>>> from Redy.Collections import Flow, Traversal
>>> x = [1, 1, 2]
>>> Flow(x)[Traversal.group].unbox
"""
ret = defaultdict(list)
for each in seq:
ret[each].append(each)
return ret | [
"def",
"group",
"(",
"seq",
":",
"ActualIterable",
"[",
"T",
"]",
")",
"->",
"Dict",
"[",
"TR",
",",
"List",
"[",
"T",
"]",
"]",
":",
"ret",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"each",
"in",
"seq",
":",
"ret",
"[",
"each",
"]",
".",
... | >>> from Redy.Collections import Flow, Traversal
>>> x = [1, 1, 2]
>>> Flow(x)[Traversal.group].unbox | [
">>>",
"from",
"Redy",
".",
"Collections",
"import",
"Flow",
"Traversal",
">>>",
"x",
"=",
"[",
"1",
"1",
"2",
"]",
">>>",
"Flow",
"(",
"x",
")",
"[",
"Traversal",
".",
"group",
"]",
".",
"unbox"
] | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Collections/Traversal.py#L210-L219 | train | Group the items in a sequence into a list of lists. |
ldomic/lintools | lintools/draw.py | Draw.draw_hydrogen_bonds | def draw_hydrogen_bonds(self,color="black"):
"""For each bond that has been determined to be important, a line gets drawn.
"""
self.draw_hbonds=""
if self.hbonds!=None:
for bond in self.hbonds.hbonds_for_drawing:
x = str((self.molecule.x_dim-self.molecule.molsize1)/2)
y = str((self.molecule.y_dim-sel... | python | def draw_hydrogen_bonds(self,color="black"):
"""For each bond that has been determined to be important, a line gets drawn.
"""
self.draw_hbonds=""
if self.hbonds!=None:
for bond in self.hbonds.hbonds_for_drawing:
x = str((self.molecule.x_dim-self.molecule.molsize1)/2)
y = str((self.molecule.y_dim-sel... | [
"def",
"draw_hydrogen_bonds",
"(",
"self",
",",
"color",
"=",
"\"black\"",
")",
":",
"self",
".",
"draw_hbonds",
"=",
"\"\"",
"if",
"self",
".",
"hbonds",
"!=",
"None",
":",
"for",
"bond",
"in",
"self",
".",
"hbonds",
".",
"hbonds_for_drawing",
":",
"x",... | For each bond that has been determined to be important, a line gets drawn. | [
"For",
"each",
"bond",
"that",
"has",
"been",
"determined",
"to",
"be",
"important",
"a",
"line",
"gets",
"drawn",
"."
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/draw.py#L29-L48 | train | This method draws the hydrogen bonds in the molecule. |
ldomic/lintools | lintools/draw.py | Draw.draw_salt_bridges | def draw_salt_bridges(self,color="blue"):
"""
For each bond that has been determined to be important, a line gets drawn.
"""
self.draw_saltbridges=""
if self.saltbridges!=None:
for bond in self.saltbridges.saltbridges_for_drawing:
self.draw_saltbridges ="<g class='SaltBridges' transform='translate("+st... | python | def draw_salt_bridges(self,color="blue"):
"""
For each bond that has been determined to be important, a line gets drawn.
"""
self.draw_saltbridges=""
if self.saltbridges!=None:
for bond in self.saltbridges.saltbridges_for_drawing:
self.draw_saltbridges ="<g class='SaltBridges' transform='translate("+st... | [
"def",
"draw_salt_bridges",
"(",
"self",
",",
"color",
"=",
"\"blue\"",
")",
":",
"self",
".",
"draw_saltbridges",
"=",
"\"\"",
"if",
"self",
".",
"saltbridges",
"!=",
"None",
":",
"for",
"bond",
"in",
"self",
".",
"saltbridges",
".",
"saltbridges_for_drawin... | For each bond that has been determined to be important, a line gets drawn. | [
"For",
"each",
"bond",
"that",
"has",
"been",
"determined",
"to",
"be",
"important",
"a",
"line",
"gets",
"drawn",
"."
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/draw.py#L69-L81 | train | This method draws the salt bridges in the topology. |
ldomic/lintools | lintools/draw.py | Draw.change_lines_in_svg | def change_lines_in_svg(self,filename, string1,string2):
"""Used to change lines in an SVG file. String1 is input - what is already present
in the file, while string2 is output - the desired line. The input has to be searchable
since .replace function is used.
Takes:
* filename * - name of the SVG file to ch... | python | def change_lines_in_svg(self,filename, string1,string2):
"""Used to change lines in an SVG file. String1 is input - what is already present
in the file, while string2 is output - the desired line. The input has to be searchable
since .replace function is used.
Takes:
* filename * - name of the SVG file to ch... | [
"def",
"change_lines_in_svg",
"(",
"self",
",",
"filename",
",",
"string1",
",",
"string2",
")",
":",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"fileinput",
".",
"input",
"(",
"filename",
",",
"inplace",
"=",
"1",
")",
")",
":",
"sys",
".",
"s... | Used to change lines in an SVG file. String1 is input - what is already present
in the file, while string2 is output - the desired line. The input has to be searchable
since .replace function is used.
Takes:
* filename * - name of the SVG file to change
* string1 * - input string
* string2 * - output str... | [
"Used",
"to",
"change",
"lines",
"in",
"an",
"SVG",
"file",
".",
"String1",
"is",
"input",
"-",
"what",
"is",
"already",
"present",
"in",
"the",
"file",
"while",
"string2",
"is",
"output",
"-",
"the",
"desired",
"line",
".",
"The",
"input",
"has",
"to"... | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/draw.py#L214-L225 | train | Used to change lines in an SVG file. |
wistful/pympris | pympris/Base.py | Base.register_signal_handler | def register_signal_handler(self, signal_name, handler_function):
"""register `handler_function` to receive `signal_name`.
Uses class's dbus interface self.IFACE, objects name self.name
and objects path self.OBJ_PATH to match signal.
:param str signal_name: The signal name;
... | python | def register_signal_handler(self, signal_name, handler_function):
"""register `handler_function` to receive `signal_name`.
Uses class's dbus interface self.IFACE, objects name self.name
and objects path self.OBJ_PATH to match signal.
:param str signal_name: The signal name;
... | [
"def",
"register_signal_handler",
"(",
"self",
",",
"signal_name",
",",
"handler_function",
")",
":",
"self",
".",
"bus",
".",
"add_signal_receiver",
"(",
"signal_wrapper",
"(",
"handler_function",
")",
",",
"signal_name",
"=",
"signal_name",
",",
"dbus_interface",
... | register `handler_function` to receive `signal_name`.
Uses class's dbus interface self.IFACE, objects name self.name
and objects path self.OBJ_PATH to match signal.
:param str signal_name: The signal name;
None(default) matches all names.
:param function... | [
"register",
"handler_function",
"to",
"receive",
"signal_name",
"."
] | 4bd64a1f0d151f2adfc392ab34fd9b38894786cb | https://github.com/wistful/pympris/blob/4bd64a1f0d151f2adfc392ab34fd9b38894786cb/pympris/Base.py#L74-L88 | train | register handler_function to receive signal_name. |
wistful/pympris | pympris/Base.py | Base.register_properties_handler | def register_properties_handler(self, handler_function):
"""register `handler_function` to receive `signal_name`.
Uses dbus interface IPROPERTIES and objects path self.OBJ_PATH
to match 'PropertiesChanged' signal.
:param function handler_function: The function to be called.
"""... | python | def register_properties_handler(self, handler_function):
"""register `handler_function` to receive `signal_name`.
Uses dbus interface IPROPERTIES and objects path self.OBJ_PATH
to match 'PropertiesChanged' signal.
:param function handler_function: The function to be called.
"""... | [
"def",
"register_properties_handler",
"(",
"self",
",",
"handler_function",
")",
":",
"handler",
"=",
"filter_properties_signals",
"(",
"signal_wrapper",
"(",
"handler_function",
")",
",",
"self",
".",
"IFACE",
")",
"self",
".",
"bus",
".",
"add_signal_receiver",
... | register `handler_function` to receive `signal_name`.
Uses dbus interface IPROPERTIES and objects path self.OBJ_PATH
to match 'PropertiesChanged' signal.
:param function handler_function: The function to be called. | [
"register",
"handler_function",
"to",
"receive",
"signal_name",
"."
] | 4bd64a1f0d151f2adfc392ab34fd9b38894786cb | https://github.com/wistful/pympris/blob/4bd64a1f0d151f2adfc392ab34fd9b38894786cb/pympris/Base.py#L90-L106 | train | register handler_function to receive signal_name. |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/variant_extras/frequencies.py | FrequenciesExtras._add_thousand_g | def _add_thousand_g(self, variant_obj, info_dict):
"""Add the thousand genomes frequency
Args:
variant_obj (puzzle.models.Variant)
info_dict (dict): A info dictionary
"""
thousand_g = info_dict.get('1000GAF')
if thousand_g:
lo... | python | def _add_thousand_g(self, variant_obj, info_dict):
"""Add the thousand genomes frequency
Args:
variant_obj (puzzle.models.Variant)
info_dict (dict): A info dictionary
"""
thousand_g = info_dict.get('1000GAF')
if thousand_g:
lo... | [
"def",
"_add_thousand_g",
"(",
"self",
",",
"variant_obj",
",",
"info_dict",
")",
":",
"thousand_g",
"=",
"info_dict",
".",
"get",
"(",
"'1000GAF'",
")",
"if",
"thousand_g",
":",
"logger",
".",
"debug",
"(",
"\"Updating thousand_g to: {0}\"",
".",
"format",
"(... | Add the thousand genomes frequency
Args:
variant_obj (puzzle.models.Variant)
info_dict (dict): A info dictionary | [
"Add",
"the",
"thousand",
"genomes",
"frequency",
"Args",
":",
"variant_obj",
"(",
"puzzle",
".",
"models",
".",
"Variant",
")",
"info_dict",
"(",
"dict",
")",
":",
"A",
"info",
"dictionary"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_extras/frequencies.py#L8-L21 | train | Adds the thousand genomes frequency
to the variant object. |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/variant_extras/frequencies.py | FrequenciesExtras._add_gmaf | def _add_gmaf(self, variant_obj, info_dict):
"""Add the gmaf frequency
Args:
variant_obj (puzzle.models.Variant)
info_dict (dict): A info dictionary
"""
##TODO search for max freq in info dict
for transcript in variant_obj.transcripts:
... | python | def _add_gmaf(self, variant_obj, info_dict):
"""Add the gmaf frequency
Args:
variant_obj (puzzle.models.Variant)
info_dict (dict): A info dictionary
"""
##TODO search for max freq in info dict
for transcript in variant_obj.transcripts:
... | [
"def",
"_add_gmaf",
"(",
"self",
",",
"variant_obj",
",",
"info_dict",
")",
":",
"##TODO search for max freq in info dict",
"for",
"transcript",
"in",
"variant_obj",
".",
"transcripts",
":",
"gmaf_raw",
"=",
"transcript",
".",
"GMAF",
"if",
"gmaf_raw",
":",
"gmaf"... | Add the gmaf frequency
Args:
variant_obj (puzzle.models.Variant)
info_dict (dict): A info dictionary | [
"Add",
"the",
"gmaf",
"frequency",
"Args",
":",
"variant_obj",
"(",
"puzzle",
".",
"models",
".",
"Variant",
")",
"info_dict",
"(",
"dict",
")",
":",
"A",
"info",
"dictionary"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_extras/frequencies.py#L23-L39 | train | Add the gmaf frequency to the variant_obj if it doesn t already exist |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/variant_extras/frequencies.py | FrequenciesExtras._add_exac | def _add_exac(self, variant_obj, info_dict):
"""Add the gmaf frequency
Args:
variant_obj (puzzle.models.Variant)
info_dict (dict): A info dictionary
"""
exac = None
exac_keys = ['ExAC', 'EXAC', 'ExACAF', 'EXACAF']
for key in exac_... | python | def _add_exac(self, variant_obj, info_dict):
"""Add the gmaf frequency
Args:
variant_obj (puzzle.models.Variant)
info_dict (dict): A info dictionary
"""
exac = None
exac_keys = ['ExAC', 'EXAC', 'ExACAF', 'EXACAF']
for key in exac_... | [
"def",
"_add_exac",
"(",
"self",
",",
"variant_obj",
",",
"info_dict",
")",
":",
"exac",
"=",
"None",
"exac_keys",
"=",
"[",
"'ExAC'",
",",
"'EXAC'",
",",
"'ExACAF'",
",",
"'EXACAF'",
"]",
"for",
"key",
"in",
"exac_keys",
":",
"if",
"info_dict",
".",
"... | Add the gmaf frequency
Args:
variant_obj (puzzle.models.Variant)
info_dict (dict): A info dictionary | [
"Add",
"the",
"gmaf",
"frequency",
"Args",
":",
"variant_obj",
"(",
"puzzle",
".",
"models",
".",
"Variant",
")",
"info_dict",
"(",
"dict",
")",
":",
"A",
"info",
"dictionary"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_extras/frequencies.py#L41-L62 | train | Add the gmaf frequency
to the variant_obj. |
eleme/meepo | meepo/pub/sqlalchemy.py | sqlalchemy_pub._pk | def _pk(self, obj):
"""Get pk values from object
:param obj: sqlalchemy object
"""
pk_values = tuple(getattr(obj, c.name)
for c in obj.__mapper__.primary_key)
if len(pk_values) == 1:
return pk_values[0]
return pk_values | python | def _pk(self, obj):
"""Get pk values from object
:param obj: sqlalchemy object
"""
pk_values = tuple(getattr(obj, c.name)
for c in obj.__mapper__.primary_key)
if len(pk_values) == 1:
return pk_values[0]
return pk_values | [
"def",
"_pk",
"(",
"self",
",",
"obj",
")",
":",
"pk_values",
"=",
"tuple",
"(",
"getattr",
"(",
"obj",
",",
"c",
".",
"name",
")",
"for",
"c",
"in",
"obj",
".",
"__mapper__",
".",
"primary_key",
")",
"if",
"len",
"(",
"pk_values",
")",
"==",
"1"... | Get pk values from object
:param obj: sqlalchemy object | [
"Get",
"pk",
"values",
"from",
"object"
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/pub/sqlalchemy.py#L135-L144 | train | Get pk values from object
AttributeNames |
eleme/meepo | meepo/pub/sqlalchemy.py | sqlalchemy_pub.session_update | def session_update(self, session, *_):
"""Record the sqlalchemy object states in the middle of session,
prepare the events for the final pub in session_commit.
"""
self._session_init(session)
session.pending_write |= set(session.new)
session.pending_update |= set(session.... | python | def session_update(self, session, *_):
"""Record the sqlalchemy object states in the middle of session,
prepare the events for the final pub in session_commit.
"""
self._session_init(session)
session.pending_write |= set(session.new)
session.pending_update |= set(session.... | [
"def",
"session_update",
"(",
"self",
",",
"session",
",",
"*",
"_",
")",
":",
"self",
".",
"_session_init",
"(",
"session",
")",
"session",
".",
"pending_write",
"|=",
"set",
"(",
"session",
".",
"new",
")",
"session",
".",
"pending_update",
"|=",
"set"... | Record the sqlalchemy object states in the middle of session,
prepare the events for the final pub in session_commit. | [
"Record",
"the",
"sqlalchemy",
"object",
"states",
"in",
"the",
"middle",
"of",
"session",
"prepare",
"the",
"events",
"for",
"the",
"final",
"pub",
"in",
"session_commit",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/pub/sqlalchemy.py#L201-L209 | train | Record the sqlalchemy object states in the middle of session |
eleme/meepo | meepo/pub/sqlalchemy.py | sqlalchemy_pub.session_commit | def session_commit(self, session):
"""Pub the events after the session committed.
This method should be linked to sqlalchemy "after_commit" event.
"""
# this may happen when there's nothing to commit
if not hasattr(session, 'meepo_unique_id'):
self.logger.debug("skip... | python | def session_commit(self, session):
"""Pub the events after the session committed.
This method should be linked to sqlalchemy "after_commit" event.
"""
# this may happen when there's nothing to commit
if not hasattr(session, 'meepo_unique_id'):
self.logger.debug("skip... | [
"def",
"session_commit",
"(",
"self",
",",
"session",
")",
":",
"# this may happen when there's nothing to commit",
"if",
"not",
"hasattr",
"(",
"session",
",",
"'meepo_unique_id'",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"skipped - session_commit\"",
... | Pub the events after the session committed.
This method should be linked to sqlalchemy "after_commit" event. | [
"Pub",
"the",
"events",
"after",
"the",
"session",
"committed",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/pub/sqlalchemy.py#L211-L222 | train | Pub the events after the session committed. |
tswicegood/Dolt | dolt/helpers.py | add_basic_auth | def add_basic_auth(dolt, username, password):
"""
Send basic auth username and password.
Normally you can use httplib2.Http.add_credentials() to add username and password.
However this has two disadvantages.
1. Some poorly implemented APIs require basic auth but don't send a
"401 Authorizat... | python | def add_basic_auth(dolt, username, password):
"""
Send basic auth username and password.
Normally you can use httplib2.Http.add_credentials() to add username and password.
However this has two disadvantages.
1. Some poorly implemented APIs require basic auth but don't send a
"401 Authorizat... | [
"def",
"add_basic_auth",
"(",
"dolt",
",",
"username",
",",
"password",
")",
":",
"return",
"dolt",
".",
"with_headers",
"(",
"Authorization",
"=",
"'Basic %s'",
"%",
"base64",
".",
"b64encode",
"(",
"'%s:%s'",
"%",
"(",
"username",
",",
"password",
")",
"... | Send basic auth username and password.
Normally you can use httplib2.Http.add_credentials() to add username and password.
However this has two disadvantages.
1. Some poorly implemented APIs require basic auth but don't send a
"401 Authorization Required". Httplib2 won't send basic auth unless the s... | [
"Send",
"basic",
"auth",
"username",
"and",
"password",
"."
] | e0da1918b7db18f885734a89f824b9e173cc30a5 | https://github.com/tswicegood/Dolt/blob/e0da1918b7db18f885734a89f824b9e173cc30a5/dolt/helpers.py#L3-L22 | train | Add basic auth to a Tomcat application. |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant_extras/genotypes.py | GenotypeExtras._add_genotypes | def _add_genotypes(self, variant_obj, gemini_variant, case_id,
individual_objs):
"""Add the genotypes for a variant for all individuals
Args:
variant_obj (puzzle.models.Variant)
gemini_variant (GeminiQueryRow): The gemini variant
... | python | def _add_genotypes(self, variant_obj, gemini_variant, case_id,
individual_objs):
"""Add the genotypes for a variant for all individuals
Args:
variant_obj (puzzle.models.Variant)
gemini_variant (GeminiQueryRow): The gemini variant
... | [
"def",
"_add_genotypes",
"(",
"self",
",",
"variant_obj",
",",
"gemini_variant",
",",
"case_id",
",",
"individual_objs",
")",
":",
"for",
"ind",
"in",
"individual_objs",
":",
"index",
"=",
"ind",
".",
"ind_index",
"variant_obj",
".",
"add_individual",
"(",
"Ge... | Add the genotypes for a variant for all individuals
Args:
variant_obj (puzzle.models.Variant)
gemini_variant (GeminiQueryRow): The gemini variant
case_id (str): related case id
individual_objs (list(dict)): A list of Indivi... | [
"Add",
"the",
"genotypes",
"for",
"a",
"variant",
"for",
"all",
"individuals"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant_extras/genotypes.py#L11-L33 | train | Add the genotypes for a variant for all individuals
COOKIE |
jam31118/vis | vis/ani.py | estimate_global_norm_range | def estimate_global_norm_range(N_t, func, num_of_sample=10, func_args={},
percen_lower=1, percen_upper=99, show_progress=True):
"""Return estimated global range for 2D (pcolormesh-like) plot.
## Returns:
- vmin
- vmax
"""
## Check input arguments
for arg in [... | python | def estimate_global_norm_range(N_t, func, num_of_sample=10, func_args={},
percen_lower=1, percen_upper=99, show_progress=True):
"""Return estimated global range for 2D (pcolormesh-like) plot.
## Returns:
- vmin
- vmax
"""
## Check input arguments
for arg in [... | [
"def",
"estimate_global_norm_range",
"(",
"N_t",
",",
"func",
",",
"num_of_sample",
"=",
"10",
",",
"func_args",
"=",
"{",
"}",
",",
"percen_lower",
"=",
"1",
",",
"percen_upper",
"=",
"99",
",",
"show_progress",
"=",
"True",
")",
":",
"## Check input argume... | Return estimated global range for 2D (pcolormesh-like) plot.
## Returns:
- vmin
- vmax | [
"Return",
"estimated",
"global",
"range",
"for",
"2D",
"(",
"pcolormesh",
"-",
"like",
")",
"plot",
"."
] | 965ebec102c539b323d5756fef04153ac71e50d9 | https://github.com/jam31118/vis/blob/965ebec102c539b323d5756fef04153ac71e50d9/vis/ani.py#L43-L83 | train | Estimate global normal range for 2D plot. |
jam31118/vis | vis/ani.py | process_frames_argument | def process_frames_argument(frames):
"""
Check and process 'frames' argument
into a proper iterable for an animation object
## Arguments
# frames
: a seed for an integer-type iterable that is used as a sequence of frame indices
- if integer or integer-valued float (e.g. 1.0):
The 'f... | python | def process_frames_argument(frames):
"""
Check and process 'frames' argument
into a proper iterable for an animation object
## Arguments
# frames
: a seed for an integer-type iterable that is used as a sequence of frame indices
- if integer or integer-valued float (e.g. 1.0):
The 'f... | [
"def",
"process_frames_argument",
"(",
"frames",
")",
":",
"result",
"=",
"None",
"if",
"np",
".",
"iterable",
"(",
"frames",
")",
":",
"try",
":",
"frames_arr",
"=",
"np",
".",
"array",
"(",
"frames",
")",
"except",
":",
"raise",
"TypeError",
"(",
"\"... | Check and process 'frames' argument
into a proper iterable for an animation object
## Arguments
# frames
: a seed for an integer-type iterable that is used as a sequence of frame indices
- if integer or integer-valued float (e.g. 1.0):
The 'frames' is interpreted as the number of total fram... | [
"Check",
"and",
"process",
"frames",
"argument",
"into",
"a",
"proper",
"iterable",
"for",
"an",
"animation",
"object"
] | 965ebec102c539b323d5756fef04153ac71e50d9 | https://github.com/jam31118/vis/blob/965ebec102c539b323d5756fef04153ac71e50d9/vis/ani.py#L86-L120 | train | Check and process the frames argument into a proper iterable for an animation object. |
jam31118/vis | vis/ani.py | Animate_Base.save | def save(self, *args, **kwargs):
"""Save animation into a movie file.
[NOTE] If 'writer' is not specified, default writer defined in this module
will be used to generate the movie file.
[TODO] Implement docstring inheritance.
"""
writer = None
if 'write... | python | def save(self, *args, **kwargs):
"""Save animation into a movie file.
[NOTE] If 'writer' is not specified, default writer defined in this module
will be used to generate the movie file.
[TODO] Implement docstring inheritance.
"""
writer = None
if 'write... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"writer",
"=",
"None",
"if",
"'writer'",
"in",
"kwargs",
".",
"keys",
"(",
")",
":",
"writer",
"=",
"kwargs",
".",
"pop",
"(",
"'writer'",
")",
"else",
":",
"writer"... | Save animation into a movie file.
[NOTE] If 'writer' is not specified, default writer defined in this module
will be used to generate the movie file.
[TODO] Implement docstring inheritance. | [
"Save",
"animation",
"into",
"a",
"movie",
"file",
".",
"[",
"NOTE",
"]",
"If",
"writer",
"is",
"not",
"specified",
"default",
"writer",
"defined",
"in",
"this",
"module",
"will",
"be",
"used",
"to",
"generate",
"the",
"movie",
"file",
"."
] | 965ebec102c539b323d5756fef04153ac71e50d9 | https://github.com/jam31118/vis/blob/965ebec102c539b323d5756fef04153ac71e50d9/vis/ani.py#L128-L140 | train | Save animation into a movie file. |
jam31118/vis | vis/ani.py | Animate_Base.show | def show(self, temp_file_name = 'ani.mp4', **kwargs):
"""
## Arguments:
- 'args' and 'kwargs' will be passed to 'self.save()'
"""
## [NOTE] Make this method as a method of base class.
## [NOTE] This should be modified to prevent erasing other existing file with ... | python | def show(self, temp_file_name = 'ani.mp4', **kwargs):
"""
## Arguments:
- 'args' and 'kwargs' will be passed to 'self.save()'
"""
## [NOTE] Make this method as a method of base class.
## [NOTE] This should be modified to prevent erasing other existing file with ... | [
"def",
"show",
"(",
"self",
",",
"temp_file_name",
"=",
"'ani.mp4'",
",",
"*",
"*",
"kwargs",
")",
":",
"## [NOTE] Make this method as a method of base class.",
"## [NOTE] This should be modified to prevent erasing other existing file with the same name.",
"assert",
"type",
"(",
... | ## Arguments:
- 'args' and 'kwargs' will be passed to 'self.save()' | [
"##",
"Arguments",
":",
"-",
"args",
"and",
"kwargs",
"will",
"be",
"passed",
"to",
"self",
".",
"save",
"()"
] | 965ebec102c539b323d5756fef04153ac71e50d9 | https://github.com/jam31118/vis/blob/965ebec102c539b323d5756fef04153ac71e50d9/vis/ani.py#L143-L163 | train | Returns a string containing the content of the current image. |
robinandeer/puzzle | puzzle/cli/init.py | init | def init(ctx, reset, root, phenomizer):
"""Initialize a database that store metadata
Check if "root" dir exists, otherwise create the directory and
build the database. If a database already exists, do nothing.
"""
configs = {}
if root is None:
root = ctx.obj.get('root') or os.p... | python | def init(ctx, reset, root, phenomizer):
"""Initialize a database that store metadata
Check if "root" dir exists, otherwise create the directory and
build the database. If a database already exists, do nothing.
"""
configs = {}
if root is None:
root = ctx.obj.get('root') or os.p... | [
"def",
"init",
"(",
"ctx",
",",
"reset",
",",
"root",
",",
"phenomizer",
")",
":",
"configs",
"=",
"{",
"}",
"if",
"root",
"is",
"None",
":",
"root",
"=",
"ctx",
".",
"obj",
".",
"get",
"(",
"'root'",
")",
"or",
"os",
".",
"path",
".",
"expandu... | Initialize a database that store metadata
Check if "root" dir exists, otherwise create the directory and
build the database. If a database already exists, do nothing. | [
"Initialize",
"a",
"database",
"that",
"store",
"metadata"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/cli/init.py#L23-L69 | train | Initialize a database that stores metadata for a specific language. |
seb-m/tss | tss.py | encode | def encode(value, encoding='utf-8', encoding_errors='strict'):
"""
Return a bytestring representation of the value.
"""
if isinstance(value, bytes):
return value
if not isinstance(value, basestring):
value = str(value)
if isinstance(value, unicode):
value = value.encode(e... | python | def encode(value, encoding='utf-8', encoding_errors='strict'):
"""
Return a bytestring representation of the value.
"""
if isinstance(value, bytes):
return value
if not isinstance(value, basestring):
value = str(value)
if isinstance(value, unicode):
value = value.encode(e... | [
"def",
"encode",
"(",
"value",
",",
"encoding",
"=",
"'utf-8'",
",",
"encoding_errors",
"=",
"'strict'",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bytes",
")",
":",
"return",
"value",
"if",
"not",
"isinstance",
"(",
"value",
",",
"basestring",
")... | Return a bytestring representation of the value. | [
"Return",
"a",
"bytestring",
"representation",
"of",
"the",
"value",
"."
] | ab45176b8585ba6bbbcaeffd21ec0c63f615dce0 | https://github.com/seb-m/tss/blob/ab45176b8585ba6bbbcaeffd21ec0c63f615dce0/tss.py#L53-L63 | train | Encodes the given value into a bytestring representation of the given encoding. |
seb-m/tss | tss.py | share_secret | def share_secret(threshold, nshares, secret, identifier, hash_id=Hash.SHA256):
"""
Create nshares of the secret. threshold specifies the number of shares
needed for reconstructing the secret value. A 0-16 bytes identifier must
be provided. Optionally the secret is hashed with the algorithm specified
... | python | def share_secret(threshold, nshares, secret, identifier, hash_id=Hash.SHA256):
"""
Create nshares of the secret. threshold specifies the number of shares
needed for reconstructing the secret value. A 0-16 bytes identifier must
be provided. Optionally the secret is hashed with the algorithm specified
... | [
"def",
"share_secret",
"(",
"threshold",
",",
"nshares",
",",
"secret",
",",
"identifier",
",",
"hash_id",
"=",
"Hash",
".",
"SHA256",
")",
":",
"if",
"identifier",
"is",
"None",
":",
"raise",
"TSSError",
"(",
"'an identifier must be provided'",
")",
"if",
"... | Create nshares of the secret. threshold specifies the number of shares
needed for reconstructing the secret value. A 0-16 bytes identifier must
be provided. Optionally the secret is hashed with the algorithm specified
by hash_id, a class attribute of Hash.
This function must return a list of formatted s... | [
"Create",
"nshares",
"of",
"the",
"secret",
".",
"threshold",
"specifies",
"the",
"number",
"of",
"shares",
"needed",
"for",
"reconstructing",
"the",
"secret",
"value",
".",
"A",
"0",
"-",
"16",
"bytes",
"identifier",
"must",
"be",
"provided",
".",
"Optional... | ab45176b8585ba6bbbcaeffd21ec0c63f615dce0 | https://github.com/seb-m/tss/blob/ab45176b8585ba6bbbcaeffd21ec0c63f615dce0/tss.py#L212-L231 | train | This function creates nshares shares of a secret. |
seb-m/tss | tss.py | reconstruct_secret | def reconstruct_secret(shares, strict_mode=True):
"""
shares must be a container with a sufficient number of well-formatted
shares used to reconstruct the secret value. If any share format is
invalid a TSSError exception is raised.
If strict_mode is False all combinations of shares are tried in orde... | python | def reconstruct_secret(shares, strict_mode=True):
"""
shares must be a container with a sufficient number of well-formatted
shares used to reconstruct the secret value. If any share format is
invalid a TSSError exception is raised.
If strict_mode is False all combinations of shares are tried in orde... | [
"def",
"reconstruct_secret",
"(",
"shares",
",",
"strict_mode",
"=",
"True",
")",
":",
"ref_header",
"=",
"None",
"data_shares",
"=",
"[",
"]",
"for",
"share",
"in",
"shares",
":",
"share",
"=",
"encode",
"(",
"share",
")",
"if",
"len",
"(",
"share",
"... | shares must be a container with a sufficient number of well-formatted
shares used to reconstruct the secret value. If any share format is
invalid a TSSError exception is raised.
If strict_mode is False all combinations of shares are tried in order
to reconstruct the secret. Otherwise this function raise... | [
"shares",
"must",
"be",
"a",
"container",
"with",
"a",
"sufficient",
"number",
"of",
"well",
"-",
"formatted",
"shares",
"used",
"to",
"reconstruct",
"the",
"secret",
"value",
".",
"If",
"any",
"share",
"format",
"is",
"invalid",
"a",
"TSSError",
"exception"... | ab45176b8585ba6bbbcaeffd21ec0c63f615dce0 | https://github.com/seb-m/tss/blob/ab45176b8585ba6bbbcaeffd21ec0c63f615dce0/tss.py#L253-L307 | train | Reconstructs the secret value of a list of well - formatted shares. |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant_extras/frequencies.py | FrequenciesExtras._add_gmaf | def _add_gmaf(self, variant_obj, gemini_variant):
"""Add the gmaf frequency
Args:
variant_obj (puzzle.models.Variant)
gemini_variant (GeminiQueryRow)
"""
max_af = gemini_variant['max_aaf_all']
if max_af:
max_af = float(max_af)... | python | def _add_gmaf(self, variant_obj, gemini_variant):
"""Add the gmaf frequency
Args:
variant_obj (puzzle.models.Variant)
gemini_variant (GeminiQueryRow)
"""
max_af = gemini_variant['max_aaf_all']
if max_af:
max_af = float(max_af)... | [
"def",
"_add_gmaf",
"(",
"self",
",",
"variant_obj",
",",
"gemini_variant",
")",
":",
"max_af",
"=",
"gemini_variant",
"[",
"'max_aaf_all'",
"]",
"if",
"max_af",
":",
"max_af",
"=",
"float",
"(",
"max_af",
")",
"if",
"max_af",
"!=",
"-",
"1.0",
":",
"var... | Add the gmaf frequency
Args:
variant_obj (puzzle.models.Variant)
gemini_variant (GeminiQueryRow) | [
"Add",
"the",
"gmaf",
"frequency",
"Args",
":",
"variant_obj",
"(",
"puzzle",
".",
"models",
".",
"Variant",
")",
"gemini_variant",
"(",
"GeminiQueryRow",
")"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant_extras/frequencies.py#L23-L35 | train | Add the gmaf frequency to the variant object. |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant_extras/frequencies.py | FrequenciesExtras._add_exac | def _add_exac(self, variant_obj, gemini_variant):
"""Add the gmaf frequency
Args:
variant_obj (puzzle.models.Variant)
gemini_variant (GeminiQueryRow)
"""
exac = gemini_variant['aaf_exac_all']
if exac:
exac = float(exac)
... | python | def _add_exac(self, variant_obj, gemini_variant):
"""Add the gmaf frequency
Args:
variant_obj (puzzle.models.Variant)
gemini_variant (GeminiQueryRow)
"""
exac = gemini_variant['aaf_exac_all']
if exac:
exac = float(exac)
... | [
"def",
"_add_exac",
"(",
"self",
",",
"variant_obj",
",",
"gemini_variant",
")",
":",
"exac",
"=",
"gemini_variant",
"[",
"'aaf_exac_all'",
"]",
"if",
"exac",
":",
"exac",
"=",
"float",
"(",
"exac",
")",
"variant_obj",
".",
"add_frequency",
"(",
"'ExAC'",
... | Add the gmaf frequency
Args:
variant_obj (puzzle.models.Variant)
gemini_variant (GeminiQueryRow) | [
"Add",
"the",
"gmaf",
"frequency",
"Args",
":",
"variant_obj",
"(",
"puzzle",
".",
"models",
".",
"Variant",
")",
"gemini_variant",
"(",
"GeminiQueryRow",
")"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant_extras/frequencies.py#L37-L49 | train | Adds the gmaf frequency
to the variant_obj. |
robinandeer/puzzle | puzzle/utils/get_info.py | get_gene_symbols | def get_gene_symbols(chrom, start, stop):
"""Get the gene symbols that a interval overlaps"""
gene_symbols = query_gene_symbol(chrom, start, stop)
logger.debug("Found gene symbols: {0}".format(', '.join(gene_symbols)))
return gene_symbols | python | def get_gene_symbols(chrom, start, stop):
"""Get the gene symbols that a interval overlaps"""
gene_symbols = query_gene_symbol(chrom, start, stop)
logger.debug("Found gene symbols: {0}".format(', '.join(gene_symbols)))
return gene_symbols | [
"def",
"get_gene_symbols",
"(",
"chrom",
",",
"start",
",",
"stop",
")",
":",
"gene_symbols",
"=",
"query_gene_symbol",
"(",
"chrom",
",",
"start",
",",
"stop",
")",
"logger",
".",
"debug",
"(",
"\"Found gene symbols: {0}\"",
".",
"format",
"(",
"', '",
".",... | Get the gene symbols that a interval overlaps | [
"Get",
"the",
"gene",
"symbols",
"that",
"a",
"interval",
"overlaps"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/utils/get_info.py#L23-L27 | train | Get the gene symbols that a interval overlaps |
robinandeer/puzzle | puzzle/utils/get_info.py | get_gene_info | def get_gene_info(ensembl_ids=None, hgnc_symbols=None):
"""Return the genes info based on the transcripts found
Args:
ensembl_ids (Optional[list]): list of Ensembl gene ids
hgnc_symbols (Optional[list]): list of HGNC gene symbols
Returns:
iterable: an iterable with `Gene` objects
... | python | def get_gene_info(ensembl_ids=None, hgnc_symbols=None):
"""Return the genes info based on the transcripts found
Args:
ensembl_ids (Optional[list]): list of Ensembl gene ids
hgnc_symbols (Optional[list]): list of HGNC gene symbols
Returns:
iterable: an iterable with `Gene` objects
... | [
"def",
"get_gene_info",
"(",
"ensembl_ids",
"=",
"None",
",",
"hgnc_symbols",
"=",
"None",
")",
":",
"uniq_ensembl_ids",
"=",
"set",
"(",
"ensembl_id",
"for",
"ensembl_id",
"in",
"(",
"ensembl_ids",
"or",
"[",
"]",
")",
")",
"uniq_hgnc_symbols",
"=",
"set",
... | Return the genes info based on the transcripts found
Args:
ensembl_ids (Optional[list]): list of Ensembl gene ids
hgnc_symbols (Optional[list]): list of HGNC gene symbols
Returns:
iterable: an iterable with `Gene` objects | [
"Return",
"the",
"genes",
"info",
"based",
"on",
"the",
"transcripts",
"found"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/utils/get_info.py#L29-L83 | train | Return the genes info based on the transcripts found
|
robinandeer/puzzle | puzzle/utils/get_info.py | get_most_severe_consequence | def get_most_severe_consequence(transcripts):
"""Get the most severe consequence
Go through all transcripts and get the most severe consequence
Args:
transcripts (list): A list of transcripts to evaluate
Returns:
most_severe_consequence (str): The most severe conse... | python | def get_most_severe_consequence(transcripts):
"""Get the most severe consequence
Go through all transcripts and get the most severe consequence
Args:
transcripts (list): A list of transcripts to evaluate
Returns:
most_severe_consequence (str): The most severe conse... | [
"def",
"get_most_severe_consequence",
"(",
"transcripts",
")",
":",
"most_severe_consequence",
"=",
"None",
"most_severe_score",
"=",
"None",
"for",
"transcript",
"in",
"transcripts",
":",
"for",
"consequence",
"in",
"transcript",
"[",
"'consequence'",
"]",
".",
"sp... | Get the most severe consequence
Go through all transcripts and get the most severe consequence
Args:
transcripts (list): A list of transcripts to evaluate
Returns:
most_severe_consequence (str): The most severe consequence | [
"Get",
"the",
"most",
"severe",
"consequence"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/utils/get_info.py#L85-L119 | train | Get the most severe consequence from the transcripts and return the most severe consequence. |
robinandeer/puzzle | puzzle/utils/get_info.py | get_cytoband_coord | def get_cytoband_coord(chrom, pos):
"""Get the cytoband coordinate for a position
Args:
chrom(str): A chromosome
pos(int): The position
Returns:
cytoband
"""
chrom = chrom.strip('chr')
pos = int(pos)
result = None
logger.debug("Finding Cytoba... | python | def get_cytoband_coord(chrom, pos):
"""Get the cytoband coordinate for a position
Args:
chrom(str): A chromosome
pos(int): The position
Returns:
cytoband
"""
chrom = chrom.strip('chr')
pos = int(pos)
result = None
logger.debug("Finding Cytoba... | [
"def",
"get_cytoband_coord",
"(",
"chrom",
",",
"pos",
")",
":",
"chrom",
"=",
"chrom",
".",
"strip",
"(",
"'chr'",
")",
"pos",
"=",
"int",
"(",
"pos",
")",
"result",
"=",
"None",
"logger",
".",
"debug",
"(",
"\"Finding Cytoband for chrom:{0} pos:{1}\"",
"... | Get the cytoband coordinate for a position
Args:
chrom(str): A chromosome
pos(int): The position
Returns:
cytoband | [
"Get",
"the",
"cytoband",
"coordinate",
"for",
"a",
"position"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/utils/get_info.py#L121-L139 | train | Get the cytoband coordinate for a position in a sequence. |
jreese/dotlink | dotlink/dotlink.py | Dotlink.parse_mapping | def parse_mapping(self, map_path, source=None, dotfiles=None):
"""Do a simple parse of the dotfile mapping, using semicolons to
separate source file name from the target file paths."""
include_re = r"""^\s*#include\s+(".+"|'.+')"""
include_re = re.compile(include_re, re.I)
mappin... | python | def parse_mapping(self, map_path, source=None, dotfiles=None):
"""Do a simple parse of the dotfile mapping, using semicolons to
separate source file name from the target file paths."""
include_re = r"""^\s*#include\s+(".+"|'.+')"""
include_re = re.compile(include_re, re.I)
mappin... | [
"def",
"parse_mapping",
"(",
"self",
",",
"map_path",
",",
"source",
"=",
"None",
",",
"dotfiles",
"=",
"None",
")",
":",
"include_re",
"=",
"r\"\"\"^\\s*#include\\s+(\".+\"|'.+')\"\"\"",
"include_re",
"=",
"re",
".",
"compile",
"(",
"include_re",
",",
"re",
"... | Do a simple parse of the dotfile mapping, using semicolons to
separate source file name from the target file paths. | [
"Do",
"a",
"simple",
"parse",
"of",
"the",
"dotfile",
"mapping",
"using",
"semicolons",
"to",
"separate",
"source",
"file",
"name",
"from",
"the",
"target",
"file",
"paths",
"."
] | 5e48c1493c20fc6df4ad0144e80563915ce339b6 | https://github.com/jreese/dotlink/blob/5e48c1493c20fc6df4ad0144e80563915ce339b6/dotlink/dotlink.py#L129-L211 | train | Parse the dotfile mapping file. |
jreese/dotlink | dotlink/dotlink.py | Dotlink.sh | def sh(self, *command, **kwargs):
"""Run a shell command with the given arguments."""
self.log.debug('shell: %s', ' '.join(command))
return subprocess.check_call(' '.join(command),
stdout=sys.stdout,
stderr=sys.stderr,
... | python | def sh(self, *command, **kwargs):
"""Run a shell command with the given arguments."""
self.log.debug('shell: %s', ' '.join(command))
return subprocess.check_call(' '.join(command),
stdout=sys.stdout,
stderr=sys.stderr,
... | [
"def",
"sh",
"(",
"self",
",",
"*",
"command",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'shell: %s'",
",",
"' '",
".",
"join",
"(",
"command",
")",
")",
"return",
"subprocess",
".",
"check_call",
"(",
"' '",
".",
... | Run a shell command with the given arguments. | [
"Run",
"a",
"shell",
"command",
"with",
"the",
"given",
"arguments",
"."
] | 5e48c1493c20fc6df4ad0144e80563915ce339b6 | https://github.com/jreese/dotlink/blob/5e48c1493c20fc6df4ad0144e80563915ce339b6/dotlink/dotlink.py#L213-L220 | train | Run a shell command with the given arguments. |
jreese/dotlink | dotlink/dotlink.py | Dotlink.ssh | def ssh(self, *command):
"""Run an ssh command using the configured user/server values."""
if self.args.user:
ssh_spec = '{0}@{1}'.format(self.args.user, self.args.server)
else:
ssh_spec = self.args.server
return self.sh('ssh', ssh_spec, *command) | python | def ssh(self, *command):
"""Run an ssh command using the configured user/server values."""
if self.args.user:
ssh_spec = '{0}@{1}'.format(self.args.user, self.args.server)
else:
ssh_spec = self.args.server
return self.sh('ssh', ssh_spec, *command) | [
"def",
"ssh",
"(",
"self",
",",
"*",
"command",
")",
":",
"if",
"self",
".",
"args",
".",
"user",
":",
"ssh_spec",
"=",
"'{0}@{1}'",
".",
"format",
"(",
"self",
".",
"args",
".",
"user",
",",
"self",
".",
"args",
".",
"server",
")",
"else",
":",
... | Run an ssh command using the configured user/server values. | [
"Run",
"an",
"ssh",
"command",
"using",
"the",
"configured",
"user",
"/",
"server",
"values",
"."
] | 5e48c1493c20fc6df4ad0144e80563915ce339b6 | https://github.com/jreese/dotlink/blob/5e48c1493c20fc6df4ad0144e80563915ce339b6/dotlink/dotlink.py#L222-L229 | train | Run an ssh command using the configured user and server values. |
jreese/dotlink | dotlink/dotlink.py | Dotlink.scp | def scp(self, local_file, remote_path=''):
"""Copy a local file to the given remote path."""
if self.args.user:
upload_spec = '{0}@{1}:{2}'.format(self.args.user,
self.args.server,
remote_path)
... | python | def scp(self, local_file, remote_path=''):
"""Copy a local file to the given remote path."""
if self.args.user:
upload_spec = '{0}@{1}:{2}'.format(self.args.user,
self.args.server,
remote_path)
... | [
"def",
"scp",
"(",
"self",
",",
"local_file",
",",
"remote_path",
"=",
"''",
")",
":",
"if",
"self",
".",
"args",
".",
"user",
":",
"upload_spec",
"=",
"'{0}@{1}:{2}'",
".",
"format",
"(",
"self",
".",
"args",
".",
"user",
",",
"self",
".",
"args",
... | Copy a local file to the given remote path. | [
"Copy",
"a",
"local",
"file",
"to",
"the",
"given",
"remote",
"path",
"."
] | 5e48c1493c20fc6df4ad0144e80563915ce339b6 | https://github.com/jreese/dotlink/blob/5e48c1493c20fc6df4ad0144e80563915ce339b6/dotlink/dotlink.py#L231-L240 | train | Copy a local file to the given remote path. |
jreese/dotlink | dotlink/dotlink.py | Dotlink.run | def run(self):
"""Start the dotfile deployment process."""
script = path.realpath(__file__)
self.log.debug('Running from %s with arguments: %s', script, self.args)
if self.args.source:
self.source = self.args.source
else:
# hardcoding as the parent-parent... | python | def run(self):
"""Start the dotfile deployment process."""
script = path.realpath(__file__)
self.log.debug('Running from %s with arguments: %s', script, self.args)
if self.args.source:
self.source = self.args.source
else:
# hardcoding as the parent-parent... | [
"def",
"run",
"(",
"self",
")",
":",
"script",
"=",
"path",
".",
"realpath",
"(",
"__file__",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'Running from %s with arguments: %s'",
",",
"script",
",",
"self",
".",
"args",
")",
"if",
"self",
".",
"args",
"... | Start the dotfile deployment process. | [
"Start",
"the",
"dotfile",
"deployment",
"process",
"."
] | 5e48c1493c20fc6df4ad0144e80563915ce339b6 | https://github.com/jreese/dotlink/blob/5e48c1493c20fc6df4ad0144e80563915ce339b6/dotlink/dotlink.py#L246-L269 | train | Start the dotfile deployment process. |
jreese/dotlink | dotlink/dotlink.py | Dotlink.load_dotfiles | def load_dotfiles(self):
"""Read in the dotfile mapping as a dictionary."""
if self.args.map and path.exists(self.args.map):
dotfiles_path = self.args.map
else:
dotfiles_path = self.source
self.log.debug('Loading dotfile mapping from %s', dotfiles_path)
... | python | def load_dotfiles(self):
"""Read in the dotfile mapping as a dictionary."""
if self.args.map and path.exists(self.args.map):
dotfiles_path = self.args.map
else:
dotfiles_path = self.source
self.log.debug('Loading dotfile mapping from %s', dotfiles_path)
... | [
"def",
"load_dotfiles",
"(",
"self",
")",
":",
"if",
"self",
".",
"args",
".",
"map",
"and",
"path",
".",
"exists",
"(",
"self",
".",
"args",
".",
"map",
")",
":",
"dotfiles_path",
"=",
"self",
".",
"args",
".",
"map",
"else",
":",
"dotfiles_path",
... | Read in the dotfile mapping as a dictionary. | [
"Read",
"in",
"the",
"dotfile",
"mapping",
"as",
"a",
"dictionary",
"."
] | 5e48c1493c20fc6df4ad0144e80563915ce339b6 | https://github.com/jreese/dotlink/blob/5e48c1493c20fc6df4ad0144e80563915ce339b6/dotlink/dotlink.py#L271-L280 | train | Read in the dotfile mapping as a dictionary. |
jreese/dotlink | dotlink/dotlink.py | Dotlink.clone_repo | def clone_repo(self):
"""Clone a repository containing the dotfiles source."""
tempdir_path = tempfile.mkdtemp()
if self.args.git:
self.log.debug('Cloning git source repository from %s to %s',
self.source, tempdir_path)
self.sh('git clone', sel... | python | def clone_repo(self):
"""Clone a repository containing the dotfiles source."""
tempdir_path = tempfile.mkdtemp()
if self.args.git:
self.log.debug('Cloning git source repository from %s to %s',
self.source, tempdir_path)
self.sh('git clone', sel... | [
"def",
"clone_repo",
"(",
"self",
")",
":",
"tempdir_path",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"if",
"self",
".",
"args",
".",
"git",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Cloning git source repository from %s to %s'",
",",
"self",
".",
"so... | Clone a repository containing the dotfiles source. | [
"Clone",
"a",
"repository",
"containing",
"the",
"dotfiles",
"source",
"."
] | 5e48c1493c20fc6df4ad0144e80563915ce339b6 | https://github.com/jreese/dotlink/blob/5e48c1493c20fc6df4ad0144e80563915ce339b6/dotlink/dotlink.py#L282-L294 | train | Clone a git repository containing the dotfiles source. |
jreese/dotlink | dotlink/dotlink.py | Dotlink.cleanup_repo | def cleanup_repo(self):
"""Cleanup the temporary directory containing the dotfiles repo."""
if self.source and path.isdir(self.source):
self.log.debug('Cleaning up source repo from %s', self.source)
shutil.rmtree(self.source) | python | def cleanup_repo(self):
"""Cleanup the temporary directory containing the dotfiles repo."""
if self.source and path.isdir(self.source):
self.log.debug('Cleaning up source repo from %s', self.source)
shutil.rmtree(self.source) | [
"def",
"cleanup_repo",
"(",
"self",
")",
":",
"if",
"self",
".",
"source",
"and",
"path",
".",
"isdir",
"(",
"self",
".",
"source",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Cleaning up source repo from %s'",
",",
"self",
".",
"source",
")",
"... | Cleanup the temporary directory containing the dotfiles repo. | [
"Cleanup",
"the",
"temporary",
"directory",
"containing",
"the",
"dotfiles",
"repo",
"."
] | 5e48c1493c20fc6df4ad0144e80563915ce339b6 | https://github.com/jreese/dotlink/blob/5e48c1493c20fc6df4ad0144e80563915ce339b6/dotlink/dotlink.py#L296-L300 | train | Cleanup the temporary directory containing the dotfiles repo. |
jreese/dotlink | dotlink/dotlink.py | Dotlink.deploy_dotfiles | def deploy_dotfiles(self, dotfiles):
"""Deploy dotfiles using the appropriate method."""
if self.args.server:
return self.deploy_remote(dotfiles)
else:
return self.deploy_local(dotfiles) | python | def deploy_dotfiles(self, dotfiles):
"""Deploy dotfiles using the appropriate method."""
if self.args.server:
return self.deploy_remote(dotfiles)
else:
return self.deploy_local(dotfiles) | [
"def",
"deploy_dotfiles",
"(",
"self",
",",
"dotfiles",
")",
":",
"if",
"self",
".",
"args",
".",
"server",
":",
"return",
"self",
".",
"deploy_remote",
"(",
"dotfiles",
")",
"else",
":",
"return",
"self",
".",
"deploy_local",
"(",
"dotfiles",
")"
] | Deploy dotfiles using the appropriate method. | [
"Deploy",
"dotfiles",
"using",
"the",
"appropriate",
"method",
"."
] | 5e48c1493c20fc6df4ad0144e80563915ce339b6 | https://github.com/jreese/dotlink/blob/5e48c1493c20fc6df4ad0144e80563915ce339b6/dotlink/dotlink.py#L302-L307 | train | Deploy dotfiles using the appropriate method. |
jreese/dotlink | dotlink/dotlink.py | Dotlink.deploy_remote | def deploy_remote(self, dotfiles):
"""Deploy dotfiles to a remote server."""
tempfile_path = None
tempdir_path = None
try:
tempdir_path = tempfile.mkdtemp()
self.log.debug('Deploying to temp dir %s', tempdir_path)
self.deploy_local(dotfiles, target_ro... | python | def deploy_remote(self, dotfiles):
"""Deploy dotfiles to a remote server."""
tempfile_path = None
tempdir_path = None
try:
tempdir_path = tempfile.mkdtemp()
self.log.debug('Deploying to temp dir %s', tempdir_path)
self.deploy_local(dotfiles, target_ro... | [
"def",
"deploy_remote",
"(",
"self",
",",
"dotfiles",
")",
":",
"tempfile_path",
"=",
"None",
"tempdir_path",
"=",
"None",
"try",
":",
"tempdir_path",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'Deploying to temp dir %... | Deploy dotfiles to a remote server. | [
"Deploy",
"dotfiles",
"to",
"a",
"remote",
"server",
"."
] | 5e48c1493c20fc6df4ad0144e80563915ce339b6 | https://github.com/jreese/dotlink/blob/5e48c1493c20fc6df4ad0144e80563915ce339b6/dotlink/dotlink.py#L309-L364 | train | Deploy dotfiles to a remote server. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.