repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/phenotype.py | PhenotypeActions.update_hpolist | def update_hpolist(self, case_obj):
"""Update the HPO gene list for a case based on current terms."""
hpo_list = self.case_genelist(case_obj)
hpo_results = hpo_genes(case_obj.phenotype_ids(),
*self.phenomizer_auth)
if hpo_results is None:
pass... | python | def update_hpolist(self, case_obj):
"""Update the HPO gene list for a case based on current terms."""
hpo_list = self.case_genelist(case_obj)
hpo_results = hpo_genes(case_obj.phenotype_ids(),
*self.phenomizer_auth)
if hpo_results is None:
pass... | [
"def",
"update_hpolist",
"(",
"self",
",",
"case_obj",
")",
":",
"hpo_list",
"=",
"self",
".",
"case_genelist",
"(",
"case_obj",
")",
"hpo_results",
"=",
"hpo_genes",
"(",
"case_obj",
".",
"phenotype_ids",
"(",
")",
",",
"*",
"self",
".",
"phenomizer_auth",
... | Update the HPO gene list for a case based on current terms. | [
"Update",
"the",
"HPO",
"gene",
"list",
"for",
"a",
"case",
"based",
"on",
"current",
"terms",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/phenotype.py#L41-L55 | train | Update the HPO gene list for a case based on current terms. |
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/phenotype.py | PhenotypeActions.remove_phenotype | def remove_phenotype(self, ind_obj, phenotypes=None):
"""Remove multiple phenotypes from an individual."""
if phenotypes is None:
logger.info("delete all phenotypes related to %s", ind_obj.ind_id)
self.query(PhenotypeTerm).filter_by(ind_id=ind_obj.id).delete()
else:
... | python | def remove_phenotype(self, ind_obj, phenotypes=None):
"""Remove multiple phenotypes from an individual."""
if phenotypes is None:
logger.info("delete all phenotypes related to %s", ind_obj.ind_id)
self.query(PhenotypeTerm).filter_by(ind_id=ind_obj.id).delete()
else:
... | [
"def",
"remove_phenotype",
"(",
"self",
",",
"ind_obj",
",",
"phenotypes",
"=",
"None",
")",
":",
"if",
"phenotypes",
"is",
"None",
":",
"logger",
".",
"info",
"(",
"\"delete all phenotypes related to %s\"",
",",
"ind_obj",
".",
"ind_id",
")",
"self",
".",
"... | Remove multiple phenotypes from an individual. | [
"Remove",
"multiple",
"phenotypes",
"from",
"an",
"individual",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/phenotype.py#L57-L71 | train | Remove multiple phenotypes from an individual. |
thautwarm/Redy | Redy/ADT/Core.py | data | def data(cls_def: type):
"""
>>> from Redy.ADT.Core import data
>>> from Redy.Magic.Classic import cast
>>> from Redy.ADT.traits import ConsInd, Discrete
>>> @data
>>> class S(ConsInd): # ConsInd class makes it available to index from this data as from a tuple.
>>> a: '1'
>>> b: l... | python | def data(cls_def: type):
"""
>>> from Redy.ADT.Core import data
>>> from Redy.Magic.Classic import cast
>>> from Redy.ADT.traits import ConsInd, Discrete
>>> @data
>>> class S(ConsInd): # ConsInd class makes it available to index from this data as from a tuple.
>>> a: '1'
>>> b: l... | [
"def",
"data",
"(",
"cls_def",
":",
"type",
")",
":",
"__annotations__",
"=",
"cls_def",
".",
"__annotations__",
"def",
"constructor_descriptor",
"(",
"f",
")",
":",
"return",
"discrete_cache",
"(",
"f",
")",
"if",
"issubclass",
"(",
"cls_def",
",",
"Discret... | >>> from Redy.ADT.Core import data
>>> from Redy.Magic.Classic import cast
>>> from Redy.ADT.traits import ConsInd, Discrete
>>> @data
>>> class S(ConsInd): # ConsInd class makes it available to index from this data as from a tuple.
>>> a: '1'
>>> b: lambda x: x
>>> c: lambda x, y ... | [
">>>",
"from",
"Redy",
".",
"ADT",
".",
"Core",
"import",
"data",
">>>",
"from",
"Redy",
".",
"Magic",
".",
"Classic",
"import",
"cast",
">>>",
"from",
"Redy",
".",
"ADT",
".",
"traits",
"import",
"ConsInd",
"Discrete",
">>>",
"@data",
">>>",
"class",
... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/ADT/Core.py#L12-L137 | train | A simple data structure for a given class. |
thautwarm/Redy | Redy/ADT/Core.py | match | def match(mode_lst: list, obj: 'object that has __destruct__ method'):
"""
>>> from Redy.ADT.Core import match, data, P
>>> from Redy.ADT.traits import ConsInd, Discrete
>>> @data
>>> class List(ConsInd, Discrete):
>>> # ConsInd(index following constructing)
>>> # |-> Ind;
>>>... | python | def match(mode_lst: list, obj: 'object that has __destruct__ method'):
"""
>>> from Redy.ADT.Core import match, data, P
>>> from Redy.ADT.traits import ConsInd, Discrete
>>> @data
>>> class List(ConsInd, Discrete):
>>> # ConsInd(index following constructing)
>>> # |-> Ind;
>>>... | [
"def",
"match",
"(",
"mode_lst",
":",
"list",
",",
"obj",
":",
"'object that has __destruct__ method'",
")",
":",
"# noinspection PyUnresolvedReferences",
"try",
":",
"# noinspection PyUnresolvedReferences",
"structure",
"=",
"obj",
".",
"__destruct__",
"(",
")",
"excep... | >>> from Redy.ADT.Core import match, data, P
>>> from Redy.ADT.traits import ConsInd, Discrete
>>> @data
>>> class List(ConsInd, Discrete):
>>> # ConsInd(index following constructing)
>>> # |-> Ind;
>>> # Discrete
>>> # |-> Im(Immutable), Eq
>>> Nil : ...
>>... | [
">>>",
"from",
"Redy",
".",
"ADT",
".",
"Core",
"import",
"match",
"data",
"P",
">>>",
"from",
"Redy",
".",
"ADT",
".",
"traits",
"import",
"ConsInd",
"Discrete",
">>>"
] | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/ADT/Core.py#L185-L227 | train | Returns True if mode_lst matches obj. |
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/gemini.py | GeminiActions.gemini_query | def gemini_query(self, query_id):
"""Return a gemini query
Args:
name (str)
"""
logger.debug("Looking for query with id {0}".format(query_id))
return self.query(GeminiQuery).filter_by(id=query_id).first() | python | def gemini_query(self, query_id):
"""Return a gemini query
Args:
name (str)
"""
logger.debug("Looking for query with id {0}".format(query_id))
return self.query(GeminiQuery).filter_by(id=query_id).first() | [
"def",
"gemini_query",
"(",
"self",
",",
"query_id",
")",
":",
"logger",
".",
"debug",
"(",
"\"Looking for query with id {0}\"",
".",
"format",
"(",
"query_id",
")",
")",
"return",
"self",
".",
"query",
"(",
"GeminiQuery",
")",
".",
"filter_by",
"(",
"id",
... | Return a gemini query
Args:
name (str) | [
"Return",
"a",
"gemini",
"query"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/gemini.py#L10-L17 | train | Returns a gemini query |
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/gemini.py | GeminiActions.add_gemini_query | def add_gemini_query(self, name, query):
"""Add a user defined gemini query
Args:
name (str)
query (str)
"""
logger.info("Adding query {0} with text {1}".format(name, query))
new_query = GeminiQuery(name=name, query=query)
self.session.add(new_que... | python | def add_gemini_query(self, name, query):
"""Add a user defined gemini query
Args:
name (str)
query (str)
"""
logger.info("Adding query {0} with text {1}".format(name, query))
new_query = GeminiQuery(name=name, query=query)
self.session.add(new_que... | [
"def",
"add_gemini_query",
"(",
"self",
",",
"name",
",",
"query",
")",
":",
"logger",
".",
"info",
"(",
"\"Adding query {0} with text {1}\"",
".",
"format",
"(",
"name",
",",
"query",
")",
")",
"new_query",
"=",
"GeminiQuery",
"(",
"name",
"=",
"name",
",... | Add a user defined gemini query
Args:
name (str)
query (str) | [
"Add",
"a",
"user",
"defined",
"gemini",
"query"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/gemini.py#L23-L34 | train | Add a user defined gemini query to the session |
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/gemini.py | GeminiActions.delete_gemini_query | def delete_gemini_query(self, query_id):
"""Delete a gemini query
Args:
name (str)
"""
query_obj = self.gemini_query(query_id)
logger.debug("Delete query: {0}".format(query_obj.name_query))
self.session.delete(query_obj)
self.save() | python | def delete_gemini_query(self, query_id):
"""Delete a gemini query
Args:
name (str)
"""
query_obj = self.gemini_query(query_id)
logger.debug("Delete query: {0}".format(query_obj.name_query))
self.session.delete(query_obj)
self.save() | [
"def",
"delete_gemini_query",
"(",
"self",
",",
"query_id",
")",
":",
"query_obj",
"=",
"self",
".",
"gemini_query",
"(",
"query_id",
")",
"logger",
".",
"debug",
"(",
"\"Delete query: {0}\"",
".",
"format",
"(",
"query_obj",
".",
"name_query",
")",
")",
"se... | Delete a gemini query
Args:
name (str) | [
"Delete",
"a",
"gemini",
"query"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/gemini.py#L36-L45 | train | Delete a gemini query |
ldomic/lintools | lintools/__main__.py | main | def main(args=None):
"""The main routine."""
if args is None:
args = sys.argv[1:]
print("This is the main routine.")
print("It should do something interesting.")
#################################################################################################################
parser = A... | python | def main(args=None):
"""The main routine."""
if args is None:
args = sys.argv[1:]
print("This is the main routine.")
print("It should do something interesting.")
#################################################################################################################
parser = A... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"print",
"(",
"\"This is the main routine.\"",
")",
"print",
"(",
"\"It should do something interesting.\"",
")",
"####... | The main routine. | [
"The",
"main",
"routine",
"."
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/__main__.py#L7-L122 | train | The main routine. |
Shinichi-Nakagawa/pitchpx | pitchpx/game/boxscore.py | BoxScore.row | def row(self):
"""
Box Score Dataset(Row)
:return: {
'retro_game_id': Retrosheet Game id
'home_team_id': Home Team Id
'away_team_id': Away Team Id
'home_lineup_[1-9]_id': Starting Member Player Id(Home)
'home_lineup_[1-9]_name': Startin... | python | def row(self):
"""
Box Score Dataset(Row)
:return: {
'retro_game_id': Retrosheet Game id
'home_team_id': Home Team Id
'away_team_id': Away Team Id
'home_lineup_[1-9]_id': Starting Member Player Id(Home)
'home_lineup_[1-9]_name': Startin... | [
"def",
"row",
"(",
"self",
")",
":",
"row",
"=",
"OrderedDict",
"(",
")",
"row",
"[",
"'retro_game_id'",
"]",
"=",
"self",
".",
"retro_game_id",
"row",
"[",
"'home_team_id'",
"]",
"=",
"self",
".",
"home_team_id",
"row",
"[",
"'away_team_id'",
"]",
"=",
... | Box Score Dataset(Row)
:return: {
'retro_game_id': Retrosheet Game id
'home_team_id': Home Team Id
'away_team_id': Away Team Id
'home_lineup_[1-9]_id': Starting Member Player Id(Home)
'home_lineup_[1-9]_name': Starting Member Player Box Name(Home)
... | [
"Box",
"Score",
"Dataset",
"(",
"Row",
")",
":",
"return",
":",
"{",
"retro_game_id",
":",
"Retrosheet",
"Game",
"id",
"home_team_id",
":",
"Home",
"Team",
"Id",
"away_team_id",
":",
"Away",
"Team",
"Id",
"home_lineup_",
"[",
"1",
"-",
"9",
"]",
"_id",
... | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/boxscore.py#L36-L75 | train | Return a dict containing the current row of the log. |
Shinichi-Nakagawa/pitchpx | pitchpx/game/boxscore.py | BoxScore.read_xml | def read_xml(cls, url, features, game, players):
"""
read xml object
:param url: contents url
:param features: markup provider
:param game: MLBAM Game object
:param players: MLBAM Players object
:return: pitchpx.box_score.box_score.BoxScore object
"""
... | python | def read_xml(cls, url, features, game, players):
"""
read xml object
:param url: contents url
:param features: markup provider
:param game: MLBAM Game object
:param players: MLBAM Players object
:return: pitchpx.box_score.box_score.BoxScore object
"""
... | [
"def",
"read_xml",
"(",
"cls",
",",
"url",
",",
"features",
",",
"game",
",",
"players",
")",
":",
"soup",
"=",
"MlbamUtil",
".",
"find_xml",
"(",
"\"\"",
".",
"join",
"(",
"[",
"url",
",",
"cls",
".",
"FILENAME",
"]",
")",
",",
"features",
")",
... | read xml object
:param url: contents url
:param features: markup provider
:param game: MLBAM Game object
:param players: MLBAM Players object
:return: pitchpx.box_score.box_score.BoxScore object | [
"read",
"xml",
"object",
":",
"param",
"url",
":",
"contents",
"url",
":",
"param",
"features",
":",
"markup",
"provider",
":",
"param",
"game",
":",
"MLBAM",
"Game",
"object",
":",
"param",
"players",
":",
"MLBAM",
"Players",
"object",
":",
"return",
":... | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/boxscore.py#L78-L88 | train | read xml object |
Shinichi-Nakagawa/pitchpx | pitchpx/game/boxscore.py | BoxScore._generate_object | def _generate_object(cls, soup, game, players):
"""
get box_score data
:param soup: Beautifulsoup object
:param game: MLBAM Game object
:param players: MLBAM Players object
:return: pitchpx.box_score.box_score.BoxScore object
"""
def get_batter(soup, team... | python | def _generate_object(cls, soup, game, players):
"""
get box_score data
:param soup: Beautifulsoup object
:param game: MLBAM Game object
:param players: MLBAM Players object
:return: pitchpx.box_score.box_score.BoxScore object
"""
def get_batter(soup, team... | [
"def",
"_generate_object",
"(",
"cls",
",",
"soup",
",",
"game",
",",
"players",
")",
":",
"def",
"get_batter",
"(",
"soup",
",",
"team_flag",
")",
":",
"batting",
"=",
"soup",
".",
"find",
"(",
"'batting'",
",",
"attrs",
"=",
"{",
"'team_flag'",
":",
... | get box_score data
:param soup: Beautifulsoup object
:param game: MLBAM Game object
:param players: MLBAM Players object
:return: pitchpx.box_score.box_score.BoxScore object | [
"get",
"box_score",
"data",
":",
"param",
"soup",
":",
"Beautifulsoup",
"object",
":",
"param",
"game",
":",
"MLBAM",
"Game",
"object",
":",
"param",
"players",
":",
"MLBAM",
"Players",
"object",
":",
"return",
":",
"pitchpx",
".",
"box_score",
".",
"box_s... | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/boxscore.py#L91-L122 | train | generate object from soup game and players |
Shinichi-Nakagawa/pitchpx | pitchpx/game/boxscore.py | BoxScore._get_batter | def _get_batter(self, batter):
"""
get batter object
:param batter: Beautifulsoup object(batter element)
:return: batter(dict)
"""
values = OrderedDict()
player = self.players.rosters.get(batter.get('id'))
bo, starting = self._get_batting_order_starting_fl... | python | def _get_batter(self, batter):
"""
get batter object
:param batter: Beautifulsoup object(batter element)
:return: batter(dict)
"""
values = OrderedDict()
player = self.players.rosters.get(batter.get('id'))
bo, starting = self._get_batting_order_starting_fl... | [
"def",
"_get_batter",
"(",
"self",
",",
"batter",
")",
":",
"values",
"=",
"OrderedDict",
"(",
")",
"player",
"=",
"self",
".",
"players",
".",
"rosters",
".",
"get",
"(",
"batter",
".",
"get",
"(",
"'id'",
")",
")",
"bo",
",",
"starting",
"=",
"se... | get batter object
:param batter: Beautifulsoup object(batter element)
:return: batter(dict) | [
"get",
"batter",
"object",
":",
"param",
"batter",
":",
"Beautifulsoup",
"object",
"(",
"batter",
"element",
")",
":",
"return",
":",
"batter",
"(",
"dict",
")"
] | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/boxscore.py#L124-L142 | train | get batter object |
Shinichi-Nakagawa/pitchpx | pitchpx/game/boxscore.py | BoxScore._get_batting_order_starting_flg | def _get_batting_order_starting_flg(cls, batter):
"""
get batting order and starting member flg
:param batter: Beautifulsoup object(batter element)
:return: batting order(1-9), starting member flg(True or False)
"""
bo = batter.get('bo', None)
if not bo or len(bo)... | python | def _get_batting_order_starting_flg(cls, batter):
"""
get batting order and starting member flg
:param batter: Beautifulsoup object(batter element)
:return: batting order(1-9), starting member flg(True or False)
"""
bo = batter.get('bo', None)
if not bo or len(bo)... | [
"def",
"_get_batting_order_starting_flg",
"(",
"cls",
",",
"batter",
")",
":",
"bo",
"=",
"batter",
".",
"get",
"(",
"'bo'",
",",
"None",
")",
"if",
"not",
"bo",
"or",
"len",
"(",
"bo",
")",
"!=",
"3",
":",
"return",
"False",
",",
"False",
"batting_o... | get batting order and starting member flg
:param batter: Beautifulsoup object(batter element)
:return: batting order(1-9), starting member flg(True or False) | [
"get",
"batting",
"order",
"and",
"starting",
"member",
"flg",
":",
"param",
"batter",
":",
"Beautifulsoup",
"object",
"(",
"batter",
"element",
")",
":",
"return",
":",
"batting",
"order",
"(",
"1",
"-",
"9",
")",
"starting",
"member",
"flg",
"(",
"True... | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/boxscore.py#L145-L156 | train | get batting order and starting member flg |
Shinichi-Nakagawa/pitchpx | pitchpx/game/boxscore.py | BoxScore._get_pitcher | def _get_pitcher(self, pitcher):
"""
get pitcher object
:param pitcher: Beautifulsoup object(pitcher element)
:return: pitcher(dict)
"""
values = OrderedDict()
player = self.players.rosters.get(pitcher.get('id'))
values['pos'] = pitcher.get('pos', MlbamCon... | python | def _get_pitcher(self, pitcher):
"""
get pitcher object
:param pitcher: Beautifulsoup object(pitcher element)
:return: pitcher(dict)
"""
values = OrderedDict()
player = self.players.rosters.get(pitcher.get('id'))
values['pos'] = pitcher.get('pos', MlbamCon... | [
"def",
"_get_pitcher",
"(",
"self",
",",
"pitcher",
")",
":",
"values",
"=",
"OrderedDict",
"(",
")",
"player",
"=",
"self",
".",
"players",
".",
"rosters",
".",
"get",
"(",
"pitcher",
".",
"get",
"(",
"'id'",
")",
")",
"values",
"[",
"'pos'",
"]",
... | get pitcher object
:param pitcher: Beautifulsoup object(pitcher element)
:return: pitcher(dict) | [
"get",
"pitcher",
"object",
":",
"param",
"pitcher",
":",
"Beautifulsoup",
"object",
"(",
"pitcher",
"element",
")",
":",
"return",
":",
"pitcher",
"(",
"dict",
")"
] | 5747402a0b3416f5e910b479e100df858f0b6440 | https://github.com/Shinichi-Nakagawa/pitchpx/blob/5747402a0b3416f5e910b479e100df858f0b6440/pitchpx/game/boxscore.py#L158-L175 | train | get pitcher object |
thautwarm/Redy | Redy/Tools/Version.py | Version.increment | def increment(self, version_number_idx: int, increment: int):
"""
increment the version number with `n` at index `i`.
>>> from Redy.Tools.Version import Version
>>> a = Version('1.0.0.2')
>>> a.increment(version_number_idx=2, increment=1)
>>> assert a == ('1.0.1.0')
... | python | def increment(self, version_number_idx: int, increment: int):
"""
increment the version number with `n` at index `i`.
>>> from Redy.Tools.Version import Version
>>> a = Version('1.0.0.2')
>>> a.increment(version_number_idx=2, increment=1)
>>> assert a == ('1.0.1.0')
... | [
"def",
"increment",
"(",
"self",
",",
"version_number_idx",
":",
"int",
",",
"increment",
":",
"int",
")",
":",
"_numbers",
"=",
"list",
"(",
"self",
".",
"_numbers",
")",
"_numbers",
"[",
"version_number_idx",
"]",
"+=",
"increment",
"for",
"each",
"in",
... | increment the version number with `n` at index `i`.
>>> from Redy.Tools.Version import Version
>>> a = Version('1.0.0.2')
>>> a.increment(version_number_idx=2, increment=1)
>>> assert a == ('1.0.1.0')
>>> print(a[0])
>>> a[0] = 2 | [
"increment",
"the",
"version",
"number",
"with",
"n",
"at",
"index",
"i",
".",
">>>",
"from",
"Redy",
".",
"Tools",
".",
"Version",
"import",
"Version",
">>>",
"a",
"=",
"Version",
"(",
"1",
".",
"0",
".",
"0",
".",
"2",
")",
">>>",
"a",
".",
"in... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Tools/Version.py#L43-L57 | train | increment the version number with n at index i. |
gusdan/geoindex | geoindex/geo_point.py | GeoPoint.distance_to | def distance_to(self, point, unit='km'):
"""
Calculate distance in miles or kilometers between current and other
passed point.
"""
assert isinstance(point, GeoPoint), (
'Other point should also be a Point instance.'
)
if self == point:
retu... | python | def distance_to(self, point, unit='km'):
"""
Calculate distance in miles or kilometers between current and other
passed point.
"""
assert isinstance(point, GeoPoint), (
'Other point should also be a Point instance.'
)
if self == point:
retu... | [
"def",
"distance_to",
"(",
"self",
",",
"point",
",",
"unit",
"=",
"'km'",
")",
":",
"assert",
"isinstance",
"(",
"point",
",",
"GeoPoint",
")",
",",
"(",
"'Other point should also be a Point instance.'",
")",
"if",
"self",
"==",
"point",
":",
"return",
"0.0... | Calculate distance in miles or kilometers between current and other
passed point. | [
"Calculate",
"distance",
"in",
"miles",
"or",
"kilometers",
"between",
"current",
"and",
"other",
"passed",
"point",
"."
] | d1b3b5a52271200713a64041576caa1f2d588f55 | https://github.com/gusdan/geoindex/blob/d1b3b5a52271200713a64041576caa1f2d588f55/geoindex/geo_point.py#L49-L72 | train | Calculate distance between current and other point. |
gusdan/geoindex | geoindex/geo_point.py | GeoPoint.rad_latitude | def rad_latitude(self):
"""
Lazy conversion degrees latitude to radians.
"""
if self._rad_latitude is None:
self._rad_latitude = math.radians(self.latitude)
return self._rad_latitude | python | def rad_latitude(self):
"""
Lazy conversion degrees latitude to radians.
"""
if self._rad_latitude is None:
self._rad_latitude = math.radians(self.latitude)
return self._rad_latitude | [
"def",
"rad_latitude",
"(",
"self",
")",
":",
"if",
"self",
".",
"_rad_latitude",
"is",
"None",
":",
"self",
".",
"_rad_latitude",
"=",
"math",
".",
"radians",
"(",
"self",
".",
"latitude",
")",
"return",
"self",
".",
"_rad_latitude"
] | Lazy conversion degrees latitude to radians. | [
"Lazy",
"conversion",
"degrees",
"latitude",
"to",
"radians",
"."
] | d1b3b5a52271200713a64041576caa1f2d588f55 | https://github.com/gusdan/geoindex/blob/d1b3b5a52271200713a64041576caa1f2d588f55/geoindex/geo_point.py#L75-L81 | train | Lazy conversion degrees latitude to radians. |
gusdan/geoindex | geoindex/geo_point.py | GeoPoint.rad_longitude | def rad_longitude(self):
"""
Lazy conversion degrees longitude to radians.
"""
if self._rad_longitude is None:
self._rad_longitude = math.radians(self.longitude)
return self._rad_longitude | python | def rad_longitude(self):
"""
Lazy conversion degrees longitude to radians.
"""
if self._rad_longitude is None:
self._rad_longitude = math.radians(self.longitude)
return self._rad_longitude | [
"def",
"rad_longitude",
"(",
"self",
")",
":",
"if",
"self",
".",
"_rad_longitude",
"is",
"None",
":",
"self",
".",
"_rad_longitude",
"=",
"math",
".",
"radians",
"(",
"self",
".",
"longitude",
")",
"return",
"self",
".",
"_rad_longitude"
] | Lazy conversion degrees longitude to radians. | [
"Lazy",
"conversion",
"degrees",
"longitude",
"to",
"radians",
"."
] | d1b3b5a52271200713a64041576caa1f2d588f55 | https://github.com/gusdan/geoindex/blob/d1b3b5a52271200713a64041576caa1f2d588f55/geoindex/geo_point.py#L84-L90 | train | Lazy conversion degrees longitude to radians. |
okeuday/erlang_py | examples/port.py | send | def send(term, stream):
"""Write an Erlang term to an output stream."""
payload = erlang.term_to_binary(term)
header = struct.pack('!I', len(payload))
stream.write(header)
stream.write(payload)
stream.flush() | python | def send(term, stream):
"""Write an Erlang term to an output stream."""
payload = erlang.term_to_binary(term)
header = struct.pack('!I', len(payload))
stream.write(header)
stream.write(payload)
stream.flush() | [
"def",
"send",
"(",
"term",
",",
"stream",
")",
":",
"payload",
"=",
"erlang",
".",
"term_to_binary",
"(",
"term",
")",
"header",
"=",
"struct",
".",
"pack",
"(",
"'!I'",
",",
"len",
"(",
"payload",
")",
")",
"stream",
".",
"write",
"(",
"header",
... | Write an Erlang term to an output stream. | [
"Write",
"an",
"Erlang",
"term",
"to",
"an",
"output",
"stream",
"."
] | 81b7c2ace66b6bdee23602a6802efff541223fa3 | https://github.com/okeuday/erlang_py/blob/81b7c2ace66b6bdee23602a6802efff541223fa3/examples/port.py#L6-L12 | train | Write an Erlang term to an output stream. |
okeuday/erlang_py | examples/port.py | recv | def recv(stream):
"""Read an Erlang term from an input stream."""
header = stream.read(4)
if len(header) != 4:
return None # EOF
(length,) = struct.unpack('!I', header)
payload = stream.read(length)
if len(payload) != length:
return None
term = erlang.binary_to_term(payload)
... | python | def recv(stream):
"""Read an Erlang term from an input stream."""
header = stream.read(4)
if len(header) != 4:
return None # EOF
(length,) = struct.unpack('!I', header)
payload = stream.read(length)
if len(payload) != length:
return None
term = erlang.binary_to_term(payload)
... | [
"def",
"recv",
"(",
"stream",
")",
":",
"header",
"=",
"stream",
".",
"read",
"(",
"4",
")",
"if",
"len",
"(",
"header",
")",
"!=",
"4",
":",
"return",
"None",
"# EOF",
"(",
"length",
",",
")",
"=",
"struct",
".",
"unpack",
"(",
"'!I'",
",",
"h... | Read an Erlang term from an input stream. | [
"Read",
"an",
"Erlang",
"term",
"from",
"an",
"input",
"stream",
"."
] | 81b7c2ace66b6bdee23602a6802efff541223fa3 | https://github.com/okeuday/erlang_py/blob/81b7c2ace66b6bdee23602a6802efff541223fa3/examples/port.py#L14-L24 | train | Read an Erlang term from an input stream. |
okeuday/erlang_py | examples/port.py | recv_loop | def recv_loop(stream):
"""Yield Erlang terms from an input stream."""
message = recv(stream)
while message:
yield message
message = recv(stream) | python | def recv_loop(stream):
"""Yield Erlang terms from an input stream."""
message = recv(stream)
while message:
yield message
message = recv(stream) | [
"def",
"recv_loop",
"(",
"stream",
")",
":",
"message",
"=",
"recv",
"(",
"stream",
")",
"while",
"message",
":",
"yield",
"message",
"message",
"=",
"recv",
"(",
"stream",
")"
] | Yield Erlang terms from an input stream. | [
"Yield",
"Erlang",
"terms",
"from",
"an",
"input",
"stream",
"."
] | 81b7c2ace66b6bdee23602a6802efff541223fa3 | https://github.com/okeuday/erlang_py/blob/81b7c2ace66b6bdee23602a6802efff541223fa3/examples/port.py#L26-L31 | train | Yield Erlang terms from an input stream. |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/variant_extras/genotype.py | GenotypeExtras._add_genotype_calls | def _add_genotype_calls(self, variant_obj, variant_line, case_obj):
"""Add the genotype calls for the variant
Args:
variant_obj (puzzle.models.Variant)
variant_dict (dict): A variant dictionary
case_obj (puzzle.models.Case)
"""
variant_line = variant... | python | def _add_genotype_calls(self, variant_obj, variant_line, case_obj):
"""Add the genotype calls for the variant
Args:
variant_obj (puzzle.models.Variant)
variant_dict (dict): A variant dictionary
case_obj (puzzle.models.Case)
"""
variant_line = variant... | [
"def",
"_add_genotype_calls",
"(",
"self",
",",
"variant_obj",
",",
"variant_line",
",",
"case_obj",
")",
":",
"variant_line",
"=",
"variant_line",
".",
"split",
"(",
"'\\t'",
")",
"#if there is gt calls we have no individuals to add",
"if",
"len",
"(",
"variant_line"... | Add the genotype calls for the variant
Args:
variant_obj (puzzle.models.Variant)
variant_dict (dict): A variant dictionary
case_obj (puzzle.models.Case) | [
"Add",
"the",
"genotype",
"calls",
"for",
"the",
"variant"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_extras/genotype.py#L12-L47 | train | Add the genotype calls for the variant. |
inveniosoftware-contrib/json-merger | json_merger/conflict.py | Conflict.with_prefix | def with_prefix(self, root_path):
"""Returns a new conflict with a prepended prefix as a path."""
return Conflict(self.conflict_type, root_path + self.path, self.body) | python | def with_prefix(self, root_path):
"""Returns a new conflict with a prepended prefix as a path."""
return Conflict(self.conflict_type, root_path + self.path, self.body) | [
"def",
"with_prefix",
"(",
"self",
",",
"root_path",
")",
":",
"return",
"Conflict",
"(",
"self",
".",
"conflict_type",
",",
"root_path",
"+",
"self",
".",
"path",
",",
"self",
".",
"body",
")"
] | Returns a new conflict with a prepended prefix as a path. | [
"Returns",
"a",
"new",
"conflict",
"with",
"a",
"prepended",
"prefix",
"as",
"a",
"path",
"."
] | adc6d372da018427e1db7b92424d3471e01a4118 | https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/conflict.py#L95-L97 | train | Returns a new conflict with a prepended prefix as a path. |
inveniosoftware-contrib/json-merger | json_merger/conflict.py | Conflict.to_json | def to_json(self):
"""Deserializes conflict to a JSON object.
It returns list of:
`json-patch <https://tools.ietf.org/html/rfc6902>`_ format.
- REORDER, SET_FIELD become "op": "replace"
- MANUAL_MERGE, ADD_BACK_TO_HEAD become "op": "add"
- Path becomes `json-pointer... | python | def to_json(self):
"""Deserializes conflict to a JSON object.
It returns list of:
`json-patch <https://tools.ietf.org/html/rfc6902>`_ format.
- REORDER, SET_FIELD become "op": "replace"
- MANUAL_MERGE, ADD_BACK_TO_HEAD become "op": "add"
- Path becomes `json-pointer... | [
"def",
"to_json",
"(",
"self",
")",
":",
"# map ConflictType to json-patch operator",
"path",
"=",
"self",
".",
"path",
"if",
"self",
".",
"conflict_type",
"in",
"(",
"'REORDER'",
",",
"'SET_FIELD'",
")",
":",
"op",
"=",
"'replace'",
"elif",
"self",
".",
"co... | Deserializes conflict to a JSON object.
It returns list of:
`json-patch <https://tools.ietf.org/html/rfc6902>`_ format.
- REORDER, SET_FIELD become "op": "replace"
- MANUAL_MERGE, ADD_BACK_TO_HEAD become "op": "add"
- Path becomes `json-pointer <https://tools.ietf.org/html/... | [
"Deserializes",
"conflict",
"to",
"a",
"JSON",
"object",
"."
] | adc6d372da018427e1db7b92424d3471e01a4118 | https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/conflict.py#L99-L139 | train | Deserializes a conflict to a JSON object. |
jwodder/javaproperties | javaproperties/writing.py | dump | def dump(props, fp, separator='=', comments=None, timestamp=True,
sort_keys=False):
"""
Write a series of key-value pairs to a file in simple line-oriented
``.properties`` format.
:param props: A mapping or iterable of ``(key, value)`` pairs to write to
``fp``. All keys and values in ... | python | def dump(props, fp, separator='=', comments=None, timestamp=True,
sort_keys=False):
"""
Write a series of key-value pairs to a file in simple line-oriented
``.properties`` format.
:param props: A mapping or iterable of ``(key, value)`` pairs to write to
``fp``. All keys and values in ... | [
"def",
"dump",
"(",
"props",
",",
"fp",
",",
"separator",
"=",
"'='",
",",
"comments",
"=",
"None",
",",
"timestamp",
"=",
"True",
",",
"sort_keys",
"=",
"False",
")",
":",
"if",
"comments",
"is",
"not",
"None",
":",
"print",
"(",
"to_comment",
"(",
... | Write a series of key-value pairs to a file in simple line-oriented
``.properties`` format.
:param props: A mapping or iterable of ``(key, value)`` pairs to write to
``fp``. All keys and values in ``props`` must be text strings. If
``sort_keys`` is `False`, the entries are output in iteration... | [
"Write",
"a",
"series",
"of",
"key",
"-",
"value",
"pairs",
"to",
"a",
"file",
"in",
"simple",
"line",
"-",
"oriented",
".",
"properties",
"format",
"."
] | 8b48f040305217ebeb80c98c4354691bbb01429b | https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/writing.py#L10-L45 | train | Writes a series of key - value pairs to a file - like object. |
jwodder/javaproperties | javaproperties/writing.py | dumps | def dumps(props, separator='=', comments=None, timestamp=True, sort_keys=False):
"""
Convert a series of key-value pairs to a text string in simple
line-oriented ``.properties`` format.
:param props: A mapping or iterable of ``(key, value)`` pairs to serialize.
All keys and values in ``props`` ... | python | def dumps(props, separator='=', comments=None, timestamp=True, sort_keys=False):
"""
Convert a series of key-value pairs to a text string in simple
line-oriented ``.properties`` format.
:param props: A mapping or iterable of ``(key, value)`` pairs to serialize.
All keys and values in ``props`` ... | [
"def",
"dumps",
"(",
"props",
",",
"separator",
"=",
"'='",
",",
"comments",
"=",
"None",
",",
"timestamp",
"=",
"True",
",",
"sort_keys",
"=",
"False",
")",
":",
"s",
"=",
"StringIO",
"(",
")",
"dump",
"(",
"props",
",",
"s",
",",
"separator",
"="... | Convert a series of key-value pairs to a text string in simple
line-oriented ``.properties`` format.
:param props: A mapping or iterable of ``(key, value)`` pairs to serialize.
All keys and values in ``props`` must be text strings. If
``sort_keys`` is `False`, the entries are output in iterati... | [
"Convert",
"a",
"series",
"of",
"key",
"-",
"value",
"pairs",
"to",
"a",
"text",
"string",
"in",
"simple",
"line",
"-",
"oriented",
".",
"properties",
"format",
"."
] | 8b48f040305217ebeb80c98c4354691bbb01429b | https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/writing.py#L47-L77 | train | Serializes a series of key - value pairs into a simple simple
. |
jwodder/javaproperties | javaproperties/writing.py | to_comment | def to_comment(comment):
"""
Convert a string to a ``.properties`` file comment. All non-Latin-1
characters in the string are escaped using ``\\uXXXX`` escapes (after
converting non-BMP characters to surrogate pairs), a ``#`` is prepended to
the string, any CR LF or CR line breaks in the string are... | python | def to_comment(comment):
"""
Convert a string to a ``.properties`` file comment. All non-Latin-1
characters in the string are escaped using ``\\uXXXX`` escapes (after
converting non-BMP characters to surrogate pairs), a ``#`` is prepended to
the string, any CR LF or CR line breaks in the string are... | [
"def",
"to_comment",
"(",
"comment",
")",
":",
"return",
"'#'",
"+",
"re",
".",
"sub",
"(",
"r'[^\\x00-\\xFF]'",
",",
"_esc",
",",
"re",
".",
"sub",
"(",
"r'\\n(?![#!])'",
",",
"'\\n#'",
",",
"re",
".",
"sub",
"(",
"r'\\r\\n?'",
",",
"'\\n'",
",",
"c... | Convert a string to a ``.properties`` file comment. All non-Latin-1
characters in the string are escaped using ``\\uXXXX`` escapes (after
converting non-BMP characters to surrogate pairs), a ``#`` is prepended to
the string, any CR LF or CR line breaks in the string are converted to LF,
and a ``#`` is ... | [
"Convert",
"a",
"string",
"to",
"a",
".",
"properties",
"file",
"comment",
".",
"All",
"non",
"-",
"Latin",
"-",
"1",
"characters",
"in",
"the",
"string",
"are",
"escaped",
"using",
"\\\\",
"uXXXX",
"escapes",
"(",
"after",
"converting",
"non",
"-",
"BMP... | 8b48f040305217ebeb80c98c4354691bbb01429b | https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/writing.py#L79-L97 | train | Convert a string to a. properties file comment. |
jwodder/javaproperties | javaproperties/writing.py | join_key_value | def join_key_value(key, value, separator='='):
r"""
Join a key and value together into a single line suitable for adding to a
simple line-oriented ``.properties`` file. No trailing newline is added.
>>> join_key_value('possible separators', '= : space')
'possible\\ separators=\\= \\: space'
:... | python | def join_key_value(key, value, separator='='):
r"""
Join a key and value together into a single line suitable for adding to a
simple line-oriented ``.properties`` file. No trailing newline is added.
>>> join_key_value('possible separators', '= : space')
'possible\\ separators=\\= \\: space'
:... | [
"def",
"join_key_value",
"(",
"key",
",",
"value",
",",
"separator",
"=",
"'='",
")",
":",
"# Escapes `key` and `value` the same way as java.util.Properties.store()",
"return",
"escape",
"(",
"key",
")",
"+",
"separator",
"+",
"re",
".",
"sub",
"(",
"r'^ +'",
",",... | r"""
Join a key and value together into a single line suitable for adding to a
simple line-oriented ``.properties`` file. No trailing newline is added.
>>> join_key_value('possible separators', '= : space')
'possible\\ separators=\\= \\: space'
:param key: the key
:type key: text string
:... | [
"r",
"Join",
"a",
"key",
"and",
"value",
"together",
"into",
"a",
"single",
"line",
"suitable",
"for",
"adding",
"to",
"a",
"simple",
"line",
"-",
"oriented",
".",
"properties",
"file",
".",
"No",
"trailing",
"newline",
"is",
"added",
"."
] | 8b48f040305217ebeb80c98c4354691bbb01429b | https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/writing.py#L99-L120 | train | r Join a key and value together into a single line suitable for adding to a. properties file. |
jwodder/javaproperties | javaproperties/writing.py | java_timestamp | def java_timestamp(timestamp=True):
"""
.. versionadded:: 0.2.0
Returns a timestamp in the format produced by |date_tostring|_, e.g.::
Mon Sep 02 14:00:54 EDT 2016
If ``timestamp`` is `True` (the default), the current date & time is
returned.
If ``timestamp`` is `None` or `False`, an... | python | def java_timestamp(timestamp=True):
"""
.. versionadded:: 0.2.0
Returns a timestamp in the format produced by |date_tostring|_, e.g.::
Mon Sep 02 14:00:54 EDT 2016
If ``timestamp`` is `True` (the default), the current date & time is
returned.
If ``timestamp`` is `None` or `False`, an... | [
"def",
"java_timestamp",
"(",
"timestamp",
"=",
"True",
")",
":",
"if",
"timestamp",
"is",
"None",
"or",
"timestamp",
"is",
"False",
":",
"return",
"''",
"if",
"isinstance",
"(",
"timestamp",
",",
"datetime",
")",
"and",
"timestamp",
".",
"tzinfo",
"is",
... | .. versionadded:: 0.2.0
Returns a timestamp in the format produced by |date_tostring|_, e.g.::
Mon Sep 02 14:00:54 EDT 2016
If ``timestamp`` is `True` (the default), the current date & time is
returned.
If ``timestamp`` is `None` or `False`, an empty string is returned.
If ``timestamp``... | [
"..",
"versionadded",
"::",
"0",
".",
"2",
".",
"0"
] | 8b48f040305217ebeb80c98c4354691bbb01429b | https://github.com/jwodder/javaproperties/blob/8b48f040305217ebeb80c98c4354691bbb01429b/javaproperties/writing.py#L177-L247 | train | Return a timestamp in the format produced by Java 8. |
wistful/pympris | pympris/PlayLists.py | PlayLists.GetPlaylists | def GetPlaylists(self, start, max_count, order, reversed):
"""Gets a set of playlists.
:param int start: The index of the first playlist to be fetched
(according to the ordering).
:param int max_count: The maximum number of playlists to fetch.
:param str order... | python | def GetPlaylists(self, start, max_count, order, reversed):
"""Gets a set of playlists.
:param int start: The index of the first playlist to be fetched
(according to the ordering).
:param int max_count: The maximum number of playlists to fetch.
:param str order... | [
"def",
"GetPlaylists",
"(",
"self",
",",
"start",
",",
"max_count",
",",
"order",
",",
"reversed",
")",
":",
"cv",
"=",
"convert2dbus",
"return",
"self",
".",
"iface",
".",
"GetPlaylists",
"(",
"cv",
"(",
"start",
",",
"'u'",
")",
",",
"cv",
"(",
"ma... | Gets a set of playlists.
:param int start: The index of the first playlist to be fetched
(according to the ordering).
:param int max_count: The maximum number of playlists to fetch.
:param str order: The ordering that should be used.
:param bool reversed: Whet... | [
"Gets",
"a",
"set",
"of",
"playlists",
"."
] | 4bd64a1f0d151f2adfc392ab34fd9b38894786cb | https://github.com/wistful/pympris/blob/4bd64a1f0d151f2adfc392ab34fd9b38894786cb/pympris/PlayLists.py#L58-L71 | train | Retrieves a set of playlists from the DBus. |
ThaWeatherman/flask-hashing | flask_hashing.py | Hashing.init_app | def init_app(self, app):
'''Initializes the Flask application with this extension. It grabs
the necessary configuration values from ``app.config``, those being
HASHING_METHOD and HASHING_ROUNDS. HASHING_METHOD defaults to ``sha256``
but can be any one of ``hashlib.algorithms``. HASHING_R... | python | def init_app(self, app):
'''Initializes the Flask application with this extension. It grabs
the necessary configuration values from ``app.config``, those being
HASHING_METHOD and HASHING_ROUNDS. HASHING_METHOD defaults to ``sha256``
but can be any one of ``hashlib.algorithms``. HASHING_R... | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"self",
".",
"algorithm",
"=",
"app",
".",
"config",
".",
"get",
"(",
"'HASHING_METHOD'",
",",
"'sha256'",
")",
"if",
"self",
".",
"algorithm",
"not",
"in",
"algs",
":",
"raise",
"ValueError",
"(",
... | Initializes the Flask application with this extension. It grabs
the necessary configuration values from ``app.config``, those being
HASHING_METHOD and HASHING_ROUNDS. HASHING_METHOD defaults to ``sha256``
but can be any one of ``hashlib.algorithms``. HASHING_ROUNDS specifies
the number o... | [
"Initializes",
"the",
"Flask",
"application",
"with",
"this",
"extension",
".",
"It",
"grabs",
"the",
"necessary",
"configuration",
"values",
"from",
"app",
".",
"config",
"those",
"being",
"HASHING_METHOD",
"and",
"HASHING_ROUNDS",
".",
"HASHING_METHOD",
"defaults"... | e2cc8526569f63362e2d79bea49c4809d4416c8a | https://github.com/ThaWeatherman/flask-hashing/blob/e2cc8526569f63362e2d79bea49c4809d4416c8a/flask_hashing.py#L62-L77 | train | Initializes the Flask application with this extension. It grabs the necessary configuration values from app. config that are being used by this extension. |
ThaWeatherman/flask-hashing | flask_hashing.py | Hashing.hash_value | def hash_value(self, value, salt=''):
'''Hashes the specified value combined with the specified salt.
The hash is done HASHING_ROUNDS times as specified by the application
configuration.
An example usage of :class:``hash_value`` would be::
val_hash = hashing.hash_value('mys... | python | def hash_value(self, value, salt=''):
'''Hashes the specified value combined with the specified salt.
The hash is done HASHING_ROUNDS times as specified by the application
configuration.
An example usage of :class:``hash_value`` would be::
val_hash = hashing.hash_value('mys... | [
"def",
"hash_value",
"(",
"self",
",",
"value",
",",
"salt",
"=",
"''",
")",
":",
"def",
"hashit",
"(",
"value",
",",
"salt",
")",
":",
"h",
"=",
"hashlib",
".",
"new",
"(",
"self",
".",
"algorithm",
")",
"tgt",
"=",
"salt",
"+",
"value",
"h",
... | Hashes the specified value combined with the specified salt.
The hash is done HASHING_ROUNDS times as specified by the application
configuration.
An example usage of :class:``hash_value`` would be::
val_hash = hashing.hash_value('mysecretdata', salt='abcd')
# save to a ... | [
"Hashes",
"the",
"specified",
"value",
"combined",
"with",
"the",
"specified",
"salt",
".",
"The",
"hash",
"is",
"done",
"HASHING_ROUNDS",
"times",
"as",
"specified",
"by",
"the",
"application",
"configuration",
"."
] | e2cc8526569f63362e2d79bea49c4809d4416c8a | https://github.com/ThaWeatherman/flask-hashing/blob/e2cc8526569f63362e2d79bea49c4809d4416c8a/flask_hashing.py#L79-L111 | train | Hashes the specified value combined with the specified salt. |
ThaWeatherman/flask-hashing | flask_hashing.py | Hashing.check_value | def check_value(self, value_hash, value, salt=''):
'''Checks the specified hash value against the hash of the provided
salt and value.
An example usage of :class:`check_value` would be::
val_hash = hashing.hash_value('mysecretdata', salt='abcd')
if hashing.check_value(v... | python | def check_value(self, value_hash, value, salt=''):
'''Checks the specified hash value against the hash of the provided
salt and value.
An example usage of :class:`check_value` would be::
val_hash = hashing.hash_value('mysecretdata', salt='abcd')
if hashing.check_value(v... | [
"def",
"check_value",
"(",
"self",
",",
"value_hash",
",",
"value",
",",
"salt",
"=",
"''",
")",
":",
"h",
"=",
"self",
".",
"hash_value",
"(",
"value",
",",
"salt",
"=",
"salt",
")",
"return",
"h",
"==",
"value_hash"
] | Checks the specified hash value against the hash of the provided
salt and value.
An example usage of :class:`check_value` would be::
val_hash = hashing.hash_value('mysecretdata', salt='abcd')
if hashing.check_value(val_hash, 'mysecretdata', salt='abcd'):
# do so... | [
"Checks",
"the",
"specified",
"hash",
"value",
"against",
"the",
"hash",
"of",
"the",
"provided",
"salt",
"and",
"value",
"."
] | e2cc8526569f63362e2d79bea49c4809d4416c8a | https://github.com/ThaWeatherman/flask-hashing/blob/e2cc8526569f63362e2d79bea49c4809d4416c8a/flask_hashing.py#L113-L130 | train | Checks the specified hash value against the hash of the provided salt and value. |
thautwarm/Redy | Redy/Tools/PathLib.py | Path.list_dir | def list_dir(self, filter_fn=None) -> 'Tuple[Path, ...]':
"""
* the `self` Path object is assumed to be a directory
:param filter_fn:
a `None` object or
a predicative function `str -> bool` which will be applied on the
filename/directory in `self` directory.
... | python | def list_dir(self, filter_fn=None) -> 'Tuple[Path, ...]':
"""
* the `self` Path object is assumed to be a directory
:param filter_fn:
a `None` object or
a predicative function `str -> bool` which will be applied on the
filename/directory in `self` directory.
... | [
"def",
"list_dir",
"(",
"self",
",",
"filter_fn",
"=",
"None",
")",
"->",
"'Tuple[Path, ...]'",
":",
"path",
"=",
"str",
"(",
"self",
")",
"items",
"=",
"os",
".",
"listdir",
"(",
"path",
")",
"if",
"filter_fn",
"is",
"not",
"None",
":",
"items",
"="... | * the `self` Path object is assumed to be a directory
:param filter_fn:
a `None` object or
a predicative function `str -> bool` which will be applied on the
filename/directory in `self` directory.
:return:
a tuple of Path objects
each of whic... | [
"*",
"the",
"self",
"Path",
"object",
"is",
"assumed",
"to",
"be",
"a",
"directory"
] | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Tools/PathLib.py#L158-L197 | train | List the directory contents of the current directory. |
thautwarm/Redy | Redy/Tools/PathLib.py | Path.relative | def relative(self,
start: typing.Optional[typing.Union['Path', str]] = None
) -> str:
"""
:param start: an object of NoneType or Path or str.
:return: a string
If `start` is None:
returns the relative path of current Path object from ... | python | def relative(self,
start: typing.Optional[typing.Union['Path', str]] = None
) -> str:
"""
:param start: an object of NoneType or Path or str.
:return: a string
If `start` is None:
returns the relative path of current Path object from ... | [
"def",
"relative",
"(",
"self",
",",
"start",
":",
"typing",
".",
"Optional",
"[",
"typing",
".",
"Union",
"[",
"'Path'",
",",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"str",
":",
"if",
"start",
"is",
"None",
":",
"return",
"os",
".",
"path",
"."... | :param start: an object of NoneType or Path or str.
:return: a string
If `start` is None:
returns the relative path of current Path object from its own directory.
Else:
returns the relative path of current Path object from the `start` path.
e.g
... | [
":",
"param",
"start",
":",
"an",
"object",
"of",
"NoneType",
"or",
"Path",
"or",
"str",
".",
":",
"return",
":",
"a",
"string",
"If",
"start",
"is",
"None",
":",
"returns",
"the",
"relative",
"path",
"of",
"current",
"Path",
"object",
"from",
"its",
... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Tools/PathLib.py#L208-L233 | train | returns the relative path of the current path to the given path. |
thautwarm/Redy | Redy/Tools/PathLib.py | Path.open | def open(self,
mode='r',
encoding: typing.Union[list, tuple, set, str, typing.
Callable] = 'auto'):
"""
:param mode: the same as the argument `mode` of `builtins.open`
:param encoding: similar to the argument `encoding` of `builtins.o... | python | def open(self,
mode='r',
encoding: typing.Union[list, tuple, set, str, typing.
Callable] = 'auto'):
"""
:param mode: the same as the argument `mode` of `builtins.open`
:param encoding: similar to the argument `encoding` of `builtins.o... | [
"def",
"open",
"(",
"self",
",",
"mode",
"=",
"'r'",
",",
"encoding",
":",
"typing",
".",
"Union",
"[",
"list",
",",
"tuple",
",",
"set",
",",
"str",
",",
"typing",
".",
"Callable",
"]",
"=",
"'auto'",
")",
":",
"if",
"'b'",
"in",
"mode",
":",
... | :param mode: the same as the argument `mode` of `builtins.open`
:param encoding: similar to the argument `encoding` of `builtins.open` which is compatible to io.open.
- `encoding='auto'` to automatically detect the encoding.
- `encoding is a <list|tuple|set>` to... | [
":",
"param",
"mode",
":",
"the",
"same",
"as",
"the",
"argument",
"mode",
"of",
"builtins",
".",
"open",
":",
"param",
"encoding",
":",
"similar",
"to",
"the",
"argument",
"encoding",
"of",
"builtins",
".",
"open",
"which",
"is",
"compatible",
"to",
"io... | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Tools/PathLib.py#L241-L270 | train | open the file with the specified mode and encoding |
wistful/pympris | pympris/TrackList.py | TrackList.AddTrack | def AddTrack(self, uri, after_track, set_as_current):
"""Adds a URI in the TrackList.
:param str uri: The uri of the item to add.
:param str after_track: The identifier of the track
after which the new item should be inserted.
:param bool set_as_current: ... | python | def AddTrack(self, uri, after_track, set_as_current):
"""Adds a URI in the TrackList.
:param str uri: The uri of the item to add.
:param str after_track: The identifier of the track
after which the new item should be inserted.
:param bool set_as_current: ... | [
"def",
"AddTrack",
"(",
"self",
",",
"uri",
",",
"after_track",
",",
"set_as_current",
")",
":",
"self",
".",
"iface",
".",
"AddTrack",
"(",
"uri",
",",
"convert2dbus",
"(",
"after_track",
",",
"'o'",
")",
",",
"convert2dbus",
"(",
"set_as_current",
",",
... | Adds a URI in the TrackList.
:param str uri: The uri of the item to add.
:param str after_track: The identifier of the track
after which the new item should be inserted.
:param bool set_as_current: Whether the newly inserted track
... | [
"Adds",
"a",
"URI",
"in",
"the",
"TrackList",
"."
] | 4bd64a1f0d151f2adfc392ab34fd9b38894786cb | https://github.com/wistful/pympris/blob/4bd64a1f0d151f2adfc392ab34fd9b38894786cb/pympris/TrackList.py#L48-L59 | train | Adds a URI to the TrackList. |
robinandeer/puzzle | puzzle/models/sql/genelist.py | GeneList.delete_gene | def delete_gene(self, *gene_ids):
"""Delete one or more gene ids form the list."""
self.gene_ids = [gene_id for gene_id in self.gene_ids
if gene_id not in gene_ids] | python | def delete_gene(self, *gene_ids):
"""Delete one or more gene ids form the list."""
self.gene_ids = [gene_id for gene_id in self.gene_ids
if gene_id not in gene_ids] | [
"def",
"delete_gene",
"(",
"self",
",",
"*",
"gene_ids",
")",
":",
"self",
".",
"gene_ids",
"=",
"[",
"gene_id",
"for",
"gene_id",
"in",
"self",
".",
"gene_ids",
"if",
"gene_id",
"not",
"in",
"gene_ids",
"]"
] | Delete one or more gene ids form the list. | [
"Delete",
"one",
"or",
"more",
"gene",
"ids",
"form",
"the",
"list",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/sql/genelist.py#L44-L47 | train | Delete one or more gene ids form the list. |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/case_mixin.py | CaseMixin.add_case | def add_case(self, case_obj):
"""Add a case obj with individuals to adapter
Args:
case_obj (puzzle.models.Case)
"""
for ind_obj in case_obj.individuals:
self._add_individual(ind_obj)
logger.debug("Adding case {0} to plugin... | python | def add_case(self, case_obj):
"""Add a case obj with individuals to adapter
Args:
case_obj (puzzle.models.Case)
"""
for ind_obj in case_obj.individuals:
self._add_individual(ind_obj)
logger.debug("Adding case {0} to plugin... | [
"def",
"add_case",
"(",
"self",
",",
"case_obj",
")",
":",
"for",
"ind_obj",
"in",
"case_obj",
".",
"individuals",
":",
"self",
".",
"_add_individual",
"(",
"ind_obj",
")",
"logger",
".",
"debug",
"(",
"\"Adding case {0} to plugin\"",
".",
"format",
"(",
"ca... | Add a case obj with individuals to adapter
Args:
case_obj (puzzle.models.Case) | [
"Add",
"a",
"case",
"obj",
"with",
"individuals",
"to",
"adapter",
"Args",
":",
"case_obj",
"(",
"puzzle",
".",
"models",
".",
"Case",
")"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/case_mixin.py#L22-L35 | train | Adds a case to the adapter |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/case_mixin.py | CaseMixin.case | def case(self, case_id=None):
"""Return a Case object
If no case_id is given return one case
Args:
case_id (str): A case id
Returns:
A Case object
"""
if case_id:
for case in self.case_objs:
if cas... | python | def case(self, case_id=None):
"""Return a Case object
If no case_id is given return one case
Args:
case_id (str): A case id
Returns:
A Case object
"""
if case_id:
for case in self.case_objs:
if cas... | [
"def",
"case",
"(",
"self",
",",
"case_id",
"=",
"None",
")",
":",
"if",
"case_id",
":",
"for",
"case",
"in",
"self",
".",
"case_objs",
":",
"if",
"case",
".",
"case_id",
"==",
"case_id",
":",
"return",
"case",
"else",
":",
"if",
"self",
".",
"case... | Return a Case object
If no case_id is given return one case
Args:
case_id (str): A case id
Returns:
A Case object | [
"Return",
"a",
"Case",
"object"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/case_mixin.py#L42-L61 | train | Return a Case object for the given case_id. If no case_id is given return one. |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/case_mixin.py | CaseMixin.individual | def individual(self, ind_id=None):
"""Return a individual object
Args:
ind_id (str): A individual id
Returns:
individual (puzzle.models.individual)
"""
for ind_obj in self.individual_objs:
if ind_obj.ind_id... | python | def individual(self, ind_id=None):
"""Return a individual object
Args:
ind_id (str): A individual id
Returns:
individual (puzzle.models.individual)
"""
for ind_obj in self.individual_objs:
if ind_obj.ind_id... | [
"def",
"individual",
"(",
"self",
",",
"ind_id",
"=",
"None",
")",
":",
"for",
"ind_obj",
"in",
"self",
".",
"individual_objs",
":",
"if",
"ind_obj",
".",
"ind_id",
"==",
"ind_id",
":",
"return",
"ind_obj",
"return",
"None"
] | Return a individual object
Args:
ind_id (str): A individual id
Returns:
individual (puzzle.models.individual) | [
"Return",
"a",
"individual",
"object",
"Args",
":",
"ind_id",
"(",
"str",
")",
":",
"A",
"individual",
"id",
"Returns",
":",
"individual",
"(",
"puzzle",
".",
"models",
".",
"individual",
")"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/case_mixin.py#L63-L75 | train | Return a individual object |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/case_mixin.py | CaseMixin.individuals | def individuals(self, ind_ids=None):
"""Return information about individuals
Args:
ind_ids (list(str)): List of individual ids
Returns:
individuals (Iterable): Iterable with Individuals
"""
if ind_ids:
for ... | python | def individuals(self, ind_ids=None):
"""Return information about individuals
Args:
ind_ids (list(str)): List of individual ids
Returns:
individuals (Iterable): Iterable with Individuals
"""
if ind_ids:
for ... | [
"def",
"individuals",
"(",
"self",
",",
"ind_ids",
"=",
"None",
")",
":",
"if",
"ind_ids",
":",
"for",
"ind_id",
"in",
"ind_ids",
":",
"for",
"ind",
"in",
"self",
".",
"individual_objs",
":",
"if",
"ind",
".",
"ind_id",
"==",
"ind_id",
":",
"yield",
... | Return information about individuals
Args:
ind_ids (list(str)): List of individual ids
Returns:
individuals (Iterable): Iterable with Individuals | [
"Return",
"information",
"about",
"individuals",
"Args",
":",
"ind_ids",
"(",
"list",
"(",
"str",
"))",
":",
"List",
"of",
"individual",
"ids",
"Returns",
":",
"individuals",
"(",
"Iterable",
")",
":",
"Iterable",
"with",
"Individuals"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/case_mixin.py#L77-L93 | train | Return information about individuals
getItsId |
jalmeroth/pymusiccast | pymusiccast/__init__.py | McDevice.healthy_update_timer | def healthy_update_timer(self):
"""Check state of update timer."""
state = None
if self.update_status_timer and self.update_status_timer.is_alive():
_LOGGER.debug("Timer: healthy")
state = True
else:
_LOGGER.debug("Timer: not healthy")
sta... | python | def healthy_update_timer(self):
"""Check state of update timer."""
state = None
if self.update_status_timer and self.update_status_timer.is_alive():
_LOGGER.debug("Timer: healthy")
state = True
else:
_LOGGER.debug("Timer: not healthy")
sta... | [
"def",
"healthy_update_timer",
"(",
"self",
")",
":",
"state",
"=",
"None",
"if",
"self",
".",
"update_status_timer",
"and",
"self",
".",
"update_status_timer",
".",
"is_alive",
"(",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Timer: healthy\"",
")",
"state",
... | Check state of update timer. | [
"Check",
"state",
"of",
"update",
"timer",
"."
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/__init__.py#L71-L82 | train | Check state of update timer. |
jalmeroth/pymusiccast | pymusiccast/__init__.py | McDevice.initialize | def initialize(self):
"""initialize the object"""
self.network_status = self.get_network_status()
self.name = self.network_status.get('network_name', 'Unknown')
self.location_info = self.get_location_info()
self.device_info = self.get_device_info()
self.device_id = (
... | python | def initialize(self):
"""initialize the object"""
self.network_status = self.get_network_status()
self.name = self.network_status.get('network_name', 'Unknown')
self.location_info = self.get_location_info()
self.device_info = self.get_device_info()
self.device_id = (
... | [
"def",
"initialize",
"(",
"self",
")",
":",
"self",
".",
"network_status",
"=",
"self",
".",
"get_network_status",
"(",
")",
"self",
".",
"name",
"=",
"self",
".",
"network_status",
".",
"get",
"(",
"'network_name'",
",",
"'Unknown'",
")",
"self",
".",
"... | initialize the object | [
"initialize",
"the",
"object"
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/__init__.py#L84-L95 | train | initialize the object |
jalmeroth/pymusiccast | pymusiccast/__init__.py | McDevice.initialize_socket | def initialize_socket(self):
"""initialize the socket"""
try:
_LOGGER.debug("Trying to open socket.")
self._socket = socket.socket(
socket.AF_INET, # IPv4
socket.SOCK_DGRAM # UDP
)
self._socket.bind(('', self._udp_port... | python | def initialize_socket(self):
"""initialize the socket"""
try:
_LOGGER.debug("Trying to open socket.")
self._socket = socket.socket(
socket.AF_INET, # IPv4
socket.SOCK_DGRAM # UDP
)
self._socket.bind(('', self._udp_port... | [
"def",
"initialize_socket",
"(",
"self",
")",
":",
"try",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Trying to open socket.\"",
")",
"self",
".",
"_socket",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"# IPv4",
"socket",
".",
"SOCK_DGRAM",
... | initialize the socket | [
"initialize",
"the",
"socket"
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/__init__.py#L97-L114 | train | Open and initialize the socket. |
jalmeroth/pymusiccast | pymusiccast/__init__.py | McDevice.initialize_worker | def initialize_worker(self):
"""initialize the worker thread"""
worker_thread = threading.Thread(
name="WorkerThread", target=message_worker, args=(self,))
worker_thread.setDaemon(True)
worker_thread.start() | python | def initialize_worker(self):
"""initialize the worker thread"""
worker_thread = threading.Thread(
name="WorkerThread", target=message_worker, args=(self,))
worker_thread.setDaemon(True)
worker_thread.start() | [
"def",
"initialize_worker",
"(",
"self",
")",
":",
"worker_thread",
"=",
"threading",
".",
"Thread",
"(",
"name",
"=",
"\"WorkerThread\"",
",",
"target",
"=",
"message_worker",
",",
"args",
"=",
"(",
"self",
",",
")",
")",
"worker_thread",
".",
"setDaemon",
... | initialize the worker thread | [
"initialize",
"the",
"worker",
"thread"
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/__init__.py#L116-L121 | train | initialize the worker thread |
jalmeroth/pymusiccast | pymusiccast/__init__.py | McDevice.initialize_zones | def initialize_zones(self):
"""initialize receiver zones"""
zone_list = self.location_info.get('zone_list', {'main': True})
for zone_id in zone_list:
if zone_list[zone_id]: # Location setup is valid
self.zones[zone_id] = Zone(self, zone_id=zone_id)
else:... | python | def initialize_zones(self):
"""initialize receiver zones"""
zone_list = self.location_info.get('zone_list', {'main': True})
for zone_id in zone_list:
if zone_list[zone_id]: # Location setup is valid
self.zones[zone_id] = Zone(self, zone_id=zone_id)
else:... | [
"def",
"initialize_zones",
"(",
"self",
")",
":",
"zone_list",
"=",
"self",
".",
"location_info",
".",
"get",
"(",
"'zone_list'",
",",
"{",
"'main'",
":",
"True",
"}",
")",
"for",
"zone_id",
"in",
"zone_list",
":",
"if",
"zone_list",
"[",
"zone_id",
"]",... | initialize receiver zones | [
"initialize",
"receiver",
"zones"
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/__init__.py#L123-L131 | train | initialize receiver zones |
jalmeroth/pymusiccast | pymusiccast/__init__.py | McDevice.get_status | def get_status(self):
"""Get status from device to register/keep alive UDP"""
headers = {
"X-AppName": "MusicCast/0.1(python)",
"X-AppPort": str(self._udp_port)
}
req_url = ENDPOINTS["getStatus"].format(self.ip_address, 'main')
return request(req_url, head... | python | def get_status(self):
"""Get status from device to register/keep alive UDP"""
headers = {
"X-AppName": "MusicCast/0.1(python)",
"X-AppPort": str(self._udp_port)
}
req_url = ENDPOINTS["getStatus"].format(self.ip_address, 'main')
return request(req_url, head... | [
"def",
"get_status",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"\"X-AppName\"",
":",
"\"MusicCast/0.1(python)\"",
",",
"\"X-AppPort\"",
":",
"str",
"(",
"self",
".",
"_udp_port",
")",
"}",
"req_url",
"=",
"ENDPOINTS",
"[",
"\"getStatus\"",
"]",
".",
"forma... | Get status from device to register/keep alive UDP | [
"Get",
"status",
"from",
"device",
"to",
"register",
"/",
"keep",
"alive",
"UDP"
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/__init__.py#L153-L160 | train | Get status from device to register keep alive UDP |
jalmeroth/pymusiccast | pymusiccast/__init__.py | McDevice.handle_status | def handle_status(self):
"""Handle status from device"""
status = self.get_status()
if status:
# Update main-zone
self.zones['main'].update_status(status) | python | def handle_status(self):
"""Handle status from device"""
status = self.get_status()
if status:
# Update main-zone
self.zones['main'].update_status(status) | [
"def",
"handle_status",
"(",
"self",
")",
":",
"status",
"=",
"self",
".",
"get_status",
"(",
")",
"if",
"status",
":",
"# Update main-zone",
"self",
".",
"zones",
"[",
"'main'",
"]",
".",
"update_status",
"(",
"status",
")"
] | Handle status from device | [
"Handle",
"status",
"from",
"device"
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/__init__.py#L162-L168 | train | Handle status from device |
jalmeroth/pymusiccast | pymusiccast/__init__.py | McDevice.handle_netusb | def handle_netusb(self, message):
"""Handles 'netusb' in message"""
# _LOGGER.debug("message: {}".format(message))
needs_update = 0
if self._yamaha:
if 'play_info_updated' in message:
play_info = self.get_play_info()
# _LOGGER.debug(play_info)... | python | def handle_netusb(self, message):
"""Handles 'netusb' in message"""
# _LOGGER.debug("message: {}".format(message))
needs_update = 0
if self._yamaha:
if 'play_info_updated' in message:
play_info = self.get_play_info()
# _LOGGER.debug(play_info)... | [
"def",
"handle_netusb",
"(",
"self",
",",
"message",
")",
":",
"# _LOGGER.debug(\"message: {}\".format(message))",
"needs_update",
"=",
"0",
"if",
"self",
".",
"_yamaha",
":",
"if",
"'play_info_updated'",
"in",
"message",
":",
"play_info",
"=",
"self",
".",
"get_p... | Handles 'netusb' in message | [
"Handles",
"netusb",
"in",
"message"
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/__init__.py#L170-L203 | train | Handle a netusb message. |
jalmeroth/pymusiccast | pymusiccast/__init__.py | McDevice.handle_features | def handle_features(self, device_features):
"""Handles features of the device"""
self.device_features = device_features
if device_features and 'zone' in device_features:
for zone in device_features['zone']:
zone_id = zone.get('id')
if zone_id in self... | python | def handle_features(self, device_features):
"""Handles features of the device"""
self.device_features = device_features
if device_features and 'zone' in device_features:
for zone in device_features['zone']:
zone_id = zone.get('id')
if zone_id in self... | [
"def",
"handle_features",
"(",
"self",
",",
"device_features",
")",
":",
"self",
".",
"device_features",
"=",
"device_features",
"if",
"device_features",
"and",
"'zone'",
"in",
"device_features",
":",
"for",
"zone",
"in",
"device_features",
"[",
"'zone'",
"]",
"... | Handles features of the device | [
"Handles",
"features",
"of",
"the",
"device"
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/__init__.py#L205-L217 | train | Handles features of the device. |
jalmeroth/pymusiccast | pymusiccast/__init__.py | McDevice.handle_event | def handle_event(self, message):
"""Dispatch all event messages"""
# _LOGGER.debug(message)
needs_update = 0
for zone in self.zones:
if zone in message:
_LOGGER.debug("Received message for zone: %s", zone)
self.zones[zone].update_status(message... | python | def handle_event(self, message):
"""Dispatch all event messages"""
# _LOGGER.debug(message)
needs_update = 0
for zone in self.zones:
if zone in message:
_LOGGER.debug("Received message for zone: %s", zone)
self.zones[zone].update_status(message... | [
"def",
"handle_event",
"(",
"self",
",",
"message",
")",
":",
"# _LOGGER.debug(message)",
"needs_update",
"=",
"0",
"for",
"zone",
"in",
"self",
".",
"zones",
":",
"if",
"zone",
"in",
"message",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Received message for zone: ... | Dispatch all event messages | [
"Dispatch",
"all",
"event",
"messages"
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/__init__.py#L219-L233 | train | Dispatch all event messages. |
jalmeroth/pymusiccast | pymusiccast/__init__.py | McDevice.update_status | def update_status(self, reset=False):
"""Update device status."""
if self.healthy_update_timer and not reset:
return
# get device features only once
if not self.device_features:
self.handle_features(self.get_features())
# Get status from device to regist... | python | def update_status(self, reset=False):
"""Update device status."""
if self.healthy_update_timer and not reset:
return
# get device features only once
if not self.device_features:
self.handle_features(self.get_features())
# Get status from device to regist... | [
"def",
"update_status",
"(",
"self",
",",
"reset",
"=",
"False",
")",
":",
"if",
"self",
".",
"healthy_update_timer",
"and",
"not",
"reset",
":",
"return",
"# get device features only once",
"if",
"not",
"self",
".",
"device_features",
":",
"self",
".",
"handl... | Update device status. | [
"Update",
"device",
"status",
"."
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/__init__.py#L239-L252 | train | Update status of the device. |
jalmeroth/pymusiccast | pymusiccast/__init__.py | McDevice.setup_update_timer | def setup_update_timer(self, reset=False):
"""Schedule a Timer Thread."""
_LOGGER.debug("Timer: firing again in %d seconds", self._interval)
self.update_status_timer = threading.Timer(
self._interval, self.update_status, [True])
self.update_status_timer.setDaemon(True)
... | python | def setup_update_timer(self, reset=False):
"""Schedule a Timer Thread."""
_LOGGER.debug("Timer: firing again in %d seconds", self._interval)
self.update_status_timer = threading.Timer(
self._interval, self.update_status, [True])
self.update_status_timer.setDaemon(True)
... | [
"def",
"setup_update_timer",
"(",
"self",
",",
"reset",
"=",
"False",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Timer: firing again in %d seconds\"",
",",
"self",
".",
"_interval",
")",
"self",
".",
"update_status_timer",
"=",
"threading",
".",
"Timer",
"(",
... | Schedule a Timer Thread. | [
"Schedule",
"a",
"Timer",
"Thread",
"."
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/__init__.py#L254-L260 | train | Schedule a Timer Thread. |
jalmeroth/pymusiccast | pymusiccast/__init__.py | McDevice.set_playback | def set_playback(self, playback):
"""Send Playback command."""
req_url = ENDPOINTS["setPlayback"].format(self._ip_address)
params = {"playback": playback}
return request(req_url, params=params) | python | def set_playback(self, playback):
"""Send Playback command."""
req_url = ENDPOINTS["setPlayback"].format(self._ip_address)
params = {"playback": playback}
return request(req_url, params=params) | [
"def",
"set_playback",
"(",
"self",
",",
"playback",
")",
":",
"req_url",
"=",
"ENDPOINTS",
"[",
"\"setPlayback\"",
"]",
".",
"format",
"(",
"self",
".",
"_ip_address",
")",
"params",
"=",
"{",
"\"playback\"",
":",
"playback",
"}",
"return",
"request",
"("... | Send Playback command. | [
"Send",
"Playback",
"command",
"."
] | 616379ae22d6b518c61042d58be6d18a46242168 | https://github.com/jalmeroth/pymusiccast/blob/616379ae22d6b518c61042d58be6d18a46242168/pymusiccast/__init__.py#L272-L276 | train | Send Playback command. |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant.py | VariantMixin.build_gemini_query | def build_gemini_query(self, query, extra_info):
"""Append sql to a gemini query
Args:
query(str): The gemini query
extra_info(str): The text that should be added
Return:
extended_query(str)
"""
if 'WHERE' in query:
return "{0} AN... | python | def build_gemini_query(self, query, extra_info):
"""Append sql to a gemini query
Args:
query(str): The gemini query
extra_info(str): The text that should be added
Return:
extended_query(str)
"""
if 'WHERE' in query:
return "{0} AN... | [
"def",
"build_gemini_query",
"(",
"self",
",",
"query",
",",
"extra_info",
")",
":",
"if",
"'WHERE'",
"in",
"query",
":",
"return",
"\"{0} AND {1}\"",
".",
"format",
"(",
"query",
",",
"extra_info",
")",
"else",
":",
"return",
"\"{0} WHERE {1}\"",
".",
"form... | Append sql to a gemini query
Args:
query(str): The gemini query
extra_info(str): The text that should be added
Return:
extended_query(str) | [
"Append",
"sql",
"to",
"a",
"gemini",
"query"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant.py#L20-L33 | train | Append sql to a gemini query |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant.py | VariantMixin.variants | def variants(self, case_id, skip=0, count=1000, filters=None):
"""Return count variants for a case.
This function needs to have different behaviours based on what is asked
for. It should allways try to give minimal information back to improve
on speed. For example, if consequences are n... | python | def variants(self, case_id, skip=0, count=1000, filters=None):
"""Return count variants for a case.
This function needs to have different behaviours based on what is asked
for. It should allways try to give minimal information back to improve
on speed. For example, if consequences are n... | [
"def",
"variants",
"(",
"self",
",",
"case_id",
",",
"skip",
"=",
"0",
",",
"count",
"=",
"1000",
",",
"filters",
"=",
"None",
")",
":",
"filters",
"=",
"filters",
"or",
"{",
"}",
"logger",
".",
"debug",
"(",
"\"Looking for variants in {0}\"",
".",
"fo... | Return count variants for a case.
This function needs to have different behaviours based on what is asked
for. It should allways try to give minimal information back to improve
on speed. For example, if consequences are not asked for we will not
build all transcripts. If not sv variants... | [
"Return",
"count",
"variants",
"for",
"a",
"case",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant.py#L35-L144 | train | Return the number of variants in a gemini db. |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant.py | VariantMixin.variant | def variant(self, case_id, variant_id):
"""Return a specific variant.
We solve this by building a gemini query and send it to _variants
Args:
case_id (str): Path to a gemini database
variant_id (int): A gemini variant id
Returns:
... | python | def variant(self, case_id, variant_id):
"""Return a specific variant.
We solve this by building a gemini query and send it to _variants
Args:
case_id (str): Path to a gemini database
variant_id (int): A gemini variant id
Returns:
... | [
"def",
"variant",
"(",
"self",
",",
"case_id",
",",
"variant_id",
")",
":",
"#Use the gemini id for fast lookup",
"variant_id",
"=",
"int",
"(",
"variant_id",
")",
"gemini_query",
"=",
"\"SELECT * from variants WHERE variant_id = {0}\"",
".",
"format",
"(",
"variant_id"... | Return a specific variant.
We solve this by building a gemini query and send it to _variants
Args:
case_id (str): Path to a gemini database
variant_id (int): A gemini variant id
Returns:
variant_obj (dict): A puzzle variant | [
"Return",
"a",
"specific",
"variant",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant.py#L146-L187 | train | Return a specific variant. |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant.py | VariantMixin._variants | def _variants(self, case_id, gemini_query):
"""Return variants found in the gemini database
Args:
case_id (str): The case for which we want to see information
gemini_query (str): What variants should be chosen
filters (dict): A dictionary with filters... | python | def _variants(self, case_id, gemini_query):
"""Return variants found in the gemini database
Args:
case_id (str): The case for which we want to see information
gemini_query (str): What variants should be chosen
filters (dict): A dictionary with filters... | [
"def",
"_variants",
"(",
"self",
",",
"case_id",
",",
"gemini_query",
")",
":",
"individuals",
"=",
"[",
"]",
"# Get the individuals for the case",
"case_obj",
"=",
"self",
".",
"case",
"(",
"case_id",
")",
"for",
"individual",
"in",
"case_obj",
".",
"individu... | Return variants found in the gemini database
Args:
case_id (str): The case for which we want to see information
gemini_query (str): What variants should be chosen
filters (dict): A dictionary with filters
Yields:
variant_obj (dict... | [
"Return",
"variants",
"found",
"in",
"the",
"gemini",
"database"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant.py#L189-L235 | train | Returns a generator that yields all the variants in the gemini database. |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant.py | VariantMixin._format_variant | def _format_variant(self, case_id, gemini_variant, individual_objs,
index=0, add_all_info=False):
"""Make a puzzle variant from a gemini variant
Args:
case_id (str): related case id
gemini_variant (GeminiQueryRow): The gemini variant
... | python | def _format_variant(self, case_id, gemini_variant, individual_objs,
index=0, add_all_info=False):
"""Make a puzzle variant from a gemini variant
Args:
case_id (str): related case id
gemini_variant (GeminiQueryRow): The gemini variant
... | [
"def",
"_format_variant",
"(",
"self",
",",
"case_id",
",",
"gemini_variant",
",",
"individual_objs",
",",
"index",
"=",
"0",
",",
"add_all_info",
"=",
"False",
")",
":",
"chrom",
"=",
"gemini_variant",
"[",
"'chrom'",
"]",
"if",
"chrom",
".",
"startswith",
... | Make a puzzle variant from a gemini variant
Args:
case_id (str): related case id
gemini_variant (GeminiQueryRow): The gemini variant
individual_objs (list(dict)): A list of Individuals
index(int): The index of the variant
Returns:... | [
"Make",
"a",
"puzzle",
"variant",
"from",
"a",
"gemini",
"variant"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant.py#L237-L323 | train | Create a puzzle variant from a gemini variant. |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant.py | VariantMixin._is_variant | def _is_variant(self, gemini_variant, ind_objs):
"""Check if the variant is a variation in any of the individuals
Args:
gemini_variant (GeminiQueryRow): The gemini variant
ind_objs (list(puzzle.models.individual)): A list of individuals to check
Returns:
boo... | python | def _is_variant(self, gemini_variant, ind_objs):
"""Check if the variant is a variation in any of the individuals
Args:
gemini_variant (GeminiQueryRow): The gemini variant
ind_objs (list(puzzle.models.individual)): A list of individuals to check
Returns:
boo... | [
"def",
"_is_variant",
"(",
"self",
",",
"gemini_variant",
",",
"ind_objs",
")",
":",
"indexes",
"=",
"(",
"ind",
".",
"ind_index",
"for",
"ind",
"in",
"ind_objs",
")",
"#Check if any individual have a heterozygous or homozygous variant call",
"for",
"index",
"in",
"... | Check if the variant is a variation in any of the individuals
Args:
gemini_variant (GeminiQueryRow): The gemini variant
ind_objs (list(puzzle.models.individual)): A list of individuals to check
Returns:
bool : If any of the individuals has the variant | [
"Check",
"if",
"the",
"variant",
"is",
"a",
"variation",
"in",
"any",
"of",
"the",
"individuals"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant.py#L325-L343 | train | Check if the variant is a variation in any of the individuals
|
robinandeer/puzzle | puzzle/models/mixins.py | PedigreeHumanMixin.is_affected | def is_affected(self):
"""Boolean for telling if the sample is affected."""
phenotype = self.phenotype
if phenotype == '1':
return False
elif phenotype == '2':
return True
else:
return False | python | def is_affected(self):
"""Boolean for telling if the sample is affected."""
phenotype = self.phenotype
if phenotype == '1':
return False
elif phenotype == '2':
return True
else:
return False | [
"def",
"is_affected",
"(",
"self",
")",
":",
"phenotype",
"=",
"self",
".",
"phenotype",
"if",
"phenotype",
"==",
"'1'",
":",
"return",
"False",
"elif",
"phenotype",
"==",
"'2'",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | Boolean for telling if the sample is affected. | [
"Boolean",
"for",
"telling",
"if",
"the",
"sample",
"is",
"affected",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/models/mixins.py#L17-L25 | train | Boolean for telling if the sample is affected. |
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/genelist.py | GeneListActions.gene_list | def gene_list(self, list_id):
"""Get a gene list from the database."""
return self.query(GeneList).filter_by(list_id=list_id).first() | python | def gene_list(self, list_id):
"""Get a gene list from the database."""
return self.query(GeneList).filter_by(list_id=list_id).first() | [
"def",
"gene_list",
"(",
"self",
",",
"list_id",
")",
":",
"return",
"self",
".",
"query",
"(",
"GeneList",
")",
".",
"filter_by",
"(",
"list_id",
"=",
"list_id",
")",
".",
"first",
"(",
")"
] | Get a gene list from the database. | [
"Get",
"a",
"gene",
"list",
"from",
"the",
"database",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/genelist.py#L6-L8 | train | Get a gene list from the database. |
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/genelist.py | GeneListActions.add_genelist | def add_genelist(self, list_id, gene_ids, case_obj=None):
"""Create a new gene list and optionally link to cases."""
new_genelist = GeneList(list_id=list_id)
new_genelist.gene_ids = gene_ids
if case_obj:
new_genelist.cases.append(case_obj)
self.session.add(new_geneli... | python | def add_genelist(self, list_id, gene_ids, case_obj=None):
"""Create a new gene list and optionally link to cases."""
new_genelist = GeneList(list_id=list_id)
new_genelist.gene_ids = gene_ids
if case_obj:
new_genelist.cases.append(case_obj)
self.session.add(new_geneli... | [
"def",
"add_genelist",
"(",
"self",
",",
"list_id",
",",
"gene_ids",
",",
"case_obj",
"=",
"None",
")",
":",
"new_genelist",
"=",
"GeneList",
"(",
"list_id",
"=",
"list_id",
")",
"new_genelist",
".",
"gene_ids",
"=",
"gene_ids",
"if",
"case_obj",
":",
"new... | Create a new gene list and optionally link to cases. | [
"Create",
"a",
"new",
"gene",
"list",
"and",
"optionally",
"link",
"to",
"cases",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/genelist.py#L14-L23 | train | Create a new gene list and optionally link to cases. |
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/genelist.py | GeneListActions.remove_genelist | def remove_genelist(self, list_id, case_obj=None):
"""Remove a gene list and links to cases."""
gene_list = self.gene_list(list_id)
if case_obj:
# remove a single link between case and gene list
case_ids = [case_obj.id]
else:
# remove all links and th... | python | def remove_genelist(self, list_id, case_obj=None):
"""Remove a gene list and links to cases."""
gene_list = self.gene_list(list_id)
if case_obj:
# remove a single link between case and gene list
case_ids = [case_obj.id]
else:
# remove all links and th... | [
"def",
"remove_genelist",
"(",
"self",
",",
"list_id",
",",
"case_obj",
"=",
"None",
")",
":",
"gene_list",
"=",
"self",
".",
"gene_list",
"(",
"list_id",
")",
"if",
"case_obj",
":",
"# remove a single link between case and gene list",
"case_ids",
"=",
"[",
"cas... | Remove a gene list and links to cases. | [
"Remove",
"a",
"gene",
"list",
"and",
"links",
"to",
"cases",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/genelist.py#L25-L44 | train | Remove a gene list and links to cases. |
robinandeer/puzzle | puzzle/plugins/sql/mixins/actions/genelist.py | GeneListActions.case_genelist | def case_genelist(self, case_obj):
"""Get or create a new case specific gene list record."""
list_id = "{}-HPO".format(case_obj.case_id)
gene_list = self.gene_list(list_id)
if gene_list is None:
gene_list = GeneList(list_id=list_id)
case_obj.gene_lists.append(gen... | python | def case_genelist(self, case_obj):
"""Get or create a new case specific gene list record."""
list_id = "{}-HPO".format(case_obj.case_id)
gene_list = self.gene_list(list_id)
if gene_list is None:
gene_list = GeneList(list_id=list_id)
case_obj.gene_lists.append(gen... | [
"def",
"case_genelist",
"(",
"self",
",",
"case_obj",
")",
":",
"list_id",
"=",
"\"{}-HPO\"",
".",
"format",
"(",
"case_obj",
".",
"case_id",
")",
"gene_list",
"=",
"self",
".",
"gene_list",
"(",
"list_id",
")",
"if",
"gene_list",
"is",
"None",
":",
"gen... | Get or create a new case specific gene list record. | [
"Get",
"or",
"create",
"a",
"new",
"case",
"specific",
"gene",
"list",
"record",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/sql/mixins/actions/genelist.py#L46-L56 | train | Get or create a new case specific gene list record. |
ldomic/lintools | lintools/figure.py | Figure.manage_the_plots | def manage_the_plots(self):
"""
Each plotted residue SVG file is edited and the contents of the file transfered into
an SVG group (g). This allows a plot to be included in the final image and the group
transform function allows to move the plot to the correct 2D coordinates in respect
... | python | def manage_the_plots(self):
"""
Each plotted residue SVG file is edited and the contents of the file transfered into
an SVG group (g). This allows a plot to be included in the final image and the group
transform function allows to move the plot to the correct 2D coordinates in respect
... | [
"def",
"manage_the_plots",
"(",
"self",
")",
":",
"diagram",
"=",
"\"\"",
"for",
"residue",
"in",
"sorted",
"(",
"self",
".",
"molecule",
".",
"nearest_points_coords",
".",
"keys",
"(",
")",
")",
":",
"for",
"i",
",",
"line",
"in",
"enumerate",
"(",
"f... | Each plotted residue SVG file is edited and the contents of the file transfered into
an SVG group (g). This allows a plot to be included in the final image and the group
transform function allows to move the plot to the correct 2D coordinates in respect
to the 2D drug molecule. The groups are ad... | [
"Each",
"plotted",
"residue",
"SVG",
"file",
"is",
"edited",
"and",
"the",
"contents",
"of",
"the",
"file",
"transfered",
"into",
"an",
"SVG",
"group",
"(",
"g",
")",
".",
"This",
"allows",
"a",
"plot",
"to",
"be",
"included",
"in",
"the",
"final",
"im... | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/figure.py#L29-L56 | train | This function handles the actual plotting of the 2D drug molecule. |
ldomic/lintools | lintools/figure.py | Figure.add_bigger_box | def add_bigger_box(self):
"""
Sets the size of the figure by expanding the space of molecule.svg file. These dimension have been
previously determined. Also makes the lines of the molecule thicker.
"""
start1 = "width='"+str(int(self.molecule.molsize1))+"px' height='"+str(int(sel... | python | def add_bigger_box(self):
"""
Sets the size of the figure by expanding the space of molecule.svg file. These dimension have been
previously determined. Also makes the lines of the molecule thicker.
"""
start1 = "width='"+str(int(self.molecule.molsize1))+"px' height='"+str(int(sel... | [
"def",
"add_bigger_box",
"(",
"self",
")",
":",
"start1",
"=",
"\"width='\"",
"+",
"str",
"(",
"int",
"(",
"self",
".",
"molecule",
".",
"molsize1",
")",
")",
"+",
"\"px' height='\"",
"+",
"str",
"(",
"int",
"(",
"self",
".",
"molecule",
".",
"molsize2... | Sets the size of the figure by expanding the space of molecule.svg file. These dimension have been
previously determined. Also makes the lines of the molecule thicker. | [
"Sets",
"the",
"size",
"of",
"the",
"figure",
"by",
"expanding",
"the",
"space",
"of",
"molecule",
".",
"svg",
"file",
".",
"These",
"dimension",
"have",
"been",
"previously",
"determined",
".",
"Also",
"makes",
"the",
"lines",
"of",
"the",
"molecule",
"th... | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/figure.py#L57-L80 | train | Adds the bigger box to the figure. |
ldomic/lintools | lintools/figure.py | Figure.draw_white_circles | def draw_white_circles(self):
"""
The plots are transparent and therefore this function is required to cover up the middle
part of the plots (that contains text). This function creates white circles that provide
background.
"""
for atom in sorted(self.molecule.nearest_poi... | python | def draw_white_circles(self):
"""
The plots are transparent and therefore this function is required to cover up the middle
part of the plots (that contains text). This function creates white circles that provide
background.
"""
for atom in sorted(self.molecule.nearest_poi... | [
"def",
"draw_white_circles",
"(",
"self",
")",
":",
"for",
"atom",
"in",
"sorted",
"(",
"self",
".",
"molecule",
".",
"nearest_points_coords",
".",
"keys",
"(",
")",
")",
":",
"self",
".",
"white_circles",
"=",
"self",
".",
"white_circles",
"+",
"\"<circle... | The plots are transparent and therefore this function is required to cover up the middle
part of the plots (that contains text). This function creates white circles that provide
background. | [
"The",
"plots",
"are",
"transparent",
"and",
"therefore",
"this",
"function",
"is",
"required",
"to",
"cover",
"up",
"the",
"middle",
"part",
"of",
"the",
"plots",
"(",
"that",
"contains",
"text",
")",
".",
"This",
"function",
"creates",
"white",
"circles",
... | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/figure.py#L81-L88 | train | This function creates white circles that are used to cover the middle
part of the plots. |
ldomic/lintools | lintools/figure.py | Figure.put_everything_together | def put_everything_together(self):
"""
All of the elements of the final SVG file are put together in the correct order (e.g. lines are placed behind plots
and the molecule).
"""
molecule_list = [self.filestart]+[self.white_circles]+[self.draw_molecule]+[self.draw.draw_hbonds]+[se... | python | def put_everything_together(self):
"""
All of the elements of the final SVG file are put together in the correct order (e.g. lines are placed behind plots
and the molecule).
"""
molecule_list = [self.filestart]+[self.white_circles]+[self.draw_molecule]+[self.draw.draw_hbonds]+[se... | [
"def",
"put_everything_together",
"(",
"self",
")",
":",
"molecule_list",
"=",
"[",
"self",
".",
"filestart",
"]",
"+",
"[",
"self",
".",
"white_circles",
"]",
"+",
"[",
"self",
".",
"draw_molecule",
"]",
"+",
"[",
"self",
".",
"draw",
".",
"draw_hbonds"... | All of the elements of the final SVG file are put together in the correct order (e.g. lines are placed behind plots
and the molecule). | [
"All",
"of",
"the",
"elements",
"of",
"the",
"final",
"SVG",
"file",
"are",
"put",
"together",
"in",
"the",
"correct",
"order",
"(",
"e",
".",
"g",
".",
"lines",
"are",
"placed",
"behind",
"plots",
"and",
"the",
"molecule",
")",
"."
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/figure.py#L90-L96 | train | This method is used to put all the elements of the final SVG file together in the correct order. |
ldomic/lintools | lintools/figure.py | Figure.write_final_draw_file | def write_final_draw_file(self, output_name):
"""The result of put_everything_together() function is writen in a file.
Takes:
* output_name * - name for the output file
"""
finalsvg = open(output_name+".svg","w")
finalsvg.writelines(self.final_molecule)
finals... | python | def write_final_draw_file(self, output_name):
"""The result of put_everything_together() function is writen in a file.
Takes:
* output_name * - name for the output file
"""
finalsvg = open(output_name+".svg","w")
finalsvg.writelines(self.final_molecule)
finals... | [
"def",
"write_final_draw_file",
"(",
"self",
",",
"output_name",
")",
":",
"finalsvg",
"=",
"open",
"(",
"output_name",
"+",
"\".svg\"",
",",
"\"w\"",
")",
"finalsvg",
".",
"writelines",
"(",
"self",
".",
"final_molecule",
")",
"finalsvg",
".",
"close",
"(",... | The result of put_everything_together() function is writen in a file.
Takes:
* output_name * - name for the output file | [
"The",
"result",
"of",
"put_everything_together",
"()",
"function",
"is",
"writen",
"in",
"a",
"file",
".",
"Takes",
":",
"*",
"output_name",
"*",
"-",
"name",
"for",
"the",
"output",
"file"
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/figure.py#L97-L104 | train | This function writes the final draw file in the specified output_name. |
ellethee/argparseinator | argparseinator/__init__.py | formatter_factory | def formatter_factory(show_defaults=True):
"""Formatter factory"""
def get_help_string(self, action):
lhelp = action.help
if isinstance(show_defaults, (list, tuple)):
if "-" + action.dest in show_defaults:
return lhelp
if '%(default)' not in action.help:
... | python | def formatter_factory(show_defaults=True):
"""Formatter factory"""
def get_help_string(self, action):
lhelp = action.help
if isinstance(show_defaults, (list, tuple)):
if "-" + action.dest in show_defaults:
return lhelp
if '%(default)' not in action.help:
... | [
"def",
"formatter_factory",
"(",
"show_defaults",
"=",
"True",
")",
":",
"def",
"get_help_string",
"(",
"self",
",",
"action",
")",
":",
"lhelp",
"=",
"action",
".",
"help",
"if",
"isinstance",
"(",
"show_defaults",
",",
"(",
"list",
",",
"tuple",
")",
"... | Formatter factory | [
"Formatter",
"factory"
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L65-L85 | train | A factory for creating the ARPIFormatter class. |
ellethee/argparseinator | argparseinator/__init__.py | extend_with | def extend_with(func):
"""Extends with class or function"""
if not func.__name__ in ArgParseInator._plugins:
ArgParseInator._plugins[func.__name__] = func | python | def extend_with(func):
"""Extends with class or function"""
if not func.__name__ in ArgParseInator._plugins:
ArgParseInator._plugins[func.__name__] = func | [
"def",
"extend_with",
"(",
"func",
")",
":",
"if",
"not",
"func",
".",
"__name__",
"in",
"ArgParseInator",
".",
"_plugins",
":",
"ArgParseInator",
".",
"_plugins",
"[",
"func",
".",
"__name__",
"]",
"=",
"func"
] | Extends with class or function | [
"Extends",
"with",
"class",
"or",
"function"
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L599-L602 | train | Extends with class or function |
ellethee/argparseinator | argparseinator/__init__.py | arg | def arg(*args, **kwargs):
"""
Dcorates a function or a class method to add to the argument parser
"""
def decorate(func):
"""
Decorate
"""
# we'll set the command name with the passed cmd_name argument, if
# exist, else the command name will be the function name
... | python | def arg(*args, **kwargs):
"""
Dcorates a function or a class method to add to the argument parser
"""
def decorate(func):
"""
Decorate
"""
# we'll set the command name with the passed cmd_name argument, if
# exist, else the command name will be the function name
... | [
"def",
"arg",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorate",
"(",
"func",
")",
":",
"\"\"\"\n Decorate\n \"\"\"",
"# we'll set the command name with the passed cmd_name argument, if",
"# exist, else the command name will be the function na... | Dcorates a function or a class method to add to the argument parser | [
"Dcorates",
"a",
"function",
"or",
"a",
"class",
"method",
"to",
"add",
"to",
"the",
"argument",
"parser"
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L605-L648 | train | Decorator that adds an argument to the argument parser. |
ellethee/argparseinator | argparseinator/__init__.py | class_args | def class_args(cls):
"""
Decorates a class to handle the arguments parser.
"""
# get the Singleton
ap_ = ArgParseInator(skip_init=True)
# collect special vars (really need?)
utils.collect_appendvars(ap_, cls)
# set class reference
cls.__cls__ = cls
cmds = {}
# get eventual cl... | python | def class_args(cls):
"""
Decorates a class to handle the arguments parser.
"""
# get the Singleton
ap_ = ArgParseInator(skip_init=True)
# collect special vars (really need?)
utils.collect_appendvars(ap_, cls)
# set class reference
cls.__cls__ = cls
cmds = {}
# get eventual cl... | [
"def",
"class_args",
"(",
"cls",
")",
":",
"# get the Singleton",
"ap_",
"=",
"ArgParseInator",
"(",
"skip_init",
"=",
"True",
")",
"# collect special vars (really need?)",
"utils",
".",
"collect_appendvars",
"(",
"ap_",
",",
"cls",
")",
"# set class reference",
"cl... | Decorates a class to handle the arguments parser. | [
"Decorates",
"a",
"class",
"to",
"handle",
"the",
"arguments",
"parser",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L651-L687 | train | Decorates a class to handle the arguments parser. |
ellethee/argparseinator | argparseinator/__init__.py | cmd_auth | def cmd_auth(auth_phrase=None):
"""
set authorization for command or subcommand.
"""
def decorate(func):
"""
decorates the funcion
"""
# get the Singleton
ap_ = ArgParseInator(skip_init=True)
# set the authorization name
auth_name = id(func)
... | python | def cmd_auth(auth_phrase=None):
"""
set authorization for command or subcommand.
"""
def decorate(func):
"""
decorates the funcion
"""
# get the Singleton
ap_ = ArgParseInator(skip_init=True)
# set the authorization name
auth_name = id(func)
... | [
"def",
"cmd_auth",
"(",
"auth_phrase",
"=",
"None",
")",
":",
"def",
"decorate",
"(",
"func",
")",
":",
"\"\"\"\n decorates the funcion\n \"\"\"",
"# get the Singleton",
"ap_",
"=",
"ArgParseInator",
"(",
"skip_init",
"=",
"True",
")",
"# set the authori... | set authorization for command or subcommand. | [
"set",
"authorization",
"for",
"command",
"or",
"subcommand",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L697-L718 | train | Decorator for command or subcommand authorization. |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator._compile | def _compile(self, module=None):
"""
Compile functions for argparsing.
"""
# get the main module
mod = module or sys.modules['__main__']
self.mod = mod
# setup the script version
if hasattr(mod, '__version__'):
version = "%(prog)s " + mod.__ver... | python | def _compile(self, module=None):
"""
Compile functions for argparsing.
"""
# get the main module
mod = module or sys.modules['__main__']
self.mod = mod
# setup the script version
if hasattr(mod, '__version__'):
version = "%(prog)s " + mod.__ver... | [
"def",
"_compile",
"(",
"self",
",",
"module",
"=",
"None",
")",
":",
"# get the main module",
"mod",
"=",
"module",
"or",
"sys",
".",
"modules",
"[",
"'__main__'",
"]",
"self",
".",
"mod",
"=",
"mod",
"# setup the script version",
"if",
"hasattr",
"(",
"m... | Compile functions for argparsing. | [
"Compile",
"functions",
"for",
"argparsing",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L223-L316 | train | Compile functions for argparsing. |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator.parse_args | def parse_args(self):
"""
Parse our arguments.
"""
# compile the parser
self._compile()
# clear the args
self.args = None
self._self_event('before_parse', 'parse', *sys.argv[1:], **{})
# list commands/subcommands in argv
cmds = [cmd for cmd... | python | def parse_args(self):
"""
Parse our arguments.
"""
# compile the parser
self._compile()
# clear the args
self.args = None
self._self_event('before_parse', 'parse', *sys.argv[1:], **{})
# list commands/subcommands in argv
cmds = [cmd for cmd... | [
"def",
"parse_args",
"(",
"self",
")",
":",
"# compile the parser",
"self",
".",
"_compile",
"(",
")",
"# clear the args",
"self",
".",
"args",
"=",
"None",
"self",
".",
"_self_event",
"(",
"'before_parse'",
",",
"'parse'",
",",
"*",
"sys",
".",
"argv",
"[... | Parse our arguments. | [
"Parse",
"our",
"arguments",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L318-L362 | train | Parse our arguments. |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator.check_auth | def check_auth(self, name):
"""
Check the authorization for the command
"""
if name in self.auths:
# if the command name is in the **need authorization list**
# get the authorization for the command
auth = self.auths[name]
if self.args.auth... | python | def check_auth(self, name):
"""
Check the authorization for the command
"""
if name in self.auths:
# if the command name is in the **need authorization list**
# get the authorization for the command
auth = self.auths[name]
if self.args.auth... | [
"def",
"check_auth",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"auths",
":",
"# if the command name is in the **need authorization list**",
"# get the authorization for the command",
"auth",
"=",
"self",
".",
"auths",
"[",
"name",
"]",
"if... | Check the authorization for the command | [
"Check",
"the",
"authorization",
"for",
"the",
"command"
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L364-L380 | train | Check the authorization for the command name |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator.check_command | def check_command(self, **new_attributes):
"""
Check if 'was passed a valid action in the command line and if so,
executes it by passing parameters and returning the result.
:return: (Any) Return the result of the called function, if provided,
or None.
"""
... | python | def check_command(self, **new_attributes):
"""
Check if 'was passed a valid action in the command line and if so,
executes it by passing parameters and returning the result.
:return: (Any) Return the result of the called function, if provided,
or None.
"""
... | [
"def",
"check_command",
"(",
"self",
",",
"*",
"*",
"new_attributes",
")",
":",
"# let's parse arguments if we didn't before.",
"if",
"not",
"self",
".",
"_is_parsed",
":",
"self",
".",
"parse_args",
"(",
")",
"if",
"not",
"self",
".",
"commands",
":",
"# if w... | Check if 'was passed a valid action in the command line and if so,
executes it by passing parameters and returning the result.
:return: (Any) Return the result of the called function, if provided,
or None. | [
"Check",
"if",
"was",
"passed",
"a",
"valid",
"action",
"in",
"the",
"command",
"line",
"and",
"if",
"so",
"executes",
"it",
"by",
"passing",
"parameters",
"and",
"returning",
"the",
"result",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L382-L417 | train | Check if the command was passed and if so executes it by passing the parameters and returning the result. |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator._execute | def _execute(self, func, command, **new_attributes):
"""
Execute command.
"""
if self._cfg_factory:
# if we have a cfg_factory
try:
# we try to load a config with the factory
if self.cfg_file:
self.cfg = self._cf... | python | def _execute(self, func, command, **new_attributes):
"""
Execute command.
"""
if self._cfg_factory:
# if we have a cfg_factory
try:
# we try to load a config with the factory
if self.cfg_file:
self.cfg = self._cf... | [
"def",
"_execute",
"(",
"self",
",",
"func",
",",
"command",
",",
"*",
"*",
"new_attributes",
")",
":",
"if",
"self",
".",
"_cfg_factory",
":",
"# if we have a cfg_factory",
"try",
":",
"# we try to load a config with the factory",
"if",
"self",
".",
"cfg_file",
... | Execute command. | [
"Execute",
"command",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L423-L529 | train | Execute the command and return the result of the command. |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator._call_event | def _call_event(self, event_name, cmd, pargs, kwargs, **kws):
"""
Try to call events for cmd.
"""
def get_result_params(res):
"""return the right list of params"""
if not isinstance(res, (list, tuple)):
return res, pargs, kwargs
elif le... | python | def _call_event(self, event_name, cmd, pargs, kwargs, **kws):
"""
Try to call events for cmd.
"""
def get_result_params(res):
"""return the right list of params"""
if not isinstance(res, (list, tuple)):
return res, pargs, kwargs
elif le... | [
"def",
"_call_event",
"(",
"self",
",",
"event_name",
",",
"cmd",
",",
"pargs",
",",
"kwargs",
",",
"*",
"*",
"kws",
")",
":",
"def",
"get_result_params",
"(",
"res",
")",
":",
"\"\"\"return the right list of params\"\"\"",
"if",
"not",
"isinstance",
"(",
"r... | Try to call events for cmd. | [
"Try",
"to",
"call",
"events",
"for",
"cmd",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L531-L550 | train | Try to call events for the command object. |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator._self_event | def _self_event(self, event_name, cmd, *pargs, **kwargs):
"""Call self event"""
if hasattr(self, event_name):
getattr(self, event_name)(cmd, *pargs, **kwargs) | python | def _self_event(self, event_name, cmd, *pargs, **kwargs):
"""Call self event"""
if hasattr(self, event_name):
getattr(self, event_name)(cmd, *pargs, **kwargs) | [
"def",
"_self_event",
"(",
"self",
",",
"event_name",
",",
"cmd",
",",
"*",
"pargs",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"event_name",
")",
":",
"getattr",
"(",
"self",
",",
"event_name",
")",
"(",
"cmd",
",",
"*",... | Call self event | [
"Call",
"self",
"event"
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L552-L555 | train | Call self event |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator.add_event | def add_event(cls, event, event_name=None):
"""Add events"""
# setattr(cls, event_name, event)
event_name = event_name or event.__name__
setattr(cls, event_name, types.MethodType(event, cls)) | python | def add_event(cls, event, event_name=None):
"""Add events"""
# setattr(cls, event_name, event)
event_name = event_name or event.__name__
setattr(cls, event_name, types.MethodType(event, cls)) | [
"def",
"add_event",
"(",
"cls",
",",
"event",
",",
"event_name",
"=",
"None",
")",
":",
"# setattr(cls, event_name, event)",
"event_name",
"=",
"event_name",
"or",
"event",
".",
"__name__",
"setattr",
"(",
"cls",
",",
"event_name",
",",
"types",
".",
"MethodTy... | Add events | [
"Add",
"events"
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L559-L563 | train | Add an event to the log. |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator.write | def write(self, *string):
"""
Writes to the output
"""
self._output.write(' '.join([six.text_type(s) for s in string]))
return self | python | def write(self, *string):
"""
Writes to the output
"""
self._output.write(' '.join([six.text_type(s) for s in string]))
return self | [
"def",
"write",
"(",
"self",
",",
"*",
"string",
")",
":",
"self",
".",
"_output",
".",
"write",
"(",
"' '",
".",
"join",
"(",
"[",
"six",
".",
"text_type",
"(",
"s",
")",
"for",
"s",
"in",
"string",
"]",
")",
")",
"return",
"self"
] | Writes to the output | [
"Writes",
"to",
"the",
"output"
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L565-L570 | train | Writes to the output |
ellethee/argparseinator | argparseinator/__init__.py | ArgParseInator.exit | def exit(self, status=EXIT_OK, message=None):
"""
Terminate the script.
"""
if not self.parser:
self.parser = argparse.ArgumentParser()
if self.msg_on_error_only:
# if msg_on_error_only is True
if status != EXIT_OK:
# if we have... | python | def exit(self, status=EXIT_OK, message=None):
"""
Terminate the script.
"""
if not self.parser:
self.parser = argparse.ArgumentParser()
if self.msg_on_error_only:
# if msg_on_error_only is True
if status != EXIT_OK:
# if we have... | [
"def",
"exit",
"(",
"self",
",",
"status",
"=",
"EXIT_OK",
",",
"message",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"parser",
":",
"self",
".",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"if",
"self",
".",
"msg_on_error_only",
... | Terminate the script. | [
"Terminate",
"the",
"script",
"."
] | 05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e | https://github.com/ellethee/argparseinator/blob/05e9c00dfaa938b9c4ee2aadc6206f5e0918e24e/argparseinator/__init__.py#L580-L597 | train | Terminate the script. |
ldomic/lintools | lintools/analysis/sasa.py | SASA.analyse_ligand_sasa | def analyse_ligand_sasa(self):
"""Analysis of ligand SASA."""
i=0
start = timer()
if self.trajectory == []:
self.trajectory = [self.topology_data.universe.filename]
try:
for traj in self.trajectory:
new_traj = mdtraj.load(traj,top=self.topology_data.universe.filename)
#Analyse only non-H ligand
... | python | def analyse_ligand_sasa(self):
"""Analysis of ligand SASA."""
i=0
start = timer()
if self.trajectory == []:
self.trajectory = [self.topology_data.universe.filename]
try:
for traj in self.trajectory:
new_traj = mdtraj.load(traj,top=self.topology_data.universe.filename)
#Analyse only non-H ligand
... | [
"def",
"analyse_ligand_sasa",
"(",
"self",
")",
":",
"i",
"=",
"0",
"start",
"=",
"timer",
"(",
")",
"if",
"self",
".",
"trajectory",
"==",
"[",
"]",
":",
"self",
".",
"trajectory",
"=",
"[",
"self",
".",
"topology_data",
".",
"universe",
".",
"filen... | Analysis of ligand SASA. | [
"Analysis",
"of",
"ligand",
"SASA",
"."
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/analysis/sasa.py#L23-L43 | train | Analyse all ligand SASA. |
ldomic/lintools | lintools/analysis/sasa.py | SASA.assign_per_atom_sasa | def assign_per_atom_sasa(self):
"""Make a dictionary with SASA assigned to each ligand atom, stored as list of SASA values over
the simulation time."""
atom_names= [atom.name for atom in self.topology_data.universe.ligand_noH.atoms]
sasa_dict = {}
for atom in range(0,self.topology_data.universe.ligand_noH.n_a... | python | def assign_per_atom_sasa(self):
"""Make a dictionary with SASA assigned to each ligand atom, stored as list of SASA values over
the simulation time."""
atom_names= [atom.name for atom in self.topology_data.universe.ligand_noH.atoms]
sasa_dict = {}
for atom in range(0,self.topology_data.universe.ligand_noH.n_a... | [
"def",
"assign_per_atom_sasa",
"(",
"self",
")",
":",
"atom_names",
"=",
"[",
"atom",
".",
"name",
"for",
"atom",
"in",
"self",
".",
"topology_data",
".",
"universe",
".",
"ligand_noH",
".",
"atoms",
"]",
"sasa_dict",
"=",
"{",
"}",
"for",
"atom",
"in",
... | Make a dictionary with SASA assigned to each ligand atom, stored as list of SASA values over
the simulation time. | [
"Make",
"a",
"dictionary",
"with",
"SASA",
"assigned",
"to",
"each",
"ligand",
"atom",
"stored",
"as",
"list",
"of",
"SASA",
"values",
"over",
"the",
"simulation",
"time",
"."
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/analysis/sasa.py#L46-L53 | train | Make a dictionary with SASA assigned to each ligand atom stored as list of SASA values over
the simulation time. |
ldomic/lintools | lintools/analysis/sasa.py | SASA.get_total_per_atom_sasa | def get_total_per_atom_sasa(self):
"""Return average SASA of the atoms."""
total_sasa = defaultdict(int)
for traj in range(len(self.atom_sasa)):
for atom in self.atom_sasa[traj]:
total_sasa[atom]+=float(sum((self.atom_sasa[traj][atom])))/len(self.atom_sasa[traj][atom])
for atom in total_sasa:
total_sa... | python | def get_total_per_atom_sasa(self):
"""Return average SASA of the atoms."""
total_sasa = defaultdict(int)
for traj in range(len(self.atom_sasa)):
for atom in self.atom_sasa[traj]:
total_sasa[atom]+=float(sum((self.atom_sasa[traj][atom])))/len(self.atom_sasa[traj][atom])
for atom in total_sasa:
total_sa... | [
"def",
"get_total_per_atom_sasa",
"(",
"self",
")",
":",
"total_sasa",
"=",
"defaultdict",
"(",
"int",
")",
"for",
"traj",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"atom_sasa",
")",
")",
":",
"for",
"atom",
"in",
"self",
".",
"atom_sasa",
"[",
"tra... | Return average SASA of the atoms. | [
"Return",
"average",
"SASA",
"of",
"the",
"atoms",
"."
] | d825a4a7b35f3f857d3b81b46c9aee72b0ec697a | https://github.com/ldomic/lintools/blob/d825a4a7b35f3f857d3b81b46c9aee72b0ec697a/lintools/analysis/sasa.py#L55-L63 | train | Return average SASA of the atoms. |
thautwarm/Redy | Redy/Async/Accompany.py | Accompany.run | def run(self, *args):
"""
You can choose whether to use lock method when running threads.
"""
if self.running:
return self
self._mut_finished(False) # in case of recovery from a disaster.
self._mut_running(True)
stream = self.target(*args)
... | python | def run(self, *args):
"""
You can choose whether to use lock method when running threads.
"""
if self.running:
return self
self._mut_finished(False) # in case of recovery from a disaster.
self._mut_running(True)
stream = self.target(*args)
... | [
"def",
"run",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"self",
".",
"running",
":",
"return",
"self",
"self",
".",
"_mut_finished",
"(",
"False",
")",
"# in case of recovery from a disaster.",
"self",
".",
"_mut_running",
"(",
"True",
")",
"stream",
... | You can choose whether to use lock method when running threads. | [
"You",
"can",
"choose",
"whether",
"to",
"use",
"lock",
"method",
"when",
"running",
"threads",
"."
] | 8beee5c5f752edfd2754bb1e6b5f4acb016a7770 | https://github.com/thautwarm/Redy/blob/8beee5c5f752edfd2754bb1e6b5f4acb016a7770/Redy/Async/Accompany.py#L114-L144 | train | Runs the thread. |
eleme/meepo | meepo/sub/nano.py | nano_sub | def nano_sub(bind, tables):
"""Nanomsg fanout sub. (Experimental)
This sub will use nanomsg to fanout the events.
:param bind: the zmq pub socket or zmq device socket.
:param tables: the events of tables to follow.
"""
logger = logging.getLogger("meepo.sub.nano_sub")
from nanomsg import S... | python | def nano_sub(bind, tables):
"""Nanomsg fanout sub. (Experimental)
This sub will use nanomsg to fanout the events.
:param bind: the zmq pub socket or zmq device socket.
:param tables: the events of tables to follow.
"""
logger = logging.getLogger("meepo.sub.nano_sub")
from nanomsg import S... | [
"def",
"nano_sub",
"(",
"bind",
",",
"tables",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"\"meepo.sub.nano_sub\"",
")",
"from",
"nanomsg",
"import",
"Socket",
",",
"PUB",
"pub_socket",
"=",
"Socket",
"(",
"PUB",
")",
"pub_socket",
".",
"bi... | Nanomsg fanout sub. (Experimental)
This sub will use nanomsg to fanout the events.
:param bind: the zmq pub socket or zmq device socket.
:param tables: the events of tables to follow. | [
"Nanomsg",
"fanout",
"sub",
".",
"(",
"Experimental",
")"
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/sub/nano.py#L10-L35 | train | Nanomsg fanout sub. |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant_extras/consequences.py | ConsequenceExtras._add_consequences | def _add_consequences(self, variant_obj):
"""Add the consequences found in all transcripts
Args:
variant_obj (puzzle.models.Variant)
"""
consequences = set()
for transcript in variant_obj.transcripts:
for consequence in transcript.consequence.split('&'):... | python | def _add_consequences(self, variant_obj):
"""Add the consequences found in all transcripts
Args:
variant_obj (puzzle.models.Variant)
"""
consequences = set()
for transcript in variant_obj.transcripts:
for consequence in transcript.consequence.split('&'):... | [
"def",
"_add_consequences",
"(",
"self",
",",
"variant_obj",
")",
":",
"consequences",
"=",
"set",
"(",
")",
"for",
"transcript",
"in",
"variant_obj",
".",
"transcripts",
":",
"for",
"consequence",
"in",
"transcript",
".",
"consequence",
".",
"split",
"(",
"... | Add the consequences found in all transcripts
Args:
variant_obj (puzzle.models.Variant) | [
"Add",
"the",
"consequences",
"found",
"in",
"all",
"transcripts"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant_extras/consequences.py#L8-L20 | train | Add the consequences found in all transcripts in the variant_obj. |
robinandeer/puzzle | puzzle/plugins/gemini/mixins/variant_extras/consequences.py | ConsequenceExtras._add_impact_severity | def _add_impact_severity(self, variant_obj, gemini_variant):
"""Add the impact severity for the most severe consequence
Args:
variant_obj (puzzle.models.Variant)
gemini_variant (GeminiQueryRow)
"""
gemini_impact = gemini_variant['impact_severi... | python | def _add_impact_severity(self, variant_obj, gemini_variant):
"""Add the impact severity for the most severe consequence
Args:
variant_obj (puzzle.models.Variant)
gemini_variant (GeminiQueryRow)
"""
gemini_impact = gemini_variant['impact_severi... | [
"def",
"_add_impact_severity",
"(",
"self",
",",
"variant_obj",
",",
"gemini_variant",
")",
":",
"gemini_impact",
"=",
"gemini_variant",
"[",
"'impact_severity'",
"]",
"if",
"gemini_impact",
"==",
"'MED'",
":",
"gemini_impact",
"=",
"'MEDIUM'",
"variant_obj",
".",
... | Add the impact severity for the most severe consequence
Args:
variant_obj (puzzle.models.Variant)
gemini_variant (GeminiQueryRow) | [
"Add",
"the",
"impact",
"severity",
"for",
"the",
"most",
"severe",
"consequence",
"Args",
":",
"variant_obj",
"(",
"puzzle",
".",
"models",
".",
"Variant",
")",
"gemini_variant",
"(",
"GeminiQueryRow",
")"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/gemini/mixins/variant_extras/consequences.py#L31-L41 | train | Add the impact severity for the most severe consequence
|
robinandeer/puzzle | puzzle/plugins/vcf/mixins/variant_extras/genes.py | GeneExtras._add_hgnc_symbols | def _add_hgnc_symbols(self, variant_obj):
"""Add hgnc symbols to the variant
If there are transcripts use the symbols found here,
otherwise use phizz to get the gene ids.
"""
hgnc_symbols = set()
if variant_obj.transcripts:
for transcript in v... | python | def _add_hgnc_symbols(self, variant_obj):
"""Add hgnc symbols to the variant
If there are transcripts use the symbols found here,
otherwise use phizz to get the gene ids.
"""
hgnc_symbols = set()
if variant_obj.transcripts:
for transcript in v... | [
"def",
"_add_hgnc_symbols",
"(",
"self",
",",
"variant_obj",
")",
":",
"hgnc_symbols",
"=",
"set",
"(",
")",
"if",
"variant_obj",
".",
"transcripts",
":",
"for",
"transcript",
"in",
"variant_obj",
".",
"transcripts",
":",
"if",
"transcript",
".",
"hgnc_symbol"... | Add hgnc symbols to the variant
If there are transcripts use the symbols found here,
otherwise use phizz to get the gene ids. | [
"Add",
"hgnc",
"symbols",
"to",
"the",
"variant",
"If",
"there",
"are",
"transcripts",
"use",
"the",
"symbols",
"found",
"here",
"otherwise",
"use",
"phizz",
"to",
"get",
"the",
"gene",
"ids",
"."
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_extras/genes.py#L7-L25 | train | Add hgnc symbols to the variant object. |
robinandeer/puzzle | puzzle/plugins/vcf/mixins/variant_extras/genes.py | GeneExtras._add_genes | def _add_genes(self, variant_obj):
"""Add the Gene objects for a variant"""
genes = []
ensembl_ids = []
hgnc_symbols = []
if variant_obj.transcripts:
for transcript in variant_obj.transcripts:
if transcript.ensembl_id:
ense... | python | def _add_genes(self, variant_obj):
"""Add the Gene objects for a variant"""
genes = []
ensembl_ids = []
hgnc_symbols = []
if variant_obj.transcripts:
for transcript in variant_obj.transcripts:
if transcript.ensembl_id:
ense... | [
"def",
"_add_genes",
"(",
"self",
",",
"variant_obj",
")",
":",
"genes",
"=",
"[",
"]",
"ensembl_ids",
"=",
"[",
"]",
"hgnc_symbols",
"=",
"[",
"]",
"if",
"variant_obj",
".",
"transcripts",
":",
"for",
"transcript",
"in",
"variant_obj",
".",
"transcripts",... | Add the Gene objects for a variant | [
"Add",
"the",
"Gene",
"objects",
"for",
"a",
"variant"
] | 9476f05b416d3a5135d25492cb31411fdf831c58 | https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/plugins/vcf/mixins/variant_extras/genes.py#L27-L49 | train | Add the Gene objects for a variant |
eleme/meepo | meepo/apps/eventsourcing/prepare_commit.py | _redis_strict_pc | def _redis_strict_pc(func):
"""Strict deco for RedisPrepareCommit
The deco will choose whether to silent exception or not based on the
strict attr in RedisPrepareCommit object.
"""
phase = "session_%s" % func.__name__
@functools.wraps(func)
def wrapper(self, session, *args, **kwargs):
... | python | def _redis_strict_pc(func):
"""Strict deco for RedisPrepareCommit
The deco will choose whether to silent exception or not based on the
strict attr in RedisPrepareCommit object.
"""
phase = "session_%s" % func.__name__
@functools.wraps(func)
def wrapper(self, session, *args, **kwargs):
... | [
"def",
"_redis_strict_pc",
"(",
"func",
")",
":",
"phase",
"=",
"\"session_%s\"",
"%",
"func",
".",
"__name__",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"session",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
... | Strict deco for RedisPrepareCommit
The deco will choose whether to silent exception or not based on the
strict attr in RedisPrepareCommit object. | [
"Strict",
"deco",
"for",
"RedisPrepareCommit"
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/prepare_commit.py#L45-L68 | train | Strict PC deco for RedisPrepareCommit
|
eleme/meepo | meepo/apps/eventsourcing/prepare_commit.py | RedisPrepareCommit.phase | def phase(self, session):
"""Determine the session phase in prepare commit.
:param session: sqlalchemy session
:return: phase "prepare" or "commit"
"""
sp_key, _ = self._keygen(session)
if self.r.sismember(sp_key, session.meepo_unique_id):
return "prepare"
... | python | def phase(self, session):
"""Determine the session phase in prepare commit.
:param session: sqlalchemy session
:return: phase "prepare" or "commit"
"""
sp_key, _ = self._keygen(session)
if self.r.sismember(sp_key, session.meepo_unique_id):
return "prepare"
... | [
"def",
"phase",
"(",
"self",
",",
"session",
")",
":",
"sp_key",
",",
"_",
"=",
"self",
".",
"_keygen",
"(",
"session",
")",
"if",
"self",
".",
"r",
".",
"sismember",
"(",
"sp_key",
",",
"session",
".",
"meepo_unique_id",
")",
":",
"return",
"\"prepa... | Determine the session phase in prepare commit.
:param session: sqlalchemy session
:return: phase "prepare" or "commit" | [
"Determine",
"the",
"session",
"phase",
"in",
"prepare",
"commit",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/prepare_commit.py#L113-L123 | train | Determine the session phase in prepare or commit. |
eleme/meepo | meepo/apps/eventsourcing/prepare_commit.py | RedisPrepareCommit.prepare | def prepare(self, session, event):
"""Prepare phase for session.
:param session: sqlalchemy session
"""
if not event:
self.logger.warn("event empty!")
return
sp_key, sp_hkey = self._keygen(session)
def _pk(obj):
pk_values = tuple(get... | python | def prepare(self, session, event):
"""Prepare phase for session.
:param session: sqlalchemy session
"""
if not event:
self.logger.warn("event empty!")
return
sp_key, sp_hkey = self._keygen(session)
def _pk(obj):
pk_values = tuple(get... | [
"def",
"prepare",
"(",
"self",
",",
"session",
",",
"event",
")",
":",
"if",
"not",
"event",
":",
"self",
".",
"logger",
".",
"warn",
"(",
"\"event empty!\"",
")",
"return",
"sp_key",
",",
"sp_hkey",
"=",
"self",
".",
"_keygen",
"(",
"session",
")",
... | Prepare phase for session.
:param session: sqlalchemy session | [
"Prepare",
"phase",
"for",
"session",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/prepare_commit.py#L126-L154 | train | Prepare phase for session.
|
eleme/meepo | meepo/apps/eventsourcing/prepare_commit.py | RedisPrepareCommit.commit | def commit(self, session):
"""Commit phase for session.
:param session: sqlalchemy session
"""
sp_key, sp_hkey = self._keygen(session)
with self.r.pipeline(transaction=False) as p:
p.srem(sp_key, session.meepo_unique_id)
p.expire(sp_hkey, 60 * 60)
... | python | def commit(self, session):
"""Commit phase for session.
:param session: sqlalchemy session
"""
sp_key, sp_hkey = self._keygen(session)
with self.r.pipeline(transaction=False) as p:
p.srem(sp_key, session.meepo_unique_id)
p.expire(sp_hkey, 60 * 60)
... | [
"def",
"commit",
"(",
"self",
",",
"session",
")",
":",
"sp_key",
",",
"sp_hkey",
"=",
"self",
".",
"_keygen",
"(",
"session",
")",
"with",
"self",
".",
"r",
".",
"pipeline",
"(",
"transaction",
"=",
"False",
")",
"as",
"p",
":",
"p",
".",
"srem",
... | Commit phase for session.
:param session: sqlalchemy session | [
"Commit",
"phase",
"for",
"session",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/prepare_commit.py#L157-L166 | train | Commit phase for session.
|
eleme/meepo | meepo/apps/eventsourcing/prepare_commit.py | RedisPrepareCommit.session_info | def session_info(self, session):
"""Return all session unique ids recorded in prepare phase.
:param ts: timestamp, default to current timestamp
:return: set of session unique ids
"""
_, sp_hkey = self._keygen(session)
picked_event = self.r.hgetall(sp_hkey)
event ... | python | def session_info(self, session):
"""Return all session unique ids recorded in prepare phase.
:param ts: timestamp, default to current timestamp
:return: set of session unique ids
"""
_, sp_hkey = self._keygen(session)
picked_event = self.r.hgetall(sp_hkey)
event ... | [
"def",
"session_info",
"(",
"self",
",",
"session",
")",
":",
"_",
",",
"sp_hkey",
"=",
"self",
".",
"_keygen",
"(",
"session",
")",
"picked_event",
"=",
"self",
".",
"r",
".",
"hgetall",
"(",
"sp_hkey",
")",
"event",
"=",
"{",
"s",
"(",
"k",
")",
... | Return all session unique ids recorded in prepare phase.
:param ts: timestamp, default to current timestamp
:return: set of session unique ids | [
"Return",
"all",
"session",
"unique",
"ids",
"recorded",
"in",
"prepare",
"phase",
"."
] | 8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a | https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/prepare_commit.py#L170-L179 | train | Return all session unique ids recorded in prepare phase. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.