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 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
OLC-Bioinformatics/sipprverse | genesippr_validation.py | ReadPrep.link_reads | def link_reads(self, analysistype):
"""
Create folders with relative symlinks to the desired simulated/sampled reads. These folders will contain all
the reads created for each sample, and will be processed with GeneSippr and COWBAT pipelines
:param analysistype: Current analysis type. Wi... | python | def link_reads(self, analysistype):
"""
Create folders with relative symlinks to the desired simulated/sampled reads. These folders will contain all
the reads created for each sample, and will be processed with GeneSippr and COWBAT pipelines
:param analysistype: Current analysis type. Wi... | [
"def",
"link_reads",
"(",
"self",
",",
"analysistype",
")",
":",
"logging",
".",
"info",
"(",
"'Linking {at} reads'",
".",
"format",
"(",
"at",
"=",
"analysistype",
")",
")",
"for",
"sample",
"in",
"self",
".",
"metadata",
":",
"# Create the output directories... | Create folders with relative symlinks to the desired simulated/sampled reads. These folders will contain all
the reads created for each sample, and will be processed with GeneSippr and COWBAT pipelines
:param analysistype: Current analysis type. Will either be 'simulated' or 'sampled' | [
"Create",
"folders",
"with",
"relative",
"symlinks",
"to",
"the",
"desired",
"simulated",
"/",
"sampled",
"reads",
".",
"These",
"folders",
"will",
"contain",
"all",
"the",
"reads",
"created",
"for",
"each",
"sample",
"and",
"will",
"be",
"processed",
"with",
... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/genesippr_validation.py#L537-L584 | train |
OLC-Bioinformatics/sipprverse | genesippr_validation.py | ReadPrep.run_genesippr | def run_genesippr(self):
"""
Run GeneSippr on each of the samples
"""
from pathlib import Path
home = str(Path.home())
logging.info('GeneSippr')
# These unfortunate hard coded paths appear to be necessary
miniconda_path = os.path.join(home, 'miniconda3')
... | python | def run_genesippr(self):
"""
Run GeneSippr on each of the samples
"""
from pathlib import Path
home = str(Path.home())
logging.info('GeneSippr')
# These unfortunate hard coded paths appear to be necessary
miniconda_path = os.path.join(home, 'miniconda3')
... | [
"def",
"run_genesippr",
"(",
"self",
")",
":",
"from",
"pathlib",
"import",
"Path",
"home",
"=",
"str",
"(",
"Path",
".",
"home",
"(",
")",
")",
"logging",
".",
"info",
"(",
"'GeneSippr'",
")",
"# These unfortunate hard coded paths appear to be necessary",
"mini... | Run GeneSippr on each of the samples | [
"Run",
"GeneSippr",
"on",
"each",
"of",
"the",
"samples"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/genesippr_validation.py#L586-L620 | train |
dnanhkhoa/logone | logone/logone.py | LogOne.set_level | def set_level(self, level):
"""
Set the logging level of this logger.
:param level: must be an int or a str.
"""
for handler in self.__coloredlogs_handlers:
handler.setLevel(level=level)
self.logger.setLevel(level=level) | python | def set_level(self, level):
"""
Set the logging level of this logger.
:param level: must be an int or a str.
"""
for handler in self.__coloredlogs_handlers:
handler.setLevel(level=level)
self.logger.setLevel(level=level) | [
"def",
"set_level",
"(",
"self",
",",
"level",
")",
":",
"for",
"handler",
"in",
"self",
".",
"__coloredlogs_handlers",
":",
"handler",
".",
"setLevel",
"(",
"level",
"=",
"level",
")",
"self",
".",
"logger",
".",
"setLevel",
"(",
"level",
"=",
"level",
... | Set the logging level of this logger.
:param level: must be an int or a str. | [
"Set",
"the",
"logging",
"level",
"of",
"this",
"logger",
"."
] | 7345a59e54ae59418a2c35ae7e7af5b2784fa1b5 | https://github.com/dnanhkhoa/logone/blob/7345a59e54ae59418a2c35ae7e7af5b2784fa1b5/logone/logone.py#L87-L96 | train |
dnanhkhoa/logone | logone/logone.py | LogOne.disable_logger | def disable_logger(self, disabled=True):
"""
Disable all logging calls.
"""
# Disable standard IO streams
if disabled:
sys.stdout = _original_stdout
sys.stderr = _original_stderr
else:
sys.stdout = self.__stdout_stream
sys.s... | python | def disable_logger(self, disabled=True):
"""
Disable all logging calls.
"""
# Disable standard IO streams
if disabled:
sys.stdout = _original_stdout
sys.stderr = _original_stderr
else:
sys.stdout = self.__stdout_stream
sys.s... | [
"def",
"disable_logger",
"(",
"self",
",",
"disabled",
"=",
"True",
")",
":",
"# Disable standard IO streams",
"if",
"disabled",
":",
"sys",
".",
"stdout",
"=",
"_original_stdout",
"sys",
".",
"stderr",
"=",
"_original_stderr",
"else",
":",
"sys",
".",
"stdout... | Disable all logging calls. | [
"Disable",
"all",
"logging",
"calls",
"."
] | 7345a59e54ae59418a2c35ae7e7af5b2784fa1b5 | https://github.com/dnanhkhoa/logone/blob/7345a59e54ae59418a2c35ae7e7af5b2784fa1b5/logone/logone.py#L98-L111 | train |
dnanhkhoa/logone | logone/logone.py | LogOne.redirect_stdout | def redirect_stdout(self, enabled=True, log_level=logging.INFO):
"""
Redirect sys.stdout to file-like object.
"""
if enabled:
if self.__stdout_wrapper:
self.__stdout_wrapper.update_log_level(log_level=log_level)
else:
self.__stdout_... | python | def redirect_stdout(self, enabled=True, log_level=logging.INFO):
"""
Redirect sys.stdout to file-like object.
"""
if enabled:
if self.__stdout_wrapper:
self.__stdout_wrapper.update_log_level(log_level=log_level)
else:
self.__stdout_... | [
"def",
"redirect_stdout",
"(",
"self",
",",
"enabled",
"=",
"True",
",",
"log_level",
"=",
"logging",
".",
"INFO",
")",
":",
"if",
"enabled",
":",
"if",
"self",
".",
"__stdout_wrapper",
":",
"self",
".",
"__stdout_wrapper",
".",
"update_log_level",
"(",
"l... | Redirect sys.stdout to file-like object. | [
"Redirect",
"sys",
".",
"stdout",
"to",
"file",
"-",
"like",
"object",
"."
] | 7345a59e54ae59418a2c35ae7e7af5b2784fa1b5 | https://github.com/dnanhkhoa/logone/blob/7345a59e54ae59418a2c35ae7e7af5b2784fa1b5/logone/logone.py#L113-L128 | train |
dnanhkhoa/logone | logone/logone.py | LogOne.redirect_stderr | def redirect_stderr(self, enabled=True, log_level=logging.ERROR):
"""
Redirect sys.stderr to file-like object.
"""
if enabled:
if self.__stderr_wrapper:
self.__stderr_wrapper.update_log_level(log_level=log_level)
else:
self.__stderr... | python | def redirect_stderr(self, enabled=True, log_level=logging.ERROR):
"""
Redirect sys.stderr to file-like object.
"""
if enabled:
if self.__stderr_wrapper:
self.__stderr_wrapper.update_log_level(log_level=log_level)
else:
self.__stderr... | [
"def",
"redirect_stderr",
"(",
"self",
",",
"enabled",
"=",
"True",
",",
"log_level",
"=",
"logging",
".",
"ERROR",
")",
":",
"if",
"enabled",
":",
"if",
"self",
".",
"__stderr_wrapper",
":",
"self",
".",
"__stderr_wrapper",
".",
"update_log_level",
"(",
"... | Redirect sys.stderr to file-like object. | [
"Redirect",
"sys",
".",
"stderr",
"to",
"file",
"-",
"like",
"object",
"."
] | 7345a59e54ae59418a2c35ae7e7af5b2784fa1b5 | https://github.com/dnanhkhoa/logone/blob/7345a59e54ae59418a2c35ae7e7af5b2784fa1b5/logone/logone.py#L130-L145 | train |
dnanhkhoa/logone | logone/logone.py | LogOne.use_file | def use_file(self, enabled=True,
file_name=None,
level=logging.WARNING,
when='d',
interval=1,
backup_count=30,
delay=False,
utc=False,
at_time=None,
log_format=None,
... | python | def use_file(self, enabled=True,
file_name=None,
level=logging.WARNING,
when='d',
interval=1,
backup_count=30,
delay=False,
utc=False,
at_time=None,
log_format=None,
... | [
"def",
"use_file",
"(",
"self",
",",
"enabled",
"=",
"True",
",",
"file_name",
"=",
"None",
",",
"level",
"=",
"logging",
".",
"WARNING",
",",
"when",
"=",
"'d'",
",",
"interval",
"=",
"1",
",",
"backup_count",
"=",
"30",
",",
"delay",
"=",
"False",
... | Handler for logging to a file, rotating the log file at certain timed intervals. | [
"Handler",
"for",
"logging",
"to",
"a",
"file",
"rotating",
"the",
"log",
"file",
"at",
"certain",
"timed",
"intervals",
"."
] | 7345a59e54ae59418a2c35ae7e7af5b2784fa1b5 | https://github.com/dnanhkhoa/logone/blob/7345a59e54ae59418a2c35ae7e7af5b2784fa1b5/logone/logone.py#L147-L199 | train |
dnanhkhoa/logone | logone/logone.py | LogOne.use_loggly | def use_loggly(self, enabled=True,
loggly_token=None,
loggly_tag=None,
level=logging.WARNING,
log_format=None,
date_format=None):
"""
Enable handler for sending the record to Loggly service.
"""
... | python | def use_loggly(self, enabled=True,
loggly_token=None,
loggly_tag=None,
level=logging.WARNING,
log_format=None,
date_format=None):
"""
Enable handler for sending the record to Loggly service.
"""
... | [
"def",
"use_loggly",
"(",
"self",
",",
"enabled",
"=",
"True",
",",
"loggly_token",
"=",
"None",
",",
"loggly_tag",
"=",
"None",
",",
"level",
"=",
"logging",
".",
"WARNING",
",",
"log_format",
"=",
"None",
",",
"date_format",
"=",
"None",
")",
":",
"i... | Enable handler for sending the record to Loggly service. | [
"Enable",
"handler",
"for",
"sending",
"the",
"record",
"to",
"Loggly",
"service",
"."
] | 7345a59e54ae59418a2c35ae7e7af5b2784fa1b5 | https://github.com/dnanhkhoa/logone/blob/7345a59e54ae59418a2c35ae7e7af5b2784fa1b5/logone/logone.py#L201-L241 | train |
dnanhkhoa/logone | logone/logone.py | LogOne.__find_caller | def __find_caller(stack_info=False):
"""
Find the stack frame of the caller so that we can note the source file name,
line number and function name.
"""
frame = logging.currentframe()
# On some versions of IronPython, currentframe() returns None if
# IronPython is... | python | def __find_caller(stack_info=False):
"""
Find the stack frame of the caller so that we can note the source file name,
line number and function name.
"""
frame = logging.currentframe()
# On some versions of IronPython, currentframe() returns None if
# IronPython is... | [
"def",
"__find_caller",
"(",
"stack_info",
"=",
"False",
")",
":",
"frame",
"=",
"logging",
".",
"currentframe",
"(",
")",
"# On some versions of IronPython, currentframe() returns None if",
"# IronPython isn't run with -X:Frames.",
"if",
"frame",
":",
"frame",
"=",
"fram... | Find the stack frame of the caller so that we can note the source file name,
line number and function name. | [
"Find",
"the",
"stack",
"frame",
"of",
"the",
"caller",
"so",
"that",
"we",
"can",
"note",
"the",
"source",
"file",
"name",
"line",
"number",
"and",
"function",
"name",
"."
] | 7345a59e54ae59418a2c35ae7e7af5b2784fa1b5 | https://github.com/dnanhkhoa/logone/blob/7345a59e54ae59418a2c35ae7e7af5b2784fa1b5/logone/logone.py#L244-L272 | train |
dnanhkhoa/logone | logone/logone.py | LogOne._log | def _log(self, level, msg, *args, **kwargs):
"""
Log 'msg % args' with the integer severity 'level'.
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
logger.log(level, "We have a %s", "mysterious problem", exc_info=1)
"""
... | python | def _log(self, level, msg, *args, **kwargs):
"""
Log 'msg % args' with the integer severity 'level'.
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
logger.log(level, "We have a %s", "mysterious problem", exc_info=1)
"""
... | [
"def",
"_log",
"(",
"self",
",",
"level",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"level",
",",
"int",
")",
":",
"if",
"logging",
".",
"raiseExceptions",
":",
"raise",
"TypeError",
"(",
"'Lev... | Log 'msg % args' with the integer severity 'level'.
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
logger.log(level, "We have a %s", "mysterious problem", exc_info=1) | [
"Log",
"msg",
"%",
"args",
"with",
"the",
"integer",
"severity",
"level",
"."
] | 7345a59e54ae59418a2c35ae7e7af5b2784fa1b5 | https://github.com/dnanhkhoa/logone/blob/7345a59e54ae59418a2c35ae7e7af5b2784fa1b5/logone/logone.py#L274-L333 | train |
dnanhkhoa/logone | logone/logone.py | StdErrWrapper.flush | def flush(self):
"""
Flush the buffer, if applicable.
"""
if self.__buffer.tell() > 0:
# Write the buffer to log
# noinspection PyProtectedMember
self.__logger._log(level=self.__log_level, msg=self.__buffer.getvalue().strip(),
... | python | def flush(self):
"""
Flush the buffer, if applicable.
"""
if self.__buffer.tell() > 0:
# Write the buffer to log
# noinspection PyProtectedMember
self.__logger._log(level=self.__log_level, msg=self.__buffer.getvalue().strip(),
... | [
"def",
"flush",
"(",
"self",
")",
":",
"if",
"self",
".",
"__buffer",
".",
"tell",
"(",
")",
">",
"0",
":",
"# Write the buffer to log",
"# noinspection PyProtectedMember",
"self",
".",
"__logger",
".",
"_log",
"(",
"level",
"=",
"self",
".",
"__log_level",
... | Flush the buffer, if applicable. | [
"Flush",
"the",
"buffer",
"if",
"applicable",
"."
] | 7345a59e54ae59418a2c35ae7e7af5b2784fa1b5 | https://github.com/dnanhkhoa/logone/blob/7345a59e54ae59418a2c35ae7e7af5b2784fa1b5/logone/logone.py#L474-L485 | train |
tsnaomi/finnsyll | finnsyll/prev/v08.py | syllabify | def syllabify(word):
'''Syllabify the given word, whether simplex or complex.'''
compound = bool(re.search(r'(-| |=)', word))
syllabify = _syllabify_compound if compound else _syllabify
syllabifications = list(syllabify(word))
for syll, rules in syllabifications:
yield syll, rules
n = ... | python | def syllabify(word):
'''Syllabify the given word, whether simplex or complex.'''
compound = bool(re.search(r'(-| |=)', word))
syllabify = _syllabify_compound if compound else _syllabify
syllabifications = list(syllabify(word))
for syll, rules in syllabifications:
yield syll, rules
n = ... | [
"def",
"syllabify",
"(",
"word",
")",
":",
"compound",
"=",
"bool",
"(",
"re",
".",
"search",
"(",
"r'(-| |=)'",
",",
"word",
")",
")",
"syllabify",
"=",
"_syllabify_compound",
"if",
"compound",
"else",
"_syllabify",
"syllabifications",
"=",
"list",
"(",
"... | Syllabify the given word, whether simplex or complex. | [
"Syllabify",
"the",
"given",
"word",
"whether",
"simplex",
"or",
"complex",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v08.py#L18-L31 | train |
tsnaomi/finnsyll | finnsyll/prev/v08.py | apply_T4 | def apply_T4(word):
'''An agglutination diphthong that ends in /u, y/ optionally contains a
syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us],
[va.ka.ut.taa].'''
WORD = word.split('.')
PARTS = [[] for part in range(len(WORD))]
for i, v in enumerate(WORD):
# i % 2 != 0 preven... | python | def apply_T4(word):
'''An agglutination diphthong that ends in /u, y/ optionally contains a
syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us],
[va.ka.ut.taa].'''
WORD = word.split('.')
PARTS = [[] for part in range(len(WORD))]
for i, v in enumerate(WORD):
# i % 2 != 0 preven... | [
"def",
"apply_T4",
"(",
"word",
")",
":",
"WORD",
"=",
"word",
".",
"split",
"(",
"'.'",
")",
"PARTS",
"=",
"[",
"[",
"]",
"for",
"part",
"in",
"range",
"(",
"len",
"(",
"WORD",
")",
")",
"]",
"for",
"i",
",",
"v",
"in",
"enumerate",
"(",
"WO... | An agglutination diphthong that ends in /u, y/ optionally contains a
syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us],
[va.ka.ut.taa]. | [
"An",
"agglutination",
"diphthong",
"that",
"ends",
"in",
"/",
"u",
"y",
"/",
"optionally",
"contains",
"a",
"syllable",
"boundary",
"when",
"-",
"C#",
"or",
"-",
"CCV",
"follow",
"e",
".",
"g",
".",
"[",
"lau",
".",
"ka",
".",
"us",
"]",
"[",
"va"... | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v08.py#L189-L217 | train |
QunarOPS/qg.core | qg/core/log.py | setup | def setup(product_name):
"""Setup logging."""
if CONF.log_config:
_load_log_config(CONF.log_config)
else:
_setup_logging_from_conf()
sys.excepthook = _create_logging_excepthook(product_name) | python | def setup(product_name):
"""Setup logging."""
if CONF.log_config:
_load_log_config(CONF.log_config)
else:
_setup_logging_from_conf()
sys.excepthook = _create_logging_excepthook(product_name) | [
"def",
"setup",
"(",
"product_name",
")",
":",
"if",
"CONF",
".",
"log_config",
":",
"_load_log_config",
"(",
"CONF",
".",
"log_config",
")",
"else",
":",
"_setup_logging_from_conf",
"(",
")",
"sys",
".",
"excepthook",
"=",
"_create_logging_excepthook",
"(",
"... | Setup logging. | [
"Setup",
"logging",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/log.py#L351-L357 | train |
QunarOPS/qg.core | qg/core/log.py | ContextFormatter.format | def format(self, record):
"""Uses contextstring if request_id is set, otherwise default."""
# NOTE(sdague): default the fancier formating params
# to an empty string so we don't throw an exception if
# they get used
for key in ('instance', 'color'):
if key not in reco... | python | def format(self, record):
"""Uses contextstring if request_id is set, otherwise default."""
# NOTE(sdague): default the fancier formating params
# to an empty string so we don't throw an exception if
# they get used
for key in ('instance', 'color'):
if key not in reco... | [
"def",
"format",
"(",
"self",
",",
"record",
")",
":",
"# NOTE(sdague): default the fancier formating params",
"# to an empty string so we don't throw an exception if",
"# they get used",
"for",
"key",
"in",
"(",
"'instance'",
",",
"'color'",
")",
":",
"if",
"key",
"not",... | Uses contextstring if request_id is set, otherwise default. | [
"Uses",
"contextstring",
"if",
"request_id",
"is",
"set",
"otherwise",
"default",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/log.py#L486-L507 | train |
QunarOPS/qg.core | qg/core/log.py | ContextFormatter.formatException | def formatException(self, exc_info, record=None):
"""Format exception output with CONF.logging_exception_prefix."""
if not record:
return logging.Formatter.formatException(self, exc_info)
stringbuffer = cStringIO.StringIO()
traceback.print_exception(exc_info[0], exc_info[1],... | python | def formatException(self, exc_info, record=None):
"""Format exception output with CONF.logging_exception_prefix."""
if not record:
return logging.Formatter.formatException(self, exc_info)
stringbuffer = cStringIO.StringIO()
traceback.print_exception(exc_info[0], exc_info[1],... | [
"def",
"formatException",
"(",
"self",
",",
"exc_info",
",",
"record",
"=",
"None",
")",
":",
"if",
"not",
"record",
":",
"return",
"logging",
".",
"Formatter",
".",
"formatException",
"(",
"self",
",",
"exc_info",
")",
"stringbuffer",
"=",
"cStringIO",
".... | Format exception output with CONF.logging_exception_prefix. | [
"Format",
"exception",
"output",
"with",
"CONF",
".",
"logging_exception_prefix",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/log.py#L509-L528 | train |
benoitkugler/abstractDataLibrary | pyDLib/GUI/app.py | abstractToolBar._set_boutons_interface | def _set_boutons_interface(self, buttons):
"""Display buttons given by the list of tuples (id,function,description,is_active)"""
for id_action, f, d, is_active in buttons:
icon = self.get_icon(id_action)
action = self.addAction(QIcon(icon), d)
action.setEnabled(is_act... | python | def _set_boutons_interface(self, buttons):
"""Display buttons given by the list of tuples (id,function,description,is_active)"""
for id_action, f, d, is_active in buttons:
icon = self.get_icon(id_action)
action = self.addAction(QIcon(icon), d)
action.setEnabled(is_act... | [
"def",
"_set_boutons_interface",
"(",
"self",
",",
"buttons",
")",
":",
"for",
"id_action",
",",
"f",
",",
"d",
",",
"is_active",
"in",
"buttons",
":",
"icon",
"=",
"self",
".",
"get_icon",
"(",
"id_action",
")",
"action",
"=",
"self",
".",
"addAction",
... | Display buttons given by the list of tuples (id,function,description,is_active) | [
"Display",
"buttons",
"given",
"by",
"the",
"list",
"of",
"tuples",
"(",
"id",
"function",
"description",
"is_active",
")"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/app.py#L93-L99 | train |
benoitkugler/abstractDataLibrary | pyDLib/GUI/app.py | abstractToolBar.set_interface | def set_interface(self, interface):
"""Add update toolbar callback to the interface"""
self.interface = interface
self.interface.callbacks.update_toolbar = self._update
self._update() | python | def set_interface(self, interface):
"""Add update toolbar callback to the interface"""
self.interface = interface
self.interface.callbacks.update_toolbar = self._update
self._update() | [
"def",
"set_interface",
"(",
"self",
",",
"interface",
")",
":",
"self",
".",
"interface",
"=",
"interface",
"self",
".",
"interface",
".",
"callbacks",
".",
"update_toolbar",
"=",
"self",
".",
"_update",
"self",
".",
"_update",
"(",
")"
] | Add update toolbar callback to the interface | [
"Add",
"update",
"toolbar",
"callback",
"to",
"the",
"interface"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/app.py#L101-L105 | train |
benoitkugler/abstractDataLibrary | pyDLib/GUI/app.py | abstractToolBar._update | def _update(self):
"""Update the display of button after querying data from interface"""
self.clear()
self._set_boutons_communs()
if self.interface:
self.addSeparator()
l_actions = self.interface.get_actions_toolbar()
self._set_boutons_interface(l_acti... | python | def _update(self):
"""Update the display of button after querying data from interface"""
self.clear()
self._set_boutons_communs()
if self.interface:
self.addSeparator()
l_actions = self.interface.get_actions_toolbar()
self._set_boutons_interface(l_acti... | [
"def",
"_update",
"(",
"self",
")",
":",
"self",
".",
"clear",
"(",
")",
"self",
".",
"_set_boutons_communs",
"(",
")",
"if",
"self",
".",
"interface",
":",
"self",
".",
"addSeparator",
"(",
")",
"l_actions",
"=",
"self",
".",
"interface",
".",
"get_ac... | Update the display of button after querying data from interface | [
"Update",
"the",
"display",
"of",
"button",
"after",
"querying",
"data",
"from",
"interface"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/app.py#L107-L114 | train |
benoitkugler/abstractDataLibrary | pyDLib/GUI/app.py | Application.init_login | def init_login(self, from_local=False):
"""Display login screen. May ask for local data loading if from_local is True."""
if self.toolbar:
self.removeToolBar(self.toolbar)
widget_login = login.Loading(self.statusBar(), self.theory_main)
self.centralWidget().addWidget(widget_l... | python | def init_login(self, from_local=False):
"""Display login screen. May ask for local data loading if from_local is True."""
if self.toolbar:
self.removeToolBar(self.toolbar)
widget_login = login.Loading(self.statusBar(), self.theory_main)
self.centralWidget().addWidget(widget_l... | [
"def",
"init_login",
"(",
"self",
",",
"from_local",
"=",
"False",
")",
":",
"if",
"self",
".",
"toolbar",
":",
"self",
".",
"removeToolBar",
"(",
"self",
".",
"toolbar",
")",
"widget_login",
"=",
"login",
".",
"Loading",
"(",
"self",
".",
"statusBar",
... | Display login screen. May ask for local data loading if from_local is True. | [
"Display",
"login",
"screen",
".",
"May",
"ask",
"for",
"local",
"data",
"loading",
"if",
"from_local",
"is",
"True",
"."
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/app.py#L160-L172 | train |
ProjetPP/PPP-libmodule-Python | ppp_libmodule/http.py | HttpRequestHandler.make_response | def make_response(self, status, content_type, response):
"""Shortcut for making a response to the client's request."""
headers = [('Access-Control-Allow-Origin', '*'),
('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'),
('Access-Control-Allow-Headers', 'Content-... | python | def make_response(self, status, content_type, response):
"""Shortcut for making a response to the client's request."""
headers = [('Access-Control-Allow-Origin', '*'),
('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'),
('Access-Control-Allow-Headers', 'Content-... | [
"def",
"make_response",
"(",
"self",
",",
"status",
",",
"content_type",
",",
"response",
")",
":",
"headers",
"=",
"[",
"(",
"'Access-Control-Allow-Origin'",
",",
"'*'",
")",
",",
"(",
"'Access-Control-Allow-Methods'",
",",
"'GET, POST, OPTIONS'",
")",
",",
"("... | Shortcut for making a response to the client's request. | [
"Shortcut",
"for",
"making",
"a",
"response",
"to",
"the",
"client",
"s",
"request",
"."
] | 8098ec3e3ac62f471ff93fb8ce29e36833a8d492 | https://github.com/ProjetPP/PPP-libmodule-Python/blob/8098ec3e3ac62f471ff93fb8ce29e36833a8d492/ppp_libmodule/http.py#L23-L32 | train |
ProjetPP/PPP-libmodule-Python | ppp_libmodule/http.py | HttpRequestHandler.process_request | def process_request(self, request):
"""Processes a request."""
try:
request = Request.from_json(request.read().decode())
except ValueError:
raise ClientError('Data is not valid JSON.')
except KeyError:
raise ClientError('Missing mandatory field in requ... | python | def process_request(self, request):
"""Processes a request."""
try:
request = Request.from_json(request.read().decode())
except ValueError:
raise ClientError('Data is not valid JSON.')
except KeyError:
raise ClientError('Missing mandatory field in requ... | [
"def",
"process_request",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"request",
"=",
"Request",
".",
"from_json",
"(",
"request",
".",
"read",
"(",
")",
".",
"decode",
"(",
")",
")",
"except",
"ValueError",
":",
"raise",
"ClientError",
"(",
"'D... | Processes a request. | [
"Processes",
"a",
"request",
"."
] | 8098ec3e3ac62f471ff93fb8ce29e36833a8d492 | https://github.com/ProjetPP/PPP-libmodule-Python/blob/8098ec3e3ac62f471ff93fb8ce29e36833a8d492/ppp_libmodule/http.py#L97-L116 | train |
ProjetPP/PPP-libmodule-Python | ppp_libmodule/http.py | HttpRequestHandler.on_post | def on_post(self):
"""Extracts the request, feeds the module, and returns the response."""
request = self.environ['wsgi.input']
try:
return self.process_request(request)
except ClientError as exc:
return self.on_client_error(exc)
except BadGateway as exc:
... | python | def on_post(self):
"""Extracts the request, feeds the module, and returns the response."""
request = self.environ['wsgi.input']
try:
return self.process_request(request)
except ClientError as exc:
return self.on_client_error(exc)
except BadGateway as exc:
... | [
"def",
"on_post",
"(",
"self",
")",
":",
"request",
"=",
"self",
".",
"environ",
"[",
"'wsgi.input'",
"]",
"try",
":",
"return",
"self",
".",
"process_request",
"(",
"request",
")",
"except",
"ClientError",
"as",
"exc",
":",
"return",
"self",
".",
"on_cl... | Extracts the request, feeds the module, and returns the response. | [
"Extracts",
"the",
"request",
"feeds",
"the",
"module",
"and",
"returns",
"the",
"response",
"."
] | 8098ec3e3ac62f471ff93fb8ce29e36833a8d492 | https://github.com/ProjetPP/PPP-libmodule-Python/blob/8098ec3e3ac62f471ff93fb8ce29e36833a8d492/ppp_libmodule/http.py#L118-L131 | train |
ProjetPP/PPP-libmodule-Python | ppp_libmodule/http.py | HttpRequestHandler.dispatch | def dispatch(self):
"""Handles dispatching of the request."""
method_name = 'on_' + self.environ['REQUEST_METHOD'].lower()
method = getattr(self, method_name, None)
if method:
return method()
else:
return self.on_bad_method() | python | def dispatch(self):
"""Handles dispatching of the request."""
method_name = 'on_' + self.environ['REQUEST_METHOD'].lower()
method = getattr(self, method_name, None)
if method:
return method()
else:
return self.on_bad_method() | [
"def",
"dispatch",
"(",
"self",
")",
":",
"method_name",
"=",
"'on_'",
"+",
"self",
".",
"environ",
"[",
"'REQUEST_METHOD'",
"]",
".",
"lower",
"(",
")",
"method",
"=",
"getattr",
"(",
"self",
",",
"method_name",
",",
"None",
")",
"if",
"method",
":",
... | Handles dispatching of the request. | [
"Handles",
"dispatching",
"of",
"the",
"request",
"."
] | 8098ec3e3ac62f471ff93fb8ce29e36833a8d492 | https://github.com/ProjetPP/PPP-libmodule-Python/blob/8098ec3e3ac62f471ff93fb8ce29e36833a8d492/ppp_libmodule/http.py#L137-L144 | train |
saltant-org/saltant-py | saltant/models/user.py | User.sync | def sync(self):
"""Sync this model with latest data on the saltant server.
Note that in addition to returning the updated object, it also
updates the existing object.
Returns:
:class:`saltant.models.user.User`:
This user instance after syncing.
"""
... | python | def sync(self):
"""Sync this model with latest data on the saltant server.
Note that in addition to returning the updated object, it also
updates the existing object.
Returns:
:class:`saltant.models.user.User`:
This user instance after syncing.
"""
... | [
"def",
"sync",
"(",
"self",
")",
":",
"self",
"=",
"self",
".",
"manager",
".",
"get",
"(",
"username",
"=",
"self",
".",
"username",
")",
"return",
"self"
] | Sync this model with latest data on the saltant server.
Note that in addition to returning the updated object, it also
updates the existing object.
Returns:
:class:`saltant.models.user.User`:
This user instance after syncing. | [
"Sync",
"this",
"model",
"with",
"latest",
"data",
"on",
"the",
"saltant",
"server",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/user.py#L35-L47 | train |
moralrecordings/mrcrowbar | mrcrowbar/blocks.py | Block.serialised | def serialised( self ):
"""Tuple containing the contents of the Block."""
klass = self.__class__
return ((klass.__module__, klass.__name__), tuple( (name, field.serialise( self._field_data[name], parent=self ) ) for name, field in klass._fields.items())) | python | def serialised( self ):
"""Tuple containing the contents of the Block."""
klass = self.__class__
return ((klass.__module__, klass.__name__), tuple( (name, field.serialise( self._field_data[name], parent=self ) ) for name, field in klass._fields.items())) | [
"def",
"serialised",
"(",
"self",
")",
":",
"klass",
"=",
"self",
".",
"__class__",
"return",
"(",
"(",
"klass",
".",
"__module__",
",",
"klass",
".",
"__name__",
")",
",",
"tuple",
"(",
"(",
"name",
",",
"field",
".",
"serialise",
"(",
"self",
".",
... | Tuple containing the contents of the Block. | [
"Tuple",
"containing",
"the",
"contents",
"of",
"the",
"Block",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/blocks.py#L193-L196 | train |
moralrecordings/mrcrowbar | mrcrowbar/blocks.py | Block.clone_data | def clone_data( self, source ):
"""Clone data from another Block.
source
Block instance to copy from.
"""
klass = self.__class__
assert isinstance( source, klass )
for name in klass._fields:
self._field_data[name] = getattr( source, name ) | python | def clone_data( self, source ):
"""Clone data from another Block.
source
Block instance to copy from.
"""
klass = self.__class__
assert isinstance( source, klass )
for name in klass._fields:
self._field_data[name] = getattr( source, name ) | [
"def",
"clone_data",
"(",
"self",
",",
"source",
")",
":",
"klass",
"=",
"self",
".",
"__class__",
"assert",
"isinstance",
"(",
"source",
",",
"klass",
")",
"for",
"name",
"in",
"klass",
".",
"_fields",
":",
"self",
".",
"_field_data",
"[",
"name",
"]"... | Clone data from another Block.
source
Block instance to copy from. | [
"Clone",
"data",
"from",
"another",
"Block",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/blocks.py#L198-L208 | train |
moralrecordings/mrcrowbar | mrcrowbar/blocks.py | Block.import_data | def import_data( self, raw_buffer ):
"""Import data from a byte array.
raw_buffer
Byte array to import from.
"""
klass = self.__class__
if raw_buffer:
assert common.is_bytes( raw_buffer )
# raw_buffer = memoryview( raw_buffer )
self._f... | python | def import_data( self, raw_buffer ):
"""Import data from a byte array.
raw_buffer
Byte array to import from.
"""
klass = self.__class__
if raw_buffer:
assert common.is_bytes( raw_buffer )
# raw_buffer = memoryview( raw_buffer )
self._f... | [
"def",
"import_data",
"(",
"self",
",",
"raw_buffer",
")",
":",
"klass",
"=",
"self",
".",
"__class__",
"if",
"raw_buffer",
":",
"assert",
"common",
".",
"is_bytes",
"(",
"raw_buffer",
")",
"# raw_buffer = memoryview( raw_buffer )",
"self",
".",
"_field... | Import data from a byte array.
raw_buffer
Byte array to import from. | [
"Import",
"data",
"from",
"a",
"byte",
"array",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/blocks.py#L210-L255 | train |
moralrecordings/mrcrowbar | mrcrowbar/blocks.py | Block.export_data | def export_data( self ):
"""Export data to a byte array."""
klass = self.__class__
output = bytearray( b'\x00'*self.get_size() )
# prevalidate all data before export.
# this is important to ensure that any dependent fields
# are updated beforehand, e.g. a count referenc... | python | def export_data( self ):
"""Export data to a byte array."""
klass = self.__class__
output = bytearray( b'\x00'*self.get_size() )
# prevalidate all data before export.
# this is important to ensure that any dependent fields
# are updated beforehand, e.g. a count referenc... | [
"def",
"export_data",
"(",
"self",
")",
":",
"klass",
"=",
"self",
".",
"__class__",
"output",
"=",
"bytearray",
"(",
"b'\\x00'",
"*",
"self",
".",
"get_size",
"(",
")",
")",
"# prevalidate all data before export.",
"# this is important to ensure that any dependent fi... | Export data to a byte array. | [
"Export",
"data",
"to",
"a",
"byte",
"array",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/blocks.py#L258-L282 | train |
moralrecordings/mrcrowbar | mrcrowbar/blocks.py | Block.update_deps | def update_deps( self ):
"""Update dependencies on all the fields on this Block instance."""
klass = self.__class__
for name in klass._fields:
self.update_deps_on_field( name )
return | python | def update_deps( self ):
"""Update dependencies on all the fields on this Block instance."""
klass = self.__class__
for name in klass._fields:
self.update_deps_on_field( name )
return | [
"def",
"update_deps",
"(",
"self",
")",
":",
"klass",
"=",
"self",
".",
"__class__",
"for",
"name",
"in",
"klass",
".",
"_fields",
":",
"self",
".",
"update_deps_on_field",
"(",
"name",
")",
"return"
] | Update dependencies on all the fields on this Block instance. | [
"Update",
"dependencies",
"on",
"all",
"the",
"fields",
"on",
"this",
"Block",
"instance",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/blocks.py#L284-L290 | train |
moralrecordings/mrcrowbar | mrcrowbar/blocks.py | Block.validate | def validate( self ):
"""Validate all the fields on this Block instance."""
klass = self.__class__
for name in klass._fields:
self.validate_field( name )
return | python | def validate( self ):
"""Validate all the fields on this Block instance."""
klass = self.__class__
for name in klass._fields:
self.validate_field( name )
return | [
"def",
"validate",
"(",
"self",
")",
":",
"klass",
"=",
"self",
".",
"__class__",
"for",
"name",
"in",
"klass",
".",
"_fields",
":",
"self",
".",
"validate_field",
"(",
"name",
")",
"return"
] | Validate all the fields on this Block instance. | [
"Validate",
"all",
"the",
"fields",
"on",
"this",
"Block",
"instance",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/blocks.py#L292-L298 | train |
moralrecordings/mrcrowbar | mrcrowbar/blocks.py | Block.get_size | def get_size( self ):
"""Get the projected size (in bytes) of the exported data from this Block instance."""
klass = self.__class__
size = 0
for name in klass._fields:
size = max( size, klass._fields[name].get_end_offset( self._field_data[name], parent=self ) )
for ch... | python | def get_size( self ):
"""Get the projected size (in bytes) of the exported data from this Block instance."""
klass = self.__class__
size = 0
for name in klass._fields:
size = max( size, klass._fields[name].get_end_offset( self._field_data[name], parent=self ) )
for ch... | [
"def",
"get_size",
"(",
"self",
")",
":",
"klass",
"=",
"self",
".",
"__class__",
"size",
"=",
"0",
"for",
"name",
"in",
"klass",
".",
"_fields",
":",
"size",
"=",
"max",
"(",
"size",
",",
"klass",
".",
"_fields",
"[",
"name",
"]",
".",
"get_end_of... | Get the projected size (in bytes) of the exported data from this Block instance. | [
"Get",
"the",
"projected",
"size",
"(",
"in",
"bytes",
")",
"of",
"the",
"exported",
"data",
"from",
"this",
"Block",
"instance",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/blocks.py#L300-L308 | train |
jorbas/GADDAG | gaddag/gaddag.py | GADDAG.save | def save(self, path, compressed=True, exist_ok=False):
"""
Save the GADDAG to file.
Args:
path: path to save the GADDAG to.
compressed: compress the saved GADDAG using gzip.
exist_ok: overwrite existing file at `path`.
"""
path = os.path.expan... | python | def save(self, path, compressed=True, exist_ok=False):
"""
Save the GADDAG to file.
Args:
path: path to save the GADDAG to.
compressed: compress the saved GADDAG using gzip.
exist_ok: overwrite existing file at `path`.
"""
path = os.path.expan... | [
"def",
"save",
"(",
"self",
",",
"path",
",",
"compressed",
"=",
"True",
",",
"exist_ok",
"=",
"False",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"expandvars",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"path",
")",
")",
"if",
"os",
"."... | Save the GADDAG to file.
Args:
path: path to save the GADDAG to.
compressed: compress the saved GADDAG using gzip.
exist_ok: overwrite existing file at `path`. | [
"Save",
"the",
"GADDAG",
"to",
"file",
"."
] | a0ede3def715c586e1f273d96e9fc0d537cd9561 | https://github.com/jorbas/GADDAG/blob/a0ede3def715c586e1f273d96e9fc0d537cd9561/gaddag/gaddag.py#L70-L95 | train |
jorbas/GADDAG | gaddag/gaddag.py | GADDAG.load | def load(self, path):
"""
Load a GADDAG from file, replacing the words currently in this GADDAG.
Args:
path: path to saved GADDAG to be loaded.
"""
path = os.path.expandvars(os.path.expanduser(path))
gdg = cgaddag.gdg_load(path.encode("ascii"))
if no... | python | def load(self, path):
"""
Load a GADDAG from file, replacing the words currently in this GADDAG.
Args:
path: path to saved GADDAG to be loaded.
"""
path = os.path.expandvars(os.path.expanduser(path))
gdg = cgaddag.gdg_load(path.encode("ascii"))
if no... | [
"def",
"load",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"expandvars",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"path",
")",
")",
"gdg",
"=",
"cgaddag",
".",
"gdg_load",
"(",
"path",
".",
"encode",
"(",
"\"as... | Load a GADDAG from file, replacing the words currently in this GADDAG.
Args:
path: path to saved GADDAG to be loaded. | [
"Load",
"a",
"GADDAG",
"from",
"file",
"replacing",
"the",
"words",
"currently",
"in",
"this",
"GADDAG",
"."
] | a0ede3def715c586e1f273d96e9fc0d537cd9561 | https://github.com/jorbas/GADDAG/blob/a0ede3def715c586e1f273d96e9fc0d537cd9561/gaddag/gaddag.py#L97-L112 | train |
jorbas/GADDAG | gaddag/gaddag.py | GADDAG.starts_with | def starts_with(self, prefix):
"""
Find all words starting with a prefix.
Args:
prefix: A prefix to be searched for.
Returns:
A list of all words found.
"""
prefix = prefix.lower()
found_words = []
res = cgaddag.gdg_starts_with(s... | python | def starts_with(self, prefix):
"""
Find all words starting with a prefix.
Args:
prefix: A prefix to be searched for.
Returns:
A list of all words found.
"""
prefix = prefix.lower()
found_words = []
res = cgaddag.gdg_starts_with(s... | [
"def",
"starts_with",
"(",
"self",
",",
"prefix",
")",
":",
"prefix",
"=",
"prefix",
".",
"lower",
"(",
")",
"found_words",
"=",
"[",
"]",
"res",
"=",
"cgaddag",
".",
"gdg_starts_with",
"(",
"self",
".",
"gdg",
",",
"prefix",
".",
"encode",
"(",
"enc... | Find all words starting with a prefix.
Args:
prefix: A prefix to be searched for.
Returns:
A list of all words found. | [
"Find",
"all",
"words",
"starting",
"with",
"a",
"prefix",
"."
] | a0ede3def715c586e1f273d96e9fc0d537cd9561 | https://github.com/jorbas/GADDAG/blob/a0ede3def715c586e1f273d96e9fc0d537cd9561/gaddag/gaddag.py#L114-L136 | train |
jorbas/GADDAG | gaddag/gaddag.py | GADDAG.contains | def contains(self, sub):
"""
Find all words containing a substring.
Args:
sub: A substring to be searched for.
Returns:
A list of all words found.
"""
sub = sub.lower()
found_words = set()
res = cgaddag.gdg_contains(self.gdg, sub... | python | def contains(self, sub):
"""
Find all words containing a substring.
Args:
sub: A substring to be searched for.
Returns:
A list of all words found.
"""
sub = sub.lower()
found_words = set()
res = cgaddag.gdg_contains(self.gdg, sub... | [
"def",
"contains",
"(",
"self",
",",
"sub",
")",
":",
"sub",
"=",
"sub",
".",
"lower",
"(",
")",
"found_words",
"=",
"set",
"(",
")",
"res",
"=",
"cgaddag",
".",
"gdg_contains",
"(",
"self",
".",
"gdg",
",",
"sub",
".",
"encode",
"(",
"encoding",
... | Find all words containing a substring.
Args:
sub: A substring to be searched for.
Returns:
A list of all words found. | [
"Find",
"all",
"words",
"containing",
"a",
"substring",
"."
] | a0ede3def715c586e1f273d96e9fc0d537cd9561 | https://github.com/jorbas/GADDAG/blob/a0ede3def715c586e1f273d96e9fc0d537cd9561/gaddag/gaddag.py#L138-L160 | train |
jorbas/GADDAG | gaddag/gaddag.py | GADDAG.ends_with | def ends_with(self, suffix):
"""
Find all words ending with a suffix.
Args:
suffix: A suffix to be searched for.
Returns:
A list of all words found.
"""
suffix = suffix.lower()
found_words = []
res = cgaddag.gdg_ends_with(self.gd... | python | def ends_with(self, suffix):
"""
Find all words ending with a suffix.
Args:
suffix: A suffix to be searched for.
Returns:
A list of all words found.
"""
suffix = suffix.lower()
found_words = []
res = cgaddag.gdg_ends_with(self.gd... | [
"def",
"ends_with",
"(",
"self",
",",
"suffix",
")",
":",
"suffix",
"=",
"suffix",
".",
"lower",
"(",
")",
"found_words",
"=",
"[",
"]",
"res",
"=",
"cgaddag",
".",
"gdg_ends_with",
"(",
"self",
".",
"gdg",
",",
"suffix",
".",
"encode",
"(",
"encodin... | Find all words ending with a suffix.
Args:
suffix: A suffix to be searched for.
Returns:
A list of all words found. | [
"Find",
"all",
"words",
"ending",
"with",
"a",
"suffix",
"."
] | a0ede3def715c586e1f273d96e9fc0d537cd9561 | https://github.com/jorbas/GADDAG/blob/a0ede3def715c586e1f273d96e9fc0d537cd9561/gaddag/gaddag.py#L162-L184 | train |
jorbas/GADDAG | gaddag/gaddag.py | GADDAG.add_word | def add_word(self, word):
"""
Add a word to the GADDAG.
Args:
word: A word to be added to the GADDAG.
"""
word = word.lower()
if not (word.isascii() and word.isalpha()):
raise ValueError("Invalid character in word '{}'".format(word))
wor... | python | def add_word(self, word):
"""
Add a word to the GADDAG.
Args:
word: A word to be added to the GADDAG.
"""
word = word.lower()
if not (word.isascii() and word.isalpha()):
raise ValueError("Invalid character in word '{}'".format(word))
wor... | [
"def",
"add_word",
"(",
"self",
",",
"word",
")",
":",
"word",
"=",
"word",
".",
"lower",
"(",
")",
"if",
"not",
"(",
"word",
".",
"isascii",
"(",
")",
"and",
"word",
".",
"isalpha",
"(",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"Invalid charac... | Add a word to the GADDAG.
Args:
word: A word to be added to the GADDAG. | [
"Add",
"a",
"word",
"to",
"the",
"GADDAG",
"."
] | a0ede3def715c586e1f273d96e9fc0d537cd9561 | https://github.com/jorbas/GADDAG/blob/a0ede3def715c586e1f273d96e9fc0d537cd9561/gaddag/gaddag.py#L186-L203 | train |
Clever/kayvee-python | kayvee/kayvee.py | formatLog | def formatLog(source="", level="", title="", data={}):
""" Similar to format, but takes additional reserved params to promote logging best-practices
:param level - severity of message - how bad is it?
:param source - application context - where did it come from?
:param title - brief description - what kind of ... | python | def formatLog(source="", level="", title="", data={}):
""" Similar to format, but takes additional reserved params to promote logging best-practices
:param level - severity of message - how bad is it?
:param source - application context - where did it come from?
:param title - brief description - what kind of ... | [
"def",
"formatLog",
"(",
"source",
"=",
"\"\"",
",",
"level",
"=",
"\"\"",
",",
"title",
"=",
"\"\"",
",",
"data",
"=",
"{",
"}",
")",
":",
"# consistently output empty string for unset params, because null values differ by language",
"source",
"=",
"\"\"",
"if",
... | Similar to format, but takes additional reserved params to promote logging best-practices
:param level - severity of message - how bad is it?
:param source - application context - where did it come from?
:param title - brief description - what kind of event happened?
:param data - additional information - what... | [
"Similar",
"to",
"format",
"but",
"takes",
"additional",
"reserved",
"params",
"to",
"promote",
"logging",
"best",
"-",
"practices"
] | 9d1cc96d592148bc3bd8f11f9e6ed03255985882 | https://github.com/Clever/kayvee-python/blob/9d1cc96d592148bc3bd8f11f9e6ed03255985882/kayvee/kayvee.py#L7-L26 | train |
saltant-org/saltant-py | saltant/models/container_task_type.py | ContainerTaskType.put | def put(self):
"""Updates this task type on the saltant server.
Returns:
:class:`saltant.models.container_task_type.ContainerTaskType`:
A task type model instance representing the task type
just updated.
"""
return self.manager.put(
... | python | def put(self):
"""Updates this task type on the saltant server.
Returns:
:class:`saltant.models.container_task_type.ContainerTaskType`:
A task type model instance representing the task type
just updated.
"""
return self.manager.put(
... | [
"def",
"put",
"(",
"self",
")",
":",
"return",
"self",
".",
"manager",
".",
"put",
"(",
"id",
"=",
"self",
".",
"id",
",",
"name",
"=",
"self",
".",
"name",
",",
"description",
"=",
"self",
".",
"description",
",",
"command_to_run",
"=",
"self",
".... | Updates this task type on the saltant server.
Returns:
:class:`saltant.models.container_task_type.ContainerTaskType`:
A task type model instance representing the task type
just updated. | [
"Updates",
"this",
"task",
"type",
"on",
"the",
"saltant",
"server",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/container_task_type.py#L101-L123 | train |
saltant-org/saltant-py | saltant/models/container_task_type.py | ContainerTaskTypeManager.create | def create(
self,
name,
command_to_run,
container_image,
container_type,
description="",
logs_path="",
results_path="",
environment_variables=None,
required_arguments=None,
required_arguments_default_values=None,
extra_data_... | python | def create(
self,
name,
command_to_run,
container_image,
container_type,
description="",
logs_path="",
results_path="",
environment_variables=None,
required_arguments=None,
required_arguments_default_values=None,
extra_data_... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"command_to_run",
",",
"container_image",
",",
"container_type",
",",
"description",
"=",
"\"\"",
",",
"logs_path",
"=",
"\"\"",
",",
"results_path",
"=",
"\"\"",
",",
"environment_variables",
"=",
"None",
",",
... | Create a container task type.
Args:
name (str): The name of the task.
command_to_run (str): The command to run to execute the task.
container_image (str): The container name and tag. For
example, ubuntu:14.04 for Docker; and docker://ubuntu:14:04
... | [
"Create",
"a",
"container",
"task",
"type",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/container_task_type.py#L142-L207 | train |
saltant-org/saltant-py | saltant/models/container_task_type.py | ContainerTaskTypeManager.put | def put(
self,
id,
name,
description,
command_to_run,
environment_variables,
required_arguments,
required_arguments_default_values,
logs_path,
results_path,
container_image,
container_type,
extra_data_to_put=None,
... | python | def put(
self,
id,
name,
description,
command_to_run,
environment_variables,
required_arguments,
required_arguments_default_values,
logs_path,
results_path,
container_image,
container_type,
extra_data_to_put=None,
... | [
"def",
"put",
"(",
"self",
",",
"id",
",",
"name",
",",
"description",
",",
"command_to_run",
",",
"environment_variables",
",",
"required_arguments",
",",
"required_arguments_default_values",
",",
"logs_path",
",",
"results_path",
",",
"container_image",
",",
"cont... | Updates a task type on the saltant server.
Args:
id (int): The ID of the task type.
name (str): The name of the task type.
description (str): The description of the task type.
command_to_run (str): The command to run to execute the task.
environment_v... | [
"Updates",
"a",
"task",
"type",
"on",
"the",
"saltant",
"server",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/container_task_type.py#L209-L273 | train |
MarcMeszaros/envitro | envitro/core.py | _strtobool | def _strtobool(val):
"""Convert a string representation of truth to true (1) or false (0).
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', '0' and ''. Raises ValueError if
'val' is anything else.
"""
val = val.lower()
if val in ('y',... | python | def _strtobool(val):
"""Convert a string representation of truth to true (1) or false (0).
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', '0' and ''. Raises ValueError if
'val' is anything else.
"""
val = val.lower()
if val in ('y',... | [
"def",
"_strtobool",
"(",
"val",
")",
":",
"val",
"=",
"val",
".",
"lower",
"(",
")",
"if",
"val",
"in",
"(",
"'y'",
",",
"'yes'",
",",
"'t'",
",",
"'true'",
",",
"'on'",
",",
"'1'",
")",
":",
"return",
"1",
"elif",
"val",
"in",
"(",
"'n'",
"... | Convert a string representation of truth to true (1) or false (0).
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', '0' and ''. Raises ValueError if
'val' is anything else. | [
"Convert",
"a",
"string",
"representation",
"of",
"truth",
"to",
"true",
"(",
"1",
")",
"or",
"false",
"(",
"0",
")",
"."
] | 19e925cd152c08d4db8126542afed35188cafff4 | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/core.py#L18-L31 | train |
MarcMeszaros/envitro | envitro/core.py | _str_to_list | def _str_to_list(value, separator):
"""Convert a string to a list with sanitization."""
value_list = [item.strip() for item in value.split(separator)]
value_list_sanitized = builtins.list(filter(None, value_list))
if len(value_list_sanitized) > 0:
return value_list_sanitized
else:
ra... | python | def _str_to_list(value, separator):
"""Convert a string to a list with sanitization."""
value_list = [item.strip() for item in value.split(separator)]
value_list_sanitized = builtins.list(filter(None, value_list))
if len(value_list_sanitized) > 0:
return value_list_sanitized
else:
ra... | [
"def",
"_str_to_list",
"(",
"value",
",",
"separator",
")",
":",
"value_list",
"=",
"[",
"item",
".",
"strip",
"(",
")",
"for",
"item",
"in",
"value",
".",
"split",
"(",
"separator",
")",
"]",
"value_list_sanitized",
"=",
"builtins",
".",
"list",
"(",
... | Convert a string to a list with sanitization. | [
"Convert",
"a",
"string",
"to",
"a",
"list",
"with",
"sanitization",
"."
] | 19e925cd152c08d4db8126542afed35188cafff4 | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/core.py#L34-L41 | train |
MarcMeszaros/envitro | envitro/core.py | write | def write(name, value):
"""Write a raw env value.
A ``None`` value clears the environment variable.
Args:
name: The environment variable name
value: The value to write
"""
if value is not None:
environ[name] = builtins.str(value)
elif environ.get(name):
del envi... | python | def write(name, value):
"""Write a raw env value.
A ``None`` value clears the environment variable.
Args:
name: The environment variable name
value: The value to write
"""
if value is not None:
environ[name] = builtins.str(value)
elif environ.get(name):
del envi... | [
"def",
"write",
"(",
"name",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"environ",
"[",
"name",
"]",
"=",
"builtins",
".",
"str",
"(",
"value",
")",
"elif",
"environ",
".",
"get",
"(",
"name",
")",
":",
"del",
"environ",
"["... | Write a raw env value.
A ``None`` value clears the environment variable.
Args:
name: The environment variable name
value: The value to write | [
"Write",
"a",
"raw",
"env",
"value",
"."
] | 19e925cd152c08d4db8126542afed35188cafff4 | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/core.py#L53-L65 | train |
MarcMeszaros/envitro | envitro/core.py | read | def read(name, default=None, allow_none=False, fallback=None):
"""Read the raw env value.
Read the raw environment variable or use the default. If the value is not
found and no default is set throw an exception.
Args:
name: The environment variable name
default: The default value to us... | python | def read(name, default=None, allow_none=False, fallback=None):
"""Read the raw env value.
Read the raw environment variable or use the default. If the value is not
found and no default is set throw an exception.
Args:
name: The environment variable name
default: The default value to us... | [
"def",
"read",
"(",
"name",
",",
"default",
"=",
"None",
",",
"allow_none",
"=",
"False",
",",
"fallback",
"=",
"None",
")",
":",
"raw_value",
"=",
"environ",
".",
"get",
"(",
"name",
")",
"if",
"raw_value",
"is",
"None",
"and",
"fallback",
"is",
"no... | Read the raw env value.
Read the raw environment variable or use the default. If the value is not
found and no default is set throw an exception.
Args:
name: The environment variable name
default: The default value to use if no environment variable is found
allow_none: If the retur... | [
"Read",
"the",
"raw",
"env",
"value",
"."
] | 19e925cd152c08d4db8126542afed35188cafff4 | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/core.py#L73-L101 | train |
MarcMeszaros/envitro | envitro/core.py | str | def str(name, default=None, allow_none=False, fallback=None):
"""Get a string based environment value or the default.
Args:
name: The environment variable name
default: The default value to use if no environment variable is found
allow_none: If the return value can be `None` (i.e. optio... | python | def str(name, default=None, allow_none=False, fallback=None):
"""Get a string based environment value or the default.
Args:
name: The environment variable name
default: The default value to use if no environment variable is found
allow_none: If the return value can be `None` (i.e. optio... | [
"def",
"str",
"(",
"name",
",",
"default",
"=",
"None",
",",
"allow_none",
"=",
"False",
",",
"fallback",
"=",
"None",
")",
":",
"value",
"=",
"read",
"(",
"name",
",",
"default",
",",
"allow_none",
",",
"fallback",
"=",
"fallback",
")",
"if",
"value... | Get a string based environment value or the default.
Args:
name: The environment variable name
default: The default value to use if no environment variable is found
allow_none: If the return value can be `None` (i.e. optional) | [
"Get",
"a",
"string",
"based",
"environment",
"value",
"or",
"the",
"default",
"."
] | 19e925cd152c08d4db8126542afed35188cafff4 | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/core.py#L109-L121 | train |
MarcMeszaros/envitro | envitro/core.py | bool | def bool(name, default=None, allow_none=False, fallback=None):
"""Get a boolean based environment value or the default.
Args:
name: The environment variable name
default: The default value to use if no environment variable is found
allow_none: If the return value can be `None` (i.e. opt... | python | def bool(name, default=None, allow_none=False, fallback=None):
"""Get a boolean based environment value or the default.
Args:
name: The environment variable name
default: The default value to use if no environment variable is found
allow_none: If the return value can be `None` (i.e. opt... | [
"def",
"bool",
"(",
"name",
",",
"default",
"=",
"None",
",",
"allow_none",
"=",
"False",
",",
"fallback",
"=",
"None",
")",
":",
"value",
"=",
"read",
"(",
"name",
",",
"default",
",",
"allow_none",
",",
"fallback",
"=",
"fallback",
")",
"if",
"isin... | Get a boolean based environment value or the default.
Args:
name: The environment variable name
default: The default value to use if no environment variable is found
allow_none: If the return value can be `None` (i.e. optional) | [
"Get",
"a",
"boolean",
"based",
"environment",
"value",
"or",
"the",
"default",
"."
] | 19e925cd152c08d4db8126542afed35188cafff4 | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/core.py#L124-L141 | train |
MarcMeszaros/envitro | envitro/core.py | int | def int(name, default=None, allow_none=False, fallback=None):
"""Get a string environment value or the default.
Args:
name: The environment variable name
default: The default value to use if no environment variable is found
allow_none: If the return value can be `None` (i.e. optional)
... | python | def int(name, default=None, allow_none=False, fallback=None):
"""Get a string environment value or the default.
Args:
name: The environment variable name
default: The default value to use if no environment variable is found
allow_none: If the return value can be `None` (i.e. optional)
... | [
"def",
"int",
"(",
"name",
",",
"default",
"=",
"None",
",",
"allow_none",
"=",
"False",
",",
"fallback",
"=",
"None",
")",
":",
"value",
"=",
"read",
"(",
"name",
",",
"default",
",",
"allow_none",
",",
"fallback",
"=",
"fallback",
")",
"if",
"isins... | Get a string environment value or the default.
Args:
name: The environment variable name
default: The default value to use if no environment variable is found
allow_none: If the return value can be `None` (i.e. optional) | [
"Get",
"a",
"string",
"environment",
"value",
"or",
"the",
"default",
"."
] | 19e925cd152c08d4db8126542afed35188cafff4 | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/core.py#L144-L159 | train |
MarcMeszaros/envitro | envitro/core.py | list | def list(name, default=None, allow_none=False, fallback=None, separator=','):
"""Get a list of strings or the default.
The individual list elements are whitespace-stripped.
Args:
name: The environment variable name
default: The default value to use if no environment variable is found
... | python | def list(name, default=None, allow_none=False, fallback=None, separator=','):
"""Get a list of strings or the default.
The individual list elements are whitespace-stripped.
Args:
name: The environment variable name
default: The default value to use if no environment variable is found
... | [
"def",
"list",
"(",
"name",
",",
"default",
"=",
"None",
",",
"allow_none",
"=",
"False",
",",
"fallback",
"=",
"None",
",",
"separator",
"=",
"','",
")",
":",
"value",
"=",
"read",
"(",
"name",
",",
"default",
",",
"allow_none",
",",
"fallback",
"="... | Get a list of strings or the default.
The individual list elements are whitespace-stripped.
Args:
name: The environment variable name
default: The default value to use if no environment variable is found
allow_none: If the return value can be `None` (i.e. optional)
separator: T... | [
"Get",
"a",
"list",
"of",
"strings",
"or",
"the",
"default",
"."
] | 19e925cd152c08d4db8126542afed35188cafff4 | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/core.py#L180-L199 | train |
OnroerendErfgoed/pyramid_urireferencer | pyramid_urireferencer/__init__.py | includeme | def includeme(config):
"""this function adds some configuration for the application"""
config.add_route('references', '/references')
_add_referencer(config.registry)
config.add_view_deriver(protected_resources.protected_view)
config.add_renderer('json_item', json_renderer)
config.scan() | python | def includeme(config):
"""this function adds some configuration for the application"""
config.add_route('references', '/references')
_add_referencer(config.registry)
config.add_view_deriver(protected_resources.protected_view)
config.add_renderer('json_item', json_renderer)
config.scan() | [
"def",
"includeme",
"(",
"config",
")",
":",
"config",
".",
"add_route",
"(",
"'references'",
",",
"'/references'",
")",
"_add_referencer",
"(",
"config",
".",
"registry",
")",
"config",
".",
"add_view_deriver",
"(",
"protected_resources",
".",
"protected_view",
... | this function adds some configuration for the application | [
"this",
"function",
"adds",
"some",
"configuration",
"for",
"the",
"application"
] | c6ee4ba863e32ced304b9cf00f3f5b450757a29a | https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/__init__.py#L17-L23 | train |
OnroerendErfgoed/pyramid_urireferencer | pyramid_urireferencer/__init__.py | _add_referencer | def _add_referencer(registry):
"""
Gets the Referencer from config and adds it to the registry.
"""
referencer = registry.queryUtility(IReferencer)
if referencer is not None:
return referencer
ref = registry.settings['urireferencer.referencer']
url = registry.settings['urireferencer.... | python | def _add_referencer(registry):
"""
Gets the Referencer from config and adds it to the registry.
"""
referencer = registry.queryUtility(IReferencer)
if referencer is not None:
return referencer
ref = registry.settings['urireferencer.referencer']
url = registry.settings['urireferencer.... | [
"def",
"_add_referencer",
"(",
"registry",
")",
":",
"referencer",
"=",
"registry",
".",
"queryUtility",
"(",
"IReferencer",
")",
"if",
"referencer",
"is",
"not",
"None",
":",
"return",
"referencer",
"ref",
"=",
"registry",
".",
"settings",
"[",
"'urireference... | Gets the Referencer from config and adds it to the registry. | [
"Gets",
"the",
"Referencer",
"from",
"config",
"and",
"adds",
"it",
"to",
"the",
"registry",
"."
] | c6ee4ba863e32ced304b9cf00f3f5b450757a29a | https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/__init__.py#L26-L37 | train |
OnroerendErfgoed/pyramid_urireferencer | pyramid_urireferencer/__init__.py | get_referencer | def get_referencer(registry):
"""
Get the referencer class
:rtype: pyramid_urireferencer.referencer.AbstractReferencer
"""
# Argument might be a config or request
regis = getattr(registry, 'registry', None)
if regis is None:
regis = registry
return regis.queryUtility(IReferencer... | python | def get_referencer(registry):
"""
Get the referencer class
:rtype: pyramid_urireferencer.referencer.AbstractReferencer
"""
# Argument might be a config or request
regis = getattr(registry, 'registry', None)
if regis is None:
regis = registry
return regis.queryUtility(IReferencer... | [
"def",
"get_referencer",
"(",
"registry",
")",
":",
"# Argument might be a config or request",
"regis",
"=",
"getattr",
"(",
"registry",
",",
"'registry'",
",",
"None",
")",
"if",
"regis",
"is",
"None",
":",
"regis",
"=",
"registry",
"return",
"regis",
".",
"q... | Get the referencer class
:rtype: pyramid_urireferencer.referencer.AbstractReferencer | [
"Get",
"the",
"referencer",
"class"
] | c6ee4ba863e32ced304b9cf00f3f5b450757a29a | https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/__init__.py#L40-L50 | train |
pyBookshelf/bookshelf | bookshelf/api_v3/ec2.py | _connect_to_ec2 | def _connect_to_ec2(region, credentials):
"""
:param region: The region of AWS to connect to.
:param EC2Credentials credentials: The credentials to use to authenticate
with EC2.
:return: a connection object to AWS EC2
"""
conn = boto.ec2.connect_to_region(
region,
aws_ac... | python | def _connect_to_ec2(region, credentials):
"""
:param region: The region of AWS to connect to.
:param EC2Credentials credentials: The credentials to use to authenticate
with EC2.
:return: a connection object to AWS EC2
"""
conn = boto.ec2.connect_to_region(
region,
aws_ac... | [
"def",
"_connect_to_ec2",
"(",
"region",
",",
"credentials",
")",
":",
"conn",
"=",
"boto",
".",
"ec2",
".",
"connect_to_region",
"(",
"region",
",",
"aws_access_key_id",
"=",
"credentials",
".",
"access_key_id",
",",
"aws_secret_access_key",
"=",
"credentials",
... | :param region: The region of AWS to connect to.
:param EC2Credentials credentials: The credentials to use to authenticate
with EC2.
:return: a connection object to AWS EC2 | [
":",
"param",
"region",
":",
"The",
"region",
"of",
"AWS",
"to",
"connect",
"to",
".",
":",
"param",
"EC2Credentials",
"credentials",
":",
"The",
"credentials",
"to",
"use",
"to",
"authenticate",
"with",
"EC2",
"."
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v3/ec2.py#L65-L82 | train |
kappius/pyheaderfile | pyheaderfile/basefile.py | PyHeaderSheet.write | def write(self, *args, **kwargs):
"""
:param args: tuple(value, style), tuple(value, style)
:param kwargs: header=tuple(value, style), header=tuple(value, style)
:param args: value, value
:param kwargs: header=value, header=value
"""
if args:
kwargs =... | python | def write(self, *args, **kwargs):
"""
:param args: tuple(value, style), tuple(value, style)
:param kwargs: header=tuple(value, style), header=tuple(value, style)
:param args: value, value
:param kwargs: header=value, header=value
"""
if args:
kwargs =... | [
"def",
"write",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"args",
":",
"kwargs",
"=",
"dict",
"(",
"zip",
"(",
"self",
".",
"header",
",",
"args",
")",
")",
"for",
"header",
"in",
"kwargs",
":",
"cell",
"=",
"kwarg... | :param args: tuple(value, style), tuple(value, style)
:param kwargs: header=tuple(value, style), header=tuple(value, style)
:param args: value, value
:param kwargs: header=value, header=value | [
":",
"param",
"args",
":",
"tuple",
"(",
"value",
"style",
")",
"tuple",
"(",
"value",
"style",
")",
":",
"param",
"kwargs",
":",
"header",
"=",
"tuple",
"(",
"value",
"style",
")",
"header",
"=",
"tuple",
"(",
"value",
"style",
")",
":",
"param",
... | 8d587dadae538adcec527fd8e74ad89ed5e2006a | https://github.com/kappius/pyheaderfile/blob/8d587dadae538adcec527fd8e74ad89ed5e2006a/pyheaderfile/basefile.py#L147-L162 | train |
benoitkugler/abstractDataLibrary | pyDLib/GUI/__init__.py | clear_layout | def clear_layout(layout: QLayout) -> None:
"""Clear the layout off all its components"""
if layout is not None:
while layout.count():
item = layout.takeAt(0)
widget = item.widget()
if widget is not None:
widget.deleteLater()
else:
... | python | def clear_layout(layout: QLayout) -> None:
"""Clear the layout off all its components"""
if layout is not None:
while layout.count():
item = layout.takeAt(0)
widget = item.widget()
if widget is not None:
widget.deleteLater()
else:
... | [
"def",
"clear_layout",
"(",
"layout",
":",
"QLayout",
")",
"->",
"None",
":",
"if",
"layout",
"is",
"not",
"None",
":",
"while",
"layout",
".",
"count",
"(",
")",
":",
"item",
"=",
"layout",
".",
"takeAt",
"(",
"0",
")",
"widget",
"=",
"item",
".",... | Clear the layout off all its components | [
"Clear",
"the",
"layout",
"off",
"all",
"its",
"components"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/__init__.py#L128-L137 | train |
leonidessaguisagjr/unicodeutil | unicodeutil/hangulutil.py | _load_hangul_syllable_types | def _load_hangul_syllable_types():
"""
Helper function for parsing the contents of "HangulSyllableType.txt" from the Unicode Character Database (UCD) and
generating a lookup table for determining whether or not a given Hangul syllable is of type "L", "V", "T", "LV" or
"LVT". For more info on the UCD, s... | python | def _load_hangul_syllable_types():
"""
Helper function for parsing the contents of "HangulSyllableType.txt" from the Unicode Character Database (UCD) and
generating a lookup table for determining whether or not a given Hangul syllable is of type "L", "V", "T", "LV" or
"LVT". For more info on the UCD, s... | [
"def",
"_load_hangul_syllable_types",
"(",
")",
":",
"filename",
"=",
"\"HangulSyllableType.txt\"",
"current_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"with",
"codecs",
".",
"open",
"(",
... | Helper function for parsing the contents of "HangulSyllableType.txt" from the Unicode Character Database (UCD) and
generating a lookup table for determining whether or not a given Hangul syllable is of type "L", "V", "T", "LV" or
"LVT". For more info on the UCD, see the following website: https://www.unicode.o... | [
"Helper",
"function",
"for",
"parsing",
"the",
"contents",
"of",
"HangulSyllableType",
".",
"txt",
"from",
"the",
"Unicode",
"Character",
"Database",
"(",
"UCD",
")",
"and",
"generating",
"a",
"lookup",
"table",
"for",
"determining",
"whether",
"or",
"not",
"a... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/hangulutil.py#L10-L29 | train |
leonidessaguisagjr/unicodeutil | unicodeutil/hangulutil.py | _load_jamo_short_names | def _load_jamo_short_names():
"""
Function for parsing the Jamo short names from the Unicode Character Database (UCD) and generating a lookup table
For more info on how this is used, see the Unicode Standard, ch. 03, section 3.12, "Conjoining Jamo Behavior" and
ch. 04, section 4.8, "Name".
https://... | python | def _load_jamo_short_names():
"""
Function for parsing the Jamo short names from the Unicode Character Database (UCD) and generating a lookup table
For more info on how this is used, see the Unicode Standard, ch. 03, section 3.12, "Conjoining Jamo Behavior" and
ch. 04, section 4.8, "Name".
https://... | [
"def",
"_load_jamo_short_names",
"(",
")",
":",
"filename",
"=",
"\"Jamo.txt\"",
"current_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"with",
"codecs",
".",
"open",
"(",
"os",
".",
"p... | Function for parsing the Jamo short names from the Unicode Character Database (UCD) and generating a lookup table
For more info on how this is used, see the Unicode Standard, ch. 03, section 3.12, "Conjoining Jamo Behavior" and
ch. 04, section 4.8, "Name".
https://www.unicode.org/versions/latest/ch03.pdf
... | [
"Function",
"for",
"parsing",
"the",
"Jamo",
"short",
"names",
"from",
"the",
"Unicode",
"Character",
"Database",
"(",
"UCD",
")",
"and",
"generating",
"a",
"lookup",
"table",
"For",
"more",
"info",
"on",
"how",
"this",
"is",
"used",
"see",
"the",
"Unicode... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/hangulutil.py#L32-L51 | train |
leonidessaguisagjr/unicodeutil | unicodeutil/hangulutil.py | _get_hangul_syllable_type | def _get_hangul_syllable_type(hangul_syllable):
"""
Function for taking a Unicode scalar value representing a Hangul syllable and determining the correct value for its
Hangul_Syllable_Type property. For more information on the Hangul_Syllable_Type property see the Unicode Standard,
ch. 03, section 3.12... | python | def _get_hangul_syllable_type(hangul_syllable):
"""
Function for taking a Unicode scalar value representing a Hangul syllable and determining the correct value for its
Hangul_Syllable_Type property. For more information on the Hangul_Syllable_Type property see the Unicode Standard,
ch. 03, section 3.12... | [
"def",
"_get_hangul_syllable_type",
"(",
"hangul_syllable",
")",
":",
"if",
"not",
"_is_hangul_syllable",
"(",
"hangul_syllable",
")",
":",
"raise",
"ValueError",
"(",
"\"Value 0x%0.4x does not represent a Hangul syllable!\"",
"%",
"hangul_syllable",
")",
"if",
"not",
"_h... | Function for taking a Unicode scalar value representing a Hangul syllable and determining the correct value for its
Hangul_Syllable_Type property. For more information on the Hangul_Syllable_Type property see the Unicode Standard,
ch. 03, section 3.12, Conjoining Jamo Behavior.
https://www.unicode.org/ver... | [
"Function",
"for",
"taking",
"a",
"Unicode",
"scalar",
"value",
"representing",
"a",
"Hangul",
"syllable",
"and",
"determining",
"the",
"correct",
"value",
"for",
"its",
"Hangul_Syllable_Type",
"property",
".",
"For",
"more",
"information",
"on",
"the",
"Hangul_Sy... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/hangulutil.py#L78-L93 | train |
leonidessaguisagjr/unicodeutil | unicodeutil/hangulutil.py | _get_jamo_short_name | def _get_jamo_short_name(jamo):
"""
Function for taking a Unicode scalar value representing a Jamo and determining the correct value for its
Jamo_Short_Name property. For more information on the Jamo_Short_Name property see the Unicode Standard,
ch. 03, section 3.12, Conjoining Jamo Behavior.
http... | python | def _get_jamo_short_name(jamo):
"""
Function for taking a Unicode scalar value representing a Jamo and determining the correct value for its
Jamo_Short_Name property. For more information on the Jamo_Short_Name property see the Unicode Standard,
ch. 03, section 3.12, Conjoining Jamo Behavior.
http... | [
"def",
"_get_jamo_short_name",
"(",
"jamo",
")",
":",
"if",
"not",
"_is_jamo",
"(",
"jamo",
")",
":",
"raise",
"ValueError",
"(",
"\"Value 0x%0.4x passed in does not represent a Jamo!\"",
"%",
"jamo",
")",
"if",
"not",
"_jamo_short_names",
":",
"_load_jamo_short_names... | Function for taking a Unicode scalar value representing a Jamo and determining the correct value for its
Jamo_Short_Name property. For more information on the Jamo_Short_Name property see the Unicode Standard,
ch. 03, section 3.12, Conjoining Jamo Behavior.
https://www.unicode.org/versions/latest/ch03.pdf... | [
"Function",
"for",
"taking",
"a",
"Unicode",
"scalar",
"value",
"representing",
"a",
"Jamo",
"and",
"determining",
"the",
"correct",
"value",
"for",
"its",
"Jamo_Short_Name",
"property",
".",
"For",
"more",
"information",
"on",
"the",
"Jamo_Short_Name",
"property"... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/hangulutil.py#L96-L111 | train |
leonidessaguisagjr/unicodeutil | unicodeutil/hangulutil.py | compose_hangul_syllable | def compose_hangul_syllable(jamo):
"""
Function for taking a tuple or list of Unicode scalar values representing Jamo and composing it into a Hangul
syllable. If the values in the list or tuple passed in are not in the ranges of Jamo, a ValueError will be raised.
The algorithm for doing the compositio... | python | def compose_hangul_syllable(jamo):
"""
Function for taking a tuple or list of Unicode scalar values representing Jamo and composing it into a Hangul
syllable. If the values in the list or tuple passed in are not in the ranges of Jamo, a ValueError will be raised.
The algorithm for doing the compositio... | [
"def",
"compose_hangul_syllable",
"(",
"jamo",
")",
":",
"fmt_str_invalid_sequence",
"=",
"\"{0} does not represent a valid sequence of Jamo!\"",
"if",
"len",
"(",
"jamo",
")",
"==",
"3",
":",
"l_part",
",",
"v_part",
",",
"t_part",
"=",
"jamo",
"if",
"not",
"(",
... | Function for taking a tuple or list of Unicode scalar values representing Jamo and composing it into a Hangul
syllable. If the values in the list or tuple passed in are not in the ranges of Jamo, a ValueError will be raised.
The algorithm for doing the composition is described in the Unicode Standard, ch. 03,... | [
"Function",
"for",
"taking",
"a",
"tuple",
"or",
"list",
"of",
"Unicode",
"scalar",
"values",
"representing",
"Jamo",
"and",
"composing",
"it",
"into",
"a",
"Hangul",
"syllable",
".",
"If",
"the",
"values",
"in",
"the",
"list",
"or",
"tuple",
"passed",
"in... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/hangulutil.py#L126-L167 | train |
leonidessaguisagjr/unicodeutil | unicodeutil/hangulutil.py | decompose_hangul_syllable | def decompose_hangul_syllable(hangul_syllable, fully_decompose=False):
"""
Function for taking a Unicode scalar value representing a Hangul syllable and decomposing it into a tuple
representing the scalar values of the decomposed (canonical decomposition) Jamo. If the Unicode scalar value
passed in is ... | python | def decompose_hangul_syllable(hangul_syllable, fully_decompose=False):
"""
Function for taking a Unicode scalar value representing a Hangul syllable and decomposing it into a tuple
representing the scalar values of the decomposed (canonical decomposition) Jamo. If the Unicode scalar value
passed in is ... | [
"def",
"decompose_hangul_syllable",
"(",
"hangul_syllable",
",",
"fully_decompose",
"=",
"False",
")",
":",
"if",
"not",
"_is_hangul_syllable",
"(",
"hangul_syllable",
")",
":",
"raise",
"ValueError",
"(",
"\"Value passed in does not represent a Hangul syllable!\"",
")",
... | Function for taking a Unicode scalar value representing a Hangul syllable and decomposing it into a tuple
representing the scalar values of the decomposed (canonical decomposition) Jamo. If the Unicode scalar value
passed in is not in the range of Hangul syllable values (as defined in UnicodeData.txt), a Value... | [
"Function",
"for",
"taking",
"a",
"Unicode",
"scalar",
"value",
"representing",
"a",
"Hangul",
"syllable",
"and",
"decomposing",
"it",
"into",
"a",
"tuple",
"representing",
"the",
"scalar",
"values",
"of",
"the",
"decomposed",
"(",
"canonical",
"decomposition",
... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/hangulutil.py#L170-L212 | train |
leonidessaguisagjr/unicodeutil | unicodeutil/hangulutil.py | _get_hangul_syllable_name | def _get_hangul_syllable_name(hangul_syllable):
"""
Function for taking a Unicode scalar value representing a Hangul syllable and converting it to its syllable name as
defined by the Unicode naming rule NR1. See the Unicode Standard, ch. 04, section 4.8, Names, for more information.
:param hangul_syll... | python | def _get_hangul_syllable_name(hangul_syllable):
"""
Function for taking a Unicode scalar value representing a Hangul syllable and converting it to its syllable name as
defined by the Unicode naming rule NR1. See the Unicode Standard, ch. 04, section 4.8, Names, for more information.
:param hangul_syll... | [
"def",
"_get_hangul_syllable_name",
"(",
"hangul_syllable",
")",
":",
"if",
"not",
"_is_hangul_syllable",
"(",
"hangul_syllable",
")",
":",
"raise",
"ValueError",
"(",
"\"Value passed in does not represent a Hangul syllable!\"",
")",
"jamo",
"=",
"decompose_hangul_syllable",
... | Function for taking a Unicode scalar value representing a Hangul syllable and converting it to its syllable name as
defined by the Unicode naming rule NR1. See the Unicode Standard, ch. 04, section 4.8, Names, for more information.
:param hangul_syllable: Unicode scalar value representing the Hangul syllable ... | [
"Function",
"for",
"taking",
"a",
"Unicode",
"scalar",
"value",
"representing",
"a",
"Hangul",
"syllable",
"and",
"converting",
"it",
"to",
"its",
"syllable",
"name",
"as",
"defined",
"by",
"the",
"Unicode",
"naming",
"rule",
"NR1",
".",
"See",
"the",
"Unico... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/hangulutil.py#L215-L230 | train |
pymacaron/pymacaron-core | pymacaron_core/swagger/client.py | generate_client_callers | def generate_client_callers(spec, timeout, error_callback, local, app):
"""Return a dict mapping method names to anonymous functions that
will call the server's endpoint of the corresponding name as
described in the api defined by the swagger dict and bravado spec"""
callers_dict = {}
def mycallba... | python | def generate_client_callers(spec, timeout, error_callback, local, app):
"""Return a dict mapping method names to anonymous functions that
will call the server's endpoint of the corresponding name as
described in the api defined by the swagger dict and bravado spec"""
callers_dict = {}
def mycallba... | [
"def",
"generate_client_callers",
"(",
"spec",
",",
"timeout",
",",
"error_callback",
",",
"local",
",",
"app",
")",
":",
"callers_dict",
"=",
"{",
"}",
"def",
"mycallback",
"(",
"endpoint",
")",
":",
"if",
"not",
"endpoint",
".",
"handler_client",
":",
"r... | Return a dict mapping method names to anonymous functions that
will call the server's endpoint of the corresponding name as
described in the api defined by the swagger dict and bravado spec | [
"Return",
"a",
"dict",
"mapping",
"method",
"names",
"to",
"anonymous",
"functions",
"that",
"will",
"call",
"the",
"server",
"s",
"endpoint",
"of",
"the",
"corresponding",
"name",
"as",
"described",
"in",
"the",
"api",
"defined",
"by",
"the",
"swagger",
"di... | 95070a39ed7065a84244ff5601fea4d54cc72b66 | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/client.py#L25-L40 | train |
pymacaron/pymacaron-core | pymacaron_core/swagger/client.py | ClientCaller._call_retry | def _call_retry(self, force_retry):
"""Call request and retry up to max_attempts times (or none if self.max_attempts=1)"""
last_exception = None
for i in range(self.max_attempts):
try:
log.info("Calling %s %s" % (self.method, self.url))
response = self... | python | def _call_retry(self, force_retry):
"""Call request and retry up to max_attempts times (or none if self.max_attempts=1)"""
last_exception = None
for i in range(self.max_attempts):
try:
log.info("Calling %s %s" % (self.method, self.url))
response = self... | [
"def",
"_call_retry",
"(",
"self",
",",
"force_retry",
")",
":",
"last_exception",
"=",
"None",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"max_attempts",
")",
":",
"try",
":",
"log",
".",
"info",
"(",
"\"Calling %s %s\"",
"%",
"(",
"self",
".",
"met... | Call request and retry up to max_attempts times (or none if self.max_attempts=1) | [
"Call",
"request",
"and",
"retry",
"up",
"to",
"max_attempts",
"times",
"(",
"or",
"none",
"if",
"self",
".",
"max_attempts",
"=",
"1",
")"
] | 95070a39ed7065a84244ff5601fea4d54cc72b66 | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/client.py#L270-L333 | train |
tsnaomi/finnsyll | finnsyll/prev/v05.py | syllabify | def syllabify(word):
'''Syllabify the given word, whether simplex or complex.'''
word = split(word) # detect any non-delimited compounds
compound = True if re.search(r'-| |\.', word) else False
syllabify = _syllabify_compound if compound else _syllabify
syll, rules = syllabify(word)
yield syll... | python | def syllabify(word):
'''Syllabify the given word, whether simplex or complex.'''
word = split(word) # detect any non-delimited compounds
compound = True if re.search(r'-| |\.', word) else False
syllabify = _syllabify_compound if compound else _syllabify
syll, rules = syllabify(word)
yield syll... | [
"def",
"syllabify",
"(",
"word",
")",
":",
"word",
"=",
"split",
"(",
"word",
")",
"# detect any non-delimited compounds",
"compound",
"=",
"True",
"if",
"re",
".",
"search",
"(",
"r'-| |\\.'",
",",
"word",
")",
"else",
"False",
"syllabify",
"=",
"_syllabify... | Syllabify the given word, whether simplex or complex. | [
"Syllabify",
"the",
"given",
"word",
"whether",
"simplex",
"or",
"complex",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v05.py#L64-L81 | train |
tsnaomi/finnsyll | finnsyll/prev/v05.py | _syllabify | def _syllabify(word, T4=True):
'''Syllabify the given word.'''
word = replace_umlauts(word)
word, rules = apply_T1(word)
if re.search(r'[^ieAyOauo]*([ieAyOauo]{2})[^ieAyOauo]*', word):
word, T2 = apply_T2(word)
word, T8 = apply_T8(word)
word, T9 = apply_T9(word)
word, T4... | python | def _syllabify(word, T4=True):
'''Syllabify the given word.'''
word = replace_umlauts(word)
word, rules = apply_T1(word)
if re.search(r'[^ieAyOauo]*([ieAyOauo]{2})[^ieAyOauo]*', word):
word, T2 = apply_T2(word)
word, T8 = apply_T8(word)
word, T9 = apply_T9(word)
word, T4... | [
"def",
"_syllabify",
"(",
"word",
",",
"T4",
"=",
"True",
")",
":",
"word",
"=",
"replace_umlauts",
"(",
"word",
")",
"word",
",",
"rules",
"=",
"apply_T1",
"(",
"word",
")",
"if",
"re",
".",
"search",
"(",
"r'[^ieAyOauo]*([ieAyOauo]{2})[^ieAyOauo]*'",
","... | Syllabify the given word. | [
"Syllabify",
"the",
"given",
"word",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v05.py#L97-L119 | train |
tsnaomi/finnsyll | finnsyll/prev/v05.py | apply_T1 | def apply_T1(word):
'''There is a syllable boundary in front of every CV-sequence.'''
# split consonants and vowels: 'balloon' -> ['b', 'a', 'll', 'oo', 'n']
WORD = [w for w in re.split('([ieAyOauo]+)', word) if w]
count = 0
for i, v in enumerate(WORD):
if i == 0 and is_consonant(v[0]):
... | python | def apply_T1(word):
'''There is a syllable boundary in front of every CV-sequence.'''
# split consonants and vowels: 'balloon' -> ['b', 'a', 'll', 'oo', 'n']
WORD = [w for w in re.split('([ieAyOauo]+)', word) if w]
count = 0
for i, v in enumerate(WORD):
if i == 0 and is_consonant(v[0]):
... | [
"def",
"apply_T1",
"(",
"word",
")",
":",
"# split consonants and vowels: 'balloon' -> ['b', 'a', 'll', 'oo', 'n']",
"WORD",
"=",
"[",
"w",
"for",
"w",
"in",
"re",
".",
"split",
"(",
"'([ieAyOauo]+)'",
",",
"word",
")",
"if",
"w",
"]",
"count",
"=",
"0",
"for"... | There is a syllable boundary in front of every CV-sequence. | [
"There",
"is",
"a",
"syllable",
"boundary",
"in",
"front",
"of",
"every",
"CV",
"-",
"sequence",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v05.py#L169-L203 | train |
OLC-Bioinformatics/sipprverse | cgecore/alignment.py | extended_cigar | def extended_cigar(aligned_template, aligned_query):
''' Convert mutation annotations to extended cigar format
https://github.com/lh3/minimap2#the-cs-optional-tag
USAGE:
>>> template = 'CGATCGATAAATAGAGTAG---GAATAGCA'
>>> query = 'CGATCG---AATAGAGTAGGTCGAATtGCA'
>>> extended_cigar(tem... | python | def extended_cigar(aligned_template, aligned_query):
''' Convert mutation annotations to extended cigar format
https://github.com/lh3/minimap2#the-cs-optional-tag
USAGE:
>>> template = 'CGATCGATAAATAGAGTAG---GAATAGCA'
>>> query = 'CGATCG---AATAGAGTAGGTCGAATtGCA'
>>> extended_cigar(tem... | [
"def",
"extended_cigar",
"(",
"aligned_template",
",",
"aligned_query",
")",
":",
"# - Go through each position in the alignment",
"insertion",
"=",
"[",
"]",
"deletion",
"=",
"[",
"]",
"matches",
"=",
"[",
"]",
"cigar",
"=",
"[",
"]",
"for",
"r_aa",
",",
"q... | Convert mutation annotations to extended cigar format
https://github.com/lh3/minimap2#the-cs-optional-tag
USAGE:
>>> template = 'CGATCGATAAATAGAGTAG---GAATAGCA'
>>> query = 'CGATCG---AATAGAGTAGGTCGAATtGCA'
>>> extended_cigar(template, query) == ':6-ata:10+gtc:4*at:3'
True | [
"Convert",
"mutation",
"annotations",
"to",
"extended",
"cigar",
"format",
"https",
":",
"//",
"github",
".",
"com",
"/",
"lh3",
"/",
"minimap2#the",
"-",
"cs",
"-",
"optional",
"-",
"tag",
"USAGE",
":",
">>>",
"template",
"=",
"CGATCGATAAATAGAGTAG",
"---",
... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/alignment.py#L14-L83 | train |
OLC-Bioinformatics/sipprverse | cgecore/alignment.py | cigar2query | def cigar2query(template, cigar):
''' Generate query sequence from the template and extended cigar annotation
USAGE:
>>> template = 'CGATCGATAAATAGAGTAGGAATAGCA'
>>> cigar = ':6-ata:10+gtc:4*at:3'
>>> cigar2query(template, cigar) == 'CGATCGAATAGAGTAGGTCGAATtGCA'.upper()
True
'''
... | python | def cigar2query(template, cigar):
''' Generate query sequence from the template and extended cigar annotation
USAGE:
>>> template = 'CGATCGATAAATAGAGTAGGAATAGCA'
>>> cigar = ':6-ata:10+gtc:4*at:3'
>>> cigar2query(template, cigar) == 'CGATCGAATAGAGTAGGTCGAATtGCA'.upper()
True
'''
... | [
"def",
"cigar2query",
"(",
"template",
",",
"cigar",
")",
":",
"query",
"=",
"[",
"]",
"entries",
"=",
"[",
"'+'",
",",
"'-'",
",",
"'*'",
",",
"':'",
"]",
"number",
"=",
"list",
"(",
"map",
"(",
"str",
",",
"range",
"(",
"10",
")",
")",
")",
... | Generate query sequence from the template and extended cigar annotation
USAGE:
>>> template = 'CGATCGATAAATAGAGTAGGAATAGCA'
>>> cigar = ':6-ata:10+gtc:4*at:3'
>>> cigar2query(template, cigar) == 'CGATCGAATAGAGTAGGTCGAATtGCA'.upper()
True | [
"Generate",
"query",
"sequence",
"from",
"the",
"template",
"and",
"extended",
"cigar",
"annotation",
"USAGE",
":",
">>>",
"template",
"=",
"CGATCGATAAATAGAGTAGGAATAGCA",
">>>",
"cigar",
"=",
":",
"6",
"-",
"ata",
":",
"10",
"+",
"gtc",
":",
"4",
"*",
"at"... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/alignment.py#L85-L128 | train |
OLC-Bioinformatics/sipprverse | cgecore/alignment.py | Blaster | def Blaster(inputfile, databases, db_path, out_path='.', min_cov=0.6,
threshold=0.9, blast='blastn', cut_off=True):
''' BLAST wrapper method, that takes a simple input and produces a overview
list of the hits to templates, and their alignments
Usage
>>> import os, subprocess, collections
... | python | def Blaster(inputfile, databases, db_path, out_path='.', min_cov=0.6,
threshold=0.9, blast='blastn', cut_off=True):
''' BLAST wrapper method, that takes a simple input and produces a overview
list of the hits to templates, and their alignments
Usage
>>> import os, subprocess, collections
... | [
"def",
"Blaster",
"(",
"inputfile",
",",
"databases",
",",
"db_path",
",",
"out_path",
"=",
"'.'",
",",
"min_cov",
"=",
"0.6",
",",
"threshold",
"=",
"0.9",
",",
"blast",
"=",
"'blastn'",
",",
"cut_off",
"=",
"True",
")",
":",
"min_cov",
"=",
"100",
... | BLAST wrapper method, that takes a simple input and produces a overview
list of the hits to templates, and their alignments
Usage
>>> import os, subprocess, collections
>>> from Bio.Blast import NCBIXML
>>> from Bio import SeqIO
>>> from string import maketrans
>>> inputfile = 't... | [
"BLAST",
"wrapper",
"method",
"that",
"takes",
"a",
"simple",
"input",
"and",
"produces",
"a",
"overview",
"list",
"of",
"the",
"hits",
"to",
"templates",
"and",
"their",
"alignments",
"Usage",
">>>",
"import",
"os",
"subprocess",
"collections",
">>>",
"from",... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/alignment.py#L130-L325 | train |
OLC-Bioinformatics/sipprverse | cgecore/alignment.py | compare_results | def compare_results(save, best_hsp, tmp_results, tmp_gene_split):
''' Function for comparing hits and saving only the best hit '''
# Get data for comparison
hit_id = best_hsp['hit_id']
new_start_query = best_hsp['query_start']
new_end_query = best_hsp['query_end']
new_start_sbjct = int(best_hsp['sbjct... | python | def compare_results(save, best_hsp, tmp_results, tmp_gene_split):
''' Function for comparing hits and saving only the best hit '''
# Get data for comparison
hit_id = best_hsp['hit_id']
new_start_query = best_hsp['query_start']
new_end_query = best_hsp['query_end']
new_start_sbjct = int(best_hsp['sbjct... | [
"def",
"compare_results",
"(",
"save",
",",
"best_hsp",
",",
"tmp_results",
",",
"tmp_gene_split",
")",
":",
"# Get data for comparison",
"hit_id",
"=",
"best_hsp",
"[",
"'hit_id'",
"]",
"new_start_query",
"=",
"best_hsp",
"[",
"'query_start'",
"]",
"new_end_query",... | Function for comparing hits and saving only the best hit | [
"Function",
"for",
"comparing",
"hits",
"and",
"saving",
"only",
"the",
"best",
"hit"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/alignment.py#L332-L446 | train |
OLC-Bioinformatics/sipprverse | cgecore/alignment.py | calculate_new_length | def calculate_new_length(gene_split, gene_results, hit):
''' Function for calcualting new length if the gene is split on several
contigs
'''
# Looping over splitted hits and calculate new length
first = 1
for split in gene_split[hit['sbjct_header']]:
new_start = int(gene_results[split]['sbjct_st... | python | def calculate_new_length(gene_split, gene_results, hit):
''' Function for calcualting new length if the gene is split on several
contigs
'''
# Looping over splitted hits and calculate new length
first = 1
for split in gene_split[hit['sbjct_header']]:
new_start = int(gene_results[split]['sbjct_st... | [
"def",
"calculate_new_length",
"(",
"gene_split",
",",
"gene_results",
",",
"hit",
")",
":",
"# Looping over splitted hits and calculate new length",
"first",
"=",
"1",
"for",
"split",
"in",
"gene_split",
"[",
"hit",
"[",
"'sbjct_header'",
"]",
"]",
":",
"new_start"... | Function for calcualting new length if the gene is split on several
contigs | [
"Function",
"for",
"calcualting",
"new",
"length",
"if",
"the",
"gene",
"is",
"split",
"on",
"several",
"contigs"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/alignment.py#L448-L473 | train |
JoelBender/modpypes | modpypes/app.py | stream_to_packet | def stream_to_packet(data):
"""
Chop a stream of data into MODBUS packets.
:param data: stream of data
:returns: a tuple of the data that is a packet with the remaining
data, or ``None``
"""
if len(data) < 6:
return None
# unpack the length
pktlen = struct.unpack(">H", ... | python | def stream_to_packet(data):
"""
Chop a stream of data into MODBUS packets.
:param data: stream of data
:returns: a tuple of the data that is a packet with the remaining
data, or ``None``
"""
if len(data) < 6:
return None
# unpack the length
pktlen = struct.unpack(">H", ... | [
"def",
"stream_to_packet",
"(",
"data",
")",
":",
"if",
"len",
"(",
"data",
")",
"<",
"6",
":",
"return",
"None",
"# unpack the length",
"pktlen",
"=",
"struct",
".",
"unpack",
"(",
"\">H\"",
",",
"data",
"[",
"4",
":",
"6",
"]",
")",
"[",
"0",
"]"... | Chop a stream of data into MODBUS packets.
:param data: stream of data
:returns: a tuple of the data that is a packet with the remaining
data, or ``None`` | [
"Chop",
"a",
"stream",
"of",
"data",
"into",
"MODBUS",
"packets",
"."
] | f6e33c48fdc70f873bc2823b1ac4111cafe2a700 | https://github.com/JoelBender/modpypes/blob/f6e33c48fdc70f873bc2823b1ac4111cafe2a700/modpypes/app.py#L61-L77 | train |
QunarOPS/qg.core | qg/core/jsonutils.py | to_primitive | def to_primitive(value, convert_instances=False, convert_datetime=True,
level=0, max_depth=3):
"""Convert a complex object into primitives.
Handy for JSON serialization. We can optionally handle instances,
but since this is a recursive function, we could have cyclical
data structures.
... | python | def to_primitive(value, convert_instances=False, convert_datetime=True,
level=0, max_depth=3):
"""Convert a complex object into primitives.
Handy for JSON serialization. We can optionally handle instances,
but since this is a recursive function, we could have cyclical
data structures.
... | [
"def",
"to_primitive",
"(",
"value",
",",
"convert_instances",
"=",
"False",
",",
"convert_datetime",
"=",
"True",
",",
"level",
"=",
"0",
",",
"max_depth",
"=",
"3",
")",
":",
"# handle obvious types first - order of basic types determined by running",
"# full tests on... | Convert a complex object into primitives.
Handy for JSON serialization. We can optionally handle instances,
but since this is a recursive function, we could have cyclical
data structures.
To handle cyclical data structures we could track the actual objects
visited in a set, but not all objects are... | [
"Convert",
"a",
"complex",
"object",
"into",
"primitives",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/jsonutils.py#L63-L156 | train |
tsnaomi/finnsyll | finnsyll/phonology.py | get_vowel | def get_vowel(syll):
'''Return the firstmost vowel in 'syll'.'''
return re.search(r'([ieaouäöy]{1})', syll, flags=FLAGS).group(1).upper() | python | def get_vowel(syll):
'''Return the firstmost vowel in 'syll'.'''
return re.search(r'([ieaouäöy]{1})', syll, flags=FLAGS).group(1).upper() | [
"def",
"get_vowel",
"(",
"syll",
")",
":",
"return",
"re",
".",
"search",
"(",
"r'([ieaouäöy]{1})', ",
"s",
"ll, ",
"f",
"ags=F",
"L",
"AGS).",
"g",
"r",
"oup(1",
")",
".",
"u",
"p",
"per()",
"",
""
] | Return the firstmost vowel in 'syll'. | [
"Return",
"the",
"firstmost",
"vowel",
"in",
"syll",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/phonology.py#L88-L90 | train |
tsnaomi/finnsyll | finnsyll/phonology.py | is_light | def is_light(syll):
'''Return True if 'syll' is light.'''
return re.match(r'(^|[^ieaouäöy]+)[ieaouäöy]{1}$', syll, flags=FLAGS) | python | def is_light(syll):
'''Return True if 'syll' is light.'''
return re.match(r'(^|[^ieaouäöy]+)[ieaouäöy]{1}$', syll, flags=FLAGS) | [
"def",
"is_light",
"(",
"syll",
")",
":",
"return",
"re",
".",
"match",
"(",
"r'(^|[^ieaouäöy]+)[ieaouäöy]{1}$', sy",
"l",
", fl",
"a",
"s=FLA",
"G",
"S)",
""
] | Return True if 'syll' is light. | [
"Return",
"True",
"if",
"syll",
"is",
"light",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/phonology.py#L98-L100 | train |
tsnaomi/finnsyll | finnsyll/phonology.py | stress | def stress(syllabified_simplex_word):
'''Assign primary and secondary stress to 'syllabified_simplex_word'.'''
syllables = syllabified_simplex_word.split('.')
stressed = '\'' + syllables[0] # primary stress
try:
n = 0
medial = syllables[1:-1]
for i, syll in enumerate(medial):
... | python | def stress(syllabified_simplex_word):
'''Assign primary and secondary stress to 'syllabified_simplex_word'.'''
syllables = syllabified_simplex_word.split('.')
stressed = '\'' + syllables[0] # primary stress
try:
n = 0
medial = syllables[1:-1]
for i, syll in enumerate(medial):
... | [
"def",
"stress",
"(",
"syllabified_simplex_word",
")",
":",
"syllables",
"=",
"syllabified_simplex_word",
".",
"split",
"(",
"'.'",
")",
"stressed",
"=",
"'\\''",
"+",
"syllables",
"[",
"0",
"]",
"# primary stress",
"try",
":",
"n",
"=",
"0",
"medial",
"=",
... | Assign primary and secondary stress to 'syllabified_simplex_word'. | [
"Assign",
"primary",
"and",
"secondary",
"stress",
"to",
"syllabified_simplex_word",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/phonology.py#L108-L141 | train |
tsnaomi/finnsyll | finnsyll/phonology.py | sonseq | def sonseq(word):
'''Return True if 'word' does not violate sonority sequencing.'''
parts = re.split(r'([ieaouäöy]+)', word, flags=re.I | re.U)
onset, coda = parts[0], parts[-1]
# simplex onset Finnish complex onset
if len(onset) <= 1 or onset.lower() in ONSETS:
# simplex coda ... | python | def sonseq(word):
'''Return True if 'word' does not violate sonority sequencing.'''
parts = re.split(r'([ieaouäöy]+)', word, flags=re.I | re.U)
onset, coda = parts[0], parts[-1]
# simplex onset Finnish complex onset
if len(onset) <= 1 or onset.lower() in ONSETS:
# simplex coda ... | [
"def",
"sonseq",
"(",
"word",
")",
":",
"parts",
"=",
"re",
".",
"split",
"(",
"r'([ieaouäöy]+)', ",
"w",
"rd, ",
"f",
"ags=r",
"e",
".I",
" ",
"|",
"r",
".U",
")",
"",
"",
"onset",
",",
"coda",
"=",
"parts",
"[",
"0",
"]",
",",
"parts",
"[",
... | Return True if 'word' does not violate sonority sequencing. | [
"Return",
"True",
"if",
"word",
"does",
"not",
"violate",
"sonority",
"sequencing",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/phonology.py#L154-L164 | train |
tsnaomi/finnsyll | finnsyll/phonology.py | harmonic | def harmonic(word):
'''Return True if the word's vowels agree in frontness/backness.'''
depth = {'ä': 0, 'ö': 0, 'y': 0, 'a': 1, 'o': 1, 'u': 1}
vowels = filter(lambda ch: is_front(ch) or is_back(ch), word)
depths = (depth[x.lower()] for x in vowels)
return len(set(depths)) < 2 | python | def harmonic(word):
'''Return True if the word's vowels agree in frontness/backness.'''
depth = {'ä': 0, 'ö': 0, 'y': 0, 'a': 1, 'o': 1, 'u': 1}
vowels = filter(lambda ch: is_front(ch) or is_back(ch), word)
depths = (depth[x.lower()] for x in vowels)
return len(set(depths)) < 2 | [
"def",
"harmonic",
"(",
"word",
")",
":",
"depth",
"=",
"{",
"'ä':",
" ",
",",
" ",
"ö': ",
"0",
" ",
"'",
"': ",
"0",
" ",
"'",
"': ",
"1",
" ",
"'",
"': ",
"1",
" ",
"'",
"': ",
"1",
"",
"",
"vowels",
"=",
"filter",
"(",
"lambda",
"ch",
... | Return True if the word's vowels agree in frontness/backness. | [
"Return",
"True",
"if",
"the",
"word",
"s",
"vowels",
"agree",
"in",
"frontness",
"/",
"backness",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/phonology.py#L172-L178 | train |
saltant-org/saltant-py | saltant/models/executable_task_type.py | ExecutableTaskType.put | def put(self):
"""Updates this task type on the saltant server.
Returns:
:class:`saltant.models.container_task_type.ExecutableTaskType`:
An executable task type model instance representing the task type
just updated.
"""
return self.manager.pu... | python | def put(self):
"""Updates this task type on the saltant server.
Returns:
:class:`saltant.models.container_task_type.ExecutableTaskType`:
An executable task type model instance representing the task type
just updated.
"""
return self.manager.pu... | [
"def",
"put",
"(",
"self",
")",
":",
"return",
"self",
".",
"manager",
".",
"put",
"(",
"id",
"=",
"self",
".",
"id",
",",
"name",
"=",
"self",
".",
"name",
",",
"description",
"=",
"self",
".",
"description",
",",
"command_to_run",
"=",
"self",
".... | Updates this task type on the saltant server.
Returns:
:class:`saltant.models.container_task_type.ExecutableTaskType`:
An executable task type model instance representing the task type
just updated. | [
"Updates",
"this",
"task",
"type",
"on",
"the",
"saltant",
"server",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/executable_task_type.py#L84-L103 | train |
saltant-org/saltant-py | saltant/models/executable_task_type.py | ExecutableTaskTypeManager.create | def create(
self,
name,
command_to_run,
description="",
environment_variables=None,
required_arguments=None,
required_arguments_default_values=None,
json_file_option=None,
extra_data_to_post=None,
):
"""Create a container task type.
... | python | def create(
self,
name,
command_to_run,
description="",
environment_variables=None,
required_arguments=None,
required_arguments_default_values=None,
json_file_option=None,
extra_data_to_post=None,
):
"""Create a container task type.
... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"command_to_run",
",",
"description",
"=",
"\"\"",
",",
"environment_variables",
"=",
"None",
",",
"required_arguments",
"=",
"None",
",",
"required_arguments_default_values",
"=",
"None",
",",
"json_file_option",
"=... | Create a container task type.
Args:
name (str): The name of the task.
command_to_run (str): The command to run to execute the task.
description (str, optional): The description of the task type.
environment_variables (list, optional): The environment
... | [
"Create",
"a",
"container",
"task",
"type",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/executable_task_type.py#L122-L172 | train |
saltant-org/saltant-py | saltant/models/executable_task_type.py | ExecutableTaskTypeManager.put | def put(
self,
id,
name,
description,
command_to_run,
environment_variables,
required_arguments,
required_arguments_default_values,
json_file_option,
extra_data_to_put=None,
):
"""Updates a task type on the saltant server.
... | python | def put(
self,
id,
name,
description,
command_to_run,
environment_variables,
required_arguments,
required_arguments_default_values,
json_file_option,
extra_data_to_put=None,
):
"""Updates a task type on the saltant server.
... | [
"def",
"put",
"(",
"self",
",",
"id",
",",
"name",
",",
"description",
",",
"command_to_run",
",",
"environment_variables",
",",
"required_arguments",
",",
"required_arguments_default_values",
",",
"json_file_option",
",",
"extra_data_to_put",
"=",
"None",
",",
")",... | Updates a task type on the saltant server.
Args:
id (int): The ID of the task type.
name (str): The name of the task type.
description (str): The description of the task type.
command_to_run (str): The command to run to execute the task.
environment_v... | [
"Updates",
"a",
"task",
"type",
"on",
"the",
"saltant",
"server",
"."
] | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/executable_task_type.py#L174-L223 | train |
OLC-Bioinformatics/sipprverse | sipprverse_reporter/reports.py | Reports.reporter | def reporter(self, analysistype='genesippr'):
"""
Creates a report of the genesippr results
:param analysistype: The variable to use when accessing attributes in the metadata object
"""
logging.info('Creating {} report'.format(analysistype))
# Create a dictionary to link ... | python | def reporter(self, analysistype='genesippr'):
"""
Creates a report of the genesippr results
:param analysistype: The variable to use when accessing attributes in the metadata object
"""
logging.info('Creating {} report'.format(analysistype))
# Create a dictionary to link ... | [
"def",
"reporter",
"(",
"self",
",",
"analysistype",
"=",
"'genesippr'",
")",
":",
"logging",
".",
"info",
"(",
"'Creating {} report'",
".",
"format",
"(",
"analysistype",
")",
")",
"# Create a dictionary to link all the genera with their genes",
"genusgenes",
"=",
"d... | Creates a report of the genesippr results
:param analysistype: The variable to use when accessing attributes in the metadata object | [
"Creates",
"a",
"report",
"of",
"the",
"genesippr",
"results",
":",
"param",
"analysistype",
":",
"The",
"variable",
"to",
"use",
"when",
"accessing",
"attributes",
"in",
"the",
"metadata",
"object"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sipprverse_reporter/reports.py#L24-L115 | train |
OLC-Bioinformatics/sipprverse | sipprverse_reporter/reports.py | Reports.genusspecific | def genusspecific(self, analysistype='genesippr'):
"""
Creates simplified genus-specific reports. Instead of the % ID and the fold coverage, a simple +/- scheme is
used for presence/absence
:param analysistype: The variable to use when accessing attributes in the metadata object
... | python | def genusspecific(self, analysistype='genesippr'):
"""
Creates simplified genus-specific reports. Instead of the % ID and the fold coverage, a simple +/- scheme is
used for presence/absence
:param analysistype: The variable to use when accessing attributes in the metadata object
... | [
"def",
"genusspecific",
"(",
"self",
",",
"analysistype",
"=",
"'genesippr'",
")",
":",
"# Dictionary to store all the output strings",
"results",
"=",
"dict",
"(",
")",
"for",
"genus",
",",
"genelist",
"in",
"self",
".",
"genedict",
".",
"items",
"(",
")",
":... | Creates simplified genus-specific reports. Instead of the % ID and the fold coverage, a simple +/- scheme is
used for presence/absence
:param analysistype: The variable to use when accessing attributes in the metadata object | [
"Creates",
"simplified",
"genus",
"-",
"specific",
"reports",
".",
"Instead",
"of",
"the",
"%",
"ID",
"and",
"the",
"fold",
"coverage",
"a",
"simple",
"+",
"/",
"-",
"scheme",
"is",
"used",
"for",
"presence",
"/",
"absence",
":",
"param",
"analysistype",
... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sipprverse_reporter/reports.py#L117-L155 | train |
OLC-Bioinformatics/sipprverse | sipprverse_reporter/reports.py | Reports.gdcsreporter | def gdcsreporter(self, analysistype='GDCS'):
"""
Creates a report of the GDCS results
:param analysistype: The variable to use when accessing attributes in the metadata object
"""
logging.info('Creating {} report'.format(analysistype))
# Initialise list to store all the G... | python | def gdcsreporter(self, analysistype='GDCS'):
"""
Creates a report of the GDCS results
:param analysistype: The variable to use when accessing attributes in the metadata object
"""
logging.info('Creating {} report'.format(analysistype))
# Initialise list to store all the G... | [
"def",
"gdcsreporter",
"(",
"self",
",",
"analysistype",
"=",
"'GDCS'",
")",
":",
"logging",
".",
"info",
"(",
"'Creating {} report'",
".",
"format",
"(",
"analysistype",
")",
")",
"# Initialise list to store all the GDCS genes, and genera in the analysis",
"gdcs",
"=",... | Creates a report of the GDCS results
:param analysistype: The variable to use when accessing attributes in the metadata object | [
"Creates",
"a",
"report",
"of",
"the",
"GDCS",
"results",
":",
"param",
"analysistype",
":",
"The",
"variable",
"to",
"use",
"when",
"accessing",
"attributes",
"in",
"the",
"metadata",
"object"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sipprverse_reporter/reports.py#L157-L260 | train |
OLC-Bioinformatics/sipprverse | sipprverse_reporter/reports.py | Reports.gdcs_fai | def gdcs_fai(sample, analysistype='GDCS'):
"""
GDCS analyses need to use the .fai file supplied in the targets folder rather than the one created following
reverse baiting
:param sample: sample object
:param analysistype: current analysis being performed
"""
try:
... | python | def gdcs_fai(sample, analysistype='GDCS'):
"""
GDCS analyses need to use the .fai file supplied in the targets folder rather than the one created following
reverse baiting
:param sample: sample object
:param analysistype: current analysis being performed
"""
try:
... | [
"def",
"gdcs_fai",
"(",
"sample",
",",
"analysistype",
"=",
"'GDCS'",
")",
":",
"try",
":",
"# Find the .fai file in the target path",
"sample",
"[",
"analysistype",
"]",
".",
"faifile",
"=",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"sample",
"[",
... | GDCS analyses need to use the .fai file supplied in the targets folder rather than the one created following
reverse baiting
:param sample: sample object
:param analysistype: current analysis being performed | [
"GDCS",
"analyses",
"need",
"to",
"use",
"the",
".",
"fai",
"file",
"supplied",
"in",
"the",
"targets",
"folder",
"rather",
"than",
"the",
"one",
"created",
"following",
"reverse",
"baiting",
":",
"param",
"sample",
":",
"sample",
"object",
":",
"param",
"... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sipprverse_reporter/reports.py#L263-L289 | train |
OLC-Bioinformatics/sipprverse | sipprverse_reporter/reports.py | Reports.sixteensreporter | def sixteensreporter(self, analysistype='sixteens_full'):
"""
Creates a report of the results
:param analysistype: The variable to use when accessing attributes in the metadata object
"""
# Create the path in which the reports are stored
make_path(self.reportpath)
... | python | def sixteensreporter(self, analysistype='sixteens_full'):
"""
Creates a report of the results
:param analysistype: The variable to use when accessing attributes in the metadata object
"""
# Create the path in which the reports are stored
make_path(self.reportpath)
... | [
"def",
"sixteensreporter",
"(",
"self",
",",
"analysistype",
"=",
"'sixteens_full'",
")",
":",
"# Create the path in which the reports are stored",
"make_path",
"(",
"self",
".",
"reportpath",
")",
"# Initialise the header and data strings",
"header",
"=",
"'Strain,Gene,Perce... | Creates a report of the results
:param analysistype: The variable to use when accessing attributes in the metadata object | [
"Creates",
"a",
"report",
"of",
"the",
"results",
":",
"param",
"analysistype",
":",
"The",
"variable",
"to",
"use",
"when",
"accessing",
"attributes",
"in",
"the",
"metadata",
"object"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sipprverse_reporter/reports.py#L291-L326 | train |
OLC-Bioinformatics/sipprverse | sipprverse_reporter/reports.py | Reports.confindr_reporter | def confindr_reporter(self, analysistype='confindr'):
"""
Creates a final report of all the ConFindr results
"""
# Initialise the data strings
data = 'Strain,Genus,NumContamSNVs,ContamStatus,PercentContam,PercentContamSTD\n'
with open(os.path.join(self.reportpath, analysi... | python | def confindr_reporter(self, analysistype='confindr'):
"""
Creates a final report of all the ConFindr results
"""
# Initialise the data strings
data = 'Strain,Genus,NumContamSNVs,ContamStatus,PercentContam,PercentContamSTD\n'
with open(os.path.join(self.reportpath, analysi... | [
"def",
"confindr_reporter",
"(",
"self",
",",
"analysistype",
"=",
"'confindr'",
")",
":",
"# Initialise the data strings",
"data",
"=",
"'Strain,Genus,NumContamSNVs,ContamStatus,PercentContam,PercentContamSTD\\n'",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"("... | Creates a final report of all the ConFindr results | [
"Creates",
"a",
"final",
"report",
"of",
"all",
"the",
"ConFindr",
"results"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sipprverse_reporter/reports.py#L328-L346 | train |
OLC-Bioinformatics/sipprverse | sipprverse_reporter/reports.py | Reports.methodreporter | def methodreporter(self):
"""
Create final reports collating results from all the individual iterations through the method pipeline
"""
# Ensure that the analyses are set to complete
self.analysescomplete = True
# Reset the report path to original value
self.repor... | python | def methodreporter(self):
"""
Create final reports collating results from all the individual iterations through the method pipeline
"""
# Ensure that the analyses are set to complete
self.analysescomplete = True
# Reset the report path to original value
self.repor... | [
"def",
"methodreporter",
"(",
"self",
")",
":",
"# Ensure that the analyses are set to complete",
"self",
".",
"analysescomplete",
"=",
"True",
"# Reset the report path to original value",
"self",
".",
"reportpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".... | Create final reports collating results from all the individual iterations through the method pipeline | [
"Create",
"final",
"reports",
"collating",
"results",
"from",
"all",
"the",
"individual",
"iterations",
"through",
"the",
"method",
"pipeline"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sipprverse_reporter/reports.py#L348-L371 | train |
OLC-Bioinformatics/sipprverse | sipprverse_reporter/reports.py | ReportImage.main | def main(self):
"""
Run the methods required to create the genesippr report summary image
"""
self.dataframe_setup()
self.figure_populate(self.outputfolder,
self.image_report,
self.header_list,
... | python | def main(self):
"""
Run the methods required to create the genesippr report summary image
"""
self.dataframe_setup()
self.figure_populate(self.outputfolder,
self.image_report,
self.header_list,
... | [
"def",
"main",
"(",
"self",
")",
":",
"self",
".",
"dataframe_setup",
"(",
")",
"self",
".",
"figure_populate",
"(",
"self",
".",
"outputfolder",
",",
"self",
".",
"image_report",
",",
"self",
".",
"header_list",
",",
"self",
".",
"samples",
",",
"'genes... | Run the methods required to create the genesippr report summary image | [
"Run",
"the",
"methods",
"required",
"to",
"create",
"the",
"genesippr",
"report",
"summary",
"image"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sipprverse_reporter/reports.py#L417-L428 | train |
OLC-Bioinformatics/sipprverse | sipprverse_reporter/reports.py | ReportImage.data_sanitise | def data_sanitise(self, inputstring, header=None):
"""
Format the data to be consistent with heatmaps
:param inputstring: string containing data to be formatted
:param header: class of the data - certain categories have specific formatting requirements
:return: the formatted outp... | python | def data_sanitise(self, inputstring, header=None):
"""
Format the data to be consistent with heatmaps
:param inputstring: string containing data to be formatted
:param header: class of the data - certain categories have specific formatting requirements
:return: the formatted outp... | [
"def",
"data_sanitise",
"(",
"self",
",",
"inputstring",
",",
"header",
"=",
"None",
")",
":",
"if",
"str",
"(",
"inputstring",
")",
"==",
"'nan'",
":",
"outputstring",
"=",
"0",
"elif",
"'%'",
"in",
"str",
"(",
"inputstring",
")",
":",
"group",
"=",
... | Format the data to be consistent with heatmaps
:param inputstring: string containing data to be formatted
:param header: class of the data - certain categories have specific formatting requirements
:return: the formatted output string | [
"Format",
"the",
"data",
"to",
"be",
"consistent",
"with",
"heatmaps",
":",
"param",
"inputstring",
":",
"string",
"containing",
"data",
"to",
"be",
"formatted",
":",
"param",
"header",
":",
"class",
"of",
"the",
"data",
"-",
"certain",
"categories",
"have",... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sipprverse_reporter/reports.py#L430-L463 | train |
OLC-Bioinformatics/sipprverse | sipprverse_reporter/reports.py | ReportImage.dataframe_setup | def dataframe_setup(self):
"""
Set-up a report to store the desired header: sanitized string combinations
"""
# Initialise a dictionary to store the sanitized headers and strings
genesippr_dict = dict()
# Try to open all the reports - use pandas to extract the results fro... | python | def dataframe_setup(self):
"""
Set-up a report to store the desired header: sanitized string combinations
"""
# Initialise a dictionary to store the sanitized headers and strings
genesippr_dict = dict()
# Try to open all the reports - use pandas to extract the results fro... | [
"def",
"dataframe_setup",
"(",
"self",
")",
":",
"# Initialise a dictionary to store the sanitized headers and strings",
"genesippr_dict",
"=",
"dict",
"(",
")",
"# Try to open all the reports - use pandas to extract the results from any report that exists",
"try",
":",
"sippr_matrix",... | Set-up a report to store the desired header: sanitized string combinations | [
"Set",
"-",
"up",
"a",
"report",
"to",
"store",
"the",
"desired",
"header",
":",
"sanitized",
"string",
"combinations"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sipprverse_reporter/reports.py#L465-L551 | train |
OLC-Bioinformatics/sipprverse | sipprverse_reporter/reports.py | ReportImage.figure_populate | def figure_populate(outputpath, csv, xlabels, ylabels, analysistype, description, fail=False):
"""
Create the report image from the summary report created in self.dataframesetup
:param outputpath: Path in which the outputs are to be created
:param csv: Name of the report file from which ... | python | def figure_populate(outputpath, csv, xlabels, ylabels, analysistype, description, fail=False):
"""
Create the report image from the summary report created in self.dataframesetup
:param outputpath: Path in which the outputs are to be created
:param csv: Name of the report file from which ... | [
"def",
"figure_populate",
"(",
"outputpath",
",",
"csv",
",",
"xlabels",
",",
"ylabels",
",",
"analysistype",
",",
"description",
",",
"fail",
"=",
"False",
")",
":",
"# Create a data frame from the summary report",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"os",
... | Create the report image from the summary report created in self.dataframesetup
:param outputpath: Path in which the outputs are to be created
:param csv: Name of the report file from which data are to be extracted
:param xlabels: List of all the labels to use on the x-axis
:param ylabels... | [
"Create",
"the",
"report",
"image",
"from",
"the",
"summary",
"report",
"created",
"in",
"self",
".",
"dataframesetup",
":",
"param",
"outputpath",
":",
"Path",
"in",
"which",
"the",
"outputs",
"are",
"to",
"be",
"created",
":",
"param",
"csv",
":",
"Name"... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sipprverse_reporter/reports.py#L554-L600 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/os_helpers.py | add_usr_local_bin_to_path | def add_usr_local_bin_to_path(log=False):
""" adds /usr/local/bin to $PATH """
if log:
bookshelf2.logging_helpers.log_green('inserts /usr/local/bin into PATH')
with settings(hide('warnings', 'running', 'stdout', 'stderr'),
capture=True):
try:
sudo('echo "export... | python | def add_usr_local_bin_to_path(log=False):
""" adds /usr/local/bin to $PATH """
if log:
bookshelf2.logging_helpers.log_green('inserts /usr/local/bin into PATH')
with settings(hide('warnings', 'running', 'stdout', 'stderr'),
capture=True):
try:
sudo('echo "export... | [
"def",
"add_usr_local_bin_to_path",
"(",
"log",
"=",
"False",
")",
":",
"if",
"log",
":",
"bookshelf2",
".",
"logging_helpers",
".",
"log_green",
"(",
"'inserts /usr/local/bin into PATH'",
")",
"with",
"settings",
"(",
"hide",
"(",
"'warnings'",
",",
"'running'",
... | adds /usr/local/bin to $PATH | [
"adds",
"/",
"usr",
"/",
"local",
"/",
"bin",
"to",
"$PATH"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L12-L24 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/os_helpers.py | dir_attribs | def dir_attribs(location, mode=None, owner=None,
group=None, recursive=False, use_sudo=False):
""" cuisine dir_attribs doesn't do sudo, so we implement our own
Updates the mode/owner/group for the given remote directory."""
args = ''
if recursive:
args = args + ' -R '
if... | python | def dir_attribs(location, mode=None, owner=None,
group=None, recursive=False, use_sudo=False):
""" cuisine dir_attribs doesn't do sudo, so we implement our own
Updates the mode/owner/group for the given remote directory."""
args = ''
if recursive:
args = args + ' -R '
if... | [
"def",
"dir_attribs",
"(",
"location",
",",
"mode",
"=",
"None",
",",
"owner",
"=",
"None",
",",
"group",
"=",
"None",
",",
"recursive",
"=",
"False",
",",
"use_sudo",
"=",
"False",
")",
":",
"args",
"=",
"''",
"if",
"recursive",
":",
"args",
"=",
... | cuisine dir_attribs doesn't do sudo, so we implement our own
Updates the mode/owner/group for the given remote directory. | [
"cuisine",
"dir_attribs",
"doesn",
"t",
"do",
"sudo",
"so",
"we",
"implement",
"our",
"own",
"Updates",
"the",
"mode",
"/",
"owner",
"/",
"group",
"for",
"the",
"given",
"remote",
"directory",
"."
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L35-L58 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/os_helpers.py | dir_ensure | def dir_ensure(location, recursive=False, mode=None,
owner=None, group=None, use_sudo=False):
""" cuisine dir_ensure doesn't do sudo, so we implement our own
Ensures that there is a remote directory at the given location,
optionally updating its mode/owner/group.
If we are not updating th... | python | def dir_ensure(location, recursive=False, mode=None,
owner=None, group=None, use_sudo=False):
""" cuisine dir_ensure doesn't do sudo, so we implement our own
Ensures that there is a remote directory at the given location,
optionally updating its mode/owner/group.
If we are not updating th... | [
"def",
"dir_ensure",
"(",
"location",
",",
"recursive",
"=",
"False",
",",
"mode",
"=",
"None",
",",
"owner",
"=",
"None",
",",
"group",
"=",
"None",
",",
"use_sudo",
"=",
"False",
")",
":",
"args",
"=",
"''",
"if",
"recursive",
":",
"args",
"=",
"... | cuisine dir_ensure doesn't do sudo, so we implement our own
Ensures that there is a remote directory at the given location,
optionally updating its mode/owner/group.
If we are not updating the owner/group then this can be done as a single
ssh call, so use that method, otherwise set owner/group after cre... | [
"cuisine",
"dir_ensure",
"doesn",
"t",
"do",
"sudo",
"so",
"we",
"implement",
"our",
"own",
"Ensures",
"that",
"there",
"is",
"a",
"remote",
"directory",
"at",
"the",
"given",
"location",
"optionally",
"updating",
"its",
"mode",
"/",
"owner",
"/",
"group",
... | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L61-L93 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/os_helpers.py | dir_exists | def dir_exists(location, use_sudo=False):
"""Tells if there is a remote directory at the given location."""
with settings(hide('running', 'stdout', 'stderr'), warn_only=True):
if use_sudo:
# convert return code 0 to True
return not bool(sudo('test -d %s' % (location)).return_code... | python | def dir_exists(location, use_sudo=False):
"""Tells if there is a remote directory at the given location."""
with settings(hide('running', 'stdout', 'stderr'), warn_only=True):
if use_sudo:
# convert return code 0 to True
return not bool(sudo('test -d %s' % (location)).return_code... | [
"def",
"dir_exists",
"(",
"location",
",",
"use_sudo",
"=",
"False",
")",
":",
"with",
"settings",
"(",
"hide",
"(",
"'running'",
",",
"'stdout'",
",",
"'stderr'",
")",
",",
"warn_only",
"=",
"True",
")",
":",
"if",
"use_sudo",
":",
"# convert return code ... | Tells if there is a remote directory at the given location. | [
"Tells",
"if",
"there",
"is",
"a",
"remote",
"directory",
"at",
"the",
"given",
"location",
"."
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L96-L103 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/os_helpers.py | disable_env_reset_on_sudo | def disable_env_reset_on_sudo(log=False):
""" updates /etc/sudoers so that users from %wheel keep their
environment when executing a sudo call
"""
if log:
bookshelf2.logging_helpers.log_green('disabling env reset on sudo')
file_append('/etc/sudoers',
'Defaults:%wheel !en... | python | def disable_env_reset_on_sudo(log=False):
""" updates /etc/sudoers so that users from %wheel keep their
environment when executing a sudo call
"""
if log:
bookshelf2.logging_helpers.log_green('disabling env reset on sudo')
file_append('/etc/sudoers',
'Defaults:%wheel !en... | [
"def",
"disable_env_reset_on_sudo",
"(",
"log",
"=",
"False",
")",
":",
"if",
"log",
":",
"bookshelf2",
".",
"logging_helpers",
".",
"log_green",
"(",
"'disabling env reset on sudo'",
")",
"file_append",
"(",
"'/etc/sudoers'",
",",
"'Defaults:%wheel !env_reset,!secure_p... | updates /etc/sudoers so that users from %wheel keep their
environment when executing a sudo call | [
"updates",
"/",
"etc",
"/",
"sudoers",
"so",
"that",
"users",
"from",
"%wheel",
"keep",
"their",
"environment",
"when",
"executing",
"a",
"sudo",
"call"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L106-L117 | train |
pyBookshelf/bookshelf | bookshelf/api_v2/os_helpers.py | disable_requiretty_on_sudoers | def disable_requiretty_on_sudoers(log=False):
""" allow sudo calls through ssh without a tty """
if log:
bookshelf2.logging_helpers.log_green(
'disabling requiretty on sudo calls')
comment_line('/etc/sudoers',
'^Defaults.*requiretty', use_sudo=True)
return True | python | def disable_requiretty_on_sudoers(log=False):
""" allow sudo calls through ssh without a tty """
if log:
bookshelf2.logging_helpers.log_green(
'disabling requiretty on sudo calls')
comment_line('/etc/sudoers',
'^Defaults.*requiretty', use_sudo=True)
return True | [
"def",
"disable_requiretty_on_sudoers",
"(",
"log",
"=",
"False",
")",
":",
"if",
"log",
":",
"bookshelf2",
".",
"logging_helpers",
".",
"log_green",
"(",
"'disabling requiretty on sudo calls'",
")",
"comment_line",
"(",
"'/etc/sudoers'",
",",
"'^Defaults.*requiretty'",... | allow sudo calls through ssh without a tty | [
"allow",
"sudo",
"calls",
"through",
"ssh",
"without",
"a",
"tty"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/os_helpers.py#L120-L128 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.