partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Table.upsert
Update a document, if it exist - insert it otherwise. Note: this will update *all* documents matching the query. :param document: the document to insert or the fields to update :param cond: which document to look for :returns: a list containing the updated document's ID
tinydb/database.py
def upsert(self, document, cond): """ Update a document, if it exist - insert it otherwise. Note: this will update *all* documents matching the query. :param document: the document to insert or the fields to update :param cond: which document to look for :returns: a lis...
def upsert(self, document, cond): """ Update a document, if it exist - insert it otherwise. Note: this will update *all* documents matching the query. :param document: the document to insert or the fields to update :param cond: which document to look for :returns: a lis...
[ "Update", "a", "document", "if", "it", "exist", "-", "insert", "it", "otherwise", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/database.py#L566-L581
[ "def", "upsert", "(", "self", ",", "document", ",", "cond", ")", ":", "updated_docs", "=", "self", ".", "update", "(", "document", ",", "cond", ")", "if", "updated_docs", ":", "return", "updated_docs", "else", ":", "return", "[", "self", ".", "insert", ...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
Table.search
Search for all documents matching a 'where' cond. :param cond: the condition to check against :type cond: Query :returns: list of matching documents :rtype: list[Element]
tinydb/database.py
def search(self, cond): """ Search for all documents matching a 'where' cond. :param cond: the condition to check against :type cond: Query :returns: list of matching documents :rtype: list[Element] """ if cond in self._query_cache: return s...
def search(self, cond): """ Search for all documents matching a 'where' cond. :param cond: the condition to check against :type cond: Query :returns: list of matching documents :rtype: list[Element] """ if cond in self._query_cache: return s...
[ "Search", "for", "all", "documents", "matching", "a", "where", "cond", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/database.py#L591-L608
[ "def", "search", "(", "self", ",", "cond", ")", ":", "if", "cond", "in", "self", ".", "_query_cache", ":", "return", "self", ".", "_query_cache", ".", "get", "(", "cond", ",", "[", "]", ")", "[", ":", "]", "docs", "=", "[", "doc", "for", "doc", ...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
Table.get
Get exactly one document specified by a query or and ID. Returns ``None`` if the document doesn't exist :param cond: the condition to check against :type cond: Query :param doc_id: the document's ID :returns: the document or None :rtype: Element | None
tinydb/database.py
def get(self, cond=None, doc_id=None, eid=None): """ Get exactly one document specified by a query or and ID. Returns ``None`` if the document doesn't exist :param cond: the condition to check against :type cond: Query :param doc_id: the document's ID :returns...
def get(self, cond=None, doc_id=None, eid=None): """ Get exactly one document specified by a query or and ID. Returns ``None`` if the document doesn't exist :param cond: the condition to check against :type cond: Query :param doc_id: the document's ID :returns...
[ "Get", "exactly", "one", "document", "specified", "by", "a", "query", "or", "and", "ID", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/database.py#L610-L636
[ "def", "get", "(", "self", ",", "cond", "=", "None", ",", "doc_id", "=", "None", ",", "eid", "=", "None", ")", ":", "doc_id", "=", "_get_doc_id", "(", "doc_id", ",", "eid", ")", "# Cannot use process_elements here because we want to return a", "# specific docume...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
Table.contains
Check wether the database contains a document matching a condition or an ID. If ``eids`` is set, it checks if the db contains a document with one of the specified. :param cond: the condition use :type cond: Query :param doc_ids: the document IDs to look for
tinydb/database.py
def contains(self, cond=None, doc_ids=None, eids=None): """ Check wether the database contains a document matching a condition or an ID. If ``eids`` is set, it checks if the db contains a document with one of the specified. :param cond: the condition use :type c...
def contains(self, cond=None, doc_ids=None, eids=None): """ Check wether the database contains a document matching a condition or an ID. If ``eids`` is set, it checks if the db contains a document with one of the specified. :param cond: the condition use :type c...
[ "Check", "wether", "the", "database", "contains", "a", "document", "matching", "a", "condition", "or", "an", "ID", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/database.py#L648-L667
[ "def", "contains", "(", "self", ",", "cond", "=", "None", ",", "doc_ids", "=", "None", ",", "eids", "=", "None", ")", ":", "doc_ids", "=", "_get_doc_ids", "(", "doc_ids", ",", "eids", ")", "if", "doc_ids", "is", "not", "None", ":", "# Documents specifi...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
CachingMiddleware.flush
Flush all unwritten data to disk.
tinydb/middlewares.py
def flush(self): """ Flush all unwritten data to disk. """ if self._cache_modified_count > 0: self.storage.write(self.cache) self._cache_modified_count = 0
def flush(self): """ Flush all unwritten data to disk. """ if self._cache_modified_count > 0: self.storage.write(self.cache) self._cache_modified_count = 0
[ "Flush", "all", "unwritten", "data", "to", "disk", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/middlewares.py#L106-L112
[ "def", "flush", "(", "self", ")", ":", "if", "self", ".", "_cache_modified_count", ">", "0", ":", "self", ".", "storage", ".", "write", "(", "self", ".", "cache", ")", "self", ".", "_cache_modified_count", "=", "0" ]
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
Query.matches
Run a regex test against a dict value (whole string has to match). >>> Query().f1.matches(r'^\w+$') :param regex: The regular expression to use for matching
tinydb/queries.py
def matches(self, regex, flags=0): """ Run a regex test against a dict value (whole string has to match). >>> Query().f1.matches(r'^\w+$') :param regex: The regular expression to use for matching """ return self._generate_test( lambda value: re.match(regex, ...
def matches(self, regex, flags=0): """ Run a regex test against a dict value (whole string has to match). >>> Query().f1.matches(r'^\w+$') :param regex: The regular expression to use for matching """ return self._generate_test( lambda value: re.match(regex, ...
[ "Run", "a", "regex", "test", "against", "a", "dict", "value", "(", "whole", "string", "has", "to", "match", ")", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/queries.py#L264-L275
[ "def", "matches", "(", "self", ",", "regex", ",", "flags", "=", "0", ")", ":", "return", "self", ".", "_generate_test", "(", "lambda", "value", ":", "re", ".", "match", "(", "regex", ",", "value", ",", "flags", ")", ",", "(", "'matches'", ",", "sel...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
Query.search
Run a regex test against a dict value (only substring string has to match). >>> Query().f1.search(r'^\w+$') :param regex: The regular expression to use for matching
tinydb/queries.py
def search(self, regex, flags=0): """ Run a regex test against a dict value (only substring string has to match). >>> Query().f1.search(r'^\w+$') :param regex: The regular expression to use for matching """ return self._generate_test( lambda value: r...
def search(self, regex, flags=0): """ Run a regex test against a dict value (only substring string has to match). >>> Query().f1.search(r'^\w+$') :param regex: The regular expression to use for matching """ return self._generate_test( lambda value: r...
[ "Run", "a", "regex", "test", "against", "a", "dict", "value", "(", "only", "substring", "string", "has", "to", "match", ")", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/queries.py#L277-L289
[ "def", "search", "(", "self", ",", "regex", ",", "flags", "=", "0", ")", ":", "return", "self", ".", "_generate_test", "(", "lambda", "value", ":", "re", ".", "search", "(", "regex", ",", "value", ",", "flags", ")", ",", "(", "'search'", ",", "self...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
Query.any
Check if a condition is met by any document in a list, where a condition can also be a sequence (e.g. list). >>> Query().f1.any(Query().f2 == 1) Matches:: {'f1': [{'f2': 1}, {'f2': 0}]} >>> Query().f1.any([1, 2, 3]) Matches:: {'f1': [1, 2]} ...
tinydb/queries.py
def any(self, cond): """ Check if a condition is met by any document in a list, where a condition can also be a sequence (e.g. list). >>> Query().f1.any(Query().f2 == 1) Matches:: {'f1': [{'f2': 1}, {'f2': 0}]} >>> Query().f1.any([1, 2, 3]) Matche...
def any(self, cond): """ Check if a condition is met by any document in a list, where a condition can also be a sequence (e.g. list). >>> Query().f1.any(Query().f2 == 1) Matches:: {'f1': [{'f2': 1}, {'f2': 0}]} >>> Query().f1.any([1, 2, 3]) Matche...
[ "Check", "if", "a", "condition", "is", "met", "by", "any", "document", "in", "a", "list", "where", "a", "condition", "can", "also", "be", "a", "sequence", "(", "e", ".", "g", ".", "list", ")", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/queries.py#L309-L342
[ "def", "any", "(", "self", ",", "cond", ")", ":", "if", "callable", "(", "cond", ")", ":", "def", "_cmp", "(", "value", ")", ":", "return", "is_sequence", "(", "value", ")", "and", "any", "(", "cond", "(", "e", ")", "for", "e", "in", "value", "...
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
Query.one_of
Check if the value is contained in a list or generator. >>> Query().f1.one_of(['value 1', 'value 2']) :param items: The list of items to check with
tinydb/queries.py
def one_of(self, items): """ Check if the value is contained in a list or generator. >>> Query().f1.one_of(['value 1', 'value 2']) :param items: The list of items to check with """ return self._generate_test( lambda value: value in items, ('one_o...
def one_of(self, items): """ Check if the value is contained in a list or generator. >>> Query().f1.one_of(['value 1', 'value 2']) :param items: The list of items to check with """ return self._generate_test( lambda value: value in items, ('one_o...
[ "Check", "if", "the", "value", "is", "contained", "in", "a", "list", "or", "generator", "." ]
msiemens/tinydb
python
https://github.com/msiemens/tinydb/blob/10052cb1ae6a3682d26eb4272c44e3b020aa5877/tinydb/queries.py#L377-L388
[ "def", "one_of", "(", "self", ",", "items", ")", ":", "return", "self", ".", "_generate_test", "(", "lambda", "value", ":", "value", "in", "items", ",", "(", "'one_of'", ",", "self", ".", "_path", ",", "freeze", "(", "items", ")", ")", ")" ]
10052cb1ae6a3682d26eb4272c44e3b020aa5877
train
setobjattr
Sets an object attribute with the correct data type.
mlbgame/object.py
def setobjattr(obj, key, value): """Sets an object attribute with the correct data type.""" try: setattr(obj, key, int(value)) except ValueError: try: setattr(obj, key, float(value)) except ValueError: # string if not number try: se...
def setobjattr(obj, key, value): """Sets an object attribute with the correct data type.""" try: setattr(obj, key, int(value)) except ValueError: try: setattr(obj, key, float(value)) except ValueError: # string if not number try: se...
[ "Sets", "an", "object", "attribute", "with", "the", "correct", "data", "type", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/object.py#L6-L18
[ "def", "setobjattr", "(", "obj", ",", "key", ",", "value", ")", ":", "try", ":", "setattr", "(", "obj", ",", "key", ",", "int", "(", "value", ")", ")", "except", "ValueError", ":", "try", ":", "setattr", "(", "obj", ",", "key", ",", "float", "(",...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
get_scoreboard
Return the game file for a certain day matching certain criteria.
mlbgame/data.py
def get_scoreboard(year, month, day): """Return the game file for a certain day matching certain criteria.""" try: data = urlopen(BASE_URL.format(year, month, day) + 'scoreboard.xml') except HTTPError: data = os.path.join(PWD, 'default.xml') return data
def get_scoreboard(year, month, day): """Return the game file for a certain day matching certain criteria.""" try: data = urlopen(BASE_URL.format(year, month, day) + 'scoreboard.xml') except HTTPError: data = os.path.join(PWD, 'default.xml') return data
[ "Return", "the", "game", "file", "for", "a", "certain", "day", "matching", "certain", "criteria", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/data.py#L56-L62
[ "def", "get_scoreboard", "(", "year", ",", "month", ",", "day", ")", ":", "try", ":", "data", "=", "urlopen", "(", "BASE_URL", ".", "format", "(", "year", ",", "month", ",", "day", ")", "+", "'scoreboard.xml'", ")", "except", "HTTPError", ":", "data", ...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
get_box_score
Return the box score file of a game with matching id.
mlbgame/data.py
def get_box_score(game_id): """Return the box score file of a game with matching id.""" year, month, day = get_date_from_game_id(game_id) try: return urlopen(GAME_URL.format(year, month, day, game_id, 'boxscore.xml')) except HTTPError: raise ValueEr...
def get_box_score(game_id): """Return the box score file of a game with matching id.""" year, month, day = get_date_from_game_id(game_id) try: return urlopen(GAME_URL.format(year, month, day, game_id, 'boxscore.xml')) except HTTPError: raise ValueEr...
[ "Return", "the", "box", "score", "file", "of", "a", "game", "with", "matching", "id", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/data.py#L65-L72
[ "def", "get_box_score", "(", "game_id", ")", ":", "year", ",", "month", ",", "day", "=", "get_date_from_game_id", "(", "game_id", ")", "try", ":", "return", "urlopen", "(", "GAME_URL", ".", "format", "(", "year", ",", "month", ",", "day", ",", "game_id",...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
get_innings
Return the innings file of a game with matching id.
mlbgame/data.py
def get_innings(game_id): """Return the innings file of a game with matching id.""" year, month, day = get_date_from_game_id(game_id) try: return urlopen(INNINGS_URL.format(year, month, day, game_id)) except HTTPError: raise ValueError('Could not find a game with that id.')
def get_innings(game_id): """Return the innings file of a game with matching id.""" year, month, day = get_date_from_game_id(game_id) try: return urlopen(INNINGS_URL.format(year, month, day, game_id)) except HTTPError: raise ValueError('Could not find a game with that id.')
[ "Return", "the", "innings", "file", "of", "a", "game", "with", "matching", "id", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/data.py#L95-L101
[ "def", "get_innings", "(", "game_id", ")", ":", "year", ",", "month", ",", "day", "=", "get_date_from_game_id", "(", "game_id", ")", "try", ":", "return", "urlopen", "(", "INNINGS_URL", ".", "format", "(", "year", ",", "month", ",", "day", ",", "game_id"...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
get_standings
Return the standings file for current standings (given current date).
mlbgame/data.py
def get_standings(date): """Return the standings file for current standings (given current date).""" try: return urlopen(STANDINGS_URL.format(date.year, date.strftime('%Y/%m/%d'))) except HTTPError: ValueError('Could not find the standings file. ' ...
def get_standings(date): """Return the standings file for current standings (given current date).""" try: return urlopen(STANDINGS_URL.format(date.year, date.strftime('%Y/%m/%d'))) except HTTPError: ValueError('Could not find the standings file. ' ...
[ "Return", "the", "standings", "file", "for", "current", "standings", "(", "given", "current", "date", ")", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/data.py#L143-L151
[ "def", "get_standings", "(", "date", ")", ":", "try", ":", "return", "urlopen", "(", "STANDINGS_URL", ".", "format", "(", "date", ".", "year", ",", "date", ".", "strftime", "(", "'%Y/%m/%d'", ")", ")", ")", "except", "HTTPError", ":", "ValueError", "(", ...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
get_historical_standings
Return the historical standings file for specified date.
mlbgame/data.py
def get_historical_standings(date): """Return the historical standings file for specified date.""" try: url = STANDINGS_HISTORICAL_URL.format(date.year, date.strftime('%Y/%m/%d')) return urlopen(url) except HTTPError: ValueError('Could no...
def get_historical_standings(date): """Return the historical standings file for specified date.""" try: url = STANDINGS_HISTORICAL_URL.format(date.year, date.strftime('%Y/%m/%d')) return urlopen(url) except HTTPError: ValueError('Could no...
[ "Return", "the", "historical", "standings", "file", "for", "specified", "date", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/data.py#L154-L161
[ "def", "get_historical_standings", "(", "date", ")", ":", "try", ":", "url", "=", "STANDINGS_HISTORICAL_URL", ".", "format", "(", "date", ".", "year", ",", "date", ".", "strftime", "(", "'%Y/%m/%d'", ")", ")", "return", "urlopen", "(", "url", ")", "except"...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
scoreboard
Return the scoreboard information for games matching the parameters as a dictionary.
mlbgame/game.py
def scoreboard(year, month, day, home=None, away=None): """Return the scoreboard information for games matching the parameters as a dictionary. """ # get data data = mlbgame.data.get_scoreboard(year, month, day) # parse data parsed = etree.parse(data) root = parsed.getroot() games = ...
def scoreboard(year, month, day, home=None, away=None): """Return the scoreboard information for games matching the parameters as a dictionary. """ # get data data = mlbgame.data.get_scoreboard(year, month, day) # parse data parsed = etree.parse(data) root = parsed.getroot() games = ...
[ "Return", "the", "scoreboard", "information", "for", "games", "matching", "the", "parameters", "as", "a", "dictionary", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/game.py#L14-L152
[ "def", "scoreboard", "(", "year", ",", "month", ",", "day", ",", "home", "=", "None", ",", "away", "=", "None", ")", ":", "# get data", "data", "=", "mlbgame", ".", "data", ".", "get_scoreboard", "(", "year", ",", "month", ",", "day", ")", "# parse d...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
box_score
Gets the box score information for the game with matching id.
mlbgame/game.py
def box_score(game_id): """Gets the box score information for the game with matching id.""" # get data data = mlbgame.data.get_box_score(game_id) # parse data parsed = etree.parse(data) root = parsed.getroot() linescore = root.find('linescore') result = dict() result['game_id'] = gam...
def box_score(game_id): """Gets the box score information for the game with matching id.""" # get data data = mlbgame.data.get_box_score(game_id) # parse data parsed = etree.parse(data) root = parsed.getroot() linescore = root.find('linescore') result = dict() result['game_id'] = gam...
[ "Gets", "the", "box", "score", "information", "for", "the", "game", "with", "matching", "id", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/game.py#L227-L243
[ "def", "box_score", "(", "game_id", ")", ":", "# get data", "data", "=", "mlbgame", ".", "data", ".", "get_box_score", "(", "game_id", ")", "# parse data", "parsed", "=", "etree", ".", "parse", "(", "data", ")", "root", "=", "parsed", ".", "getroot", "("...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
value_to_int
Massage runs in an inning to 0 if an empty string, or key not found. Otherwise return the value
mlbgame/game.py
def value_to_int(attrib, key): """ Massage runs in an inning to 0 if an empty string, or key not found. Otherwise return the value """ val = attrib.get(key, 0) if isinstance(val, str): if val.isspace() or val == '': return 0 return val
def value_to_int(attrib, key): """ Massage runs in an inning to 0 if an empty string, or key not found. Otherwise return the value """ val = attrib.get(key, 0) if isinstance(val, str): if val.isspace() or val == '': return 0 return val
[ "Massage", "runs", "in", "an", "inning", "to", "0", "if", "an", "empty", "string", "or", "key", "not", "found", ".", "Otherwise", "return", "the", "value" ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/game.py#L246-L253
[ "def", "value_to_int", "(", "attrib", ",", "key", ")", ":", "val", "=", "attrib", ".", "get", "(", "key", ",", "0", ")", "if", "isinstance", "(", "val", ",", "str", ")", ":", "if", "val", ".", "isspace", "(", ")", "or", "val", "==", "''", ":", ...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
overview
Gets the overview information for the game with matching id.
mlbgame/game.py
def overview(game_id): """Gets the overview information for the game with matching id.""" output = {} # get data overview = mlbgame.data.get_overview(game_id) # parse data overview_root = etree.parse(overview).getroot() try: output = add_raw_box_score_attributes(output, game_id) ...
def overview(game_id): """Gets the overview information for the game with matching id.""" output = {} # get data overview = mlbgame.data.get_overview(game_id) # parse data overview_root = etree.parse(overview).getroot() try: output = add_raw_box_score_attributes(output, game_id) ...
[ "Gets", "the", "overview", "information", "for", "the", "game", "with", "matching", "id", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/game.py#L332-L364
[ "def", "overview", "(", "game_id", ")", ":", "output", "=", "{", "}", "# get data", "overview", "=", "mlbgame", ".", "data", ".", "get_overview", "(", "game_id", ")", "# parse data", "overview_root", "=", "etree", ".", "parse", "(", "overview", ")", ".", ...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
players
Gets player/coach/umpire information for the game with matching id.
mlbgame/game.py
def players(game_id): """Gets player/coach/umpire information for the game with matching id.""" # get data data = mlbgame.data.get_players(game_id) # parse data parsed = etree.parse(data) root = parsed.getroot() output = {} output['game_id'] = game_id # get player/coach data fo...
def players(game_id): """Gets player/coach/umpire information for the game with matching id.""" # get data data = mlbgame.data.get_players(game_id) # parse data parsed = etree.parse(data) root = parsed.getroot() output = {} output['game_id'] = game_id # get player/coach data fo...
[ "Gets", "player", "/", "coach", "/", "umpire", "information", "for", "the", "game", "with", "matching", "id", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/game.py#L548-L587
[ "def", "players", "(", "game_id", ")", ":", "# get data", "data", "=", "mlbgame", ".", "data", ".", "get_players", "(", "game_id", ")", "# parse data", "parsed", "=", "etree", ".", "parse", "(", "data", ")", "root", "=", "parsed", ".", "getroot", "(", ...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
GameBoxScore.print_scoreboard
Print object as a scoreboard.
mlbgame/game.py
def print_scoreboard(self): """Print object as a scoreboard.""" output = '' # parallel dictionaries with innings and scores innings = [] away = [] home = [] for x in self: innings.append(x['inning']) away.append(x['away']) home....
def print_scoreboard(self): """Print object as a scoreboard.""" output = '' # parallel dictionaries with innings and scores innings = [] away = [] home = [] for x in self: innings.append(x['inning']) away.append(x['away']) home....
[ "Print", "object", "as", "a", "scoreboard", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/game.py#L308-L329
[ "def", "print_scoreboard", "(", "self", ")", ":", "output", "=", "''", "# parallel dictionaries with innings and scores", "innings", "=", "[", "]", "away", "=", "[", "]", "home", "=", "[", "]", "for", "x", "in", "self", ":", "innings", ".", "append", "(", ...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
day
Return a list of games for a certain day. If the home and away team are the same, it will return the game(s) for that team.
mlbgame/__init__.py
def day(year, month, day, home=None, away=None): """Return a list of games for a certain day. If the home and away team are the same, it will return the game(s) for that team. """ # get the days per month daysinmonth = calendar.monthrange(year, month)[1] # do not even try to get data if day...
def day(year, month, day, home=None, away=None): """Return a list of games for a certain day. If the home and away team are the same, it will return the game(s) for that team. """ # get the days per month daysinmonth = calendar.monthrange(year, month)[1] # do not even try to get data if day...
[ "Return", "a", "list", "of", "games", "for", "a", "certain", "day", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/__init__.py#L139-L152
[ "def", "day", "(", "year", ",", "month", ",", "day", ",", "home", "=", "None", ",", "away", "=", "None", ")", ":", "# get the days per month", "daysinmonth", "=", "calendar", ".", "monthrange", "(", "year", ",", "month", ")", "[", "1", "]", "# do not e...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
games
Return a list of lists of games for multiple days. If home and away are the same team, it will return all games for that team.
mlbgame/__init__.py
def games(years, months=None, days=None, home=None, away=None): """Return a list of lists of games for multiple days. If home and away are the same team, it will return all games for that team. """ # put in data if months and days are not specified if months is None: months = list(range(1, ...
def games(years, months=None, days=None, home=None, away=None): """Return a list of lists of games for multiple days. If home and away are the same team, it will return all games for that team. """ # put in data if months and days are not specified if months is None: months = list(range(1, ...
[ "Return", "a", "list", "of", "lists", "of", "games", "for", "multiple", "days", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/__init__.py#L155-L184
[ "def", "games", "(", "years", ",", "months", "=", "None", ",", "days", "=", "None", ",", "home", "=", "None", ",", "away", "=", "None", ")", ":", "# put in data if months and days are not specified", "if", "months", "is", "None", ":", "months", "=", "list"...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
box_score
Return box score for game matching the game id.
mlbgame/__init__.py
def box_score(game_id): """Return box score for game matching the game id.""" # get box score data data = mlbgame.game.box_score(game_id) # create object with data obj = mlbgame.game.GameBoxScore(data) return obj
def box_score(game_id): """Return box score for game matching the game id.""" # get box score data data = mlbgame.game.box_score(game_id) # create object with data obj = mlbgame.game.GameBoxScore(data) return obj
[ "Return", "box", "score", "for", "game", "matching", "the", "game", "id", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/__init__.py#L187-L193
[ "def", "box_score", "(", "game_id", ")", ":", "# get box score data", "data", "=", "mlbgame", ".", "game", ".", "box_score", "(", "game_id", ")", "# create object with data", "obj", "=", "mlbgame", ".", "game", ".", "GameBoxScore", "(", "data", ")", "return", ...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
player_stats
Return dictionary of player stats for game matching the game id.
mlbgame/__init__.py
def player_stats(game_id): """Return dictionary of player stats for game matching the game id.""" # get information for that game data = mlbgame.stats.player_stats(game_id) return mlbgame.stats.Stats(data, game_id, True)
def player_stats(game_id): """Return dictionary of player stats for game matching the game id.""" # get information for that game data = mlbgame.stats.player_stats(game_id) return mlbgame.stats.Stats(data, game_id, True)
[ "Return", "dictionary", "of", "player", "stats", "for", "game", "matching", "the", "game", "id", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/__init__.py#L211-L215
[ "def", "player_stats", "(", "game_id", ")", ":", "# get information for that game", "data", "=", "mlbgame", ".", "stats", ".", "player_stats", "(", "game_id", ")", "return", "mlbgame", ".", "stats", ".", "Stats", "(", "data", ",", "game_id", ",", "True", ")"...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
team_stats
Return dictionary of team stats for game matching the game id.
mlbgame/__init__.py
def team_stats(game_id): """Return dictionary of team stats for game matching the game id.""" # get data data = mlbgame.stats.team_stats(game_id) return mlbgame.stats.Stats(data, game_id, False)
def team_stats(game_id): """Return dictionary of team stats for game matching the game id.""" # get data data = mlbgame.stats.team_stats(game_id) return mlbgame.stats.Stats(data, game_id, False)
[ "Return", "dictionary", "of", "team", "stats", "for", "game", "matching", "the", "game", "id", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/__init__.py#L218-L222
[ "def", "team_stats", "(", "game_id", ")", ":", "# get data", "data", "=", "mlbgame", ".", "stats", ".", "team_stats", "(", "game_id", ")", "return", "mlbgame", ".", "stats", ".", "Stats", "(", "data", ",", "game_id", ",", "False", ")" ]
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
game_events
Return list of Inning objects for game matching the game id. Using `inning_endpoints=True` will result in objects with additional, undocumented data properties, but also objects that may be missing properties expected by the user. `innings_endpoint`: bool, use more detailed `innings` API endpoint
mlbgame/__init__.py
def game_events(game_id, innings_endpoint=False): """Return list of Inning objects for game matching the game id. Using `inning_endpoints=True` will result in objects with additional, undocumented data properties, but also objects that may be missing properties expected by the user. `innings_endpo...
def game_events(game_id, innings_endpoint=False): """Return list of Inning objects for game matching the game id. Using `inning_endpoints=True` will result in objects with additional, undocumented data properties, but also objects that may be missing properties expected by the user. `innings_endpo...
[ "Return", "list", "of", "Inning", "objects", "for", "game", "matching", "the", "game", "id", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/__init__.py#L225-L235
[ "def", "game_events", "(", "game_id", ",", "innings_endpoint", "=", "False", ")", ":", "data", "=", "mlbgame", ".", "events", ".", "game_events", "(", "game_id", ",", "innings_endpoint", ")", "return", "[", "mlbgame", ".", "events", ".", "Inning", "(", "da...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
important_dates
Return ImportantDates object that contains MLB important dates
mlbgame/__init__.py
def important_dates(year=None): """Return ImportantDates object that contains MLB important dates""" year = datetime.now().year if not year else year data = mlbgame.info.important_dates(year) return mlbgame.info.ImportantDates(data)
def important_dates(year=None): """Return ImportantDates object that contains MLB important dates""" year = datetime.now().year if not year else year data = mlbgame.info.important_dates(year) return mlbgame.info.ImportantDates(data)
[ "Return", "ImportantDates", "object", "that", "contains", "MLB", "important", "dates" ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/__init__.py#L238-L242
[ "def", "important_dates", "(", "year", "=", "None", ")", ":", "year", "=", "datetime", ".", "now", "(", ")", ".", "year", "if", "not", "year", "else", "year", "data", "=", "mlbgame", ".", "info", ".", "important_dates", "(", "year", ")", "return", "m...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
roster
Return Roster object that contains roster info for a team
mlbgame/__init__.py
def roster(team_id): """Return Roster object that contains roster info for a team""" data = mlbgame.info.roster(team_id) return mlbgame.info.Roster(data)
def roster(team_id): """Return Roster object that contains roster info for a team""" data = mlbgame.info.roster(team_id) return mlbgame.info.Roster(data)
[ "Return", "Roster", "object", "that", "contains", "roster", "info", "for", "a", "team" ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/__init__.py#L255-L258
[ "def", "roster", "(", "team_id", ")", ":", "data", "=", "mlbgame", ".", "info", ".", "roster", "(", "team_id", ")", "return", "mlbgame", ".", "info", ".", "Roster", "(", "data", ")" ]
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
standings
Return Standings object that contains standings info date should be a datetime object, leave empty to get current standings
mlbgame/__init__.py
def standings(date=datetime.now()): """Return Standings object that contains standings info date should be a datetime object, leave empty to get current standings """ data = mlbgame.info.standings(date) return mlbgame.info.Standings(data)
def standings(date=datetime.now()): """Return Standings object that contains standings info date should be a datetime object, leave empty to get current standings """ data = mlbgame.info.standings(date) return mlbgame.info.Standings(data)
[ "Return", "Standings", "object", "that", "contains", "standings", "info" ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/__init__.py#L261-L268
[ "def", "standings", "(", "date", "=", "datetime", ".", "now", "(", ")", ")", ":", "data", "=", "mlbgame", ".", "info", ".", "standings", "(", "date", ")", "return", "mlbgame", ".", "info", ".", "Standings", "(", "data", ")" ]
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
broadcast_info
Return BroadcastInfo object that containts information about the television and radio broadcasts for the team_id and year
mlbgame/__init__.py
def broadcast_info(team_id, date=datetime.now()): """Return BroadcastInfo object that containts information about the television and radio broadcasts for the team_id and year""" data = mlbgame.info.broadcast_info(team_id, date) return [mlbgame.info.BroadcastInfo(x) for x in data]
def broadcast_info(team_id, date=datetime.now()): """Return BroadcastInfo object that containts information about the television and radio broadcasts for the team_id and year""" data = mlbgame.info.broadcast_info(team_id, date) return [mlbgame.info.BroadcastInfo(x) for x in data]
[ "Return", "BroadcastInfo", "object", "that", "containts", "information", "about", "the", "television", "and", "radio", "broadcasts", "for", "the", "team_id", "and", "year" ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/__init__.py#L277-L282
[ "def", "broadcast_info", "(", "team_id", ",", "date", "=", "datetime", ".", "now", "(", ")", ")", ":", "data", "=", "mlbgame", ".", "info", ".", "broadcast_info", "(", "team_id", ",", "date", ")", "return", "[", "mlbgame", ".", "info", ".", "BroadcastI...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
player_stats
Return dictionary of individual stats of a game with matching id. The additional pitching/batting is mostly the same stats, except it contains some useful stats such as groundouts/flyouts per pitcher (go/ao). MLB decided to have two box score files, thus we return the data from both.
mlbgame/stats.py
def player_stats(game_id): """Return dictionary of individual stats of a game with matching id. The additional pitching/batting is mostly the same stats, except it contains some useful stats such as groundouts/flyouts per pitcher (go/ao). MLB decided to have two box score files, thus we return...
def player_stats(game_id): """Return dictionary of individual stats of a game with matching id. The additional pitching/batting is mostly the same stats, except it contains some useful stats such as groundouts/flyouts per pitcher (go/ao). MLB decided to have two box score files, thus we return...
[ "Return", "dictionary", "of", "individual", "stats", "of", "a", "game", "with", "matching", "id", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/stats.py#L62-L106
[ "def", "player_stats", "(", "game_id", ")", ":", "# get data from data module", "box_score", "=", "mlbgame", ".", "data", ".", "get_box_score", "(", "game_id", ")", "box_score_tree", "=", "etree", ".", "parse", "(", "box_score", ")", ".", "getroot", "(", ")", ...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
team_stats
Return team stats of a game with matching id. The additional pitching/batting is mostly the same stats. MLB decided to have two box score files, thus we return the data from both.
mlbgame/stats.py
def team_stats(game_id): """Return team stats of a game with matching id. The additional pitching/batting is mostly the same stats. MLB decided to have two box score files, thus we return the data from both. """ # get data from data module box_score = mlbgame.data.get_box_score(game_id) raw...
def team_stats(game_id): """Return team stats of a game with matching id. The additional pitching/batting is mostly the same stats. MLB decided to have two box score files, thus we return the data from both. """ # get data from data module box_score = mlbgame.data.get_box_score(game_id) raw...
[ "Return", "team", "stats", "of", "a", "game", "with", "matching", "id", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/stats.py#L147-L167
[ "def", "team_stats", "(", "game_id", ")", ":", "# get data from data module", "box_score", "=", "mlbgame", ".", "data", ".", "get_box_score", "(", "game_id", ")", "raw_box_score", "=", "mlbgame", ".", "data", ".", "get_raw_box_score", "(", "game_id", ")", "# par...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
__get_league_object
Returns the xml object corresponding to the league Only designed for internal use
mlbgame/info.py
def __get_league_object(): """Returns the xml object corresponding to the league Only designed for internal use""" # get data data = mlbgame.data.get_properties() # return league object return etree.parse(data).getroot().find('leagues').find('league')
def __get_league_object(): """Returns the xml object corresponding to the league Only designed for internal use""" # get data data = mlbgame.data.get_properties() # return league object return etree.parse(data).getroot().find('leagues').find('league')
[ "Returns", "the", "xml", "object", "corresponding", "to", "the", "league" ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/info.py#L17-L24
[ "def", "__get_league_object", "(", ")", ":", "# get data", "data", "=", "mlbgame", ".", "data", ".", "get_properties", "(", ")", "# return league object", "return", "etree", ".", "parse", "(", "data", ")", ".", "getroot", "(", ")", ".", "find", "(", "'leag...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
league_info
Returns a dictionary of league information
mlbgame/info.py
def league_info(): """Returns a dictionary of league information""" league = __get_league_object() output = {} for x in league.attrib: output[x] = league.attrib[x] return output
def league_info(): """Returns a dictionary of league information""" league = __get_league_object() output = {} for x in league.attrib: output[x] = league.attrib[x] return output
[ "Returns", "a", "dictionary", "of", "league", "information" ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/info.py#L27-L33
[ "def", "league_info", "(", ")", ":", "league", "=", "__get_league_object", "(", ")", "output", "=", "{", "}", "for", "x", "in", "league", ".", "attrib", ":", "output", "[", "x", "]", "=", "league", ".", "attrib", "[", "x", "]", "return", "output" ]
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
team_info
Returns a list of team information dictionaries
mlbgame/info.py
def team_info(): """Returns a list of team information dictionaries""" teams = __get_league_object().find('teams').findall('team') output = [] for team in teams: info = {} for x in team.attrib: info[x] = team.attrib[x] output.append(info) return output
def team_info(): """Returns a list of team information dictionaries""" teams = __get_league_object().find('teams').findall('team') output = [] for team in teams: info = {} for x in team.attrib: info[x] = team.attrib[x] output.append(info) return output
[ "Returns", "a", "list", "of", "team", "information", "dictionaries" ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/info.py#L36-L45
[ "def", "team_info", "(", ")", ":", "teams", "=", "__get_league_object", "(", ")", ".", "find", "(", "'teams'", ")", ".", "findall", "(", "'team'", ")", "output", "=", "[", "]", "for", "team", "in", "teams", ":", "info", "=", "{", "}", "for", "x", ...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
important_dates
Returns a dictionary of important dates
mlbgame/info.py
def important_dates(year): """Returns a dictionary of important dates""" output = {} data = mlbgame.data.get_important_dates(year) important_dates = etree.parse(data).getroot().\ find('queryResults').find('row') try: for x in important_dates.attrib: output[x] = important_...
def important_dates(year): """Returns a dictionary of important dates""" output = {} data = mlbgame.data.get_important_dates(year) important_dates = etree.parse(data).getroot().\ find('queryResults').find('row') try: for x in important_dates.attrib: output[x] = important_...
[ "Returns", "a", "dictionary", "of", "important", "dates" ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/info.py#L48-L59
[ "def", "important_dates", "(", "year", ")", ":", "output", "=", "{", "}", "data", "=", "mlbgame", ".", "data", ".", "get_important_dates", "(", "year", ")", "important_dates", "=", "etree", ".", "parse", "(", "data", ")", ".", "getroot", "(", ")", ".",...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
broadcast_info
Returns a dictionary of broadcast information for a given team during a given season
mlbgame/info.py
def broadcast_info(team_id, date=datetime.now()): """Returns a dictionary of broadcast information for a given team during a given season""" year = date.year game_date = date.strftime('%Y-%m-%dT00:00:00') data = mlbgame.data.get_broadcast_info(team_id, year) schedule = json.loads(data.read().dec...
def broadcast_info(team_id, date=datetime.now()): """Returns a dictionary of broadcast information for a given team during a given season""" year = date.year game_date = date.strftime('%Y-%m-%dT00:00:00') data = mlbgame.data.get_broadcast_info(team_id, year) schedule = json.loads(data.read().dec...
[ "Returns", "a", "dictionary", "of", "broadcast", "information", "for", "a", "given", "team", "during", "a", "given", "season" ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/info.py#L62-L70
[ "def", "broadcast_info", "(", "team_id", ",", "date", "=", "datetime", ".", "now", "(", ")", ")", ":", "year", "=", "date", ".", "year", "game_date", "=", "date", ".", "strftime", "(", "'%Y-%m-%dT00:00:00'", ")", "data", "=", "mlbgame", ".", "data", "....
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
roster
Returns a dictionary of roster information for team id
mlbgame/info.py
def roster(team_id): """Returns a dictionary of roster information for team id""" data = mlbgame.data.get_roster(team_id) parsed = json.loads(data.read().decode('utf-8')) players = parsed['roster_40']['queryResults']['row'] return {'players': players, 'team_id': team_id}
def roster(team_id): """Returns a dictionary of roster information for team id""" data = mlbgame.data.get_roster(team_id) parsed = json.loads(data.read().decode('utf-8')) players = parsed['roster_40']['queryResults']['row'] return {'players': players, 'team_id': team_id}
[ "Returns", "a", "dictionary", "of", "roster", "information", "for", "team", "id" ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/info.py#L271-L276
[ "def", "roster", "(", "team_id", ")", ":", "data", "=", "mlbgame", ".", "data", ".", "get_roster", "(", "team_id", ")", "parsed", "=", "json", ".", "loads", "(", "data", ".", "read", "(", ")", ".", "decode", "(", "'utf-8'", ")", ")", "players", "="...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
ImportantDates.nice_output
Return a string for printing
mlbgame/info.py
def nice_output(self): """Return a string for printing""" dates = [ str_format('Opening Day {0}: {1}.', [self.year, date_format(self.first_date_seas)]), str_format('Last day of the 1st half: {0}.', [date_format(self.last_date_1sth)]),...
def nice_output(self): """Return a string for printing""" dates = [ str_format('Opening Day {0}: {1}.', [self.year, date_format(self.first_date_seas)]), str_format('Last day of the 1st half: {0}.', [date_format(self.last_date_1sth)]),...
[ "Return", "a", "string", "for", "printing" ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/info.py#L153-L171
[ "def", "nice_output", "(", "self", ")", ":", "dates", "=", "[", "str_format", "(", "'Opening Day {0}: {1}.'", ",", "[", "self", ".", "year", ",", "date_format", "(", "self", ".", "first_date_seas", ")", "]", ")", ",", "str_format", "(", "'Last day of the 1st...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
game_events
Return dictionary of events for a game with matching id.
mlbgame/events.py
def game_events(game_id, innings_endpoint=False): """Return dictionary of events for a game with matching id.""" # get data from data module if not innings_endpoint: data = mlbgame.data.get_game_events(game_id) endpoint = 'game_events' else: data = mlbgame.data.get_innings(game_i...
def game_events(game_id, innings_endpoint=False): """Return dictionary of events for a game with matching id.""" # get data from data module if not innings_endpoint: data = mlbgame.data.get_game_events(game_id) endpoint = 'game_events' else: data = mlbgame.data.get_innings(game_i...
[ "Return", "dictionary", "of", "events", "for", "a", "game", "with", "matching", "id", "." ]
panzarino/mlbgame
python
https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/events.py#L44-L65
[ "def", "game_events", "(", "game_id", ",", "innings_endpoint", "=", "False", ")", ":", "# get data from data module", "if", "not", "innings_endpoint", ":", "data", "=", "mlbgame", ".", "data", ".", "get_game_events", "(", "game_id", ")", "endpoint", "=", "'game_...
0a2d10540de793fdc3b8476aa18f5cf3b53d0b54
train
get_platform
Return a DHT platform interface for the currently detected platform.
Adafruit_DHT/common.py
def get_platform(): """Return a DHT platform interface for the currently detected platform.""" plat = platform_detect.platform_detect() if plat == platform_detect.RASPBERRY_PI: # Check for version 1 or 2 of the pi. version = platform_detect.pi_version() if version == 1: f...
def get_platform(): """Return a DHT platform interface for the currently detected platform.""" plat = platform_detect.platform_detect() if plat == platform_detect.RASPBERRY_PI: # Check for version 1 or 2 of the pi. version = platform_detect.pi_version() if version == 1: f...
[ "Return", "a", "DHT", "platform", "interface", "for", "the", "currently", "detected", "platform", "." ]
adafruit/Adafruit_Python_DHT
python
https://github.com/adafruit/Adafruit_Python_DHT/blob/c9407aa0506321bbc63ec8ba3c59fc21291f4746/Adafruit_DHT/common.py#L41-L63
[ "def", "get_platform", "(", ")", ":", "plat", "=", "platform_detect", ".", "platform_detect", "(", ")", "if", "plat", "==", "platform_detect", ".", "RASPBERRY_PI", ":", "# Check for version 1 or 2 of the pi.", "version", "=", "platform_detect", ".", "pi_version", "(...
c9407aa0506321bbc63ec8ba3c59fc21291f4746
train
read
Read DHT sensor of specified sensor type (DHT11, DHT22, or AM2302) on specified pin and return a tuple of humidity (as a floating point value in percent) and temperature (as a floating point value in Celsius). Note that because the sensor requires strict timing to read and Linux is not a real time OS, a...
Adafruit_DHT/common.py
def read(sensor, pin, platform=None): """Read DHT sensor of specified sensor type (DHT11, DHT22, or AM2302) on specified pin and return a tuple of humidity (as a floating point value in percent) and temperature (as a floating point value in Celsius). Note that because the sensor requires strict timing t...
def read(sensor, pin, platform=None): """Read DHT sensor of specified sensor type (DHT11, DHT22, or AM2302) on specified pin and return a tuple of humidity (as a floating point value in percent) and temperature (as a floating point value in Celsius). Note that because the sensor requires strict timing t...
[ "Read", "DHT", "sensor", "of", "specified", "sensor", "type", "(", "DHT11", "DHT22", "or", "AM2302", ")", "on", "specified", "pin", "and", "return", "a", "tuple", "of", "humidity", "(", "as", "a", "floating", "point", "value", "in", "percent", ")", "and"...
adafruit/Adafruit_Python_DHT
python
https://github.com/adafruit/Adafruit_Python_DHT/blob/c9407aa0506321bbc63ec8ba3c59fc21291f4746/Adafruit_DHT/common.py#L65-L81
[ "def", "read", "(", "sensor", ",", "pin", ",", "platform", "=", "None", ")", ":", "if", "sensor", "not", "in", "SENSORS", ":", "raise", "ValueError", "(", "'Expected DHT11, DHT22, or AM2302 sensor value.'", ")", "if", "platform", "is", "None", ":", "platform",...
c9407aa0506321bbc63ec8ba3c59fc21291f4746
train
read_retry
Read DHT sensor of specified sensor type (DHT11, DHT22, or AM2302) on specified pin and return a tuple of humidity (as a floating point value in percent) and temperature (as a floating point value in Celsius). Unlike the read function, this read_retry function will attempt to read multiple times (up to ...
Adafruit_DHT/common.py
def read_retry(sensor, pin, retries=15, delay_seconds=2, platform=None): """Read DHT sensor of specified sensor type (DHT11, DHT22, or AM2302) on specified pin and return a tuple of humidity (as a floating point value in percent) and temperature (as a floating point value in Celsius). Unlike the read fu...
def read_retry(sensor, pin, retries=15, delay_seconds=2, platform=None): """Read DHT sensor of specified sensor type (DHT11, DHT22, or AM2302) on specified pin and return a tuple of humidity (as a floating point value in percent) and temperature (as a floating point value in Celsius). Unlike the read fu...
[ "Read", "DHT", "sensor", "of", "specified", "sensor", "type", "(", "DHT11", "DHT22", "or", "AM2302", ")", "on", "specified", "pin", "and", "return", "a", "tuple", "of", "humidity", "(", "as", "a", "floating", "point", "value", "in", "percent", ")", "and"...
adafruit/Adafruit_Python_DHT
python
https://github.com/adafruit/Adafruit_Python_DHT/blob/c9407aa0506321bbc63ec8ba3c59fc21291f4746/Adafruit_DHT/common.py#L83-L98
[ "def", "read_retry", "(", "sensor", ",", "pin", ",", "retries", "=", "15", ",", "delay_seconds", "=", "2", ",", "platform", "=", "None", ")", ":", "for", "i", "in", "range", "(", "retries", ")", ":", "humidity", ",", "temperature", "=", "read", "(", ...
c9407aa0506321bbc63ec8ba3c59fc21291f4746
train
login_open_sheet
Connect to Google Docs spreadsheet and return the first worksheet.
examples/google_spreadsheet.py
def login_open_sheet(oauth_key_file, spreadsheet): """Connect to Google Docs spreadsheet and return the first worksheet.""" try: scope = ['https://spreadsheets.google.com/feeds'] credentials = ServiceAccountCredentials.from_json_keyfile_name(oauth_key_file, scope) gc = gspread.authorize...
def login_open_sheet(oauth_key_file, spreadsheet): """Connect to Google Docs spreadsheet and return the first worksheet.""" try: scope = ['https://spreadsheets.google.com/feeds'] credentials = ServiceAccountCredentials.from_json_keyfile_name(oauth_key_file, scope) gc = gspread.authorize...
[ "Connect", "to", "Google", "Docs", "spreadsheet", "and", "return", "the", "first", "worksheet", "." ]
adafruit/Adafruit_Python_DHT
python
https://github.com/adafruit/Adafruit_Python_DHT/blob/c9407aa0506321bbc63ec8ba3c59fc21291f4746/examples/google_spreadsheet.py#L81-L92
[ "def", "login_open_sheet", "(", "oauth_key_file", ",", "spreadsheet", ")", ":", "try", ":", "scope", "=", "[", "'https://spreadsheets.google.com/feeds'", "]", "credentials", "=", "ServiceAccountCredentials", ".", "from_json_keyfile_name", "(", "oauth_key_file", ",", "sc...
c9407aa0506321bbc63ec8ba3c59fc21291f4746
train
platform_detect
Detect if running on the Raspberry Pi or Beaglebone Black and return the platform type. Will return RASPBERRY_PI, BEAGLEBONE_BLACK, or UNKNOWN.
Adafruit_DHT/platform_detect.py
def platform_detect(): """Detect if running on the Raspberry Pi or Beaglebone Black and return the platform type. Will return RASPBERRY_PI, BEAGLEBONE_BLACK, or UNKNOWN.""" # Handle Raspberry Pi pi = pi_version() if pi is not None: return RASPBERRY_PI # Handle Beaglebone Black # TO...
def platform_detect(): """Detect if running on the Raspberry Pi or Beaglebone Black and return the platform type. Will return RASPBERRY_PI, BEAGLEBONE_BLACK, or UNKNOWN.""" # Handle Raspberry Pi pi = pi_version() if pi is not None: return RASPBERRY_PI # Handle Beaglebone Black # TO...
[ "Detect", "if", "running", "on", "the", "Raspberry", "Pi", "or", "Beaglebone", "Black", "and", "return", "the", "platform", "type", ".", "Will", "return", "RASPBERRY_PI", "BEAGLEBONE_BLACK", "or", "UNKNOWN", "." ]
adafruit/Adafruit_Python_DHT
python
https://github.com/adafruit/Adafruit_Python_DHT/blob/c9407aa0506321bbc63ec8ba3c59fc21291f4746/Adafruit_DHT/platform_detect.py#L36-L58
[ "def", "platform_detect", "(", ")", ":", "# Handle Raspberry Pi", "pi", "=", "pi_version", "(", ")", "if", "pi", "is", "not", "None", ":", "return", "RASPBERRY_PI", "# Handle Beaglebone Black", "# TODO: Check the Beaglebone Black /proc/cpuinfo value instead of reading", "# ...
c9407aa0506321bbc63ec8ba3c59fc21291f4746
train
pi_revision
Detect the revision number of a Raspberry Pi, useful for changing functionality like default I2C bus based on revision.
Adafruit_DHT/platform_detect.py
def pi_revision(): """Detect the revision number of a Raspberry Pi, useful for changing functionality like default I2C bus based on revision.""" # Revision list available at: http://elinux.org/RPi_HardwareHistory#Board_Revision_History with open('/proc/cpuinfo', 'r') as infile: for line in infil...
def pi_revision(): """Detect the revision number of a Raspberry Pi, useful for changing functionality like default I2C bus based on revision.""" # Revision list available at: http://elinux.org/RPi_HardwareHistory#Board_Revision_History with open('/proc/cpuinfo', 'r') as infile: for line in infil...
[ "Detect", "the", "revision", "number", "of", "a", "Raspberry", "Pi", "useful", "for", "changing", "functionality", "like", "default", "I2C", "bus", "based", "on", "revision", "." ]
adafruit/Adafruit_Python_DHT
python
https://github.com/adafruit/Adafruit_Python_DHT/blob/c9407aa0506321bbc63ec8ba3c59fc21291f4746/Adafruit_DHT/platform_detect.py#L61-L77
[ "def", "pi_revision", "(", ")", ":", "# Revision list available at: http://elinux.org/RPi_HardwareHistory#Board_Revision_History", "with", "open", "(", "'/proc/cpuinfo'", ",", "'r'", ")", "as", "infile", ":", "for", "line", "in", "infile", ":", "# Match a line of the form \...
c9407aa0506321bbc63ec8ba3c59fc21291f4746
train
handle_password
Handles getting the password
yagmail/password.py
def handle_password(user, password): # pragma: no cover """ Handles getting the password""" if password is None: try: password = keyring.get_password("yagmail", user) except NameError as e: print( "'keyring' cannot be loaded. Try 'pip install keyring' or ...
def handle_password(user, password): # pragma: no cover """ Handles getting the password""" if password is None: try: password = keyring.get_password("yagmail", user) except NameError as e: print( "'keyring' cannot be loaded. Try 'pip install keyring' or ...
[ "Handles", "getting", "the", "password" ]
kootenpv/yagmail
python
https://github.com/kootenpv/yagmail/blob/b8873299ce682193eef43314aa214e553c2b67cb/yagmail/password.py#L7-L32
[ "def", "handle_password", "(", "user", ",", "password", ")", ":", "# pragma: no cover", "if", "password", "is", "None", ":", "try", ":", "password", "=", "keyring", ".", "get_password", "(", "\"yagmail\"", ",", "user", ")", "except", "NameError", "as", "e", ...
b8873299ce682193eef43314aa214e553c2b67cb
train
resolve_addresses
Handle the targets addresses, adding aliases when defined
yagmail/headers.py
def resolve_addresses(user, useralias, to, cc, bcc): """ Handle the targets addresses, adding aliases when defined """ addresses = {"recipients": []} if to is not None: make_addr_alias_target(to, addresses, "To") elif cc is not None and bcc is not None: make_addr_alias_target([user, user...
def resolve_addresses(user, useralias, to, cc, bcc): """ Handle the targets addresses, adding aliases when defined """ addresses = {"recipients": []} if to is not None: make_addr_alias_target(to, addresses, "To") elif cc is not None and bcc is not None: make_addr_alias_target([user, user...
[ "Handle", "the", "targets", "addresses", "adding", "aliases", "when", "defined" ]
kootenpv/yagmail
python
https://github.com/kootenpv/yagmail/blob/b8873299ce682193eef43314aa214e553c2b67cb/yagmail/headers.py#L5-L18
[ "def", "resolve_addresses", "(", "user", ",", "useralias", ",", "to", ",", "cc", ",", "bcc", ")", ":", "addresses", "=", "{", "\"recipients\"", ":", "[", "]", "}", "if", "to", "is", "not", "None", ":", "make_addr_alias_target", "(", "to", ",", "address...
b8873299ce682193eef43314aa214e553c2b67cb
train
main
This is the function that is run from commandline with `yagmail`
yagmail/__main__.py
def main(): """ This is the function that is run from commandline with `yagmail` """ import argparse parser = argparse.ArgumentParser(description='Send a (g)mail with yagmail.') subparsers = parser.add_subparsers(dest="command") oauth = subparsers.add_parser('oauth') oauth.add_argument( ...
def main(): """ This is the function that is run from commandline with `yagmail` """ import argparse parser = argparse.ArgumentParser(description='Send a (g)mail with yagmail.') subparsers = parser.add_subparsers(dest="command") oauth = subparsers.add_parser('oauth') oauth.add_argument( ...
[ "This", "is", "the", "function", "that", "is", "run", "from", "commandline", "with", "yagmail" ]
kootenpv/yagmail
python
https://github.com/kootenpv/yagmail/blob/b8873299ce682193eef43314aa214e553c2b67cb/yagmail/__main__.py#L15-L49
[ "def", "main", "(", ")", ":", "import", "argparse", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Send a (g)mail with yagmail.'", ")", "subparsers", "=", "parser", ".", "add_subparsers", "(", "dest", "=", "\"command\"", ")", "oauth...
b8873299ce682193eef43314aa214e553c2b67cb
train
prepare_message
Prepare a MIME message
yagmail/message.py
def prepare_message(user, useralias, addresses, subject, contents, attachments, headers, encoding, newline_to_break=True): # check if closed!!!!!! XXX """ Prepare a MIME message """ if isinstance(contents, text_type): contents = [contents] if isinstance(attachments, text_type): attachmen...
def prepare_message(user, useralias, addresses, subject, contents, attachments, headers, encoding, newline_to_break=True): # check if closed!!!!!! XXX """ Prepare a MIME message """ if isinstance(contents, text_type): contents = [contents] if isinstance(attachments, text_type): attachmen...
[ "Prepare", "a", "MIME", "message" ]
kootenpv/yagmail
python
https://github.com/kootenpv/yagmail/blob/b8873299ce682193eef43314aa214e553c2b67cb/yagmail/message.py#L15-L99
[ "def", "prepare_message", "(", "user", ",", "useralias", ",", "addresses", ",", "subject", ",", "contents", ",", "attachments", ",", "headers", ",", "encoding", ",", "newline_to_break", "=", "True", ")", ":", "# check if closed!!!!!! XXX", "if", "isinstance", "(...
b8873299ce682193eef43314aa214e553c2b67cb
train
validate_email_with_regex
Note that this will only filter out syntax mistakes in emailaddresses. If a human would think it is probably a valid email, it will most likely pass. However, it could still very well be that the actual emailaddress has simply not be claimed by anyone (so then this function fails to devalidate).
yagmail/validate.py
def validate_email_with_regex(email_address): """ Note that this will only filter out syntax mistakes in emailaddresses. If a human would think it is probably a valid email, it will most likely pass. However, it could still very well be that the actual emailaddress has simply not be claimed by anyon...
def validate_email_with_regex(email_address): """ Note that this will only filter out syntax mistakes in emailaddresses. If a human would think it is probably a valid email, it will most likely pass. However, it could still very well be that the actual emailaddress has simply not be claimed by anyon...
[ "Note", "that", "this", "will", "only", "filter", "out", "syntax", "mistakes", "in", "emailaddresses", ".", "If", "a", "human", "would", "think", "it", "is", "probably", "a", "valid", "email", "it", "will", "most", "likely", "pass", ".", "However", "it", ...
kootenpv/yagmail
python
https://github.com/kootenpv/yagmail/blob/b8873299ce682193eef43314aa214e553c2b67cb/yagmail/validate.py#L100-L113
[ "def", "validate_email_with_regex", "(", "email_address", ")", ":", "if", "not", "re", ".", "match", "(", "VALID_ADDRESS_REGEXP", ",", "email_address", ")", ":", "emsg", "=", "'Emailaddress \"{}\" is not valid according to RFC 2822 standards'", ".", "format", "(", "emai...
b8873299ce682193eef43314aa214e553c2b67cb
train
SMTPBase.set_logging
This function allows to change the logging backend, either output or file as backend It also allows to set the logging level (whether to display only critical/error/info/debug. for example:: yag = yagmail.SMTP() yag.set_logging(yagmail.logging.DEBUG) # to see everything ...
yagmail/sender.py
def set_logging(self, log_level=logging.ERROR, file_path_name=None): """ This function allows to change the logging backend, either output or file as backend It also allows to set the logging level (whether to display only critical/error/info/debug. for example:: yag = yagma...
def set_logging(self, log_level=logging.ERROR, file_path_name=None): """ This function allows to change the logging backend, either output or file as backend It also allows to set the logging level (whether to display only critical/error/info/debug. for example:: yag = yagma...
[ "This", "function", "allows", "to", "change", "the", "logging", "backend", "either", "output", "or", "file", "as", "backend", "It", "also", "allows", "to", "set", "the", "logging", "level", "(", "whether", "to", "display", "only", "critical", "/", "error", ...
kootenpv/yagmail
python
https://github.com/kootenpv/yagmail/blob/b8873299ce682193eef43314aa214e553c2b67cb/yagmail/sender.py#L84-L99
[ "def", "set_logging", "(", "self", ",", "log_level", "=", "logging", ".", "ERROR", ",", "file_path_name", "=", "None", ")", ":", "self", ".", "log", "=", "get_logger", "(", "log_level", ",", "file_path_name", ")" ]
b8873299ce682193eef43314aa214e553c2b67cb
train
SMTPBase.send
Use this to send an email with gmail
yagmail/sender.py
def send( self, to=None, subject=None, contents=None, attachments=None, cc=None, bcc=None, preview_only=False, headers=None, newline_to_break=True, ): """ Use this to send an email with gmail""" self.login() reci...
def send( self, to=None, subject=None, contents=None, attachments=None, cc=None, bcc=None, preview_only=False, headers=None, newline_to_break=True, ): """ Use this to send an email with gmail""" self.login() reci...
[ "Use", "this", "to", "send", "an", "email", "with", "gmail" ]
kootenpv/yagmail
python
https://github.com/kootenpv/yagmail/blob/b8873299ce682193eef43314aa214e553c2b67cb/yagmail/sender.py#L134-L153
[ "def", "send", "(", "self", ",", "to", "=", "None", ",", "subject", "=", "None", ",", "contents", "=", "None", ",", "attachments", "=", "None", ",", "cc", "=", "None", ",", "bcc", "=", "None", ",", "preview_only", "=", "False", ",", "headers", "=",...
b8873299ce682193eef43314aa214e553c2b67cb
train
SMTPBase.send_unsent
Emails that were not being able to send will be stored in :attr:`self.unsent`. Use this function to attempt to send these again
yagmail/sender.py
def send_unsent(self): """ Emails that were not being able to send will be stored in :attr:`self.unsent`. Use this function to attempt to send these again """ for i in range(len(self.unsent)): recipients, msg_string = self.unsent.pop(i) self._attempt_send(...
def send_unsent(self): """ Emails that were not being able to send will be stored in :attr:`self.unsent`. Use this function to attempt to send these again """ for i in range(len(self.unsent)): recipients, msg_string = self.unsent.pop(i) self._attempt_send(...
[ "Emails", "that", "were", "not", "being", "able", "to", "send", "will", "be", "stored", "in", ":", "attr", ":", "self", ".", "unsent", ".", "Use", "this", "function", "to", "attempt", "to", "send", "these", "again" ]
kootenpv/yagmail
python
https://github.com/kootenpv/yagmail/blob/b8873299ce682193eef43314aa214e553c2b67cb/yagmail/sender.py#L170-L177
[ "def", "send_unsent", "(", "self", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "unsent", ")", ")", ":", "recipients", ",", "msg_string", "=", "self", ".", "unsent", ".", "pop", "(", "i", ")", "self", ".", "_attempt_send", "("...
b8873299ce682193eef43314aa214e553c2b67cb
train
SMTPBase.close
Close the connection to the SMTP server
yagmail/sender.py
def close(self): """ Close the connection to the SMTP server """ self.is_closed = True try: self.smtp.quit() except (TypeError, AttributeError, smtplib.SMTPServerDisconnected): pass
def close(self): """ Close the connection to the SMTP server """ self.is_closed = True try: self.smtp.quit() except (TypeError, AttributeError, smtplib.SMTPServerDisconnected): pass
[ "Close", "the", "connection", "to", "the", "SMTP", "server" ]
kootenpv/yagmail
python
https://github.com/kootenpv/yagmail/blob/b8873299ce682193eef43314aa214e553c2b67cb/yagmail/sender.py#L179-L185
[ "def", "close", "(", "self", ")", ":", "self", ".", "is_closed", "=", "True", "try", ":", "self", ".", "smtp", ".", "quit", "(", ")", "except", "(", "TypeError", ",", "AttributeError", ",", "smtplib", ".", "SMTPServerDisconnected", ")", ":", "pass" ]
b8873299ce682193eef43314aa214e553c2b67cb
train
SMTPBase._login
Login to the SMTP server using password. `login` only needs to be manually run when the connection to the SMTP server was closed by the user.
yagmail/sender.py
def _login(self, password): """ Login to the SMTP server using password. `login` only needs to be manually run when the connection to the SMTP server was closed by the user. """ self.smtp = self.connection(self.host, self.port, **self.kwargs) self.smtp.set_debuglevel(self...
def _login(self, password): """ Login to the SMTP server using password. `login` only needs to be manually run when the connection to the SMTP server was closed by the user. """ self.smtp = self.connection(self.host, self.port, **self.kwargs) self.smtp.set_debuglevel(self...
[ "Login", "to", "the", "SMTP", "server", "using", "password", ".", "login", "only", "needs", "to", "be", "manually", "run", "when", "the", "connection", "to", "the", "SMTP", "server", "was", "closed", "by", "the", "user", "." ]
kootenpv/yagmail
python
https://github.com/kootenpv/yagmail/blob/b8873299ce682193eef43314aa214e553c2b67cb/yagmail/sender.py#L187-L205
[ "def", "_login", "(", "self", ",", "password", ")", ":", "self", ".", "smtp", "=", "self", ".", "connection", "(", "self", ".", "host", ",", "self", ".", "port", ",", "*", "*", "self", ".", "kwargs", ")", "self", ".", "smtp", ".", "set_debuglevel",...
b8873299ce682193eef43314aa214e553c2b67cb
train
Server.start
Start the server.
voltron/core.py
def start(self): """ Start the server. """ plugins = voltron.plugin.pm.web_plugins self.app = DispatcherMiddleware( RootFlaskApp(), { "/api": APIFlaskApp(server=self), "/view": SharedDataMiddleware( None,...
def start(self): """ Start the server. """ plugins = voltron.plugin.pm.web_plugins self.app = DispatcherMiddleware( RootFlaskApp(), { "/api": APIFlaskApp(server=self), "/view": SharedDataMiddleware( None,...
[ "Start", "the", "server", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/core.py#L134-L172
[ "def", "start", "(", "self", ")", ":", "plugins", "=", "voltron", ".", "plugin", ".", "pm", ".", "web_plugins", "self", ".", "app", "=", "DispatcherMiddleware", "(", "RootFlaskApp", "(", ")", ",", "{", "\"/api\"", ":", "APIFlaskApp", "(", "server", "=", ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
Server.stop
Stop the server.
voltron/core.py
def stop(self): """ Stop the server. """ log.debug("Stopping listeners") self.queue_lock.acquire() for s in self.listeners: log.debug("Stopping {}".format(s)) s.shutdown() s.socket.close() self.cancel_queue() for t in se...
def stop(self): """ Stop the server. """ log.debug("Stopping listeners") self.queue_lock.acquire() for s in self.listeners: log.debug("Stopping {}".format(s)) s.shutdown() s.socket.close() self.cancel_queue() for t in se...
[ "Stop", "the", "server", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/core.py#L174-L191
[ "def", "stop", "(", "self", ")", ":", "log", ".", "debug", "(", "\"Stopping listeners\"", ")", "self", ".", "queue_lock", ".", "acquire", "(", ")", "for", "s", "in", "self", ".", "listeners", ":", "log", ".", "debug", "(", "\"Stopping {}\"", ".", "form...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
Server.cancel_queue
Cancel all requests in the queue so we can exit.
voltron/core.py
def cancel_queue(self): """ Cancel all requests in the queue so we can exit. """ q = list(self.queue) self.queue = [] log.debug("Canceling requests: {}".format(q)) for req in q: req.response = APIServerNotRunningErrorResponse() for req in q: ...
def cancel_queue(self): """ Cancel all requests in the queue so we can exit. """ q = list(self.queue) self.queue = [] log.debug("Canceling requests: {}".format(q)) for req in q: req.response = APIServerNotRunningErrorResponse() for req in q: ...
[ "Cancel", "all", "requests", "in", "the", "queue", "so", "we", "can", "exit", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/core.py#L251-L261
[ "def", "cancel_queue", "(", "self", ")", ":", "q", "=", "list", "(", "self", ".", "queue", ")", "self", ".", "queue", "=", "[", "]", "log", ".", "debug", "(", "\"Canceling requests: {}\"", ".", "format", "(", "q", ")", ")", "for", "req", "in", "q",...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
Server.dispatch_queue
Dispatch any queued requests. Called by the debugger when it stops.
voltron/core.py
def dispatch_queue(self): """ Dispatch any queued requests. Called by the debugger when it stops. """ self.queue_lock.acquire() q = list(self.queue) self.queue = [] self.queue_lock.release() log.debug("Dispatching requests: {}".format(q)) ...
def dispatch_queue(self): """ Dispatch any queued requests. Called by the debugger when it stops. """ self.queue_lock.acquire() q = list(self.queue) self.queue = [] self.queue_lock.release() log.debug("Dispatching requests: {}".format(q)) ...
[ "Dispatch", "any", "queued", "requests", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/core.py#L263-L277
[ "def", "dispatch_queue", "(", "self", ")", ":", "self", ".", "queue_lock", ".", "acquire", "(", ")", "q", "=", "list", "(", "self", ".", "queue", ")", "self", ".", "queue", "=", "[", "]", "self", ".", "queue_lock", ".", "release", "(", ")", "log", ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
Server.dispatch_request
Dispatch a request object.
voltron/core.py
def dispatch_request(self, req): """ Dispatch a request object. """ log.debug("Dispatching request: {}".format(str(req))) # make sure it's valid res = None try: req.validate() except MissingFieldError as e: res = APIMissingFieldErr...
def dispatch_request(self, req): """ Dispatch a request object. """ log.debug("Dispatching request: {}".format(str(req))) # make sure it's valid res = None try: req.validate() except MissingFieldError as e: res = APIMissingFieldErr...
[ "Dispatch", "a", "request", "object", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/core.py#L279-L303
[ "def", "dispatch_request", "(", "self", ",", "req", ")", ":", "log", ".", "debug", "(", "\"Dispatching request: {}\"", ".", "format", "(", "str", "(", "req", ")", ")", ")", "# make sure it's valid", "res", "=", "None", "try", ":", "req", ".", "validate", ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
Client.send_request
Send a request to the server. `request` is an APIRequest subclass. Returns an APIResponse or subclass instance. If an error occurred, it will be an APIErrorResponse, if the request was successful it will be the plugin's specified response class if one exists, otherwise it will ...
voltron/core.py
def send_request(self, request): """ Send a request to the server. `request` is an APIRequest subclass. Returns an APIResponse or subclass instance. If an error occurred, it will be an APIErrorResponse, if the request was successful it will be the plugin's specified res...
def send_request(self, request): """ Send a request to the server. `request` is an APIRequest subclass. Returns an APIResponse or subclass instance. If an error occurred, it will be an APIErrorResponse, if the request was successful it will be the plugin's specified res...
[ "Send", "a", "request", "to", "the", "server", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/core.py#L416-L461
[ "def", "send_request", "(", "self", ",", "request", ")", ":", "# default to an empty response error", "res", "=", "APIEmptyResponseErrorResponse", "(", ")", "# perform the request", "log", ".", "debug", "(", "\"Client sending request: \"", "+", "str", "(", "request", ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
Client.send_requests
Send a set of requests. Each request is sent over its own connection and the function will return when all the requests have been fulfilled.
voltron/core.py
def send_requests(self, *args): """ Send a set of requests. Each request is sent over its own connection and the function will return when all the requests have been fulfilled. """ threads = [ClientThread(self, req) for req in args] for t in threads: ...
def send_requests(self, *args): """ Send a set of requests. Each request is sent over its own connection and the function will return when all the requests have been fulfilled. """ threads = [ClientThread(self, req) for req in args] for t in threads: ...
[ "Send", "a", "set", "of", "requests", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/core.py#L463-L478
[ "def", "send_requests", "(", "self", ",", "*", "args", ")", ":", "threads", "=", "[", "ClientThread", "(", "self", ",", "req", ")", "for", "req", "in", "args", "]", "for", "t", "in", "threads", ":", "t", ".", "start", "(", ")", "for", "t", "in", ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
Client.perform_request
Create and send a request. `request_type` is the request type (string). This is used to look up a plugin, whose request class is instantiated and passed the remaining arguments passed to this function.
voltron/core.py
def perform_request(self, request_type, *args, **kwargs): """ Create and send a request. `request_type` is the request type (string). This is used to look up a plugin, whose request class is instantiated and passed the remaining arguments passed to this function. """ ...
def perform_request(self, request_type, *args, **kwargs): """ Create and send a request. `request_type` is the request type (string). This is used to look up a plugin, whose request class is instantiated and passed the remaining arguments passed to this function. """ ...
[ "Create", "and", "send", "a", "request", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/core.py#L490-L504
[ "def", "perform_request", "(", "self", ",", "request_type", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# create a request", "req", "=", "api_request", "(", "request_type", ",", "*", "args", ",", "*", "*", "kwargs", ")", "# send it", "res", "="...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
Client.update
Update the display
voltron/core.py
def update(self): """ Update the display """ # build requests for this iteration reqs = self.build_requests() for r in reqs: r.block = self.block results = self.send_requests(*reqs) # call callback with the results self.callback(result...
def update(self): """ Update the display """ # build requests for this iteration reqs = self.build_requests() for r in reqs: r.block = self.block results = self.send_requests(*reqs) # call callback with the results self.callback(result...
[ "Update", "the", "display" ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/core.py#L506-L517
[ "def", "update", "(", "self", ")", ":", "# build requests for this iteration", "reqs", "=", "self", ".", "build_requests", "(", ")", "for", "r", "in", "reqs", ":", "r", ".", "block", "=", "self", ".", "block", "results", "=", "self", ".", "send_requests", ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
Client.run
Run the client in a loop, calling the callback each time the debugger stops.
voltron/core.py
def run(self, build_requests=None, callback=None): """ Run the client in a loop, calling the callback each time the debugger stops. """ if callback: self.callback = callback if build_requests: self.build_requests = build_requests def norma...
def run(self, build_requests=None, callback=None): """ Run the client in a loop, calling the callback each time the debugger stops. """ if callback: self.callback = callback if build_requests: self.build_requests = build_requests def norma...
[ "Run", "the", "client", "in", "a", "loop", "calling", "the", "callback", "each", "time", "the", "debugger", "stops", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/core.py#L519-L567
[ "def", "run", "(", "self", ",", "build_requests", "=", "None", ",", "callback", "=", "None", ")", ":", "if", "callback", ":", "self", ".", "callback", "=", "callback", "if", "build_requests", ":", "self", ".", "build_requests", "=", "build_requests", "def"...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
Client.start
Run the client using a background thread.
voltron/core.py
def start(self, build_requests=None, callback=None): """ Run the client using a background thread. """ if callback: self.callback = callback if build_requests: self.build_requests = build_requests # spin off requester thread self.sw = thre...
def start(self, build_requests=None, callback=None): """ Run the client using a background thread. """ if callback: self.callback = callback if build_requests: self.build_requests = build_requests # spin off requester thread self.sw = thre...
[ "Run", "the", "client", "using", "a", "background", "thread", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/core.py#L569-L580
[ "def", "start", "(", "self", ",", "build_requests", "=", "None", ",", "callback", "=", "None", ")", ":", "if", "callback", ":", "self", ".", "callback", "=", "callback", "if", "build_requests", ":", "self", ".", "build_requests", "=", "build_requests", "# ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
server_side
Decorator to designate an API method applicable only to server-side instances. This allows us to use the same APIRequest and APIResponse subclasses on the client and server sides without too much confusion.
voltron/api.py
def server_side(func): """ Decorator to designate an API method applicable only to server-side instances. This allows us to use the same APIRequest and APIResponse subclasses on the client and server sides without too much confusion. """ def inner(*args, **kwargs): if args and hasat...
def server_side(func): """ Decorator to designate an API method applicable only to server-side instances. This allows us to use the same APIRequest and APIResponse subclasses on the client and server sides without too much confusion. """ def inner(*args, **kwargs): if args and hasat...
[ "Decorator", "to", "designate", "an", "API", "method", "applicable", "only", "to", "server", "-", "side", "instances", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/api.py#L124-L136
[ "def", "server_side", "(", "func", ")", ":", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "args", "and", "hasattr", "(", "args", "[", "0", "]", ",", "'is_server'", ")", "and", "not", "voltron", ".", "debugger", ":", ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
client_side
Decorator to designate an API method applicable only to client-side instances. This allows us to use the same APIRequest and APIResponse subclasses on the client and server sides without too much confusion.
voltron/api.py
def client_side(func): """ Decorator to designate an API method applicable only to client-side instances. This allows us to use the same APIRequest and APIResponse subclasses on the client and server sides without too much confusion. """ def inner(*args, **kwargs): if args and hasat...
def client_side(func): """ Decorator to designate an API method applicable only to client-side instances. This allows us to use the same APIRequest and APIResponse subclasses on the client and server sides without too much confusion. """ def inner(*args, **kwargs): if args and hasat...
[ "Decorator", "to", "designate", "an", "API", "method", "applicable", "only", "to", "client", "-", "side", "instances", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/api.py#L139-L151
[ "def", "client_side", "(", "func", ")", ":", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "args", "and", "hasattr", "(", "args", "[", "0", "]", ",", "'is_server'", ")", "and", "voltron", ".", "debugger", ":", "raise", ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
APIMessage.to_dict
Return a transmission-safe dictionary representation of the API message properties.
voltron/api.py
def to_dict(self): """ Return a transmission-safe dictionary representation of the API message properties. """ d = {field: getattr(self, field) for field in self._top_fields if hasattr(self, field)} # set values of data fields d['data'] = {} for field in self._fi...
def to_dict(self): """ Return a transmission-safe dictionary representation of the API message properties. """ d = {field: getattr(self, field) for field in self._top_fields if hasattr(self, field)} # set values of data fields d['data'] = {} for field in self._fi...
[ "Return", "a", "transmission", "-", "safe", "dictionary", "representation", "of", "the", "API", "message", "properties", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/api.py#L195-L214
[ "def", "to_dict", "(", "self", ")", ":", "d", "=", "{", "field", ":", "getattr", "(", "self", ",", "field", ")", "for", "field", "in", "self", ".", "_top_fields", "if", "hasattr", "(", "self", ",", "field", ")", "}", "# set values of data fields", "d",...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
APIMessage.from_dict
Initialise an API message from a transmission-safe dictionary.
voltron/api.py
def from_dict(self, d): """ Initialise an API message from a transmission-safe dictionary. """ for key in d: if key == 'data': for dkey in d['data']: if dkey in self._encode_fields: setattr(self, str(dkey), base64.b6...
def from_dict(self, d): """ Initialise an API message from a transmission-safe dictionary. """ for key in d: if key == 'data': for dkey in d['data']: if dkey in self._encode_fields: setattr(self, str(dkey), base64.b6...
[ "Initialise", "an", "API", "message", "from", "a", "transmission", "-", "safe", "dictionary", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/api.py#L216-L228
[ "def", "from_dict", "(", "self", ",", "d", ")", ":", "for", "key", "in", "d", ":", "if", "key", "==", "'data'", ":", "for", "dkey", "in", "d", "[", "'data'", "]", ":", "if", "dkey", "in", "self", ".", "_encode_fields", ":", "setattr", "(", "self"...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
APIMessage.from_json
Initialise an API message from a JSON representation.
voltron/api.py
def from_json(self, data): """ Initialise an API message from a JSON representation. """ try: d = json.loads(data) except ValueError: raise InvalidMessageException() self.from_dict(d)
def from_json(self, data): """ Initialise an API message from a JSON representation. """ try: d = json.loads(data) except ValueError: raise InvalidMessageException() self.from_dict(d)
[ "Initialise", "an", "API", "message", "from", "a", "JSON", "representation", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/api.py#L236-L244
[ "def", "from_json", "(", "self", ",", "data", ")", ":", "try", ":", "d", "=", "json", ".", "loads", "(", "data", ")", "except", "ValueError", ":", "raise", "InvalidMessageException", "(", ")", "self", ".", "from_dict", "(", "d", ")" ]
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
APIMessage.validate
Validate the message. Ensure all the required fields are present and not None.
voltron/api.py
def validate(self): """ Validate the message. Ensure all the required fields are present and not None. """ required_fields = list(filter(lambda x: self._fields[x], self._fields.keys())) for field in (self._top_fields + required_fields): if not hasattr(self, f...
def validate(self): """ Validate the message. Ensure all the required fields are present and not None. """ required_fields = list(filter(lambda x: self._fields[x], self._fields.keys())) for field in (self._top_fields + required_fields): if not hasattr(self, f...
[ "Validate", "the", "message", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/api.py#L256-L265
[ "def", "validate", "(", "self", ")", ":", "required_fields", "=", "list", "(", "filter", "(", "lambda", "x", ":", "self", ".", "_fields", "[", "x", "]", ",", "self", ".", "_fields", ".", "keys", "(", ")", ")", ")", "for", "field", "in", "(", "sel...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
APIRequest.wait
Wait for the request to be dispatched.
voltron/api.py
def wait(self): """ Wait for the request to be dispatched. """ self.wait_event = threading.Event() timeout = int(self.timeout) if self.timeout else None self.timed_out = not self.wait_event.wait(timeout)
def wait(self): """ Wait for the request to be dispatched. """ self.wait_event = threading.Event() timeout = int(self.timeout) if self.timeout else None self.timed_out = not self.wait_event.wait(timeout)
[ "Wait", "for", "the", "request", "to", "be", "dispatched", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/api.py#L300-L306
[ "def", "wait", "(", "self", ")", ":", "self", ".", "wait_event", "=", "threading", ".", "Event", "(", ")", "timeout", "=", "int", "(", "self", ".", "timeout", ")", "if", "self", ".", "timeout", "else", "None", "self", ".", "timed_out", "=", "not", ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
validate_target
A decorator that ensures that the specified target_id exists and is valid. Expects the target ID to be either the 'target_id' param in kwargs, or the first positional parameter. Raises a NoSuchTargetException if the target does not exist.
voltron/dbg.py
def validate_target(func, *args, **kwargs): """ A decorator that ensures that the specified target_id exists and is valid. Expects the target ID to be either the 'target_id' param in kwargs, or the first positional parameter. Raises a NoSuchTargetException if the target does not exist. """...
def validate_target(func, *args, **kwargs): """ A decorator that ensures that the specified target_id exists and is valid. Expects the target ID to be either the 'target_id' param in kwargs, or the first positional parameter. Raises a NoSuchTargetException if the target does not exist. """...
[ "A", "decorator", "that", "ensures", "that", "the", "specified", "target_id", "exists", "and", "is", "valid", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/dbg.py#L17-L41
[ "def", "validate_target", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "inner", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# find the target param", "target_id", "=", "None", "if", "'target_id'", "in"...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
validate_busy
A decorator that raises an exception if the specified target is busy. Expects the target ID to be either the 'target_id' param in kwargs, or the first positional parameter. Raises a TargetBusyException if the target does not exist.
voltron/dbg.py
def validate_busy(func, *args, **kwargs): """ A decorator that raises an exception if the specified target is busy. Expects the target ID to be either the 'target_id' param in kwargs, or the first positional parameter. Raises a TargetBusyException if the target does not exist. """ def inne...
def validate_busy(func, *args, **kwargs): """ A decorator that raises an exception if the specified target is busy. Expects the target ID to be either the 'target_id' param in kwargs, or the first positional parameter. Raises a TargetBusyException if the target does not exist. """ def inne...
[ "A", "decorator", "that", "raises", "an", "exception", "if", "the", "specified", "target", "is", "busy", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/dbg.py#L44-L67
[ "def", "validate_busy", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "inner", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# find the target param", "target_id", "=", "None", "if", "'target_id'", "in", ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
lock_host
A decorator that acquires a lock before accessing the debugger to avoid API locking related errors with the debugger host.
voltron/dbg.py
def lock_host(func, *args, **kwargs): """ A decorator that acquires a lock before accessing the debugger to avoid API locking related errors with the debugger host. """ def inner(self, *args, **kwargs): self.host_lock.acquire() try: res = func(self, *args, **kwargs) ...
def lock_host(func, *args, **kwargs): """ A decorator that acquires a lock before accessing the debugger to avoid API locking related errors with the debugger host. """ def inner(self, *args, **kwargs): self.host_lock.acquire() try: res = func(self, *args, **kwargs) ...
[ "A", "decorator", "that", "acquires", "a", "lock", "before", "accessing", "the", "debugger", "to", "avoid", "API", "locking", "related", "errors", "with", "the", "debugger", "host", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/dbg.py#L70-L84
[ "def", "lock_host", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "inner", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "host_lock", ".", "acquire", "(", ")", "try", ":", "res", "=", ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
DebuggerAdaptor.target_exists
Returns True or False indicating whether or not the specified target is present and valid. `target_id` is a target ID (or None for the first target)
voltron/dbg.py
def target_exists(self, target_id=0): """ Returns True or False indicating whether or not the specified target is present and valid. `target_id` is a target ID (or None for the first target) """ try: target = self._target(target_id=target_id) except E...
def target_exists(self, target_id=0): """ Returns True or False indicating whether or not the specified target is present and valid. `target_id` is a target ID (or None for the first target) """ try: target = self._target(target_id=target_id) except E...
[ "Returns", "True", "or", "False", "indicating", "whether", "or", "not", "the", "specified", "target", "is", "present", "and", "valid", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/dbg.py#L119-L131
[ "def", "target_exists", "(", "self", ",", "target_id", "=", "0", ")", ":", "try", ":", "target", "=", "self", ".", "_target", "(", "target_id", "=", "target_id", ")", "except", "Exception", "as", "e", ":", "log", ".", "error", "(", "\"Exception checking ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
DebuggerAdaptor.target_is_valid
Returns True or False indicating whether or not the specified target is present and valid. `target_id` is a target ID (or None for the first target)
voltron/dbg.py
def target_is_valid(self, target_id=0): """ Returns True or False indicating whether or not the specified target is present and valid. `target_id` is a target ID (or None for the first target) """ try: target = self._target(target_id=target_id) except...
def target_is_valid(self, target_id=0): """ Returns True or False indicating whether or not the specified target is present and valid. `target_id` is a target ID (or None for the first target) """ try: target = self._target(target_id=target_id) except...
[ "Returns", "True", "or", "False", "indicating", "whether", "or", "not", "the", "specified", "target", "is", "present", "and", "valid", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/dbg.py#L133-L144
[ "def", "target_is_valid", "(", "self", ",", "target_id", "=", "0", ")", ":", "try", ":", "target", "=", "self", ".", "_target", "(", "target_id", "=", "target_id", ")", "except", ":", "return", "False", "return", "target", "[", "'state'", "]", "!=", "\...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
DebuggerAdaptor.target_is_busy
Returns True or False indicating whether or not the specified target is busy. `target_id` is a target ID (or None for the first target)
voltron/dbg.py
def target_is_busy(self, target_id=0): """ Returns True or False indicating whether or not the specified target is busy. `target_id` is a target ID (or None for the first target) """ try: target = self._target(target_id=target_id) except: ...
def target_is_busy(self, target_id=0): """ Returns True or False indicating whether or not the specified target is busy. `target_id` is a target ID (or None for the first target) """ try: target = self._target(target_id=target_id) except: ...
[ "Returns", "True", "or", "False", "indicating", "whether", "or", "not", "the", "specified", "target", "is", "busy", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/dbg.py#L146-L157
[ "def", "target_is_busy", "(", "self", ",", "target_id", "=", "0", ")", ":", "try", ":", "target", "=", "self", ".", "_target", "(", "target_id", "=", "target_id", ")", "except", ":", "raise", "NoSuchTargetException", "(", ")", "return", "target", "[", "'...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
DebuggerAdaptor.remove_listener
Remove a listener.
voltron/dbg.py
def remove_listener(self, callback): """ Remove a listener. """ listeners = filter(lambda x: x['callback'] == callback, self.listeners) for l in listeners: self.listeners.remove(l)
def remove_listener(self, callback): """ Remove a listener. """ listeners = filter(lambda x: x['callback'] == callback, self.listeners) for l in listeners: self.listeners.remove(l)
[ "Remove", "a", "listener", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/dbg.py#L165-L171
[ "def", "remove_listener", "(", "self", ",", "callback", ")", ":", "listeners", "=", "filter", "(", "lambda", "x", ":", "x", "[", "'callback'", "]", "==", "callback", ",", "self", ".", "listeners", ")", "for", "l", "in", "listeners", ":", "self", ".", ...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
DebuggerAdaptor.disassemble_capstone
Disassemble with capstone.
voltron/dbg.py
def disassemble_capstone(self, target_id=0, address=None, count=None): """ Disassemble with capstone. """ target = self._target(target_id) if not address: pc_name, address = self.pc() mem = self.memory(address, count * 16, target_id=target_id) md = c...
def disassemble_capstone(self, target_id=0, address=None, count=None): """ Disassemble with capstone. """ target = self._target(target_id) if not address: pc_name, address = self.pc() mem = self.memory(address, count * 16, target_id=target_id) md = c...
[ "Disassemble", "with", "capstone", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/dbg.py#L203-L220
[ "def", "disassemble_capstone", "(", "self", ",", "target_id", "=", "0", ",", "address", "=", "None", ",", "count", "=", "None", ")", ":", "target", "=", "self", ".", "_target", "(", "target_id", ")", "if", "not", "address", ":", "pc_name", ",", "addres...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
api_request
Create an API request. `request_type` is the request type (string). This is used to look up a plugin, whose request class is instantiated and passed the remaining arguments passed to this function.
voltron/plugin.py
def api_request(request, *args, **kwargs): """ Create an API request. `request_type` is the request type (string). This is used to look up a plugin, whose request class is instantiated and passed the remaining arguments passed to this function. """ plugin = pm.api_plugin_for_request(request...
def api_request(request, *args, **kwargs): """ Create an API request. `request_type` is the request type (string). This is used to look up a plugin, whose request class is instantiated and passed the remaining arguments passed to this function. """ plugin = pm.api_plugin_for_request(request...
[ "Create", "an", "API", "request", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/plugin.py#L310-L323
[ "def", "api_request", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "plugin", "=", "pm", ".", "api_plugin_for_request", "(", "request", ")", "if", "plugin", "and", "plugin", ".", "request_class", ":", "req", "=", "plugin", ".", "...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
PluginManager.register_plugin
Register a new plugin with the PluginManager. `plugin` is a subclass of scruffy's Plugin class. This is called by __init__(), but may also be called by the debugger host to load a specific plugin at runtime.
voltron/plugin.py
def register_plugin(self, plugin): """ Register a new plugin with the PluginManager. `plugin` is a subclass of scruffy's Plugin class. This is called by __init__(), but may also be called by the debugger host to load a specific plugin at runtime. """ if hasattr(...
def register_plugin(self, plugin): """ Register a new plugin with the PluginManager. `plugin` is a subclass of scruffy's Plugin class. This is called by __init__(), but may also be called by the debugger host to load a specific plugin at runtime. """ if hasattr(...
[ "Register", "a", "new", "plugin", "with", "the", "PluginManager", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/plugin.py#L60-L89
[ "def", "register_plugin", "(", "self", ",", "plugin", ")", ":", "if", "hasattr", "(", "plugin", ",", "'initialise'", ")", ":", "plugin", ".", "initialise", "(", ")", "if", "self", ".", "valid_api_plugin", "(", "plugin", ")", ":", "log", ".", "debug", "...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
PluginManager.valid_api_plugin
Validate an API plugin, ensuring it is an API plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class.
voltron/plugin.py
def valid_api_plugin(self, plugin): """ Validate an API plugin, ensuring it is an API plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class. """ if (issubclass(plugin, APIPlugin) and hasattr(plugin, 'plugin_type')...
def valid_api_plugin(self, plugin): """ Validate an API plugin, ensuring it is an API plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class. """ if (issubclass(plugin, APIPlugin) and hasattr(plugin, 'plugin_type')...
[ "Validate", "an", "API", "plugin", "ensuring", "it", "is", "an", "API", "plugin", "and", "has", "the", "necessary", "fields", "present", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/plugin.py#L91-L104
[ "def", "valid_api_plugin", "(", "self", ",", "plugin", ")", ":", "if", "(", "issubclass", "(", "plugin", ",", "APIPlugin", ")", "and", "hasattr", "(", "plugin", ",", "'plugin_type'", ")", "and", "plugin", ".", "plugin_type", "==", "'api'", "and", "hasattr"...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
PluginManager.valid_debugger_plugin
Validate a debugger plugin, ensuring it is a debugger plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class.
voltron/plugin.py
def valid_debugger_plugin(self, plugin): """ Validate a debugger plugin, ensuring it is a debugger plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class. """ if (issubclass(plugin, DebuggerAdaptorPlugin) and hasattr(plu...
def valid_debugger_plugin(self, plugin): """ Validate a debugger plugin, ensuring it is a debugger plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class. """ if (issubclass(plugin, DebuggerAdaptorPlugin) and hasattr(plu...
[ "Validate", "a", "debugger", "plugin", "ensuring", "it", "is", "a", "debugger", "plugin", "and", "has", "the", "necessary", "fields", "present", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/plugin.py#L106-L117
[ "def", "valid_debugger_plugin", "(", "self", ",", "plugin", ")", ":", "if", "(", "issubclass", "(", "plugin", ",", "DebuggerAdaptorPlugin", ")", "and", "hasattr", "(", "plugin", ",", "'plugin_type'", ")", "and", "plugin", ".", "plugin_type", "==", "'debugger'"...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
PluginManager.valid_view_plugin
Validate a view plugin, ensuring it is a view plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class.
voltron/plugin.py
def valid_view_plugin(self, plugin): """ Validate a view plugin, ensuring it is a view plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class. """ if (issubclass(plugin, ViewPlugin) and hasattr(plugin, 'plugin_type'...
def valid_view_plugin(self, plugin): """ Validate a view plugin, ensuring it is a view plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class. """ if (issubclass(plugin, ViewPlugin) and hasattr(plugin, 'plugin_type'...
[ "Validate", "a", "view", "plugin", "ensuring", "it", "is", "a", "view", "plugin", "and", "has", "the", "necessary", "fields", "present", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/plugin.py#L119-L131
[ "def", "valid_view_plugin", "(", "self", ",", "plugin", ")", ":", "if", "(", "issubclass", "(", "plugin", ",", "ViewPlugin", ")", "and", "hasattr", "(", "plugin", ",", "'plugin_type'", ")", "and", "plugin", ".", "plugin_type", "==", "'view'", "and", "hasat...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
PluginManager.valid_web_plugin
Validate a web plugin, ensuring it is a web plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class.
voltron/plugin.py
def valid_web_plugin(self, plugin): """ Validate a web plugin, ensuring it is a web plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class. """ if (issubclass(plugin, WebPlugin) and hasattr(plugin, 'plugin_type') ...
def valid_web_plugin(self, plugin): """ Validate a web plugin, ensuring it is a web plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class. """ if (issubclass(plugin, WebPlugin) and hasattr(plugin, 'plugin_type') ...
[ "Validate", "a", "web", "plugin", "ensuring", "it", "is", "a", "web", "plugin", "and", "has", "the", "necessary", "fields", "present", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/plugin.py#L133-L144
[ "def", "valid_web_plugin", "(", "self", ",", "plugin", ")", ":", "if", "(", "issubclass", "(", "plugin", ",", "WebPlugin", ")", "and", "hasattr", "(", "plugin", ",", "'plugin_type'", ")", "and", "plugin", ".", "plugin_type", "==", "'web'", "and", "hasattr"...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
PluginManager.valid_command_plugin
Validate a command plugin, ensuring it is a command plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class.
voltron/plugin.py
def valid_command_plugin(self, plugin): """ Validate a command plugin, ensuring it is a command plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class. """ if (issubclass(plugin, CommandPlugin) and hasattr(plugin, 'plu...
def valid_command_plugin(self, plugin): """ Validate a command plugin, ensuring it is a command plugin and has the necessary fields present. `plugin` is a subclass of scruffy's Plugin class. """ if (issubclass(plugin, CommandPlugin) and hasattr(plugin, 'plu...
[ "Validate", "a", "command", "plugin", "ensuring", "it", "is", "a", "command", "plugin", "and", "has", "the", "necessary", "fields", "present", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/plugin.py#L146-L157
[ "def", "valid_command_plugin", "(", "self", ",", "plugin", ")", ":", "if", "(", "issubclass", "(", "plugin", ",", "CommandPlugin", ")", "and", "hasattr", "(", "plugin", ",", "'plugin_type'", ")", "and", "plugin", ".", "plugin_type", "==", "'command'", "and",...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
check_install
Try to detect the two most common installation errors: 1. Installing on macOS using a Homebrew version of Python 2. Installing on Linux using Python 2 when GDB is linked with Python 3
setup.py
def check_install(): """ Try to detect the two most common installation errors: 1. Installing on macOS using a Homebrew version of Python 2. Installing on Linux using Python 2 when GDB is linked with Python 3 """ if platform.system() == 'Darwin' and sys.executable != '/usr/bin/python': ...
def check_install(): """ Try to detect the two most common installation errors: 1. Installing on macOS using a Homebrew version of Python 2. Installing on Linux using Python 2 when GDB is linked with Python 3 """ if platform.system() == 'Darwin' and sys.executable != '/usr/bin/python': ...
[ "Try", "to", "detect", "the", "two", "most", "common", "installation", "errors", ":" ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/setup.py#L10-L51
[ "def", "check_install", "(", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "'Darwin'", "and", "sys", ".", "executable", "!=", "'/usr/bin/python'", ":", "print", "(", "\"*\"", "*", "79", ")", "print", "(", "textwrap", ".", "fill", "(", "\"W...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
TerminalView.run
Run the view event loop.
voltron/view.py
def run(self): """ Run the view event loop. """ def render(results=[], error=None): if len(results) and not results[0].timed_out: self.render(results) elif error: self.do_render(error=error) # start the client self....
def run(self): """ Run the view event loop. """ def render(results=[], error=None): if len(results) and not results[0].timed_out: self.render(results) elif error: self.do_render(error=error) # start the client self....
[ "Run", "the", "view", "event", "loop", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/view.py#L390-L412
[ "def", "run", "(", "self", ")", ":", "def", "render", "(", "results", "=", "[", "]", ",", "error", "=", "None", ")", ":", "if", "len", "(", "results", ")", "and", "not", "results", "[", "0", "]", ".", "timed_out", ":", "self", ".", "render", "(...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
TerminalView.handle_key
Handle a keypress. Concrete subclasses can implement this method if custom keypresses need to be handled other than for exit and scrolling.
voltron/view.py
def handle_key(self, key): """ Handle a keypress. Concrete subclasses can implement this method if custom keypresses need to be handled other than for exit and scrolling. """ try: func = None if key.is_sequence: try: fun...
def handle_key(self, key): """ Handle a keypress. Concrete subclasses can implement this method if custom keypresses need to be handled other than for exit and scrolling. """ try: func = None if key.is_sequence: try: fun...
[ "Handle", "a", "keypress", ".", "Concrete", "subclasses", "can", "implement", "this", "method", "if", "custom", "keypresses", "need", "to", "be", "handled", "other", "than", "for", "exit", "and", "scrolling", "." ]
snare/voltron
python
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/voltron/view.py#L414-L435
[ "def", "handle_key", "(", "self", ",", "key", ")", ":", "try", ":", "func", "=", "None", "if", "key", ".", "is_sequence", ":", "try", ":", "func", "=", "self", ".", "config", ".", "keymap", "[", "key", ".", "name", "]", "except", ":", "try", ":",...
4ee3cbe6f7c1e38303f5dc6114c48b60217253c3
train
Listener.new_cast_status
Handle reception of a new CastStatus.
pychromecast/controllers/multizone.py
def new_cast_status(self, cast_status): """Handle reception of a new CastStatus.""" casts = self._casts group_members = self._mz.members for member_uuid in group_members: if member_uuid not in casts: continue for listener in list(casts[member_uuid]...
def new_cast_status(self, cast_status): """Handle reception of a new CastStatus.""" casts = self._casts group_members = self._mz.members for member_uuid in group_members: if member_uuid not in casts: continue for listener in list(casts[member_uuid]...
[ "Handle", "reception", "of", "a", "new", "CastStatus", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/multizone.py#L38-L47
[ "def", "new_cast_status", "(", "self", ",", "cast_status", ")", ":", "casts", "=", "self", ".", "_casts", "group_members", "=", "self", ".", "_mz", ".", "members", "for", "member_uuid", "in", "group_members", ":", "if", "member_uuid", "not", "in", "casts", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
Listener.new_media_status
Handle reception of a new MediaStatus.
pychromecast/controllers/multizone.py
def new_media_status(self, media_status): """Handle reception of a new MediaStatus.""" casts = self._casts group_members = self._mz.members for member_uuid in group_members: if member_uuid not in casts: continue for listener in list(casts[member_uu...
def new_media_status(self, media_status): """Handle reception of a new MediaStatus.""" casts = self._casts group_members = self._mz.members for member_uuid in group_members: if member_uuid not in casts: continue for listener in list(casts[member_uu...
[ "Handle", "reception", "of", "a", "new", "MediaStatus", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/multizone.py#L49-L58
[ "def", "new_media_status", "(", "self", ",", "media_status", ")", ":", "casts", "=", "self", ".", "_casts", "group_members", "=", "self", ".", "_mz", ".", "members", "for", "member_uuid", "in", "group_members", ":", "if", "member_uuid", "not", "in", "casts",...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
Listener.new_connection_status
Handle reception of a new ConnectionStatus.
pychromecast/controllers/multizone.py
def new_connection_status(self, conn_status): """Handle reception of a new ConnectionStatus.""" if conn_status.status == CONNECTION_STATUS_CONNECTED: self._mz.update_members() if (conn_status.status == CONNECTION_STATUS_DISCONNECTED or conn_status.status == CONNECTION...
def new_connection_status(self, conn_status): """Handle reception of a new ConnectionStatus.""" if conn_status.status == CONNECTION_STATUS_CONNECTED: self._mz.update_members() if (conn_status.status == CONNECTION_STATUS_DISCONNECTED or conn_status.status == CONNECTION...
[ "Handle", "reception", "of", "a", "new", "ConnectionStatus", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/multizone.py#L60-L66
[ "def", "new_connection_status", "(", "self", ",", "conn_status", ")", ":", "if", "conn_status", ".", "status", "==", "CONNECTION_STATUS_CONNECTED", ":", "self", ".", "_mz", ".", "update_members", "(", ")", "if", "(", "conn_status", ".", "status", "==", "CONNEC...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
Listener.multizone_member_added
Handle added audio group member.
pychromecast/controllers/multizone.py
def multizone_member_added(self, member_uuid): """Handle added audio group member.""" casts = self._casts if member_uuid not in casts: casts[member_uuid] = {'listeners': [], 'groups': set()} casts[member_uuid]['groups'].add(self._group_uuid) ...
def multizone_member_added(self, member_uuid): """Handle added audio group member.""" casts = self._casts if member_uuid not in casts: casts[member_uuid] = {'listeners': [], 'groups': set()} casts[member_uuid]['groups'].add(self._group_uuid) ...
[ "Handle", "added", "audio", "group", "member", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/multizone.py#L68-L76
[ "def", "multizone_member_added", "(", "self", ",", "member_uuid", ")", ":", "casts", "=", "self", ".", "_casts", "if", "member_uuid", "not", "in", "casts", ":", "casts", "[", "member_uuid", "]", "=", "{", "'listeners'", ":", "[", "]", ",", "'groups'", ":...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
Listener.multizone_member_removed
Handle removed audio group member.
pychromecast/controllers/multizone.py
def multizone_member_removed(self, member_uuid): """Handle removed audio group member.""" casts = self._casts if member_uuid not in casts: casts[member_uuid] = {'listeners': [], 'groups': set()} casts[member_uuid]['groups'].discard(self._group_uuid) for listener in li...
def multizone_member_removed(self, member_uuid): """Handle removed audio group member.""" casts = self._casts if member_uuid not in casts: casts[member_uuid] = {'listeners': [], 'groups': set()} casts[member_uuid]['groups'].discard(self._group_uuid) for listener in li...
[ "Handle", "removed", "audio", "group", "member", "." ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/multizone.py#L78-L85
[ "def", "multizone_member_removed", "(", "self", ",", "member_uuid", ")", ":", "casts", "=", "self", ".", "_casts", "if", "member_uuid", "not", "in", "casts", ":", "casts", "[", "member_uuid", "]", "=", "{", "'listeners'", ":", "[", "]", ",", "'groups'", ...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
MultizoneManager.add_multizone
Start managing a group
pychromecast/controllers/multizone.py
def add_multizone(self, group_cast): """ Start managing a group """ self._groups[str(group_cast.uuid)] = { 'chromecast': group_cast, 'listener': Listener(group_cast, self._casts), 'members': set()}
def add_multizone(self, group_cast): """ Start managing a group """ self._groups[str(group_cast.uuid)] = { 'chromecast': group_cast, 'listener': Listener(group_cast, self._casts), 'members': set()}
[ "Start", "managing", "a", "group" ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/multizone.py#L100-L105
[ "def", "add_multizone", "(", "self", ",", "group_cast", ")", ":", "self", ".", "_groups", "[", "str", "(", "group_cast", ".", "uuid", ")", "]", "=", "{", "'chromecast'", ":", "group_cast", ",", "'listener'", ":", "Listener", "(", "group_cast", ",", "self...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6
train
MultizoneManager.remove_multizone
Stop managing a group
pychromecast/controllers/multizone.py
def remove_multizone(self, group_uuid): """ Stop managing a group """ group_uuid = str(group_uuid) group = self._groups.pop(group_uuid, None) # Inform all group members that they are no longer members if group is not None: group['listener']._mz.reset_members() # noqa...
def remove_multizone(self, group_uuid): """ Stop managing a group """ group_uuid = str(group_uuid) group = self._groups.pop(group_uuid, None) # Inform all group members that they are no longer members if group is not None: group['listener']._mz.reset_members() # noqa...
[ "Stop", "managing", "a", "group" ]
balloob/pychromecast
python
https://github.com/balloob/pychromecast/blob/831b09c4fed185a7bffe0ea330b7849d5f4e36b6/pychromecast/controllers/multizone.py#L107-L115
[ "def", "remove_multizone", "(", "self", ",", "group_uuid", ")", ":", "group_uuid", "=", "str", "(", "group_uuid", ")", "group", "=", "self", ".", "_groups", ".", "pop", "(", "group_uuid", ",", "None", ")", "# Inform all group members that they are no longer member...
831b09c4fed185a7bffe0ea330b7849d5f4e36b6