repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
LeKono/pyhgnc | src/pyhgnc/manager/query.py | QueryManager.get_model_queries | def get_model_queries(self, query_obj, model_queries_config):
"""use this if your are searching for a field in the same model"""
for search4, model_attrib in model_queries_config:
if search4 is not None:
query_obj = self._model_query(query_obj, search4, model_attrib)
... | python | def get_model_queries(self, query_obj, model_queries_config):
"""use this if your are searching for a field in the same model"""
for search4, model_attrib in model_queries_config:
if search4 is not None:
query_obj = self._model_query(query_obj, search4, model_attrib)
... | [
"def",
"get_model_queries",
"(",
"self",
",",
"query_obj",
",",
"model_queries_config",
")",
":",
"for",
"search4",
",",
"model_attrib",
"in",
"model_queries_config",
":",
"if",
"search4",
"is",
"not",
"None",
":",
"query_obj",
"=",
"self",
".",
"_model_query",
... | use this if your are searching for a field in the same model | [
"use",
"this",
"if",
"your",
"are",
"searching",
"for",
"a",
"field",
"in",
"the",
"same",
"model"
] | 1cae20c40874bfb51581b7c5c1481707e942b5d0 | https://github.com/LeKono/pyhgnc/blob/1cae20c40874bfb51581b7c5c1481707e942b5d0/src/pyhgnc/manager/query.py#L44-L50 | train |
happyleavesaoc/python-upsmychoice | upsmychoice/__init__.py | _login | def _login(session):
"""Login to UPS."""
resp = session.get(LOGIN_URL, params=_get_params(session.auth.locale))
parsed = BeautifulSoup(resp.text, HTML_PARSER)
csrf = parsed.find(CSRF_FIND_TAG, CSRF_FIND_ATTR).get(VALUE_ATTR)
resp = session.post(LOGIN_URL, {
'userID': session.auth.username,
... | python | def _login(session):
"""Login to UPS."""
resp = session.get(LOGIN_URL, params=_get_params(session.auth.locale))
parsed = BeautifulSoup(resp.text, HTML_PARSER)
csrf = parsed.find(CSRF_FIND_TAG, CSRF_FIND_ATTR).get(VALUE_ATTR)
resp = session.post(LOGIN_URL, {
'userID': session.auth.username,
... | [
"def",
"_login",
"(",
"session",
")",
":",
"resp",
"=",
"session",
".",
"get",
"(",
"LOGIN_URL",
",",
"params",
"=",
"_get_params",
"(",
"session",
".",
"auth",
".",
"locale",
")",
")",
"parsed",
"=",
"BeautifulSoup",
"(",
"resp",
".",
"text",
",",
"... | Login to UPS. | [
"Login",
"to",
"UPS",
"."
] | df4d7e9d92f95884c8d86f9d38b5a2291cf9edbe | https://github.com/happyleavesaoc/python-upsmychoice/blob/df4d7e9d92f95884c8d86f9d38b5a2291cf9edbe/upsmychoice/__init__.py#L64-L82 | train |
happyleavesaoc/python-upsmychoice | upsmychoice/__init__.py | get_packages | def get_packages(session):
"""Get deliveries in progress and completed."""
resp = session.get(DELIVERIES_URL, params=_get_params(session.auth.locale))
parsed = BeautifulSoup(resp.text, HTML_PARSER)
token_elem = parsed.find(TOKEN_FIND_TAG, TOKEN_FIND_ATTR)
tid_elem = parsed.find(TID_FIND_TAG, TID_FIN... | python | def get_packages(session):
"""Get deliveries in progress and completed."""
resp = session.get(DELIVERIES_URL, params=_get_params(session.auth.locale))
parsed = BeautifulSoup(resp.text, HTML_PARSER)
token_elem = parsed.find(TOKEN_FIND_TAG, TOKEN_FIND_ATTR)
tid_elem = parsed.find(TID_FIND_TAG, TID_FIN... | [
"def",
"get_packages",
"(",
"session",
")",
":",
"resp",
"=",
"session",
".",
"get",
"(",
"DELIVERIES_URL",
",",
"params",
"=",
"_get_params",
"(",
"session",
".",
"auth",
".",
"locale",
")",
")",
"parsed",
"=",
"BeautifulSoup",
"(",
"resp",
".",
"text",... | Get deliveries in progress and completed. | [
"Get",
"deliveries",
"in",
"progress",
"and",
"completed",
"."
] | df4d7e9d92f95884c8d86f9d38b5a2291cf9edbe | https://github.com/happyleavesaoc/python-upsmychoice/blob/df4d7e9d92f95884c8d86f9d38b5a2291cf9edbe/upsmychoice/__init__.py#L98-L137 | train |
happyleavesaoc/python-upsmychoice | upsmychoice/__init__.py | get_session | def get_session(username, password, locale=DEFAULT_LOCALE,
cookie_path=COOKIE_PATH):
"""Get UPS HTTP session."""
class UPSAuth(AuthBase): # pylint: disable=too-few-public-methods
"""UPS authorization storage."""
def __init__(self, username, password, locale, cookie_path):
... | python | def get_session(username, password, locale=DEFAULT_LOCALE,
cookie_path=COOKIE_PATH):
"""Get UPS HTTP session."""
class UPSAuth(AuthBase): # pylint: disable=too-few-public-methods
"""UPS authorization storage."""
def __init__(self, username, password, locale, cookie_path):
... | [
"def",
"get_session",
"(",
"username",
",",
"password",
",",
"locale",
"=",
"DEFAULT_LOCALE",
",",
"cookie_path",
"=",
"COOKIE_PATH",
")",
":",
"class",
"UPSAuth",
"(",
"AuthBase",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"username",
",",
"password",
... | Get UPS HTTP session. | [
"Get",
"UPS",
"HTTP",
"session",
"."
] | df4d7e9d92f95884c8d86f9d38b5a2291cf9edbe | https://github.com/happyleavesaoc/python-upsmychoice/blob/df4d7e9d92f95884c8d86f9d38b5a2291cf9edbe/upsmychoice/__init__.py#L140-L163 | train |
portfors-lab/sparkle | sparkle/gui/hidden_widget.py | WidgetHider.hide | def hide(self, event):
"""Toggles the visiblity of the content widget"""
if self.content.isHidden():
self.content.show()
self.hideBtn.setIcon(self.hideIcon)
self.setMaximumHeight(16777215)
else:
self.content.hide()
self.hideBtn.setIcon(... | python | def hide(self, event):
"""Toggles the visiblity of the content widget"""
if self.content.isHidden():
self.content.show()
self.hideBtn.setIcon(self.hideIcon)
self.setMaximumHeight(16777215)
else:
self.content.hide()
self.hideBtn.setIcon(... | [
"def",
"hide",
"(",
"self",
",",
"event",
")",
":",
"if",
"self",
".",
"content",
".",
"isHidden",
"(",
")",
":",
"self",
".",
"content",
".",
"show",
"(",
")",
"self",
".",
"hideBtn",
".",
"setIcon",
"(",
"self",
".",
"hideIcon",
")",
"self",
".... | Toggles the visiblity of the content widget | [
"Toggles",
"the",
"visiblity",
"of",
"the",
"content",
"widget"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/hidden_widget.py#L41-L50 | train |
maxharp3r/archive-rotator | archive_rotator/rotator.py | _next_rotation_id | def _next_rotation_id(rotated_files):
"""Given the hanoi_rotator generated files in the output directory,
returns the rotation_id that will be given to the current file. If there
are no existing rotated files, return 0.
"""
if not rotated_files:
return 0
else:
highest_rotated_fil... | python | def _next_rotation_id(rotated_files):
"""Given the hanoi_rotator generated files in the output directory,
returns the rotation_id that will be given to the current file. If there
are no existing rotated files, return 0.
"""
if not rotated_files:
return 0
else:
highest_rotated_fil... | [
"def",
"_next_rotation_id",
"(",
"rotated_files",
")",
":",
"if",
"not",
"rotated_files",
":",
"return",
"0",
"else",
":",
"highest_rotated_file",
"=",
"max",
"(",
"rotated_files",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
"1",
"]",
")",
"return",
"... | Given the hanoi_rotator generated files in the output directory,
returns the rotation_id that will be given to the current file. If there
are no existing rotated files, return 0. | [
"Given",
"the",
"hanoi_rotator",
"generated",
"files",
"in",
"the",
"output",
"directory",
"returns",
"the",
"rotation_id",
"that",
"will",
"be",
"given",
"to",
"the",
"current",
"file",
".",
"If",
"there",
"are",
"no",
"existing",
"rotated",
"files",
"return"... | 40b8e571461c54717cee7daead04dbc9751062c8 | https://github.com/maxharp3r/archive-rotator/blob/40b8e571461c54717cee7daead04dbc9751062c8/archive_rotator/rotator.py#L73-L82 | train |
maxharp3r/archive-rotator | archive_rotator/rotator.py | _locate_files_to_delete | def _locate_files_to_delete(algorithm, rotated_files, next_rotation_id):
"""Looks for hanoi_rotator generated files that occupy the same slot
that will be given to rotation_id.
"""
rotation_slot = algorithm.id_to_slot(next_rotation_id)
for a_path, a_rotation_id in rotated_files:
if rotation_... | python | def _locate_files_to_delete(algorithm, rotated_files, next_rotation_id):
"""Looks for hanoi_rotator generated files that occupy the same slot
that will be given to rotation_id.
"""
rotation_slot = algorithm.id_to_slot(next_rotation_id)
for a_path, a_rotation_id in rotated_files:
if rotation_... | [
"def",
"_locate_files_to_delete",
"(",
"algorithm",
",",
"rotated_files",
",",
"next_rotation_id",
")",
":",
"rotation_slot",
"=",
"algorithm",
".",
"id_to_slot",
"(",
"next_rotation_id",
")",
"for",
"a_path",
",",
"a_rotation_id",
"in",
"rotated_files",
":",
"if",
... | Looks for hanoi_rotator generated files that occupy the same slot
that will be given to rotation_id. | [
"Looks",
"for",
"hanoi_rotator",
"generated",
"files",
"that",
"occupy",
"the",
"same",
"slot",
"that",
"will",
"be",
"given",
"to",
"rotation_id",
"."
] | 40b8e571461c54717cee7daead04dbc9751062c8 | https://github.com/maxharp3r/archive-rotator/blob/40b8e571461c54717cee7daead04dbc9751062c8/archive_rotator/rotator.py#L85-L92 | train |
maxharp3r/archive-rotator | archive_rotator/rotator.py | rotate | def rotate(algorithm, path, ext="", destination_dir=None, verbose=False):
"""
Programmatic access to the archive rotator
:param algorithm: an instance of BaseRotator from algorithms.py
:param path: full path to input file
:param ext: (optional) file extension to preserve
:param destination_dir:... | python | def rotate(algorithm, path, ext="", destination_dir=None, verbose=False):
"""
Programmatic access to the archive rotator
:param algorithm: an instance of BaseRotator from algorithms.py
:param path: full path to input file
:param ext: (optional) file extension to preserve
:param destination_dir:... | [
"def",
"rotate",
"(",
"algorithm",
",",
"path",
",",
"ext",
"=",
"\"\"",
",",
"destination_dir",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"paths",
"=",
"Paths",
"(",
"path",
",",
"ext",
",",
"destination_dir",
")",
"_move_files",
"(",
"algo... | Programmatic access to the archive rotator
:param algorithm: an instance of BaseRotator from algorithms.py
:param path: full path to input file
:param ext: (optional) file extension to preserve
:param destination_dir: (optional) different location for output file
:param verbose: (optional) print mo... | [
"Programmatic",
"access",
"to",
"the",
"archive",
"rotator"
] | 40b8e571461c54717cee7daead04dbc9751062c8 | https://github.com/maxharp3r/archive-rotator/blob/40b8e571461c54717cee7daead04dbc9751062c8/archive_rotator/rotator.py#L126-L138 | train |
The-Politico/politico-civic-election | election/models/election.py | Election.update_or_create_candidate | def update_or_create_candidate(
self, candidate, aggregable=True, uncontested=False
):
"""Create a CandidateElection."""
candidate_election, c = CandidateElection.objects.update_or_create(
candidate=candidate,
election=self,
defaults={"aggregable": aggrega... | python | def update_or_create_candidate(
self, candidate, aggregable=True, uncontested=False
):
"""Create a CandidateElection."""
candidate_election, c = CandidateElection.objects.update_or_create(
candidate=candidate,
election=self,
defaults={"aggregable": aggrega... | [
"def",
"update_or_create_candidate",
"(",
"self",
",",
"candidate",
",",
"aggregable",
"=",
"True",
",",
"uncontested",
"=",
"False",
")",
":",
"candidate_election",
",",
"c",
"=",
"CandidateElection",
".",
"objects",
".",
"update_or_create",
"(",
"candidate",
"... | Create a CandidateElection. | [
"Create",
"a",
"CandidateElection",
"."
] | 44c6872c419909df616e997e1990c4d295b25eda | https://github.com/The-Politico/politico-civic-election/blob/44c6872c419909df616e997e1990c4d295b25eda/election/models/election.py#L54-L64 | train |
The-Politico/politico-civic-election | election/models/election.py | Election.delete_candidate | def delete_candidate(self, candidate):
"""Delete a CandidateElection."""
CandidateElection.objects.filter(
candidate=candidate, election=self
).delete() | python | def delete_candidate(self, candidate):
"""Delete a CandidateElection."""
CandidateElection.objects.filter(
candidate=candidate, election=self
).delete() | [
"def",
"delete_candidate",
"(",
"self",
",",
"candidate",
")",
":",
"CandidateElection",
".",
"objects",
".",
"filter",
"(",
"candidate",
"=",
"candidate",
",",
"election",
"=",
"self",
")",
".",
"delete",
"(",
")"
] | Delete a CandidateElection. | [
"Delete",
"a",
"CandidateElection",
"."
] | 44c6872c419909df616e997e1990c4d295b25eda | https://github.com/The-Politico/politico-civic-election/blob/44c6872c419909df616e997e1990c4d295b25eda/election/models/election.py#L66-L70 | train |
The-Politico/politico-civic-election | election/models/election.py | Election.get_candidates | def get_candidates(self):
"""Get all CandidateElections for this election."""
candidate_elections = CandidateElection.objects.filter(election=self)
return [ce.candidate for ce in candidate_elections] | python | def get_candidates(self):
"""Get all CandidateElections for this election."""
candidate_elections = CandidateElection.objects.filter(election=self)
return [ce.candidate for ce in candidate_elections] | [
"def",
"get_candidates",
"(",
"self",
")",
":",
"candidate_elections",
"=",
"CandidateElection",
".",
"objects",
".",
"filter",
"(",
"election",
"=",
"self",
")",
"return",
"[",
"ce",
".",
"candidate",
"for",
"ce",
"in",
"candidate_elections",
"]"
] | Get all CandidateElections for this election. | [
"Get",
"all",
"CandidateElections",
"for",
"this",
"election",
"."
] | 44c6872c419909df616e997e1990c4d295b25eda | https://github.com/The-Politico/politico-civic-election/blob/44c6872c419909df616e997e1990c4d295b25eda/election/models/election.py#L72-L76 | train |
The-Politico/politico-civic-election | election/models/election.py | Election.get_candidates_by_party | def get_candidates_by_party(self):
"""
Get CandidateElections serialized into an object with
party-slug keys.
"""
candidate_elections = CandidateElection.objects.filter(election=self)
return {
ce.candidate.party.slug: ce.candidate for ce in candidate_election... | python | def get_candidates_by_party(self):
"""
Get CandidateElections serialized into an object with
party-slug keys.
"""
candidate_elections = CandidateElection.objects.filter(election=self)
return {
ce.candidate.party.slug: ce.candidate for ce in candidate_election... | [
"def",
"get_candidates_by_party",
"(",
"self",
")",
":",
"candidate_elections",
"=",
"CandidateElection",
".",
"objects",
".",
"filter",
"(",
"election",
"=",
"self",
")",
"return",
"{",
"ce",
".",
"candidate",
".",
"party",
".",
"slug",
":",
"ce",
".",
"c... | Get CandidateElections serialized into an object with
party-slug keys. | [
"Get",
"CandidateElections",
"serialized",
"into",
"an",
"object",
"with",
"party",
"-",
"slug",
"keys",
"."
] | 44c6872c419909df616e997e1990c4d295b25eda | https://github.com/The-Politico/politico-civic-election/blob/44c6872c419909df616e997e1990c4d295b25eda/election/models/election.py#L78-L87 | train |
The-Politico/politico-civic-election | election/models/election.py | Election.get_candidate_election | def get_candidate_election(self, candidate):
"""Get CandidateElection for a Candidate in this election."""
return CandidateElection.objects.get(
candidate=candidate, election=self
) | python | def get_candidate_election(self, candidate):
"""Get CandidateElection for a Candidate in this election."""
return CandidateElection.objects.get(
candidate=candidate, election=self
) | [
"def",
"get_candidate_election",
"(",
"self",
",",
"candidate",
")",
":",
"return",
"CandidateElection",
".",
"objects",
".",
"get",
"(",
"candidate",
"=",
"candidate",
",",
"election",
"=",
"self",
")"
] | Get CandidateElection for a Candidate in this election. | [
"Get",
"CandidateElection",
"for",
"a",
"Candidate",
"in",
"this",
"election",
"."
] | 44c6872c419909df616e997e1990c4d295b25eda | https://github.com/The-Politico/politico-civic-election/blob/44c6872c419909df616e997e1990c4d295b25eda/election/models/election.py#L89-L93 | train |
The-Politico/politico-civic-election | election/models/election.py | Election.get_candidate_votes | def get_candidate_votes(self, candidate):
"""
Get all votes attached to a CandidateElection for a Candidate in
this election.
"""
candidate_election = CandidateElection.objects.get(
candidate=candidate, election=self
)
return candidate_election.votes.... | python | def get_candidate_votes(self, candidate):
"""
Get all votes attached to a CandidateElection for a Candidate in
this election.
"""
candidate_election = CandidateElection.objects.get(
candidate=candidate, election=self
)
return candidate_election.votes.... | [
"def",
"get_candidate_votes",
"(",
"self",
",",
"candidate",
")",
":",
"candidate_election",
"=",
"CandidateElection",
".",
"objects",
".",
"get",
"(",
"candidate",
"=",
"candidate",
",",
"election",
"=",
"self",
")",
"return",
"candidate_election",
".",
"votes"... | Get all votes attached to a CandidateElection for a Candidate in
this election. | [
"Get",
"all",
"votes",
"attached",
"to",
"a",
"CandidateElection",
"for",
"a",
"Candidate",
"in",
"this",
"election",
"."
] | 44c6872c419909df616e997e1990c4d295b25eda | https://github.com/The-Politico/politico-civic-election/blob/44c6872c419909df616e997e1990c4d295b25eda/election/models/election.py#L95-L104 | train |
The-Politico/politico-civic-election | election/models/election.py | Election.get_votes | def get_votes(self):
"""
Get all votes for this election.
"""
candidate_elections = CandidateElection.objects.filter(election=self)
votes = None
for ce in candidate_elections:
votes = votes | ce.votes.all()
return votes | python | def get_votes(self):
"""
Get all votes for this election.
"""
candidate_elections = CandidateElection.objects.filter(election=self)
votes = None
for ce in candidate_elections:
votes = votes | ce.votes.all()
return votes | [
"def",
"get_votes",
"(",
"self",
")",
":",
"candidate_elections",
"=",
"CandidateElection",
".",
"objects",
".",
"filter",
"(",
"election",
"=",
"self",
")",
"votes",
"=",
"None",
"for",
"ce",
"in",
"candidate_elections",
":",
"votes",
"=",
"votes",
"|",
"... | Get all votes for this election. | [
"Get",
"all",
"votes",
"for",
"this",
"election",
"."
] | 44c6872c419909df616e997e1990c4d295b25eda | https://github.com/The-Politico/politico-civic-election/blob/44c6872c419909df616e997e1990c4d295b25eda/election/models/election.py#L106-L116 | train |
The-Politico/politico-civic-election | election/models/election.py | Election.get_candidate_electoral_votes | def get_candidate_electoral_votes(self, candidate):
"""
Get all electoral votes for a candidate in this election.
"""
candidate_election = CandidateElection.objects.get(
candidate=candidate, election=self
)
return candidate_election.electoral_votes.all() | python | def get_candidate_electoral_votes(self, candidate):
"""
Get all electoral votes for a candidate in this election.
"""
candidate_election = CandidateElection.objects.get(
candidate=candidate, election=self
)
return candidate_election.electoral_votes.all() | [
"def",
"get_candidate_electoral_votes",
"(",
"self",
",",
"candidate",
")",
":",
"candidate_election",
"=",
"CandidateElection",
".",
"objects",
".",
"get",
"(",
"candidate",
"=",
"candidate",
",",
"election",
"=",
"self",
")",
"return",
"candidate_election",
".",... | Get all electoral votes for a candidate in this election. | [
"Get",
"all",
"electoral",
"votes",
"for",
"a",
"candidate",
"in",
"this",
"election",
"."
] | 44c6872c419909df616e997e1990c4d295b25eda | https://github.com/The-Politico/politico-civic-election/blob/44c6872c419909df616e997e1990c4d295b25eda/election/models/election.py#L118-L126 | train |
The-Politico/politico-civic-election | election/models/election.py | Election.get_electoral_votes | def get_electoral_votes(self):
"""
Get all electoral votes for all candidates in this election.
"""
candidate_elections = CandidateElection.objects.filter(election=self)
electoral_votes = None
for ce in candidate_elections:
electoral_votes = electoral_votes |... | python | def get_electoral_votes(self):
"""
Get all electoral votes for all candidates in this election.
"""
candidate_elections = CandidateElection.objects.filter(election=self)
electoral_votes = None
for ce in candidate_elections:
electoral_votes = electoral_votes |... | [
"def",
"get_electoral_votes",
"(",
"self",
")",
":",
"candidate_elections",
"=",
"CandidateElection",
".",
"objects",
".",
"filter",
"(",
"election",
"=",
"self",
")",
"electoral_votes",
"=",
"None",
"for",
"ce",
"in",
"candidate_elections",
":",
"electoral_votes"... | Get all electoral votes for all candidates in this election. | [
"Get",
"all",
"electoral",
"votes",
"for",
"all",
"candidates",
"in",
"this",
"election",
"."
] | 44c6872c419909df616e997e1990c4d295b25eda | https://github.com/The-Politico/politico-civic-election/blob/44c6872c419909df616e997e1990c4d295b25eda/election/models/election.py#L128-L138 | train |
The-Politico/politico-civic-election | election/models/election.py | Election.get_candidate_delegates | def get_candidate_delegates(self, candidate):
"""
Get all pledged delegates for a candidate in this election.
"""
candidate_election = CandidateElection.objects.get(
candidate=candidate, election=self
)
return candidate_election.delegates.all() | python | def get_candidate_delegates(self, candidate):
"""
Get all pledged delegates for a candidate in this election.
"""
candidate_election = CandidateElection.objects.get(
candidate=candidate, election=self
)
return candidate_election.delegates.all() | [
"def",
"get_candidate_delegates",
"(",
"self",
",",
"candidate",
")",
":",
"candidate_election",
"=",
"CandidateElection",
".",
"objects",
".",
"get",
"(",
"candidate",
"=",
"candidate",
",",
"election",
"=",
"self",
")",
"return",
"candidate_election",
".",
"de... | Get all pledged delegates for a candidate in this election. | [
"Get",
"all",
"pledged",
"delegates",
"for",
"a",
"candidate",
"in",
"this",
"election",
"."
] | 44c6872c419909df616e997e1990c4d295b25eda | https://github.com/The-Politico/politico-civic-election/blob/44c6872c419909df616e997e1990c4d295b25eda/election/models/election.py#L140-L148 | train |
The-Politico/politico-civic-election | election/models/election.py | Election.get_delegates | def get_delegates(self):
"""
Get all pledged delegates for any candidate in this election.
"""
candidate_elections = CandidateElection.objects.filter(election=self)
delegates = None
for ce in candidate_elections:
delegates = delegates | ce.delegates.all()
... | python | def get_delegates(self):
"""
Get all pledged delegates for any candidate in this election.
"""
candidate_elections = CandidateElection.objects.filter(election=self)
delegates = None
for ce in candidate_elections:
delegates = delegates | ce.delegates.all()
... | [
"def",
"get_delegates",
"(",
"self",
")",
":",
"candidate_elections",
"=",
"CandidateElection",
".",
"objects",
".",
"filter",
"(",
"election",
"=",
"self",
")",
"delegates",
"=",
"None",
"for",
"ce",
"in",
"candidate_elections",
":",
"delegates",
"=",
"delega... | Get all pledged delegates for any candidate in this election. | [
"Get",
"all",
"pledged",
"delegates",
"for",
"any",
"candidate",
"in",
"this",
"election",
"."
] | 44c6872c419909df616e997e1990c4d295b25eda | https://github.com/The-Politico/politico-civic-election/blob/44c6872c419909df616e997e1990c4d295b25eda/election/models/election.py#L150-L160 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.list_packet_names | def list_packet_names(self):
"""
Returns the existing packet names.
:rtype: ~collections.Iterable[str]
"""
# Server does not do pagination on listings of this resource.
# Return an iterator anyway for similarity with other API methods
path = '/archive/{}/packet-n... | python | def list_packet_names(self):
"""
Returns the existing packet names.
:rtype: ~collections.Iterable[str]
"""
# Server does not do pagination on listings of this resource.
# Return an iterator anyway for similarity with other API methods
path = '/archive/{}/packet-n... | [
"def",
"list_packet_names",
"(",
"self",
")",
":",
"path",
"=",
"'/archive/{}/packet-names'",
".",
"format",
"(",
"self",
".",
"_instance",
")",
"response",
"=",
"self",
".",
"_client",
".",
"get_proto",
"(",
"path",
"=",
"path",
")",
"message",
"=",
"arch... | Returns the existing packet names.
:rtype: ~collections.Iterable[str] | [
"Returns",
"the",
"existing",
"packet",
"names",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L37-L50 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.list_processed_parameter_groups | def list_processed_parameter_groups(self):
"""
Returns the existing parameter groups.
:rtype: ~collections.Iterable[str]
"""
# Server does not do pagination on listings of this resource.
# Return an iterator anyway for similarity with other API methods
path = '/a... | python | def list_processed_parameter_groups(self):
"""
Returns the existing parameter groups.
:rtype: ~collections.Iterable[str]
"""
# Server does not do pagination on listings of this resource.
# Return an iterator anyway for similarity with other API methods
path = '/a... | [
"def",
"list_processed_parameter_groups",
"(",
"self",
")",
":",
"path",
"=",
"'/archive/{}/parameter-groups'",
".",
"format",
"(",
"self",
".",
"_instance",
")",
"response",
"=",
"self",
".",
"_client",
".",
"get_proto",
"(",
"path",
"=",
"path",
")",
"messag... | Returns the existing parameter groups.
:rtype: ~collections.Iterable[str] | [
"Returns",
"the",
"existing",
"parameter",
"groups",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L81-L94 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.list_processed_parameter_group_histogram | def list_processed_parameter_group_histogram(self, group=None, start=None, stop=None, merge_time=20):
"""
Reads index records related to processed parameter groups between the
specified start and stop time.
Each iteration returns a chunk of chronologically-sorted records.
:para... | python | def list_processed_parameter_group_histogram(self, group=None, start=None, stop=None, merge_time=20):
"""
Reads index records related to processed parameter groups between the
specified start and stop time.
Each iteration returns a chunk of chronologically-sorted records.
:para... | [
"def",
"list_processed_parameter_group_histogram",
"(",
"self",
",",
"group",
"=",
"None",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"merge_time",
"=",
"20",
")",
":",
"params",
"=",
"{",
"}",
"if",
"group",
"is",
"not",
"None",
":",
"p... | Reads index records related to processed parameter groups between the
specified start and stop time.
Each iteration returns a chunk of chronologically-sorted records.
:param float merge_time: Maximum gap in seconds before two consecutive index records are merged together.
:rtype: ~coll... | [
"Reads",
"index",
"records",
"related",
"to",
"processed",
"parameter",
"groups",
"between",
"the",
"specified",
"start",
"and",
"stop",
"time",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L96-L123 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.list_event_sources | def list_event_sources(self):
"""
Returns the existing event sources.
:rtype: ~collections.Iterable[str]
"""
# Server does not do pagination on listings of this resource.
# Return an iterator anyway for similarity with other API methods
path = '/archive/{}/events... | python | def list_event_sources(self):
"""
Returns the existing event sources.
:rtype: ~collections.Iterable[str]
"""
# Server does not do pagination on listings of this resource.
# Return an iterator anyway for similarity with other API methods
path = '/archive/{}/events... | [
"def",
"list_event_sources",
"(",
"self",
")",
":",
"path",
"=",
"'/archive/{}/events/sources'",
".",
"format",
"(",
"self",
".",
"_instance",
")",
"response",
"=",
"self",
".",
"_client",
".",
"get_proto",
"(",
"path",
"=",
"path",
")",
"message",
"=",
"a... | Returns the existing event sources.
:rtype: ~collections.Iterable[str] | [
"Returns",
"the",
"existing",
"event",
"sources",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L125-L138 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.list_completeness_index | def list_completeness_index(self, start=None, stop=None):
"""
Reads completeness index records between the specified start and stop
time.
Each iteration returns a chunk of chronologically-sorted records.
:rtype: ~collections.Iterable[.IndexGroup]
"""
params = {}... | python | def list_completeness_index(self, start=None, stop=None):
"""
Reads completeness index records between the specified start and stop
time.
Each iteration returns a chunk of chronologically-sorted records.
:rtype: ~collections.Iterable[.IndexGroup]
"""
params = {}... | [
"def",
"list_completeness_index",
"(",
"self",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"params",
"=",
"{",
"}",
"if",
"start",
"is",
"not",
"None",
":",
"params",
"[",
"'start'",
"]",
"=",
"to_isostring",
"(",
"start",
")",
"if... | Reads completeness index records between the specified start and stop
time.
Each iteration returns a chunk of chronologically-sorted records.
:rtype: ~collections.Iterable[.IndexGroup] | [
"Reads",
"completeness",
"index",
"records",
"between",
"the",
"specified",
"start",
"and",
"stop",
"time",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L198-L220 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.list_packets | def list_packets(self, name=None, start=None, stop=None, page_size=500, descending=False):
"""
Reads packet information between the specified start and stop
time.
Packets are sorted by generation time and sequence number.
:param ~datetime.datetime start: Minimum generation time... | python | def list_packets(self, name=None, start=None, stop=None, page_size=500, descending=False):
"""
Reads packet information between the specified start and stop
time.
Packets are sorted by generation time and sequence number.
:param ~datetime.datetime start: Minimum generation time... | [
"def",
"list_packets",
"(",
"self",
",",
"name",
"=",
"None",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"page_size",
"=",
"500",
",",
"descending",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'order'",
":",
"'desc'",
"if",
"descendin... | Reads packet information between the specified start and stop
time.
Packets are sorted by generation time and sequence number.
:param ~datetime.datetime start: Minimum generation time of the returned
packets (inclusive)
:param ~datetime.datetime... | [
"Reads",
"packet",
"information",
"between",
"the",
"specified",
"start",
"and",
"stop",
"time",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L222-L258 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.list_events | def list_events(self, source=None, severity=None, text_filter=None,
start=None, stop=None, page_size=500, descending=False):
"""
Reads events between the specified start and stop time.
Events are sorted by generation time, source, then sequence number.
:param str so... | python | def list_events(self, source=None, severity=None, text_filter=None,
start=None, stop=None, page_size=500, descending=False):
"""
Reads events between the specified start and stop time.
Events are sorted by generation time, source, then sequence number.
:param str so... | [
"def",
"list_events",
"(",
"self",
",",
"source",
"=",
"None",
",",
"severity",
"=",
"None",
",",
"text_filter",
"=",
"None",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"page_size",
"=",
"500",
",",
"descending",
"=",
"False",
")",
":"... | Reads events between the specified start and stop time.
Events are sorted by generation time, source, then sequence number.
:param str source: The source of the returned events.
:param str severity: The minimum severity level of the returned events.
One of ``INFO``... | [
"Reads",
"events",
"between",
"the",
"specified",
"start",
"and",
"stop",
"time",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L275-L318 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.sample_parameter_values | def sample_parameter_values(self, parameter, start=None, stop=None,
sample_count=500, parameter_cache='realtime',
source='ParameterArchive'):
"""
Returns parameter samples.
The query range is split in sample intervals of equal leng... | python | def sample_parameter_values(self, parameter, start=None, stop=None,
sample_count=500, parameter_cache='realtime',
source='ParameterArchive'):
"""
Returns parameter samples.
The query range is split in sample intervals of equal leng... | [
"def",
"sample_parameter_values",
"(",
"self",
",",
"parameter",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"sample_count",
"=",
"500",
",",
"parameter_cache",
"=",
"'realtime'",
",",
"source",
"=",
"'ParameterArchive'",
")",
":",
"path",
"=",... | Returns parameter samples.
The query range is split in sample intervals of equal length. For
each interval a :class:`.Sample` is returned which describes the
min, max, count and avg during that interval.
Note that sample times are determined without considering the
actual param... | [
"Returns",
"parameter",
"samples",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L320-L382 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.list_parameter_ranges | def list_parameter_ranges(self, parameter, start=None, stop=None,
min_gap=None, max_gap=None,
parameter_cache='realtime'):
"""
Returns parameter ranges between the specified start and stop time.
Each range indicates an interval during ... | python | def list_parameter_ranges(self, parameter, start=None, stop=None,
min_gap=None, max_gap=None,
parameter_cache='realtime'):
"""
Returns parameter ranges between the specified start and stop time.
Each range indicates an interval during ... | [
"def",
"list_parameter_ranges",
"(",
"self",
",",
"parameter",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"min_gap",
"=",
"None",
",",
"max_gap",
"=",
"None",
",",
"parameter_cache",
"=",
"'realtime'",
")",
":",
"path",
"=",
"'/archive/{}/pa... | Returns parameter ranges between the specified start and stop time.
Each range indicates an interval during which this parameter's
value was uninterrupted and unchanged.
Ranges are a good fit for retrieving the value of a parameter
that does not change frequently. For example an on/off... | [
"Returns",
"parameter",
"ranges",
"between",
"the",
"specified",
"start",
"and",
"stop",
"time",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L384-L444 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.list_parameter_values | def list_parameter_values(self, parameter, start=None, stop=None,
page_size=500, descending=False,
parameter_cache='realtime',
source='ParameterArchive'):
"""
Reads parameter values between the specified start and ... | python | def list_parameter_values(self, parameter, start=None, stop=None,
page_size=500, descending=False,
parameter_cache='realtime',
source='ParameterArchive'):
"""
Reads parameter values between the specified start and ... | [
"def",
"list_parameter_values",
"(",
"self",
",",
"parameter",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"page_size",
"=",
"500",
",",
"descending",
"=",
"False",
",",
"parameter_cache",
"=",
"'realtime'",
",",
"source",
"=",
"'ParameterArchi... | Reads parameter values between the specified start and stop time.
:param str parameter: Either a fully-qualified XTCE name or an alias in the
format ``NAMESPACE/NAME``.
:param ~datetime.datetime start: Minimum generation time of the returned
... | [
"Reads",
"parameter",
"values",
"between",
"the",
"specified",
"start",
"and",
"stop",
"time",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L446-L499 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.list_command_history | def list_command_history(self, command=None, start=None, stop=None,
page_size=500, descending=False):
"""
Reads command history entries between the specified start and stop time.
:param str command: Either a fully-qualified XTCE name or an alias in the
... | python | def list_command_history(self, command=None, start=None, stop=None,
page_size=500, descending=False):
"""
Reads command history entries between the specified start and stop time.
:param str command: Either a fully-qualified XTCE name or an alias in the
... | [
"def",
"list_command_history",
"(",
"self",
",",
"command",
"=",
"None",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"page_size",
"=",
"500",
",",
"descending",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'order'",
":",
"'desc'",
"if",
... | Reads command history entries between the specified start and stop time.
:param str command: Either a fully-qualified XTCE name or an alias in the
format ``NAMESPACE/NAME``.
:param ~datetime.datetime start: Minimum generation time of the returned
... | [
"Reads",
"command",
"history",
"entries",
"between",
"the",
"specified",
"start",
"and",
"stop",
"time",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L501-L540 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.list_tables | def list_tables(self):
"""
Returns the existing tables.
Tables are returned in lexicographical order.
:rtype: ~collections.Iterable[.Table]
"""
# Server does not do pagination on listings of this resource.
# Return an iterator anyway for similarity with other AP... | python | def list_tables(self):
"""
Returns the existing tables.
Tables are returned in lexicographical order.
:rtype: ~collections.Iterable[.Table]
"""
# Server does not do pagination on listings of this resource.
# Return an iterator anyway for similarity with other AP... | [
"def",
"list_tables",
"(",
"self",
")",
":",
"path",
"=",
"'/archive/{}/tables'",
".",
"format",
"(",
"self",
".",
"_instance",
")",
"response",
"=",
"self",
".",
"_client",
".",
"get_proto",
"(",
"path",
"=",
"path",
")",
"message",
"=",
"rest_pb2",
"."... | Returns the existing tables.
Tables are returned in lexicographical order.
:rtype: ~collections.Iterable[.Table] | [
"Returns",
"the",
"existing",
"tables",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L542-L557 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.get_table | def get_table(self, table):
"""
Gets a single table.
:param str table: The name of the table.
:rtype: .Table
"""
path = '/archive/{}/tables/{}'.format(self._instance, table)
response = self._client.get_proto(path=path)
message = archive_pb2.TableInfo()
... | python | def get_table(self, table):
"""
Gets a single table.
:param str table: The name of the table.
:rtype: .Table
"""
path = '/archive/{}/tables/{}'.format(self._instance, table)
response = self._client.get_proto(path=path)
message = archive_pb2.TableInfo()
... | [
"def",
"get_table",
"(",
"self",
",",
"table",
")",
":",
"path",
"=",
"'/archive/{}/tables/{}'",
".",
"format",
"(",
"self",
".",
"_instance",
",",
"table",
")",
"response",
"=",
"self",
".",
"_client",
".",
"get_proto",
"(",
"path",
"=",
"path",
")",
... | Gets a single table.
:param str table: The name of the table.
:rtype: .Table | [
"Gets",
"a",
"single",
"table",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L559-L570 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.list_streams | def list_streams(self):
"""
Returns the existing streams.
Streams are returned in lexicographical order.
:rtype: ~collections.Iterable[.Stream]
"""
# Server does not do pagination on listings of this resource.
# Return an iterator anyway for similarity with othe... | python | def list_streams(self):
"""
Returns the existing streams.
Streams are returned in lexicographical order.
:rtype: ~collections.Iterable[.Stream]
"""
# Server does not do pagination on listings of this resource.
# Return an iterator anyway for similarity with othe... | [
"def",
"list_streams",
"(",
"self",
")",
":",
"path",
"=",
"'/archive/{}/streams'",
".",
"format",
"(",
"self",
".",
"_instance",
")",
"response",
"=",
"self",
".",
"_client",
".",
"get_proto",
"(",
"path",
"=",
"path",
")",
"message",
"=",
"rest_pb2",
"... | Returns the existing streams.
Streams are returned in lexicographical order.
:rtype: ~collections.Iterable[.Stream] | [
"Returns",
"the",
"existing",
"streams",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L585-L600 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.get_stream | def get_stream(self, stream):
"""
Gets a single stream.
:param str stream: The name of the stream.
:rtype: .Stream
"""
path = '/archive/{}/streams/{}'.format(self._instance, stream)
response = self._client.get_proto(path=path)
message = archive_pb2.Stream... | python | def get_stream(self, stream):
"""
Gets a single stream.
:param str stream: The name of the stream.
:rtype: .Stream
"""
path = '/archive/{}/streams/{}'.format(self._instance, stream)
response = self._client.get_proto(path=path)
message = archive_pb2.Stream... | [
"def",
"get_stream",
"(",
"self",
",",
"stream",
")",
":",
"path",
"=",
"'/archive/{}/streams/{}'",
".",
"format",
"(",
"self",
".",
"_instance",
",",
"stream",
")",
"response",
"=",
"self",
".",
"_client",
".",
"get_proto",
"(",
"path",
"=",
"path",
")"... | Gets a single stream.
:param str stream: The name of the stream.
:rtype: .Stream | [
"Gets",
"a",
"single",
"stream",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L602-L613 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.create_stream_subscription | def create_stream_subscription(self, stream, on_data, timeout=60):
"""
Create a new stream subscription.
:param str stream: The name of the stream.
:param on_data: Function that gets called with :class:`.StreamData`
updates.
:param float timeout: The amo... | python | def create_stream_subscription(self, stream, on_data, timeout=60):
"""
Create a new stream subscription.
:param str stream: The name of the stream.
:param on_data: Function that gets called with :class:`.StreamData`
updates.
:param float timeout: The amo... | [
"def",
"create_stream_subscription",
"(",
"self",
",",
"stream",
",",
"on_data",
",",
"timeout",
"=",
"60",
")",
":",
"options",
"=",
"rest_pb2",
".",
"StreamSubscribeRequest",
"(",
")",
"options",
".",
"stream",
"=",
"stream",
"manager",
"=",
"WebSocketSubscr... | Create a new stream subscription.
:param str stream: The name of the stream.
:param on_data: Function that gets called with :class:`.StreamData`
updates.
:param float timeout: The amount of seconds to wait for the request
to complete.
... | [
"Create",
"a",
"new",
"stream",
"subscription",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L615-L645 | train |
yamcs/yamcs-python | yamcs-client/yamcs/archive/client.py | ArchiveClient.execute_sql | def execute_sql(self, statement):
"""
Executes a single SQL statement.
:param statement: SQL string
:return: String response
:rtype: str
"""
path = '/archive/{}/sql'.format(self._instance)
req = archive_pb2.ExecuteSqlRequest()
req.statement = stat... | python | def execute_sql(self, statement):
"""
Executes a single SQL statement.
:param statement: SQL string
:return: String response
:rtype: str
"""
path = '/archive/{}/sql'.format(self._instance)
req = archive_pb2.ExecuteSqlRequest()
req.statement = stat... | [
"def",
"execute_sql",
"(",
"self",
",",
"statement",
")",
":",
"path",
"=",
"'/archive/{}/sql'",
".",
"format",
"(",
"self",
".",
"_instance",
")",
"req",
"=",
"archive_pb2",
".",
"ExecuteSqlRequest",
"(",
")",
"req",
".",
"statement",
"=",
"statement",
"r... | Executes a single SQL statement.
:param statement: SQL string
:return: String response
:rtype: str | [
"Executes",
"a",
"single",
"SQL",
"statement",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/archive/client.py#L647-L665 | train |
moin18/utilspie | utilspie/fileutils/file_utils.py | copy_file | def copy_file(source, destination, unique=False, sort=False, case_sensitive=True, create_path=False):
"""
Python utility to create file
Args:
source: absolute/relative path of source file
destination: absolute/relative path of destination file.
Use same as source for re... | python | def copy_file(source, destination, unique=False, sort=False, case_sensitive=True, create_path=False):
"""
Python utility to create file
Args:
source: absolute/relative path of source file
destination: absolute/relative path of destination file.
Use same as source for re... | [
"def",
"copy_file",
"(",
"source",
",",
"destination",
",",
"unique",
"=",
"False",
",",
"sort",
"=",
"False",
",",
"case_sensitive",
"=",
"True",
",",
"create_path",
"=",
"False",
")",
":",
"_File",
".",
"copy",
"(",
"source",
",",
"destination",
",",
... | Python utility to create file
Args:
source: absolute/relative path of source file
destination: absolute/relative path of destination file.
Use same as source for replacing the content of existing file.
unique: Copy only unique lines from file
sort: Sort the cont... | [
"Python",
"utility",
"to",
"create",
"file"
] | ea96860b93fd058019a829847258e39323fef31f | https://github.com/moin18/utilspie/blob/ea96860b93fd058019a829847258e39323fef31f/utilspie/fileutils/file_utils.py#L34-L50 | train |
sirfoga/pyhal | hal/files/models/audio.py | MP3Song.get_details | def get_details(self):
"""Finds songs details
:return: Dictionary with songs details about title, artist, album and
year
"""
title = str(self.get_title()).strip()
artist = str(self.get_artist()).strip()
album = str(self.get_album()).strip()
year = str... | python | def get_details(self):
"""Finds songs details
:return: Dictionary with songs details about title, artist, album and
year
"""
title = str(self.get_title()).strip()
artist = str(self.get_artist()).strip()
album = str(self.get_album()).strip()
year = str... | [
"def",
"get_details",
"(",
"self",
")",
":",
"title",
"=",
"str",
"(",
"self",
".",
"get_title",
"(",
")",
")",
".",
"strip",
"(",
")",
"artist",
"=",
"str",
"(",
"self",
".",
"get_artist",
"(",
")",
")",
".",
"strip",
"(",
")",
"album",
"=",
"... | Finds songs details
:return: Dictionary with songs details about title, artist, album and
year | [
"Finds",
"songs",
"details"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/audio.py#L51-L67 | train |
sirfoga/pyhal | hal/files/models/audio.py | MP3Song._set_attr | def _set_attr(self, attribute):
"""Sets attribute of song
:param attribute: Attribute to save
:return: True iff operation completed
"""
self.tags.add(attribute)
self.song.save() | python | def _set_attr(self, attribute):
"""Sets attribute of song
:param attribute: Attribute to save
:return: True iff operation completed
"""
self.tags.add(attribute)
self.song.save() | [
"def",
"_set_attr",
"(",
"self",
",",
"attribute",
")",
":",
"self",
".",
"tags",
".",
"add",
"(",
"attribute",
")",
"self",
".",
"song",
".",
"save",
"(",
")"
] | Sets attribute of song
:param attribute: Attribute to save
:return: True iff operation completed | [
"Sets",
"attribute",
"of",
"song"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/audio.py#L70-L78 | train |
sirfoga/pyhal | hal/files/models/audio.py | MP3Song.set_title | def set_title(self, name):
"""Sets song's title
:param name: title
"""
self._set_attr(TIT2(encoding=3, text=name.decode('utf-8'))) | python | def set_title(self, name):
"""Sets song's title
:param name: title
"""
self._set_attr(TIT2(encoding=3, text=name.decode('utf-8'))) | [
"def",
"set_title",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_set_attr",
"(",
"TIT2",
"(",
"encoding",
"=",
"3",
",",
"text",
"=",
"name",
".",
"decode",
"(",
"'utf-8'",
")",
")",
")"
] | Sets song's title
:param name: title | [
"Sets",
"song",
"s",
"title"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/audio.py#L80-L85 | train |
sirfoga/pyhal | hal/files/models/audio.py | MP3Song.set_artist | def set_artist(self, artist):
"""Sets song's artist
:param artist: artist
"""
self._set_attr(TPE1(encoding=3, text=artist.decode('utf-8'))) | python | def set_artist(self, artist):
"""Sets song's artist
:param artist: artist
"""
self._set_attr(TPE1(encoding=3, text=artist.decode('utf-8'))) | [
"def",
"set_artist",
"(",
"self",
",",
"artist",
")",
":",
"self",
".",
"_set_attr",
"(",
"TPE1",
"(",
"encoding",
"=",
"3",
",",
"text",
"=",
"artist",
".",
"decode",
"(",
"'utf-8'",
")",
")",
")"
] | Sets song's artist
:param artist: artist | [
"Sets",
"song",
"s",
"artist"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/audio.py#L87-L92 | train |
sirfoga/pyhal | hal/files/models/audio.py | MP3Song.set_album | def set_album(self, album):
"""Sets song's album
:param album: album
"""
self._set_attr(TALB(encoding=3, text=album.decode('utf-8'))) | python | def set_album(self, album):
"""Sets song's album
:param album: album
"""
self._set_attr(TALB(encoding=3, text=album.decode('utf-8'))) | [
"def",
"set_album",
"(",
"self",
",",
"album",
")",
":",
"self",
".",
"_set_attr",
"(",
"TALB",
"(",
"encoding",
"=",
"3",
",",
"text",
"=",
"album",
".",
"decode",
"(",
"'utf-8'",
")",
")",
")"
] | Sets song's album
:param album: album | [
"Sets",
"song",
"s",
"album"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/audio.py#L94-L99 | train |
sirfoga/pyhal | hal/files/models/audio.py | MP3Song.set_nr_track | def set_nr_track(self, nr_track):
"""Sets song's track numb
:param nr_track: of track
"""
self._set_attr(TRCK(encoding=3, text=str(nr_track))) | python | def set_nr_track(self, nr_track):
"""Sets song's track numb
:param nr_track: of track
"""
self._set_attr(TRCK(encoding=3, text=str(nr_track))) | [
"def",
"set_nr_track",
"(",
"self",
",",
"nr_track",
")",
":",
"self",
".",
"_set_attr",
"(",
"TRCK",
"(",
"encoding",
"=",
"3",
",",
"text",
"=",
"str",
"(",
"nr_track",
")",
")",
")"
] | Sets song's track numb
:param nr_track: of track | [
"Sets",
"song",
"s",
"track",
"numb"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/audio.py#L101-L106 | train |
sirfoga/pyhal | hal/files/models/audio.py | MP3Song.set_year | def set_year(self, year):
"""Sets song's year
:param year: year
"""
self._set_attr(TDRC(encoding=3, text=str(year))) | python | def set_year(self, year):
"""Sets song's year
:param year: year
"""
self._set_attr(TDRC(encoding=3, text=str(year))) | [
"def",
"set_year",
"(",
"self",
",",
"year",
")",
":",
"self",
".",
"_set_attr",
"(",
"TDRC",
"(",
"encoding",
"=",
"3",
",",
"text",
"=",
"str",
"(",
"year",
")",
")",
")"
] | Sets song's year
:param year: year | [
"Sets",
"song",
"s",
"year"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/audio.py#L108-L113 | train |
sirfoga/pyhal | hal/files/models/audio.py | MP3Song.set_genre | def set_genre(self, genre):
"""Sets song's genre
:param genre: genre
"""
self._set_attr(TCON(encoding=3, text=str(genre))) | python | def set_genre(self, genre):
"""Sets song's genre
:param genre: genre
"""
self._set_attr(TCON(encoding=3, text=str(genre))) | [
"def",
"set_genre",
"(",
"self",
",",
"genre",
")",
":",
"self",
".",
"_set_attr",
"(",
"TCON",
"(",
"encoding",
"=",
"3",
",",
"text",
"=",
"str",
"(",
"genre",
")",
")",
")"
] | Sets song's genre
:param genre: genre | [
"Sets",
"song",
"s",
"genre"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/models/audio.py#L115-L120 | train |
portfors-lab/sparkle | sparkle/gui/stim/stimulus_editor.py | StimulusEditor.updateTraceCount | def updateTraceCount(self):
"""Updates the trace count label with the data from the model"""
self.ui.ntracesLbl.setNum(self.ui.trackview.model().traceCount()) | python | def updateTraceCount(self):
"""Updates the trace count label with the data from the model"""
self.ui.ntracesLbl.setNum(self.ui.trackview.model().traceCount()) | [
"def",
"updateTraceCount",
"(",
"self",
")",
":",
"self",
".",
"ui",
".",
"ntracesLbl",
".",
"setNum",
"(",
"self",
".",
"ui",
".",
"trackview",
".",
"model",
"(",
")",
".",
"traceCount",
"(",
")",
")"
] | Updates the trace count label with the data from the model | [
"Updates",
"the",
"trace",
"count",
"label",
"with",
"the",
"data",
"from",
"the",
"model"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/stimulus_editor.py#L70-L72 | train |
portfors-lab/sparkle | sparkle/gui/stim/stimulus_editor.py | StimulusEditor.preview | def preview(self):
"""Assemble the current components in the QStimulusModel and generate a spectrogram
plot in a separate window"""
msg = self.ui.trackview.model().verify()
if msg:
answer = QtGui.QMessageBox.warning(self, "Bummer", 'Problem: {}.'.format(msg))
ret... | python | def preview(self):
"""Assemble the current components in the QStimulusModel and generate a spectrogram
plot in a separate window"""
msg = self.ui.trackview.model().verify()
if msg:
answer = QtGui.QMessageBox.warning(self, "Bummer", 'Problem: {}.'.format(msg))
ret... | [
"def",
"preview",
"(",
"self",
")",
":",
"msg",
"=",
"self",
".",
"ui",
".",
"trackview",
".",
"model",
"(",
")",
".",
"verify",
"(",
")",
"if",
"msg",
":",
"answer",
"=",
"QtGui",
".",
"QMessageBox",
".",
"warning",
"(",
"self",
",",
"\"Bummer\"",... | Assemble the current components in the QStimulusModel and generate a spectrogram
plot in a separate window | [
"Assemble",
"the",
"current",
"components",
"in",
"the",
"QStimulusModel",
"and",
"generate",
"a",
"spectrogram",
"plot",
"in",
"a",
"separate",
"window"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/stimulus_editor.py#L74-L87 | train |
lowandrew/OLCTools | spadespipeline/offhours.py | Offhours.assertpathsandfiles | def assertpathsandfiles(self):
"""Assertions to make sure that arguments are at least mostly valid"""
# Assertion to ensure that the MiSeq path exists
assert os.path.isdir(self.miseqpath), u'MiSeqPath is not a valid directory {0!r:s}'.format(self.miseqpath)
# If the miseq folder name is ... | python | def assertpathsandfiles(self):
"""Assertions to make sure that arguments are at least mostly valid"""
# Assertion to ensure that the MiSeq path exists
assert os.path.isdir(self.miseqpath), u'MiSeqPath is not a valid directory {0!r:s}'.format(self.miseqpath)
# If the miseq folder name is ... | [
"def",
"assertpathsandfiles",
"(",
"self",
")",
":",
"assert",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"miseqpath",
")",
",",
"u'MiSeqPath is not a valid directory {0!r:s}'",
".",
"format",
"(",
"self",
".",
"miseqpath",
")",
"if",
"not",
"self",
... | Assertions to make sure that arguments are at least mostly valid | [
"Assertions",
"to",
"make",
"sure",
"that",
"arguments",
"are",
"at",
"least",
"mostly",
"valid"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/offhours.py#L14-L41 | train |
lowandrew/OLCTools | spadespipeline/offhours.py | Offhours.numberofsamples | def numberofsamples(self):
"""Count the number of samples is the samplesheet"""
# Initialise variables to store line data
idline = 0
linenumber = 0
# Parse the sample sheet to find the number of samples
with open(self.samplesheet, "rb") as ssheet:
# Use enumer... | python | def numberofsamples(self):
"""Count the number of samples is the samplesheet"""
# Initialise variables to store line data
idline = 0
linenumber = 0
# Parse the sample sheet to find the number of samples
with open(self.samplesheet, "rb") as ssheet:
# Use enumer... | [
"def",
"numberofsamples",
"(",
"self",
")",
":",
"idline",
"=",
"0",
"linenumber",
"=",
"0",
"with",
"open",
"(",
"self",
".",
"samplesheet",
",",
"\"rb\"",
")",
"as",
"ssheet",
":",
"for",
"linenumber",
",",
"entry",
"in",
"enumerate",
"(",
"ssheet",
... | Count the number of samples is the samplesheet | [
"Count",
"the",
"number",
"of",
"samples",
"is",
"the",
"samplesheet"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/offhours.py#L43-L65 | train |
yamcs/yamcs-python | yamcs-client/examples/archive_retrieval.py | print_packet_range | def print_packet_range():
"""Print the range of archived packets."""
first_packet = next(iter(archive.list_packets()))
last_packet = next(iter(archive.list_packets(descending=True)))
print('First packet:', first_packet)
print('Last packet:', last_packet)
td = last_packet.generation_time - first... | python | def print_packet_range():
"""Print the range of archived packets."""
first_packet = next(iter(archive.list_packets()))
last_packet = next(iter(archive.list_packets(descending=True)))
print('First packet:', first_packet)
print('Last packet:', last_packet)
td = last_packet.generation_time - first... | [
"def",
"print_packet_range",
"(",
")",
":",
"first_packet",
"=",
"next",
"(",
"iter",
"(",
"archive",
".",
"list_packets",
"(",
")",
")",
")",
"last_packet",
"=",
"next",
"(",
"iter",
"(",
"archive",
".",
"list_packets",
"(",
"descending",
"=",
"True",
"... | Print the range of archived packets. | [
"Print",
"the",
"range",
"of",
"archived",
"packets",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/archive_retrieval.py#L15-L23 | train |
yamcs/yamcs-python | yamcs-client/examples/archive_retrieval.py | iterate_specific_packet_range | def iterate_specific_packet_range():
"""Count the number of packets in a specific range."""
now = datetime.utcnow()
start = now - timedelta(hours=1)
total = 0
for packet in archive.list_packets(start=start, stop=now):
total += 1
# print(packet)
print('Found', total, 'packets in ... | python | def iterate_specific_packet_range():
"""Count the number of packets in a specific range."""
now = datetime.utcnow()
start = now - timedelta(hours=1)
total = 0
for packet in archive.list_packets(start=start, stop=now):
total += 1
# print(packet)
print('Found', total, 'packets in ... | [
"def",
"iterate_specific_packet_range",
"(",
")",
":",
"now",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"start",
"=",
"now",
"-",
"timedelta",
"(",
"hours",
"=",
"1",
")",
"total",
"=",
"0",
"for",
"packet",
"in",
"archive",
".",
"list_packets",
"(",
"... | Count the number of packets in a specific range. | [
"Count",
"the",
"number",
"of",
"packets",
"in",
"a",
"specific",
"range",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/archive_retrieval.py#L26-L35 | train |
yamcs/yamcs-python | yamcs-client/examples/archive_retrieval.py | iterate_specific_event_range | def iterate_specific_event_range():
"""Count the number of events in a specific range."""
now = datetime.utcnow()
start = now - timedelta(hours=1)
total = 0
for event in archive.list_events(start=start, stop=now):
total += 1
# print(event)
print('Found', total, 'events in range'... | python | def iterate_specific_event_range():
"""Count the number of events in a specific range."""
now = datetime.utcnow()
start = now - timedelta(hours=1)
total = 0
for event in archive.list_events(start=start, stop=now):
total += 1
# print(event)
print('Found', total, 'events in range'... | [
"def",
"iterate_specific_event_range",
"(",
")",
":",
"now",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"start",
"=",
"now",
"-",
"timedelta",
"(",
"hours",
"=",
"1",
")",
"total",
"=",
"0",
"for",
"event",
"in",
"archive",
".",
"list_events",
"(",
"sta... | Count the number of events in a specific range. | [
"Count",
"the",
"number",
"of",
"events",
"in",
"a",
"specific",
"range",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/archive_retrieval.py#L38-L47 | train |
yamcs/yamcs-python | yamcs-client/examples/archive_retrieval.py | print_last_values | def print_last_values():
"""Print the last 10 values."""
iterable = archive.list_parameter_values('/YSS/SIMULATOR/BatteryVoltage1',
descending=True)
for pval in islice(iterable, 0, 10):
print(pval) | python | def print_last_values():
"""Print the last 10 values."""
iterable = archive.list_parameter_values('/YSS/SIMULATOR/BatteryVoltage1',
descending=True)
for pval in islice(iterable, 0, 10):
print(pval) | [
"def",
"print_last_values",
"(",
")",
":",
"iterable",
"=",
"archive",
".",
"list_parameter_values",
"(",
"'/YSS/SIMULATOR/BatteryVoltage1'",
",",
"descending",
"=",
"True",
")",
"for",
"pval",
"in",
"islice",
"(",
"iterable",
",",
"0",
",",
"10",
")",
":",
... | Print the last 10 values. | [
"Print",
"the",
"last",
"10",
"values",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/archive_retrieval.py#L50-L55 | train |
yamcs/yamcs-python | yamcs-client/examples/archive_retrieval.py | iterate_specific_parameter_range | def iterate_specific_parameter_range():
"""Count the number of parameter values in a specific range."""
now = datetime.utcnow()
start = now - timedelta(hours=1)
total = 0
for pval in archive.list_parameter_values(
'/YSS/SIMULATOR/BatteryVoltage1', start=start, stop=now):
total +... | python | def iterate_specific_parameter_range():
"""Count the number of parameter values in a specific range."""
now = datetime.utcnow()
start = now - timedelta(hours=1)
total = 0
for pval in archive.list_parameter_values(
'/YSS/SIMULATOR/BatteryVoltage1', start=start, stop=now):
total +... | [
"def",
"iterate_specific_parameter_range",
"(",
")",
":",
"now",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"start",
"=",
"now",
"-",
"timedelta",
"(",
"hours",
"=",
"1",
")",
"total",
"=",
"0",
"for",
"pval",
"in",
"archive",
".",
"list_parameter_values",
... | Count the number of parameter values in a specific range. | [
"Count",
"the",
"number",
"of",
"parameter",
"values",
"in",
"a",
"specific",
"range",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/archive_retrieval.py#L58-L68 | train |
yamcs/yamcs-python | yamcs-client/examples/archive_retrieval.py | print_last_commands | def print_last_commands():
"""Print the last 10 commands."""
iterable = archive.list_command_history(descending=True)
for entry in islice(iterable, 0, 10):
print(entry) | python | def print_last_commands():
"""Print the last 10 commands."""
iterable = archive.list_command_history(descending=True)
for entry in islice(iterable, 0, 10):
print(entry) | [
"def",
"print_last_commands",
"(",
")",
":",
"iterable",
"=",
"archive",
".",
"list_command_history",
"(",
"descending",
"=",
"True",
")",
"for",
"entry",
"in",
"islice",
"(",
"iterable",
",",
"0",
",",
"10",
")",
":",
"print",
"(",
"entry",
")"
] | Print the last 10 commands. | [
"Print",
"the",
"last",
"10",
"commands",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/archive_retrieval.py#L71-L75 | train |
sholsapp/py509 | py509/utils.py | transmogrify | def transmogrify(l):
"""Fit a flat list into a treeable object."""
d = {l[0]: {}}
tmp = d
for c in l:
tmp[c] = {}
tmp = tmp[c]
return d | python | def transmogrify(l):
"""Fit a flat list into a treeable object."""
d = {l[0]: {}}
tmp = d
for c in l:
tmp[c] = {}
tmp = tmp[c]
return d | [
"def",
"transmogrify",
"(",
"l",
")",
":",
"d",
"=",
"{",
"l",
"[",
"0",
"]",
":",
"{",
"}",
"}",
"tmp",
"=",
"d",
"for",
"c",
"in",
"l",
":",
"tmp",
"[",
"c",
"]",
"=",
"{",
"}",
"tmp",
"=",
"tmp",
"[",
"c",
"]",
"return",
"d"
] | Fit a flat list into a treeable object. | [
"Fit",
"a",
"flat",
"list",
"into",
"a",
"treeable",
"object",
"."
] | 83bd6786a8ec1543b66c42ea5523e611c3e8dc5a | https://github.com/sholsapp/py509/blob/83bd6786a8ec1543b66c42ea5523e611c3e8dc5a/py509/utils.py#L8-L15 | train |
sholsapp/py509 | py509/utils.py | tree | def tree(node, formatter=None, prefix=None, postfix=None, _depth=1):
"""Print a tree.
Sometimes it's useful to print datastructures as a tree. This function prints
out a pretty tree with root `node`. A tree is represented as a :class:`dict`,
whose keys are node names and values are :class:`dict` objects for su... | python | def tree(node, formatter=None, prefix=None, postfix=None, _depth=1):
"""Print a tree.
Sometimes it's useful to print datastructures as a tree. This function prints
out a pretty tree with root `node`. A tree is represented as a :class:`dict`,
whose keys are node names and values are :class:`dict` objects for su... | [
"def",
"tree",
"(",
"node",
",",
"formatter",
"=",
"None",
",",
"prefix",
"=",
"None",
",",
"postfix",
"=",
"None",
",",
"_depth",
"=",
"1",
")",
":",
"current",
"=",
"0",
"length",
"=",
"len",
"(",
"node",
".",
"keys",
"(",
")",
")",
"tee_joint"... | Print a tree.
Sometimes it's useful to print datastructures as a tree. This function prints
out a pretty tree with root `node`. A tree is represented as a :class:`dict`,
whose keys are node names and values are :class:`dict` objects for sub-trees
and :class:`None` for terminals.
:param dict node: The root o... | [
"Print",
"a",
"tree",
"."
] | 83bd6786a8ec1543b66c42ea5523e611c3e8dc5a | https://github.com/sholsapp/py509/blob/83bd6786a8ec1543b66c42ea5523e611c3e8dc5a/py509/utils.py#L18-L48 | train |
sholsapp/py509 | py509/utils.py | assemble_chain | def assemble_chain(leaf, store):
"""Assemble the trust chain.
This assembly method uses the certificates subject and issuer common name and
should be used for informational purposes only. It does *not*
cryptographically verify the chain!
:param OpenSSL.crypto.X509 leaf: The leaf certificate from which to bu... | python | def assemble_chain(leaf, store):
"""Assemble the trust chain.
This assembly method uses the certificates subject and issuer common name and
should be used for informational purposes only. It does *not*
cryptographically verify the chain!
:param OpenSSL.crypto.X509 leaf: The leaf certificate from which to bu... | [
"def",
"assemble_chain",
"(",
"leaf",
",",
"store",
")",
":",
"store_dict",
"=",
"{",
"}",
"for",
"cert",
"in",
"store",
":",
"store_dict",
"[",
"cert",
".",
"get_subject",
"(",
")",
".",
"CN",
"]",
"=",
"cert",
"chain",
"=",
"[",
"leaf",
"]",
"cur... | Assemble the trust chain.
This assembly method uses the certificates subject and issuer common name and
should be used for informational purposes only. It does *not*
cryptographically verify the chain!
:param OpenSSL.crypto.X509 leaf: The leaf certificate from which to build the
chain.
:param list[OpenS... | [
"Assemble",
"the",
"trust",
"chain",
"."
] | 83bd6786a8ec1543b66c42ea5523e611c3e8dc5a | https://github.com/sholsapp/py509/blob/83bd6786a8ec1543b66c42ea5523e611c3e8dc5a/py509/utils.py#L53-L86 | train |
sirfoga/pyhal | hal/internet/services/github.py | GithubRawApi._get_api_content | def _get_api_content(self):
"""Updates class api content by calling Github api and storing result"""
if GITHUB_TOKEN is not None:
self.add_params_to_url({
"access_token": GITHUB_TOKEN
})
api_content_response = requests.get(self.api_url)
self.api_... | python | def _get_api_content(self):
"""Updates class api content by calling Github api and storing result"""
if GITHUB_TOKEN is not None:
self.add_params_to_url({
"access_token": GITHUB_TOKEN
})
api_content_response = requests.get(self.api_url)
self.api_... | [
"def",
"_get_api_content",
"(",
"self",
")",
":",
"if",
"GITHUB_TOKEN",
"is",
"not",
"None",
":",
"self",
".",
"add_params_to_url",
"(",
"{",
"\"access_token\"",
":",
"GITHUB_TOKEN",
"}",
")",
"api_content_response",
"=",
"requests",
".",
"get",
"(",
"self",
... | Updates class api content by calling Github api and storing result | [
"Updates",
"class",
"api",
"content",
"by",
"calling",
"Github",
"api",
"and",
"storing",
"result"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/internet/services/github.py#L79-L90 | train |
sirfoga/pyhal | hal/internet/services/github.py | GithubApi.get_trending_daily | def get_trending_daily(lang=""):
"""Fetches repos in "Trending Daily" Github section
:param lang: Coding language
:return: List of GithubUserRepository
"""
url = "https://github.com/trending/"
url += str(lang).lower().replace(" ", "") + "?since=daily"
api_content... | python | def get_trending_daily(lang=""):
"""Fetches repos in "Trending Daily" Github section
:param lang: Coding language
:return: List of GithubUserRepository
"""
url = "https://github.com/trending/"
url += str(lang).lower().replace(" ", "") + "?since=daily"
api_content... | [
"def",
"get_trending_daily",
"(",
"lang",
"=",
"\"\"",
")",
":",
"url",
"=",
"\"https://github.com/trending/\"",
"url",
"+=",
"str",
"(",
"lang",
")",
".",
"lower",
"(",
")",
".",
"replace",
"(",
"\" \"",
",",
"\"\"",
")",
"+",
"\"?since=daily\"",
"api_con... | Fetches repos in "Trending Daily" Github section
:param lang: Coding language
:return: List of GithubUserRepository | [
"Fetches",
"repos",
"in",
"Trending",
"Daily",
"Github",
"section"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/internet/services/github.py#L114-L136 | train |
sirfoga/pyhal | hal/internet/services/github.py | GithubUser._get_repos | def _get_repos(url):
"""Gets repos in url
:param url: Url
:return: List of repositories in given url
"""
current_page = 1
there_is_something_left = True
repos_list = []
while there_is_something_left:
api_driver = GithubRawApi(
... | python | def _get_repos(url):
"""Gets repos in url
:param url: Url
:return: List of repositories in given url
"""
current_page = 1
there_is_something_left = True
repos_list = []
while there_is_something_left:
api_driver = GithubRawApi(
... | [
"def",
"_get_repos",
"(",
"url",
")",
":",
"current_page",
"=",
"1",
"there_is_something_left",
"=",
"True",
"repos_list",
"=",
"[",
"]",
"while",
"there_is_something_left",
":",
"api_driver",
"=",
"GithubRawApi",
"(",
"url",
",",
"url_params",
"=",
"{",
"\"pa... | Gets repos in url
:param url: Url
:return: List of repositories in given url | [
"Gets",
"repos",
"in",
"url"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/internet/services/github.py#L167-L193 | train |
iqbal-lab-org/cluster_vcf_records | cluster_vcf_records/vcf_merge.py | _dict_of_vars_to_vcf_file | def _dict_of_vars_to_vcf_file(variants, outfile):
'''Input is dict made by vcf_file_read.vcf_file_to_dict_of_vars or
vcf_file_read.vcf_file_to_dict_of_vars. Output is bare-bones VCF
file (columns empty wherever possible'''
header_lines = [
'##fileformat=VCFv4.2',
'##source=cluster_vcf_re... | python | def _dict_of_vars_to_vcf_file(variants, outfile):
'''Input is dict made by vcf_file_read.vcf_file_to_dict_of_vars or
vcf_file_read.vcf_file_to_dict_of_vars. Output is bare-bones VCF
file (columns empty wherever possible'''
header_lines = [
'##fileformat=VCFv4.2',
'##source=cluster_vcf_re... | [
"def",
"_dict_of_vars_to_vcf_file",
"(",
"variants",
",",
"outfile",
")",
":",
"header_lines",
"=",
"[",
"'##fileformat=VCFv4.2'",
",",
"'##source=cluster_vcf_records, version '",
"+",
"cluster_vcf_records_version",
",",
"'##fileDate='",
"+",
"str",
"(",
"datetime",
".",
... | Input is dict made by vcf_file_read.vcf_file_to_dict_of_vars or
vcf_file_read.vcf_file_to_dict_of_vars. Output is bare-bones VCF
file (columns empty wherever possible | [
"Input",
"is",
"dict",
"made",
"by",
"vcf_file_read",
".",
"vcf_file_to_dict_of_vars",
"or",
"vcf_file_read",
".",
"vcf_file_to_dict_of_vars",
".",
"Output",
"is",
"bare",
"-",
"bones",
"VCF",
"file",
"(",
"columns",
"empty",
"wherever",
"possible"
] | 0db26af36b6da97a7361364457d2152dc756055c | https://github.com/iqbal-lab-org/cluster_vcf_records/blob/0db26af36b6da97a7361364457d2152dc756055c/cluster_vcf_records/vcf_merge.py#L8-L26 | train |
wylee/runcommands | runcommands/util/__init__.py | collect_commands | def collect_commands(package_name=None, in_place=False, level=1):
"""Collect commands from package and its subpackages.
This replaces the tedium of adding and maintaining a bunch of
imports like ``from .xyz import x, y, z`` in modules that are used
to collect all of the commands in a package.
Args... | python | def collect_commands(package_name=None, in_place=False, level=1):
"""Collect commands from package and its subpackages.
This replaces the tedium of adding and maintaining a bunch of
imports like ``from .xyz import x, y, z`` in modules that are used
to collect all of the commands in a package.
Args... | [
"def",
"collect_commands",
"(",
"package_name",
"=",
"None",
",",
"in_place",
"=",
"False",
",",
"level",
"=",
"1",
")",
":",
"commands",
"=",
"{",
"}",
"frame",
"=",
"inspect",
".",
"stack",
"(",
")",
"[",
"level",
"]",
"[",
"0",
"]",
"f_globals",
... | Collect commands from package and its subpackages.
This replaces the tedium of adding and maintaining a bunch of
imports like ``from .xyz import x, y, z`` in modules that are used
to collect all of the commands in a package.
Args:
package_name (str): Package to collect from. If not passed, the... | [
"Collect",
"commands",
"from",
"package",
"and",
"its",
"subpackages",
"."
] | b1d7c262885b9ced7ab89b63562f5464ca9970fe | https://github.com/wylee/runcommands/blob/b1d7c262885b9ced7ab89b63562f5464ca9970fe/runcommands/util/__init__.py#L28-L94 | train |
wylee/runcommands | runcommands/util/__init__.py | get_commands_in_namespace | def get_commands_in_namespace(namespace=None, level=1):
"""Get commands in namespace.
Args:
namespace (dict|module): Typically a module. If not passed, the
globals from the call site will be used.
level (int): If not called from the global scope, set this
appropriately t... | python | def get_commands_in_namespace(namespace=None, level=1):
"""Get commands in namespace.
Args:
namespace (dict|module): Typically a module. If not passed, the
globals from the call site will be used.
level (int): If not called from the global scope, set this
appropriately t... | [
"def",
"get_commands_in_namespace",
"(",
"namespace",
"=",
"None",
",",
"level",
"=",
"1",
")",
":",
"from",
".",
".",
"command",
"import",
"Command",
"commands",
"=",
"{",
"}",
"if",
"namespace",
"is",
"None",
":",
"frame",
"=",
"inspect",
".",
"stack",... | Get commands in namespace.
Args:
namespace (dict|module): Typically a module. If not passed, the
globals from the call site will be used.
level (int): If not called from the global scope, set this
appropriately to account for the call stack.
Returns:
OrderedDict... | [
"Get",
"commands",
"in",
"namespace",
"."
] | b1d7c262885b9ced7ab89b63562f5464ca9970fe | https://github.com/wylee/runcommands/blob/b1d7c262885b9ced7ab89b63562f5464ca9970fe/runcommands/util/__init__.py#L97-L126 | train |
portfors-lab/sparkle | sparkle/gui/stim/selectionmodel.py | ComponentSelectionModel.selectedIndexes | def selectedIndexes(self):
"""Returns a list of QModelIndex currently in the model"""
model = self.model()
indexes = []
for comp in self._selectedComponents:
index = model.indexByComponent(comp)
if index is None:
# must have been removed from model... | python | def selectedIndexes(self):
"""Returns a list of QModelIndex currently in the model"""
model = self.model()
indexes = []
for comp in self._selectedComponents:
index = model.indexByComponent(comp)
if index is None:
# must have been removed from model... | [
"def",
"selectedIndexes",
"(",
"self",
")",
":",
"model",
"=",
"self",
".",
"model",
"(",
")",
"indexes",
"=",
"[",
"]",
"for",
"comp",
"in",
"self",
".",
"_selectedComponents",
":",
"index",
"=",
"model",
".",
"indexByComponent",
"(",
"comp",
")",
"if... | Returns a list of QModelIndex currently in the model | [
"Returns",
"a",
"list",
"of",
"QModelIndex",
"currently",
"in",
"the",
"model"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/selectionmodel.py#L35-L46 | train |
portfors-lab/sparkle | sparkle/gui/stim/selectionmodel.py | ComponentSelectionModel.selection | def selection(self):
"""Returns items in selection as a QItemSelection object"""
sel = QtGui.QItemSelection()
for index in self.selectedIndexes():
sel.select(index, index)
return sel | python | def selection(self):
"""Returns items in selection as a QItemSelection object"""
sel = QtGui.QItemSelection()
for index in self.selectedIndexes():
sel.select(index, index)
return sel | [
"def",
"selection",
"(",
"self",
")",
":",
"sel",
"=",
"QtGui",
".",
"QItemSelection",
"(",
")",
"for",
"index",
"in",
"self",
".",
"selectedIndexes",
"(",
")",
":",
"sel",
".",
"select",
"(",
"index",
",",
"index",
")",
"return",
"sel"
] | Returns items in selection as a QItemSelection object | [
"Returns",
"items",
"in",
"selection",
"as",
"a",
"QItemSelection",
"object"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/selectionmodel.py#L48-L53 | train |
portfors-lab/sparkle | sparkle/gui/stim/selectionmodel.py | ComponentSelectionModel.selectionComponents | def selectionComponents(self):
"""Returns the names of the component types in this selection"""
comps = []
model = self.model()
for comp in self._selectedComponents:
index = model.indexByComponent(comp)
if index is not None:
comps.append(comp)
... | python | def selectionComponents(self):
"""Returns the names of the component types in this selection"""
comps = []
model = self.model()
for comp in self._selectedComponents:
index = model.indexByComponent(comp)
if index is not None:
comps.append(comp)
... | [
"def",
"selectionComponents",
"(",
"self",
")",
":",
"comps",
"=",
"[",
"]",
"model",
"=",
"self",
".",
"model",
"(",
")",
"for",
"comp",
"in",
"self",
".",
"_selectedComponents",
":",
"index",
"=",
"model",
".",
"indexByComponent",
"(",
"comp",
")",
"... | Returns the names of the component types in this selection | [
"Returns",
"the",
"names",
"of",
"the",
"component",
"types",
"in",
"this",
"selection"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/selectionmodel.py#L55-L63 | train |
ArabellaTech/django-basic-cms | basic_cms/models.py | Page.expose_content | def expose_content(self):
"""Return all the current content of this page into a `string`.
This is used by the haystack framework to build the search index."""
placeholders = get_placeholders(self.get_template())
exposed_content = []
for lang in self.get_languages():
... | python | def expose_content(self):
"""Return all the current content of this page into a `string`.
This is used by the haystack framework to build the search index."""
placeholders = get_placeholders(self.get_template())
exposed_content = []
for lang in self.get_languages():
... | [
"def",
"expose_content",
"(",
"self",
")",
":",
"placeholders",
"=",
"get_placeholders",
"(",
"self",
".",
"get_template",
"(",
")",
")",
"exposed_content",
"=",
"[",
"]",
"for",
"lang",
"in",
"self",
".",
"get_languages",
"(",
")",
":",
"for",
"ctype",
... | Return all the current content of this page into a `string`.
This is used by the haystack framework to build the search index. | [
"Return",
"all",
"the",
"current",
"content",
"of",
"this",
"page",
"into",
"a",
"string",
"."
] | 863f3c6098606f663994930cd8e7723ad0c07caf | https://github.com/ArabellaTech/django-basic-cms/blob/863f3c6098606f663994930cd8e7723ad0c07caf/basic_cms/models.py#L346-L357 | train |
CyberInt/dockermon | dockermon.py | read_http_header | def read_http_header(sock):
"""Read HTTP header from socket, return header and rest of data."""
buf = []
hdr_end = '\r\n\r\n'
while True:
buf.append(sock.recv(bufsize).decode('utf-8'))
data = ''.join(buf)
i = data.find(hdr_end)
if i == -1:
continue
re... | python | def read_http_header(sock):
"""Read HTTP header from socket, return header and rest of data."""
buf = []
hdr_end = '\r\n\r\n'
while True:
buf.append(sock.recv(bufsize).decode('utf-8'))
data = ''.join(buf)
i = data.find(hdr_end)
if i == -1:
continue
re... | [
"def",
"read_http_header",
"(",
"sock",
")",
":",
"buf",
"=",
"[",
"]",
"hdr_end",
"=",
"'\\r\\n\\r\\n'",
"while",
"True",
":",
"buf",
".",
"append",
"(",
"sock",
".",
"recv",
"(",
"bufsize",
")",
".",
"decode",
"(",
"'utf-8'",
")",
")",
"data",
"=",... | Read HTTP header from socket, return header and rest of data. | [
"Read",
"HTTP",
"header",
"from",
"socket",
"return",
"header",
"and",
"rest",
"of",
"data",
"."
] | a8733b9395cb1b551971f17c31d7f4a8268bb969 | https://github.com/CyberInt/dockermon/blob/a8733b9395cb1b551971f17c31d7f4a8268bb969/dockermon.py#L28-L39 | train |
CyberInt/dockermon | dockermon.py | connect | def connect(url):
"""Connect to UNIX or TCP socket.
url can be either tcp://<host>:port or ipc://<path>
"""
url = urlparse(url)
if url.scheme == 'tcp':
sock = socket()
netloc = tuple(url.netloc.rsplit(':', 1))
hostname = socket.gethostname()
elif url.scheme == 'ipc':... | python | def connect(url):
"""Connect to UNIX or TCP socket.
url can be either tcp://<host>:port or ipc://<path>
"""
url = urlparse(url)
if url.scheme == 'tcp':
sock = socket()
netloc = tuple(url.netloc.rsplit(':', 1))
hostname = socket.gethostname()
elif url.scheme == 'ipc':... | [
"def",
"connect",
"(",
"url",
")",
":",
"url",
"=",
"urlparse",
"(",
"url",
")",
"if",
"url",
".",
"scheme",
"==",
"'tcp'",
":",
"sock",
"=",
"socket",
"(",
")",
"netloc",
"=",
"tuple",
"(",
"url",
".",
"netloc",
".",
"rsplit",
"(",
"':'",
",",
... | Connect to UNIX or TCP socket.
url can be either tcp://<host>:port or ipc://<path> | [
"Connect",
"to",
"UNIX",
"or",
"TCP",
"socket",
"."
] | a8733b9395cb1b551971f17c31d7f4a8268bb969 | https://github.com/CyberInt/dockermon/blob/a8733b9395cb1b551971f17c31d7f4a8268bb969/dockermon.py#L50-L68 | train |
CyberInt/dockermon | dockermon.py | print_callback | def print_callback(msg):
"""Print callback, prints message to stdout as JSON in one line."""
json.dump(msg, stdout)
stdout.write('\n')
stdout.flush() | python | def print_callback(msg):
"""Print callback, prints message to stdout as JSON in one line."""
json.dump(msg, stdout)
stdout.write('\n')
stdout.flush() | [
"def",
"print_callback",
"(",
"msg",
")",
":",
"json",
".",
"dump",
"(",
"msg",
",",
"stdout",
")",
"stdout",
".",
"write",
"(",
"'\\n'",
")",
"stdout",
".",
"flush",
"(",
")"
] | Print callback, prints message to stdout as JSON in one line. | [
"Print",
"callback",
"prints",
"message",
"to",
"stdout",
"as",
"JSON",
"in",
"one",
"line",
"."
] | a8733b9395cb1b551971f17c31d7f4a8268bb969 | https://github.com/CyberInt/dockermon/blob/a8733b9395cb1b551971f17c31d7f4a8268bb969/dockermon.py#L109-L113 | train |
CyberInt/dockermon | dockermon.py | prog_callback | def prog_callback(prog, msg):
"""Program callback, calls prog with message in stdin"""
pipe = Popen(prog, stdin=PIPE)
data = json.dumps(msg)
pipe.stdin.write(data.encode('utf-8'))
pipe.stdin.close() | python | def prog_callback(prog, msg):
"""Program callback, calls prog with message in stdin"""
pipe = Popen(prog, stdin=PIPE)
data = json.dumps(msg)
pipe.stdin.write(data.encode('utf-8'))
pipe.stdin.close() | [
"def",
"prog_callback",
"(",
"prog",
",",
"msg",
")",
":",
"pipe",
"=",
"Popen",
"(",
"prog",
",",
"stdin",
"=",
"PIPE",
")",
"data",
"=",
"json",
".",
"dumps",
"(",
"msg",
")",
"pipe",
".",
"stdin",
".",
"write",
"(",
"data",
".",
"encode",
"(",... | Program callback, calls prog with message in stdin | [
"Program",
"callback",
"calls",
"prog",
"with",
"message",
"in",
"stdin"
] | a8733b9395cb1b551971f17c31d7f4a8268bb969 | https://github.com/CyberInt/dockermon/blob/a8733b9395cb1b551971f17c31d7f4a8268bb969/dockermon.py#L116-L121 | train |
lsst-sqre/sqre-codekit | codekit/eups.py | git_tag2eups_tag | def git_tag2eups_tag(git_tag):
"""Convert git tag to an acceptable eups tag format
I.e., eups no likey semantic versioning markup, wants underscores
Parameters
----------
git_tag: str
literal git tag string
Returns
-------
eups_tag: string
A string suitable for use as ... | python | def git_tag2eups_tag(git_tag):
"""Convert git tag to an acceptable eups tag format
I.e., eups no likey semantic versioning markup, wants underscores
Parameters
----------
git_tag: str
literal git tag string
Returns
-------
eups_tag: string
A string suitable for use as ... | [
"def",
"git_tag2eups_tag",
"(",
"git_tag",
")",
":",
"eups_tag",
"=",
"git_tag",
"if",
"re",
".",
"match",
"(",
"r'\\d'",
",",
"eups_tag",
")",
":",
"eups_tag",
"=",
"\"v{eups_tag}\"",
".",
"format",
"(",
"eups_tag",
"=",
"eups_tag",
")",
"eups_tag",
"=",
... | Convert git tag to an acceptable eups tag format
I.e., eups no likey semantic versioning markup, wants underscores
Parameters
----------
git_tag: str
literal git tag string
Returns
-------
eups_tag: string
A string suitable for use as an eups tag name | [
"Convert",
"git",
"tag",
"to",
"an",
"acceptable",
"eups",
"tag",
"format"
] | 98122404cd9065d4d1d570867fe518042669126c | https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/eups.py#L160-L185 | train |
leovt/constructible | constructible.py | sqrt | def sqrt(n):
'''return the square root of n in an exact representation'''
if isinstance(n, Rational):
n = Constructible(n)
elif not isinstance(n, Constructible):
raise ValueError('the square root is not implemented for the type %s' % type(n))
r = n._try_sqrt() # pylint: disable=protect... | python | def sqrt(n):
'''return the square root of n in an exact representation'''
if isinstance(n, Rational):
n = Constructible(n)
elif not isinstance(n, Constructible):
raise ValueError('the square root is not implemented for the type %s' % type(n))
r = n._try_sqrt() # pylint: disable=protect... | [
"def",
"sqrt",
"(",
"n",
")",
":",
"if",
"isinstance",
"(",
"n",
",",
"Rational",
")",
":",
"n",
"=",
"Constructible",
"(",
"n",
")",
"elif",
"not",
"isinstance",
"(",
"n",
",",
"Constructible",
")",
":",
"raise",
"ValueError",
"(",
"'the square root i... | return the square root of n in an exact representation | [
"return",
"the",
"square",
"root",
"of",
"n",
"in",
"an",
"exact",
"representation"
] | 16fb627c81d15ffd8373397633224f50f047f882 | https://github.com/leovt/constructible/blob/16fb627c81d15ffd8373397633224f50f047f882/constructible.py#L435-L447 | train |
leovt/constructible | constructible.py | Constructible._try_sqrt | def _try_sqrt(self):
''' try to compute the square root in the field itself.
if there is no square root in the field return None.
'''
if not self.field:
assert self.b == 0
root, remainder = fsqrt(self.a)
if remainder == 1:
return Const... | python | def _try_sqrt(self):
''' try to compute the square root in the field itself.
if there is no square root in the field return None.
'''
if not self.field:
assert self.b == 0
root, remainder = fsqrt(self.a)
if remainder == 1:
return Const... | [
"def",
"_try_sqrt",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"field",
":",
"assert",
"self",
".",
"b",
"==",
"0",
"root",
",",
"remainder",
"=",
"fsqrt",
"(",
"self",
".",
"a",
")",
"if",
"remainder",
"==",
"1",
":",
"return",
"Constructibl... | try to compute the square root in the field itself.
if there is no square root in the field return None. | [
"try",
"to",
"compute",
"the",
"square",
"root",
"in",
"the",
"field",
"itself",
"."
] | 16fb627c81d15ffd8373397633224f50f047f882 | https://github.com/leovt/constructible/blob/16fb627c81d15ffd8373397633224f50f047f882/constructible.py#L397-L433 | train |
yamcs/yamcs-python | yamcs-client/examples/archive_breakdown.py | print_packet_count | def print_packet_count():
"""Print the number of packets grouped by packet name."""
for name in archive.list_packet_names():
packet_count = 0
for group in archive.list_packet_histogram(name):
for rec in group.records:
packet_count += rec.count
print(' {: <40}... | python | def print_packet_count():
"""Print the number of packets grouped by packet name."""
for name in archive.list_packet_names():
packet_count = 0
for group in archive.list_packet_histogram(name):
for rec in group.records:
packet_count += rec.count
print(' {: <40}... | [
"def",
"print_packet_count",
"(",
")",
":",
"for",
"name",
"in",
"archive",
".",
"list_packet_names",
"(",
")",
":",
"packet_count",
"=",
"0",
"for",
"group",
"in",
"archive",
".",
"list_packet_histogram",
"(",
"name",
")",
":",
"for",
"rec",
"in",
"group"... | Print the number of packets grouped by packet name. | [
"Print",
"the",
"number",
"of",
"packets",
"grouped",
"by",
"packet",
"name",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/archive_breakdown.py#L6-L13 | train |
yamcs/yamcs-python | yamcs-client/examples/archive_breakdown.py | print_pp_groups | def print_pp_groups():
"""Print the number of processed parameter frames by group name."""
for group in archive.list_processed_parameter_groups():
frame_count = 0
for pp_group in archive.list_processed_parameter_group_histogram(group):
for rec in pp_group.records:
fra... | python | def print_pp_groups():
"""Print the number of processed parameter frames by group name."""
for group in archive.list_processed_parameter_groups():
frame_count = 0
for pp_group in archive.list_processed_parameter_group_histogram(group):
for rec in pp_group.records:
fra... | [
"def",
"print_pp_groups",
"(",
")",
":",
"for",
"group",
"in",
"archive",
".",
"list_processed_parameter_groups",
"(",
")",
":",
"frame_count",
"=",
"0",
"for",
"pp_group",
"in",
"archive",
".",
"list_processed_parameter_group_histogram",
"(",
"group",
")",
":",
... | Print the number of processed parameter frames by group name. | [
"Print",
"the",
"number",
"of",
"processed",
"parameter",
"frames",
"by",
"group",
"name",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/archive_breakdown.py#L16-L23 | train |
yamcs/yamcs-python | yamcs-client/examples/archive_breakdown.py | print_event_count | def print_event_count():
"""Print the number of events grouped by source."""
for source in archive.list_event_sources():
event_count = 0
for group in archive.list_event_histogram(source):
for rec in group.records:
event_count += rec.count
print(' {: <40} {: >... | python | def print_event_count():
"""Print the number of events grouped by source."""
for source in archive.list_event_sources():
event_count = 0
for group in archive.list_event_histogram(source):
for rec in group.records:
event_count += rec.count
print(' {: <40} {: >... | [
"def",
"print_event_count",
"(",
")",
":",
"for",
"source",
"in",
"archive",
".",
"list_event_sources",
"(",
")",
":",
"event_count",
"=",
"0",
"for",
"group",
"in",
"archive",
".",
"list_event_histogram",
"(",
"source",
")",
":",
"for",
"rec",
"in",
"grou... | Print the number of events grouped by source. | [
"Print",
"the",
"number",
"of",
"events",
"grouped",
"by",
"source",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/archive_breakdown.py#L26-L33 | train |
yamcs/yamcs-python | yamcs-client/examples/archive_breakdown.py | print_command_count | def print_command_count():
"""Print the number of commands grouped by name."""
mdb = client.get_mdb(instance='simulator')
for command in mdb.list_commands():
total = 0
for group in archive.list_command_histogram(command.qualified_name):
for rec in group.records:
t... | python | def print_command_count():
"""Print the number of commands grouped by name."""
mdb = client.get_mdb(instance='simulator')
for command in mdb.list_commands():
total = 0
for group in archive.list_command_histogram(command.qualified_name):
for rec in group.records:
t... | [
"def",
"print_command_count",
"(",
")",
":",
"mdb",
"=",
"client",
".",
"get_mdb",
"(",
"instance",
"=",
"'simulator'",
")",
"for",
"command",
"in",
"mdb",
".",
"list_commands",
"(",
")",
":",
"total",
"=",
"0",
"for",
"group",
"in",
"archive",
".",
"l... | Print the number of commands grouped by name. | [
"Print",
"the",
"number",
"of",
"commands",
"grouped",
"by",
"name",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/archive_breakdown.py#L36-L44 | train |
lsst-sqre/sqre-codekit | codekit/cli/github_tag_release.py | cmp_dict | def cmp_dict(d1, d2, ignore_keys=[]):
"""Compare dicts ignoring select keys"""
# https://stackoverflow.com/questions/10480806/compare-dictionaries-ignoring-specific-keys
return {k: v for k, v in d1.items() if k not in ignore_keys} \
== {k: v for k, v in d2.items() if k not in ignore_keys} | python | def cmp_dict(d1, d2, ignore_keys=[]):
"""Compare dicts ignoring select keys"""
# https://stackoverflow.com/questions/10480806/compare-dictionaries-ignoring-specific-keys
return {k: v for k, v in d1.items() if k not in ignore_keys} \
== {k: v for k, v in d2.items() if k not in ignore_keys} | [
"def",
"cmp_dict",
"(",
"d1",
",",
"d2",
",",
"ignore_keys",
"=",
"[",
"]",
")",
":",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"d1",
".",
"items",
"(",
")",
"if",
"k",
"not",
"in",
"ignore_keys",
"}",
"==",
"{",
"k",
":",
"... | Compare dicts ignoring select keys | [
"Compare",
"dicts",
"ignoring",
"select",
"keys"
] | 98122404cd9065d4d1d570867fe518042669126c | https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/cli/github_tag_release.py#L232-L236 | train |
lsst-sqre/sqre-codekit | codekit/cli/github_tag_release.py | cross_reference_products | def cross_reference_products(
eups_products,
manifest_products,
ignore_manifest_versions=False,
fail_fast=False,
):
"""
Cross reference EupsTag and Manifest data and return a merged result
Parameters
----------
eups_products:
manifest:
fail_fast: bool
ignore_manifest_ver... | python | def cross_reference_products(
eups_products,
manifest_products,
ignore_manifest_versions=False,
fail_fast=False,
):
"""
Cross reference EupsTag and Manifest data and return a merged result
Parameters
----------
eups_products:
manifest:
fail_fast: bool
ignore_manifest_ver... | [
"def",
"cross_reference_products",
"(",
"eups_products",
",",
"manifest_products",
",",
"ignore_manifest_versions",
"=",
"False",
",",
"fail_fast",
"=",
"False",
",",
")",
":",
"products",
"=",
"{",
"}",
"problems",
"=",
"[",
"]",
"for",
"name",
",",
"eups_dat... | Cross reference EupsTag and Manifest data and return a merged result
Parameters
----------
eups_products:
manifest:
fail_fast: bool
ignore_manifest_versions: bool
Returns
-------
products: dict
Raises
------
RuntimeError
Upon error if `fail_fast` is `True`. | [
"Cross",
"reference",
"EupsTag",
"and",
"Manifest",
"data",
"and",
"return",
"a",
"merged",
"result"
] | 98122404cd9065d4d1d570867fe518042669126c | https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/cli/github_tag_release.py#L239-L311 | train |
lsst-sqre/sqre-codekit | codekit/cli/github_tag_release.py | check_existing_git_tag | def check_existing_git_tag(repo, t_tag, **kwargs):
"""
Check for a pre-existng tag in the github repo.
Parameters
----------
repo : github.Repository.Repository
repo to inspect for an existing tagsdf
t_tag: codekit.pygithub.TargetTag
dict repesenting a target git tag
Return... | python | def check_existing_git_tag(repo, t_tag, **kwargs):
"""
Check for a pre-existng tag in the github repo.
Parameters
----------
repo : github.Repository.Repository
repo to inspect for an existing tagsdf
t_tag: codekit.pygithub.TargetTag
dict repesenting a target git tag
Return... | [
"def",
"check_existing_git_tag",
"(",
"repo",
",",
"t_tag",
",",
"**",
"kwargs",
")",
":",
"assert",
"isinstance",
"(",
"repo",
",",
"github",
".",
"Repository",
".",
"Repository",
")",
",",
"type",
"(",
"repo",
")",
"assert",
"isinstance",
"(",
"t_tag",
... | Check for a pre-existng tag in the github repo.
Parameters
----------
repo : github.Repository.Repository
repo to inspect for an existing tagsdf
t_tag: codekit.pygithub.TargetTag
dict repesenting a target git tag
Returns
-------
insync : `bool`
True if tag exists an... | [
"Check",
"for",
"a",
"pre",
"-",
"existng",
"tag",
"in",
"the",
"github",
"repo",
"."
] | 98122404cd9065d4d1d570867fe518042669126c | https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/cli/github_tag_release.py#L445-L523 | train |
lsst-sqre/sqre-codekit | codekit/cli/github_tag_release.py | run | def run():
"""Create the tag"""
args = parse_args()
codetools.setup_logging(args.debug)
git_tag = args.tag
# if email not specified, try getting it from the gitconfig
git_email = codetools.lookup_email(args)
# ditto for the name of the git user
git_user = codetools.lookup_user(args)
... | python | def run():
"""Create the tag"""
args = parse_args()
codetools.setup_logging(args.debug)
git_tag = args.tag
# if email not specified, try getting it from the gitconfig
git_email = codetools.lookup_email(args)
# ditto for the name of the git user
git_user = codetools.lookup_user(args)
... | [
"def",
"run",
"(",
")",
":",
"args",
"=",
"parse_args",
"(",
")",
"codetools",
".",
"setup_logging",
"(",
"args",
".",
"debug",
")",
"git_tag",
"=",
"args",
".",
"tag",
"git_email",
"=",
"codetools",
".",
"lookup_email",
"(",
"args",
")",
"git_user",
"... | Create the tag | [
"Create",
"the",
"tag"
] | 98122404cd9065d4d1d570867fe518042669126c | https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/cli/github_tag_release.py#L722-L847 | train |
sirfoga/pyhal | hal/times/cron.py | AppCronLock.can_proceed | def can_proceed(self):
"""Checks whether app can proceed
:return: True iff app is not locked and times since last update < app
update interval
"""
now = datetime.datetime.now()
delta = datetime.timedelta(days=self.update_interval)
return now >= self.last_upda... | python | def can_proceed(self):
"""Checks whether app can proceed
:return: True iff app is not locked and times since last update < app
update interval
"""
now = datetime.datetime.now()
delta = datetime.timedelta(days=self.update_interval)
return now >= self.last_upda... | [
"def",
"can_proceed",
"(",
"self",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"delta",
"=",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"self",
".",
"update_interval",
")",
"return",
"now",
">=",
"self",
".",
"last_upd... | Checks whether app can proceed
:return: True iff app is not locked and times since last update < app
update interval | [
"Checks",
"whether",
"app",
"can",
"proceed"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/times/cron.py#L31-L39 | train |
sirfoga/pyhal | hal/times/cron.py | AppCronLock.parse_lock | def parse_lock(self):
"""Parses app lock file
:return: Details about last update
"""
try:
with open(self.lock_file, "r") as reader:
data = json.loads(reader.read())
self.last_update = datetime.datetime.strptime(
data["last_... | python | def parse_lock(self):
"""Parses app lock file
:return: Details about last update
"""
try:
with open(self.lock_file, "r") as reader:
data = json.loads(reader.read())
self.last_update = datetime.datetime.strptime(
data["last_... | [
"def",
"parse_lock",
"(",
"self",
")",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"lock_file",
",",
"\"r\"",
")",
"as",
"reader",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"reader",
".",
"read",
"(",
")",
")",
"self",
".",
"last_update",... | Parses app lock file
:return: Details about last update | [
"Parses",
"app",
"lock",
"file"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/times/cron.py#L41-L55 | train |
sirfoga/pyhal | hal/times/cron.py | AppCronLock.write_lock | def write_lock(self, last_update=datetime.datetime.now()):
"""Writes lock file
:param last_update: last update of app
"""
data = {
"last_update": last_update.strftime(AppCronLock.DATETIME_FORMAT)
}
with open(self.lock_file, "w") as writer:
json.d... | python | def write_lock(self, last_update=datetime.datetime.now()):
"""Writes lock file
:param last_update: last update of app
"""
data = {
"last_update": last_update.strftime(AppCronLock.DATETIME_FORMAT)
}
with open(self.lock_file, "w") as writer:
json.d... | [
"def",
"write_lock",
"(",
"self",
",",
"last_update",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
")",
":",
"data",
"=",
"{",
"\"last_update\"",
":",
"last_update",
".",
"strftime",
"(",
"AppCronLock",
".",
"DATETIME_FORMAT",
")",
"}",
"with",
... | Writes lock file
:param last_update: last update of app | [
"Writes",
"lock",
"file"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/times/cron.py#L57-L67 | train |
MersenneForum/MersenneForumAliquot | scripts/drivers.py | filter_seq | def filter_seq(seq):
'''Examines unreserved sequences to see if they are prone to mutation. This
currently ignores solely-power-of-2 guides with b > 3'''
if seq.res:
return None
n = nt.Factors(seq.factors)
guide, s, t = aq.canonical_form(n)
seq.guide = guide
# The target_tau... | python | def filter_seq(seq):
'''Examines unreserved sequences to see if they are prone to mutation. This
currently ignores solely-power-of-2 guides with b > 3'''
if seq.res:
return None
n = nt.Factors(seq.factors)
guide, s, t = aq.canonical_form(n)
seq.guide = guide
# The target_tau... | [
"def",
"filter_seq",
"(",
"seq",
")",
":",
"if",
"seq",
".",
"res",
":",
"return",
"None",
"n",
"=",
"nt",
".",
"Factors",
"(",
"seq",
".",
"factors",
")",
"guide",
",",
"s",
",",
"t",
"=",
"aq",
".",
"canonical_form",
"(",
"n",
")",
"seq",
"."... | Examines unreserved sequences to see if they are prone to mutation. This
currently ignores solely-power-of-2 guides with b > 3 | [
"Examines",
"unreserved",
"sequences",
"to",
"see",
"if",
"they",
"are",
"prone",
"to",
"mutation",
".",
"This",
"currently",
"ignores",
"solely",
"-",
"power",
"-",
"of",
"-",
"2",
"guides",
"with",
"b",
">",
"3"
] | d2605f1b3bb7c25980d11698d915ffc1c525acda | https://github.com/MersenneForum/MersenneForumAliquot/blob/d2605f1b3bb7c25980d11698d915ffc1c525acda/scripts/drivers.py#L110-L134 | train |
farshidce/touchworks-python | touchworks/api/http.py | TouchWorks.get_token | def get_token(self, appname, username, password):
"""
get the security token by connecting to TouchWorks API
"""
ext_exception = TouchWorksException(
TouchWorksErrorMessages.GET_TOKEN_FAILED_ERROR)
data = {'Username': username,
'Password': password... | python | def get_token(self, appname, username, password):
"""
get the security token by connecting to TouchWorks API
"""
ext_exception = TouchWorksException(
TouchWorksErrorMessages.GET_TOKEN_FAILED_ERROR)
data = {'Username': username,
'Password': password... | [
"def",
"get_token",
"(",
"self",
",",
"appname",
",",
"username",
",",
"password",
")",
":",
"ext_exception",
"=",
"TouchWorksException",
"(",
"TouchWorksErrorMessages",
".",
"GET_TOKEN_FAILED_ERROR",
")",
"data",
"=",
"{",
"'Username'",
":",
"username",
",",
"'... | get the security token by connecting to TouchWorks API | [
"get",
"the",
"security",
"token",
"by",
"connecting",
"to",
"TouchWorks",
"API"
] | ea8f93a0f4273de1317a318e945a571f5038ba62 | https://github.com/farshidce/touchworks-python/blob/ea8f93a0f4273de1317a318e945a571f5038ba62/touchworks/api/http.py#L139-L161 | train |
farshidce/touchworks-python | touchworks/api/http.py | TouchWorks._http_request | def _http_request(self, api, data, headers=None):
"""
internal method for handling request and response
and raising an exception is http return status code is not success
:rtype : response object from requests.post()
"""
if not headers:
headers = {'Content-Ty... | python | def _http_request(self, api, data, headers=None):
"""
internal method for handling request and response
and raising an exception is http return status code is not success
:rtype : response object from requests.post()
"""
if not headers:
headers = {'Content-Ty... | [
"def",
"_http_request",
"(",
"self",
",",
"api",
",",
"data",
",",
"headers",
"=",
"None",
")",
":",
"if",
"not",
"headers",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
"}",
"if",
"not",
"self",
".",
"_token_valid",
":",
"self"... | internal method for handling request and response
and raising an exception is http return status code is not success
:rtype : response object from requests.post() | [
"internal",
"method",
"for",
"handling",
"request",
"and",
"response",
"and",
"raising",
"an",
"exception",
"is",
"http",
"return",
"status",
"code",
"is",
"not",
"success"
] | ea8f93a0f4273de1317a318e945a571f5038ba62 | https://github.com/farshidce/touchworks-python/blob/ea8f93a0f4273de1317a318e945a571f5038ba62/touchworks/api/http.py#L178-L195 | train |
NoviceLive/intellicoder | intellicoder/database.py | Database.query_item | def query_item(self, key, abis):
"""Query items based on system call number or name."""
try:
key = int(key)
field = 'number'
except ValueError:
try:
key = int(key, 16)
field = 'number'
except ValueError:
... | python | def query_item(self, key, abis):
"""Query items based on system call number or name."""
try:
key = int(key)
field = 'number'
except ValueError:
try:
key = int(key, 16)
field = 'number'
except ValueError:
... | [
"def",
"query_item",
"(",
"self",
",",
"key",
",",
"abis",
")",
":",
"try",
":",
"key",
"=",
"int",
"(",
"key",
")",
"field",
"=",
"'number'",
"except",
"ValueError",
":",
"try",
":",
"key",
"=",
"int",
"(",
"key",
",",
"16",
")",
"field",
"=",
... | Query items based on system call number or name. | [
"Query",
"items",
"based",
"on",
"system",
"call",
"number",
"or",
"name",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/database.py#L49-L62 | train |
NoviceLive/intellicoder | intellicoder/database.py | Database.query_decl | def query_decl(self, **kwargs):
"""Query declarations."""
return self.session.query(Decl).filter_by(**kwargs).all() | python | def query_decl(self, **kwargs):
"""Query declarations."""
return self.session.query(Decl).filter_by(**kwargs).all() | [
"def",
"query_decl",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"return",
"self",
".",
"session",
".",
"query",
"(",
"Decl",
")",
".",
"filter_by",
"(",
"**",
"kwargs",
")",
".",
"all",
"(",
")"
] | Query declarations. | [
"Query",
"declarations",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/database.py#L64-L66 | train |
NoviceLive/intellicoder | intellicoder/database.py | Database.add_data | def add_data(self, filenames):
"""Add data."""
def _parse_table(table):
def _parse_line(line):
return line.split('\t')
lines = (_parse_line(one) for one in table.splitlines()
if re.match(r'^\d', one))
return (remove_false(one) for ... | python | def add_data(self, filenames):
"""Add data."""
def _parse_table(table):
def _parse_line(line):
return line.split('\t')
lines = (_parse_line(one) for one in table.splitlines()
if re.match(r'^\d', one))
return (remove_false(one) for ... | [
"def",
"add_data",
"(",
"self",
",",
"filenames",
")",
":",
"def",
"_parse_table",
"(",
"table",
")",
":",
"def",
"_parse_line",
"(",
"line",
")",
":",
"return",
"line",
".",
"split",
"(",
"'\\t'",
")",
"lines",
"=",
"(",
"_parse_line",
"(",
"one",
"... | Add data. | [
"Add",
"data",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/database.py#L68-L115 | train |
dalloriam/engel | engel/application.py | Application.start | def start(self, on_exit_callback=None):
"""
Start the Engel application by initializing all registered services and starting an Autobahn IOLoop.
:param on_exit_callback: Callback triggered on application exit
"""
# TODO: Support params for services by mapping {servicename: {clas... | python | def start(self, on_exit_callback=None):
"""
Start the Engel application by initializing all registered services and starting an Autobahn IOLoop.
:param on_exit_callback: Callback triggered on application exit
"""
# TODO: Support params for services by mapping {servicename: {clas... | [
"def",
"start",
"(",
"self",
",",
"on_exit_callback",
"=",
"None",
")",
":",
"for",
"service",
"in",
"self",
".",
"services",
".",
"keys",
"(",
")",
":",
"self",
".",
"services",
"[",
"service",
"]",
"=",
"self",
".",
"services",
"[",
"service",
"]",... | Start the Engel application by initializing all registered services and starting an Autobahn IOLoop.
:param on_exit_callback: Callback triggered on application exit | [
"Start",
"the",
"Engel",
"application",
"by",
"initializing",
"all",
"registered",
"services",
"and",
"starting",
"an",
"Autobahn",
"IOLoop",
"."
] | f3477cd546e885bc53e755b3eb1452ce43ef5697 | https://github.com/dalloriam/engel/blob/f3477cd546e885bc53e755b3eb1452ce43ef5697/engel/application.py#L59-L70 | train |
dalloriam/engel | engel/application.py | Application.register | def register(self, event, callback, selector=None):
"""
Resister an event that you want to monitor.
:param event: Name of the event to monitor
:param callback: Callback function for when the event is received (Params: event, interface).
:param selector: `(Optional)` CSS selector... | python | def register(self, event, callback, selector=None):
"""
Resister an event that you want to monitor.
:param event: Name of the event to monitor
:param callback: Callback function for when the event is received (Params: event, interface).
:param selector: `(Optional)` CSS selector... | [
"def",
"register",
"(",
"self",
",",
"event",
",",
"callback",
",",
"selector",
"=",
"None",
")",
":",
"self",
".",
"processor",
".",
"register",
"(",
"event",
",",
"callback",
",",
"selector",
")"
] | Resister an event that you want to monitor.
:param event: Name of the event to monitor
:param callback: Callback function for when the event is received (Params: event, interface).
:param selector: `(Optional)` CSS selector for the element(s) you want to monitor. | [
"Resister",
"an",
"event",
"that",
"you",
"want",
"to",
"monitor",
"."
] | f3477cd546e885bc53e755b3eb1452ce43ef5697 | https://github.com/dalloriam/engel/blob/f3477cd546e885bc53e755b3eb1452ce43ef5697/engel/application.py#L72-L80 | train |
dalloriam/engel | engel/application.py | Application.unregister | def unregister(self, event, callback, selector=None):
"""
Unregisters an event that was being monitored.
:param event: Name of the event to monitor
:param callback: Callback function for when the event is received (Params: event, interface).
:param selector: `(Optional)` CSS sel... | python | def unregister(self, event, callback, selector=None):
"""
Unregisters an event that was being monitored.
:param event: Name of the event to monitor
:param callback: Callback function for when the event is received (Params: event, interface).
:param selector: `(Optional)` CSS sel... | [
"def",
"unregister",
"(",
"self",
",",
"event",
",",
"callback",
",",
"selector",
"=",
"None",
")",
":",
"self",
".",
"processor",
".",
"unregister",
"(",
"event",
",",
"callback",
",",
"selector",
")"
] | Unregisters an event that was being monitored.
:param event: Name of the event to monitor
:param callback: Callback function for when the event is received (Params: event, interface).
:param selector: `(Optional)` CSS selector for the element(s) you want to monitor | [
"Unregisters",
"an",
"event",
"that",
"was",
"being",
"monitored",
"."
] | f3477cd546e885bc53e755b3eb1452ce43ef5697 | https://github.com/dalloriam/engel/blob/f3477cd546e885bc53e755b3eb1452ce43ef5697/engel/application.py#L82-L90 | train |
RedHatQE/Sentaku | examples/todo_example/spec.py | TodoAPI.from_api | def from_api(cls, api):
"""
create an application description for the todo app,
that based on the api can use either tha api or the ux for interaction
"""
ux = TodoUX(api)
from .pseudorpc import PseudoRpc
rpc = PseudoRpc(api)
return cls({ViaAPI: api, Via... | python | def from_api(cls, api):
"""
create an application description for the todo app,
that based on the api can use either tha api or the ux for interaction
"""
ux = TodoUX(api)
from .pseudorpc import PseudoRpc
rpc = PseudoRpc(api)
return cls({ViaAPI: api, Via... | [
"def",
"from_api",
"(",
"cls",
",",
"api",
")",
":",
"ux",
"=",
"TodoUX",
"(",
"api",
")",
"from",
".",
"pseudorpc",
"import",
"PseudoRpc",
"rpc",
"=",
"PseudoRpc",
"(",
"api",
")",
"return",
"cls",
"(",
"{",
"ViaAPI",
":",
"api",
",",
"ViaUX",
":"... | create an application description for the todo app,
that based on the api can use either tha api or the ux for interaction | [
"create",
"an",
"application",
"description",
"for",
"the",
"todo",
"app",
"that",
"based",
"on",
"the",
"api",
"can",
"use",
"either",
"tha",
"api",
"or",
"the",
"ux",
"for",
"interaction"
] | b336cef5b6ee2db4e8dff28dcdb2be35a1f3d01c | https://github.com/RedHatQE/Sentaku/blob/b336cef5b6ee2db4e8dff28dcdb2be35a1f3d01c/examples/todo_example/spec.py#L14-L24 | train |
yamcs/yamcs-python | yamcs-client/yamcs/mdb/model.py | Significance.consequence_level | def consequence_level(self):
"""
One of ``NONE``, ``WATCH``, ``WARNING``, ``DISTRESS``, ``CRITICAL``
or ``SEVERE``.
"""
if self._proto.HasField('consequenceLevel'):
return mdb_pb2.SignificanceInfo.SignificanceLevelType.Name(self._proto.consequenceLevel)
return... | python | def consequence_level(self):
"""
One of ``NONE``, ``WATCH``, ``WARNING``, ``DISTRESS``, ``CRITICAL``
or ``SEVERE``.
"""
if self._proto.HasField('consequenceLevel'):
return mdb_pb2.SignificanceInfo.SignificanceLevelType.Name(self._proto.consequenceLevel)
return... | [
"def",
"consequence_level",
"(",
"self",
")",
":",
"if",
"self",
".",
"_proto",
".",
"HasField",
"(",
"'consequenceLevel'",
")",
":",
"return",
"mdb_pb2",
".",
"SignificanceInfo",
".",
"SignificanceLevelType",
".",
"Name",
"(",
"self",
".",
"_proto",
".",
"c... | One of ``NONE``, ``WATCH``, ``WARNING``, ``DISTRESS``, ``CRITICAL``
or ``SEVERE``. | [
"One",
"of",
"NONE",
"WATCH",
"WARNING",
"DISTRESS",
"CRITICAL",
"or",
"SEVERE",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/mdb/model.py#L106-L113 | train |
sirfoga/pyhal | hal/mongodb/models.py | DbBrowser.get_documents_count | def get_documents_count(self):
"""Counts documents in database
:return: Number of documents in db
"""
db_collections = [
self.database[c] for c in self.get_collection_names()
] # list of all collections in database
return sum([c.count() for c in db_collectio... | python | def get_documents_count(self):
"""Counts documents in database
:return: Number of documents in db
"""
db_collections = [
self.database[c] for c in self.get_collection_names()
] # list of all collections in database
return sum([c.count() for c in db_collectio... | [
"def",
"get_documents_count",
"(",
"self",
")",
":",
"db_collections",
"=",
"[",
"self",
".",
"database",
"[",
"c",
"]",
"for",
"c",
"in",
"self",
".",
"get_collection_names",
"(",
")",
"]",
"return",
"sum",
"(",
"[",
"c",
".",
"count",
"(",
")",
"fo... | Counts documents in database
:return: Number of documents in db | [
"Counts",
"documents",
"in",
"database"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/mongodb/models.py#L25-L33 | train |
sirfoga/pyhal | hal/mongodb/models.py | DbBrowser.get_documents_in_collection | def get_documents_in_collection(self, collection_name, with_id=True):
"""Gets all documents in collection
:param collection_name: Name of collection
:param with_id: True iff each document should also come with its id
:return: List of documents in collection in self.db
"""
... | python | def get_documents_in_collection(self, collection_name, with_id=True):
"""Gets all documents in collection
:param collection_name: Name of collection
:param with_id: True iff each document should also come with its id
:return: List of documents in collection in self.db
"""
... | [
"def",
"get_documents_in_collection",
"(",
"self",
",",
"collection_name",
",",
"with_id",
"=",
"True",
")",
":",
"documents_iterator",
"=",
"self",
".",
"database",
"[",
"collection_name",
"]",
".",
"find",
"(",
")",
"documents",
"=",
"[",
"d",
"for",
"d",
... | Gets all documents in collection
:param collection_name: Name of collection
:param with_id: True iff each document should also come with its id
:return: List of documents in collection in self.db | [
"Gets",
"all",
"documents",
"in",
"collection"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/mongodb/models.py#L35-L51 | train |
sirfoga/pyhal | hal/mongodb/models.py | DbBrowser.get_documents_in_database | def get_documents_in_database(self, with_id=True):
"""Gets all documents in database
:param with_id: True iff each document should also come with its id
:return: List of documents in collection in database
"""
documents = []
for coll in self.get_collection_names():
... | python | def get_documents_in_database(self, with_id=True):
"""Gets all documents in database
:param with_id: True iff each document should also come with its id
:return: List of documents in collection in database
"""
documents = []
for coll in self.get_collection_names():
... | [
"def",
"get_documents_in_database",
"(",
"self",
",",
"with_id",
"=",
"True",
")",
":",
"documents",
"=",
"[",
"]",
"for",
"coll",
"in",
"self",
".",
"get_collection_names",
"(",
")",
":",
"documents",
"+=",
"self",
".",
"get_documents_in_collection",
"(",
"... | Gets all documents in database
:param with_id: True iff each document should also come with its id
:return: List of documents in collection in database | [
"Gets",
"all",
"documents",
"in",
"database"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/mongodb/models.py#L61-L74 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.