repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
roclark/sportsreference
sportsreference/nhl/schedule.py
Game.overtime
def overtime(self): """ Returns an ``int`` of the number of overtimes that were played during the game, or an int constant if the game went to a shootout. """ if self._overtime.lower() == 'ot': return 1 if self._overtime.lower() == 'so': return SHO...
python
def overtime(self): """ Returns an ``int`` of the number of overtimes that were played during the game, or an int constant if the game went to a shootout. """ if self._overtime.lower() == 'ot': return 1 if self._overtime.lower() == 'so': return SHO...
[ "def", "overtime", "(", "self", ")", ":", "if", "self", ".", "_overtime", ".", "lower", "(", ")", "==", "'ot'", ":", "return", "1", "if", "self", ".", "_overtime", ".", "lower", "(", ")", "==", "'so'", ":", "return", "SHOOTOUT", "if", "self", ".", ...
Returns an ``int`` of the number of overtimes that were played during the game, or an int constant if the game went to a shootout.
[ "Returns", "an", "int", "of", "the", "number", "of", "overtimes", "that", "were", "played", "during", "the", "game", "or", "an", "int", "constant", "if", "the", "game", "went", "to", "a", "shootout", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nhl/schedule.py#L284-L298
train
roclark/sportsreference
sportsreference/ncaab/schedule.py
Game.datetime
def datetime(self): """ Returns a datetime object to indicate the month, day, year, and time the requested game took place. """ date_string = '%s %s' % (self._date, self._time.upper()) date_string = re.sub(r'/.*', '', date_string) date_string = re.sub(r' ET', '', ...
python
def datetime(self): """ Returns a datetime object to indicate the month, day, year, and time the requested game took place. """ date_string = '%s %s' % (self._date, self._time.upper()) date_string = re.sub(r'/.*', '', date_string) date_string = re.sub(r' ET', '', ...
[ "def", "datetime", "(", "self", ")", ":", "date_string", "=", "'%s %s'", "%", "(", "self", ".", "_date", ",", "self", ".", "_time", ".", "upper", "(", ")", ")", "date_string", "=", "re", ".", "sub", "(", "r'/.*'", ",", "''", ",", "date_string", ")"...
Returns a datetime object to indicate the month, day, year, and time the requested game took place.
[ "Returns", "a", "datetime", "object", "to", "indicate", "the", "month", "day", "year", "and", "time", "the", "requested", "game", "took", "place", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/schedule.py#L195-L208
train
roclark/sportsreference
sportsreference/ncaab/schedule.py
Game.type
def type(self): """ Returns a ``string`` constant to indicate whether the game was played during the regular season or in the post season. """ if self._type.lower() == 'reg': return REGULAR_SEASON if self._type.lower() == 'ctourn': return CONFERENC...
python
def type(self): """ Returns a ``string`` constant to indicate whether the game was played during the regular season or in the post season. """ if self._type.lower() == 'reg': return REGULAR_SEASON if self._type.lower() == 'ctourn': return CONFERENC...
[ "def", "type", "(", "self", ")", ":", "if", "self", ".", "_type", ".", "lower", "(", ")", "==", "'reg'", ":", "return", "REGULAR_SEASON", "if", "self", ".", "_type", ".", "lower", "(", ")", "==", "'ctourn'", ":", "return", "CONFERENCE_TOURNAMENT", "if"...
Returns a ``string`` constant to indicate whether the game was played during the regular season or in the post season.
[ "Returns", "a", "string", "constant", "to", "indicate", "whether", "the", "game", "was", "played", "during", "the", "regular", "season", "or", "in", "the", "post", "season", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/schedule.py#L235-L251
train
roclark/sportsreference
sportsreference/ncaab/schedule.py
Game.location
def location(self): """ Returns a ``string`` constant to indicate whether the game was played at the team's home venue, the opponent's venue, or at a neutral site. """ if self._location == '': return HOME if self._location == 'N': return NEUTRAL ...
python
def location(self): """ Returns a ``string`` constant to indicate whether the game was played at the team's home venue, the opponent's venue, or at a neutral site. """ if self._location == '': return HOME if self._location == 'N': return NEUTRAL ...
[ "def", "location", "(", "self", ")", ":", "if", "self", ".", "_location", "==", "''", ":", "return", "HOME", "if", "self", ".", "_location", "==", "'N'", ":", "return", "NEUTRAL", "if", "self", ".", "_location", "==", "'@'", ":", "return", "AWAY" ]
Returns a ``string`` constant to indicate whether the game was played at the team's home venue, the opponent's venue, or at a neutral site.
[ "Returns", "a", "string", "constant", "to", "indicate", "whether", "the", "game", "was", "played", "at", "the", "team", "s", "home", "venue", "the", "opponent", "s", "venue", "or", "at", "a", "neutral", "site", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/schedule.py#L254-L264
train
roclark/sportsreference
sportsreference/ncaab/schedule.py
Game.opponent_name
def opponent_name(self): """ Returns a ``string`` of the opponent's name, such as the 'Purdue Boilermakers'. """ name = re.sub(r'\(\d+\)', '', self._opponent_name) name = name.replace(u'\xa0', '') return name
python
def opponent_name(self): """ Returns a ``string`` of the opponent's name, such as the 'Purdue Boilermakers'. """ name = re.sub(r'\(\d+\)', '', self._opponent_name) name = name.replace(u'\xa0', '') return name
[ "def", "opponent_name", "(", "self", ")", ":", "name", "=", "re", ".", "sub", "(", "r'\\(\\d+\\)'", ",", "''", ",", "self", ".", "_opponent_name", ")", "name", "=", "name", ".", "replace", "(", "u'\\xa0'", ",", "''", ")", "return", "name" ]
Returns a ``string`` of the opponent's name, such as the 'Purdue Boilermakers'.
[ "Returns", "a", "string", "of", "the", "opponent", "s", "name", "such", "as", "the", "Purdue", "Boilermakers", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/schedule.py#L275-L282
train
roclark/sportsreference
sportsreference/ncaab/schedule.py
Game.opponent_rank
def opponent_rank(self): """ Returns a ``string`` of the opponent's rank when the game was played and None if the team was unranked. """ rank = re.findall(r'\d+', self._opponent_name) if len(rank) > 0: return int(rank[0]) return None
python
def opponent_rank(self): """ Returns a ``string`` of the opponent's rank when the game was played and None if the team was unranked. """ rank = re.findall(r'\d+', self._opponent_name) if len(rank) > 0: return int(rank[0]) return None
[ "def", "opponent_rank", "(", "self", ")", ":", "rank", "=", "re", ".", "findall", "(", "r'\\d+'", ",", "self", ".", "_opponent_name", ")", "if", "len", "(", "rank", ")", ">", "0", ":", "return", "int", "(", "rank", "[", "0", "]", ")", "return", "...
Returns a ``string`` of the opponent's rank when the game was played and None if the team was unranked.
[ "Returns", "a", "string", "of", "the", "opponent", "s", "rank", "when", "the", "game", "was", "played", "and", "None", "if", "the", "team", "was", "unranked", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/schedule.py#L285-L293
train
roclark/sportsreference
sportsreference/ncaab/schedule.py
Game.overtimes
def overtimes(self): """ Returns an ``int`` of the number of overtimes that were played during the game and 0 if the game finished at the end of regulation time. """ if self._overtimes == '' or self._overtimes is None: return 0 if self._overtimes.lower() == 'o...
python
def overtimes(self): """ Returns an ``int`` of the number of overtimes that were played during the game and 0 if the game finished at the end of regulation time. """ if self._overtimes == '' or self._overtimes is None: return 0 if self._overtimes.lower() == 'o...
[ "def", "overtimes", "(", "self", ")", ":", "if", "self", ".", "_overtimes", "==", "''", "or", "self", ".", "_overtimes", "is", "None", ":", "return", "0", "if", "self", ".", "_overtimes", ".", "lower", "(", ")", "==", "'ot'", ":", "return", "1", "n...
Returns an ``int`` of the number of overtimes that were played during the game and 0 if the game finished at the end of regulation time.
[ "Returns", "an", "int", "of", "the", "number", "of", "overtimes", "that", "were", "played", "during", "the", "game", "and", "0", "if", "the", "game", "finished", "at", "the", "end", "of", "regulation", "time", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/schedule.py#L333-L346
train
roclark/sportsreference
sportsreference/nba/roster.py
Player._parse_nationality
def _parse_nationality(self, player_info): """ Parse the player's nationality. The player's nationality is denoted by a flag in the information section with a country code for each nation. The country code needs to pulled and then matched to find the player's home country. Once ...
python
def _parse_nationality(self, player_info): """ Parse the player's nationality. The player's nationality is denoted by a flag in the information section with a country code for each nation. The country code needs to pulled and then matched to find the player's home country. Once ...
[ "def", "_parse_nationality", "(", "self", ",", "player_info", ")", ":", "for", "span", "in", "player_info", "(", "'span'", ")", ".", "items", "(", ")", ":", "if", "'class=\"f-i'", "in", "str", "(", "span", ")", ":", "nationality", "=", "span", ".", "te...
Parse the player's nationality. The player's nationality is denoted by a flag in the information section with a country code for each nation. The country code needs to pulled and then matched to find the player's home country. Once found, the '_nationality' attribute is set for the play...
[ "Parse", "the", "player", "s", "nationality", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/roster.py#L312-L331
train
roclark/sportsreference
sportsreference/nba/roster.py
Player._parse_contract_headers
def _parse_contract_headers(self, table): """ Parse the years on the contract. The years are listed as the headers on the contract. The first header contains 'Team' which specifies the player's current team and should not be included in the years. Parameters ---...
python
def _parse_contract_headers(self, table): """ Parse the years on the contract. The years are listed as the headers on the contract. The first header contains 'Team' which specifies the player's current team and should not be included in the years. Parameters ---...
[ "def", "_parse_contract_headers", "(", "self", ",", "table", ")", ":", "years", "=", "[", "i", ".", "text", "(", ")", "for", "i", "in", "table", "(", "'th'", ")", ".", "items", "(", ")", "]", "years", ".", "remove", "(", "'Team'", ")", "return", ...
Parse the years on the contract. The years are listed as the headers on the contract. The first header contains 'Team' which specifies the player's current team and should not be included in the years. Parameters ---------- table : PyQuery object A PyQuery o...
[ "Parse", "the", "years", "on", "the", "contract", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/roster.py#L366-L387
train
roclark/sportsreference
sportsreference/nba/roster.py
Player._parse_contract_wages
def _parse_contract_wages(self, table): """ Parse the wages on the contract. The wages are listed as the data points in the contract table. Any values that don't have a value which starts with a '$' sign are likely not valid and should be dropped. Parameters ---...
python
def _parse_contract_wages(self, table): """ Parse the wages on the contract. The wages are listed as the data points in the contract table. Any values that don't have a value which starts with a '$' sign are likely not valid and should be dropped. Parameters ---...
[ "def", "_parse_contract_wages", "(", "self", ",", "table", ")", ":", "wages", "=", "[", "i", ".", "text", "(", ")", "if", "i", ".", "text", "(", ")", ".", "startswith", "(", "'$'", ")", "else", "''", "for", "i", "in", "table", "(", "'td'", ")", ...
Parse the wages on the contract. The wages are listed as the data points in the contract table. Any values that don't have a value which starts with a '$' sign are likely not valid and should be dropped. Parameters ---------- table : PyQuery object A PyQuery...
[ "Parse", "the", "wages", "on", "the", "contract", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/roster.py#L389-L411
train
roclark/sportsreference
sportsreference/nba/roster.py
Player._combine_contract
def _combine_contract(self, years, wages): """ Combine the contract wages and year. Match the wages with the year and add to a dictionary representing the player's contract. Parameters ---------- years : list A list where each element is a string den...
python
def _combine_contract(self, years, wages): """ Combine the contract wages and year. Match the wages with the year and add to a dictionary representing the player's contract. Parameters ---------- years : list A list where each element is a string den...
[ "def", "_combine_contract", "(", "self", ",", "years", ",", "wages", ")", ":", "contract", "=", "{", "}", "for", "i", "in", "range", "(", "len", "(", "years", ")", ")", ":", "contract", "[", "years", "[", "i", "]", "]", "=", "wages", "[", "i", ...
Combine the contract wages and year. Match the wages with the year and add to a dictionary representing the player's contract. Parameters ---------- years : list A list where each element is a string denoting the season, such as '2017-18'. wages ...
[ "Combine", "the", "contract", "wages", "and", "year", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/roster.py#L413-L440
train
roclark/sportsreference
sportsreference/nba/roster.py
Player._find_initial_index
def _find_initial_index(self): """ Find the index of career stats. When the Player class is instantiated, the default stats to pull are the player's career stats. Upon being called, the index of the 'Career' element should be the index value. """ index = 0 ...
python
def _find_initial_index(self): """ Find the index of career stats. When the Player class is instantiated, the default stats to pull are the player's career stats. Upon being called, the index of the 'Career' element should be the index value. """ index = 0 ...
[ "def", "_find_initial_index", "(", "self", ")", ":", "index", "=", "0", "for", "season", "in", "self", ".", "_season", ":", "if", "season", "==", "'Career'", ":", "self", ".", "_index", "=", "index", "break", "index", "+=", "1" ]
Find the index of career stats. When the Player class is instantiated, the default stats to pull are the player's career stats. Upon being called, the index of the 'Career' element should be the index value.
[ "Find", "the", "index", "of", "career", "stats", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/roster.py#L495-L508
train
roclark/sportsreference
sportsreference/ncaab/roster.py
Player._parse_player_position
def _parse_player_position(self, player_info): """ Parse the player's position. The player's position isn't contained within a unique tag and the player's meta information should be iterated through until 'Position' is found as it contains the desired text. Parameters ...
python
def _parse_player_position(self, player_info): """ Parse the player's position. The player's position isn't contained within a unique tag and the player's meta information should be iterated through until 'Position' is found as it contains the desired text. Parameters ...
[ "def", "_parse_player_position", "(", "self", ",", "player_info", ")", ":", "for", "section", "in", "player_info", "(", "'div#meta p'", ")", ".", "items", "(", ")", ":", "if", "'Position'", "in", "str", "(", "section", ")", ":", "position", "=", "section",...
Parse the player's position. The player's position isn't contained within a unique tag and the player's meta information should be iterated through until 'Position' is found as it contains the desired text. Parameters ---------- player_info : PyQuery object ...
[ "Parse", "the", "player", "s", "position", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/roster.py#L258-L276
train
roclark/sportsreference
sportsreference/ncaab/roster.py
Player._parse_conference
def _parse_conference(self, stats): """ Parse the conference abbreviation for the player's team. The conference abbreviation is embedded within the conference name tag and should be special-parsed to extract it. Parameters ---------- stats : PyQuery object ...
python
def _parse_conference(self, stats): """ Parse the conference abbreviation for the player's team. The conference abbreviation is embedded within the conference name tag and should be special-parsed to extract it. Parameters ---------- stats : PyQuery object ...
[ "def", "_parse_conference", "(", "self", ",", "stats", ")", ":", "conference_tag", "=", "stats", "(", "PLAYER_SCHEME", "[", "'conference'", "]", ")", "conference", "=", "re", ".", "sub", "(", "r'.*/cbb/conferences/'", ",", "''", ",", "str", "(", "conference_...
Parse the conference abbreviation for the player's team. The conference abbreviation is embedded within the conference name tag and should be special-parsed to extract it. Parameters ---------- stats : PyQuery object A PyQuery object containing the HTML from the pla...
[ "Parse", "the", "conference", "abbreviation", "for", "the", "player", "s", "team", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/roster.py#L278-L300
train
roclark/sportsreference
sportsreference/ncaab/roster.py
Player._parse_team_abbreviation
def _parse_team_abbreviation(self, stats): """ Parse the team abbreviation. The team abbreviation is embedded within the team name tag and should be special-parsed to extract it. Parameters ---------- stats : PyQuery object A PyQuery object containin...
python
def _parse_team_abbreviation(self, stats): """ Parse the team abbreviation. The team abbreviation is embedded within the team name tag and should be special-parsed to extract it. Parameters ---------- stats : PyQuery object A PyQuery object containin...
[ "def", "_parse_team_abbreviation", "(", "self", ",", "stats", ")", ":", "team_tag", "=", "stats", "(", "PLAYER_SCHEME", "[", "'team_abbreviation'", "]", ")", "team", "=", "re", ".", "sub", "(", "r'.*/cbb/schools/'", ",", "''", ",", "str", "(", "team_tag", ...
Parse the team abbreviation. The team abbreviation is embedded within the team name tag and should be special-parsed to extract it. Parameters ---------- stats : PyQuery object A PyQuery object containing the HTML from the player's stats page. Returns ...
[ "Parse", "the", "team", "abbreviation", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/roster.py#L302-L323
train
roclark/sportsreference
sportsreference/nhl/player.py
AbstractPlayer._parse_player_data
def _parse_player_data(self, player_data): """ Parse all player information and set attributes. Iterate through each class attribute to parse the data from the HTML page and set the attribute value with the result. Parameters ---------- player_data : dictionary ...
python
def _parse_player_data(self, player_data): """ Parse all player information and set attributes. Iterate through each class attribute to parse the data from the HTML page and set the attribute value with the result. Parameters ---------- player_data : dictionary ...
[ "def", "_parse_player_data", "(", "self", ",", "player_data", ")", ":", "for", "field", "in", "self", ".", "__dict__", ":", "short_field", "=", "str", "(", "field", ")", "[", "1", ":", "]", "if", "short_field", "==", "'player_id'", "or", "short_field", "...
Parse all player information and set attributes. Iterate through each class attribute to parse the data from the HTML page and set the attribute value with the result. Parameters ---------- player_data : dictionary or string If this class is inherited from the ``Pla...
[ "Parse", "all", "player", "information", "and", "set", "attributes", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nhl/player.py#L127-L164
train
roclark/sportsreference
sportsreference/ncaab/boxscore.py
Boxscore._parse_ranking
def _parse_ranking(self, field, boxscore): """ Parse each team's rank if applicable. Retrieve the team's rank according to the rankings published each week. The ranking for the week is only located in the scores section at the top of the page and not in the actual boxscore infor...
python
def _parse_ranking(self, field, boxscore): """ Parse each team's rank if applicable. Retrieve the team's rank according to the rankings published each week. The ranking for the week is only located in the scores section at the top of the page and not in the actual boxscore infor...
[ "def", "_parse_ranking", "(", "self", ",", "field", ",", "boxscore", ")", ":", "ranking", "=", "None", "index", "=", "BOXSCORE_ELEMENT_INDEX", "[", "field", "]", "teams_boxscore", "=", "boxscore", "(", "BOXSCORE_SCHEME", "[", "field", "]", ")", "if", "str", ...
Parse each team's rank if applicable. Retrieve the team's rank according to the rankings published each week. The ranking for the week is only located in the scores section at the top of the page and not in the actual boxscore information. The rank is after the team name inside a parent...
[ "Parse", "each", "team", "s", "rank", "if", "applicable", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/boxscore.py#L311-L348
train
roclark/sportsreference
sportsreference/ncaab/boxscore.py
Boxscore._parse_record
def _parse_record(self, field, boxscore, index): """ Parse each team's record. Find the record for both the home and away teams which are listed above the basic boxscore stats tables. Depending on whether or not the advanced stats table is included on the page (generally only fo...
python
def _parse_record(self, field, boxscore, index): """ Parse each team's record. Find the record for both the home and away teams which are listed above the basic boxscore stats tables. Depending on whether or not the advanced stats table is included on the page (generally only fo...
[ "def", "_parse_record", "(", "self", ",", "field", ",", "boxscore", ",", "index", ")", ":", "records", "=", "boxscore", "(", "BOXSCORE_SCHEME", "[", "field", "]", ")", ".", "items", "(", ")", "records", "=", "[", "x", ".", "text", "(", ")", "for", ...
Parse each team's record. Find the record for both the home and away teams which are listed above the basic boxscore stats tables. Depending on whether or not the advanced stats table is included on the page (generally only for more recent matchups), a blank header is added to the list ...
[ "Parse", "each", "team", "s", "record", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/boxscore.py#L350-L378
train
roclark/sportsreference
sportsreference/ncaab/boxscore.py
Boxscore.winning_name
def winning_name(self): """ Returns a ``string`` of the winning team's name, such as 'Purdue Boilermakers'. """ if self.winner == HOME: if 'cbb/schools' not in str(self._home_name): return str(self._home_name) return self._home_name.text() ...
python
def winning_name(self): """ Returns a ``string`` of the winning team's name, such as 'Purdue Boilermakers'. """ if self.winner == HOME: if 'cbb/schools' not in str(self._home_name): return str(self._home_name) return self._home_name.text() ...
[ "def", "winning_name", "(", "self", ")", ":", "if", "self", ".", "winner", "==", "HOME", ":", "if", "'cbb/schools'", "not", "in", "str", "(", "self", ".", "_home_name", ")", ":", "return", "str", "(", "self", ".", "_home_name", ")", "return", "self", ...
Returns a ``string`` of the winning team's name, such as 'Purdue Boilermakers'.
[ "Returns", "a", "string", "of", "the", "winning", "team", "s", "name", "such", "as", "Purdue", "Boilermakers", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/boxscore.py#L796-L807
train
roclark/sportsreference
sportsreference/ncaab/boxscore.py
Boxscore.losing_name
def losing_name(self): """ Returns a ``string`` of the losing team's name, such as 'Indiana' Hoosiers'. """ if self.winner == HOME: if 'cbb/schools' not in str(self._away_name): return str(self._away_name) return self._away_name.text() ...
python
def losing_name(self): """ Returns a ``string`` of the losing team's name, such as 'Indiana' Hoosiers'. """ if self.winner == HOME: if 'cbb/schools' not in str(self._away_name): return str(self._away_name) return self._away_name.text() ...
[ "def", "losing_name", "(", "self", ")", ":", "if", "self", ".", "winner", "==", "HOME", ":", "if", "'cbb/schools'", "not", "in", "str", "(", "self", ".", "_away_name", ")", ":", "return", "str", "(", "self", ".", "_away_name", ")", "return", "self", ...
Returns a ``string`` of the losing team's name, such as 'Indiana' Hoosiers'.
[ "Returns", "a", "string", "of", "the", "losing", "team", "s", "name", "such", "as", "Indiana", "Hoosiers", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/boxscore.py#L824-L835
train
roclark/sportsreference
sportsreference/ncaab/boxscore.py
Boxscore.away_win_percentage
def away_win_percentage(self): """ Returns a ``float`` of the percentage of games the away team has won after the conclusion of the game. Percentage ranges from 0-1. """ try: result = float(self.away_wins) / \ float(self.away_wins + self.away_loss...
python
def away_win_percentage(self): """ Returns a ``float`` of the percentage of games the away team has won after the conclusion of the game. Percentage ranges from 0-1. """ try: result = float(self.away_wins) / \ float(self.away_wins + self.away_loss...
[ "def", "away_win_percentage", "(", "self", ")", ":", "try", ":", "result", "=", "float", "(", "self", ".", "away_wins", ")", "/", "float", "(", "self", ".", "away_wins", "+", "self", ".", "away_losses", ")", "return", "round", "(", "result", ",", "3", ...
Returns a ``float`` of the percentage of games the away team has won after the conclusion of the game. Percentage ranges from 0-1.
[ "Returns", "a", "float", "of", "the", "percentage", "of", "games", "the", "away", "team", "has", "won", "after", "the", "conclusion", "of", "the", "game", ".", "Percentage", "ranges", "from", "0", "-", "1", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/boxscore.py#L868-L878
train
roclark/sportsreference
sportsreference/ncaab/boxscore.py
Boxscore.away_wins
def away_wins(self): """ Returns an ``int`` of the number of games the team has won after the conclusion of the game. """ try: wins, losses = re.findall(r'\d+', self._away_record) return wins except (ValueError, TypeError): return 0
python
def away_wins(self): """ Returns an ``int`` of the number of games the team has won after the conclusion of the game. """ try: wins, losses = re.findall(r'\d+', self._away_record) return wins except (ValueError, TypeError): return 0
[ "def", "away_wins", "(", "self", ")", ":", "try", ":", "wins", ",", "losses", "=", "re", ".", "findall", "(", "r'\\d+'", ",", "self", ".", "_away_record", ")", "return", "wins", "except", "(", "ValueError", ",", "TypeError", ")", ":", "return", "0" ]
Returns an ``int`` of the number of games the team has won after the conclusion of the game.
[ "Returns", "an", "int", "of", "the", "number", "of", "games", "the", "team", "has", "won", "after", "the", "conclusion", "of", "the", "game", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/boxscore.py#L881-L890
train
roclark/sportsreference
sportsreference/ncaab/boxscore.py
Boxscore.home_win_percentage
def home_win_percentage(self): """ Returns a ``float`` of the percentage of games the home team has won after the conclusion of the game. Percentage ranges from 0-1. """ try: result = float(self.home_wins) / \ float(self.home_wins + self.home_loss...
python
def home_win_percentage(self): """ Returns a ``float`` of the percentage of games the home team has won after the conclusion of the game. Percentage ranges from 0-1. """ try: result = float(self.home_wins) / \ float(self.home_wins + self.home_loss...
[ "def", "home_win_percentage", "(", "self", ")", ":", "try", ":", "result", "=", "float", "(", "self", ".", "home_wins", ")", "/", "float", "(", "self", ".", "home_wins", "+", "self", ".", "home_losses", ")", "return", "round", "(", "result", ",", "3", ...
Returns a ``float`` of the percentage of games the home team has won after the conclusion of the game. Percentage ranges from 0-1.
[ "Returns", "a", "float", "of", "the", "percentage", "of", "games", "the", "home", "team", "has", "won", "after", "the", "conclusion", "of", "the", "game", ".", "Percentage", "ranges", "from", "0", "-", "1", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/boxscore.py#L1191-L1201
train
roclark/sportsreference
sportsreference/ncaab/boxscore.py
Boxscores._get_rank
def _get_rank(self, team): """ Find the team's rank when applicable. If a team is ranked, it will showup in a separate <span> tag with the actual rank embedded between parentheses. When a team is ranked, the integer value representing their ranking should be returned. For teams ...
python
def _get_rank(self, team): """ Find the team's rank when applicable. If a team is ranked, it will showup in a separate <span> tag with the actual rank embedded between parentheses. When a team is ranked, the integer value representing their ranking should be returned. For teams ...
[ "def", "_get_rank", "(", "self", ",", "team", ")", ":", "rank", "=", "None", "rank_field", "=", "team", "(", "'span[class=\"pollrank\"]'", ")", "if", "len", "(", "rank_field", ")", ">", "0", ":", "rank", "=", "re", ".", "findall", "(", "r'\\(\\d+\\)'", ...
Find the team's rank when applicable. If a team is ranked, it will showup in a separate <span> tag with the actual rank embedded between parentheses. When a team is ranked, the integer value representing their ranking should be returned. For teams that are not ranked, None should be ret...
[ "Find", "the", "team", "s", "rank", "when", "applicable", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/boxscore.py#L1717-L1742
train
roclark/sportsreference
sportsreference/ncaab/boxscore.py
Boxscores._get_team_results
def _get_team_results(self, away_name, away_abbr, away_score, home_name, home_abbr, home_score): """ Determine the winner and loser of the game. If the game has been completed and sports-reference has been updated with the score, determine the winner and loser ...
python
def _get_team_results(self, away_name, away_abbr, away_score, home_name, home_abbr, home_score): """ Determine the winner and loser of the game. If the game has been completed and sports-reference has been updated with the score, determine the winner and loser ...
[ "def", "_get_team_results", "(", "self", ",", "away_name", ",", "away_abbr", ",", "away_score", ",", "home_name", ",", "home_abbr", ",", "home_score", ")", ":", "if", "not", "away_score", "or", "not", "home_score", ":", "return", "None", ",", "None", "if", ...
Determine the winner and loser of the game. If the game has been completed and sports-reference has been updated with the score, determine the winner and loser and return their respective names and abbreviations. Parameters ---------- away_name : string The ...
[ "Determine", "the", "winner", "and", "loser", "of", "the", "game", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/boxscore.py#L1793-L1832
train
roclark/sportsreference
sportsreference/ncaab/teams.py
Team.two_point_field_goal_percentage
def two_point_field_goal_percentage(self): """ Returns a ``float`` of the number of two point field goals made divided by the number of two point field goal attempts. Percentage ranges from 0-1. """ try: result = float(self.two_point_field_goals) / \ ...
python
def two_point_field_goal_percentage(self): """ Returns a ``float`` of the number of two point field goals made divided by the number of two point field goal attempts. Percentage ranges from 0-1. """ try: result = float(self.two_point_field_goals) / \ ...
[ "def", "two_point_field_goal_percentage", "(", "self", ")", ":", "try", ":", "result", "=", "float", "(", "self", ".", "two_point_field_goals", ")", "/", "float", "(", "self", ".", "two_point_field_goal_attempts", ")", "return", "round", "(", "result", ",", "3...
Returns a ``float`` of the number of two point field goals made divided by the number of two point field goal attempts. Percentage ranges from 0-1.
[ "Returns", "a", "float", "of", "the", "number", "of", "two", "point", "field", "goals", "made", "divided", "by", "the", "number", "of", "two", "point", "field", "goal", "attempts", ".", "Percentage", "ranges", "from", "0", "-", "1", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/teams.py#L465-L476
train
roclark/sportsreference
sportsreference/ncaab/teams.py
Team.opp_two_point_field_goal_percentage
def opp_two_point_field_goal_percentage(self): """ Returns a ``float`` of the number of two point field goals made divided by the number of two point field goal attempts by opponents. Percentage ranges from 0-1. """ try: result = float(self.opp_two_point_field...
python
def opp_two_point_field_goal_percentage(self): """ Returns a ``float`` of the number of two point field goals made divided by the number of two point field goal attempts by opponents. Percentage ranges from 0-1. """ try: result = float(self.opp_two_point_field...
[ "def", "opp_two_point_field_goal_percentage", "(", "self", ")", ":", "try", ":", "result", "=", "float", "(", "self", ".", "opp_two_point_field_goals", ")", "/", "float", "(", "self", ".", "opp_two_point_field_goal_attempts", ")", "return", "round", "(", "result",...
Returns a ``float`` of the number of two point field goals made divided by the number of two point field goal attempts by opponents. Percentage ranges from 0-1.
[ "Returns", "a", "float", "of", "the", "number", "of", "two", "point", "field", "goals", "made", "divided", "by", "the", "number", "of", "two", "point", "field", "goal", "attempts", "by", "opponents", ".", "Percentage", "ranges", "from", "0", "-", "1", "....
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/teams.py#L632-L643
train
roclark/sportsreference
sportsreference/ncaab/teams.py
Teams._add_stats_data
def _add_stats_data(self, teams_list, team_data_dict): """ Add a team's stats row to a dictionary. Pass table contents and a stats dictionary of all teams to accumulate all stats for each team in a single variable. Parameters ---------- teams_list : generator ...
python
def _add_stats_data(self, teams_list, team_data_dict): """ Add a team's stats row to a dictionary. Pass table contents and a stats dictionary of all teams to accumulate all stats for each team in a single variable. Parameters ---------- teams_list : generator ...
[ "def", "_add_stats_data", "(", "self", ",", "teams_list", ",", "team_data_dict", ")", ":", "for", "team_data", "in", "teams_list", ":", "if", "'class=\"over_header thead\"'", "in", "str", "(", "team_data", ")", "or", "'class=\"thead\"'", "in", "str", "(", "team_...
Add a team's stats row to a dictionary. Pass table contents and a stats dictionary of all teams to accumulate all stats for each team in a single variable. Parameters ---------- teams_list : generator A generator of all row items in a given table. team_data_...
[ "Add", "a", "team", "s", "stats", "row", "to", "a", "dictionary", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/teams.py#L1061-L1094
train
roclark/sportsreference
sportsreference/ncaaf/conferences.py
Conference._get_team_abbreviation
def _get_team_abbreviation(self, team): """ Retrieve team's abbreviation. The team's abbreviation is embedded within the 'school_name' tag and requires special parsing as it is located in the middle of a URI. The abbreviation is returned for the requested school. Parame...
python
def _get_team_abbreviation(self, team): """ Retrieve team's abbreviation. The team's abbreviation is embedded within the 'school_name' tag and requires special parsing as it is located in the middle of a URI. The abbreviation is returned for the requested school. Parame...
[ "def", "_get_team_abbreviation", "(", "self", ",", "team", ")", ":", "name_tag", "=", "team", "(", "'th[data-stat=\"school_name\"] a'", ")", "team_abbreviation", "=", "re", ".", "sub", "(", "r'.*/cfb/schools/'", ",", "''", ",", "str", "(", "name_tag", ")", ")"...
Retrieve team's abbreviation. The team's abbreviation is embedded within the 'school_name' tag and requires special parsing as it is located in the middle of a URI. The abbreviation is returned for the requested school. Parameters ---------- team : PyQuery object ...
[ "Retrieve", "team", "s", "abbreviation", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/conferences.py#L49-L71
train
roclark/sportsreference
sportsreference/ncaaf/conferences.py
Conference._find_conference_teams
def _find_conference_teams(self, conference_abbreviation, year): """ Retrieve the teams in the conference for the requested season. Find and retrieve all teams that participated in a conference for a given season. The name and abbreviation for each team are parsed and recorded t...
python
def _find_conference_teams(self, conference_abbreviation, year): """ Retrieve the teams in the conference for the requested season. Find and retrieve all teams that participated in a conference for a given season. The name and abbreviation for each team are parsed and recorded t...
[ "def", "_find_conference_teams", "(", "self", ",", "conference_abbreviation", ",", "year", ")", ":", "if", "not", "year", ":", "year", "=", "utils", ".", "_find_year_for_season", "(", "'ncaaf'", ")", "page", "=", "self", ".", "_pull_conference_page", "(", "con...
Retrieve the teams in the conference for the requested season. Find and retrieve all teams that participated in a conference for a given season. The name and abbreviation for each team are parsed and recorded to enable easy queries of conference schools.. Parameters ---------- ...
[ "Retrieve", "the", "teams", "in", "the", "conference", "for", "the", "requested", "season", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/conferences.py#L73-L103
train
roclark/sportsreference
sportsreference/ncaaf/conferences.py
Conferences._get_conference_id
def _get_conference_id(self, conference): """ Get the conference abbreviation, such as 'big-12'. The conference abbreviation is embedded within the Conference Name tag and requires special parsing to extract. The abbreviation is returned as a string. Parameters ...
python
def _get_conference_id(self, conference): """ Get the conference abbreviation, such as 'big-12'. The conference abbreviation is embedded within the Conference Name tag and requires special parsing to extract. The abbreviation is returned as a string. Parameters ...
[ "def", "_get_conference_id", "(", "self", ",", "conference", ")", ":", "name_tag", "=", "conference", "(", "'td[data-stat=\"conf_name\"] a'", ")", "conference_id", "=", "re", ".", "sub", "(", "r'.*/cfb/conferences/'", ",", "''", ",", "str", "(", "name_tag", ")",...
Get the conference abbreviation, such as 'big-12'. The conference abbreviation is embedded within the Conference Name tag and requires special parsing to extract. The abbreviation is returned as a string. Parameters ---------- conference : PyQuery object A P...
[ "Get", "the", "conference", "abbreviation", "such", "as", "big", "-", "12", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/conferences.py#L159-L181
train
roclark/sportsreference
sportsreference/ncaaf/conferences.py
Conferences._find_conferences
def _find_conferences(self, year): """ Retrieve the conferences and teams for the requested season. Find and retrieve all conferences for a given season and parse all of the teams that participated in the conference during that year. Conference information includes abbreviation ...
python
def _find_conferences(self, year): """ Retrieve the conferences and teams for the requested season. Find and retrieve all conferences for a given season and parse all of the teams that participated in the conference during that year. Conference information includes abbreviation ...
[ "def", "_find_conferences", "(", "self", ",", "year", ")", ":", "if", "not", "year", ":", "year", "=", "utils", ".", "_find_year_for_season", "(", "'ncaaf'", ")", "page", "=", "self", ".", "_pull_conference_page", "(", "year", ")", "if", "not", "page", "...
Retrieve the conferences and teams for the requested season. Find and retrieve all conferences for a given season and parse all of the teams that participated in the conference during that year. Conference information includes abbreviation and full name for the conference as well as the...
[ "Retrieve", "the", "conferences", "and", "teams", "for", "the", "requested", "season", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/conferences.py#L183-L216
train
roclark/sportsreference
sportsreference/nfl/schedule.py
Game.week
def week(self): """ Returns an ``int`` of the week number in the season, such as 1 for the first week of the regular season. """ if self._week.lower() == 'wild card': return WILD_CARD if self._week.lower() == 'division': return DIVISION if ...
python
def week(self): """ Returns an ``int`` of the week number in the season, such as 1 for the first week of the regular season. """ if self._week.lower() == 'wild card': return WILD_CARD if self._week.lower() == 'division': return DIVISION if ...
[ "def", "week", "(", "self", ")", ":", "if", "self", ".", "_week", ".", "lower", "(", ")", "==", "'wild card'", ":", "return", "WILD_CARD", "if", "self", ".", "_week", ".", "lower", "(", ")", "==", "'division'", ":", "return", "DIVISION", "if", "self"...
Returns an ``int`` of the week number in the season, such as 1 for the first week of the regular season.
[ "Returns", "an", "int", "of", "the", "week", "number", "in", "the", "season", "such", "as", "1", "for", "the", "first", "week", "of", "the", "regular", "season", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/schedule.py#L216-L229
train
roclark/sportsreference
sportsreference/nfl/schedule.py
Game.datetime
def datetime(self): """ Returns a datetime object representing the date the game was played. """ date_string = '%s %s %s' % (self._day, self._date, self._year) return datetime.strptime(date_string, '%a %B %d ...
python
def datetime(self): """ Returns a datetime object representing the date the game was played. """ date_string = '%s %s %s' % (self._day, self._date, self._year) return datetime.strptime(date_string, '%a %B %d ...
[ "def", "datetime", "(", "self", ")", ":", "date_string", "=", "'%s %s %s'", "%", "(", "self", ".", "_day", ",", "self", ".", "_date", ",", "self", ".", "_year", ")", "return", "datetime", ".", "strptime", "(", "date_string", ",", "'%a %B %d %Y'", ")" ]
Returns a datetime object representing the date the game was played.
[ "Returns", "a", "datetime", "object", "representing", "the", "date", "the", "game", "was", "played", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/schedule.py#L272-L279
train
roclark/sportsreference
sportsreference/nfl/schedule.py
Schedule._add_games_to_schedule
def _add_games_to_schedule(self, schedule, game_type, year): """ Add games instances to schedule. Create a Game instance for every applicable game in the season and append the instance to the '_game' property. Parameters ---------- schedule : PyQuery object ...
python
def _add_games_to_schedule(self, schedule, game_type, year): """ Add games instances to schedule. Create a Game instance for every applicable game in the season and append the instance to the '_game' property. Parameters ---------- schedule : PyQuery object ...
[ "def", "_add_games_to_schedule", "(", "self", ",", "schedule", ",", "game_type", ",", "year", ")", ":", "for", "item", "in", "schedule", ":", "game", "=", "Game", "(", "item", ",", "game_type", ",", "year", ")", "self", ".", "_games", ".", "append", "(...
Add games instances to schedule. Create a Game instance for every applicable game in the season and append the instance to the '_game' property. Parameters ---------- schedule : PyQuery object A PyQuery object pertaining to a team's schedule table. game_type...
[ "Add", "games", "instances", "to", "schedule", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/schedule.py#L623-L642
train
roclark/sportsreference
sportsreference/nba/boxscore.py
BoxscorePlayer.minutes_played
def minutes_played(self): """ Returns a ``float`` of the number of game minutes the player was on the court for. """ if self._minutes_played[self._index]: minutes, seconds = self._minutes_played[self._index].split(':') minutes = float(minutes) + float(seco...
python
def minutes_played(self): """ Returns a ``float`` of the number of game minutes the player was on the court for. """ if self._minutes_played[self._index]: minutes, seconds = self._minutes_played[self._index].split(':') minutes = float(minutes) + float(seco...
[ "def", "minutes_played", "(", "self", ")", ":", "if", "self", ".", "_minutes_played", "[", "self", ".", "_index", "]", ":", "minutes", ",", "seconds", "=", "self", ".", "_minutes_played", "[", "self", ".", "_index", "]", ".", "split", "(", "':'", ")", ...
Returns a ``float`` of the number of game minutes the player was on the court for.
[ "Returns", "a", "float", "of", "the", "number", "of", "game", "minutes", "the", "player", "was", "on", "the", "court", "for", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/boxscore.py#L110-L119
train
roclark/sportsreference
sportsreference/nba/boxscore.py
BoxscorePlayer.two_pointers
def two_pointers(self): """ Returns an ``int`` of the total number of two point field goals the player made. """ if self.field_goals and self.three_pointers: return int(self.field_goals - self.three_pointers) # Occurs when the player didn't make any three poin...
python
def two_pointers(self): """ Returns an ``int`` of the total number of two point field goals the player made. """ if self.field_goals and self.three_pointers: return int(self.field_goals - self.three_pointers) # Occurs when the player didn't make any three poin...
[ "def", "two_pointers", "(", "self", ")", ":", "if", "self", ".", "field_goals", "and", "self", ".", "three_pointers", ":", "return", "int", "(", "self", ".", "field_goals", "-", "self", ".", "three_pointers", ")", "if", "self", ".", "field_goals", ":", "...
Returns an ``int`` of the total number of two point field goals the player made.
[ "Returns", "an", "int", "of", "the", "total", "number", "of", "two", "point", "field", "goals", "the", "player", "made", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/boxscore.py#L122-L136
train
roclark/sportsreference
sportsreference/nba/boxscore.py
BoxscorePlayer.two_point_attempts
def two_point_attempts(self): """ Returns an ``int`` of the total number of two point field goals the player attempted during the season. """ if self.field_goal_attempts and self.three_point_attempts: return int(self.field_goal_attempts - self.three_point_attempts) ...
python
def two_point_attempts(self): """ Returns an ``int`` of the total number of two point field goals the player attempted during the season. """ if self.field_goal_attempts and self.three_point_attempts: return int(self.field_goal_attempts - self.three_point_attempts) ...
[ "def", "two_point_attempts", "(", "self", ")", ":", "if", "self", ".", "field_goal_attempts", "and", "self", ".", "three_point_attempts", ":", "return", "int", "(", "self", ".", "field_goal_attempts", "-", "self", ".", "three_point_attempts", ")", "if", "self", ...
Returns an ``int`` of the total number of two point field goals the player attempted during the season.
[ "Returns", "an", "int", "of", "the", "total", "number", "of", "two", "point", "field", "goals", "the", "player", "attempted", "during", "the", "season", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/boxscore.py#L139-L153
train
roclark/sportsreference
sportsreference/nba/boxscore.py
BoxscorePlayer.two_point_percentage
def two_point_percentage(self): """ Returns a ``float`` of the player's two point field goal percentage during the season. Percentage ranges from 0-1. """ if self.two_pointers and self.two_point_attempts: perc = float(self.two_pointers) / float(self.two_point_attempts...
python
def two_point_percentage(self): """ Returns a ``float`` of the player's two point field goal percentage during the season. Percentage ranges from 0-1. """ if self.two_pointers and self.two_point_attempts: perc = float(self.two_pointers) / float(self.two_point_attempts...
[ "def", "two_point_percentage", "(", "self", ")", ":", "if", "self", ".", "two_pointers", "and", "self", ".", "two_point_attempts", ":", "perc", "=", "float", "(", "self", ".", "two_pointers", ")", "/", "float", "(", "self", ".", "two_point_attempts", ")", ...
Returns a ``float`` of the player's two point field goal percentage during the season. Percentage ranges from 0-1.
[ "Returns", "a", "float", "of", "the", "player", "s", "two", "point", "field", "goal", "percentage", "during", "the", "season", ".", "Percentage", "ranges", "from", "0", "-", "1", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/boxscore.py#L156-L167
train
roclark/sportsreference
sportsreference/nba/boxscore.py
Boxscore.away_two_point_field_goal_percentage
def away_two_point_field_goal_percentage(self): """ Returns a ``float`` of the number of two point field goals made divided by the number of two point field goal attempts by the away team. Percentage ranges from 0-1. """ result = float(self.away_two_point_field_goals) / \...
python
def away_two_point_field_goal_percentage(self): """ Returns a ``float`` of the number of two point field goals made divided by the number of two point field goal attempts by the away team. Percentage ranges from 0-1. """ result = float(self.away_two_point_field_goals) / \...
[ "def", "away_two_point_field_goal_percentage", "(", "self", ")", ":", "result", "=", "float", "(", "self", ".", "away_two_point_field_goals", ")", "/", "float", "(", "self", ".", "away_two_point_field_goal_attempts", ")", "return", "round", "(", "float", "(", "res...
Returns a ``float`` of the number of two point field goals made divided by the number of two point field goal attempts by the away team. Percentage ranges from 0-1.
[ "Returns", "a", "float", "of", "the", "number", "of", "two", "point", "field", "goals", "made", "divided", "by", "the", "number", "of", "two", "point", "field", "goal", "attempts", "by", "the", "away", "team", ".", "Percentage", "ranges", "from", "0", "-...
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/boxscore.py#L909-L917
train
roclark/sportsreference
sportsreference/nba/boxscore.py
Boxscore.home_wins
def home_wins(self): """ Returns an ``int`` of the number of games the home team won after the conclusion of the game. """ try: wins, losses = re.findall(r'\d+', self._home_record) return wins except ValueError: return 0
python
def home_wins(self): """ Returns an ``int`` of the number of games the home team won after the conclusion of the game. """ try: wins, losses = re.findall(r'\d+', self._home_record) return wins except ValueError: return 0
[ "def", "home_wins", "(", "self", ")", ":", "try", ":", "wins", ",", "losses", "=", "re", ".", "findall", "(", "r'\\d+'", ",", "self", ".", "_home_record", ")", "return", "wins", "except", "ValueError", ":", "return", "0" ]
Returns an ``int`` of the number of games the home team won after the conclusion of the game.
[ "Returns", "an", "int", "of", "the", "number", "of", "games", "the", "home", "team", "won", "after", "the", "conclusion", "of", "the", "game", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/boxscore.py#L1115-L1124
train
roclark/sportsreference
sportsreference/nba/boxscore.py
Boxscore.home_two_point_field_goal_percentage
def home_two_point_field_goal_percentage(self): """ Returns a ``float`` of the number of two point field goals made divided by the number of two point field goal attempts by the home team. Percentage ranges from 0-1. """ result = float(self.home_two_point_field_goals) / \...
python
def home_two_point_field_goal_percentage(self): """ Returns a ``float`` of the number of two point field goals made divided by the number of two point field goal attempts by the home team. Percentage ranges from 0-1. """ result = float(self.home_two_point_field_goals) / \...
[ "def", "home_two_point_field_goal_percentage", "(", "self", ")", ":", "result", "=", "float", "(", "self", ".", "home_two_point_field_goals", ")", "/", "float", "(", "self", ".", "home_two_point_field_goal_attempts", ")", "return", "round", "(", "float", "(", "res...
Returns a ``float`` of the number of two point field goals made divided by the number of two point field goal attempts by the home team. Percentage ranges from 0-1.
[ "Returns", "a", "float", "of", "the", "number", "of", "two", "point", "field", "goals", "made", "divided", "by", "the", "number", "of", "two", "point", "field", "goal", "attempts", "by", "the", "home", "team", ".", "Percentage", "ranges", "from", "0", "-...
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/boxscore.py#L1214-L1222
train
roclark/sportsreference
sportsreference/nfl/teams.py
Team.dataframe
def dataframe(self): """ Returns a pandas DataFrame containing all other class properties and values. The index for the DataFrame is the string abbreviation of the team, such as 'KAN'. """ fields_to_include = { 'abbreviation': self.abbreviation, 'd...
python
def dataframe(self): """ Returns a pandas DataFrame containing all other class properties and values. The index for the DataFrame is the string abbreviation of the team, such as 'KAN'. """ fields_to_include = { 'abbreviation': self.abbreviation, 'd...
[ "def", "dataframe", "(", "self", ")", ":", "fields_to_include", "=", "{", "'abbreviation'", ":", "self", ".", "abbreviation", ",", "'defensive_simple_rating_system'", ":", "self", ".", "defensive_simple_rating_system", ",", "'first_downs'", ":", "self", ".", "first_...
Returns a pandas DataFrame containing all other class properties and values. The index for the DataFrame is the string abbreviation of the team, such as 'KAN'.
[ "Returns", "a", "pandas", "DataFrame", "containing", "all", "other", "class", "properties", "and", "values", ".", "The", "index", "for", "the", "DataFrame", "is", "the", "string", "abbreviation", "of", "the", "team", "such", "as", "KAN", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nfl/teams.py#L106-L157
train
roclark/sportsreference
sportsreference/mlb/roster.py
Player._parse_team_name
def _parse_team_name(self, team): """ Parse the team name in the contract table. The team names in the contract table contain special encoded characters that are not supported by Python 2.7. These characters should be filtered out to get the proper team name. Parameters...
python
def _parse_team_name(self, team): """ Parse the team name in the contract table. The team names in the contract table contain special encoded characters that are not supported by Python 2.7. These characters should be filtered out to get the proper team name. Parameters...
[ "def", "_parse_team_name", "(", "self", ",", "team", ")", ":", "team", "=", "team", ".", "replace", "(", "'&#160;'", ",", "' '", ")", "team", "=", "team", ".", "replace", "(", "'\\xa0'", ",", "' '", ")", "team_html", "=", "pq", "(", "team", ")", "r...
Parse the team name in the contract table. The team names in the contract table contain special encoded characters that are not supported by Python 2.7. These characters should be filtered out to get the proper team name. Parameters ---------- team : string ...
[ "Parse", "the", "team", "name", "in", "the", "contract", "table", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/roster.py#L403-L425
train
roclark/sportsreference
sportsreference/mlb/roster.py
Player._parse_value
def _parse_value(self, html_data, field): """ Parse the HTML table to find the requested field's value. All of the values are passed in an HTML table row instead of as individual items. The values need to be parsed by matching the requested attribute with a parsing scheme that s...
python
def _parse_value(self, html_data, field): """ Parse the HTML table to find the requested field's value. All of the values are passed in an HTML table row instead of as individual items. The values need to be parsed by matching the requested attribute with a parsing scheme that s...
[ "def", "_parse_value", "(", "self", ",", "html_data", ",", "field", ")", ":", "scheme", "=", "PLAYER_SCHEME", "[", "field", "]", "items", "=", "[", "i", ".", "text", "(", ")", "for", "i", "in", "html_data", "(", "scheme", ")", ".", "items", "(", ")...
Parse the HTML table to find the requested field's value. All of the values are passed in an HTML table row instead of as individual items. The values need to be parsed by matching the requested attribute with a parsing scheme that sports-reference uses to differentiate stats. This func...
[ "Parse", "the", "HTML", "table", "to", "find", "the", "requested", "field", "s", "value", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/roster.py#L459-L491
train
roclark/sportsreference
sportsreference/mlb/roster.py
Roster._get_id
def _get_id(self, player): """ Parse the player ID. Given a PyQuery object representing a single player on the team roster, parse the player ID and return it as a string. Parameters ---------- player : PyQuery object A PyQuery object representing the...
python
def _get_id(self, player): """ Parse the player ID. Given a PyQuery object representing a single player on the team roster, parse the player ID and return it as a string. Parameters ---------- player : PyQuery object A PyQuery object representing the...
[ "def", "_get_id", "(", "self", ",", "player", ")", ":", "name_tag", "=", "player", "(", "'td[data-stat=\"player\"] a'", ")", "name", "=", "re", ".", "sub", "(", "r'.*/players/./'", ",", "''", ",", "str", "(", "name_tag", ")", ")", "return", "re", ".", ...
Parse the player ID. Given a PyQuery object representing a single player on the team roster, parse the player ID and return it as a string. Parameters ---------- player : PyQuery object A PyQuery object representing the player information from the roster...
[ "Parse", "the", "player", "ID", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/roster.py#L1489-L1509
train
roclark/sportsreference
sportsreference/nhl/boxscore.py
BoxscorePlayer.dataframe
def dataframe(self): """ Returns a ``pandas DataFrame`` containing all other relevant properties and values for the specified game. """ fields_to_include = { 'assists': self.assists, 'blocks_at_even_strength': self.blocks_at_even_strength, 'cor...
python
def dataframe(self): """ Returns a ``pandas DataFrame`` containing all other relevant properties and values for the specified game. """ fields_to_include = { 'assists': self.assists, 'blocks_at_even_strength': self.blocks_at_even_strength, 'cor...
[ "def", "dataframe", "(", "self", ")", ":", "fields_to_include", "=", "{", "'assists'", ":", "self", ".", "assists", ",", "'blocks_at_even_strength'", ":", "self", ".", "blocks_at_even_strength", ",", "'corsi_for_percentage'", ":", "self", ".", "corsi_for_percentage"...
Returns a ``pandas DataFrame`` containing all other relevant properties and values for the specified game.
[ "Returns", "a", "pandas", "DataFrame", "containing", "all", "other", "relevant", "properties", "and", "values", "for", "the", "specified", "game", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nhl/boxscore.py#L96-L141
train
roclark/sportsreference
sportsreference/nhl/boxscore.py
Boxscore._find_player_id
def _find_player_id(self, row): """ Find the player's ID. Find the player's ID as embedded in the 'data-append-csv' attribute, such as 'zettehe01' for Henrik Zetterberg. Parameters ---------- row : PyQuery object A PyQuery object representing a singl...
python
def _find_player_id(self, row): """ Find the player's ID. Find the player's ID as embedded in the 'data-append-csv' attribute, such as 'zettehe01' for Henrik Zetterberg. Parameters ---------- row : PyQuery object A PyQuery object representing a singl...
[ "def", "_find_player_id", "(", "self", ",", "row", ")", ":", "player_id", "=", "row", "(", "'th'", ")", ".", "attr", "(", "'data-append-csv'", ")", "if", "not", "player_id", ":", "player_id", "=", "row", "(", "'td'", ")", ".", "attr", "(", "'data-appen...
Find the player's ID. Find the player's ID as embedded in the 'data-append-csv' attribute, such as 'zettehe01' for Henrik Zetterberg. Parameters ---------- row : PyQuery object A PyQuery object representing a single row in a boxscore table for a single p...
[ "Find", "the", "player", "s", "ID", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nhl/boxscore.py#L413-L435
train
roclark/sportsreference
sportsreference/nhl/boxscore.py
Boxscore.dataframe
def dataframe(self): """ Returns a pandas DataFrame containing all other class properties and values. The index for the DataFrame is the string URI that is used to instantiate the class, such as '201806070VEG'. """ if self._away_goals is None and self._home_goals is None:...
python
def dataframe(self): """ Returns a pandas DataFrame containing all other class properties and values. The index for the DataFrame is the string URI that is used to instantiate the class, such as '201806070VEG'. """ if self._away_goals is None and self._home_goals is None:...
[ "def", "dataframe", "(", "self", ")", ":", "if", "self", ".", "_away_goals", "is", "None", "and", "self", ".", "_home_goals", "is", "None", ":", "return", "None", "fields_to_include", "=", "{", "'arena'", ":", "self", ".", "arena", ",", "'attendance'", "...
Returns a pandas DataFrame containing all other class properties and values. The index for the DataFrame is the string URI that is used to instantiate the class, such as '201806070VEG'.
[ "Returns", "a", "pandas", "DataFrame", "containing", "all", "other", "class", "properties", "and", "values", ".", "The", "index", "for", "the", "DataFrame", "is", "the", "string", "URI", "that", "is", "used", "to", "instantiate", "the", "class", "such", "as"...
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nhl/boxscore.py#L667-L719
train
roclark/sportsreference
sportsreference/nhl/boxscore.py
Boxscore.away_save_percentage
def away_save_percentage(self): """ Returns a ``float`` of the percentage of shots the away team saved. Percentage ranges from 0-1. """ try: save_pct = float(self.away_saves) / float(self.home_shots_on_goal) return round(save_pct, 3) except ZeroDiv...
python
def away_save_percentage(self): """ Returns a ``float`` of the percentage of shots the away team saved. Percentage ranges from 0-1. """ try: save_pct = float(self.away_saves) / float(self.home_shots_on_goal) return round(save_pct, 3) except ZeroDiv...
[ "def", "away_save_percentage", "(", "self", ")", ":", "try", ":", "save_pct", "=", "float", "(", "self", ".", "away_saves", ")", "/", "float", "(", "self", ".", "home_shots_on_goal", ")", "return", "round", "(", "save_pct", ",", "3", ")", "except", "Zero...
Returns a ``float`` of the percentage of shots the away team saved. Percentage ranges from 0-1.
[ "Returns", "a", "float", "of", "the", "percentage", "of", "shots", "the", "away", "team", "saved", ".", "Percentage", "ranges", "from", "0", "-", "1", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nhl/boxscore.py#L941-L950
train
roclark/sportsreference
sportsreference/nhl/boxscore.py
Boxscore.home_save_percentage
def home_save_percentage(self): """ Returns a ``float`` of the percentage of shots the home team saved. Percentage ranges from 0-1. """ try: save_pct = float(self.home_saves) / float(self.away_shots_on_goal) return round(save_pct, 3) except ZeroDiv...
python
def home_save_percentage(self): """ Returns a ``float`` of the percentage of shots the home team saved. Percentage ranges from 0-1. """ try: save_pct = float(self.home_saves) / float(self.away_shots_on_goal) return round(save_pct, 3) except ZeroDiv...
[ "def", "home_save_percentage", "(", "self", ")", ":", "try", ":", "save_pct", "=", "float", "(", "self", ".", "home_saves", ")", "/", "float", "(", "self", ".", "away_shots_on_goal", ")", "return", "round", "(", "save_pct", ",", "3", ")", "except", "Zero...
Returns a ``float`` of the percentage of shots the home team saved. Percentage ranges from 0-1.
[ "Returns", "a", "float", "of", "the", "percentage", "of", "shots", "the", "home", "team", "saved", ".", "Percentage", "ranges", "from", "0", "-", "1", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nhl/boxscore.py#L1069-L1078
train
roclark/sportsreference
sportsreference/ncaaf/schedule.py
Game.location
def location(self): """ Returns a ``string`` constant to indicate whether the game was played at home, away, or in a neutral location. """ if self._location.lower() == 'n': return NEUTRAL if self._location.lower() == '@': return AWAY return...
python
def location(self): """ Returns a ``string`` constant to indicate whether the game was played at home, away, or in a neutral location. """ if self._location.lower() == 'n': return NEUTRAL if self._location.lower() == '@': return AWAY return...
[ "def", "location", "(", "self", ")", ":", "if", "self", ".", "_location", ".", "lower", "(", ")", "==", "'n'", ":", "return", "NEUTRAL", "if", "self", ".", "_location", ".", "lower", "(", ")", "==", "'@'", ":", "return", "AWAY", "return", "HOME" ]
Returns a ``string`` constant to indicate whether the game was played at home, away, or in a neutral location.
[ "Returns", "a", "string", "constant", "to", "indicate", "whether", "the", "game", "was", "played", "at", "home", "away", "or", "in", "a", "neutral", "location", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/schedule.py#L223-L232
train
roclark/sportsreference
sportsreference/ncaaf/schedule.py
Game.rank
def rank(self): """ Returns an ``int`` of the team's rank at the time the game was played. """ rank = re.findall(r'\d+', self._rank) if len(rank) == 0: return None return rank[0]
python
def rank(self): """ Returns an ``int`` of the team's rank at the time the game was played. """ rank = re.findall(r'\d+', self._rank) if len(rank) == 0: return None return rank[0]
[ "def", "rank", "(", "self", ")", ":", "rank", "=", "re", ".", "findall", "(", "r'\\d+'", ",", "self", ".", "_rank", ")", "if", "len", "(", "rank", ")", "==", "0", ":", "return", "None", "return", "rank", "[", "0", "]" ]
Returns an ``int`` of the team's rank at the time the game was played.
[ "Returns", "an", "int", "of", "the", "team", "s", "rank", "at", "the", "time", "the", "game", "was", "played", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/schedule.py#L235-L242
train
roclark/sportsreference
sportsreference/mlb/schedule.py
Game.datetime
def datetime(self): """ Returns a datetime object of the month, day, year, and time the game was played. """ date_string = '%s %s' % (self._date, self._year) date_string = re.sub(r' \(\d+\)', '', date_string) return datetime.strptime(date_string, '%A, %b %d %Y')
python
def datetime(self): """ Returns a datetime object of the month, day, year, and time the game was played. """ date_string = '%s %s' % (self._date, self._year) date_string = re.sub(r' \(\d+\)', '', date_string) return datetime.strptime(date_string, '%A, %b %d %Y')
[ "def", "datetime", "(", "self", ")", ":", "date_string", "=", "'%s %s'", "%", "(", "self", ".", "_date", ",", "self", ".", "_year", ")", "date_string", "=", "re", ".", "sub", "(", "r' \\(\\d+\\)'", ",", "''", ",", "date_string", ")", "return", "datetim...
Returns a datetime object of the month, day, year, and time the game was played.
[ "Returns", "a", "datetime", "object", "of", "the", "month", "day", "year", "and", "time", "the", "game", "was", "played", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/schedule.py#L172-L179
train
roclark/sportsreference
sportsreference/mlb/schedule.py
Game.game_number_for_day
def game_number_for_day(self): """ Returns an ``int`` denoting which game is played for the team during the given day. Default value is 1 where a team plays only one game during the day, but can be higher for double headers, etc. For example, if a team has a double header one day...
python
def game_number_for_day(self): """ Returns an ``int`` denoting which game is played for the team during the given day. Default value is 1 where a team plays only one game during the day, but can be higher for double headers, etc. For example, if a team has a double header one day...
[ "def", "game_number_for_day", "(", "self", ")", ":", "game_number", "=", "re", ".", "findall", "(", "r'\\(\\d+\\)'", ",", "self", ".", "_date", ")", "if", "len", "(", "game_number", ")", "==", "0", ":", "return", "1", "game_number", "=", "re", ".", "fi...
Returns an ``int`` denoting which game is played for the team during the given day. Default value is 1 where a team plays only one game during the day, but can be higher for double headers, etc. For example, if a team has a double header one day, the first game of the day will return 1 w...
[ "Returns", "an", "int", "denoting", "which", "game", "is", "played", "for", "the", "team", "during", "the", "given", "day", ".", "Default", "value", "is", "1", "where", "a", "team", "plays", "only", "one", "game", "during", "the", "day", "but", "can", ...
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/schedule.py#L182-L194
train
roclark/sportsreference
sportsreference/mlb/schedule.py
Game.games_behind
def games_behind(self): """ Returns a ``float`` of the number of games behind the leader the team is. 0.0 indicates the team is tied for first. Negative numbers indicate the number of games a team is ahead of the second place team. """ if 'up' in self._games_behind.lower(...
python
def games_behind(self): """ Returns a ``float`` of the number of games behind the leader the team is. 0.0 indicates the team is tied for first. Negative numbers indicate the number of games a team is ahead of the second place team. """ if 'up' in self._games_behind.lower(...
[ "def", "games_behind", "(", "self", ")", ":", "if", "'up'", "in", "self", ".", "_games_behind", ".", "lower", "(", ")", ":", "games_behind", "=", "re", ".", "sub", "(", "'up *'", ",", "''", ",", "self", ".", "_games_behind", ".", "lower", "(", ")", ...
Returns a ``float`` of the number of games behind the leader the team is. 0.0 indicates the team is tied for first. Negative numbers indicate the number of games a team is ahead of the second place team.
[ "Returns", "a", "float", "of", "the", "number", "of", "games", "behind", "the", "leader", "the", "team", "is", ".", "0", ".", "0", "indicates", "the", "team", "is", "tied", "for", "first", ".", "Negative", "numbers", "indicate", "the", "number", "of", ...
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/schedule.py#L279-L296
train
roclark/sportsreference
sportsreference/mlb/teams.py
Team._parse_name
def _parse_name(self, team_data): """ Parses the team's name. On the pages being parsed, the team's name doesn't follow the standard parsing algorithm that we use for the fields, and requires a special one-off algorithm. The name is attached in the 'title' attribute from ...
python
def _parse_name(self, team_data): """ Parses the team's name. On the pages being parsed, the team's name doesn't follow the standard parsing algorithm that we use for the fields, and requires a special one-off algorithm. The name is attached in the 'title' attribute from ...
[ "def", "_parse_name", "(", "self", ",", "team_data", ")", ":", "name", "=", "team_data", "(", "'td[data-stat=\"team_ID\"]:first'", ")", "name", "=", "re", ".", "sub", "(", "r'.*title=\"'", ",", "''", ",", "str", "(", "name", ")", ")", "name", "=", "re", ...
Parses the team's name. On the pages being parsed, the team's name doesn't follow the standard parsing algorithm that we use for the fields, and requires a special one-off algorithm. The name is attached in the 'title' attribute from within 'team_ID'. A few simple regex subs captures th...
[ "Parses", "the", "team", "s", "name", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/mlb/teams.py#L140-L161
train
roclark/sportsreference
sportsreference/nba/schedule.py
Game._parse_opponent_abbr
def _parse_opponent_abbr(self, game_data): """ Parses the opponent's abbreviation for the game. The opponent's 3-letter abbreviation is embedded within the HTML tag and needs a special parsing scheme in order to be extracted. Parameters ---------- game_data : Py...
python
def _parse_opponent_abbr(self, game_data): """ Parses the opponent's abbreviation for the game. The opponent's 3-letter abbreviation is embedded within the HTML tag and needs a special parsing scheme in order to be extracted. Parameters ---------- game_data : Py...
[ "def", "_parse_opponent_abbr", "(", "self", ",", "game_data", ")", ":", "opponent", "=", "game_data", "(", "'td[data-stat=\"opp_name\"]:first'", ")", "opponent", "=", "re", ".", "sub", "(", "r'.*/teams/'", ",", "''", ",", "str", "(", "opponent", ")", ")", "o...
Parses the opponent's abbreviation for the game. The opponent's 3-letter abbreviation is embedded within the HTML tag and needs a special parsing scheme in order to be extracted. Parameters ---------- game_data : PyQuery object A PyQuery object containing the inform...
[ "Parses", "the", "opponent", "s", "abbreviation", "for", "the", "game", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/schedule.py#L66-L81
train
roclark/sportsreference
sportsreference/nba/schedule.py
Schedule._add_games_to_schedule
def _add_games_to_schedule(self, schedule): """ Add game information to list of games. Create a Game instance for the given game in the schedule and add it to the list of games the team has or will play during the season. Parameters ---------- schedule : PyQuery...
python
def _add_games_to_schedule(self, schedule): """ Add game information to list of games. Create a Game instance for the given game in the schedule and add it to the list of games the team has or will play during the season. Parameters ---------- schedule : PyQuery...
[ "def", "_add_games_to_schedule", "(", "self", ",", "schedule", ")", ":", "for", "item", "in", "schedule", ":", "if", "'class=\"thead\"'", "in", "str", "(", "item", ")", "or", "'class=\"over_header thead\"'", "in", "str", "(", "item", ")", ":", "continue", "g...
Add game information to list of games. Create a Game instance for the given game in the schedule and add it to the list of games the team has or will play during the season. Parameters ---------- schedule : PyQuery object A PyQuery object pertaining to a team's sche...
[ "Add", "game", "information", "to", "list", "of", "games", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nba/schedule.py#L359-L378
train
roclark/sportsreference
sportsreference/ncaaf/boxscore.py
BoxscorePlayer.dataframe
def dataframe(self): """ Returns a ``pandas DataFrame`` containing all other relevant class properties and value for the specified game. """ fields_to_include = { 'completed_passes': self.completed_passes, 'attempted_passes': self.attempted_passes, ...
python
def dataframe(self): """ Returns a ``pandas DataFrame`` containing all other relevant class properties and value for the specified game. """ fields_to_include = { 'completed_passes': self.completed_passes, 'attempted_passes': self.attempted_passes, ...
[ "def", "dataframe", "(", "self", ")", ":", "fields_to_include", "=", "{", "'completed_passes'", ":", "self", ".", "completed_passes", ",", "'attempted_passes'", ":", "self", ".", "attempted_passes", ",", "'passing_completion'", ":", "self", ".", "passing_completion"...
Returns a ``pandas DataFrame`` containing all other relevant class properties and value for the specified game.
[ "Returns", "a", "pandas", "DataFrame", "containing", "all", "other", "relevant", "class", "properties", "and", "value", "for", "the", "specified", "game", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/boxscore.py#L101-L168
train
roclark/sportsreference
sportsreference/ncaaf/boxscore.py
Boxscore.dataframe
def dataframe(self): """ Returns a pandas DataFrame containing all other class properties and values. The index for the DataFrame is the string URI that is used to instantiate the class, such as '2018-01-08-georgia'. """ if self._away_points is None and self._home_points ...
python
def dataframe(self): """ Returns a pandas DataFrame containing all other class properties and values. The index for the DataFrame is the string URI that is used to instantiate the class, such as '2018-01-08-georgia'. """ if self._away_points is None and self._home_points ...
[ "def", "dataframe", "(", "self", ")", ":", "if", "self", ".", "_away_points", "is", "None", "and", "self", ".", "_home_points", "is", "None", ":", "return", "None", "fields_to_include", "=", "{", "'away_first_downs'", ":", "self", ".", "away_first_downs", ",...
Returns a pandas DataFrame containing all other class properties and values. The index for the DataFrame is the string URI that is used to instantiate the class, such as '2018-01-08-georgia'.
[ "Returns", "a", "pandas", "DataFrame", "containing", "all", "other", "class", "properties", "and", "values", ".", "The", "index", "for", "the", "DataFrame", "is", "the", "string", "URI", "that", "is", "used", "to", "instantiate", "the", "class", "such", "as"...
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/boxscore.py#L708-L758
train
roclark/sportsreference
sportsreference/ncaaf/boxscore.py
Boxscore.winning_abbr
def winning_abbr(self): """ Returns a ``string`` of the winning team's abbreviation, such as 'ALABAMA' for the Alabama Crimson Tide. """ if self.winner == HOME: if 'cfb/schools' not in str(self._home_name): return self._home_name.text() ...
python
def winning_abbr(self): """ Returns a ``string`` of the winning team's abbreviation, such as 'ALABAMA' for the Alabama Crimson Tide. """ if self.winner == HOME: if 'cfb/schools' not in str(self._home_name): return self._home_name.text() ...
[ "def", "winning_abbr", "(", "self", ")", ":", "if", "self", ".", "winner", "==", "HOME", ":", "if", "'cfb/schools'", "not", "in", "str", "(", "self", ".", "_home_name", ")", ":", "return", "self", ".", "_home_name", ".", "text", "(", ")", "return", "...
Returns a ``string`` of the winning team's abbreviation, such as 'ALABAMA' for the Alabama Crimson Tide.
[ "Returns", "a", "string", "of", "the", "winning", "team", "s", "abbreviation", "such", "as", "ALABAMA", "for", "the", "Alabama", "Crimson", "Tide", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/boxscore.py#L818-L830
train
roclark/sportsreference
sportsreference/ncaaf/roster.py
Player._combine_all_stats
def _combine_all_stats(self, player_info): """ Pull stats from all tables into a single data structure. Pull the stats from all of the requested tables into a dictionary that is separated by season to allow easy queries of the player's stats for each season. Parameters ...
python
def _combine_all_stats(self, player_info): """ Pull stats from all tables into a single data structure. Pull the stats from all of the requested tables into a dictionary that is separated by season to allow easy queries of the player's stats for each season. Parameters ...
[ "def", "_combine_all_stats", "(", "self", ",", "player_info", ")", ":", "all_stats_dict", "=", "{", "}", "for", "table_id", "in", "[", "'passing'", ",", "'rushing'", ",", "'defense'", ",", "'scoring'", "]", ":", "table_items", "=", "utils", ".", "_get_stats_...
Pull stats from all tables into a single data structure. Pull the stats from all of the requested tables into a dictionary that is separated by season to allow easy queries of the player's stats for each season. Parameters ---------- player_info : PyQuery object ...
[ "Pull", "stats", "from", "all", "tables", "into", "a", "single", "data", "structure", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/roster.py#L233-L264
train
roclark/sportsreference
sportsreference/ncaaf/roster.py
Player._pull_player_data
def _pull_player_data(self): """ Pull and aggregate all player information. Pull the player's HTML stats page and parse unique properties, such as the player's height, weight, and name. Next, combine all stats for all seasons plus the player's career stats into a single object w...
python
def _pull_player_data(self): """ Pull and aggregate all player information. Pull the player's HTML stats page and parse unique properties, such as the player's height, weight, and name. Next, combine all stats for all seasons plus the player's career stats into a single object w...
[ "def", "_pull_player_data", "(", "self", ")", ":", "player_info", "=", "self", ".", "_retrieve_html_page", "(", ")", "if", "not", "player_info", ":", "return", "self", ".", "_parse_player_information", "(", "player_info", ")", "all_stats", "=", "self", ".", "_...
Pull and aggregate all player information. Pull the player's HTML stats page and parse unique properties, such as the player's height, weight, and name. Next, combine all stats for all seasons plus the player's career stats into a single object which can easily be iterated upon. ...
[ "Pull", "and", "aggregate", "all", "player", "information", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaaf/roster.py#L284-L306
train
roclark/sportsreference
sportsreference/nhl/roster.py
Player.team_abbreviation
def team_abbreviation(self): """ Returns a ``string`` of the team's abbreviation, such as 'DET' for the Detroit Red Wings. """ # For career stats, skip the team abbreviation. if self._season[self._index].lower() == 'career': return None return self._te...
python
def team_abbreviation(self): """ Returns a ``string`` of the team's abbreviation, such as 'DET' for the Detroit Red Wings. """ # For career stats, skip the team abbreviation. if self._season[self._index].lower() == 'career': return None return self._te...
[ "def", "team_abbreviation", "(", "self", ")", ":", "if", "self", ".", "_season", "[", "self", ".", "_index", "]", ".", "lower", "(", ")", "==", "'career'", ":", "return", "None", "return", "self", ".", "_team_abbreviation", "[", "self", ".", "_index", ...
Returns a ``string`` of the team's abbreviation, such as 'DET' for the Detroit Red Wings.
[ "Returns", "a", "string", "of", "the", "team", "s", "abbreviation", "such", "as", "DET", "for", "the", "Detroit", "Red", "Wings", "." ]
ea0bae432be76450e137671d2998eb38f962dffd
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nhl/roster.py#L548-L556
train
elehcimd/pynb
pynb/notebook.py
Notebook.add_cell_footer
def add_cell_footer(self): """ Add footer cell """ # check if there's already a cell footer... if true, do not add a second cell footer. # this situation happens when exporting to ipynb and then importing from ipynb. logging.info('Adding footer cell') for cell ...
python
def add_cell_footer(self): """ Add footer cell """ # check if there's already a cell footer... if true, do not add a second cell footer. # this situation happens when exporting to ipynb and then importing from ipynb. logging.info('Adding footer cell') for cell ...
[ "def", "add_cell_footer", "(", "self", ")", ":", "logging", ".", "info", "(", "'Adding footer cell'", ")", "for", "cell", "in", "self", ".", "nb", "[", "'cells'", "]", ":", "if", "cell", ".", "cell_type", "==", "'markdown'", ":", "if", "'pynb_footer_tag'",...
Add footer cell
[ "Add", "footer", "cell" ]
a32af1f0e574f880eccda4a46aede6d65151f8c9
https://github.com/elehcimd/pynb/blob/a32af1f0e574f880eccda4a46aede6d65151f8c9/pynb/notebook.py#L278-L306
train
elehcimd/pynb
pynb/notebook.py
Notebook.get_kernelspec
def get_kernelspec(self, name): """Get a kernel specification dictionary given a kernel name """ ksm = KernelSpecManager() kernelspec = ksm.get_kernel_spec(name).to_dict() kernelspec['name'] = name kernelspec.pop('argv') return kernelspec
python
def get_kernelspec(self, name): """Get a kernel specification dictionary given a kernel name """ ksm = KernelSpecManager() kernelspec = ksm.get_kernel_spec(name).to_dict() kernelspec['name'] = name kernelspec.pop('argv') return kernelspec
[ "def", "get_kernelspec", "(", "self", ",", "name", ")", ":", "ksm", "=", "KernelSpecManager", "(", ")", "kernelspec", "=", "ksm", ".", "get_kernel_spec", "(", "name", ")", ".", "to_dict", "(", ")", "kernelspec", "[", "'name'", "]", "=", "name", "kernelsp...
Get a kernel specification dictionary given a kernel name
[ "Get", "a", "kernel", "specification", "dictionary", "given", "a", "kernel", "name" ]
a32af1f0e574f880eccda4a46aede6d65151f8c9
https://github.com/elehcimd/pynb/blob/a32af1f0e574f880eccda4a46aede6d65151f8c9/pynb/notebook.py#L558-L565
train
elehcimd/pynb
fabfile.py
docker_start
def docker_start(develop=True): """ Start docker container """ curr_dir = os.path.dirname(os.path.realpath(__file__)) local('docker run --rm --name pynb -d -ti -p 127.0.0.1:8889:8888 -v {}:/code -t pynb'.format(curr_dir)) if develop: # Install package in develop mode: the code in /code...
python
def docker_start(develop=True): """ Start docker container """ curr_dir = os.path.dirname(os.path.realpath(__file__)) local('docker run --rm --name pynb -d -ti -p 127.0.0.1:8889:8888 -v {}:/code -t pynb'.format(curr_dir)) if develop: # Install package in develop mode: the code in /code...
[ "def", "docker_start", "(", "develop", "=", "True", ")", ":", "curr_dir", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "(", "__file__", ")", ")", "local", "(", "'docker run --rm --name pynb -d -ti -p 127.0.0.1:8889:8888 -v {}...
Start docker container
[ "Start", "docker", "container" ]
a32af1f0e574f880eccda4a46aede6d65151f8c9
https://github.com/elehcimd/pynb/blob/a32af1f0e574f880eccda4a46aede6d65151f8c9/fabfile.py#L99-L110
train
glut23/webvtt-py
webvtt/parsers.py
TextBasedParser.read
def read(self, file): """Reads the captions file.""" content = self._read_content(file) self._validate(content) self._parse(content) return self
python
def read(self, file): """Reads the captions file.""" content = self._read_content(file) self._validate(content) self._parse(content) return self
[ "def", "read", "(", "self", ",", "file", ")", ":", "content", "=", "self", ".", "_read_content", "(", "file", ")", "self", ".", "_validate", "(", "content", ")", "self", ".", "_parse", "(", "content", ")", "return", "self" ]
Reads the captions file.
[ "Reads", "the", "captions", "file", "." ]
7b4da0123c2e2afaf31402107528721eb1d3d481
https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/parsers.py#L22-L28
train
glut23/webvtt-py
webvtt/parsers.py
TextBasedParser._parse_timeframe_line
def _parse_timeframe_line(self, line): """Parse timeframe line and return start and end timestamps.""" tf = self._validate_timeframe_line(line) if not tf: raise MalformedCaptionError('Invalid time format') return tf.group(1), tf.group(2)
python
def _parse_timeframe_line(self, line): """Parse timeframe line and return start and end timestamps.""" tf = self._validate_timeframe_line(line) if not tf: raise MalformedCaptionError('Invalid time format') return tf.group(1), tf.group(2)
[ "def", "_parse_timeframe_line", "(", "self", ",", "line", ")", ":", "tf", "=", "self", ".", "_validate_timeframe_line", "(", "line", ")", "if", "not", "tf", ":", "raise", "MalformedCaptionError", "(", "'Invalid time format'", ")", "return", "tf", ".", "group",...
Parse timeframe line and return start and end timestamps.
[ "Parse", "timeframe", "line", "and", "return", "start", "and", "end", "timestamps", "." ]
7b4da0123c2e2afaf31402107528721eb1d3d481
https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/parsers.py#L49-L55
train
glut23/webvtt-py
webvtt/cli.py
main
def main(): """Main entry point for CLI commands.""" options = docopt(__doc__, version=__version__) if options['segment']: segment( options['<file>'], options['--output'], options['--target-duration'], options['--mpegts'], )
python
def main(): """Main entry point for CLI commands.""" options = docopt(__doc__, version=__version__) if options['segment']: segment( options['<file>'], options['--output'], options['--target-duration'], options['--mpegts'], )
[ "def", "main", "(", ")", ":", "options", "=", "docopt", "(", "__doc__", ",", "version", "=", "__version__", ")", "if", "options", "[", "'segment'", "]", ":", "segment", "(", "options", "[", "'<file>'", "]", ",", "options", "[", "'--output'", "]", ",", ...
Main entry point for CLI commands.
[ "Main", "entry", "point", "for", "CLI", "commands", "." ]
7b4da0123c2e2afaf31402107528721eb1d3d481
https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/cli.py#L23-L32
train
glut23/webvtt-py
webvtt/cli.py
segment
def segment(f, output, target_duration, mpegts): """Segment command.""" try: target_duration = int(target_duration) except ValueError: exit('Error: Invalid target duration.') try: mpegts = int(mpegts) except ValueError: exit('Error: Invalid MPEGTS value.') WebVT...
python
def segment(f, output, target_duration, mpegts): """Segment command.""" try: target_duration = int(target_duration) except ValueError: exit('Error: Invalid target duration.') try: mpegts = int(mpegts) except ValueError: exit('Error: Invalid MPEGTS value.') WebVT...
[ "def", "segment", "(", "f", ",", "output", ",", "target_duration", ",", "mpegts", ")", ":", "try", ":", "target_duration", "=", "int", "(", "target_duration", ")", "except", "ValueError", ":", "exit", "(", "'Error: Invalid target duration.'", ")", "try", ":", ...
Segment command.
[ "Segment", "command", "." ]
7b4da0123c2e2afaf31402107528721eb1d3d481
https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/cli.py#L35-L47
train
glut23/webvtt-py
webvtt/webvtt.py
WebVTT.from_srt
def from_srt(cls, file): """Reads captions from a file in SubRip format.""" parser = SRTParser().read(file) return cls(file=file, captions=parser.captions)
python
def from_srt(cls, file): """Reads captions from a file in SubRip format.""" parser = SRTParser().read(file) return cls(file=file, captions=parser.captions)
[ "def", "from_srt", "(", "cls", ",", "file", ")", ":", "parser", "=", "SRTParser", "(", ")", ".", "read", "(", "file", ")", "return", "cls", "(", "file", "=", "file", ",", "captions", "=", "parser", ".", "captions", ")" ]
Reads captions from a file in SubRip format.
[ "Reads", "captions", "from", "a", "file", "in", "SubRip", "format", "." ]
7b4da0123c2e2afaf31402107528721eb1d3d481
https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/webvtt.py#L46-L49
train
glut23/webvtt-py
webvtt/webvtt.py
WebVTT.from_sbv
def from_sbv(cls, file): """Reads captions from a file in YouTube SBV format.""" parser = SBVParser().read(file) return cls(file=file, captions=parser.captions)
python
def from_sbv(cls, file): """Reads captions from a file in YouTube SBV format.""" parser = SBVParser().read(file) return cls(file=file, captions=parser.captions)
[ "def", "from_sbv", "(", "cls", ",", "file", ")", ":", "parser", "=", "SBVParser", "(", ")", ".", "read", "(", "file", ")", "return", "cls", "(", "file", "=", "file", ",", "captions", "=", "parser", ".", "captions", ")" ]
Reads captions from a file in YouTube SBV format.
[ "Reads", "captions", "from", "a", "file", "in", "YouTube", "SBV", "format", "." ]
7b4da0123c2e2afaf31402107528721eb1d3d481
https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/webvtt.py#L52-L55
train
glut23/webvtt-py
webvtt/webvtt.py
WebVTT.read
def read(cls, file): """Reads a WebVTT captions file.""" parser = WebVTTParser().read(file) return cls(file=file, captions=parser.captions, styles=parser.styles)
python
def read(cls, file): """Reads a WebVTT captions file.""" parser = WebVTTParser().read(file) return cls(file=file, captions=parser.captions, styles=parser.styles)
[ "def", "read", "(", "cls", ",", "file", ")", ":", "parser", "=", "WebVTTParser", "(", ")", ".", "read", "(", "file", ")", "return", "cls", "(", "file", "=", "file", ",", "captions", "=", "parser", ".", "captions", ",", "styles", "=", "parser", ".",...
Reads a WebVTT captions file.
[ "Reads", "a", "WebVTT", "captions", "file", "." ]
7b4da0123c2e2afaf31402107528721eb1d3d481
https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/webvtt.py#L58-L61
train
glut23/webvtt-py
webvtt/webvtt.py
WebVTT.save
def save(self, output=''): """Save the document. If no output is provided the file will be saved in the same location. Otherwise output can determine a target directory or file. """ self.file = self._get_output_file(output) with open(self.file, 'w', encoding='utf-8') as f...
python
def save(self, output=''): """Save the document. If no output is provided the file will be saved in the same location. Otherwise output can determine a target directory or file. """ self.file = self._get_output_file(output) with open(self.file, 'w', encoding='utf-8') as f...
[ "def", "save", "(", "self", ",", "output", "=", "''", ")", ":", "self", ".", "file", "=", "self", ".", "_get_output_file", "(", "output", ")", "with", "open", "(", "self", ".", "file", ",", "'w'", ",", "encoding", "=", "'utf-8'", ")", "as", "f", ...
Save the document. If no output is provided the file will be saved in the same location. Otherwise output can determine a target directory or file.
[ "Save", "the", "document", ".", "If", "no", "output", "is", "provided", "the", "file", "will", "be", "saved", "in", "the", "same", "location", ".", "Otherwise", "output", "can", "determine", "a", "target", "directory", "or", "file", "." ]
7b4da0123c2e2afaf31402107528721eb1d3d481
https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/webvtt.py#L84-L91
train
glut23/webvtt-py
webvtt/webvtt.py
WebVTT.total_length
def total_length(self): """Returns the total length of the captions.""" if not self._captions: return 0 return int(self._captions[-1].end_in_seconds) - int(self._captions[0].start_in_seconds)
python
def total_length(self): """Returns the total length of the captions.""" if not self._captions: return 0 return int(self._captions[-1].end_in_seconds) - int(self._captions[0].start_in_seconds)
[ "def", "total_length", "(", "self", ")", ":", "if", "not", "self", ".", "_captions", ":", "return", "0", "return", "int", "(", "self", ".", "_captions", "[", "-", "1", "]", ".", "end_in_seconds", ")", "-", "int", "(", "self", ".", "_captions", "[", ...
Returns the total length of the captions.
[ "Returns", "the", "total", "length", "of", "the", "captions", "." ]
7b4da0123c2e2afaf31402107528721eb1d3d481
https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/webvtt.py#L117-L121
train
glut23/webvtt-py
webvtt/segmenter.py
WebVTTSegmenter.segment
def segment(self, webvtt, output='', seconds=SECONDS, mpegts=MPEGTS): """Segments the captions based on a number of seconds.""" if isinstance(webvtt, str): # if a string is supplied we parse the file captions = WebVTT().read(webvtt).captions elif not self._validate_webvtt...
python
def segment(self, webvtt, output='', seconds=SECONDS, mpegts=MPEGTS): """Segments the captions based on a number of seconds.""" if isinstance(webvtt, str): # if a string is supplied we parse the file captions = WebVTT().read(webvtt).captions elif not self._validate_webvtt...
[ "def", "segment", "(", "self", ",", "webvtt", ",", "output", "=", "''", ",", "seconds", "=", "SECONDS", ",", "mpegts", "=", "MPEGTS", ")", ":", "if", "isinstance", "(", "webvtt", ",", "str", ")", ":", "captions", "=", "WebVTT", "(", ")", ".", "read...
Segments the captions based on a number of seconds.
[ "Segments", "the", "captions", "based", "on", "a", "number", "of", "seconds", "." ]
7b4da0123c2e2afaf31402107528721eb1d3d481
https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/segmenter.py#L73-L95
train
simonw/csvs-to-sqlite
csvs_to_sqlite/utils.py
best_fts_version
def best_fts_version(): "Discovers the most advanced supported SQLite FTS version" conn = sqlite3.connect(":memory:") for fts in ("FTS5", "FTS4", "FTS3"): try: conn.execute("CREATE VIRTUAL TABLE v USING {} (t TEXT);".format(fts)) return fts except sqlite3.OperationalE...
python
def best_fts_version(): "Discovers the most advanced supported SQLite FTS version" conn = sqlite3.connect(":memory:") for fts in ("FTS5", "FTS4", "FTS3"): try: conn.execute("CREATE VIRTUAL TABLE v USING {} (t TEXT);".format(fts)) return fts except sqlite3.OperationalE...
[ "def", "best_fts_version", "(", ")", ":", "\"Discovers the most advanced supported SQLite FTS version\"", "conn", "=", "sqlite3", ".", "connect", "(", "\":memory:\"", ")", "for", "fts", "in", "(", "\"FTS5\"", ",", "\"FTS4\"", ",", "\"FTS3\"", ")", ":", "try", ":",...
Discovers the most advanced supported SQLite FTS version
[ "Discovers", "the", "most", "advanced", "supported", "SQLite", "FTS", "version" ]
0a014284eac75c1b06cbdaca362f2a66648c11d2
https://github.com/simonw/csvs-to-sqlite/blob/0a014284eac75c1b06cbdaca362f2a66648c11d2/csvs_to_sqlite/utils.py#L359-L368
train
rochacbruno/manage
manage/commands_collector.py
add_click_commands
def add_click_commands(module, cli, command_dict, namespaced): """Loads all click commands""" module_commands = [ item for item in getmembers(module) if isinstance(item[1], BaseCommand) ] options = command_dict.get('config', {}) namespace = command_dict.get('namespace') for name,...
python
def add_click_commands(module, cli, command_dict, namespaced): """Loads all click commands""" module_commands = [ item for item in getmembers(module) if isinstance(item[1], BaseCommand) ] options = command_dict.get('config', {}) namespace = command_dict.get('namespace') for name,...
[ "def", "add_click_commands", "(", "module", ",", "cli", ",", "command_dict", ",", "namespaced", ")", ":", "module_commands", "=", "[", "item", "for", "item", "in", "getmembers", "(", "module", ")", "if", "isinstance", "(", "item", "[", "1", "]", ",", "Ba...
Loads all click commands
[ "Loads", "all", "click", "commands" ]
e904c451862f036f4be8723df5704a9844103c74
https://github.com/rochacbruno/manage/blob/e904c451862f036f4be8723df5704a9844103c74/manage/commands_collector.py#L10-L27
train
rochacbruno/manage
manage/commands_collector.py
load_commands
def load_commands(cli, manage_dict): """Loads the commands defined in manage file""" namespaced = manage_dict.get('namespaced') # get click commands commands = manage_dict.get('click_commands', []) for command_dict in commands: root_module = import_string(command_dict['module']) gro...
python
def load_commands(cli, manage_dict): """Loads the commands defined in manage file""" namespaced = manage_dict.get('namespaced') # get click commands commands = manage_dict.get('click_commands', []) for command_dict in commands: root_module = import_string(command_dict['module']) gro...
[ "def", "load_commands", "(", "cli", ",", "manage_dict", ")", ":", "namespaced", "=", "manage_dict", ".", "get", "(", "'namespaced'", ")", "commands", "=", "manage_dict", ".", "get", "(", "'click_commands'", ",", "[", "]", ")", "for", "command_dict", "in", ...
Loads the commands defined in manage file
[ "Loads", "the", "commands", "defined", "in", "manage", "file" ]
e904c451862f036f4be8723df5704a9844103c74
https://github.com/rochacbruno/manage/blob/e904c451862f036f4be8723df5704a9844103c74/manage/commands_collector.py#L83-L143
train
rochacbruno/manage
manage/cli.py
debug
def debug(version=False): """Shows the parsed manage file -V shows version""" if version: print(__version__) return print(json.dumps(MANAGE_DICT, indent=2))
python
def debug(version=False): """Shows the parsed manage file -V shows version""" if version: print(__version__) return print(json.dumps(MANAGE_DICT, indent=2))
[ "def", "debug", "(", "version", "=", "False", ")", ":", "if", "version", ":", "print", "(", "__version__", ")", "return", "print", "(", "json", ".", "dumps", "(", "MANAGE_DICT", ",", "indent", "=", "2", ")", ")" ]
Shows the parsed manage file -V shows version
[ "Shows", "the", "parsed", "manage", "file", "-", "V", "shows", "version" ]
e904c451862f036f4be8723df5704a9844103c74
https://github.com/rochacbruno/manage/blob/e904c451862f036f4be8723df5704a9844103c74/manage/cli.py#L95-L100
train
rochacbruno/manage
manage/cli.py
create_shell
def create_shell(console, manage_dict=None, extra_vars=None, exit_hooks=None): """Creates the shell""" manage_dict = manage_dict or MANAGE_DICT _vars = globals() _vars.update(locals()) auto_imported = import_objects(manage_dict) if extra_vars: auto_imported.update(extra_vars) _vars.u...
python
def create_shell(console, manage_dict=None, extra_vars=None, exit_hooks=None): """Creates the shell""" manage_dict = manage_dict or MANAGE_DICT _vars = globals() _vars.update(locals()) auto_imported = import_objects(manage_dict) if extra_vars: auto_imported.update(extra_vars) _vars.u...
[ "def", "create_shell", "(", "console", ",", "manage_dict", "=", "None", ",", "extra_vars", "=", "None", ",", "exit_hooks", "=", "None", ")", ":", "manage_dict", "=", "manage_dict", "or", "MANAGE_DICT", "_vars", "=", "globals", "(", ")", "_vars", ".", "upda...
Creates the shell
[ "Creates", "the", "shell" ]
e904c451862f036f4be8723df5704a9844103c74
https://github.com/rochacbruno/manage/blob/e904c451862f036f4be8723df5704a9844103c74/manage/cli.py#L103-L180
train
sk-/git-lint
gitlint/__init__.py
find_invalid_filenames
def find_invalid_filenames(filenames, repository_root): """Find files that does not exist, are not in the repo or are directories. Args: filenames: list of filenames to check repository_root: the absolute path of the repository's root. Returns: A list of errors. """ errors = [] for...
python
def find_invalid_filenames(filenames, repository_root): """Find files that does not exist, are not in the repo or are directories. Args: filenames: list of filenames to check repository_root: the absolute path of the repository's root. Returns: A list of errors. """ errors = [] for...
[ "def", "find_invalid_filenames", "(", "filenames", ",", "repository_root", ")", ":", "errors", "=", "[", "]", "for", "filename", "in", "filenames", ":", "if", "not", "os", ".", "path", ".", "abspath", "(", "filename", ")", ".", "startswith", "(", "reposito...
Find files that does not exist, are not in the repo or are directories. Args: filenames: list of filenames to check repository_root: the absolute path of the repository's root. Returns: A list of errors.
[ "Find", "files", "that", "does", "not", "exist", "are", "not", "in", "the", "repo", "or", "are", "directories", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/__init__.py#L65-L87
train
sk-/git-lint
gitlint/__init__.py
get_config
def get_config(repo_root): """Gets the configuration file either from the repository or the default.""" config = os.path.join(os.path.dirname(__file__), 'configs', 'config.yaml') if repo_root: repo_config = os.path.join(repo_root, '.gitlint.yaml') if os.path.exists(repo_config): ...
python
def get_config(repo_root): """Gets the configuration file either from the repository or the default.""" config = os.path.join(os.path.dirname(__file__), 'configs', 'config.yaml') if repo_root: repo_config = os.path.join(repo_root, '.gitlint.yaml') if os.path.exists(repo_config): ...
[ "def", "get_config", "(", "repo_root", ")", ":", "config", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'configs'", ",", "'config.yaml'", ")", "if", "repo_root", ":", "repo_config", "=", "os",...
Gets the configuration file either from the repository or the default.
[ "Gets", "the", "configuration", "file", "either", "from", "the", "repository", "or", "the", "default", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/__init__.py#L90-L109
train
sk-/git-lint
gitlint/__init__.py
format_comment
def format_comment(comment_data): """Formats the data returned by the linters. Given a dictionary with the fields: line, column, severity, message_id, message, will generate a message like: 'line {line}, col {column}: {severity}: [{message_id}]: {message}' Any of the fields may nbe absent. A...
python
def format_comment(comment_data): """Formats the data returned by the linters. Given a dictionary with the fields: line, column, severity, message_id, message, will generate a message like: 'line {line}, col {column}: {severity}: [{message_id}]: {message}' Any of the fields may nbe absent. A...
[ "def", "format_comment", "(", "comment_data", ")", ":", "format_pieces", "=", "[", "]", "if", "'line'", "in", "comment_data", ":", "format_pieces", ".", "append", "(", "'line {line}'", ")", "if", "'column'", "in", "comment_data", ":", "if", "format_pieces", ":...
Formats the data returned by the linters. Given a dictionary with the fields: line, column, severity, message_id, message, will generate a message like: 'line {line}, col {column}: {severity}: [{message_id}]: {message}' Any of the fields may nbe absent. Args: comment_data: dictionary with ...
[ "Formats", "the", "data", "returned", "by", "the", "linters", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/__init__.py#L112-L150
train
sk-/git-lint
gitlint/__init__.py
get_vcs_root
def get_vcs_root(): """Returns the vcs module and the root of the repo. Returns: A tuple containing the vcs module to use (git, hg) and the root of the repository. If no repository exisits then (None, None) is returned. """ for vcs in (git, hg): repo_root = vcs.repository_root() ...
python
def get_vcs_root(): """Returns the vcs module and the root of the repo. Returns: A tuple containing the vcs module to use (git, hg) and the root of the repository. If no repository exisits then (None, None) is returned. """ for vcs in (git, hg): repo_root = vcs.repository_root() ...
[ "def", "get_vcs_root", "(", ")", ":", "for", "vcs", "in", "(", "git", ",", "hg", ")", ":", "repo_root", "=", "vcs", ".", "repository_root", "(", ")", "if", "repo_root", ":", "return", "vcs", ",", "repo_root", "return", "(", "None", ",", "None", ")" ]
Returns the vcs module and the root of the repo. Returns: A tuple containing the vcs module to use (git, hg) and the root of the repository. If no repository exisits then (None, None) is returned.
[ "Returns", "the", "vcs", "module", "and", "the", "root", "of", "the", "repo", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/__init__.py#L153-L165
train
sk-/git-lint
gitlint/__init__.py
process_file
def process_file(vcs, commit, force, gitlint_config, file_data): """Lint the file Returns: The results from the linter. """ filename, extra_data = file_data if force: modified_lines = None else: modified_lines = vcs.modified_lines( filename, extra_data, commit...
python
def process_file(vcs, commit, force, gitlint_config, file_data): """Lint the file Returns: The results from the linter. """ filename, extra_data = file_data if force: modified_lines = None else: modified_lines = vcs.modified_lines( filename, extra_data, commit...
[ "def", "process_file", "(", "vcs", ",", "commit", ",", "force", ",", "gitlint_config", ",", "file_data", ")", ":", "filename", ",", "extra_data", "=", "file_data", "if", "force", ":", "modified_lines", "=", "None", "else", ":", "modified_lines", "=", "vcs", ...
Lint the file Returns: The results from the linter.
[ "Lint", "the", "file" ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/__init__.py#L168-L184
train
sk-/git-lint
gitlint/hg.py
last_commit
def last_commit(): """Returns the SHA1 of the last commit.""" try: root = subprocess.check_output( ['hg', 'parent', '--template={node}'], stderr=subprocess.STDOUT).strip() # Convert to unicode first return root.decode('utf-8') except subprocess.CalledProcessEr...
python
def last_commit(): """Returns the SHA1 of the last commit.""" try: root = subprocess.check_output( ['hg', 'parent', '--template={node}'], stderr=subprocess.STDOUT).strip() # Convert to unicode first return root.decode('utf-8') except subprocess.CalledProcessEr...
[ "def", "last_commit", "(", ")", ":", "try", ":", "root", "=", "subprocess", ".", "check_output", "(", "[", "'hg'", ",", "'parent'", ",", "'--template={node}'", "]", ",", "stderr", "=", "subprocess", ".", "STDOUT", ")", ".", "strip", "(", ")", "return", ...
Returns the SHA1 of the last commit.
[ "Returns", "the", "SHA1", "of", "the", "last", "commit", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/hg.py#L33-L42
train
sk-/git-lint
gitlint/hg.py
modified_files
def modified_files(root, tracked_only=False, commit=None): """Returns a list of files that has been modified since the last commit. Args: root: the root of the repository, it has to be an absolute path. tracked_only: exclude untracked files when True. commit: SHA1 of the commit. If None, it w...
python
def modified_files(root, tracked_only=False, commit=None): """Returns a list of files that has been modified since the last commit. Args: root: the root of the repository, it has to be an absolute path. tracked_only: exclude untracked files when True. commit: SHA1 of the commit. If None, it w...
[ "def", "modified_files", "(", "root", ",", "tracked_only", "=", "False", ",", "commit", "=", "None", ")", ":", "assert", "os", ".", "path", ".", "isabs", "(", "root", ")", ",", "\"Root has to be absolute, got: %s\"", "%", "root", "command", "=", "[", "'hg'...
Returns a list of files that has been modified since the last commit. Args: root: the root of the repository, it has to be an absolute path. tracked_only: exclude untracked files when True. commit: SHA1 of the commit. If None, it will get the modified files in the working copy. Retur...
[ "Returns", "a", "list", "of", "files", "that", "has", "been", "modified", "since", "the", "last", "commit", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/hg.py#L45-L79
train
sk-/git-lint
scripts/custom_linters/ini_linter.py
lint
def lint(filename): """Lints an INI file, returning 0 in case of success.""" config = ConfigParser.ConfigParser() try: config.read(filename) return 0 except ConfigParser.Error as error: print('Error: %s' % error) return 1 except: print('Unexpected Error') ...
python
def lint(filename): """Lints an INI file, returning 0 in case of success.""" config = ConfigParser.ConfigParser() try: config.read(filename) return 0 except ConfigParser.Error as error: print('Error: %s' % error) return 1 except: print('Unexpected Error') ...
[ "def", "lint", "(", "filename", ")", ":", "config", "=", "ConfigParser", ".", "ConfigParser", "(", ")", "try", ":", "config", ".", "read", "(", "filename", ")", "return", "0", "except", "ConfigParser", ".", "Error", "as", "error", ":", "print", "(", "'...
Lints an INI file, returning 0 in case of success.
[ "Lints", "an", "INI", "file", "returning", "0", "in", "case", "of", "success", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/scripts/custom_linters/ini_linter.py#L23-L34
train
sk-/git-lint
gitlint/linters.py
missing_requirements_command
def missing_requirements_command(missing_programs, installation_string, filename, unused_lines): """Pseudo-command to be used when requirements are missing.""" verb = 'is' if len(missing_programs) > 1: verb = 'are' return { filename: { 'skippe...
python
def missing_requirements_command(missing_programs, installation_string, filename, unused_lines): """Pseudo-command to be used when requirements are missing.""" verb = 'is' if len(missing_programs) > 1: verb = 'are' return { filename: { 'skippe...
[ "def", "missing_requirements_command", "(", "missing_programs", ",", "installation_string", ",", "filename", ",", "unused_lines", ")", ":", "verb", "=", "'is'", "if", "len", "(", "missing_programs", ")", ">", "1", ":", "verb", "=", "'are'", "return", "{", "fil...
Pseudo-command to be used when requirements are missing.
[ "Pseudo", "-", "command", "to", "be", "used", "when", "requirements", "are", "missing", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/linters.py#L41-L54
train
sk-/git-lint
gitlint/linters.py
lint_command
def lint_command(name, program, arguments, filter_regex, filename, lines): """Executes a lint program and filter the output. Executes the lint tool 'program' with arguments 'arguments' over the file 'filename' returning only those lines matching the regular expression 'filter_regex'. Args: n...
python
def lint_command(name, program, arguments, filter_regex, filename, lines): """Executes a lint program and filter the output. Executes the lint tool 'program' with arguments 'arguments' over the file 'filename' returning only those lines matching the regular expression 'filter_regex'. Args: n...
[ "def", "lint_command", "(", "name", ",", "program", ",", "arguments", ",", "filter_regex", ",", "filename", ",", "lines", ")", ":", "output", "=", "utils", ".", "get_output_from_cache", "(", "name", ",", "filename", ")", "if", "output", "is", "None", ":", ...
Executes a lint program and filter the output. Executes the lint tool 'program' with arguments 'arguments' over the file 'filename' returning only those lines matching the regular expression 'filter_regex'. Args: name: string: the name of the linter. program: string: lint program. ar...
[ "Executes", "a", "lint", "program", "and", "filter", "the", "output", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/linters.py#L58-L121
train
sk-/git-lint
gitlint/linters.py
_replace_variables
def _replace_variables(data, variables): """Replace the format variables in all items of data.""" formatter = string.Formatter() return [formatter.vformat(item, [], variables) for item in data]
python
def _replace_variables(data, variables): """Replace the format variables in all items of data.""" formatter = string.Formatter() return [formatter.vformat(item, [], variables) for item in data]
[ "def", "_replace_variables", "(", "data", ",", "variables", ")", ":", "formatter", "=", "string", ".", "Formatter", "(", ")", "return", "[", "formatter", ".", "vformat", "(", "item", ",", "[", "]", ",", "variables", ")", "for", "item", "in", "data", "]...
Replace the format variables in all items of data.
[ "Replace", "the", "format", "variables", "in", "all", "items", "of", "data", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/linters.py#L124-L127
train
sk-/git-lint
gitlint/linters.py
lint
def lint(filename, lines, config): """Lints a file. Args: filename: string: filename to lint. lines: list[int]|None: list of lines that we want to capture. If None, then all lines will be captured. config: dict[string: linter]: mapping from extension to a linter func...
python
def lint(filename, lines, config): """Lints a file. Args: filename: string: filename to lint. lines: list[int]|None: list of lines that we want to capture. If None, then all lines will be captured. config: dict[string: linter]: mapping from extension to a linter func...
[ "def", "lint", "(", "filename", ",", "lines", ",", "config", ")", ":", "_", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "if", "ext", "in", "config", ":", "output", "=", "collections", ".", "defaultdict", "(", "list", ...
Lints a file. Args: filename: string: filename to lint. lines: list[int]|None: list of lines that we want to capture. If None, then all lines will be captured. config: dict[string: linter]: mapping from extension to a linter function. Returns: dict: if there were er...
[ "Lints", "a", "file", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/linters.py#L160-L197
train
sk-/git-lint
gitlint/utils.py
filter_lines
def filter_lines(lines, filter_regex, groups=None): """Filters out the lines not matching the pattern. Args: lines: list[string]: lines to filter. pattern: string: regular expression to filter out lines. Returns: list[string]: the list of filtered lines. """ pattern = re.compile(filter...
python
def filter_lines(lines, filter_regex, groups=None): """Filters out the lines not matching the pattern. Args: lines: list[string]: lines to filter. pattern: string: regular expression to filter out lines. Returns: list[string]: the list of filtered lines. """ pattern = re.compile(filter...
[ "def", "filter_lines", "(", "lines", ",", "filter_regex", ",", "groups", "=", "None", ")", ":", "pattern", "=", "re", ".", "compile", "(", "filter_regex", ")", "for", "line", "in", "lines", ":", "match", "=", "pattern", ".", "search", "(", "line", ")",...
Filters out the lines not matching the pattern. Args: lines: list[string]: lines to filter. pattern: string: regular expression to filter out lines. Returns: list[string]: the list of filtered lines.
[ "Filters", "out", "the", "lines", "not", "matching", "the", "pattern", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/utils.py#L24-L43
train
sk-/git-lint
gitlint/utils.py
which
def which(program): """Returns a list of paths where the program is found.""" if (os.path.isabs(program) and os.path.isfile(program) and os.access(program, os.X_OK)): return [program] candidates = [] locations = os.environ.get("PATH").split(os.pathsep) for location in locations:...
python
def which(program): """Returns a list of paths where the program is found.""" if (os.path.isabs(program) and os.path.isfile(program) and os.access(program, os.X_OK)): return [program] candidates = [] locations = os.environ.get("PATH").split(os.pathsep) for location in locations:...
[ "def", "which", "(", "program", ")", ":", "if", "(", "os", ".", "path", ".", "isabs", "(", "program", ")", "and", "os", ".", "path", ".", "isfile", "(", "program", ")", "and", "os", ".", "access", "(", "program", ",", "os", ".", "X_OK", ")", ")...
Returns a list of paths where the program is found.
[ "Returns", "a", "list", "of", "paths", "where", "the", "program", "is", "found", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/utils.py#L47-L59
train
sk-/git-lint
gitlint/utils.py
_open_for_write
def _open_for_write(filename): """Opens filename for writing, creating the directories if needed.""" dirname = os.path.dirname(filename) pathlib.Path(dirname).mkdir(parents=True, exist_ok=True) return io.open(filename, 'w')
python
def _open_for_write(filename): """Opens filename for writing, creating the directories if needed.""" dirname = os.path.dirname(filename) pathlib.Path(dirname).mkdir(parents=True, exist_ok=True) return io.open(filename, 'w')
[ "def", "_open_for_write", "(", "filename", ")", ":", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "filename", ")", "pathlib", ".", "Path", "(", "dirname", ")", ".", "mkdir", "(", "parents", "=", "True", ",", "exist_ok", "=", "True", ")", "...
Opens filename for writing, creating the directories if needed.
[ "Opens", "filename", "for", "writing", "creating", "the", "directories", "if", "needed", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/utils.py#L67-L72
train
sk-/git-lint
gitlint/utils.py
_get_cache_filename
def _get_cache_filename(name, filename): """Returns the cache location for filename and linter name.""" filename = os.path.abspath(filename)[1:] home_folder = os.path.expanduser('~') base_cache_dir = os.path.join(home_folder, '.git-lint', 'cache') return os.path.join(base_cache_dir, name, filename)
python
def _get_cache_filename(name, filename): """Returns the cache location for filename and linter name.""" filename = os.path.abspath(filename)[1:] home_folder = os.path.expanduser('~') base_cache_dir = os.path.join(home_folder, '.git-lint', 'cache') return os.path.join(base_cache_dir, name, filename)
[ "def", "_get_cache_filename", "(", "name", ",", "filename", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "[", "1", ":", "]", "home_folder", "=", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "base_cache_d...
Returns the cache location for filename and linter name.
[ "Returns", "the", "cache", "location", "for", "filename", "and", "linter", "name", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/utils.py#L75-L81
train
sk-/git-lint
gitlint/utils.py
get_output_from_cache
def get_output_from_cache(name, filename): """Returns the output from the cache if still valid. It checks that the cache file is defined and that its modification time is after the modification time of the original file. Args: name: string: name of the linter. filename: string: path of the...
python
def get_output_from_cache(name, filename): """Returns the output from the cache if still valid. It checks that the cache file is defined and that its modification time is after the modification time of the original file. Args: name: string: name of the linter. filename: string: path of the...
[ "def", "get_output_from_cache", "(", "name", ",", "filename", ")", ":", "cache_filename", "=", "_get_cache_filename", "(", "name", ",", "filename", ")", "if", "(", "os", ".", "path", ".", "exists", "(", "cache_filename", ")", "and", "os", ".", "path", ".",...
Returns the output from the cache if still valid. It checks that the cache file is defined and that its modification time is after the modification time of the original file. Args: name: string: name of the linter. filename: string: path of the filename for which we are retrieving the ...
[ "Returns", "the", "output", "from", "the", "cache", "if", "still", "valid", "." ]
4f19ec88bfa1b6670ff37ccbfc53c6b67251b027
https://github.com/sk-/git-lint/blob/4f19ec88bfa1b6670ff37ccbfc53c6b67251b027/gitlint/utils.py#L84-L103
train