partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | BitReader.get_bits | Get an integer containing the next [count] bits from the source. | mrcrowbar/utils.py | def get_bits( self, count ):
"""Get an integer containing the next [count] bits from the source."""
result = 0
for i in range( count ):
if self.bits_remaining <= 0:
self._fill_buffer()
if self.bits_reverse:
bit = (1 if (self.current_bits & ... | def get_bits( self, count ):
"""Get an integer containing the next [count] bits from the source."""
result = 0
for i in range( count ):
if self.bits_remaining <= 0:
self._fill_buffer()
if self.bits_reverse:
bit = (1 if (self.current_bits & ... | [
"Get",
"an",
"integer",
"containing",
"the",
"next",
"[",
"count",
"]",
"bits",
"from",
"the",
"source",
"."
] | moralrecordings/mrcrowbar | python | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L545-L566 | [
"def",
"get_bits",
"(",
"self",
",",
"count",
")",
":",
"result",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"count",
")",
":",
"if",
"self",
".",
"bits_remaining",
"<=",
"0",
":",
"self",
".",
"_fill_buffer",
"(",
")",
"if",
"self",
".",
"bits_reve... | b1ed882c4555552e7656b2d84aca543184577fa3 |
train | BitWriter.put_bits | Push bits into the target.
value
Integer containing bits to push, ordered from least-significant bit to
most-significant bit.
count
Number of bits to push to the target. | mrcrowbar/utils.py | def put_bits( self, value, count ):
"""Push bits into the target.
value
Integer containing bits to push, ordered from least-significant bit to
most-significant bit.
count
Number of bits to push to the target.
"""
for _ in range( count ):
... | def put_bits( self, value, count ):
"""Push bits into the target.
value
Integer containing bits to push, ordered from least-significant bit to
most-significant bit.
count
Number of bits to push to the target.
"""
for _ in range( count ):
... | [
"Push",
"bits",
"into",
"the",
"target",
"."
] | moralrecordings/mrcrowbar | python | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L592-L627 | [
"def",
"put_bits",
"(",
"self",
",",
"value",
",",
"count",
")",
":",
"for",
"_",
"in",
"range",
"(",
"count",
")",
":",
"# bits are retrieved from the source LSB first",
"bit",
"=",
"(",
"value",
"&",
"1",
")",
"value",
">>=",
"1",
"# however, bits are put ... | b1ed882c4555552e7656b2d84aca543184577fa3 |
train | BitWriter.get_buffer | Return a byte string containing the target as currently written. | mrcrowbar/utils.py | def get_buffer( self ):
"""Return a byte string containing the target as currently written."""
last_byte = self.current_bits if (self.bits_remaining < 8) else None
result = self.output
if last_byte is not None:
result = bytearray( result )
result.append( last_byt... | def get_buffer( self ):
"""Return a byte string containing the target as currently written."""
last_byte = self.current_bits if (self.bits_remaining < 8) else None
result = self.output
if last_byte is not None:
result = bytearray( result )
result.append( last_byt... | [
"Return",
"a",
"byte",
"string",
"containing",
"the",
"target",
"as",
"currently",
"written",
"."
] | moralrecordings/mrcrowbar | python | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/utils.py#L629-L641 | [
"def",
"get_buffer",
"(",
"self",
")",
":",
"last_byte",
"=",
"self",
".",
"current_bits",
"if",
"(",
"self",
".",
"bits_remaining",
"<",
"8",
")",
"else",
"None",
"result",
"=",
"self",
".",
"output",
"if",
"last_byte",
"is",
"not",
"None",
":",
"resu... | b1ed882c4555552e7656b2d84aca543184577fa3 |
train | BaseManager.get_for_update | http://docs.sqlalchemy.org/en/latest/orm/query.html?highlight=update#sqlalchemy.orm.query.Query.with_for_update # noqa | flask_philo_sqlalchemy/orm.py | def get_for_update(self, connection_name='DEFAULT', **kwargs):
"""
http://docs.sqlalchemy.org/en/latest/orm/query.html?highlight=update#sqlalchemy.orm.query.Query.with_for_update # noqa
"""
if not kwargs:
raise InvalidQueryError(
"Can not execute a query wit... | def get_for_update(self, connection_name='DEFAULT', **kwargs):
"""
http://docs.sqlalchemy.org/en/latest/orm/query.html?highlight=update#sqlalchemy.orm.query.Query.with_for_update # noqa
"""
if not kwargs:
raise InvalidQueryError(
"Can not execute a query wit... | [
"http",
":",
"//",
"docs",
".",
"sqlalchemy",
".",
"org",
"/",
"en",
"/",
"latest",
"/",
"orm",
"/",
"query",
".",
"html?highlight",
"=",
"update#sqlalchemy",
".",
"orm",
".",
"query",
".",
"Query",
".",
"with_for_update",
"#",
"noqa"
] | Riffstation/Flask-Philo-SQLAlchemy | python | https://github.com/Riffstation/Flask-Philo-SQLAlchemy/blob/71598bb603b8458a2cf9f7989f71d8f1c77fafb9/flask_philo_sqlalchemy/orm.py#L35-L49 | [
"def",
"get_for_update",
"(",
"self",
",",
"connection_name",
"=",
"'DEFAULT'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"kwargs",
":",
"raise",
"InvalidQueryError",
"(",
"\"Can not execute a query without parameters\"",
")",
"obj",
"=",
"self",
".",
"poo... | 71598bb603b8458a2cf9f7989f71d8f1c77fafb9 |
train | syllabify | Syllabify the given word, whether simplex or complex. | finnsyll/prev/v07.py | def syllabify(word, compound=None):
'''Syllabify the given word, whether simplex or complex.'''
if compound is None:
compound = bool(re.search(r'(-| |=)', word))
syllabify = _syllabify_compound if compound else _syllabify
syll, rules = syllabify(word)
yield syll, rules
n = 7
if '... | def syllabify(word, compound=None):
'''Syllabify the given word, whether simplex or complex.'''
if compound is None:
compound = bool(re.search(r'(-| |=)', word))
syllabify = _syllabify_compound if compound else _syllabify
syll, rules = syllabify(word)
yield syll, rules
n = 7
if '... | [
"Syllabify",
"the",
"given",
"word",
"whether",
"simplex",
"or",
"complex",
"."
] | tsnaomi/finnsyll | python | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v07.py#L17-L43 | [
"def",
"syllabify",
"(",
"word",
",",
"compound",
"=",
"None",
")",
":",
"if",
"compound",
"is",
"None",
":",
"compound",
"=",
"bool",
"(",
"re",
".",
"search",
"(",
"r'(-| |=)'",
",",
"word",
")",
")",
"syllabify",
"=",
"_syllabify_compound",
"if",
"c... | 6a42740311688c946a636a3e2304866c7aa041b3 |
train | ModelCompiler.convert_case | Converts name from CamelCase to snake_case | algen/compilers.py | def convert_case(name):
"""Converts name from CamelCase to snake_case"""
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | def convert_case(name):
"""Converts name from CamelCase to snake_case"""
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | [
"Converts",
"name",
"from",
"CamelCase",
"to",
"snake_case"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L35-L38 | [
"def",
"convert_case",
"(",
"name",
")",
":",
"s1",
"=",
"re",
".",
"sub",
"(",
"'(.)([A-Z][a-z]+)'",
",",
"r'\\1_\\2'",
",",
"name",
")",
"return",
"re",
".",
"sub",
"(",
"'([a-z0-9])([A-Z])'",
",",
"r'\\1_\\2'",
",",
"s1",
")",
".",
"lower",
"(",
")"... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.table_name | Pluralises the class_name using utterly simple algo and returns as table_name | algen/compilers.py | def table_name(self):
"""Pluralises the class_name using utterly simple algo and returns as table_name"""
if not self.class_name:
raise ValueError
else:
tbl_name = ModelCompiler.convert_case(self.class_name)
last_letter = tbl_name[-1]
if last_letter in ("y... | def table_name(self):
"""Pluralises the class_name using utterly simple algo and returns as table_name"""
if not self.class_name:
raise ValueError
else:
tbl_name = ModelCompiler.convert_case(self.class_name)
last_letter = tbl_name[-1]
if last_letter in ("y... | [
"Pluralises",
"the",
"class_name",
"using",
"utterly",
"simple",
"algo",
"and",
"returns",
"as",
"table_name"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L41-L53 | [
"def",
"table_name",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"class_name",
":",
"raise",
"ValueError",
"else",
":",
"tbl_name",
"=",
"ModelCompiler",
".",
"convert_case",
"(",
"self",
".",
"class_name",
")",
"last_letter",
"=",
"tbl_name",
"[",
"-... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.types | All the unique types found in user supplied model | algen/compilers.py | def types(self):
"""All the unique types found in user supplied model"""
res = []
for column in self.column_definitions:
tmp = column.get('type', None)
res.append(ModelCompiler.get_column_type(tmp)) if tmp else False
res = list(set(res))
return res | def types(self):
"""All the unique types found in user supplied model"""
res = []
for column in self.column_definitions:
tmp = column.get('type', None)
res.append(ModelCompiler.get_column_type(tmp)) if tmp else False
res = list(set(res))
return res | [
"All",
"the",
"unique",
"types",
"found",
"in",
"user",
"supplied",
"model"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L71-L78 | [
"def",
"types",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"for",
"column",
"in",
"self",
".",
"column_definitions",
":",
"tmp",
"=",
"column",
".",
"get",
"(",
"'type'",
",",
"None",
")",
"res",
".",
"append",
"(",
"ModelCompiler",
".",
"get_colum... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.basic_types | Returns non-postgres types referenced in user supplied model | algen/compilers.py | def basic_types(self):
"""Returns non-postgres types referenced in user supplied model """
if not self.foreign_key_definitions:
return self.standard_types
else:
tmp = self.standard_types
tmp.append('ForeignKey')
return tmp | def basic_types(self):
"""Returns non-postgres types referenced in user supplied model """
if not self.foreign_key_definitions:
return self.standard_types
else:
tmp = self.standard_types
tmp.append('ForeignKey')
return tmp | [
"Returns",
"non",
"-",
"postgres",
"types",
"referenced",
"in",
"user",
"supplied",
"model"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L91-L98 | [
"def",
"basic_types",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"foreign_key_definitions",
":",
"return",
"self",
".",
"standard_types",
"else",
":",
"tmp",
"=",
"self",
".",
"standard_types",
"tmp",
".",
"append",
"(",
"'ForeignKey'",
")",
"return",
... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.primary_keys | Returns the primary keys referenced in user supplied model | algen/compilers.py | def primary_keys(self):
"""Returns the primary keys referenced in user supplied model"""
res = []
for column in self.column_definitions:
if 'primary_key' in column.keys():
tmp = column.get('primary_key', None)
res.append(column['name']) if tmp else Fal... | def primary_keys(self):
"""Returns the primary keys referenced in user supplied model"""
res = []
for column in self.column_definitions:
if 'primary_key' in column.keys():
tmp = column.get('primary_key', None)
res.append(column['name']) if tmp else Fal... | [
"Returns",
"the",
"primary",
"keys",
"referenced",
"in",
"user",
"supplied",
"model"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L105-L112 | [
"def",
"primary_keys",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"for",
"column",
"in",
"self",
".",
"column_definitions",
":",
"if",
"'primary_key'",
"in",
"column",
".",
"keys",
"(",
")",
":",
"tmp",
"=",
"column",
".",
"get",
"(",
"'primary_key'"... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.compiled_named_imports | Returns compiled named imports required for the model | algen/compilers.py | def compiled_named_imports(self):
"""Returns compiled named imports required for the model"""
res = []
if self.postgres_types:
res.append(
ALCHEMY_TEMPLATES.named_import.safe_substitute(
module='sqlalchemy.dialects.postgresql',
... | def compiled_named_imports(self):
"""Returns compiled named imports required for the model"""
res = []
if self.postgres_types:
res.append(
ALCHEMY_TEMPLATES.named_import.safe_substitute(
module='sqlalchemy.dialects.postgresql',
... | [
"Returns",
"compiled",
"named",
"imports",
"required",
"for",
"the",
"model"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L115-L128 | [
"def",
"compiled_named_imports",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"if",
"self",
".",
"postgres_types",
":",
"res",
".",
"append",
"(",
"ALCHEMY_TEMPLATES",
".",
"named_import",
".",
"safe_substitute",
"(",
"module",
"=",
"'sqlalchemy.dialects.postgre... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.compiled_orm_imports | Returns compiled named imports required for the model | algen/compilers.py | def compiled_orm_imports(self):
"""Returns compiled named imports required for the model"""
module = 'sqlalchemy.orm'
labels = []
if self.relationship_definitions:
labels.append("relationship")
return ALCHEMY_TEMPLATES.named_import.safe_substitute(module=module, label... | def compiled_orm_imports(self):
"""Returns compiled named imports required for the model"""
module = 'sqlalchemy.orm'
labels = []
if self.relationship_definitions:
labels.append("relationship")
return ALCHEMY_TEMPLATES.named_import.safe_substitute(module=module, label... | [
"Returns",
"compiled",
"named",
"imports",
"required",
"for",
"the",
"model"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L131-L137 | [
"def",
"compiled_orm_imports",
"(",
"self",
")",
":",
"module",
"=",
"'sqlalchemy.orm'",
"labels",
"=",
"[",
"]",
"if",
"self",
".",
"relationship_definitions",
":",
"labels",
".",
"append",
"(",
"\"relationship\"",
")",
"return",
"ALCHEMY_TEMPLATES",
".",
"name... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.compiled_columns | Returns compiled column definitions | algen/compilers.py | def compiled_columns(self):
"""Returns compiled column definitions"""
def get_column_args(column):
tmp = []
for arg_name, arg_val in column.items():
if arg_name not in ('name', 'type'):
if arg_name in ('server_default', 'server_onupdate'):
... | def compiled_columns(self):
"""Returns compiled column definitions"""
def get_column_args(column):
tmp = []
for arg_name, arg_val in column.items():
if arg_name not in ('name', 'type'):
if arg_name in ('server_default', 'server_onupdate'):
... | [
"Returns",
"compiled",
"column",
"definitions"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L140-L168 | [
"def",
"compiled_columns",
"(",
"self",
")",
":",
"def",
"get_column_args",
"(",
"column",
")",
":",
"tmp",
"=",
"[",
"]",
"for",
"arg_name",
",",
"arg_val",
"in",
"column",
".",
"items",
"(",
")",
":",
"if",
"arg_name",
"not",
"in",
"(",
"'name'",
"... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.compiled_foreign_keys | Returns compiled foreign key definitions | algen/compilers.py | def compiled_foreign_keys(self):
"""Returns compiled foreign key definitions"""
def get_column_args(column):
tmp = []
for arg_name, arg_val in column.items():
if arg_name not in ('name', 'type', 'reference'):
if arg_name in ('server_default', ... | def compiled_foreign_keys(self):
"""Returns compiled foreign key definitions"""
def get_column_args(column):
tmp = []
for arg_name, arg_val in column.items():
if arg_name not in ('name', 'type', 'reference'):
if arg_name in ('server_default', ... | [
"Returns",
"compiled",
"foreign",
"key",
"definitions"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L171-L206 | [
"def",
"compiled_foreign_keys",
"(",
"self",
")",
":",
"def",
"get_column_args",
"(",
"column",
")",
":",
"tmp",
"=",
"[",
"]",
"for",
"arg_name",
",",
"arg_val",
"in",
"column",
".",
"items",
"(",
")",
":",
"if",
"arg_name",
"not",
"in",
"(",
"'name'"... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.compiled_relationships | Returns compiled relationship definitions | algen/compilers.py | def compiled_relationships(self):
"""Returns compiled relationship definitions"""
def get_column_args(column):
tmp = []
for arg_name, arg_val in column.items():
if arg_name not in ('name', 'type', 'reference', 'class'):
if arg_name in ('back_p... | def compiled_relationships(self):
"""Returns compiled relationship definitions"""
def get_column_args(column):
tmp = []
for arg_name, arg_val in column.items():
if arg_name not in ('name', 'type', 'reference', 'class'):
if arg_name in ('back_p... | [
"Returns",
"compiled",
"relationship",
"definitions"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L209-L232 | [
"def",
"compiled_relationships",
"(",
"self",
")",
":",
"def",
"get_column_args",
"(",
"column",
")",
":",
"tmp",
"=",
"[",
"]",
"for",
"arg_name",
",",
"arg_val",
"in",
"column",
".",
"items",
"(",
")",
":",
"if",
"arg_name",
"not",
"in",
"(",
"'name'... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.columns | Return names of all the addressable columns (including foreign keys) referenced in user supplied model | algen/compilers.py | def columns(self):
"""Return names of all the addressable columns (including foreign keys) referenced in user supplied model"""
res = [col['name'] for col in self.column_definitions]
res.extend([col['name'] for col in self.foreign_key_definitions])
return res | def columns(self):
"""Return names of all the addressable columns (including foreign keys) referenced in user supplied model"""
res = [col['name'] for col in self.column_definitions]
res.extend([col['name'] for col in self.foreign_key_definitions])
return res | [
"Return",
"names",
"of",
"all",
"the",
"addressable",
"columns",
"(",
"including",
"foreign",
"keys",
")",
"referenced",
"in",
"user",
"supplied",
"model"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L235-L239 | [
"def",
"columns",
"(",
"self",
")",
":",
"res",
"=",
"[",
"col",
"[",
"'name'",
"]",
"for",
"col",
"in",
"self",
".",
"column_definitions",
"]",
"res",
".",
"extend",
"(",
"[",
"col",
"[",
"'name'",
"]",
"for",
"col",
"in",
"self",
".",
"foreign_ke... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.compiled_init_func | Returns compiled init function | algen/compilers.py | def compiled_init_func(self):
"""Returns compiled init function"""
def get_column_assignment(column_name):
return ALCHEMY_TEMPLATES.col_assignment.safe_substitute(col_name=column_name)
def get_compiled_args(arg_name):
return ALCHEMY_TEMPLATES.func_arg.safe_substitute(ar... | def compiled_init_func(self):
"""Returns compiled init function"""
def get_column_assignment(column_name):
return ALCHEMY_TEMPLATES.col_assignment.safe_substitute(col_name=column_name)
def get_compiled_args(arg_name):
return ALCHEMY_TEMPLATES.func_arg.safe_substitute(ar... | [
"Returns",
"compiled",
"init",
"function"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L242-L255 | [
"def",
"compiled_init_func",
"(",
"self",
")",
":",
"def",
"get_column_assignment",
"(",
"column_name",
")",
":",
"return",
"ALCHEMY_TEMPLATES",
".",
"col_assignment",
".",
"safe_substitute",
"(",
"col_name",
"=",
"column_name",
")",
"def",
"get_compiled_args",
"(",... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.compiled_update_func | Returns compiled update function | algen/compilers.py | def compiled_update_func(self):
"""Returns compiled update function"""
def get_not_none_col_assignment(column_name):
return ALCHEMY_TEMPLATES.not_none_col_assignment.safe_substitute(col_name=column_name)
def get_compiled_args(arg_name):
return ALCHEMY_TEMPLATES.func_arg... | def compiled_update_func(self):
"""Returns compiled update function"""
def get_not_none_col_assignment(column_name):
return ALCHEMY_TEMPLATES.not_none_col_assignment.safe_substitute(col_name=column_name)
def get_compiled_args(arg_name):
return ALCHEMY_TEMPLATES.func_arg... | [
"Returns",
"compiled",
"update",
"function"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L258-L273 | [
"def",
"compiled_update_func",
"(",
"self",
")",
":",
"def",
"get_not_none_col_assignment",
"(",
"column_name",
")",
":",
"return",
"ALCHEMY_TEMPLATES",
".",
"not_none_col_assignment",
".",
"safe_substitute",
"(",
"col_name",
"=",
"column_name",
")",
"def",
"get_compi... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.compiled_hash_func | Returns compiled hash function based on hash of stringified primary_keys.
This isn't the most efficient way | algen/compilers.py | def compiled_hash_func(self):
"""Returns compiled hash function based on hash of stringified primary_keys.
This isn't the most efficient way"""
def get_primary_key_str(pkey_name):
return "str(self.{})".format(pkey_name)
hash_str = "+ ".join([get_primary_key_str(n) for n in ... | def compiled_hash_func(self):
"""Returns compiled hash function based on hash of stringified primary_keys.
This isn't the most efficient way"""
def get_primary_key_str(pkey_name):
return "str(self.{})".format(pkey_name)
hash_str = "+ ".join([get_primary_key_str(n) for n in ... | [
"Returns",
"compiled",
"hash",
"function",
"based",
"on",
"hash",
"of",
"stringified",
"primary_keys",
".",
"This",
"isn",
"t",
"the",
"most",
"efficient",
"way"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L276-L284 | [
"def",
"compiled_hash_func",
"(",
"self",
")",
":",
"def",
"get_primary_key_str",
"(",
"pkey_name",
")",
":",
"return",
"\"str(self.{})\"",
".",
"format",
"(",
"pkey_name",
")",
"hash_str",
"=",
"\"+ \"",
".",
"join",
"(",
"[",
"get_primary_key_str",
"(",
"n",... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.representation_function_compiler | Generic function can be used to compile __repr__ or __unicode__ or __str__ | algen/compilers.py | def representation_function_compiler(self, func_name):
"""Generic function can be used to compile __repr__ or __unicode__ or __str__"""
def get_col_accessor(col):
return ALCHEMY_TEMPLATES.col_accessor.safe_substitute(col=col)
def get_col_evaluator(col):
return ALCHEMY_T... | def representation_function_compiler(self, func_name):
"""Generic function can be used to compile __repr__ or __unicode__ or __str__"""
def get_col_accessor(col):
return ALCHEMY_TEMPLATES.col_accessor.safe_substitute(col=col)
def get_col_evaluator(col):
return ALCHEMY_T... | [
"Generic",
"function",
"can",
"be",
"used",
"to",
"compile",
"__repr__",
"or",
"__unicode__",
"or",
"__str__"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L308-L323 | [
"def",
"representation_function_compiler",
"(",
"self",
",",
"func_name",
")",
":",
"def",
"get_col_accessor",
"(",
"col",
")",
":",
"return",
"ALCHEMY_TEMPLATES",
".",
"col_accessor",
".",
"safe_substitute",
"(",
"col",
"=",
"col",
")",
"def",
"get_col_evaluator"... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | ModelCompiler.compiled_model | Returns compile ORM class for the user supplied model | algen/compilers.py | def compiled_model(self):
"""Returns compile ORM class for the user supplied model"""
return ALCHEMY_TEMPLATES.model.safe_substitute(class_name=self.class_name,
table_name=self.table_name,
colum... | def compiled_model(self):
"""Returns compile ORM class for the user supplied model"""
return ALCHEMY_TEMPLATES.model.safe_substitute(class_name=self.class_name,
table_name=self.table_name,
colum... | [
"Returns",
"compile",
"ORM",
"class",
"for",
"the",
"user",
"supplied",
"model"
] | danishabdullah/algen | python | https://github.com/danishabdullah/algen/blob/642ba26d8721c588fce505ac67528070c1edc264/algen/compilers.py#L346-L370 | [
"def",
"compiled_model",
"(",
"self",
")",
":",
"return",
"ALCHEMY_TEMPLATES",
".",
"model",
".",
"safe_substitute",
"(",
"class_name",
"=",
"self",
".",
"class_name",
",",
"table_name",
"=",
"self",
".",
"table_name",
",",
"column_definitions",
"=",
"self",
"... | 642ba26d8721c588fce505ac67528070c1edc264 |
train | TaskQueue.put | Updates this task queue on the saltant server.
Returns:
:class:`saltant.models.task_queue.TaskQueue`:
A task queue model instance representing the task queue
just updated. | saltant/models/task_queue.py | def put(self):
"""Updates this task queue on the saltant server.
Returns:
:class:`saltant.models.task_queue.TaskQueue`:
A task queue model instance representing the task queue
just updated.
"""
return self.manager.put(
id=self.id,
... | def put(self):
"""Updates this task queue on the saltant server.
Returns:
:class:`saltant.models.task_queue.TaskQueue`:
A task queue model instance representing the task queue
just updated.
"""
return self.manager.put(
id=self.id,
... | [
"Updates",
"this",
"task",
"queue",
"on",
"the",
"saltant",
"server",
"."
] | saltant-org/saltant-py | python | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/task_queue.py#L119-L137 | [
"def",
"put",
"(",
"self",
")",
":",
"return",
"self",
".",
"manager",
".",
"put",
"(",
"id",
"=",
"self",
".",
"id",
",",
"name",
"=",
"self",
".",
"name",
",",
"description",
"=",
"self",
".",
"description",
",",
"private",
"=",
"self",
".",
"p... | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be |
train | TaskQueueManager.get | Get a task queue.
Either the id xor the name of the task type must be specified.
Args:
id (int, optional): The id of the task type to get.
name (str, optional): The name of the task type to get.
Returns:
:class:`saltant.models.task_queue.TaskQueue`:
... | saltant/models/task_queue.py | def get(self, id=None, name=None):
"""Get a task queue.
Either the id xor the name of the task type must be specified.
Args:
id (int, optional): The id of the task type to get.
name (str, optional): The name of the task type to get.
Returns:
:class:... | def get(self, id=None, name=None):
"""Get a task queue.
Either the id xor the name of the task type must be specified.
Args:
id (int, optional): The id of the task type to get.
name (str, optional): The name of the task type to get.
Returns:
:class:... | [
"Get",
"a",
"task",
"queue",
"."
] | saltant-org/saltant-py | python | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/task_queue.py#L156-L183 | [
"def",
"get",
"(",
"self",
",",
"id",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"# Validate arguments - use an xor",
"if",
"not",
"(",
"id",
"is",
"None",
")",
"^",
"(",
"name",
"is",
"None",
")",
":",
"raise",
"ValueError",
"(",
"\"Either id or... | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be |
train | TaskQueueManager.create | Create a task queue.
Args:
name (str): The name of the task queue.
description (str, optional): A description of the task queue.
private (bool, optional): A boolean specifying whether the
queue is exclusive to its creator. Defaults to False.
runs_... | saltant/models/task_queue.py | def create(
self,
name,
description="",
private=False,
runs_executable_tasks=True,
runs_docker_container_tasks=True,
runs_singularity_container_tasks=True,
active=True,
whitelists=None,
):
"""Create a task queue.
Args:
... | def create(
self,
name,
description="",
private=False,
runs_executable_tasks=True,
runs_docker_container_tasks=True,
runs_singularity_container_tasks=True,
active=True,
whitelists=None,
):
"""Create a task queue.
Args:
... | [
"Create",
"a",
"task",
"queue",
"."
] | saltant-org/saltant-py | python | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/task_queue.py#L185-L250 | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"description",
"=",
"\"\"",
",",
"private",
"=",
"False",
",",
"runs_executable_tasks",
"=",
"True",
",",
"runs_docker_container_tasks",
"=",
"True",
",",
"runs_singularity_container_tasks",
"=",
"True",
",",
"acti... | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be |
train | TaskQueueManager.patch | Partially updates a task queue on the saltant server.
Args:
id (int): The ID of the task queue.
name (str, optional): The name of the task queue.
description (str, optional): The description of the task
queue.
private (bool, optional): A Booleon s... | saltant/models/task_queue.py | def patch(
self,
id,
name=None,
description=None,
private=None,
runs_executable_tasks=None,
runs_docker_container_tasks=None,
runs_singularity_container_tasks=None,
active=None,
whitelists=None,
):
"""Partially updates a task qu... | def patch(
self,
id,
name=None,
description=None,
private=None,
runs_executable_tasks=None,
runs_docker_container_tasks=None,
runs_singularity_container_tasks=None,
active=None,
whitelists=None,
):
"""Partially updates a task qu... | [
"Partially",
"updates",
"a",
"task",
"queue",
"on",
"the",
"saltant",
"server",
"."
] | saltant-org/saltant-py | python | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/task_queue.py#L252-L334 | [
"def",
"patch",
"(",
"self",
",",
"id",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"private",
"=",
"None",
",",
"runs_executable_tasks",
"=",
"None",
",",
"runs_docker_container_tasks",
"=",
"None",
",",
"runs_singularity_container_tasks",
... | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be |
train | TaskQueueManager.put | Updates a task queue on the saltant server.
Args:
id (int): The ID of the task queue.
name (str): The name of the task queue.
description (str): The description of the task queue.
private (bool): A Booleon signalling whether the queue can
only be ... | saltant/models/task_queue.py | def put(
self,
id,
name,
description,
private,
runs_executable_tasks,
runs_docker_container_tasks,
runs_singularity_container_tasks,
active,
whitelists,
):
"""Updates a task queue on the saltant server.
Args:
... | def put(
self,
id,
name,
description,
private,
runs_executable_tasks,
runs_docker_container_tasks,
runs_singularity_container_tasks,
active,
whitelists,
):
"""Updates a task queue on the saltant server.
Args:
... | [
"Updates",
"a",
"task",
"queue",
"on",
"the",
"saltant",
"server",
"."
] | saltant-org/saltant-py | python | https://github.com/saltant-org/saltant-py/blob/bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be/saltant/models/task_queue.py#L336-L397 | [
"def",
"put",
"(",
"self",
",",
"id",
",",
"name",
",",
"description",
",",
"private",
",",
"runs_executable_tasks",
",",
"runs_docker_container_tasks",
",",
"runs_singularity_container_tasks",
",",
"active",
",",
"whitelists",
",",
")",
":",
"# Update the object",
... | bf3bdbc4ec9c772c7f621f8bd6a76c5932af68be |
train | SixteenSBait.main | Run the required methods in the appropriate order | sixteenS/sixteens_full.py | def main(self):
"""
Run the required methods in the appropriate order
"""
self.targets()
self.bait(k=49)
self.reversebait(maskmiddle='t', k=19)
self.subsample_reads() | def main(self):
"""
Run the required methods in the appropriate order
"""
self.targets()
self.bait(k=49)
self.reversebait(maskmiddle='t', k=19)
self.subsample_reads() | [
"Run",
"the",
"required",
"methods",
"in",
"the",
"appropriate",
"order"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L31-L38 | [
"def",
"main",
"(",
"self",
")",
":",
"self",
".",
"targets",
"(",
")",
"self",
".",
"bait",
"(",
"k",
"=",
"49",
")",
"self",
".",
"reversebait",
"(",
"maskmiddle",
"=",
"'t'",
",",
"k",
"=",
"19",
")",
"self",
".",
"subsample_reads",
"(",
")"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | SixteenSBait.targets | Create the GenObject for the analysis type, create the hash file for baiting (if necessary) | sixteenS/sixteens_full.py | def targets(self):
"""
Create the GenObject for the analysis type, create the hash file for baiting (if necessary)
"""
for sample in self.runmetadata:
if sample.general.bestassemblyfile != 'NA':
setattr(sample, self.analysistype, GenObject())
s... | def targets(self):
"""
Create the GenObject for the analysis type, create the hash file for baiting (if necessary)
"""
for sample in self.runmetadata:
if sample.general.bestassemblyfile != 'NA':
setattr(sample, self.analysistype, GenObject())
s... | [
"Create",
"the",
"GenObject",
"for",
"the",
"analysis",
"type",
"create",
"the",
"hash",
"file",
"for",
"baiting",
"(",
"if",
"necessary",
")"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L40-L61 | [
"def",
"targets",
"(",
"self",
")",
":",
"for",
"sample",
"in",
"self",
".",
"runmetadata",
":",
"if",
"sample",
".",
"general",
".",
"bestassemblyfile",
"!=",
"'NA'",
":",
"setattr",
"(",
"sample",
",",
"self",
".",
"analysistype",
",",
"GenObject",
"("... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | SixteenSSipper.targets | Using the data from the BLAST analyses, set the targets folder, and create the 'mapping file'. This is the
genera-specific FASTA file that will be used for all the reference mapping; it replaces the 'bait file' in the
code | sixteenS/sixteens_full.py | def targets(self):
"""
Using the data from the BLAST analyses, set the targets folder, and create the 'mapping file'. This is the
genera-specific FASTA file that will be used for all the reference mapping; it replaces the 'bait file' in the
code
"""
logging.info('Performi... | def targets(self):
"""
Using the data from the BLAST analyses, set the targets folder, and create the 'mapping file'. This is the
genera-specific FASTA file that will be used for all the reference mapping; it replaces the 'bait file' in the
code
"""
logging.info('Performi... | [
"Using",
"the",
"data",
"from",
"the",
"BLAST",
"analyses",
"set",
"the",
"targets",
"folder",
"and",
"create",
"the",
"mapping",
"file",
".",
"This",
"is",
"the",
"genera",
"-",
"specific",
"FASTA",
"file",
"that",
"will",
"be",
"used",
"for",
"all",
"t... | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L82-L106 | [
"def",
"targets",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Performing analysis with {} targets folder'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
")",
"for",
"sample",
"in",
"self",
".",
"runmetadata",
":",
"if",
"sample",
".",
"gen... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | SixteenS.runner | Run the necessary methods in the correct order | sixteenS/sixteens_full.py | def runner(self):
"""
Run the necessary methods in the correct order
"""
logging.info('Starting {} analysis pipeline'.format(self.analysistype))
if not self.pipeline:
# If the metadata has been passed from the method script, self.pipeline must still be false in order ... | def runner(self):
"""
Run the necessary methods in the correct order
"""
logging.info('Starting {} analysis pipeline'.format(self.analysistype))
if not self.pipeline:
# If the metadata has been passed from the method script, self.pipeline must still be false in order ... | [
"Run",
"the",
"necessary",
"methods",
"in",
"the",
"correct",
"order"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L111-L151 | [
"def",
"runner",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Starting {} analysis pipeline'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
")",
"if",
"not",
"self",
".",
"pipeline",
":",
"# If the metadata has been passed from the method script, s... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | SixteenS.subsample | Subsample 1000 reads from the baited files | sixteenS/sixteens_full.py | def subsample(self):
"""
Subsample 1000 reads from the baited files
"""
# Create the threads for the analysis
logging.info('Subsampling FASTQ reads')
for _ in range(self.cpus):
threads = Thread(target=self.subsamplethreads, args=())
threads.setDaem... | def subsample(self):
"""
Subsample 1000 reads from the baited files
"""
# Create the threads for the analysis
logging.info('Subsampling FASTQ reads')
for _ in range(self.cpus):
threads = Thread(target=self.subsamplethreads, args=())
threads.setDaem... | [
"Subsample",
"1000",
"reads",
"from",
"the",
"baited",
"files"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L153-L175 | [
"def",
"subsample",
"(",
"self",
")",
":",
"# Create the threads for the analysis",
"logging",
".",
"info",
"(",
"'Subsampling FASTQ reads'",
")",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"cpus",
")",
":",
"threads",
"=",
"Thread",
"(",
"target",
"=",
"s... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | SixteenS.fasta | Convert the subsampled reads to FASTA format using reformat.sh | sixteenS/sixteens_full.py | def fasta(self):
"""
Convert the subsampled reads to FASTA format using reformat.sh
"""
logging.info('Converting FASTQ files to FASTA format')
# Create the threads for the analysis
for _ in range(self.cpus):
threads = Thread(target=self.fastathreads, args=())
... | def fasta(self):
"""
Convert the subsampled reads to FASTA format using reformat.sh
"""
logging.info('Converting FASTQ files to FASTA format')
# Create the threads for the analysis
for _ in range(self.cpus):
threads = Thread(target=self.fastathreads, args=())
... | [
"Convert",
"the",
"subsampled",
"reads",
"to",
"FASTA",
"format",
"using",
"reformat",
".",
"sh"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L194-L216 | [
"def",
"fasta",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Converting FASTQ files to FASTA format'",
")",
"# Create the threads for the analysis",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"cpus",
")",
":",
"threads",
"=",
"Thread",
"(",
"target",
... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | SixteenS.makeblastdb | Makes blast database files from targets as necessary | sixteenS/sixteens_full.py | def makeblastdb(self):
"""
Makes blast database files from targets as necessary
"""
# Iterate through the samples to set the bait file.
for sample in self.runmetadata.samples:
if sample.general.bestassemblyfile != 'NA':
# Remove the file extension
... | def makeblastdb(self):
"""
Makes blast database files from targets as necessary
"""
# Iterate through the samples to set the bait file.
for sample in self.runmetadata.samples:
if sample.general.bestassemblyfile != 'NA':
# Remove the file extension
... | [
"Makes",
"blast",
"database",
"files",
"from",
"targets",
"as",
"necessary"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L235-L259 | [
"def",
"makeblastdb",
"(",
"self",
")",
":",
"# Iterate through the samples to set the bait file.",
"for",
"sample",
"in",
"self",
".",
"runmetadata",
".",
"samples",
":",
"if",
"sample",
".",
"general",
".",
"bestassemblyfile",
"!=",
"'NA'",
":",
"# Remove the file... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | SixteenS.blast | Run BLAST analyses of the subsampled FASTQ reads against the NCBI 16S reference database | sixteenS/sixteens_full.py | def blast(self):
"""
Run BLAST analyses of the subsampled FASTQ reads against the NCBI 16S reference database
"""
logging.info('BLASTing FASTA files against {} database'.format(self.analysistype))
for _ in range(self.cpus):
threads = Thread(target=self.blastthreads, a... | def blast(self):
"""
Run BLAST analyses of the subsampled FASTQ reads against the NCBI 16S reference database
"""
logging.info('BLASTing FASTA files against {} database'.format(self.analysistype))
for _ in range(self.cpus):
threads = Thread(target=self.blastthreads, a... | [
"Run",
"BLAST",
"analyses",
"of",
"the",
"subsampled",
"FASTQ",
"reads",
"against",
"the",
"NCBI",
"16S",
"reference",
"database"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L261-L289 | [
"def",
"blast",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'BLASTing FASTA files against {} database'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
")",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"cpus",
")",
":",
"threads",
"=",
"T... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | SixteenS.blastparse | Parse the blast results, and store necessary data in dictionaries in sample object | sixteenS/sixteens_full.py | def blastparse(self):
"""
Parse the blast results, and store necessary data in dictionaries in sample object
"""
logging.info('Parsing BLAST results')
# Load the NCBI 16S reference database as a dictionary
for sample in self.runmetadata.samples:
if sample.gene... | def blastparse(self):
"""
Parse the blast results, and store necessary data in dictionaries in sample object
"""
logging.info('Parsing BLAST results')
# Load the NCBI 16S reference database as a dictionary
for sample in self.runmetadata.samples:
if sample.gene... | [
"Parse",
"the",
"blast",
"results",
"and",
"store",
"necessary",
"data",
"in",
"dictionaries",
"in",
"sample",
"object"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L304-L361 | [
"def",
"blastparse",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Parsing BLAST results'",
")",
"# Load the NCBI 16S reference database as a dictionary",
"for",
"sample",
"in",
"self",
".",
"runmetadata",
".",
"samples",
":",
"if",
"sample",
".",
"general",... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | SixteenS.reporter | Creates a report of the results | sixteenS/sixteens_full.py | def reporter(self):
"""
Creates a report of the results
"""
# Create the path in which the reports are stored
make_path(self.reportpath)
logging.info('Creating {} report'.format(self.analysistype))
# Initialise the header and data strings
header = 'Strain,... | def reporter(self):
"""
Creates a report of the results
"""
# Create the path in which the reports are stored
make_path(self.reportpath)
logging.info('Creating {} report'.format(self.analysistype))
# Initialise the header and data strings
header = 'Strain,... | [
"Creates",
"a",
"report",
"of",
"the",
"results"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteens_full.py#L364-L413 | [
"def",
"reporter",
"(",
"self",
")",
":",
"# Create the path in which the reports are stored",
"make_path",
"(",
"self",
".",
"reportpath",
")",
"logging",
".",
"info",
"(",
"'Creating {} report'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
")",
"# Init... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | Observable.add_listener | 添加观察者函数。
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
.. note::
允许一个函数多次注册,多次注册意味着一次 :func:`fire_event` 多次调用。 | qg/core/observer.py | def add_listener(self, evt_name, fn):
"""添加观察者函数。
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
.. note::
允许一个函数多次注册,多次注册意味着一次 :func:`fire_event` 多次调用。
"""
self._listeners.setdefault(evt_name, [])
listeners = self.__get_listeners(evt_name)
lis... | def add_listener(self, evt_name, fn):
"""添加观察者函数。
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
.. note::
允许一个函数多次注册,多次注册意味着一次 :func:`fire_event` 多次调用。
"""
self._listeners.setdefault(evt_name, [])
listeners = self.__get_listeners(evt_name)
lis... | [
"添加观察者函数。"
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/observer.py#L59-L70 | [
"def",
"add_listener",
"(",
"self",
",",
"evt_name",
",",
"fn",
")",
":",
"self",
".",
"_listeners",
".",
"setdefault",
"(",
"evt_name",
",",
"[",
"]",
")",
"listeners",
"=",
"self",
".",
"__get_listeners",
"(",
"evt_name",
")",
"listeners",
".",
"append... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | Observable.remove_listener | 删除观察者函数。
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
:params remove_all: 是否删除fn在evt_name中的所有注册\n
如果为 `True`,则删除所有\n
如果为 `False`,则按注册先后顺序删除第一个\n
.. note::
允许一个函数多次注册,多次注册意味着一次时间多次调用。 | qg/core/observer.py | def remove_listener(self, evt_name, fn, remove_all=False):
"""删除观察者函数。
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
:params remove_all: 是否删除fn在evt_name中的所有注册\n
如果为 `True`,则删除所有\n
如果为 `False`,则按注册先后顺序删除第一个\n
.. note::
... | def remove_listener(self, evt_name, fn, remove_all=False):
"""删除观察者函数。
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
:params remove_all: 是否删除fn在evt_name中的所有注册\n
如果为 `True`,则删除所有\n
如果为 `False`,则按注册先后顺序删除第一个\n
.. note::
... | [
"删除观察者函数。"
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/observer.py#L72-L92 | [
"def",
"remove_listener",
"(",
"self",
",",
"evt_name",
",",
"fn",
",",
"remove_all",
"=",
"False",
")",
":",
"listeners",
"=",
"self",
".",
"__get_listeners",
"(",
"evt_name",
")",
"if",
"not",
"self",
".",
"has_listener",
"(",
"evt_name",
",",
"fn",
")... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | Observable.has_listener | 指定listener是否存在
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数 | qg/core/observer.py | def has_listener(self, evt_name, fn):
"""指定listener是否存在
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
"""
listeners = self.__get_listeners(evt_name)
return fn in listeners | def has_listener(self, evt_name, fn):
"""指定listener是否存在
:params evt_name: 事件名称
:params fn: 要注册的触发函数函数
"""
listeners = self.__get_listeners(evt_name)
return fn in listeners | [
"指定listener是否存在"
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/observer.py#L94-L101 | [
"def",
"has_listener",
"(",
"self",
",",
"evt_name",
",",
"fn",
")",
":",
"listeners",
"=",
"self",
".",
"__get_listeners",
"(",
"evt_name",
")",
"return",
"fn",
"in",
"listeners"
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | Observable.fire_event | 触发事件
:params evt_name: 事件名称
:params args: 给事件接受者的参数
:params kwargs: 给事件接受者的参数 | qg/core/observer.py | def fire_event(self, evt_name, *args, **kwargs):
"""触发事件
:params evt_name: 事件名称
:params args: 给事件接受者的参数
:params kwargs: 给事件接受者的参数
"""
listeners = self.__get_listeners(evt_name)
evt = self.generate_event(evt_name)
for listener in listeners:
lis... | def fire_event(self, evt_name, *args, **kwargs):
"""触发事件
:params evt_name: 事件名称
:params args: 给事件接受者的参数
:params kwargs: 给事件接受者的参数
"""
listeners = self.__get_listeners(evt_name)
evt = self.generate_event(evt_name)
for listener in listeners:
lis... | [
"触发事件"
] | QunarOPS/qg.core | python | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/observer.py#L118-L128 | [
"def",
"fire_event",
"(",
"self",
",",
"evt_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"listeners",
"=",
"self",
".",
"__get_listeners",
"(",
"evt_name",
")",
"evt",
"=",
"self",
".",
"generate_event",
"(",
"evt_name",
")",
"for",
"lis... | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 |
train | create_server_ec2 | Creates EC2 Instance | bookshelf/api_v2/ec2.py | def create_server_ec2(connection,
region,
disk_name,
disk_size,
ami,
key_pair,
instance_type,
tags={},
security_groups=None,
... | def create_server_ec2(connection,
region,
disk_name,
disk_size,
ami,
key_pair,
instance_type,
tags={},
security_groups=None,
... | [
"Creates",
"EC2",
"Instance"
] | pyBookshelf/bookshelf | python | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L54-L115 | [
"def",
"create_server_ec2",
"(",
"connection",
",",
"region",
",",
"disk_name",
",",
"disk_size",
",",
"ami",
",",
"key_pair",
",",
"instance_type",
",",
"tags",
"=",
"{",
"}",
",",
"security_groups",
"=",
"None",
",",
"delete_on_termination",
"=",
"True",
"... | a6770678e735de95b194f6e6989223970db5f654 |
train | destroy_ebs_volume | destroys an ebs volume | bookshelf/api_v2/ec2.py | def destroy_ebs_volume(connection, region, volume_id, log=False):
""" destroys an ebs volume """
if ebs_volume_exists(connection, region, volume_id):
if log:
log_yellow('destroying EBS volume ...')
try:
connection.delete_volume(volume_id)
except:
# ou... | def destroy_ebs_volume(connection, region, volume_id, log=False):
""" destroys an ebs volume """
if ebs_volume_exists(connection, region, volume_id):
if log:
log_yellow('destroying EBS volume ...')
try:
connection.delete_volume(volume_id)
except:
# ou... | [
"destroys",
"an",
"ebs",
"volume"
] | pyBookshelf/bookshelf | python | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L118-L133 | [
"def",
"destroy_ebs_volume",
"(",
"connection",
",",
"region",
",",
"volume_id",
",",
"log",
"=",
"False",
")",
":",
"if",
"ebs_volume_exists",
"(",
"connection",
",",
"region",
",",
"volume_id",
")",
":",
"if",
"log",
":",
"log_yellow",
"(",
"'destroying EB... | a6770678e735de95b194f6e6989223970db5f654 |
train | destroy_ec2 | terminates the instance | bookshelf/api_v2/ec2.py | def destroy_ec2(connection, region, instance_id, log=False):
""" terminates the instance """
data = get_ec2_info(connection=connection,
instance_id=instance_id,
region=region)
instance = connection.terminate_instances(instance_ids=[data['id']])[0]
if log... | def destroy_ec2(connection, region, instance_id, log=False):
""" terminates the instance """
data = get_ec2_info(connection=connection,
instance_id=instance_id,
region=region)
instance = connection.terminate_instances(instance_ids=[data['id']])[0]
if log... | [
"terminates",
"the",
"instance"
] | pyBookshelf/bookshelf | python | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L136-L153 | [
"def",
"destroy_ec2",
"(",
"connection",
",",
"region",
",",
"instance_id",
",",
"log",
"=",
"False",
")",
":",
"data",
"=",
"get_ec2_info",
"(",
"connection",
"=",
"connection",
",",
"instance_id",
"=",
"instance_id",
",",
"region",
"=",
"region",
")",
"i... | a6770678e735de95b194f6e6989223970db5f654 |
train | down_ec2 | shutdown of an existing EC2 instance | bookshelf/api_v2/ec2.py | def down_ec2(connection, instance_id, region, log=False):
""" shutdown of an existing EC2 instance """
# get the instance_id from the state file, and stop the instance
instance = connection.stop_instances(instance_ids=instance_id)[0]
while instance.state != "stopped":
if log:
log_yel... | def down_ec2(connection, instance_id, region, log=False):
""" shutdown of an existing EC2 instance """
# get the instance_id from the state file, and stop the instance
instance = connection.stop_instances(instance_ids=instance_id)[0]
while instance.state != "stopped":
if log:
log_yel... | [
"shutdown",
"of",
"an",
"existing",
"EC2",
"instance"
] | pyBookshelf/bookshelf | python | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L156-L166 | [
"def",
"down_ec2",
"(",
"connection",
",",
"instance_id",
",",
"region",
",",
"log",
"=",
"False",
")",
":",
"# get the instance_id from the state file, and stop the instance",
"instance",
"=",
"connection",
".",
"stop_instances",
"(",
"instance_ids",
"=",
"instance_id"... | a6770678e735de95b194f6e6989223970db5f654 |
train | ebs_volume_exists | finds out if a ebs volume exists | bookshelf/api_v2/ec2.py | def ebs_volume_exists(connection, region, volume_id):
""" finds out if a ebs volume exists """
for vol in connection.get_all_volumes():
if vol.id == volume_id:
return True
return False | def ebs_volume_exists(connection, region, volume_id):
""" finds out if a ebs volume exists """
for vol in connection.get_all_volumes():
if vol.id == volume_id:
return True
return False | [
"finds",
"out",
"if",
"a",
"ebs",
"volume",
"exists"
] | pyBookshelf/bookshelf | python | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L169-L174 | [
"def",
"ebs_volume_exists",
"(",
"connection",
",",
"region",
",",
"volume_id",
")",
":",
"for",
"vol",
"in",
"connection",
".",
"get_all_volumes",
"(",
")",
":",
"if",
"vol",
".",
"id",
"==",
"volume_id",
":",
"return",
"True",
"return",
"False"
] | a6770678e735de95b194f6e6989223970db5f654 |
train | get_ec2_info | queries EC2 for details about a particular instance_id | bookshelf/api_v2/ec2.py | def get_ec2_info(connection,
instance_id,
region,
username=None):
""" queries EC2 for details about a particular instance_id
"""
instance = connection.get_only_instances(
filters={'instance_id': instance_id}
)[0]
data = instance.__dict_... | def get_ec2_info(connection,
instance_id,
region,
username=None):
""" queries EC2 for details about a particular instance_id
"""
instance = connection.get_only_instances(
filters={'instance_id': instance_id}
)[0]
data = instance.__dict_... | [
"queries",
"EC2",
"for",
"details",
"about",
"a",
"particular",
"instance_id"
] | pyBookshelf/bookshelf | python | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L181-L202 | [
"def",
"get_ec2_info",
"(",
"connection",
",",
"instance_id",
",",
"region",
",",
"username",
"=",
"None",
")",
":",
"instance",
"=",
"connection",
".",
"get_only_instances",
"(",
"filters",
"=",
"{",
"'instance_id'",
":",
"instance_id",
"}",
")",
"[",
"0",
... | a6770678e735de95b194f6e6989223970db5f654 |
train | up_ec2 | boots an existing ec2_instance | bookshelf/api_v2/ec2.py | def up_ec2(connection,
region,
instance_id,
wait_for_ssh_available=True,
log=False,
timeout=600):
""" boots an existing ec2_instance """
# boot the ec2 instance
instance = connection.start_instances(instance_ids=instance_id)[0]
instance.update()
... | def up_ec2(connection,
region,
instance_id,
wait_for_ssh_available=True,
log=False,
timeout=600):
""" boots an existing ec2_instance """
# boot the ec2 instance
instance = connection.start_instances(instance_ids=instance_id)[0]
instance.update()
... | [
"boots",
"an",
"existing",
"ec2_instance"
] | pyBookshelf/bookshelf | python | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/ec2.py#L205-L226 | [
"def",
"up_ec2",
"(",
"connection",
",",
"region",
",",
"instance_id",
",",
"wait_for_ssh_available",
"=",
"True",
",",
"log",
"=",
"False",
",",
"timeout",
"=",
"600",
")",
":",
"# boot the ec2 instance",
"instance",
"=",
"connection",
".",
"start_instances",
... | a6770678e735de95b194f6e6989223970db5f654 |
train | apply_T4 | An agglutination diphthong that ends in /u, y/ usually contains a
syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us],
[va.ka.ut.taa]. | finnsyll/prev/v03.py | def apply_T4(word):
'''An agglutination diphthong that ends in /u, y/ usually contains a
syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us],
[va.ka.ut.taa].'''
WORD = word.split('.')
for i, v in enumerate(WORD):
# i % 2 != 0 prevents this rule from applying to first, third, etc.
... | def apply_T4(word):
'''An agglutination diphthong that ends in /u, y/ usually contains a
syllable boundary when -C# or -CCV follow, e.g., [lau.ka.us],
[va.ka.ut.taa].'''
WORD = word.split('.')
for i, v in enumerate(WORD):
# i % 2 != 0 prevents this rule from applying to first, third, etc.
... | [
"An",
"agglutination",
"diphthong",
"that",
"ends",
"in",
"/",
"u",
"y",
"/",
"usually",
"contains",
"a",
"syllable",
"boundary",
"when",
"-",
"C#",
"or",
"-",
"CCV",
"follow",
"e",
".",
"g",
".",
"[",
"lau",
".",
"ka",
".",
"us",
"]",
"[",
"va",
... | tsnaomi/finnsyll | python | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v03.py#L137-L159 | [
"def",
"apply_T4",
"(",
"word",
")",
":",
"WORD",
"=",
"word",
".",
"split",
"(",
"'.'",
")",
"for",
"i",
",",
"v",
"in",
"enumerate",
"(",
"WORD",
")",
":",
"# i % 2 != 0 prevents this rule from applying to first, third, etc.",
"# syllables, which receive stress (W... | 6a42740311688c946a636a3e2304866c7aa041b3 |
train | seqs_from_file | Extract sequences from a file
Name:
seqs_from_file
Author(s):
Martin C F Thomsen
Date:
18 Jul 2013
Description:
Iterator which extract sequence data from the input file
Args:
filename: string which contain a path to the input file
Supported Formats:
fasta, fastq... | cgecore/utility.py | def seqs_from_file(filename, exit_on_err=False, return_qual=False):
"""Extract sequences from a file
Name:
seqs_from_file
Author(s):
Martin C F Thomsen
Date:
18 Jul 2013
Description:
Iterator which extract sequence data from the input file
Args:
filename: string which... | def seqs_from_file(filename, exit_on_err=False, return_qual=False):
"""Extract sequences from a file
Name:
seqs_from_file
Author(s):
Martin C F Thomsen
Date:
18 Jul 2013
Description:
Iterator which extract sequence data from the input file
Args:
filename: string which... | [
"Extract",
"sequences",
"from",
"a",
"file",
"Name",
":",
"seqs_from_file",
"Author",
"(",
"s",
")",
":",
"Martin",
"C",
"F",
"Thomsen",
"Date",
":",
"18",
"Jul",
"2013",
"Description",
":",
"Iterator",
"which",
"extract",
"sequence",
"data",
"from",
"the"... | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L223-L318 | [
"def",
"seqs_from_file",
"(",
"filename",
",",
"exit_on_err",
"=",
"False",
",",
"return_qual",
"=",
"False",
")",
":",
"# VALIDATE INPUT",
"if",
"not",
"isinstance",
"(",
"filename",
",",
"str",
")",
":",
"msg",
"=",
"'Filename has to be a string.'",
"if",
"e... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | open_ | Switch for both open() and gzip.open().
Determines if the file is normal or gzipped by looking at the file
extension.
The filename argument is required; mode defaults to 'rb' for gzip and 'r'
for normal and compresslevel defaults to 9 for gzip.
>>> import gzip
>>> from contextlib import cl... | cgecore/utility.py | def open_(filename, mode=None, compresslevel=9):
"""Switch for both open() and gzip.open().
Determines if the file is normal or gzipped by looking at the file
extension.
The filename argument is required; mode defaults to 'rb' for gzip and 'r'
for normal and compresslevel defaults to 9 for gzip.
... | def open_(filename, mode=None, compresslevel=9):
"""Switch for both open() and gzip.open().
Determines if the file is normal or gzipped by looking at the file
extension.
The filename argument is required; mode defaults to 'rb' for gzip and 'r'
for normal and compresslevel defaults to 9 for gzip.
... | [
"Switch",
"for",
"both",
"open",
"()",
"and",
"gzip",
".",
"open",
"()",
".",
"Determines",
"if",
"the",
"file",
"is",
"normal",
"or",
"gzipped",
"by",
"looking",
"at",
"the",
"file",
"extension",
".",
"The",
"filename",
"argument",
"is",
"required",
";"... | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L321-L340 | [
"def",
"open_",
"(",
"filename",
",",
"mode",
"=",
"None",
",",
"compresslevel",
"=",
"9",
")",
":",
"if",
"filename",
"[",
"-",
"3",
":",
"]",
"==",
"'.gz'",
":",
"if",
"mode",
"is",
"None",
":",
"mode",
"=",
"'rt'",
"return",
"closing",
"(",
"g... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | load_json | Load json from file or file name | cgecore/utility.py | def load_json(json_object):
''' Load json from file or file name '''
content = None
if isinstance(json_object, str) and os.path.exists(json_object):
with open_(json_object) as f:
try:
content = json.load(f)
except Exception as e:
debug.log("Warning: Content of '%... | def load_json(json_object):
''' Load json from file or file name '''
content = None
if isinstance(json_object, str) and os.path.exists(json_object):
with open_(json_object) as f:
try:
content = json.load(f)
except Exception as e:
debug.log("Warning: Content of '%... | [
"Load",
"json",
"from",
"file",
"or",
"file",
"name"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L342-L358 | [
"def",
"load_json",
"(",
"json_object",
")",
":",
"content",
"=",
"None",
"if",
"isinstance",
"(",
"json_object",
",",
"str",
")",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"json_object",
")",
":",
"with",
"open_",
"(",
"json_object",
")",
"as",
"f... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | sort2groups | Sort an array of strings to groups by patterns | cgecore/utility.py | def sort2groups(array, gpat=['_R1','_R2']):
""" Sort an array of strings to groups by patterns """
groups = [REGroup(gp) for gp in gpat]
unmatched = []
for item in array:
matched = False
for m in groups:
if m.match(item):
matched = True
break
if not matched... | def sort2groups(array, gpat=['_R1','_R2']):
""" Sort an array of strings to groups by patterns """
groups = [REGroup(gp) for gp in gpat]
unmatched = []
for item in array:
matched = False
for m in groups:
if m.match(item):
matched = True
break
if not matched... | [
"Sort",
"an",
"array",
"of",
"strings",
"to",
"groups",
"by",
"patterns"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L360-L371 | [
"def",
"sort2groups",
"(",
"array",
",",
"gpat",
"=",
"[",
"'_R1'",
",",
"'_R2'",
"]",
")",
":",
"groups",
"=",
"[",
"REGroup",
"(",
"gp",
")",
"for",
"gp",
"in",
"gpat",
"]",
"unmatched",
"=",
"[",
"]",
"for",
"item",
"in",
"array",
":",
"matche... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | sort_and_distribute | Sort an array of strings to groups by alphabetically continuous
distribution | cgecore/utility.py | def sort_and_distribute(array, splits=2):
""" Sort an array of strings to groups by alphabetically continuous
distribution
"""
if not isinstance(array, (list,tuple)): raise TypeError("array must be a list")
if not isinstance(splits, int): raise TypeError("splits must be an integer")
remaining = so... | def sort_and_distribute(array, splits=2):
""" Sort an array of strings to groups by alphabetically continuous
distribution
"""
if not isinstance(array, (list,tuple)): raise TypeError("array must be a list")
if not isinstance(splits, int): raise TypeError("splits must be an integer")
remaining = so... | [
"Sort",
"an",
"array",
"of",
"strings",
"to",
"groups",
"by",
"alphabetically",
"continuous",
"distribution"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L373-L388 | [
"def",
"sort_and_distribute",
"(",
"array",
",",
"splits",
"=",
"2",
")",
":",
"if",
"not",
"isinstance",
"(",
"array",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"array must be a list\"",
")",
"if",
"not",
"isinstance",
... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | mkpath | This function executes a mkdir command for filepath and with permissions
(octal number with leading 0 or string only)
# eg. mkpath("path/to/file", "0o775") | cgecore/utility.py | def mkpath(filepath, permissions=0o777):
""" This function executes a mkdir command for filepath and with permissions
(octal number with leading 0 or string only)
# eg. mkpath("path/to/file", "0o775")
"""
# Converting string of octal to integer, if string is given.
if isinstance(permissions, str):
... | def mkpath(filepath, permissions=0o777):
""" This function executes a mkdir command for filepath and with permissions
(octal number with leading 0 or string only)
# eg. mkpath("path/to/file", "0o775")
"""
# Converting string of octal to integer, if string is given.
if isinstance(permissions, str):
... | [
"This",
"function",
"executes",
"a",
"mkdir",
"command",
"for",
"filepath",
"and",
"with",
"permissions",
"(",
"octal",
"number",
"with",
"leading",
"0",
"or",
"string",
"only",
")",
"#",
"eg",
".",
"mkpath",
"(",
"path",
"/",
"to",
"/",
"file",
"0o775",... | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L390-L405 | [
"def",
"mkpath",
"(",
"filepath",
",",
"permissions",
"=",
"0o777",
")",
":",
"# Converting string of octal to integer, if string is given.",
"if",
"isinstance",
"(",
"permissions",
",",
"str",
")",
":",
"permissions",
"=",
"sum",
"(",
"[",
"int",
"(",
"x",
")",... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | create_zip_dir | This function creates a zipfile located in zipFilePath with the files in
the file list
# fileList can be both a comma separated list or an array | cgecore/utility.py | def create_zip_dir(zipfile_path, *file_list):
""" This function creates a zipfile located in zipFilePath with the files in
the file list
# fileList can be both a comma separated list or an array
"""
try:
if isinstance(file_list, (list, tuple)): #unfolding list of list or tuple
if len(file_... | def create_zip_dir(zipfile_path, *file_list):
""" This function creates a zipfile located in zipFilePath with the files in
the file list
# fileList can be both a comma separated list or an array
"""
try:
if isinstance(file_list, (list, tuple)): #unfolding list of list or tuple
if len(file_... | [
"This",
"function",
"creates",
"a",
"zipfile",
"located",
"in",
"zipFilePath",
"with",
"the",
"files",
"in",
"the",
"file",
"list",
"#",
"fileList",
"can",
"be",
"both",
"a",
"comma",
"separated",
"list",
"or",
"an",
"array"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L407-L431 | [
"def",
"create_zip_dir",
"(",
"zipfile_path",
",",
"*",
"file_list",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"file_list",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"#unfolding list of list or tuple",
"if",
"len",
"(",
"file_list",
")",
"==",
"1... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | file_zipper | This function will zip the files created in the runroot directory and
subdirectories | cgecore/utility.py | def file_zipper(root_dir):
""" This function will zip the files created in the runroot directory and
subdirectories """
# FINDING AND ZIPPING UNZIPPED FILES
for root, dirs, files in os.walk(root_dir, topdown=False):
if root != "":
if root[-1] != '/': root += '/'
for current_file in f... | def file_zipper(root_dir):
""" This function will zip the files created in the runroot directory and
subdirectories """
# FINDING AND ZIPPING UNZIPPED FILES
for root, dirs, files in os.walk(root_dir, topdown=False):
if root != "":
if root[-1] != '/': root += '/'
for current_file in f... | [
"This",
"function",
"will",
"zip",
"the",
"files",
"created",
"in",
"the",
"runroot",
"directory",
"and",
"subdirectories"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L433-L469 | [
"def",
"file_zipper",
"(",
"root_dir",
")",
":",
"# FINDING AND ZIPPING UNZIPPED FILES",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"root_dir",
",",
"topdown",
"=",
"False",
")",
":",
"if",
"root",
"!=",
"\"\"",
":",
"if",
"r... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | file_unzipper | This function will unzip all files in the runroot directory and
subdirectories | cgecore/utility.py | def file_unzipper(directory):
""" This function will unzip all files in the runroot directory and
subdirectories
"""
debug.log("Unzipping directory (%s)..."%directory)
#FINDING AND UNZIPPING ZIPPED FILES
for root, dirs, files in os.walk(directory, topdown=False):
if root != "":
orig_dir... | def file_unzipper(directory):
""" This function will unzip all files in the runroot directory and
subdirectories
"""
debug.log("Unzipping directory (%s)..."%directory)
#FINDING AND UNZIPPING ZIPPED FILES
for root, dirs, files in os.walk(directory, topdown=False):
if root != "":
orig_dir... | [
"This",
"function",
"will",
"unzip",
"all",
"files",
"in",
"the",
"runroot",
"directory",
"and",
"subdirectories"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L471-L484 | [
"def",
"file_unzipper",
"(",
"directory",
")",
":",
"debug",
".",
"log",
"(",
"\"Unzipping directory (%s)...\"",
"%",
"directory",
")",
"#FINDING AND UNZIPPING ZIPPED FILES",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"directory",
",... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | move_file | this function will simply move the file from the source path to the dest
path given as input | cgecore/utility.py | def move_file(src, dst):
""" this function will simply move the file from the source path to the dest
path given as input
"""
# Sanity checkpoint
src = re.sub('[^\w/\-\.\*]', '', src)
dst = re.sub('[^\w/\-\.\*]', '', dst)
if len(re.sub('[\W]', '', src)) < 5 or len(re.sub('[\W]', '', dst)) < 5:
... | def move_file(src, dst):
""" this function will simply move the file from the source path to the dest
path given as input
"""
# Sanity checkpoint
src = re.sub('[^\w/\-\.\*]', '', src)
dst = re.sub('[^\w/\-\.\*]', '', dst)
if len(re.sub('[\W]', '', src)) < 5 or len(re.sub('[\W]', '', dst)) < 5:
... | [
"this",
"function",
"will",
"simply",
"move",
"the",
"file",
"from",
"the",
"source",
"path",
"to",
"the",
"dest",
"path",
"given",
"as",
"input"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L486-L532 | [
"def",
"move_file",
"(",
"src",
",",
"dst",
")",
":",
"# Sanity checkpoint",
"src",
"=",
"re",
".",
"sub",
"(",
"'[^\\w/\\-\\.\\*]'",
",",
"''",
",",
"src",
")",
"dst",
"=",
"re",
".",
"sub",
"(",
"'[^\\w/\\-\\.\\*]'",
",",
"''",
",",
"dst",
")",
"if... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | copy_file | this function will simply copy the file from the source path to the dest
path given as input | cgecore/utility.py | def copy_file(src, dst, ignore=None):
""" this function will simply copy the file from the source path to the dest
path given as input
"""
# Sanity checkpoint
src = re.sub('[^\w/\-\.\*]', '', src)
dst = re.sub('[^\w/\-\.\*]', '', dst)
if len(re.sub('[\W]', '', src)) < 5 or len(re.sub('[\W]', '', ds... | def copy_file(src, dst, ignore=None):
""" this function will simply copy the file from the source path to the dest
path given as input
"""
# Sanity checkpoint
src = re.sub('[^\w/\-\.\*]', '', src)
dst = re.sub('[^\w/\-\.\*]', '', dst)
if len(re.sub('[\W]', '', src)) < 5 or len(re.sub('[\W]', '', ds... | [
"this",
"function",
"will",
"simply",
"copy",
"the",
"file",
"from",
"the",
"source",
"path",
"to",
"the",
"dest",
"path",
"given",
"as",
"input"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L534-L574 | [
"def",
"copy_file",
"(",
"src",
",",
"dst",
",",
"ignore",
"=",
"None",
")",
":",
"# Sanity checkpoint",
"src",
"=",
"re",
".",
"sub",
"(",
"'[^\\w/\\-\\.\\*]'",
",",
"''",
",",
"src",
")",
"dst",
"=",
"re",
".",
"sub",
"(",
"'[^\\w/\\-\\.\\*]'",
",",
... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | copy_dir | this function will simply copy the file from the source path to the dest
path given as input | cgecore/utility.py | def copy_dir(src, dst):
""" this function will simply copy the file from the source path to the dest
path given as input
"""
try:
debug.log("copy dir from "+ src, "to "+ dst)
shutil.copytree(src, dst)
except Exception as e:
debug.log("Error: happened while copying!\n%s\n"%e) | def copy_dir(src, dst):
""" this function will simply copy the file from the source path to the dest
path given as input
"""
try:
debug.log("copy dir from "+ src, "to "+ dst)
shutil.copytree(src, dst)
except Exception as e:
debug.log("Error: happened while copying!\n%s\n"%e) | [
"this",
"function",
"will",
"simply",
"copy",
"the",
"file",
"from",
"the",
"source",
"path",
"to",
"the",
"dest",
"path",
"given",
"as",
"input"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L576-L584 | [
"def",
"copy_dir",
"(",
"src",
",",
"dst",
")",
":",
"try",
":",
"debug",
".",
"log",
"(",
"\"copy dir from \"",
"+",
"src",
",",
"\"to \"",
"+",
"dst",
")",
"shutil",
".",
"copytree",
"(",
"src",
",",
"dst",
")",
"except",
"Exception",
"as",
"e",
... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | Debug.print_out | Print list of strings to the predefined stdout. | cgecore/utility.py | def print_out(self, *lst):
""" Print list of strings to the predefined stdout. """
self.print2file(self.stdout, True, True, *lst) | def print_out(self, *lst):
""" Print list of strings to the predefined stdout. """
self.print2file(self.stdout, True, True, *lst) | [
"Print",
"list",
"of",
"strings",
"to",
"the",
"predefined",
"stdout",
"."
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L43-L45 | [
"def",
"print_out",
"(",
"self",
",",
"*",
"lst",
")",
":",
"self",
".",
"print2file",
"(",
"self",
".",
"stdout",
",",
"True",
",",
"True",
",",
"*",
"lst",
")"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | Debug.print_err | Print list of strings to the predefined stdout. | cgecore/utility.py | def print_err(self, *lst):
""" Print list of strings to the predefined stdout. """
self.print2file(self.stderr, False, True, *lst) | def print_err(self, *lst):
""" Print list of strings to the predefined stdout. """
self.print2file(self.stderr, False, True, *lst) | [
"Print",
"list",
"of",
"strings",
"to",
"the",
"predefined",
"stdout",
"."
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L46-L48 | [
"def",
"print_err",
"(",
"self",
",",
"*",
"lst",
")",
":",
"self",
".",
"print2file",
"(",
"self",
".",
"stderr",
",",
"False",
",",
"True",
",",
"*",
"lst",
")"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | Debug.print2file | This function prints to the screen and logs to a file, all the strings
given.
# print2screen eg. True, *lst is a commaseparated list of strings | cgecore/utility.py | def print2file(self, logfile, print2screen, addLineFeed, *lst):
""" This function prints to the screen and logs to a file, all the strings
given.
# print2screen eg. True, *lst is a commaseparated list of strings
"""
if addLineFeed:
linefeed = '\n'
else: linefeed = ''
i... | def print2file(self, logfile, print2screen, addLineFeed, *lst):
""" This function prints to the screen and logs to a file, all the strings
given.
# print2screen eg. True, *lst is a commaseparated list of strings
"""
if addLineFeed:
linefeed = '\n'
else: linefeed = ''
i... | [
"This",
"function",
"prints",
"to",
"the",
"screen",
"and",
"logs",
"to",
"a",
"file",
"all",
"the",
"strings",
"given",
".",
"#",
"print2screen",
"eg",
".",
"True",
"*",
"lst",
"is",
"a",
"commaseparated",
"list",
"of",
"strings"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L49-L69 | [
"def",
"print2file",
"(",
"self",
",",
"logfile",
",",
"print2screen",
",",
"addLineFeed",
",",
"*",
"lst",
")",
":",
"if",
"addLineFeed",
":",
"linefeed",
"=",
"'\\n'",
"else",
":",
"linefeed",
"=",
"''",
"if",
"print2screen",
":",
"print",
"(",
"linefe... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | Debug.log | Print list of strings to the predefined logfile if debug is set. and
sets the caught_error message if an error is found | cgecore/utility.py | def log(self, *lst):
""" Print list of strings to the predefined logfile if debug is set. and
sets the caught_error message if an error is found
"""
self.print2file(self.logfile, self.debug, True, *lst)
if 'Error' in '\n'.join([str(x) for x in lst]):
self.caught_error = '\n'.join(... | def log(self, *lst):
""" Print list of strings to the predefined logfile if debug is set. and
sets the caught_error message if an error is found
"""
self.print2file(self.logfile, self.debug, True, *lst)
if 'Error' in '\n'.join([str(x) for x in lst]):
self.caught_error = '\n'.join(... | [
"Print",
"list",
"of",
"strings",
"to",
"the",
"predefined",
"logfile",
"if",
"debug",
"is",
"set",
".",
"and",
"sets",
"the",
"caught_error",
"message",
"if",
"an",
"error",
"is",
"found"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L70-L76 | [
"def",
"log",
"(",
"self",
",",
"*",
"lst",
")",
":",
"self",
".",
"print2file",
"(",
"self",
".",
"logfile",
",",
"self",
".",
"debug",
",",
"True",
",",
"*",
"lst",
")",
"if",
"'Error'",
"in",
"'\\n'",
".",
"join",
"(",
"[",
"str",
"(",
"x",
... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | Debug.log_no_newline | print the message to the predefined log file without newline | cgecore/utility.py | def log_no_newline(self, msg):
""" print the message to the predefined log file without newline """
self.print2file(self.logfile, False, False, msg) | def log_no_newline(self, msg):
""" print the message to the predefined log file without newline """
self.print2file(self.logfile, False, False, msg) | [
"print",
"the",
"message",
"to",
"the",
"predefined",
"log",
"file",
"without",
"newline"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L77-L79 | [
"def",
"log_no_newline",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"print2file",
"(",
"self",
".",
"logfile",
",",
"False",
",",
"False",
",",
"msg",
")"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | Debug.graceful_exit | This function Tries to update the MSQL database before exiting. | cgecore/utility.py | def graceful_exit(self, msg):
""" This function Tries to update the MSQL database before exiting. """
# Print stored errors to stderr
if self.caught_error:
self.print2file(self.stderr, False, False, self.caught_error)
# Kill process with error message
self.log(msg)
sys.exit(... | def graceful_exit(self, msg):
""" This function Tries to update the MSQL database before exiting. """
# Print stored errors to stderr
if self.caught_error:
self.print2file(self.stderr, False, False, self.caught_error)
# Kill process with error message
self.log(msg)
sys.exit(... | [
"This",
"function",
"Tries",
"to",
"update",
"the",
"MSQL",
"database",
"before",
"exiting",
"."
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L80-L87 | [
"def",
"graceful_exit",
"(",
"self",
",",
"msg",
")",
":",
"# Print stored errors to stderr",
"if",
"self",
".",
"caught_error",
":",
"self",
".",
"print2file",
"(",
"self",
".",
"stderr",
",",
"False",
",",
"False",
",",
"self",
".",
"caught_error",
")",
... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | adv_dict.get_tree | gettree will extract the value from a nested tree
INPUT
list_of_keys: a list of keys ie. ['key1', 'key2']
USAGE
>>> # Access the value for key2 within the nested dictionary
>>> adv_dict({'key1': {'key2': 'value'}}).gettree(['key1', 'key2'])
'value' | cgecore/utility.py | def get_tree(self, list_of_keys):
""" gettree will extract the value from a nested tree
INPUT
list_of_keys: a list of keys ie. ['key1', 'key2']
USAGE
>>> # Access the value for key2 within the nested dictionary
>>> adv_dict({'key1': {'key2': 'value'}}).gettree(['key1', 'key... | def get_tree(self, list_of_keys):
""" gettree will extract the value from a nested tree
INPUT
list_of_keys: a list of keys ie. ['key1', 'key2']
USAGE
>>> # Access the value for key2 within the nested dictionary
>>> adv_dict({'key1': {'key2': 'value'}}).gettree(['key1', 'key... | [
"gettree",
"will",
"extract",
"the",
"value",
"from",
"a",
"nested",
"tree",
"INPUT",
"list_of_keys",
":",
"a",
"list",
"of",
"keys",
"ie",
".",
"[",
"key1",
"key2",
"]",
"USAGE",
">>>",
"#",
"Access",
"the",
"value",
"for",
"key2",
"within",
"the",
"n... | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L93-L107 | [
"def",
"get_tree",
"(",
"self",
",",
"list_of_keys",
")",
":",
"cur_obj",
"=",
"self",
"for",
"key",
"in",
"list_of_keys",
":",
"cur_obj",
"=",
"cur_obj",
".",
"get",
"(",
"key",
")",
"if",
"not",
"cur_obj",
":",
"break",
"return",
"cur_obj"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | adv_dict.invert | Return inverse mapping of dictionary with sorted values.
USAGE
>>> # Switch the keys and values
>>> adv_dict({
... 'A': [1, 2, 3],
... 'B': [4, 2],
... 'C': [1, 4],
... }).invert()
{1: ['A', 'C'], 2: ['A', 'B'], 3: ['A'], 4: ['B', 'C']} | cgecore/utility.py | def invert(self):
''' Return inverse mapping of dictionary with sorted values.
USAGE
>>> # Switch the keys and values
>>> adv_dict({
... 'A': [1, 2, 3],
... 'B': [4, 2],
... 'C': [1, 4],
... }).invert()
{1: ['A', 'C'], 2: ['A', 'B'],... | def invert(self):
''' Return inverse mapping of dictionary with sorted values.
USAGE
>>> # Switch the keys and values
>>> adv_dict({
... 'A': [1, 2, 3],
... 'B': [4, 2],
... 'C': [1, 4],
... }).invert()
{1: ['A', 'C'], 2: ['A', 'B'],... | [
"Return",
"inverse",
"mapping",
"of",
"dictionary",
"with",
"sorted",
"values",
".",
"USAGE",
">>>",
"#",
"Switch",
"the",
"keys",
"and",
"values",
">>>",
"adv_dict",
"(",
"{",
"...",
"A",
":",
"[",
"1",
"2",
"3",
"]",
"...",
"B",
":",
"[",
"4",
"2... | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L108-L134 | [
"def",
"invert",
"(",
"self",
")",
":",
"inv_map",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
"0",
")",
":",
"acceptable_v_instance",
"=",
"isinstance",
"(... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | Reg.sub | returns new string where the matching cases (limited by the count) in
the string is replaced. | cgecore/utility.py | def sub(self, replace, string, count=0):
""" returns new string where the matching cases (limited by the count) in
the string is replaced. """
return self.re.sub(replace, string, count) | def sub(self, replace, string, count=0):
""" returns new string where the matching cases (limited by the count) in
the string is replaced. """
return self.re.sub(replace, string, count) | [
"returns",
"new",
"string",
"where",
"the",
"matching",
"cases",
"(",
"limited",
"by",
"the",
"count",
")",
"in",
"the",
"string",
"is",
"replaced",
"."
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L186-L189 | [
"def",
"sub",
"(",
"self",
",",
"replace",
",",
"string",
",",
"count",
"=",
"0",
")",
":",
"return",
"self",
".",
"re",
".",
"sub",
"(",
"replace",
",",
"string",
",",
"count",
")"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | Reg.match | Matches the string to the stored regular expression, and stores all
groups in mathches. Returns False on negative match. | cgecore/utility.py | def match(self, s):
""" Matches the string to the stored regular expression, and stores all
groups in mathches. Returns False on negative match. """
self.matches = self.re.search(s)
return self.matches | def match(self, s):
""" Matches the string to the stored regular expression, and stores all
groups in mathches. Returns False on negative match. """
self.matches = self.re.search(s)
return self.matches | [
"Matches",
"the",
"string",
"to",
"the",
"stored",
"regular",
"expression",
"and",
"stores",
"all",
"groups",
"in",
"mathches",
".",
"Returns",
"False",
"on",
"negative",
"match",
"."
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L193-L197 | [
"def",
"match",
"(",
"self",
",",
"s",
")",
":",
"self",
".",
"matches",
"=",
"self",
".",
"re",
".",
"search",
"(",
"s",
")",
"return",
"self",
".",
"matches"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | REGroup.match | Matching the pattern to the input string, returns True/False and
saves the matched string in the internal list | cgecore/utility.py | def match(self, s):
""" Matching the pattern to the input string, returns True/False and
saves the matched string in the internal list
"""
if self.re.match(s):
self.list.append(s)
return True
else: return False | def match(self, s):
""" Matching the pattern to the input string, returns True/False and
saves the matched string in the internal list
"""
if self.re.match(s):
self.list.append(s)
return True
else: return False | [
"Matching",
"the",
"pattern",
"to",
"the",
"input",
"string",
"returns",
"True",
"/",
"False",
"and",
"saves",
"the",
"matched",
"string",
"in",
"the",
"internal",
"list"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/utility.py#L213-L220 | [
"def",
"match",
"(",
"self",
",",
"s",
")",
":",
"if",
"self",
".",
"re",
".",
"match",
"(",
"s",
")",
":",
"self",
".",
"list",
".",
"append",
"(",
"s",
")",
"return",
"True",
"else",
":",
"return",
"False"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | Mash.reporter | Create the MASH report | MASHsippr/mash.py | def reporter(self):
"""
Create the MASH report
"""
logging.info('Creating {} report'.format(self.analysistype))
make_path(self.reportpath)
header = 'Strain,ReferenceGenus,ReferenceFile,ReferenceGenomeMashDistance,Pvalue,NumMatchingHashes\n'
data = ''
for s... | def reporter(self):
"""
Create the MASH report
"""
logging.info('Creating {} report'.format(self.analysistype))
make_path(self.reportpath)
header = 'Strain,ReferenceGenus,ReferenceFile,ReferenceGenomeMashDistance,Pvalue,NumMatchingHashes\n'
data = ''
for s... | [
"Create",
"the",
"MASH",
"report"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/MASHsippr/mash.py#L214-L236 | [
"def",
"reporter",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Creating {} report'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
")",
"make_path",
"(",
"self",
".",
"reportpath",
")",
"header",
"=",
"'Strain,ReferenceGenus,ReferenceFile,Refer... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | get_function | Take a full path to a python method or class, for example
mypkg.subpkg.method and return the method or class (after importing the
required packages) | pymacaron_core/utils.py | def get_function(pkgpath):
"""Take a full path to a python method or class, for example
mypkg.subpkg.method and return the method or class (after importing the
required packages)
"""
# Extract the module and function name from pkgpath
elems = pkgpath.split('.')
if len(elems) <= 1:
ra... | def get_function(pkgpath):
"""Take a full path to a python method or class, for example
mypkg.subpkg.method and return the method or class (after importing the
required packages)
"""
# Extract the module and function name from pkgpath
elems = pkgpath.split('.')
if len(elems) <= 1:
ra... | [
"Take",
"a",
"full",
"path",
"to",
"a",
"python",
"method",
"or",
"class",
"for",
"example",
"mypkg",
".",
"subpkg",
".",
"method",
"and",
"return",
"the",
"method",
"or",
"class",
"(",
"after",
"importing",
"the",
"required",
"packages",
")"
] | pymacaron/pymacaron-core | python | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/utils.py#L5-L24 | [
"def",
"get_function",
"(",
"pkgpath",
")",
":",
"# Extract the module and function name from pkgpath",
"elems",
"=",
"pkgpath",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"elems",
")",
"<=",
"1",
":",
"raise",
"PyMacaronCoreException",
"(",
"\"Path %s is to... | 95070a39ed7065a84244ff5601fea4d54cc72b66 |
train | GDCS.runner | Run the necessary methods in the correct order | gdcs/gdcs.py | def runner(self):
"""
Run the necessary methods in the correct order
"""
printtime('Starting {} analysis pipeline'.format(self.analysistype), self.starttime)
# Create the objects to be used in the analyses
objects = Objectprep(self)
objects.objectprep()
se... | def runner(self):
"""
Run the necessary methods in the correct order
"""
printtime('Starting {} analysis pipeline'.format(self.analysistype), self.starttime)
# Create the objects to be used in the analyses
objects = Objectprep(self)
objects.objectprep()
se... | [
"Run",
"the",
"necessary",
"methods",
"in",
"the",
"correct",
"order"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/gdcs/gdcs.py#L15-L29 | [
"def",
"runner",
"(",
"self",
")",
":",
"printtime",
"(",
"'Starting {} analysis pipeline'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
",",
"self",
".",
"starttime",
")",
"# Create the objects to be used in the analyses",
"objects",
"=",
"Objectprep",
"(... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | syllabify | Syllabify the given word, whether simplex or complex. | finnsyll/prev/v06.py | 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):
'''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... | [
"Syllabify",
"the",
"given",
"word",
"whether",
"simplex",
"or",
"complex",
"."
] | tsnaomi/finnsyll | python | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v06.py#L148-L173 | [
"def",
"syllabify",
"(",
"word",
")",
":",
"word",
"=",
"split",
"(",
"word",
")",
"# detect any non-delimited compounds",
"compound",
"=",
"True",
"if",
"re",
".",
"search",
"(",
"r'-| |\\.'",
",",
"word",
")",
"else",
"False",
"syllabify",
"=",
"_syllabify... | 6a42740311688c946a636a3e2304866c7aa041b3 |
train | Node.edges | Return the edge characters of this node. | gaddag/node.py | def edges(self):
"""
Return the edge characters of this node.
"""
edge_str = ctypes.create_string_buffer(MAX_CHARS)
cgaddag.gdg_edges(self.gdg, self.node, edge_str)
return [char for char in edge_str.value.decode("ascii")] | def edges(self):
"""
Return the edge characters of this node.
"""
edge_str = ctypes.create_string_buffer(MAX_CHARS)
cgaddag.gdg_edges(self.gdg, self.node, edge_str)
return [char for char in edge_str.value.decode("ascii")] | [
"Return",
"the",
"edge",
"characters",
"of",
"this",
"node",
"."
] | jorbas/GADDAG | python | https://github.com/jorbas/GADDAG/blob/a0ede3def715c586e1f273d96e9fc0d537cd9561/gaddag/node.py#L64-L72 | [
"def",
"edges",
"(",
"self",
")",
":",
"edge_str",
"=",
"ctypes",
".",
"create_string_buffer",
"(",
"MAX_CHARS",
")",
"cgaddag",
".",
"gdg_edges",
"(",
"self",
".",
"gdg",
",",
"self",
".",
"node",
",",
"edge_str",
")",
"return",
"[",
"char",
"for",
"c... | a0ede3def715c586e1f273d96e9fc0d537cd9561 |
train | Node.letter_set | Return the letter set of this node. | gaddag/node.py | def letter_set(self):
"""
Return the letter set of this node.
"""
end_str = ctypes.create_string_buffer(MAX_CHARS)
cgaddag.gdg_letter_set(self.gdg, self.node, end_str)
return [char for char in end_str.value.decode("ascii")] | def letter_set(self):
"""
Return the letter set of this node.
"""
end_str = ctypes.create_string_buffer(MAX_CHARS)
cgaddag.gdg_letter_set(self.gdg, self.node, end_str)
return [char for char in end_str.value.decode("ascii")] | [
"Return",
"the",
"letter",
"set",
"of",
"this",
"node",
"."
] | jorbas/GADDAG | python | https://github.com/jorbas/GADDAG/blob/a0ede3def715c586e1f273d96e9fc0d537cd9561/gaddag/node.py#L75-L83 | [
"def",
"letter_set",
"(",
"self",
")",
":",
"end_str",
"=",
"ctypes",
".",
"create_string_buffer",
"(",
"MAX_CHARS",
")",
"cgaddag",
".",
"gdg_letter_set",
"(",
"self",
".",
"gdg",
",",
"self",
".",
"node",
",",
"end_str",
")",
"return",
"[",
"char",
"fo... | a0ede3def715c586e1f273d96e9fc0d537cd9561 |
train | Node.is_end | Return `True` if this `char` is part of this node's letter set,
`False` otherwise. | gaddag/node.py | def is_end(self, char):
"""
Return `True` if this `char` is part of this node's letter set,
`False` otherwise.
"""
char = char.lower()
return bool(cgaddag.gdg_is_end(self.gdg, self.node, char.encode("ascii"))) | def is_end(self, char):
"""
Return `True` if this `char` is part of this node's letter set,
`False` otherwise.
"""
char = char.lower()
return bool(cgaddag.gdg_is_end(self.gdg, self.node, char.encode("ascii"))) | [
"Return",
"True",
"if",
"this",
"char",
"is",
"part",
"of",
"this",
"node",
"s",
"letter",
"set",
"False",
"otherwise",
"."
] | jorbas/GADDAG | python | https://github.com/jorbas/GADDAG/blob/a0ede3def715c586e1f273d96e9fc0d537cd9561/gaddag/node.py#L85-L92 | [
"def",
"is_end",
"(",
"self",
",",
"char",
")",
":",
"char",
"=",
"char",
".",
"lower",
"(",
")",
"return",
"bool",
"(",
"cgaddag",
".",
"gdg_is_end",
"(",
"self",
".",
"gdg",
",",
"self",
".",
"node",
",",
"char",
".",
"encode",
"(",
"\"ascii\"",
... | a0ede3def715c586e1f273d96e9fc0d537cd9561 |
train | Node.follow | Traverse the GADDAG to the node at the end of the given characters.
Args:
chars: An string of characters to traverse in the GADDAG.
Returns:
The Node which is found by traversing the tree. | gaddag/node.py | def follow(self, chars):
"""
Traverse the GADDAG to the node at the end of the given characters.
Args:
chars: An string of characters to traverse in the GADDAG.
Returns:
The Node which is found by traversing the tree.
"""
chars = chars.lower()
... | def follow(self, chars):
"""
Traverse the GADDAG to the node at the end of the given characters.
Args:
chars: An string of characters to traverse in the GADDAG.
Returns:
The Node which is found by traversing the tree.
"""
chars = chars.lower()
... | [
"Traverse",
"the",
"GADDAG",
"to",
"the",
"node",
"at",
"the",
"end",
"of",
"the",
"given",
"characters",
"."
] | jorbas/GADDAG | python | https://github.com/jorbas/GADDAG/blob/a0ede3def715c586e1f273d96e9fc0d537cd9561/gaddag/node.py#L94-L112 | [
"def",
"follow",
"(",
"self",
",",
"chars",
")",
":",
"chars",
"=",
"chars",
".",
"lower",
"(",
")",
"node",
"=",
"self",
".",
"node",
"for",
"char",
"in",
"chars",
":",
"node",
"=",
"cgaddag",
".",
"gdg_follow_edge",
"(",
"self",
".",
"gdg",
",",
... | a0ede3def715c586e1f273d96e9fc0d537cd9561 |
train | _split_docker_link | Splits a docker link string into a list of 3 items (protocol, host, port).
- Assumes IPv4 Docker links
ex: _split_docker_link('DB') -> ['tcp', '172.17.0.82', '8080'] | envitro/docker.py | def _split_docker_link(alias_name):
"""
Splits a docker link string into a list of 3 items (protocol, host, port).
- Assumes IPv4 Docker links
ex: _split_docker_link('DB') -> ['tcp', '172.17.0.82', '8080']
"""
sanitized_name = alias_name.strip().upper()
split_list = re.split(r':|//', core.s... | def _split_docker_link(alias_name):
"""
Splits a docker link string into a list of 3 items (protocol, host, port).
- Assumes IPv4 Docker links
ex: _split_docker_link('DB') -> ['tcp', '172.17.0.82', '8080']
"""
sanitized_name = alias_name.strip().upper()
split_list = re.split(r':|//', core.s... | [
"Splits",
"a",
"docker",
"link",
"string",
"into",
"a",
"list",
"of",
"3",
"items",
"(",
"protocol",
"host",
"port",
")",
".",
"-",
"Assumes",
"IPv4",
"Docker",
"links"
] | MarcMeszaros/envitro | python | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/docker.py#L14-L25 | [
"def",
"_split_docker_link",
"(",
"alias_name",
")",
":",
"sanitized_name",
"=",
"alias_name",
".",
"strip",
"(",
")",
".",
"upper",
"(",
")",
"split_list",
"=",
"re",
".",
"split",
"(",
"r':|//'",
",",
"core",
".",
"str",
"(",
"'{0}_PORT'",
".",
"format... | 19e925cd152c08d4db8126542afed35188cafff4 |
train | read | Get the raw docker link value.
Get the raw environment variable for the docker link
Args:
alias_name: The environment variable name
default: The default value if the link isn't available
allow_none: If the return value can be `None` (i.e. optional) | envitro/docker.py | def read(alias_name, allow_none=False):
"""Get the raw docker link value.
Get the raw environment variable for the docker link
Args:
alias_name: The environment variable name
default: The default value if the link isn't available
allow_none: If the return value can be `None` (i.e. ... | def read(alias_name, allow_none=False):
"""Get the raw docker link value.
Get the raw environment variable for the docker link
Args:
alias_name: The environment variable name
default: The default value if the link isn't available
allow_none: If the return value can be `None` (i.e. ... | [
"Get",
"the",
"raw",
"docker",
"link",
"value",
"."
] | MarcMeszaros/envitro | python | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/docker.py#L28-L39 | [
"def",
"read",
"(",
"alias_name",
",",
"allow_none",
"=",
"False",
")",
":",
"warnings",
".",
"warn",
"(",
"'Will be removed in v1.0'",
",",
"DeprecationWarning",
",",
"stacklevel",
"=",
"2",
")",
"return",
"core",
".",
"read",
"(",
"'{0}_PORT'",
".",
"forma... | 19e925cd152c08d4db8126542afed35188cafff4 |
train | isset | Return a boolean if the docker link is set or not and is a valid looking docker link value.
Args:
alias_name: The link alias name | envitro/docker.py | def isset(alias_name):
"""Return a boolean if the docker link is set or not and is a valid looking docker link value.
Args:
alias_name: The link alias name
"""
warnings.warn('Will be removed in v1.0', DeprecationWarning, stacklevel=2)
raw_value = read(alias_name, allow_none=True)
if raw... | def isset(alias_name):
"""Return a boolean if the docker link is set or not and is a valid looking docker link value.
Args:
alias_name: The link alias name
"""
warnings.warn('Will be removed in v1.0', DeprecationWarning, stacklevel=2)
raw_value = read(alias_name, allow_none=True)
if raw... | [
"Return",
"a",
"boolean",
"if",
"the",
"docker",
"link",
"is",
"set",
"or",
"not",
"and",
"is",
"a",
"valid",
"looking",
"docker",
"link",
"value",
"."
] | MarcMeszaros/envitro | python | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/docker.py#L47-L62 | [
"def",
"isset",
"(",
"alias_name",
")",
":",
"warnings",
".",
"warn",
"(",
"'Will be removed in v1.0'",
",",
"DeprecationWarning",
",",
"stacklevel",
"=",
"2",
")",
"raw_value",
"=",
"read",
"(",
"alias_name",
",",
"allow_none",
"=",
"True",
")",
"if",
"raw_... | 19e925cd152c08d4db8126542afed35188cafff4 |
train | protocol | Get the protocol from the docker link alias or return the default.
Args:
alias_name: The docker link alias
default: The default value if the link isn't available
allow_none: If the return value can be `None` (i.e. optional)
Examples:
Assuming a Docker link was created with ``do... | envitro/docker.py | def protocol(alias_name, default=None, allow_none=False):
"""Get the protocol from the docker link alias or return the default.
Args:
alias_name: The docker link alias
default: The default value if the link isn't available
allow_none: If the return value can be `None` (i.e. optional)
... | def protocol(alias_name, default=None, allow_none=False):
"""Get the protocol from the docker link alias or return the default.
Args:
alias_name: The docker link alias
default: The default value if the link isn't available
allow_none: If the return value can be `None` (i.e. optional)
... | [
"Get",
"the",
"protocol",
"from",
"the",
"docker",
"link",
"alias",
"or",
"return",
"the",
"default",
"."
] | MarcMeszaros/envitro | python | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/docker.py#L64-L86 | [
"def",
"protocol",
"(",
"alias_name",
",",
"default",
"=",
"None",
",",
"allow_none",
"=",
"False",
")",
":",
"warnings",
".",
"warn",
"(",
"'Will be removed in v1.0'",
",",
"DeprecationWarning",
",",
"stacklevel",
"=",
"2",
")",
"try",
":",
"return",
"_spli... | 19e925cd152c08d4db8126542afed35188cafff4 |
train | port | Get the port from the docker link alias or return the default.
Args:
alias_name: The docker link alias
default: The default value if the link isn't available
allow_none: If the return value can be `None` (i.e. optional)
Examples:
Assuming a Docker link was created with ``docker... | envitro/docker.py | def port(alias_name, default=None, allow_none=False):
"""Get the port from the docker link alias or return the default.
Args:
alias_name: The docker link alias
default: The default value if the link isn't available
allow_none: If the return value can be `None` (i.e. optional)
Examp... | def port(alias_name, default=None, allow_none=False):
"""Get the port from the docker link alias or return the default.
Args:
alias_name: The docker link alias
default: The default value if the link isn't available
allow_none: If the return value can be `None` (i.e. optional)
Examp... | [
"Get",
"the",
"port",
"from",
"the",
"docker",
"link",
"alias",
"or",
"return",
"the",
"default",
"."
] | MarcMeszaros/envitro | python | https://github.com/MarcMeszaros/envitro/blob/19e925cd152c08d4db8126542afed35188cafff4/envitro/docker.py#L114-L136 | [
"def",
"port",
"(",
"alias_name",
",",
"default",
"=",
"None",
",",
"allow_none",
"=",
"False",
")",
":",
"warnings",
".",
"warn",
"(",
"'Will be removed in v1.0'",
",",
"DeprecationWarning",
",",
"stacklevel",
"=",
"2",
")",
"try",
":",
"return",
"int",
"... | 19e925cd152c08d4db8126542afed35188cafff4 |
train | SixteenS.runner | Run the necessary methods in the correct order | sixteenS/sixteenS.py | def runner(self):
"""
Run the necessary methods in the correct order
"""
printtime('Starting {} analysis pipeline'.format(self.analysistype), self.starttime)
if not self.pipeline:
# If the metadata has been passed from the method script, self.pipeline must still be fa... | def runner(self):
"""
Run the necessary methods in the correct order
"""
printtime('Starting {} analysis pipeline'.format(self.analysistype), self.starttime)
if not self.pipeline:
# If the metadata has been passed from the method script, self.pipeline must still be fa... | [
"Run",
"the",
"necessary",
"methods",
"in",
"the",
"correct",
"order"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteenS.py#L14-L37 | [
"def",
"runner",
"(",
"self",
")",
":",
"printtime",
"(",
"'Starting {} analysis pipeline'",
".",
"format",
"(",
"self",
".",
"analysistype",
")",
",",
"self",
".",
"starttime",
")",
"if",
"not",
"self",
".",
"pipeline",
":",
"# If the metadata has been passed f... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | SixteenS.attributer | Parses the 16S target files to link accession numbers stored in the .fai and metadata files to the genera stored
in the target file | sixteenS/sixteenS.py | def attributer(self):
"""
Parses the 16S target files to link accession numbers stored in the .fai and metadata files to the genera stored
in the target file
"""
from Bio import SeqIO
import operator
for sample in self.runmetadata.samples:
# Load the r... | def attributer(self):
"""
Parses the 16S target files to link accession numbers stored in the .fai and metadata files to the genera stored
in the target file
"""
from Bio import SeqIO
import operator
for sample in self.runmetadata.samples:
# Load the r... | [
"Parses",
"the",
"16S",
"target",
"files",
"to",
"link",
"accession",
"numbers",
"stored",
"in",
"the",
".",
"fai",
"and",
"metadata",
"files",
"to",
"the",
"genera",
"stored",
"in",
"the",
"target",
"file"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteenS.py#L39-L76 | [
"def",
"attributer",
"(",
"self",
")",
":",
"from",
"Bio",
"import",
"SeqIO",
"import",
"operator",
"for",
"sample",
"in",
"self",
".",
"runmetadata",
".",
"samples",
":",
"# Load the records from the target file into a dictionary",
"record_dict",
"=",
"SeqIO",
".",... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | SixteenS.reporter | Creates a report of the results | sixteenS/sixteenS.py | def reporter(self):
"""
Creates a report of the results
"""
# Create the path in which the reports are stored
make_path(self.reportpath)
header = 'Strain,Gene,PercentIdentity,Genus,FoldCoverage\n'
data = ''
with open(os.path.join(self.reportpath, self.anal... | def reporter(self):
"""
Creates a report of the results
"""
# Create the path in which the reports are stored
make_path(self.reportpath)
header = 'Strain,Gene,PercentIdentity,Genus,FoldCoverage\n'
data = ''
with open(os.path.join(self.reportpath, self.anal... | [
"Creates",
"a",
"report",
"of",
"the",
"results"
] | OLC-Bioinformatics/sipprverse | python | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sixteenS/sixteenS.py#L79-L102 | [
"def",
"reporter",
"(",
"self",
")",
":",
"# Create the path in which the reports are stored",
"make_path",
"(",
"self",
".",
"reportpath",
")",
"header",
"=",
"'Strain,Gene,PercentIdentity,Genus,FoldCoverage\\n'",
"data",
"=",
"''",
"with",
"open",
"(",
"os",
".",
"p... | d4f10cdf8e1a39dac0953db61c21c97efc6006de |
train | spawn_server_api | Take a a Flask app and a swagger file in YAML format describing a REST
API, and populate the app with routes handling all the paths and methods
declared in the swagger file.
Also handle marshaling and unmarshaling between json and object instances
representing the definitions from the swagger file. | pymacaron_core/swagger/server.py | def spawn_server_api(api_name, app, api_spec, error_callback, decorator):
"""Take a a Flask app and a swagger file in YAML format describing a REST
API, and populate the app with routes handling all the paths and methods
declared in the swagger file.
Also handle marshaling and unmarshaling between json... | def spawn_server_api(api_name, app, api_spec, error_callback, decorator):
"""Take a a Flask app and a swagger file in YAML format describing a REST
API, and populate the app with routes handling all the paths and methods
declared in the swagger file.
Also handle marshaling and unmarshaling between json... | [
"Take",
"a",
"a",
"Flask",
"app",
"and",
"a",
"swagger",
"file",
"in",
"YAML",
"format",
"describing",
"a",
"REST",
"API",
"and",
"populate",
"the",
"app",
"with",
"routes",
"handling",
"all",
"the",
"paths",
"and",
"methods",
"declared",
"in",
"the",
"s... | pymacaron/pymacaron-core | python | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/server.py#L22-L46 | [
"def",
"spawn_server_api",
"(",
"api_name",
",",
"app",
",",
"api_spec",
",",
"error_callback",
",",
"decorator",
")",
":",
"def",
"mycallback",
"(",
"endpoint",
")",
":",
"handler_func",
"=",
"get_function",
"(",
"endpoint",
".",
"handler_server",
")",
"# Gen... | 95070a39ed7065a84244ff5601fea4d54cc72b66 |
train | _responsify | Take a bravado-core model representing an error, and return a Flask Response
with the given error code and error instance as body | pymacaron_core/swagger/server.py | def _responsify(api_spec, error, status):
"""Take a bravado-core model representing an error, and return a Flask Response
with the given error code and error instance as body"""
result_json = api_spec.model_to_json(error)
r = jsonify(result_json)
r.status_code = status
return r | def _responsify(api_spec, error, status):
"""Take a bravado-core model representing an error, and return a Flask Response
with the given error code and error instance as body"""
result_json = api_spec.model_to_json(error)
r = jsonify(result_json)
r.status_code = status
return r | [
"Take",
"a",
"bravado",
"-",
"core",
"model",
"representing",
"an",
"error",
"and",
"return",
"a",
"Flask",
"Response",
"with",
"the",
"given",
"error",
"code",
"and",
"error",
"instance",
"as",
"body"
] | pymacaron/pymacaron-core | python | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/server.py#L49-L55 | [
"def",
"_responsify",
"(",
"api_spec",
",",
"error",
",",
"status",
")",
":",
"result_json",
"=",
"api_spec",
".",
"model_to_json",
"(",
"error",
")",
"r",
"=",
"jsonify",
"(",
"result_json",
")",
"r",
".",
"status_code",
"=",
"status",
"return",
"r"
] | 95070a39ed7065a84244ff5601fea4d54cc72b66 |
train | _generate_handler_wrapper | Generate a handler method for the given url method+path and operation | pymacaron_core/swagger/server.py | def _generate_handler_wrapper(api_name, api_spec, endpoint, handler_func, error_callback, global_decorator):
"""Generate a handler method for the given url method+path and operation"""
# Decorate the handler function, if Swagger spec tells us to
if endpoint.decorate_server:
endpoint_decorator = get... | def _generate_handler_wrapper(api_name, api_spec, endpoint, handler_func, error_callback, global_decorator):
"""Generate a handler method for the given url method+path and operation"""
# Decorate the handler function, if Swagger spec tells us to
if endpoint.decorate_server:
endpoint_decorator = get... | [
"Generate",
"a",
"handler",
"method",
"for",
"the",
"given",
"url",
"method",
"+",
"path",
"and",
"operation"
] | pymacaron/pymacaron-core | python | https://github.com/pymacaron/pymacaron-core/blob/95070a39ed7065a84244ff5601fea4d54cc72b66/pymacaron_core/swagger/server.py#L58-L178 | [
"def",
"_generate_handler_wrapper",
"(",
"api_name",
",",
"api_spec",
",",
"endpoint",
",",
"handler_func",
",",
"error_callback",
",",
"global_decorator",
")",
":",
"# Decorate the handler function, if Swagger spec tells us to",
"if",
"endpoint",
".",
"decorate_server",
":... | 95070a39ed7065a84244ff5601fea4d54cc72b66 |
train | format_escape | Returns the ANSI escape sequence to set character formatting.
foreground
Foreground colour to use. Accepted types: None, int (xterm
palette ID), tuple (RGB, RGBA), Colour
background
Background colour to use. Accepted types: None, int (xterm
palette ID), tuple (RGB, RGBA), Colou... | mrcrowbar/ansi.py | def format_escape( foreground=None, background=None, bold=False, faint=False,
italic=False, underline=False, blink=False, inverted=False ):
"""Returns the ANSI escape sequence to set character formatting.
foreground
Foreground colour to use. Accepted types: None, int (xterm
palette ID), tup... | def format_escape( foreground=None, background=None, bold=False, faint=False,
italic=False, underline=False, blink=False, inverted=False ):
"""Returns the ANSI escape sequence to set character formatting.
foreground
Foreground colour to use. Accepted types: None, int (xterm
palette ID), tup... | [
"Returns",
"the",
"ANSI",
"escape",
"sequence",
"to",
"set",
"character",
"formatting",
"."
] | moralrecordings/mrcrowbar | python | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/ansi.py#L44-L109 | [
"def",
"format_escape",
"(",
"foreground",
"=",
"None",
",",
"background",
"=",
"None",
",",
"bold",
"=",
"False",
",",
"faint",
"=",
"False",
",",
"italic",
"=",
"False",
",",
"underline",
"=",
"False",
",",
"blink",
"=",
"False",
",",
"inverted",
"="... | b1ed882c4555552e7656b2d84aca543184577fa3 |
train | format_string | Returns a Unicode string formatted with an ANSI escape sequence.
string
String to format
foreground
Foreground colour to use. Accepted types: None, int (xterm
palette ID), tuple (RGB, RGBA), Colour
background
Background colour to use. Accepted types: None, int (xterm
... | mrcrowbar/ansi.py | def format_string( string, foreground=None, background=None, reset=True, bold=False,
faint=False, italic=False, underline=False, blink=False, inverted=False ):
"""Returns a Unicode string formatted with an ANSI escape sequence.
string
String to format
foreground
Foreground colour to us... | def format_string( string, foreground=None, background=None, reset=True, bold=False,
faint=False, italic=False, underline=False, blink=False, inverted=False ):
"""Returns a Unicode string formatted with an ANSI escape sequence.
string
String to format
foreground
Foreground colour to us... | [
"Returns",
"a",
"Unicode",
"string",
"formatted",
"with",
"an",
"ANSI",
"escape",
"sequence",
"."
] | moralrecordings/mrcrowbar | python | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/ansi.py#L112-L152 | [
"def",
"format_string",
"(",
"string",
",",
"foreground",
"=",
"None",
",",
"background",
"=",
"None",
",",
"reset",
"=",
"True",
",",
"bold",
"=",
"False",
",",
"faint",
"=",
"False",
",",
"italic",
"=",
"False",
",",
"underline",
"=",
"False",
",",
... | b1ed882c4555552e7656b2d84aca543184577fa3 |
train | format_pixels | Return the ANSI escape sequence to render two vertically-stacked pixels as a
single monospace character.
top
Top colour to use. Accepted types: None, int (xterm
palette ID), tuple (RGB, RGBA), Colour
bottom
Bottom colour to use. Accepted types: None, int (xterm
palette ID),... | mrcrowbar/ansi.py | def format_pixels( top, bottom, reset=True, repeat=1 ):
"""Return the ANSI escape sequence to render two vertically-stacked pixels as a
single monospace character.
top
Top colour to use. Accepted types: None, int (xterm
palette ID), tuple (RGB, RGBA), Colour
bottom
Bottom colou... | def format_pixels( top, bottom, reset=True, repeat=1 ):
"""Return the ANSI escape sequence to render two vertically-stacked pixels as a
single monospace character.
top
Top colour to use. Accepted types: None, int (xterm
palette ID), tuple (RGB, RGBA), Colour
bottom
Bottom colou... | [
"Return",
"the",
"ANSI",
"escape",
"sequence",
"to",
"render",
"two",
"vertically",
"-",
"stacked",
"pixels",
"as",
"a",
"single",
"monospace",
"character",
"."
] | moralrecordings/mrcrowbar | python | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/ansi.py#L155-L221 | [
"def",
"format_pixels",
"(",
"top",
",",
"bottom",
",",
"reset",
"=",
"True",
",",
"repeat",
"=",
"1",
")",
":",
"top_src",
"=",
"None",
"if",
"isinstance",
"(",
"top",
",",
"int",
")",
":",
"top_src",
"=",
"top",
"else",
":",
"top_rgba",
"=",
"col... | b1ed882c4555552e7656b2d84aca543184577fa3 |
train | format_image_iter | Return the ANSI escape sequence to render a bitmap image.
data_fetch
Function that takes three arguments (x position, y position, and frame) and returns
a Colour corresponding to the pixel stored there, or Transparent if the requested
pixel is out of bounds.
x_start
Offset fro... | mrcrowbar/ansi.py | def format_image_iter( data_fetch, x_start=0, y_start=0, width=32, height=32, frame=0, columns=1, downsample=1 ):
"""Return the ANSI escape sequence to render a bitmap image.
data_fetch
Function that takes three arguments (x position, y position, and frame) and returns
a Colour corresponding to... | def format_image_iter( data_fetch, x_start=0, y_start=0, width=32, height=32, frame=0, columns=1, downsample=1 ):
"""Return the ANSI escape sequence to render a bitmap image.
data_fetch
Function that takes three arguments (x position, y position, and frame) and returns
a Colour corresponding to... | [
"Return",
"the",
"ANSI",
"escape",
"sequence",
"to",
"render",
"a",
"bitmap",
"image",
"."
] | moralrecordings/mrcrowbar | python | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/ansi.py#L282-L338 | [
"def",
"format_image_iter",
"(",
"data_fetch",
",",
"x_start",
"=",
"0",
",",
"y_start",
"=",
"0",
",",
"width",
"=",
"32",
",",
"height",
"=",
"32",
",",
"frame",
"=",
"0",
",",
"columns",
"=",
"1",
",",
"downsample",
"=",
"1",
")",
":",
"frames",... | b1ed882c4555552e7656b2d84aca543184577fa3 |
train | Field.update_buffer_with_value | Write a Python object into a byte array, using the field definition.
value
Input Python object to process.
buffer
Output byte array to encode value into.
parent
Parent block object where this Field is defined. Used for e.g.
evaluating Refs. | mrcrowbar/fields.py | def update_buffer_with_value( self, value, buffer, parent=None ):
"""Write a Python object into a byte array, using the field definition.
value
Input Python object to process.
buffer
Output byte array to encode value into.
parent
Parent block object... | def update_buffer_with_value( self, value, buffer, parent=None ):
"""Write a Python object into a byte array, using the field definition.
value
Input Python object to process.
buffer
Output byte array to encode value into.
parent
Parent block object... | [
"Write",
"a",
"Python",
"object",
"into",
"a",
"byte",
"array",
"using",
"the",
"field",
"definition",
"."
] | moralrecordings/mrcrowbar | python | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/fields.py#L72-L87 | [
"def",
"update_buffer_with_value",
"(",
"self",
",",
"value",
",",
"buffer",
",",
"parent",
"=",
"None",
")",
":",
"assert",
"common",
".",
"is_bytes",
"(",
"buffer",
")",
"self",
".",
"validate",
"(",
"value",
",",
"parent",
")",
"return"
] | b1ed882c4555552e7656b2d84aca543184577fa3 |
train | Field.get_end_offset | Return the end offset of the Field's data. Useful for chainloading.
value
Input Python object to process.
parent
Parent block object where this Field is defined. Used for e.g.
evaluating Refs.
index
Index of the Python object to measure from. Us... | mrcrowbar/fields.py | def get_end_offset( self, value, parent=None, index=None ):
"""Return the end offset of the Field's data. Useful for chainloading.
value
Input Python object to process.
parent
Parent block object where this Field is defined. Used for e.g.
evaluating Refs.
... | def get_end_offset( self, value, parent=None, index=None ):
"""Return the end offset of the Field's data. Useful for chainloading.
value
Input Python object to process.
parent
Parent block object where this Field is defined. Used for e.g.
evaluating Refs.
... | [
"Return",
"the",
"end",
"offset",
"of",
"the",
"Field",
"s",
"data",
".",
"Useful",
"for",
"chainloading",
"."
] | moralrecordings/mrcrowbar | python | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/fields.py#L123-L137 | [
"def",
"get_end_offset",
"(",
"self",
",",
"value",
",",
"parent",
"=",
"None",
",",
"index",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_start_offset",
"(",
"value",
",",
"parent",
",",
"index",
")",
"+",
"self",
".",
"get_size",
"(",
"value",
... | b1ed882c4555552e7656b2d84aca543184577fa3 |
train | nonalpha_split | Split 'string' along any punctuation or whitespace. | finnsyll/utilities.py | def nonalpha_split(string):
'''Split 'string' along any punctuation or whitespace.'''
return re.findall(r'[%s]+|[^%s]+' % (A, A), string, flags=FLAGS) | def nonalpha_split(string):
'''Split 'string' along any punctuation or whitespace.'''
return re.findall(r'[%s]+|[^%s]+' % (A, A), string, flags=FLAGS) | [
"Split",
"string",
"along",
"any",
"punctuation",
"or",
"whitespace",
"."
] | tsnaomi/finnsyll | python | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/utilities.py#L16-L18 | [
"def",
"nonalpha_split",
"(",
"string",
")",
":",
"return",
"re",
".",
"findall",
"(",
"r'[%s]+|[^%s]+'",
"%",
"(",
"A",
",",
"A",
")",
",",
"string",
",",
"flags",
"=",
"FLAGS",
")"
] | 6a42740311688c946a636a3e2304866c7aa041b3 |
train | syllable_split | Split 'string' into (stressed) syllables and punctuation/whitespace. | finnsyll/utilities.py | def syllable_split(string):
'''Split 'string' into (stressed) syllables and punctuation/whitespace.'''
p = r'\'[%s]+|`[%s]+|[%s]+|[^%s\'`\.]+|[^\.]{1}' % (A, A, A, A)
return re.findall(p, string, flags=FLAGS) | def syllable_split(string):
'''Split 'string' into (stressed) syllables and punctuation/whitespace.'''
p = r'\'[%s]+|`[%s]+|[%s]+|[^%s\'`\.]+|[^\.]{1}' % (A, A, A, A)
return re.findall(p, string, flags=FLAGS) | [
"Split",
"string",
"into",
"(",
"stressed",
")",
"syllables",
"and",
"punctuation",
"/",
"whitespace",
"."
] | tsnaomi/finnsyll | python | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/utilities.py#L21-L24 | [
"def",
"syllable_split",
"(",
"string",
")",
":",
"p",
"=",
"r'\\'[%s]+|`[%s]+|[%s]+|[^%s\\'`\\.]+|[^\\.]{1}'",
"%",
"(",
"A",
",",
"A",
",",
"A",
",",
"A",
")",
"return",
"re",
".",
"findall",
"(",
"p",
",",
"string",
",",
"flags",
"=",
"FLAGS",
")"
] | 6a42740311688c946a636a3e2304866c7aa041b3 |
train | extract_words | Extract all alphabetic syllabified forms from 'string'. | finnsyll/utilities.py | def extract_words(string):
'''Extract all alphabetic syllabified forms from 'string'.'''
return re.findall(r'[%s]+[%s\.]*[%s]+' % (A, A, A), string, flags=FLAGS) | def extract_words(string):
'''Extract all alphabetic syllabified forms from 'string'.'''
return re.findall(r'[%s]+[%s\.]*[%s]+' % (A, A, A), string, flags=FLAGS) | [
"Extract",
"all",
"alphabetic",
"syllabified",
"forms",
"from",
"string",
"."
] | tsnaomi/finnsyll | python | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/utilities.py#L27-L29 | [
"def",
"extract_words",
"(",
"string",
")",
":",
"return",
"re",
".",
"findall",
"(",
"r'[%s]+[%s\\.]*[%s]+'",
"%",
"(",
"A",
",",
"A",
",",
"A",
")",
",",
"string",
",",
"flags",
"=",
"FLAGS",
")"
] | 6a42740311688c946a636a3e2304866c7aa041b3 |
train | init_threads | Should define dummyThread class and dummySignal class | pyDLib/Core/threads.py | def init_threads(t=None, s=None):
"""Should define dummyThread class and dummySignal class"""
global THREAD, SIGNAL
THREAD = t or dummyThread
SIGNAL = s or dummySignal | def init_threads(t=None, s=None):
"""Should define dummyThread class and dummySignal class"""
global THREAD, SIGNAL
THREAD = t or dummyThread
SIGNAL = s or dummySignal | [
"Should",
"define",
"dummyThread",
"class",
"and",
"dummySignal",
"class"
] | benoitkugler/abstractDataLibrary | python | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/threads.py#L6-L10 | [
"def",
"init_threads",
"(",
"t",
"=",
"None",
",",
"s",
"=",
"None",
")",
":",
"global",
"THREAD",
",",
"SIGNAL",
"THREAD",
"=",
"t",
"or",
"dummyThread",
"SIGNAL",
"=",
"s",
"or",
"dummySignal"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.