repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
robhowley/nhlscrapi
nhlscrapi/games/eventsummary.py
EventSummary.sort_players
def sort_players(self, sort_key=None, sort_func=None, reverse=False): """ Return all home and away by player info sorted by either the provided key or function. Must provide at least one of the two parameters. Can sort either ascending or descending. :param sort_key: (def None) ...
python
def sort_players(self, sort_key=None, sort_func=None, reverse=False): """ Return all home and away by player info sorted by either the provided key or function. Must provide at least one of the two parameters. Can sort either ascending or descending. :param sort_key: (def None) ...
[ "def", "sort_players", "(", "self", ",", "sort_key", "=", "None", ",", "sort_func", "=", "None", ",", "reverse", "=", "False", ")", ":", "def", "each", "(", "d", ")", ":", "t", "=", "[", "]", "for", "num", ",", "v", "in", "d", ".", "items", "("...
Return all home and away by player info sorted by either the provided key or function. Must provide at least one of the two parameters. Can sort either ascending or descending. :param sort_key: (def None) dict key to sort on :param sort_func: (def None) sorting function :param r...
[ "Return", "all", "home", "and", "away", "by", "player", "info", "sorted", "by", "either", "the", "provided", "key", "or", "function", ".", "Must", "provide", "at", "least", "one", "of", "the", "two", "parameters", ".", "Can", "sort", "either", "ascending",...
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/eventsummary.py#L172-L194
robhowley/nhlscrapi
nhlscrapi/games/eventsummary.py
EventSummary.top_by_key
def top_by_key(self, sort_key): """ Return home/away by player info for the players on each team that are first in the provided category. :param sort_key: str, the dictionary key to be sorted on :returns: dict of the form ``{ 'home/away': { by_player_dict } }``. See :py:func:`ho...
python
def top_by_key(self, sort_key): """ Return home/away by player info for the players on each team that are first in the provided category. :param sort_key: str, the dictionary key to be sorted on :returns: dict of the form ``{ 'home/away': { by_player_dict } }``. See :py:func:`ho...
[ "def", "top_by_key", "(", "self", ",", "sort_key", ")", ":", "res", "=", "self", ".", "sort_players", "(", "sort_key", "=", "sort_key", ",", "reverse", "=", "True", ")", "return", "{", "'home'", ":", "res", "[", "'home'", "]", "[", "0", "]", ",", "...
Return home/away by player info for the players on each team that are first in the provided category. :param sort_key: str, the dictionary key to be sorted on :returns: dict of the form ``{ 'home/away': { by_player_dict } }``. See :py:func:`home_players` and :py:func:`away_players`
[ "Return", "home", "/", "away", "by", "player", "info", "for", "the", "players", "on", "each", "team", "that", "are", "first", "in", "the", "provided", "category", ".", ":", "param", "sort_key", ":", "str", "the", "dictionary", "key", "to", "be", "sorted"...
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/eventsummary.py#L226-L237
robhowley/nhlscrapi
nhlscrapi/games/eventsummary.py
EventSummary.top_by_func
def top_by_func(self, sort_func): """ Return home/away by player info for the players on each team who come in first according to the provided sorting function. Will perform ascending sort. :param sort_func: function that yields the sorting quantity :returns: dict of the...
python
def top_by_func(self, sort_func): """ Return home/away by player info for the players on each team who come in first according to the provided sorting function. Will perform ascending sort. :param sort_func: function that yields the sorting quantity :returns: dict of the...
[ "def", "top_by_func", "(", "self", ",", "sort_func", ")", ":", "res", "=", "self", ".", "sort_players", "(", "sort_func", "=", "sort_func", ",", "reverse", "=", "True", ")", "return", "{", "'home'", ":", "res", "[", "'home'", "]", "[", "0", "]", ",",...
Return home/away by player info for the players on each team who come in first according to the provided sorting function. Will perform ascending sort. :param sort_func: function that yields the sorting quantity :returns: dict of the form ``{ 'home/away': { by_player_dict } }``. See :py...
[ "Return", "home", "/", "away", "by", "player", "info", "for", "the", "players", "on", "each", "team", "who", "come", "in", "first", "according", "to", "the", "provided", "sorting", "function", ".", "Will", "perform", "ascending", "sort", ".", ":", "param",...
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/eventsummary.py#L239-L251
ryanpetrello/python-zombie
zombie/proxy/client.py
encode
def encode(obj): """ Encode one argument/object to json """ if hasattr(obj, 'json'): return obj.json if hasattr(obj, '__json__'): return obj.__json__() return dumps(obj)
python
def encode(obj): """ Encode one argument/object to json """ if hasattr(obj, 'json'): return obj.json if hasattr(obj, '__json__'): return obj.__json__() return dumps(obj)
[ "def", "encode", "(", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "'json'", ")", ":", "return", "obj", ".", "json", "if", "hasattr", "(", "obj", ",", "'__json__'", ")", ":", "return", "obj", ".", "__json__", "(", ")", "return", "dumps", "(",...
Encode one argument/object to json
[ "Encode", "one", "argument", "/", "object", "to", "json" ]
train
https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/proxy/client.py#L14-L22
ryanpetrello/python-zombie
zombie/proxy/client.py
encode_args
def encode_args(args, extra=False): """ Encode a list of arguments """ if not args: return '' methodargs = ', '.join([encode(a) for a in args]) if extra: methodargs += ', ' return methodargs
python
def encode_args(args, extra=False): """ Encode a list of arguments """ if not args: return '' methodargs = ', '.join([encode(a) for a in args]) if extra: methodargs += ', ' return methodargs
[ "def", "encode_args", "(", "args", ",", "extra", "=", "False", ")", ":", "if", "not", "args", ":", "return", "''", "methodargs", "=", "', '", ".", "join", "(", "[", "encode", "(", "a", ")", "for", "a", "in", "args", "]", ")", "if", "extra", ":", ...
Encode a list of arguments
[ "Encode", "a", "list", "of", "arguments" ]
train
https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/proxy/client.py#L25-L36
ryanpetrello/python-zombie
zombie/proxy/client.py
ZombieProxyClient._send
def _send(self, javascript): """ Establishes a socket connection to the zombie.js server and sends Javascript instructions. :param js: the Javascript string to execute """ # Prepend JS to switch to the proper client context. message = """ var _ctx = ...
python
def _send(self, javascript): """ Establishes a socket connection to the zombie.js server and sends Javascript instructions. :param js: the Javascript string to execute """ # Prepend JS to switch to the proper client context. message = """ var _ctx = ...
[ "def", "_send", "(", "self", ",", "javascript", ")", ":", "# Prepend JS to switch to the proper client context.", "message", "=", "\"\"\"\n var _ctx = ctx_switch('%s'),\n browser = _ctx[0],\n ELEMENTS = _ctx[1];\n %s\n \"\"\"", "%", ...
Establishes a socket connection to the zombie.js server and sends Javascript instructions. :param js: the Javascript string to execute
[ "Establishes", "a", "socket", "connection", "to", "the", "zombie", ".", "js", "server", "and", "sends", "Javascript", "instructions", "." ]
train
https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/proxy/client.py#L123-L141
ryanpetrello/python-zombie
zombie/proxy/client.py
ZombieProxyClient.wait
def wait(self, method, *args): """ Call a method on the zombie.js Browser instance and wait on a callback. :param method: the method to call, e.g., html() :param args: one of more arguments for the method """ methodargs = encode_args(args, extra=True) js = """ ...
python
def wait(self, method, *args): """ Call a method on the zombie.js Browser instance and wait on a callback. :param method: the method to call, e.g., html() :param args: one of more arguments for the method """ methodargs = encode_args(args, extra=True) js = """ ...
[ "def", "wait", "(", "self", ",", "method", ",", "*", "args", ")", ":", "methodargs", "=", "encode_args", "(", "args", ",", "extra", "=", "True", ")", "js", "=", "\"\"\"\n %s(%s wait_callback);\n \"\"\"", "%", "(", "method", ",", "methodargs", "...
Call a method on the zombie.js Browser instance and wait on a callback. :param method: the method to call, e.g., html() :param args: one of more arguments for the method
[ "Call", "a", "method", "on", "the", "zombie", ".", "js", "Browser", "instance", "and", "wait", "on", "a", "callback", "." ]
train
https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/proxy/client.py#L168-L179
ryanpetrello/python-zombie
zombie/proxy/client.py
ZombieProxyClient.create_element
def create_element(self, method, args=None): """ Evaluate a browser method and CSS selector against the document (or an optional context DOMNode) and return a single :class:`zombie.dom.DOMNode` object, e.g., browser._node('query', 'body > div') ...roughly translates to ...
python
def create_element(self, method, args=None): """ Evaluate a browser method and CSS selector against the document (or an optional context DOMNode) and return a single :class:`zombie.dom.DOMNode` object, e.g., browser._node('query', 'body > div') ...roughly translates to ...
[ "def", "create_element", "(", "self", ",", "method", ",", "args", "=", "None", ")", ":", "if", "args", "is", "None", ":", "arguments", "=", "''", "else", ":", "arguments", "=", "\"(%s)\"", "%", "encode_args", "(", "args", ")", "js", "=", "\"\"\"\n ...
Evaluate a browser method and CSS selector against the document (or an optional context DOMNode) and return a single :class:`zombie.dom.DOMNode` object, e.g., browser._node('query', 'body > div') ...roughly translates to the following Javascript... browser.query('body > div') ...
[ "Evaluate", "a", "browser", "method", "and", "CSS", "selector", "against", "the", "document", "(", "or", "an", "optional", "context", "DOMNode", ")", "and", "return", "a", "single", ":", "class", ":", "zombie", ".", "dom", ".", "DOMNode", "object", "e", ...
train
https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/proxy/client.py#L213-L245
ryanpetrello/python-zombie
zombie/proxy/client.py
ZombieProxyClient.create_elements
def create_elements(self, method, args=[]): """ Execute a browser method that will return a list of elements. Returns a list of the element indexes """ args = encode_args(args) js = """ create_elements(ELEMENTS, %(method)s(%(args)s)) """ % { ...
python
def create_elements(self, method, args=[]): """ Execute a browser method that will return a list of elements. Returns a list of the element indexes """ args = encode_args(args) js = """ create_elements(ELEMENTS, %(method)s(%(args)s)) """ % { ...
[ "def", "create_elements", "(", "self", ",", "method", ",", "args", "=", "[", "]", ")", ":", "args", "=", "encode_args", "(", "args", ")", "js", "=", "\"\"\"\n create_elements(ELEMENTS, %(method)s(%(args)s))\n \"\"\"", "%", "{", "'method'", ":", "...
Execute a browser method that will return a list of elements. Returns a list of the element indexes
[ "Execute", "a", "browser", "method", "that", "will", "return", "a", "list", "of", "elements", "." ]
train
https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/proxy/client.py#L247-L263
ryanpetrello/python-zombie
zombie/browser.py
Browser.fill
def fill(self, field, value): """ Fill a specified form field in the current document. :param field: an instance of :class:`zombie.dom.DOMNode` :param value: any string value :return: self to allow function chaining. """ self.client.nowait('browser.fill', (field,...
python
def fill(self, field, value): """ Fill a specified form field in the current document. :param field: an instance of :class:`zombie.dom.DOMNode` :param value: any string value :return: self to allow function chaining. """ self.client.nowait('browser.fill', (field,...
[ "def", "fill", "(", "self", ",", "field", ",", "value", ")", ":", "self", ".", "client", ".", "nowait", "(", "'browser.fill'", ",", "(", "field", ",", "value", ")", ")", "return", "self" ]
Fill a specified form field in the current document. :param field: an instance of :class:`zombie.dom.DOMNode` :param value: any string value :return: self to allow function chaining.
[ "Fill", "a", "specified", "form", "field", "in", "the", "current", "document", "." ]
train
https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/browser.py#L39-L48
ryanpetrello/python-zombie
zombie/browser.py
Browser.query
def query(self, selector, context=None): """ Evaluate a CSS selector against the document (or an optional context :class:`zombie.dom.DOMNode`) and return a single :class:`zombie.dom.DOMNode` object. :param selector: a string CSS selector (http://zombie.la...
python
def query(self, selector, context=None): """ Evaluate a CSS selector against the document (or an optional context :class:`zombie.dom.DOMNode`) and return a single :class:`zombie.dom.DOMNode` object. :param selector: a string CSS selector (http://zombie.la...
[ "def", "query", "(", "self", ",", "selector", ",", "context", "=", "None", ")", ":", "element", "=", "self", ".", "client", ".", "create_element", "(", "'browser.query'", ",", "(", "selector", ",", "context", ")", ")", "return", "DOMNode", ".", "factory"...
Evaluate a CSS selector against the document (or an optional context :class:`zombie.dom.DOMNode`) and return a single :class:`zombie.dom.DOMNode` object. :param selector: a string CSS selector (http://zombie.labnotes.org/selectors) :param context: an (optional) i...
[ "Evaluate", "a", "CSS", "selector", "against", "the", "document", "(", "or", "an", "optional", "context", ":", "class", ":", "zombie", ".", "dom", ".", "DOMNode", ")", "and", "return", "a", "single", ":", "class", ":", "zombie", ".", "dom", ".", "DOMNo...
train
https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/browser.py#L124-L136
ryanpetrello/python-zombie
zombie/browser.py
Browser.queryAll
def queryAll(self, selector, context=None): """ Evaluate a CSS selector against the document (or an optional context :class:`zombie.dom.DOMNode`) and return a list of :class:`zombie.dom.DOMNode` objects. :param selector: a string CSS selector (http://zomb...
python
def queryAll(self, selector, context=None): """ Evaluate a CSS selector against the document (or an optional context :class:`zombie.dom.DOMNode`) and return a list of :class:`zombie.dom.DOMNode` objects. :param selector: a string CSS selector (http://zomb...
[ "def", "queryAll", "(", "self", ",", "selector", ",", "context", "=", "None", ")", ":", "elements", "=", "self", ".", "client", ".", "create_elements", "(", "'browser.queryAll'", ",", "(", "selector", ",", "context", ")", ")", "return", "[", "DOMNode", "...
Evaluate a CSS selector against the document (or an optional context :class:`zombie.dom.DOMNode`) and return a list of :class:`zombie.dom.DOMNode` objects. :param selector: a string CSS selector (http://zombie.labnotes.org/selectors) :param context: an (optional)...
[ "Evaluate", "a", "CSS", "selector", "against", "the", "document", "(", "or", "an", "optional", "context", ":", "class", ":", "zombie", ".", "dom", ".", "DOMNode", ")", "and", "return", "a", "list", "of", ":", "class", ":", "zombie", ".", "dom", ".", ...
train
https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/browser.py#L138-L150
ryanpetrello/python-zombie
zombie/browser.py
Browser.link
def link(self, selector): """ Finds and returns a link ``<a>`` element (:class:`zombie.dom.DOMNode`). You can use a CSS selector or find a link by its text contents (case sensitive, but ignores leading/trailing spaces). :param selector: an optional string CSS selector ...
python
def link(self, selector): """ Finds and returns a link ``<a>`` element (:class:`zombie.dom.DOMNode`). You can use a CSS selector or find a link by its text contents (case sensitive, but ignores leading/trailing spaces). :param selector: an optional string CSS selector ...
[ "def", "link", "(", "self", ",", "selector", ")", ":", "element", "=", "self", ".", "client", ".", "create_element", "(", "'browser.link'", ",", "(", "selector", ",", ")", ")", "return", "DOMNode", "(", "element", ",", "self", ")" ]
Finds and returns a link ``<a>`` element (:class:`zombie.dom.DOMNode`). You can use a CSS selector or find a link by its text contents (case sensitive, but ignores leading/trailing spaces). :param selector: an optional string CSS selector (http://zombie.labnotes.org/sele...
[ "Finds", "and", "returns", "a", "link", "<a", ">", "element", "(", ":", "class", ":", "zombie", ".", "dom", ".", "DOMNode", ")", ".", "You", "can", "use", "a", "CSS", "selector", "or", "find", "a", "link", "by", "its", "text", "contents", "(", "cas...
train
https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/browser.py#L234-L244
ryanpetrello/python-zombie
zombie/browser.py
DOMNode.value
def value(self, value): """ Used to set the ``value`` of form elements. """ self.client.nowait( 'set_field', (Literal('browser'), self.element, value))
python
def value(self, value): """ Used to set the ``value`` of form elements. """ self.client.nowait( 'set_field', (Literal('browser'), self.element, value))
[ "def", "value", "(", "self", ",", "value", ")", ":", "self", ".", "client", ".", "nowait", "(", "'set_field'", ",", "(", "Literal", "(", "'browser'", ")", ",", "self", ".", "element", ",", "value", ")", ")" ]
Used to set the ``value`` of form elements.
[ "Used", "to", "set", "the", "value", "of", "form", "elements", "." ]
train
https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/browser.py#L527-L532
ryanpetrello/python-zombie
zombie/browser.py
DOMNode.fire
def fire(self, event): """ Fires a specified DOM event on the current node. :param event: the name of the event to fire (e.g., 'click'). Returns the :class:`zombie.dom.DOMNode` to allow function chaining. """ self.browser.fire(self.element, event) return self
python
def fire(self, event): """ Fires a specified DOM event on the current node. :param event: the name of the event to fire (e.g., 'click'). Returns the :class:`zombie.dom.DOMNode` to allow function chaining. """ self.browser.fire(self.element, event) return self
[ "def", "fire", "(", "self", ",", "event", ")", ":", "self", ".", "browser", ".", "fire", "(", "self", ".", "element", ",", "event", ")", "return", "self" ]
Fires a specified DOM event on the current node. :param event: the name of the event to fire (e.g., 'click'). Returns the :class:`zombie.dom.DOMNode` to allow function chaining.
[ "Fires", "a", "specified", "DOM", "event", "on", "the", "current", "node", "." ]
train
https://github.com/ryanpetrello/python-zombie/blob/638916572d8ee5ebbdb2dcfc5000a952e99f280f/zombie/browser.py#L562-L571
robhowley/nhlscrapi
nhlscrapi/games/game.py
Game.load_all
def load_all(self): """ Force all reports to be loaded and parsed instead of lazy loading on demand. :returns: ``self`` or ``None`` if load fails """ try: self.toi.load_all() self.rosters.load_all() #self.summary.load_all() ...
python
def load_all(self): """ Force all reports to be loaded and parsed instead of lazy loading on demand. :returns: ``self`` or ``None`` if load fails """ try: self.toi.load_all() self.rosters.load_all() #self.summary.load_all() ...
[ "def", "load_all", "(", "self", ")", ":", "try", ":", "self", ".", "toi", ".", "load_all", "(", ")", "self", ".", "rosters", ".", "load_all", "(", ")", "#self.summary.load_all()", "self", ".", "play_by_play", ".", "load_all", "(", ")", "self", ".", "fa...
Force all reports to be loaded and parsed instead of lazy loading on demand. :returns: ``self`` or ``None`` if load fails
[ "Force", "all", "reports", "to", "be", "loaded", "and", "parsed", "instead", "of", "lazy", "loading", "on", "demand", ".", ":", "returns", ":", "self", "or", "None", "if", "load", "fails" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/game.py#L135-L150
robhowley/nhlscrapi
nhlscrapi/games/game.py
Game.matchup
def matchup(self): """ Return the game meta information displayed in report banners including team names, final score, game date, location, and attendance. Data format is .. code:: python { 'home': home, 'away': away, ...
python
def matchup(self): """ Return the game meta information displayed in report banners including team names, final score, game date, location, and attendance. Data format is .. code:: python { 'home': home, 'away': away, ...
[ "def", "matchup", "(", "self", ")", ":", "if", "self", ".", "play_by_play", ".", "matchup", ":", "return", "self", ".", "play_by_play", ".", "matchup", "elif", "self", ".", "rosters", ".", "matchup", ":", "return", "self", ".", "rosters", ".", "matchup",...
Return the game meta information displayed in report banners including team names, final score, game date, location, and attendance. Data format is .. code:: python { 'home': home, 'away': away, 'final': final, ...
[ "Return", "the", "game", "meta", "information", "displayed", "in", "report", "banners", "including", "team", "names", "final", "score", "game", "date", "location", "and", "attendance", ".", "Data", "format", "is", "..", "code", "::", "python", "{", "home", "...
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/game.py#L159-L185
evansherlock/nytimesarticle
nytimesarticle.py
articleAPI._utf8_encode
def _utf8_encode(self, d): """ Ensures all values are encoded in UTF-8 and converts them to lowercase """ for k, v in d.items(): if isinstance(v, str): d[k] = v.encode('utf8').lower() if isinstance(v, list): for index,item ...
python
def _utf8_encode(self, d): """ Ensures all values are encoded in UTF-8 and converts them to lowercase """ for k, v in d.items(): if isinstance(v, str): d[k] = v.encode('utf8').lower() if isinstance(v, list): for index,item ...
[ "def", "_utf8_encode", "(", "self", ",", "d", ")", ":", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "str", ")", ":", "d", "[", "k", "]", "=", "v", ".", "encode", "(", "'utf8'", ")", ".", ...
Ensures all values are encoded in UTF-8 and converts them to lowercase
[ "Ensures", "all", "values", "are", "encoded", "in", "UTF", "-", "8", "and", "converts", "them", "to", "lowercase" ]
train
https://github.com/evansherlock/nytimesarticle/blob/89f551699ffb11f71b47271246d350a1043e9326/nytimesarticle.py#L29-L44
evansherlock/nytimesarticle
nytimesarticle.py
articleAPI._bool_encode
def _bool_encode(self, d): """ Converts bool values to lowercase strings """ for k, v in d.items(): if isinstance(v, bool): d[k] = str(v).lower() return d
python
def _bool_encode(self, d): """ Converts bool values to lowercase strings """ for k, v in d.items(): if isinstance(v, bool): d[k] = str(v).lower() return d
[ "def", "_bool_encode", "(", "self", ",", "d", ")", ":", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "bool", ")", ":", "d", "[", "k", "]", "=", "str", "(", "v", ")", ".", "lower", "(", "...
Converts bool values to lowercase strings
[ "Converts", "bool", "values", "to", "lowercase", "strings" ]
train
https://github.com/evansherlock/nytimesarticle/blob/89f551699ffb11f71b47271246d350a1043e9326/nytimesarticle.py#L46-L55
evansherlock/nytimesarticle
nytimesarticle.py
articleAPI._options
def _options(self, **kwargs): """ Formats search parameters/values for use with API :param \*\*kwargs: search parameters/values """ def _format_fq(d): for k,v in d.items(): if isinstance(v, list): d[k] = ' '.join(m...
python
def _options(self, **kwargs): """ Formats search parameters/values for use with API :param \*\*kwargs: search parameters/values """ def _format_fq(d): for k,v in d.items(): if isinstance(v, list): d[k] = ' '.join(m...
[ "def", "_options", "(", "self", ",", "*", "*", "kwargs", ")", ":", "def", "_format_fq", "(", "d", ")", ":", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "list", ")", ":", "d", "[", "k", "]...
Formats search parameters/values for use with API :param \*\*kwargs: search parameters/values
[ "Formats", "search", "parameters", "/", "values", "for", "use", "with", "API", ":", "param", "\\", "*", "\\", "*", "kwargs", ":", "search", "parameters", "/", "values" ]
train
https://github.com/evansherlock/nytimesarticle/blob/89f551699ffb11f71b47271246d350a1043e9326/nytimesarticle.py#L57-L89
evansherlock/nytimesarticle
nytimesarticle.py
articleAPI.search
def search(self, response_format = None, key = None, **kwargs): """ Calls the API and returns a dictionary of the search results :param response_format: the format that the API uses for its response, inc...
python
def search(self, response_format = None, key = None, **kwargs): """ Calls the API and returns a dictionary of the search results :param response_format: the format that the API uses for its response, inc...
[ "def", "search", "(", "self", ",", "response_format", "=", "None", ",", "key", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "response_format", "is", "None", ":", "response_format", "=", "self", ".", "response_format", "if", "key", "is", "None", ...
Calls the API and returns a dictionary of the search results :param response_format: the format that the API uses for its response, includes JSON (.json) and JSONP (.jsonp). Defaults to '.json'. :...
[ "Calls", "the", "API", "and", "returns", "a", "dictionary", "of", "the", "search", "results", ":", "param", "response_format", ":", "the", "format", "that", "the", "API", "uses", "for", "its", "response", "includes", "JSON", "(", ".", "json", ")", "and", ...
train
https://github.com/evansherlock/nytimesarticle/blob/89f551699ffb11f71b47271246d350a1043e9326/nytimesarticle.py#L91-L115
robhowley/nhlscrapi
nhlscrapi/scrapr/gamesummrep.py
parse
def parse(self): """Fully parses game summary report. :returns: boolean success indicator :rtype: bool """ r = super(GameSummRep, self).parse() try: self.parse_scoring_summary() return r and False except: return False
python
def parse(self): """Fully parses game summary report. :returns: boolean success indicator :rtype: bool """ r = super(GameSummRep, self).parse() try: self.parse_scoring_summary() return r and False except: return False
[ "def", "parse", "(", "self", ")", ":", "r", "=", "super", "(", "GameSummRep", ",", "self", ")", ".", "parse", "(", ")", "try", ":", "self", ".", "parse_scoring_summary", "(", ")", "return", "r", "and", "False", "except", ":", "return", "False" ]
Fully parses game summary report. :returns: boolean success indicator :rtype: bool
[ "Fully", "parses", "game", "summary", "report", ".", ":", "returns", ":", "boolean", "success", "indicator", ":", "rtype", ":", "bool" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/gamesummrep.py#L18-L28
robhowley/nhlscrapi
nhlscrapi/games/events.py
EventFactory.Create
def Create(event_type): """ Factory method creates objects derived from :py:class`.Event` with class name matching the :py:class`.EventType`. :param event_type: number for type of event :returns: constructed event corresponding to ``event_type`` :rtype: :py:class:`.Event...
python
def Create(event_type): """ Factory method creates objects derived from :py:class`.Event` with class name matching the :py:class`.EventType`. :param event_type: number for type of event :returns: constructed event corresponding to ``event_type`` :rtype: :py:class:`.Event...
[ "def", "Create", "(", "event_type", ")", ":", "if", "event_type", "in", "EventType", ".", "Name", ":", "# unknown event type gets base class", "if", "EventType", ".", "Name", "[", "event_type", "]", "==", "Event", ".", "__name__", ":", "return", "Event", "(", ...
Factory method creates objects derived from :py:class`.Event` with class name matching the :py:class`.EventType`. :param event_type: number for type of event :returns: constructed event corresponding to ``event_type`` :rtype: :py:class:`.Event`
[ "Factory", "method", "creates", "objects", "derived", "from", ":", "py", ":", "class", ".", "Event", "with", "class", "name", "matching", "the", ":", "py", ":", "class", ".", "EventType", ".", ":", "param", "event_type", ":", "number", "for", "type", "of...
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/events.py#L167-L183
robhowley/nhlscrapi
nhlscrapi/games/toi.py
TOI.home_shift_summ
def home_shift_summ(self): """ :returns: :py:class:`.ShiftSummary` by player for the home team :rtype: dict ``{ player_num: shift_summary_obj }`` """ if not self.__wrapped_home: self.__wrapped_home = self.__wrap(self._home.by_player) return self.__wra...
python
def home_shift_summ(self): """ :returns: :py:class:`.ShiftSummary` by player for the home team :rtype: dict ``{ player_num: shift_summary_obj }`` """ if not self.__wrapped_home: self.__wrapped_home = self.__wrap(self._home.by_player) return self.__wra...
[ "def", "home_shift_summ", "(", "self", ")", ":", "if", "not", "self", ".", "__wrapped_home", ":", "self", ".", "__wrapped_home", "=", "self", ".", "__wrap", "(", "self", ".", "_home", ".", "by_player", ")", "return", "self", ".", "__wrapped_home" ]
:returns: :py:class:`.ShiftSummary` by player for the home team :rtype: dict ``{ player_num: shift_summary_obj }``
[ ":", "returns", ":", ":", "py", ":", "class", ":", ".", "ShiftSummary", "by", "player", "for", "the", "home", "team", ":", "rtype", ":", "dict", "{", "player_num", ":", "shift_summary_obj", "}" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/toi.py#L88-L96
robhowley/nhlscrapi
nhlscrapi/games/toi.py
TOI.away_shift_summ
def away_shift_summ(self): """ :returns: :py:class:`.ShiftSummary` by player for the away team :rtype: dict ``{ player_num: shift_summary_obj }`` """ if not self.__wrapped_away: self.__wrapped_away = self.__wrap(self._away.by_player) return self.__wra...
python
def away_shift_summ(self): """ :returns: :py:class:`.ShiftSummary` by player for the away team :rtype: dict ``{ player_num: shift_summary_obj }`` """ if not self.__wrapped_away: self.__wrapped_away = self.__wrap(self._away.by_player) return self.__wra...
[ "def", "away_shift_summ", "(", "self", ")", ":", "if", "not", "self", ".", "__wrapped_away", ":", "self", ".", "__wrapped_away", "=", "self", ".", "__wrap", "(", "self", ".", "_away", ".", "by_player", ")", "return", "self", ".", "__wrapped_away" ]
:returns: :py:class:`.ShiftSummary` by player for the away team :rtype: dict ``{ player_num: shift_summary_obj }``
[ ":", "returns", ":", ":", "py", ":", "class", ":", ".", "ShiftSummary", "by", "player", "for", "the", "away", "team", ":", "rtype", ":", "dict", "{", "player_num", ":", "shift_summary_obj", "}" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/toi.py#L100-L108
robhowley/nhlscrapi
nhlscrapi/scrapr/rosterrep.py
RosterRep.parse
def parse(self): """ Retreive and parse Play by Play data for the given :py:class:`nhlscrapi.games.game.GameKey`` :returns: ``self`` on success, ``None`` otherwise """ try: return super(RosterRep, self).parse() \ .parse_rosters() \ .p...
python
def parse(self): """ Retreive and parse Play by Play data for the given :py:class:`nhlscrapi.games.game.GameKey`` :returns: ``self`` on success, ``None`` otherwise """ try: return super(RosterRep, self).parse() \ .parse_rosters() \ .p...
[ "def", "parse", "(", "self", ")", ":", "try", ":", "return", "super", "(", "RosterRep", ",", "self", ")", ".", "parse", "(", ")", ".", "parse_rosters", "(", ")", ".", "parse_scratches", "(", ")", ".", "parse_coaches", "(", ")", ".", "parse_officials", ...
Retreive and parse Play by Play data for the given :py:class:`nhlscrapi.games.game.GameKey`` :returns: ``self`` on success, ``None`` otherwise
[ "Retreive", "and", "parse", "Play", "by", "Play", "data", "for", "the", "given", ":", "py", ":", "class", ":", "nhlscrapi", ".", "games", ".", "game", ".", "GameKey" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/rosterrep.py#L65-L79
robhowley/nhlscrapi
nhlscrapi/scrapr/rosterrep.py
RosterRep.parse_rosters
def parse_rosters(self): """ Parse the home and away game rosters :returns: ``self`` on success, ``None`` otherwise """ lx_doc = self.html_doc() if not self.__blocks: self.__pl_blocks(lx_doc) for t in ['home', 'away']: self.rosters[t] = ...
python
def parse_rosters(self): """ Parse the home and away game rosters :returns: ``self`` on success, ``None`` otherwise """ lx_doc = self.html_doc() if not self.__blocks: self.__pl_blocks(lx_doc) for t in ['home', 'away']: self.rosters[t] = ...
[ "def", "parse_rosters", "(", "self", ")", ":", "lx_doc", "=", "self", ".", "html_doc", "(", ")", "if", "not", "self", ".", "__blocks", ":", "self", ".", "__pl_blocks", "(", "lx_doc", ")", "for", "t", "in", "[", "'home'", ",", "'away'", "]", ":", "s...
Parse the home and away game rosters :returns: ``self`` on success, ``None`` otherwise
[ "Parse", "the", "home", "and", "away", "game", "rosters" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/rosterrep.py#L82-L96
robhowley/nhlscrapi
nhlscrapi/scrapr/rosterrep.py
RosterRep.parse_scratches
def parse_scratches(self): """ Parse the home and away healthy scratches :returns: ``self`` on success, ``None`` otherwise """ lx_doc = self.html_doc() if not self.__blocks: self.__pl_blocks(lx_doc) for t in ['aw_scr', 'h_scr']: ix = 'awa...
python
def parse_scratches(self): """ Parse the home and away healthy scratches :returns: ``self`` on success, ``None`` otherwise """ lx_doc = self.html_doc() if not self.__blocks: self.__pl_blocks(lx_doc) for t in ['aw_scr', 'h_scr']: ix = 'awa...
[ "def", "parse_scratches", "(", "self", ")", ":", "lx_doc", "=", "self", ".", "html_doc", "(", ")", "if", "not", "self", ".", "__blocks", ":", "self", ".", "__pl_blocks", "(", "lx_doc", ")", "for", "t", "in", "[", "'aw_scr'", ",", "'h_scr'", "]", ":",...
Parse the home and away healthy scratches :returns: ``self`` on success, ``None`` otherwise
[ "Parse", "the", "home", "and", "away", "healthy", "scratches" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/rosterrep.py#L99-L113
robhowley/nhlscrapi
nhlscrapi/scrapr/rosterrep.py
RosterRep.parse_coaches
def parse_coaches(self): """ Parse the home and away coaches :returns: ``self`` on success, ``None`` otherwise """ lx_doc = self.html_doc() tr = lx_doc.xpath('//tr[@id="HeadCoaches"]')[0] for i, td in enumerate(tr): txt = td.xpath('.//text()') ...
python
def parse_coaches(self): """ Parse the home and away coaches :returns: ``self`` on success, ``None`` otherwise """ lx_doc = self.html_doc() tr = lx_doc.xpath('//tr[@id="HeadCoaches"]')[0] for i, td in enumerate(tr): txt = td.xpath('.//text()') ...
[ "def", "parse_coaches", "(", "self", ")", ":", "lx_doc", "=", "self", ".", "html_doc", "(", ")", "tr", "=", "lx_doc", ".", "xpath", "(", "'//tr[@id=\"HeadCoaches\"]'", ")", "[", "0", "]", "for", "i", ",", "td", "in", "enumerate", "(", "tr", ")", ":",...
Parse the home and away coaches :returns: ``self`` on success, ``None`` otherwise
[ "Parse", "the", "home", "and", "away", "coaches" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/rosterrep.py#L116-L131
robhowley/nhlscrapi
nhlscrapi/scrapr/rosterrep.py
RosterRep.parse_officials
def parse_officials(self): """ Parse the officials :returns: ``self`` on success, ``None`` otherwise """ # begin proper body of method lx_doc = self.html_doc() off_parser = opm(self.game_key.season) self.officials = off_parser(lx_doc) return self...
python
def parse_officials(self): """ Parse the officials :returns: ``self`` on success, ``None`` otherwise """ # begin proper body of method lx_doc = self.html_doc() off_parser = opm(self.game_key.season) self.officials = off_parser(lx_doc) return self...
[ "def", "parse_officials", "(", "self", ")", ":", "# begin proper body of method", "lx_doc", "=", "self", ".", "html_doc", "(", ")", "off_parser", "=", "opm", "(", "self", ".", "game_key", ".", "season", ")", "self", ".", "officials", "=", "off_parser", "(", ...
Parse the officials :returns: ``self`` on success, ``None`` otherwise
[ "Parse", "the", "officials" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/rosterrep.py#L134-L145
michaelherold/pyIsEmail
pyisemail/__init__.py
is_email
def is_email(address, check_dns=False, diagnose=False): """Validate an email address. Keyword arguments: address --- the email address as a string check_dns --- flag for whether to check the DNS status of the domain diagnose --- flag for whether to return True/False or a Diagnosis """ ...
python
def is_email(address, check_dns=False, diagnose=False): """Validate an email address. Keyword arguments: address --- the email address as a string check_dns --- flag for whether to check the DNS status of the domain diagnose --- flag for whether to return True/False or a Diagnosis """ ...
[ "def", "is_email", "(", "address", ",", "check_dns", "=", "False", ",", "diagnose", "=", "False", ")", ":", "threshold", "=", "BaseDiagnosis", ".", "CATEGORIES", "[", "\"THRESHOLD\"", "]", "d", "=", "ParserValidator", "(", ")", ".", "is_email", "(", "addre...
Validate an email address. Keyword arguments: address --- the email address as a string check_dns --- flag for whether to check the DNS status of the domain diagnose --- flag for whether to return True/False or a Diagnosis
[ "Validate", "an", "email", "address", "." ]
train
https://github.com/michaelherold/pyIsEmail/blob/dd42d6425c59e5061fc214d42672210dccc64cf5/pyisemail/__init__.py#L12-L28
robhowley/nhlscrapi
nhlscrapi/games/repscrwrap.py
dispatch_loader
def dispatch_loader(scraper, loader_name): """ Decorator that enforces one time loading for scrapers. The one time loading is applied to partial loaders, e.g. only parse and load the home team roster once. This is not meant to be used directly. :param scraper: property name (string) containing ...
python
def dispatch_loader(scraper, loader_name): """ Decorator that enforces one time loading for scrapers. The one time loading is applied to partial loaders, e.g. only parse and load the home team roster once. This is not meant to be used directly. :param scraper: property name (string) containing ...
[ "def", "dispatch_loader", "(", "scraper", ",", "loader_name", ")", ":", "l", "=", "'.'", ".", "join", "(", "[", "scraper", ",", "loader_name", "]", ")", "def", "wrapper", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapped", "(", "self...
Decorator that enforces one time loading for scrapers. The one time loading is applied to partial loaders, e.g. only parse and load the home team roster once. This is not meant to be used directly. :param scraper: property name (string) containing an object of type :py:class:`scrapr.ReportLoader` :...
[ "Decorator", "that", "enforces", "one", "time", "loading", "for", "scrapers", ".", "The", "one", "time", "loading", "is", "applied", "to", "partial", "loaders", "e", ".", "g", ".", "only", "parse", "and", "load", "the", "home", "team", "roster", "once", ...
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/repscrwrap.py#L5-L28
robhowley/nhlscrapi
nhlscrapi/scrapr/toirep.py
TOIRepBase.parse_shifts
def parse_shifts(self): """ Parse shifts from TOI report :returns: self if successfule else None """ lx_doc = self.html_doc() pl_heads = lx_doc.xpath('//td[contains(@class, "playerHeading")]') for pl in pl_heads: sh_sum = { } ...
python
def parse_shifts(self): """ Parse shifts from TOI report :returns: self if successfule else None """ lx_doc = self.html_doc() pl_heads = lx_doc.xpath('//td[contains(@class, "playerHeading")]') for pl in pl_heads: sh_sum = { } ...
[ "def", "parse_shifts", "(", "self", ")", ":", "lx_doc", "=", "self", ".", "html_doc", "(", ")", "pl_heads", "=", "lx_doc", ".", "xpath", "(", "'//td[contains(@class, \"playerHeading\")]'", ")", "for", "pl", "in", "pl_heads", ":", "sh_sum", "=", "{", "}", "...
Parse shifts from TOI report :returns: self if successfule else None
[ "Parse", "shifts", "from", "TOI", "report", ":", "returns", ":", "self", "if", "successfule", "else", "None" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/toirep.py#L130-L159
michaelherold/pyIsEmail
pyisemail/validators/dns_validator.py
DNSValidator.is_valid
def is_valid(self, domain, diagnose=False): """Check whether a domain has a valid MX or A record. Keyword arguments: domain --- the domain to check diagnose --- flag to report a diagnosis or a boolean (default False) """ return_status = [ValidDiagnosis()] dn...
python
def is_valid(self, domain, diagnose=False): """Check whether a domain has a valid MX or A record. Keyword arguments: domain --- the domain to check diagnose --- flag to report a diagnosis or a boolean (default False) """ return_status = [ValidDiagnosis()] dn...
[ "def", "is_valid", "(", "self", ",", "domain", ",", "diagnose", "=", "False", ")", ":", "return_status", "=", "[", "ValidDiagnosis", "(", ")", "]", "dns_checked", "=", "False", "# http://tools.ietf.org/html/rfc5321#section-2.3.5", "# Names that can be resolved to MX R...
Check whether a domain has a valid MX or A record. Keyword arguments: domain --- the domain to check diagnose --- flag to report a diagnosis or a boolean (default False)
[ "Check", "whether", "a", "domain", "has", "a", "valid", "MX", "or", "A", "record", "." ]
train
https://github.com/michaelherold/pyIsEmail/blob/dd42d6425c59e5061fc214d42672210dccc64cf5/pyisemail/validators/dns_validator.py#L8-L111
robhowley/nhlscrapi
nhlscrapi/scrapr/reportloader.py
ReportLoader.html_doc
def html_doc(self): """ :returns: the lxml processed html document :rtype: ``lxml.html.document_fromstring`` output """ if self.__lx_doc is None: cn = NHLCn() if hasattr(cn, self.report_type): html = getattr(cn, self.rep...
python
def html_doc(self): """ :returns: the lxml processed html document :rtype: ``lxml.html.document_fromstring`` output """ if self.__lx_doc is None: cn = NHLCn() if hasattr(cn, self.report_type): html = getattr(cn, self.rep...
[ "def", "html_doc", "(", "self", ")", ":", "if", "self", ".", "__lx_doc", "is", "None", ":", "cn", "=", "NHLCn", "(", ")", "if", "hasattr", "(", "cn", ",", "self", ".", "report_type", ")", ":", "html", "=", "getattr", "(", "cn", ",", "self", ".", ...
:returns: the lxml processed html document :rtype: ``lxml.html.document_fromstring`` output
[ ":", "returns", ":", "the", "lxml", "processed", "html", "document", ":", "rtype", ":", "lxml", ".", "html", ".", "document_fromstring", "output" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/reportloader.py#L52-L71
robhowley/nhlscrapi
nhlscrapi/scrapr/reportloader.py
ReportLoader.parse_matchup
def parse_matchup(self): """ Parse the banner matchup meta info for the game. :returns: ``self`` on success or ``None`` """ lx_doc = self.html_doc() try: if not self.matchup: self.matchup = self._fill_meta(lx_doc) return se...
python
def parse_matchup(self): """ Parse the banner matchup meta info for the game. :returns: ``self`` on success or ``None`` """ lx_doc = self.html_doc() try: if not self.matchup: self.matchup = self._fill_meta(lx_doc) return se...
[ "def", "parse_matchup", "(", "self", ")", ":", "lx_doc", "=", "self", ".", "html_doc", "(", ")", "try", ":", "if", "not", "self", ".", "matchup", ":", "self", ".", "matchup", "=", "self", ".", "_fill_meta", "(", "lx_doc", ")", "return", "self", "exce...
Parse the banner matchup meta info for the game. :returns: ``self`` on success or ``None``
[ "Parse", "the", "banner", "matchup", "meta", "info", "for", "the", "game", ".", ":", "returns", ":", "self", "on", "success", "or", "None" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/reportloader.py#L74-L86
robhowley/nhlscrapi
nhlscrapi/scrapr/rtss.py
RTSS.parse_plays_stream
def parse_plays_stream(self): """Generate and yield a stream of parsed plays. Useful for per play processing.""" lx_doc = self.html_doc() if lx_doc is not None: parser = PlayParser(self.game_key.season, self.game_key.game_type) plays = lx_doc.xpath('//tr[@class =...
python
def parse_plays_stream(self): """Generate and yield a stream of parsed plays. Useful for per play processing.""" lx_doc = self.html_doc() if lx_doc is not None: parser = PlayParser(self.game_key.season, self.game_key.game_type) plays = lx_doc.xpath('//tr[@class =...
[ "def", "parse_plays_stream", "(", "self", ")", ":", "lx_doc", "=", "self", ".", "html_doc", "(", ")", "if", "lx_doc", "is", "not", "None", ":", "parser", "=", "PlayParser", "(", "self", ".", "game_key", ".", "season", ",", "self", ".", "game_key", ".",...
Generate and yield a stream of parsed plays. Useful for per play processing.
[ "Generate", "and", "yield", "a", "stream", "of", "parsed", "plays", ".", "Useful", "for", "per", "play", "processing", "." ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/rtss.py#L48-L59
robhowley/nhlscrapi
nhlscrapi/scrapr/rtss.py
PlayParser.ColMap
def ColMap(season): """ Returns a dictionary mapping the type of information in the RTSS play row to the appropriate column number. The column locations pre/post 2008 are different. :param season: int for the season number :returns: mapping of RTSS column to info type ...
python
def ColMap(season): """ Returns a dictionary mapping the type of information in the RTSS play row to the appropriate column number. The column locations pre/post 2008 are different. :param season: int for the season number :returns: mapping of RTSS column to info type ...
[ "def", "ColMap", "(", "season", ")", ":", "if", "c", ".", "MIN_SEASON", "<=", "season", "<=", "c", ".", "MAX_SEASON", ":", "return", "{", "\"play_num\"", ":", "0", ",", "\"per\"", ":", "1", ",", "\"str\"", ":", "2", ",", "\"time\"", ":", "3", ",", ...
Returns a dictionary mapping the type of information in the RTSS play row to the appropriate column number. The column locations pre/post 2008 are different. :param season: int for the season number :returns: mapping of RTSS column to info type :rtype: dict, keys are ``'play_num...
[ "Returns", "a", "dictionary", "mapping", "the", "type", "of", "information", "in", "the", "RTSS", "play", "row", "to", "the", "appropriate", "column", "number", ".", "The", "column", "locations", "pre", "/", "post", "2008", "are", "different", ".", ":", "p...
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/rtss.py#L71-L92
robhowley/nhlscrapi
nhlscrapi/scrapr/rtss.py
PlayParser.build_play
def build_play(self, pbp_row): """ Parses table row from RTSS. These are the rows tagged with ``<tr class='evenColor' ... >``. Result set contains :py:class:`nhlscrapi.games.playbyplay.Strength` and :py:class:`nhlscrapi.games.events.EventType` objects. Returned play data is in the form ...
python
def build_play(self, pbp_row): """ Parses table row from RTSS. These are the rows tagged with ``<tr class='evenColor' ... >``. Result set contains :py:class:`nhlscrapi.games.playbyplay.Strength` and :py:class:`nhlscrapi.games.events.EventType` objects. Returned play data is in the form ...
[ "def", "build_play", "(", "self", ",", "pbp_row", ")", ":", "d", "=", "pbp_row", ".", "findall", "(", "'./td'", ")", "c", "=", "PlayParser", ".", "ColMap", "(", "self", ".", "season", ")", "p", "=", "{", "}", "to_dig", "=", "lambda", "t", ":", "i...
Parses table row from RTSS. These are the rows tagged with ``<tr class='evenColor' ... >``. Result set contains :py:class:`nhlscrapi.games.playbyplay.Strength` and :py:class:`nhlscrapi.games.events.EventType` objects. Returned play data is in the form .. code:: python ...
[ "Parses", "table", "row", "from", "RTSS", ".", "These", "are", "the", "rows", "tagged", "with", "<tr", "class", "=", "evenColor", "...", ">", ".", "Result", "set", "contains", ":", "py", ":", "class", ":", "nhlscrapi", ".", "games", ".", "playbyplay", ...
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/rtss.py#L94-L145
robhowley/nhlscrapi
nhlscrapi/scrapr/rtss.py
PlayParser.__skaters
def __skaters(self, tab): """ Constructs dictionary of players on the ice in the provided table at time of play. :param tab: RTSS table of the skaters and goalie on at the time of the play :rtype: dictionary, key = player number, value = [position, name] """ res ...
python
def __skaters(self, tab): """ Constructs dictionary of players on the ice in the provided table at time of play. :param tab: RTSS table of the skaters and goalie on at the time of the play :rtype: dictionary, key = player number, value = [position, name] """ res ...
[ "def", "__skaters", "(", "self", ",", "tab", ")", ":", "res", "=", "{", "}", "for", "td", "in", "tab", ".", "iterchildren", "(", ")", ":", "if", "len", "(", "td", ")", ":", "pl_data", "=", "td", ".", "xpath", "(", "\"./table/tr\"", ")", "pl", "...
Constructs dictionary of players on the ice in the provided table at time of play. :param tab: RTSS table of the skaters and goalie on at the time of the play :rtype: dictionary, key = player number, value = [position, name]
[ "Constructs", "dictionary", "of", "players", "on", "the", "ice", "in", "the", "provided", "table", "at", "time", "of", "play", ".", ":", "param", "tab", ":", "RTSS", "table", "of", "the", "skaters", "and", "goalie", "on", "at", "the", "time", "of", "th...
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/rtss.py#L147-L166
robhowley/nhlscrapi
nhlscrapi/_tools.py
exclude_from
def exclude_from(l, containing = [], equal_to = []): """Exclude elements in list l containing any elements from list ex. Example: >>> l = ['bob', 'r', 'rob\r', '\r\nrobert'] >>> containing = ['\n', '\r'] >>> equal_to = ['r'] >>> exclude_from(l, containing, equal_to) ['bob...
python
def exclude_from(l, containing = [], equal_to = []): """Exclude elements in list l containing any elements from list ex. Example: >>> l = ['bob', 'r', 'rob\r', '\r\nrobert'] >>> containing = ['\n', '\r'] >>> equal_to = ['r'] >>> exclude_from(l, containing, equal_to) ['bob...
[ "def", "exclude_from", "(", "l", ",", "containing", "=", "[", "]", ",", "equal_to", "=", "[", "]", ")", ":", "cont", "=", "lambda", "li", ":", "any", "(", "c", "in", "li", "for", "c", "in", "containing", ")", "eq", "=", "lambda", "li", ":", "an...
Exclude elements in list l containing any elements from list ex. Example: >>> l = ['bob', 'r', 'rob\r', '\r\nrobert'] >>> containing = ['\n', '\r'] >>> equal_to = ['r'] >>> exclude_from(l, containing, equal_to) ['bob']
[ "Exclude", "elements", "in", "list", "l", "containing", "any", "elements", "from", "list", "ex", ".", "Example", ":", ">>>", "l", "=", "[", "bob", "r", "rob", "\\", "r", "\\", "r", "\\", "nrobert", "]", ">>>", "containing", "=", "[", "\\", "n", "\\...
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/_tools.py#L23-L35
NeuroanatomyAndConnectivity/surfdist
nipype/surfdist_nipype.py
calc_surfdist
def calc_surfdist(surface, labels, annot, reg, origin, target): import nibabel as nib import numpy as np import os from surfdist import load, utils, surfdist import csv """ inputs: surface - surface file (e.g. lh.pial, with full path) labels - label file (e.g. lh.cortex.label, with full path) annot -...
python
def calc_surfdist(surface, labels, annot, reg, origin, target): import nibabel as nib import numpy as np import os from surfdist import load, utils, surfdist import csv """ inputs: surface - surface file (e.g. lh.pial, with full path) labels - label file (e.g. lh.cortex.label, with full path) annot -...
[ "def", "calc_surfdist", "(", "surface", ",", "labels", ",", "annot", ",", "reg", ",", "origin", ",", "target", ")", ":", "import", "nibabel", "as", "nib", "import", "numpy", "as", "np", "import", "os", "from", "surfdist", "import", "load", ",", "utils", ...
inputs: surface - surface file (e.g. lh.pial, with full path) labels - label file (e.g. lh.cortex.label, with full path) annot - annot file (e.g. lh.aparc.a2009s.annot, with full path) reg - registration file (lh.sphere.reg) origin - the label from which we calculate distances target - target surface (e.g. ...
[ "inputs", ":", "surface", "-", "surface", "file", "(", "e", ".", "g", ".", "lh", ".", "pial", "with", "full", "path", ")", "labels", "-", "label", "file", "(", "e", ".", "g", ".", "lh", ".", "cortex", ".", "label", "with", "full", "path", ")", ...
train
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/nipype/surfdist_nipype.py#L20-L56
NeuroanatomyAndConnectivity/surfdist
nipype/surfdist_nipype.py
stack_files
def stack_files(files, hemi, source, target): """ This function takes a list of files as input and vstacks them """ import csv import os import numpy as np fname = "sdist_%s_%s_%s.csv" % (hemi, source, target) filename = os.path.join(os.getcwd(),fname) alldist = [] for dfile in files: alldist...
python
def stack_files(files, hemi, source, target): """ This function takes a list of files as input and vstacks them """ import csv import os import numpy as np fname = "sdist_%s_%s_%s.csv" % (hemi, source, target) filename = os.path.join(os.getcwd(),fname) alldist = [] for dfile in files: alldist...
[ "def", "stack_files", "(", "files", ",", "hemi", ",", "source", ",", "target", ")", ":", "import", "csv", "import", "os", "import", "numpy", "as", "np", "fname", "=", "\"sdist_%s_%s_%s.csv\"", "%", "(", "hemi", ",", "source", ",", "target", ")", "filenam...
This function takes a list of files as input and vstacks them
[ "This", "function", "takes", "a", "list", "of", "files", "as", "input", "and", "vstacks", "them" ]
train
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/nipype/surfdist_nipype.py#L58-L77
gcushen/mezzanine-api
mezzanine_api/serializers.py
PostOutputSerializer.get_short_url
def get_short_url(self, obj): """ Get short URL of blog post like '/blog/<slug>/' using ``get_absolute_url`` if available. Removes dependency on reverse URLs of Mezzanine views when deploying Mezzanine only as an API backend. """ try: url = obj.get_absolute_url() ...
python
def get_short_url(self, obj): """ Get short URL of blog post like '/blog/<slug>/' using ``get_absolute_url`` if available. Removes dependency on reverse URLs of Mezzanine views when deploying Mezzanine only as an API backend. """ try: url = obj.get_absolute_url() ...
[ "def", "get_short_url", "(", "self", ",", "obj", ")", ":", "try", ":", "url", "=", "obj", ".", "get_absolute_url", "(", ")", "except", "NoReverseMatch", ":", "url", "=", "'/blog/'", "+", "obj", ".", "slug", "return", "url" ]
Get short URL of blog post like '/blog/<slug>/' using ``get_absolute_url`` if available. Removes dependency on reverse URLs of Mezzanine views when deploying Mezzanine only as an API backend.
[ "Get", "short", "URL", "of", "blog", "post", "like", "/", "blog", "/", "<slug", ">", "/", "using", "get_absolute_url", "if", "available", ".", "Removes", "dependency", "on", "reverse", "URLs", "of", "Mezzanine", "views", "when", "deploying", "Mezzanine", "on...
train
https://github.com/gcushen/mezzanine-api/blob/8e9d519c0008f46019302fa3d4bf83c372d4ae21/mezzanine_api/serializers.py#L253-L262
robhowley/nhlscrapi
nhlscrapi/games/faceoffcomp.py
FaceOffComparison.head_to_head
def head_to_head(self, home_num, away_num): """ Return the head-to-head face-off outcomes between two players. If the matchup didn't happen, ``{ }`` is returned. :param home_num: the number of the home team player :param away_num: the number of the away team player ...
python
def head_to_head(self, home_num, away_num): """ Return the head-to-head face-off outcomes between two players. If the matchup didn't happen, ``{ }`` is returned. :param home_num: the number of the home team player :param away_num: the number of the away team player ...
[ "def", "head_to_head", "(", "self", ",", "home_num", ",", "away_num", ")", ":", "if", "home_num", "in", "self", ".", "home_fo", "and", "away_num", "in", "self", ".", "home_fo", "[", "home_num", "]", "[", "'opps'", "]", ":", "h_fo", "=", "self", ".", ...
Return the head-to-head face-off outcomes between two players. If the matchup didn't happen, ``{ }`` is returned. :param home_num: the number of the home team player :param away_num: the number of the away team player :returns: dict, either ``{ }`` or the following ...
[ "Return", "the", "head", "-", "to", "-", "head", "face", "-", "off", "outcomes", "between", "two", "players", ".", "If", "the", "matchup", "didn", "t", "happen", "{", "}", "is", "returned", ".", ":", "param", "home_num", ":", "the", "number", "of", "...
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/faceoffcomp.py#L47-L72
robhowley/nhlscrapi
nhlscrapi/games/faceoffcomp.py
FaceOffComparison.team_totals
def team_totals(self): """ Returns the overall faceoff win/total breakdown for home and away as :returns: dict, ``{ 'home/away': { 'won': won, 'total': total } }`` """ if self.__team_tots is None: self.__team_tots = self.__comp_tot() return {...
python
def team_totals(self): """ Returns the overall faceoff win/total breakdown for home and away as :returns: dict, ``{ 'home/away': { 'won': won, 'total': total } }`` """ if self.__team_tots is None: self.__team_tots = self.__comp_tot() return {...
[ "def", "team_totals", "(", "self", ")", ":", "if", "self", ".", "__team_tots", "is", "None", ":", "self", ".", "__team_tots", "=", "self", ".", "__comp_tot", "(", ")", "return", "{", "t", ":", "self", ".", "__team_tots", "[", "t", "]", "[", "'all'", ...
Returns the overall faceoff win/total breakdown for home and away as :returns: dict, ``{ 'home/away': { 'won': won, 'total': total } }``
[ "Returns", "the", "overall", "faceoff", "win", "/", "total", "breakdown", "for", "home", "and", "away", "as", ":", "returns", ":", "dict", "{", "home", "/", "away", ":", "{", "won", ":", "won", "total", ":", "total", "}", "}" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/faceoffcomp.py#L75-L87
robhowley/nhlscrapi
nhlscrapi/games/faceoffcomp.py
FaceOffComparison.by_zone
def by_zone(self): """ Returns the faceoff win/total breakdown by zone for home and away as .. code:: python { 'home/away': { 'off/def/neut/all': { 'won': won, 'total': total } } } :returns: dict ...
python
def by_zone(self): """ Returns the faceoff win/total breakdown by zone for home and away as .. code:: python { 'home/away': { 'off/def/neut/all': { 'won': won, 'total': total } } } :returns: dict ...
[ "def", "by_zone", "(", "self", ")", ":", "if", "self", ".", "__team_tots", "is", "None", ":", "self", ".", "__team_tots", "=", "self", ".", "__comp_tot", "(", ")", "return", "{", "t", ":", "{", "z", ":", "self", ".", "__team_tots", "[", "t", "]", ...
Returns the faceoff win/total breakdown by zone for home and away as .. code:: python { 'home/away': { 'off/def/neut/all': { 'won': won, 'total': total } } } :returns: dict
[ "Returns", "the", "faceoff", "win", "/", "total", "breakdown", "by", "zone", "for", "home", "and", "away", "as", "..", "code", "::", "python", "{", "home", "/", "away", ":", "{", "off", "/", "def", "/", "neut", "/", "all", ":", "{", "won", ":", "...
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/faceoffcomp.py#L90-L113
robhowley/nhlscrapi
nhlscrapi/games/faceoffcomp.py
FaceOffComparison.fo_pct
def fo_pct(self): """ Get the by team overall face-off win %. :returns: dict, ``{ 'home': %, 'away': % }`` """ tots = self.team_totals return { t: tots[t]['won']/(1.0*tots[t]['total']) if tots[t]['total'] else 0.0 for t in [ 'home', 'away'...
python
def fo_pct(self): """ Get the by team overall face-off win %. :returns: dict, ``{ 'home': %, 'away': % }`` """ tots = self.team_totals return { t: tots[t]['won']/(1.0*tots[t]['total']) if tots[t]['total'] else 0.0 for t in [ 'home', 'away'...
[ "def", "fo_pct", "(", "self", ")", ":", "tots", "=", "self", ".", "team_totals", "return", "{", "t", ":", "tots", "[", "t", "]", "[", "'won'", "]", "/", "(", "1.0", "*", "tots", "[", "t", "]", "[", "'total'", "]", ")", "if", "tots", "[", "t",...
Get the by team overall face-off win %. :returns: dict, ``{ 'home': %, 'away': % }``
[ "Get", "the", "by", "team", "overall", "face", "-", "off", "win", "%", ".", ":", "returns", ":", "dict", "{", "home", ":", "%", "away", ":", "%", "}" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/faceoffcomp.py#L116-L126
robhowley/nhlscrapi
nhlscrapi/games/faceoffcomp.py
FaceOffComparison.fo_pct_by_zone
def fo_pct_by_zone(self): """ Get the by team face-off win % by zone. Format is :returns: dict ``{ 'home/away': { 'off/def/neut': % } }`` """ bz = self.by_zone return { t: { z: bz[t][z]['won']/(1.0*bz[t][z]['total']) if bz[t][z]['t...
python
def fo_pct_by_zone(self): """ Get the by team face-off win % by zone. Format is :returns: dict ``{ 'home/away': { 'off/def/neut': % } }`` """ bz = self.by_zone return { t: { z: bz[t][z]['won']/(1.0*bz[t][z]['total']) if bz[t][z]['t...
[ "def", "fo_pct_by_zone", "(", "self", ")", ":", "bz", "=", "self", ".", "by_zone", "return", "{", "t", ":", "{", "z", ":", "bz", "[", "t", "]", "[", "z", "]", "[", "'won'", "]", "/", "(", "1.0", "*", "bz", "[", "t", "]", "[", "z", "]", "[...
Get the by team face-off win % by zone. Format is :returns: dict ``{ 'home/away': { 'off/def/neut': % } }``
[ "Get", "the", "by", "team", "face", "-", "off", "win", "%", "by", "zone", ".", "Format", "is", ":", "returns", ":", "dict", "{", "home", "/", "away", ":", "{", "off", "/", "def", "/", "neut", ":", "%", "}", "}" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/faceoffcomp.py#L129-L144
robhowley/nhlscrapi
nhlscrapi/games/cumstats.py
TeamIncrementor.update
def update(self, play): """ Update the accumulator with the current play :returns: new tally :rtype: dict, ``{ 'period': per, 'time': clock, 'team': cumul, 'play': play }`` """ new_tally = { } #if any(isinstance(play.event, te) for te in self.trigger_even...
python
def update(self, play): """ Update the accumulator with the current play :returns: new tally :rtype: dict, ``{ 'period': per, 'time': clock, 'team': cumul, 'play': play }`` """ new_tally = { } #if any(isinstance(play.event, te) for te in self.trigger_even...
[ "def", "update", "(", "self", ",", "play", ")", ":", "new_tally", "=", "{", "}", "#if any(isinstance(play.event, te) for te in self.trigger_event_types):", "if", "self", ".", "_count_play", "(", "play", ")", ":", "# the team who made the play / triggered the event", "team...
Update the accumulator with the current play :returns: new tally :rtype: dict, ``{ 'period': per, 'time': clock, 'team': cumul, 'play': play }``
[ "Update", "the", "accumulator", "with", "the", "current", "play", ":", "returns", ":", "new", "tally", ":", "rtype", ":", "dict", "{", "period", ":", "per", "time", ":", "clock", "team", ":", "cumul", "play", ":", "play", "}" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/cumstats.py#L55-L93
robhowley/nhlscrapi
nhlscrapi/games/cumstats.py
Corsi.share
def share(self): """ The Cori-share (% of shot attempts) for each team :returns: dict, ``{ 'home_name': %, 'away_name': % }`` """ tot = sum(self.total.values()) return { k: v/float(tot) for k,v in self.total.items() }
python
def share(self): """ The Cori-share (% of shot attempts) for each team :returns: dict, ``{ 'home_name': %, 'away_name': % }`` """ tot = sum(self.total.values()) return { k: v/float(tot) for k,v in self.total.items() }
[ "def", "share", "(", "self", ")", ":", "tot", "=", "sum", "(", "self", ".", "total", ".", "values", "(", ")", ")", "return", "{", "k", ":", "v", "/", "float", "(", "tot", ")", "for", "k", ",", "v", "in", "self", ".", "total", ".", "items", ...
The Cori-share (% of shot attempts) for each team :returns: dict, ``{ 'home_name': %, 'away_name': % }``
[ "The", "Cori", "-", "share", "(", "%", "of", "shot", "attempts", ")", "for", "each", "team", ":", "returns", ":", "dict", "{", "home_name", ":", "%", "away_name", ":", "%", "}" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/cumstats.py#L171-L178
robhowley/nhlscrapi
nhlscrapi/games/playbyplay.py
PlayByPlay.compute_stats
def compute_stats(self): """ Compute the stats defined in ``self.cum_stats``. :returns: collection of all computed :py:class:`.AccumulateStats` :rtype: dict """ if not self.__have_stats: if self.init_cs_teams and self.cum_stats: self._...
python
def compute_stats(self): """ Compute the stats defined in ``self.cum_stats``. :returns: collection of all computed :py:class:`.AccumulateStats` :rtype: dict """ if not self.__have_stats: if self.init_cs_teams and self.cum_stats: self._...
[ "def", "compute_stats", "(", "self", ")", ":", "if", "not", "self", ".", "__have_stats", ":", "if", "self", ".", "init_cs_teams", "and", "self", ".", "cum_stats", ":", "self", ".", "__init_cs_teams", "(", ")", "for", "play", "in", "self", ".", "_rep_read...
Compute the stats defined in ``self.cum_stats``. :returns: collection of all computed :py:class:`.AccumulateStats` :rtype: dict
[ "Compute", "the", "stats", "defined", "in", "self", ".", "cum_stats", ".", ":", "returns", ":", "collection", "of", "all", "computed", ":", "py", ":", "class", ":", ".", "AccumulateStats", ":", "rtype", ":", "dict" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/playbyplay.py#L84-L102
robhowley/nhlscrapi
nhlscrapi/scrapr/nhlreq.py
NHLCn.__html_rep
def __html_rep(self, game_key, rep_code): """Retrieves the nhl html reports for the specified game and report code""" seas, gt, num = game_key.to_tuple() url = [ self.__domain, "scores/htmlreports/", str(seas-1), str(seas), "/", rep_code, "0", str(gt), ("%04i" % (num)), ".HTM" ] ...
python
def __html_rep(self, game_key, rep_code): """Retrieves the nhl html reports for the specified game and report code""" seas, gt, num = game_key.to_tuple() url = [ self.__domain, "scores/htmlreports/", str(seas-1), str(seas), "/", rep_code, "0", str(gt), ("%04i" % (num)), ".HTM" ] ...
[ "def", "__html_rep", "(", "self", ",", "game_key", ",", "rep_code", ")", ":", "seas", ",", "gt", ",", "num", "=", "game_key", ".", "to_tuple", "(", ")", "url", "=", "[", "self", ".", "__domain", ",", "\"scores/htmlreports/\"", ",", "str", "(", "seas", ...
Retrieves the nhl html reports for the specified game and report code
[ "Retrieves", "the", "nhl", "html", "reports", "for", "the", "specified", "game", "and", "report", "code" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/nhlreq.py#L17-L24
michaelherold/pyIsEmail
pyisemail/validators/parser_validator.py
to_char
def to_char(token): """Transforms the ASCII control character symbols to their real char. Note: If the token is not an ASCII control character symbol, just return the token. Keyword arguments: token -- the token to transform """ if ord(token) in _range(9216, 9229 + 1): token = _un...
python
def to_char(token): """Transforms the ASCII control character symbols to their real char. Note: If the token is not an ASCII control character symbol, just return the token. Keyword arguments: token -- the token to transform """ if ord(token) in _range(9216, 9229 + 1): token = _un...
[ "def", "to_char", "(", "token", ")", ":", "if", "ord", "(", "token", ")", "in", "_range", "(", "9216", ",", "9229", "+", "1", ")", ":", "token", "=", "_unichr", "(", "ord", "(", "token", ")", "-", "9216", ")", "return", "token" ]
Transforms the ASCII control character symbols to their real char. Note: If the token is not an ASCII control character symbol, just return the token. Keyword arguments: token -- the token to transform
[ "Transforms", "the", "ASCII", "control", "character", "symbols", "to", "their", "real", "char", "." ]
train
https://github.com/michaelherold/pyIsEmail/blob/dd42d6425c59e5061fc214d42672210dccc64cf5/pyisemail/validators/parser_validator.py#L48-L61
michaelherold/pyIsEmail
pyisemail/validators/parser_validator.py
ParserValidator.is_email
def is_email(self, address, diagnose=False): """Check that an address address conforms to RFCs 5321, 5322 and others. More specifically, see the follow RFCs: * http://tools.ietf.org/html/rfc5321 * http://tools.ietf.org/html/rfc5322 * http://tools.ietf.org/html/rfc429...
python
def is_email(self, address, diagnose=False): """Check that an address address conforms to RFCs 5321, 5322 and others. More specifically, see the follow RFCs: * http://tools.ietf.org/html/rfc5321 * http://tools.ietf.org/html/rfc5322 * http://tools.ietf.org/html/rfc429...
[ "def", "is_email", "(", "self", ",", "address", ",", "diagnose", "=", "False", ")", ":", "threshold", "=", "BaseDiagnosis", ".", "CATEGORIES", "[", "'VALID'", "]", "return_status", "=", "[", "ValidDiagnosis", "(", ")", "]", "parse_data", "=", "{", "}", "...
Check that an address address conforms to RFCs 5321, 5322 and others. More specifically, see the follow RFCs: * http://tools.ietf.org/html/rfc5321 * http://tools.ietf.org/html/rfc5322 * http://tools.ietf.org/html/rfc4291#section-2.2 * http://tools.ietf.org/html/r...
[ "Check", "that", "an", "address", "address", "conforms", "to", "RFCs", "5321", "5322", "and", "others", "." ]
train
https://github.com/michaelherold/pyIsEmail/blob/dd42d6425c59e5061fc214d42672210dccc64cf5/pyisemail/validators/parser_validator.py#L65-L1127
NeuroanatomyAndConnectivity/surfdist
surfdist/load.py
load_freesurfer_label
def load_freesurfer_label(annot_input, label_name, cortex=None): """ Get source node list for a specified freesurfer label. Inputs ------- annot_input : freesurfer annotation label file label_name : freesurfer label name cortex : not used """ if cortex is not None: print("W...
python
def load_freesurfer_label(annot_input, label_name, cortex=None): """ Get source node list for a specified freesurfer label. Inputs ------- annot_input : freesurfer annotation label file label_name : freesurfer label name cortex : not used """ if cortex is not None: print("W...
[ "def", "load_freesurfer_label", "(", "annot_input", ",", "label_name", ",", "cortex", "=", "None", ")", ":", "if", "cortex", "is", "not", "None", ":", "print", "(", "\"Warning: cortex is not used to load the freesurfer label\"", ")", "labels", ",", "color_table", ",...
Get source node list for a specified freesurfer label. Inputs ------- annot_input : freesurfer annotation label file label_name : freesurfer label name cortex : not used
[ "Get", "source", "node", "list", "for", "a", "specified", "freesurfer", "label", "." ]
train
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/surfdist/load.py#L5-L24
NeuroanatomyAndConnectivity/surfdist
surfdist/load.py
get_freesurfer_label
def get_freesurfer_label(annot_input, verbose = True): """ Print freesurfer label names. """ labels, color_table, names = nib.freesurfer.read_annot(annot_input) if verbose: print(names) return names
python
def get_freesurfer_label(annot_input, verbose = True): """ Print freesurfer label names. """ labels, color_table, names = nib.freesurfer.read_annot(annot_input) if verbose: print(names) return names
[ "def", "get_freesurfer_label", "(", "annot_input", ",", "verbose", "=", "True", ")", ":", "labels", ",", "color_table", ",", "names", "=", "nib", ".", "freesurfer", ".", "read_annot", "(", "annot_input", ")", "if", "verbose", ":", "print", "(", "names", ")...
Print freesurfer label names.
[ "Print", "freesurfer", "label", "names", "." ]
train
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/surfdist/load.py#L27-L34
NeuroanatomyAndConnectivity/surfdist
surfdist/viz.py
viz
def viz(coords, faces, stat_map=None, elev=0, azim=0, cmap='coolwarm', threshold=None, alpha='auto', bg_map=None, bg_on_stat=False, figsize=None, **kwargs): ''' Visualize results on cortical surface using matplotlib. Inputs ------- coords : numpy array of shape ...
python
def viz(coords, faces, stat_map=None, elev=0, azim=0, cmap='coolwarm', threshold=None, alpha='auto', bg_map=None, bg_on_stat=False, figsize=None, **kwargs): ''' Visualize results on cortical surface using matplotlib. Inputs ------- coords : numpy array of shape ...
[ "def", "viz", "(", "coords", ",", "faces", ",", "stat_map", "=", "None", ",", "elev", "=", "0", ",", "azim", "=", "0", ",", "cmap", "=", "'coolwarm'", ",", "threshold", "=", "None", ",", "alpha", "=", "'auto'", ",", "bg_map", "=", "None", ",", "b...
Visualize results on cortical surface using matplotlib. Inputs ------- coords : numpy array of shape (n_nodes,3), each row specifying the x,y,z coordinates of one node of surface mesh faces : numpy array of shape (n_faces, 3), each row specifying the indices of the three nodes b...
[ "Visualize", "results", "on", "cortical", "surface", "using", "matplotlib", "." ]
train
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/surfdist/viz.py#L1-L128
NeuroanatomyAndConnectivity/surfdist
surfdist/utils.py
surf_keep_cortex
def surf_keep_cortex(surf, cortex): """ Remove medial wall from cortical surface to ensure that shortest paths are only calculated through the cortex. Inputs ------- surf : Tuple containing two numpy arrays of shape (n_nodes,3). Each node of the first array specifies the x, y, z coordina...
python
def surf_keep_cortex(surf, cortex): """ Remove medial wall from cortical surface to ensure that shortest paths are only calculated through the cortex. Inputs ------- surf : Tuple containing two numpy arrays of shape (n_nodes,3). Each node of the first array specifies the x, y, z coordina...
[ "def", "surf_keep_cortex", "(", "surf", ",", "cortex", ")", ":", "# split surface into vertices and triangles", "vertices", ",", "triangles", "=", "surf", "# keep only the vertices within the cortex label", "cortex_vertices", "=", "np", ".", "array", "(", "vertices", "[",...
Remove medial wall from cortical surface to ensure that shortest paths are only calculated through the cortex. Inputs ------- surf : Tuple containing two numpy arrays of shape (n_nodes,3). Each node of the first array specifies the x, y, z coordinates one node of the surface mesh. Each node of t...
[ "Remove", "medial", "wall", "from", "cortical", "surface", "to", "ensure", "that", "shortest", "paths", "are", "only", "calculated", "through", "the", "cortex", "." ]
train
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/surfdist/utils.py#L5-L28
NeuroanatomyAndConnectivity/surfdist
surfdist/utils.py
triangles_keep_cortex
def triangles_keep_cortex(triangles, cortex): """ Remove triangles with nodes not contained in the cortex label array """ # for or each face/triangle keep only those that only contain nodes within the list of cortex nodes input_shape = triangles.shape triangle_is_in_cortex = np.all(np.reshape(n...
python
def triangles_keep_cortex(triangles, cortex): """ Remove triangles with nodes not contained in the cortex label array """ # for or each face/triangle keep only those that only contain nodes within the list of cortex nodes input_shape = triangles.shape triangle_is_in_cortex = np.all(np.reshape(n...
[ "def", "triangles_keep_cortex", "(", "triangles", ",", "cortex", ")", ":", "# for or each face/triangle keep only those that only contain nodes within the list of cortex nodes", "input_shape", "=", "triangles", ".", "shape", "triangle_is_in_cortex", "=", "np", ".", "all", "(", ...
Remove triangles with nodes not contained in the cortex label array
[ "Remove", "triangles", "with", "nodes", "not", "contained", "in", "the", "cortex", "label", "array" ]
train
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/surfdist/utils.py#L31-L46
NeuroanatomyAndConnectivity/surfdist
surfdist/utils.py
translate_src
def translate_src(src, cortex): """ Convert source nodes to new surface (without medial wall). """ src_new = np.array(np.where(np.in1d(cortex, src))[0], dtype=np.int32) return src_new
python
def translate_src(src, cortex): """ Convert source nodes to new surface (without medial wall). """ src_new = np.array(np.where(np.in1d(cortex, src))[0], dtype=np.int32) return src_new
[ "def", "translate_src", "(", "src", ",", "cortex", ")", ":", "src_new", "=", "np", ".", "array", "(", "np", ".", "where", "(", "np", ".", "in1d", "(", "cortex", ",", "src", ")", ")", "[", "0", "]", ",", "dtype", "=", "np", ".", "int32", ")", ...
Convert source nodes to new surface (without medial wall).
[ "Convert", "source", "nodes", "to", "new", "surface", "(", "without", "medial", "wall", ")", "." ]
train
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/surfdist/utils.py#L49-L55
NeuroanatomyAndConnectivity/surfdist
surfdist/utils.py
recort
def recort(input_data, surf, cortex): """ Return data values to space of full cortex (including medial wall), with medial wall equal to zero. """ data = np.zeros(len(surf[0])) data[cortex] = input_data return data
python
def recort(input_data, surf, cortex): """ Return data values to space of full cortex (including medial wall), with medial wall equal to zero. """ data = np.zeros(len(surf[0])) data[cortex] = input_data return data
[ "def", "recort", "(", "input_data", ",", "surf", ",", "cortex", ")", ":", "data", "=", "np", ".", "zeros", "(", "len", "(", "surf", "[", "0", "]", ")", ")", "data", "[", "cortex", "]", "=", "input_data", "return", "data" ]
Return data values to space of full cortex (including medial wall), with medial wall equal to zero.
[ "Return", "data", "values", "to", "space", "of", "full", "cortex", "(", "including", "medial", "wall", ")", "with", "medial", "wall", "equal", "to", "zero", "." ]
train
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/surfdist/utils.py#L57-L63
NeuroanatomyAndConnectivity/surfdist
surfdist/utils.py
find_node_match
def find_node_match(simple_vertices, complex_vertices): """ Thanks to juhuntenburg. Functions taken from https://github.com/juhuntenburg/brainsurfacescripts Finds those points on the complex mesh that correspond best to the simple mesh while forcing a one-to-one mapping. """ import scipy.s...
python
def find_node_match(simple_vertices, complex_vertices): """ Thanks to juhuntenburg. Functions taken from https://github.com/juhuntenburg/brainsurfacescripts Finds those points on the complex mesh that correspond best to the simple mesh while forcing a one-to-one mapping. """ import scipy.s...
[ "def", "find_node_match", "(", "simple_vertices", ",", "complex_vertices", ")", ":", "import", "scipy", ".", "spatial", "# make array for writing in final voronoi seed indices", "voronoi_seed_idx", "=", "np", ".", "zeros", "(", "(", "simple_vertices", ".", "shape", "[",...
Thanks to juhuntenburg. Functions taken from https://github.com/juhuntenburg/brainsurfacescripts Finds those points on the complex mesh that correspond best to the simple mesh while forcing a one-to-one mapping.
[ "Thanks", "to", "juhuntenburg", ".", "Functions", "taken", "from", "https", ":", "//", "github", ".", "com", "/", "juhuntenburg", "/", "brainsurfacescripts" ]
train
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/surfdist/utils.py#L66-L119
robhowley/nhlscrapi
nhlscrapi/scrapr/eventsummrep.py
EventSummRep.parse
def parse(self): """ Retreive and parse Event Summary report for the given :py:class:`nhlscrapi.games.game.GameKey` :returns: ``self`` on success, ``None`` otherwise """ try: return super(EventSummRep, self).parse() \ .parse_away_shots() \ ...
python
def parse(self): """ Retreive and parse Event Summary report for the given :py:class:`nhlscrapi.games.game.GameKey` :returns: ``self`` on success, ``None`` otherwise """ try: return super(EventSummRep, self).parse() \ .parse_away_shots() \ ...
[ "def", "parse", "(", "self", ")", ":", "try", ":", "return", "super", "(", "EventSummRep", ",", "self", ")", ".", "parse", "(", ")", ".", "parse_away_shots", "(", ")", ".", "parse_home_shots", "(", ")", ".", "parse_away_fo", "(", ")", ".", "parse_home_...
Retreive and parse Event Summary report for the given :py:class:`nhlscrapi.games.game.GameKey` :returns: ``self`` on success, ``None`` otherwise
[ "Retreive", "and", "parse", "Event", "Summary", "report", "for", "the", "given", ":", "py", ":", "class", ":", "nhlscrapi", ".", "games", ".", "game", ".", "GameKey", ":", "returns", ":", "self", "on", "success", "None", "otherwise" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/eventsummrep.py#L86-L101
robhowley/nhlscrapi
nhlscrapi/scrapr/eventsummrep.py
EventSummRep.parse_home_shots
def parse_home_shots(self): """ Parse shot info for home team. :returns: ``self`` on success, ``None`` otherwise """ try: self.__set_shot_tables() self.shots['home'] = self.__parse_shot_tables( self.__home_top, self...
python
def parse_home_shots(self): """ Parse shot info for home team. :returns: ``self`` on success, ``None`` otherwise """ try: self.__set_shot_tables() self.shots['home'] = self.__parse_shot_tables( self.__home_top, self...
[ "def", "parse_home_shots", "(", "self", ")", ":", "try", ":", "self", ".", "__set_shot_tables", "(", ")", "self", ".", "shots", "[", "'home'", "]", "=", "self", ".", "__parse_shot_tables", "(", "self", ".", "__home_top", ",", "self", ".", "__home_bot", "...
Parse shot info for home team. :returns: ``self`` on success, ``None`` otherwise
[ "Parse", "shot", "info", "for", "home", "team", ".", ":", "returns", ":", "self", "on", "success", "None", "otherwise" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/eventsummrep.py#L149-L163
robhowley/nhlscrapi
nhlscrapi/scrapr/eventsummrep.py
EventSummRep.parse_away_shots
def parse_away_shots(self): """ Parse shot info for away team. :returns: ``self`` on success, ``None`` otherwise """ try: self.__set_shot_tables() self.shots['away'] = self.__parse_shot_tables( self.__aw_top, self._...
python
def parse_away_shots(self): """ Parse shot info for away team. :returns: ``self`` on success, ``None`` otherwise """ try: self.__set_shot_tables() self.shots['away'] = self.__parse_shot_tables( self.__aw_top, self._...
[ "def", "parse_away_shots", "(", "self", ")", ":", "try", ":", "self", ".", "__set_shot_tables", "(", ")", "self", ".", "shots", "[", "'away'", "]", "=", "self", ".", "__parse_shot_tables", "(", "self", ".", "__aw_top", ",", "self", ".", "__aw_bot", ")", ...
Parse shot info for away team. :returns: ``self`` on success, ``None`` otherwise
[ "Parse", "shot", "info", "for", "away", "team", ".", ":", "returns", ":", "self", "on", "success", "None", "otherwise" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/eventsummrep.py#L165-L179
robhowley/nhlscrapi
nhlscrapi/scrapr/eventsummrep.py
EventSummRep.parse_home_fo
def parse_home_fo(self): """ Parse face-off info for home team. :returns: ``self`` on success, ``None`` otherwise """ try: self.__set_fo_tables() self.face_offs['home'] = self.__parse_fo_table(self.__home_fo) return self except...
python
def parse_home_fo(self): """ Parse face-off info for home team. :returns: ``self`` on success, ``None`` otherwise """ try: self.__set_fo_tables() self.face_offs['home'] = self.__parse_fo_table(self.__home_fo) return self except...
[ "def", "parse_home_fo", "(", "self", ")", ":", "try", ":", "self", ".", "__set_fo_tables", "(", ")", "self", ".", "face_offs", "[", "'home'", "]", "=", "self", ".", "__parse_fo_table", "(", "self", ".", "__home_fo", ")", "return", "self", "except", ":", ...
Parse face-off info for home team. :returns: ``self`` on success, ``None`` otherwise
[ "Parse", "face", "-", "off", "info", "for", "home", "team", ".", ":", "returns", ":", "self", "on", "success", "None", "otherwise" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/eventsummrep.py#L181-L192
robhowley/nhlscrapi
nhlscrapi/scrapr/eventsummrep.py
EventSummRep.parse_away_fo
def parse_away_fo(self): """ Parse face-off info for away team. :returns: ``self`` on success, ``None`` otherwise """ try: self.__set_fo_tables() self.face_offs['away'] = self.__parse_fo_table(self.__away_fo) return self except...
python
def parse_away_fo(self): """ Parse face-off info for away team. :returns: ``self`` on success, ``None`` otherwise """ try: self.__set_fo_tables() self.face_offs['away'] = self.__parse_fo_table(self.__away_fo) return self except...
[ "def", "parse_away_fo", "(", "self", ")", ":", "try", ":", "self", ".", "__set_fo_tables", "(", ")", "self", ".", "face_offs", "[", "'away'", "]", "=", "self", ".", "__parse_fo_table", "(", "self", ".", "__away_fo", ")", "return", "self", "except", ":", ...
Parse face-off info for away team. :returns: ``self`` on success, ``None`` otherwise
[ "Parse", "face", "-", "off", "info", "for", "away", "team", ".", ":", "returns", ":", "self", "on", "success", "None", "otherwise" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/eventsummrep.py#L194-L205
NeuroanatomyAndConnectivity/surfdist
surfdist/surfdist.py
dist_calc
def dist_calc(surf, cortex, source_nodes): """ Calculate exact geodesic distance along cortical surface from set of source nodes. "dist_type" specifies whether to calculate "min", "mean", "median", or "max" distance values from a region-of-interest. If running only on single node, defaults to "min". ...
python
def dist_calc(surf, cortex, source_nodes): """ Calculate exact geodesic distance along cortical surface from set of source nodes. "dist_type" specifies whether to calculate "min", "mean", "median", or "max" distance values from a region-of-interest. If running only on single node, defaults to "min". ...
[ "def", "dist_calc", "(", "surf", ",", "cortex", ",", "source_nodes", ")", ":", "cortex_vertices", ",", "cortex_triangles", "=", "surf_keep_cortex", "(", "surf", ",", "cortex", ")", "translated_source_nodes", "=", "translate_src", "(", "source_nodes", ",", "cortex"...
Calculate exact geodesic distance along cortical surface from set of source nodes. "dist_type" specifies whether to calculate "min", "mean", "median", or "max" distance values from a region-of-interest. If running only on single node, defaults to "min".
[ "Calculate", "exact", "geodesic", "distance", "along", "cortical", "surface", "from", "set", "of", "source", "nodes", ".", "dist_type", "specifies", "whether", "to", "calculate", "min", "mean", "median", "or", "max", "distance", "values", "from", "a", "region", ...
train
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/surfdist/surfdist.py#L6-L20
NeuroanatomyAndConnectivity/surfdist
surfdist/surfdist.py
zone_calc
def zone_calc(surf, cortex, src): """ Calculate closest nodes to each source node using exact geodesic distance along the cortical surface. """ cortex_vertices, cortex_triangles = surf_keep_cortex(surf, cortex) dist_vals = np.zeros((len(source_nodes), len(cortex_vertices))) for x in range(len...
python
def zone_calc(surf, cortex, src): """ Calculate closest nodes to each source node using exact geodesic distance along the cortical surface. """ cortex_vertices, cortex_triangles = surf_keep_cortex(surf, cortex) dist_vals = np.zeros((len(source_nodes), len(cortex_vertices))) for x in range(len...
[ "def", "zone_calc", "(", "surf", ",", "cortex", ",", "src", ")", ":", "cortex_vertices", ",", "cortex_triangles", "=", "surf_keep_cortex", "(", "surf", ",", "cortex", ")", "dist_vals", "=", "np", ".", "zeros", "(", "(", "len", "(", "source_nodes", ")", "...
Calculate closest nodes to each source node using exact geodesic distance along the cortical surface.
[ "Calculate", "closest", "nodes", "to", "each", "source", "node", "using", "exact", "geodesic", "distance", "along", "the", "cortical", "surface", "." ]
train
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/surfdist/surfdist.py#L23-L43
NeuroanatomyAndConnectivity/surfdist
surfdist/surfdist.py
dist_calc_matrix
def dist_calc_matrix(surf, cortex, labels, exceptions = ['Unknown', 'Medial_wall'], verbose = True): """ Calculate exact geodesic distance along cortical surface from set of source nodes. "labels" specifies the freesurfer label file to use. All values will be used other than those specified in "exceptio...
python
def dist_calc_matrix(surf, cortex, labels, exceptions = ['Unknown', 'Medial_wall'], verbose = True): """ Calculate exact geodesic distance along cortical surface from set of source nodes. "labels" specifies the freesurfer label file to use. All values will be used other than those specified in "exceptio...
[ "def", "dist_calc_matrix", "(", "surf", ",", "cortex", ",", "labels", ",", "exceptions", "=", "[", "'Unknown'", ",", "'Medial_wall'", "]", ",", "verbose", "=", "True", ")", ":", "cortex_vertices", ",", "cortex_triangles", "=", "surf_keep_cortex", "(", "surf", ...
Calculate exact geodesic distance along cortical surface from set of source nodes. "labels" specifies the freesurfer label file to use. All values will be used other than those specified in "exceptions" (default: 'Unknown' and 'Medial_Wall'). returns: dist_mat: symmetrical nxn matrix of minimum dista...
[ "Calculate", "exact", "geodesic", "distance", "along", "cortical", "surface", "from", "set", "of", "source", "nodes", ".", "labels", "specifies", "the", "freesurfer", "label", "file", "to", "use", ".", "All", "values", "will", "be", "used", "other", "than", ...
train
https://github.com/NeuroanatomyAndConnectivity/surfdist/blob/849fdfbb2822ff1aa530a3b0bc955a4312e3edf1/surfdist/surfdist.py#L46-L85
robhowley/nhlscrapi
nhlscrapi/scrapr/faceoffrep.py
FaceOffRep.parse
def parse(self): """ Retreive and parse Play by Play data for the given nhlscrapi.GameKey :returns: ``self`` on success, ``None`` otherwise """ try: return ( super(FaceOffRep, self).parse() and self.parse_home_face_offs() ...
python
def parse(self): """ Retreive and parse Play by Play data for the given nhlscrapi.GameKey :returns: ``self`` on success, ``None`` otherwise """ try: return ( super(FaceOffRep, self).parse() and self.parse_home_face_offs() ...
[ "def", "parse", "(", "self", ")", ":", "try", ":", "return", "(", "super", "(", "FaceOffRep", ",", "self", ")", ".", "parse", "(", ")", "and", "self", ".", "parse_home_face_offs", "(", ")", "and", "self", ".", "parse_away_face_offs", "(", ")", ")", "...
Retreive and parse Play by Play data for the given nhlscrapi.GameKey :returns: ``self`` on success, ``None`` otherwise
[ "Retreive", "and", "parse", "Play", "by", "Play", "data", "for", "the", "given", "nhlscrapi", ".", "GameKey", ":", "returns", ":", "self", "on", "success", "None", "otherwise" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/faceoffrep.py#L53-L66
robhowley/nhlscrapi
nhlscrapi/scrapr/faceoffrep.py
FaceOffRep.parse_home_face_offs
def parse_home_face_offs(self): """ Parse only the home faceoffs :returns: ``self`` on success, ``None`` otherwise """ self.__set_team_docs() self.face_offs['home'] = FaceOffRep.__read_team_doc(self.__home_doc) return self
python
def parse_home_face_offs(self): """ Parse only the home faceoffs :returns: ``self`` on success, ``None`` otherwise """ self.__set_team_docs() self.face_offs['home'] = FaceOffRep.__read_team_doc(self.__home_doc) return self
[ "def", "parse_home_face_offs", "(", "self", ")", ":", "self", ".", "__set_team_docs", "(", ")", "self", ".", "face_offs", "[", "'home'", "]", "=", "FaceOffRep", ".", "__read_team_doc", "(", "self", ".", "__home_doc", ")", "return", "self" ]
Parse only the home faceoffs :returns: ``self`` on success, ``None`` otherwise
[ "Parse", "only", "the", "home", "faceoffs", ":", "returns", ":", "self", "on", "success", "None", "otherwise" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/faceoffrep.py#L68-L76
robhowley/nhlscrapi
nhlscrapi/scrapr/faceoffrep.py
FaceOffRep.parse_away_face_offs
def parse_away_face_offs(self): """ Parse only the away faceoffs :returns: ``self`` on success, ``None`` otherwise """ self.__set_team_docs() self.face_offs['away'] = FaceOffRep.__read_team_doc(self.__vis_doc) return self
python
def parse_away_face_offs(self): """ Parse only the away faceoffs :returns: ``self`` on success, ``None`` otherwise """ self.__set_team_docs() self.face_offs['away'] = FaceOffRep.__read_team_doc(self.__vis_doc) return self
[ "def", "parse_away_face_offs", "(", "self", ")", ":", "self", ".", "__set_team_docs", "(", ")", "self", ".", "face_offs", "[", "'away'", "]", "=", "FaceOffRep", ".", "__read_team_doc", "(", "self", ".", "__vis_doc", ")", "return", "self" ]
Parse only the away faceoffs :returns: ``self`` on success, ``None`` otherwise
[ "Parse", "only", "the", "away", "faceoffs", ":", "returns", ":", "self", "on", "success", "None", "otherwise" ]
train
https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/scrapr/faceoffrep.py#L78-L86
linkedin/Zopkio
zopkio/utils.py
load_module
def load_module(filename): """ Loads a module by filename """ basename = os.path.basename(filename) path = os.path.dirname(filename) sys.path.append(path) # TODO(tlan) need to figure out how to handle errors thrown here return __import__(os.path.splitext(basename)[0])
python
def load_module(filename): """ Loads a module by filename """ basename = os.path.basename(filename) path = os.path.dirname(filename) sys.path.append(path) # TODO(tlan) need to figure out how to handle errors thrown here return __import__(os.path.splitext(basename)[0])
[ "def", "load_module", "(", "filename", ")", ":", "basename", "=", "os", ".", "path", ".", "basename", "(", "filename", ")", "path", "=", "os", ".", "path", ".", "dirname", "(", "filename", ")", "sys", ".", "path", ".", "append", "(", "path", ")", "...
Loads a module by filename
[ "Loads", "a", "module", "by", "filename" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/utils.py#L58-L66
linkedin/Zopkio
zopkio/utils.py
make_machine_mapping
def make_machine_mapping(machine_list): """ Convert the machine list argument from a list of names into a mapping of logical names to physical hosts. This is similar to the _parse_configs function but separated to provide the opportunity for extension and additional checking of machine access """ if machine...
python
def make_machine_mapping(machine_list): """ Convert the machine list argument from a list of names into a mapping of logical names to physical hosts. This is similar to the _parse_configs function but separated to provide the opportunity for extension and additional checking of machine access """ if machine...
[ "def", "make_machine_mapping", "(", "machine_list", ")", ":", "if", "machine_list", "is", "None", ":", "return", "{", "}", "else", ":", "mapping", "=", "{", "}", "for", "pair", "in", "machine_list", ":", "if", "(", "constants", ".", "MACHINE_SEPARATOR", "n...
Convert the machine list argument from a list of names into a mapping of logical names to physical hosts. This is similar to the _parse_configs function but separated to provide the opportunity for extension and additional checking of machine access
[ "Convert", "the", "machine", "list", "argument", "from", "a", "list", "of", "names", "into", "a", "mapping", "of", "logical", "names", "to", "physical", "hosts", ".", "This", "is", "similar", "to", "the", "_parse_configs", "function", "but", "separated", "to...
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/utils.py#L79-L95
linkedin/Zopkio
zopkio/utils.py
parse_config_list
def parse_config_list(config_list): """ Parse a list of configuration properties separated by '=' """ if config_list is None: return {} else: mapping = {} for pair in config_list: if (constants.CONFIG_SEPARATOR not in pair) or (pair.count(constants.CONFIG_SEPARATOR) != 1): raise Valu...
python
def parse_config_list(config_list): """ Parse a list of configuration properties separated by '=' """ if config_list is None: return {} else: mapping = {} for pair in config_list: if (constants.CONFIG_SEPARATOR not in pair) or (pair.count(constants.CONFIG_SEPARATOR) != 1): raise Valu...
[ "def", "parse_config_list", "(", "config_list", ")", ":", "if", "config_list", "is", "None", ":", "return", "{", "}", "else", ":", "mapping", "=", "{", "}", "for", "pair", "in", "config_list", ":", "if", "(", "constants", ".", "CONFIG_SEPARATOR", "not", ...
Parse a list of configuration properties separated by '='
[ "Parse", "a", "list", "of", "configuration", "properties", "separated", "by", "=" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/utils.py#L98-L111
linkedin/Zopkio
zopkio/utils.py
parse_config_file
def parse_config_file(config_file_path): """ Parse a configuration file. Currently only supports .json, .py and properties separated by '=' :param config_file_path: :return: a dict of the configuration properties """ extension = os.path.splitext(config_file_path)[1] if extension == '.pyc': raise Value...
python
def parse_config_file(config_file_path): """ Parse a configuration file. Currently only supports .json, .py and properties separated by '=' :param config_file_path: :return: a dict of the configuration properties """ extension = os.path.splitext(config_file_path)[1] if extension == '.pyc': raise Value...
[ "def", "parse_config_file", "(", "config_file_path", ")", ":", "extension", "=", "os", ".", "path", ".", "splitext", "(", "config_file_path", ")", "[", "1", "]", "if", "extension", "==", "'.pyc'", ":", "raise", "ValueError", "(", "\"Skipping .pyc file as config\...
Parse a configuration file. Currently only supports .json, .py and properties separated by '=' :param config_file_path: :return: a dict of the configuration properties
[ "Parse", "a", "configuration", "file", ".", "Currently", "only", "supports", ".", "json", ".", "py", "and", "properties", "separated", "by", "=", ":", "param", "config_file_path", ":", ":", "return", ":", "a", "dict", "of", "the", "configuration", "propertie...
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/utils.py#L114-L143
linkedin/Zopkio
zopkio/remote_host_helper.py
exec_with_env
def exec_with_env(ssh, command, msg='', env={}, **kwargs): """ :param ssh: :param command: :param msg: :param env: :param synch: :return: """ bash_profile_command = "source .bash_profile > /dev/null 2> /dev/null;" env_command = build_os_environment_string(env) new_command = bash_profi...
python
def exec_with_env(ssh, command, msg='', env={}, **kwargs): """ :param ssh: :param command: :param msg: :param env: :param synch: :return: """ bash_profile_command = "source .bash_profile > /dev/null 2> /dev/null;" env_command = build_os_environment_string(env) new_command = bash_profi...
[ "def", "exec_with_env", "(", "ssh", ",", "command", ",", "msg", "=", "''", ",", "env", "=", "{", "}", ",", "*", "*", "kwargs", ")", ":", "bash_profile_command", "=", "\"source .bash_profile > /dev/null 2> /dev/null;\"", "env_command", "=", "build_os_environment_st...
:param ssh: :param command: :param msg: :param env: :param synch: :return:
[ ":", "param", "ssh", ":", ":", "param", "command", ":", ":", "param", "msg", ":", ":", "param", "env", ":", ":", "param", "synch", ":", ":", "return", ":" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/remote_host_helper.py#L72-L88
linkedin/Zopkio
zopkio/remote_host_helper.py
better_exec_command
def better_exec_command(ssh, command, msg): """Uses paramiko to execute a command but handles failure by raising a ParamikoError if the command fails. Note that unlike paramiko.SSHClient.exec_command this is not asynchronous because we wait until the exit status is known :Parameter ssh: a paramiko SSH Client...
python
def better_exec_command(ssh, command, msg): """Uses paramiko to execute a command but handles failure by raising a ParamikoError if the command fails. Note that unlike paramiko.SSHClient.exec_command this is not asynchronous because we wait until the exit status is known :Parameter ssh: a paramiko SSH Client...
[ "def", "better_exec_command", "(", "ssh", ",", "command", ",", "msg", ")", ":", "chan", "=", "ssh", ".", "get_transport", "(", ")", ".", "open_session", "(", ")", "chan", ".", "exec_command", "(", "command", ")", "exit_status", "=", "chan", ".", "recv_ex...
Uses paramiko to execute a command but handles failure by raising a ParamikoError if the command fails. Note that unlike paramiko.SSHClient.exec_command this is not asynchronous because we wait until the exit status is known :Parameter ssh: a paramiko SSH Client :Parameter command: the command to execute ...
[ "Uses", "paramiko", "to", "execute", "a", "command", "but", "handles", "failure", "by", "raising", "a", "ParamikoError", "if", "the", "command", "fails", ".", "Note", "that", "unlike", "paramiko", ".", "SSHClient", ".", "exec_command", "this", "is", "not", "...
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/remote_host_helper.py#L90-L116
linkedin/Zopkio
zopkio/remote_host_helper.py
log_output
def log_output(chan): """ logs the output from a remote command the input should be an open channel in the case of synchronous better_exec_command otherwise this will not log anything and simply return to the caller :param chan: :return: """ if hasattr(chan, "recv"): str = chan.recv(1024) ...
python
def log_output(chan): """ logs the output from a remote command the input should be an open channel in the case of synchronous better_exec_command otherwise this will not log anything and simply return to the caller :param chan: :return: """ if hasattr(chan, "recv"): str = chan.recv(1024) ...
[ "def", "log_output", "(", "chan", ")", ":", "if", "hasattr", "(", "chan", ",", "\"recv\"", ")", ":", "str", "=", "chan", ".", "recv", "(", "1024", ")", "msgs", "=", "[", "]", "while", "len", "(", "str", ")", ">", "0", ":", "msgs", ".", "append"...
logs the output from a remote command the input should be an open channel in the case of synchronous better_exec_command otherwise this will not log anything and simply return to the caller :param chan: :return:
[ "logs", "the", "output", "from", "a", "remote", "command", "the", "input", "should", "be", "an", "open", "channel", "in", "the", "case", "of", "synchronous", "better_exec_command", "otherwise", "this", "will", "not", "log", "anything", "and", "simply", "return...
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/remote_host_helper.py#L118-L134
linkedin/Zopkio
zopkio/remote_host_helper.py
copy_dir
def copy_dir(ftp, filename, outputdir, prefix, pattern=''): """ Recursively copy a directory flattens the output into a single directory but prefixes the files with the path from the original input directory :param ftp: :param filename: :param outputdir: :param prefix: :param pattern: a regex pa...
python
def copy_dir(ftp, filename, outputdir, prefix, pattern=''): """ Recursively copy a directory flattens the output into a single directory but prefixes the files with the path from the original input directory :param ftp: :param filename: :param outputdir: :param prefix: :param pattern: a regex pa...
[ "def", "copy_dir", "(", "ftp", ",", "filename", ",", "outputdir", ",", "prefix", ",", "pattern", "=", "''", ")", ":", "try", ":", "mode", "=", "ftp", ".", "stat", "(", "filename", ")", ".", "st_mode", "except", "IOError", ",", "e", ":", "if", "e", ...
Recursively copy a directory flattens the output into a single directory but prefixes the files with the path from the original input directory :param ftp: :param filename: :param outputdir: :param prefix: :param pattern: a regex pattern for files to match (by default matches everything) :return:
[ "Recursively", "copy", "a", "directory", "flattens", "the", "output", "into", "a", "single", "directory", "but", "prefixes", "the", "files", "with", "the", "path", "from", "the", "original", "input", "directory", ":", "param", "ftp", ":", ":", "param", "file...
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/remote_host_helper.py#L137-L162
linkedin/Zopkio
zopkio/remote_host_helper.py
open_remote_file
def open_remote_file(hostname, filename, mode='r', bufsize=-1, username=None, password=None): """ :param hostname: :param filename: :return: """ with get_ssh_client(hostname, username=username, password=password) as ssh: sftp = None f = None try: sftp = ssh.open_sftp() f...
python
def open_remote_file(hostname, filename, mode='r', bufsize=-1, username=None, password=None): """ :param hostname: :param filename: :return: """ with get_ssh_client(hostname, username=username, password=password) as ssh: sftp = None f = None try: sftp = ssh.open_sftp() f...
[ "def", "open_remote_file", "(", "hostname", ",", "filename", ",", "mode", "=", "'r'", ",", "bufsize", "=", "-", "1", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "with", "get_ssh_client", "(", "hostname", ",", "username", "=", ...
:param hostname: :param filename: :return:
[ ":", "param", "hostname", ":", ":", "param", "filename", ":", ":", "return", ":" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/remote_host_helper.py#L166-L184
linkedin/Zopkio
zopkio/deployer.py
Deployer.deploy
def deploy(self, unique_id, configs=None): """Deploys the service to the host. This should at least perform the same actions as install and start but may perform additional tasks as needed. :Parameter unique_id: the name of the process :Parameter configs: a mao of configs the deployer may use to modif...
python
def deploy(self, unique_id, configs=None): """Deploys the service to the host. This should at least perform the same actions as install and start but may perform additional tasks as needed. :Parameter unique_id: the name of the process :Parameter configs: a mao of configs the deployer may use to modif...
[ "def", "deploy", "(", "self", ",", "unique_id", ",", "configs", "=", "None", ")", ":", "self", ".", "install", "(", "unique_id", ",", "configs", ")", "self", ".", "start", "(", "unique_id", ",", "configs", ")" ]
Deploys the service to the host. This should at least perform the same actions as install and start but may perform additional tasks as needed. :Parameter unique_id: the name of the process :Parameter configs: a mao of configs the deployer may use to modify the deployment
[ "Deploys", "the", "service", "to", "the", "host", ".", "This", "should", "at", "least", "perform", "the", "same", "actions", "as", "install", "and", "start", "but", "may", "perform", "additional", "tasks", "as", "needed", "." ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L81-L89
linkedin/Zopkio
zopkio/deployer.py
Deployer.undeploy
def undeploy(self, unique_id, configs=None): """Undeploys the service. This should at least perform the same actions as stop and uninstall but may perform additional tasks as needed. :Parameter unique_id: the name of the process :Parameter configs: a map of configs the deployer may use """ sel...
python
def undeploy(self, unique_id, configs=None): """Undeploys the service. This should at least perform the same actions as stop and uninstall but may perform additional tasks as needed. :Parameter unique_id: the name of the process :Parameter configs: a map of configs the deployer may use """ sel...
[ "def", "undeploy", "(", "self", ",", "unique_id", ",", "configs", "=", "None", ")", ":", "self", ".", "stop", "(", "unique_id", ",", "configs", ")", "self", ".", "uninstall", "(", "unique_id", ",", "configs", ")" ]
Undeploys the service. This should at least perform the same actions as stop and uninstall but may perform additional tasks as needed. :Parameter unique_id: the name of the process :Parameter configs: a map of configs the deployer may use
[ "Undeploys", "the", "service", ".", "This", "should", "at", "least", "perform", "the", "same", "actions", "as", "stop", "and", "uninstall", "but", "may", "perform", "additional", "tasks", "as", "needed", "." ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L91-L99
linkedin/Zopkio
zopkio/deployer.py
Deployer.soft_bounce
def soft_bounce(self, unique_id, configs=None): """ Performs a soft bounce (stop and start) for the specified process :Parameter unique_id: the name of the process """ self.stop(unique_id, configs) self.start(unique_id, configs)
python
def soft_bounce(self, unique_id, configs=None): """ Performs a soft bounce (stop and start) for the specified process :Parameter unique_id: the name of the process """ self.stop(unique_id, configs) self.start(unique_id, configs)
[ "def", "soft_bounce", "(", "self", ",", "unique_id", ",", "configs", "=", "None", ")", ":", "self", ".", "stop", "(", "unique_id", ",", "configs", ")", "self", ".", "start", "(", "unique_id", ",", "configs", ")" ]
Performs a soft bounce (stop and start) for the specified process :Parameter unique_id: the name of the process
[ "Performs", "a", "soft", "bounce", "(", "stop", "and", "start", ")", "for", "the", "specified", "process" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L148-L154
linkedin/Zopkio
zopkio/deployer.py
Deployer.hard_bounce
def hard_bounce(self, unique_id, configs=None): """ Performs a hard bounce (kill and start) for the specified process :Parameter unique_id: the name of the process """ self.kill(unique_id, configs) self.start(unique_id, configs)
python
def hard_bounce(self, unique_id, configs=None): """ Performs a hard bounce (kill and start) for the specified process :Parameter unique_id: the name of the process """ self.kill(unique_id, configs) self.start(unique_id, configs)
[ "def", "hard_bounce", "(", "self", ",", "unique_id", ",", "configs", "=", "None", ")", ":", "self", ".", "kill", "(", "unique_id", ",", "configs", ")", "self", ".", "start", "(", "unique_id", ",", "configs", ")" ]
Performs a hard bounce (kill and start) for the specified process :Parameter unique_id: the name of the process
[ "Performs", "a", "hard", "bounce", "(", "kill", "and", "start", ")", "for", "the", "specified", "process" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L156-L162
linkedin/Zopkio
zopkio/deployer.py
Deployer.sleep
def sleep(self, unique_id, delay, configs=None): """ Pauses the process for the specified delay and then resumes it :Parameter unique_id: the name of the process :Parameter delay: delay time in seconds """ self.pause(unique_id, configs) time.sleep(delay) self.resume(unique_id, configs)
python
def sleep(self, unique_id, delay, configs=None): """ Pauses the process for the specified delay and then resumes it :Parameter unique_id: the name of the process :Parameter delay: delay time in seconds """ self.pause(unique_id, configs) time.sleep(delay) self.resume(unique_id, configs)
[ "def", "sleep", "(", "self", ",", "unique_id", ",", "delay", ",", "configs", "=", "None", ")", ":", "self", ".", "pause", "(", "unique_id", ",", "configs", ")", "time", ".", "sleep", "(", "delay", ")", "self", ".", "resume", "(", "unique_id", ",", ...
Pauses the process for the specified delay and then resumes it :Parameter unique_id: the name of the process :Parameter delay: delay time in seconds
[ "Pauses", "the", "process", "for", "the", "specified", "delay", "and", "then", "resumes", "it" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L164-L172
linkedin/Zopkio
zopkio/deployer.py
Deployer.pause
def pause(self, unique_id, configs=None): """ Issues a sigstop for the specified process :Parameter unique_id: the name of the process """ pids = self.get_pid(unique_id, configs) if pids != constants.PROCESS_NOT_RUNNING_PID: pid_str = ' '.join(str(pid) for pid in pids) hostname = self.p...
python
def pause(self, unique_id, configs=None): """ Issues a sigstop for the specified process :Parameter unique_id: the name of the process """ pids = self.get_pid(unique_id, configs) if pids != constants.PROCESS_NOT_RUNNING_PID: pid_str = ' '.join(str(pid) for pid in pids) hostname = self.p...
[ "def", "pause", "(", "self", ",", "unique_id", ",", "configs", "=", "None", ")", ":", "pids", "=", "self", ".", "get_pid", "(", "unique_id", ",", "configs", ")", "if", "pids", "!=", "constants", ".", "PROCESS_NOT_RUNNING_PID", ":", "pid_str", "=", "' '",...
Issues a sigstop for the specified process :Parameter unique_id: the name of the process
[ "Issues", "a", "sigstop", "for", "the", "specified", "process" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L174-L184
linkedin/Zopkio
zopkio/deployer.py
Deployer._send_signal
def _send_signal(self, unique_id, signalno, configs): """ Issues a signal for the specified process :Parameter unique_id: the name of the process """ pids = self.get_pid(unique_id, configs) if pids != constants.PROCESS_NOT_RUNNING_PID: pid_str = ' '.join(str(pid) for pid in pids) hostna...
python
def _send_signal(self, unique_id, signalno, configs): """ Issues a signal for the specified process :Parameter unique_id: the name of the process """ pids = self.get_pid(unique_id, configs) if pids != constants.PROCESS_NOT_RUNNING_PID: pid_str = ' '.join(str(pid) for pid in pids) hostna...
[ "def", "_send_signal", "(", "self", ",", "unique_id", ",", "signalno", ",", "configs", ")", ":", "pids", "=", "self", ".", "get_pid", "(", "unique_id", ",", "configs", ")", "if", "pids", "!=", "constants", ".", "PROCESS_NOT_RUNNING_PID", ":", "pid_str", "=...
Issues a signal for the specified process :Parameter unique_id: the name of the process
[ "Issues", "a", "signal", "for", "the", "specified", "process" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L186-L197
linkedin/Zopkio
zopkio/deployer.py
Deployer.resume
def resume(self, unique_id, configs=None): """ Issues a sigcont for the specified process :Parameter unique_id: the name of the process """ self._send_signal(unique_id, signal.SIGCONT,configs)
python
def resume(self, unique_id, configs=None): """ Issues a sigcont for the specified process :Parameter unique_id: the name of the process """ self._send_signal(unique_id, signal.SIGCONT,configs)
[ "def", "resume", "(", "self", ",", "unique_id", ",", "configs", "=", "None", ")", ":", "self", ".", "_send_signal", "(", "unique_id", ",", "signal", ".", "SIGCONT", ",", "configs", ")" ]
Issues a sigcont for the specified process :Parameter unique_id: the name of the process
[ "Issues", "a", "sigcont", "for", "the", "specified", "process" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L200-L205
linkedin/Zopkio
zopkio/deployer.py
Deployer.kill
def kill(self, unique_id, configs=None): """ Issues a kill -9 to the specified process calls the deployers get_pid function for the process. If no pid_file/pid_keyword is specified a generic grep of ps aux command is executed on remote machine based on process parameters which may not be reliable if mor...
python
def kill(self, unique_id, configs=None): """ Issues a kill -9 to the specified process calls the deployers get_pid function for the process. If no pid_file/pid_keyword is specified a generic grep of ps aux command is executed on remote machine based on process parameters which may not be reliable if mor...
[ "def", "kill", "(", "self", ",", "unique_id", ",", "configs", "=", "None", ")", ":", "self", ".", "_send_signal", "(", "unique_id", ",", "signal", ".", "SIGKILL", ",", "configs", ")" ]
Issues a kill -9 to the specified process calls the deployers get_pid function for the process. If no pid_file/pid_keyword is specified a generic grep of ps aux command is executed on remote machine based on process parameters which may not be reliable if more process are running with similar name :Par...
[ "Issues", "a", "kill", "-", "9", "to", "the", "specified", "process", "calls", "the", "deployers", "get_pid", "function", "for", "the", "process", ".", "If", "no", "pid_file", "/", "pid_keyword", "is", "specified", "a", "generic", "grep", "of", "ps", "aux"...
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L207-L215
linkedin/Zopkio
zopkio/deployer.py
Deployer.terminate
def terminate(self, unique_id, configs=None): """ Issues a kill -15 to the specified process :Parameter unique_id: the name of the process """ self._send_signal(unique_id, signal.SIGTERM, configs)
python
def terminate(self, unique_id, configs=None): """ Issues a kill -15 to the specified process :Parameter unique_id: the name of the process """ self._send_signal(unique_id, signal.SIGTERM, configs)
[ "def", "terminate", "(", "self", ",", "unique_id", ",", "configs", "=", "None", ")", ":", "self", ".", "_send_signal", "(", "unique_id", ",", "signal", ".", "SIGTERM", ",", "configs", ")" ]
Issues a kill -15 to the specified process :Parameter unique_id: the name of the process
[ "Issues", "a", "kill", "-", "15", "to", "the", "specified", "process" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L217-L222
linkedin/Zopkio
zopkio/deployer.py
Deployer.hangup
def hangup(self, unique_id, configs=None): """ Issue a signal to hangup the specified process :Parameter unique_id: the name of the process """ self._send_signal(unique_id, signal.SIGHUP, configs)
python
def hangup(self, unique_id, configs=None): """ Issue a signal to hangup the specified process :Parameter unique_id: the name of the process """ self._send_signal(unique_id, signal.SIGHUP, configs)
[ "def", "hangup", "(", "self", ",", "unique_id", ",", "configs", "=", "None", ")", ":", "self", ".", "_send_signal", "(", "unique_id", ",", "signal", ".", "SIGHUP", ",", "configs", ")" ]
Issue a signal to hangup the specified process :Parameter unique_id: the name of the process
[ "Issue", "a", "signal", "to", "hangup", "the", "specified", "process" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L224-L230
linkedin/Zopkio
zopkio/deployer.py
Deployer.get_logs
def get_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_NONE): """deprecated name for fetch_logs""" self.fetch_logs(unique_id, logs, directory, pattern)
python
def get_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_NONE): """deprecated name for fetch_logs""" self.fetch_logs(unique_id, logs, directory, pattern)
[ "def", "get_logs", "(", "self", ",", "unique_id", ",", "logs", ",", "directory", ",", "pattern", "=", "constants", ".", "FILTER_NAME_ALLOW_NONE", ")", ":", "self", ".", "fetch_logs", "(", "unique_id", ",", "logs", ",", "directory", ",", "pattern", ")" ]
deprecated name for fetch_logs
[ "deprecated", "name", "for", "fetch_logs" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L232-L234
linkedin/Zopkio
zopkio/deployer.py
Deployer.fetch_logs
def fetch_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_NONE): """ Copies logs from the remote host that the process is running on to the provided directory :Parameter unique_id the unique_id of the process in question :Parameter logs a list of logs given by absolute path from ...
python
def fetch_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_NONE): """ Copies logs from the remote host that the process is running on to the provided directory :Parameter unique_id the unique_id of the process in question :Parameter logs a list of logs given by absolute path from ...
[ "def", "fetch_logs", "(", "self", ",", "unique_id", ",", "logs", ",", "directory", ",", "pattern", "=", "constants", ".", "FILTER_NAME_ALLOW_NONE", ")", ":", "hostname", "=", "self", ".", "processes", "[", "unique_id", "]", ".", "hostname", "install_path", "...
Copies logs from the remote host that the process is running on to the provided directory :Parameter unique_id the unique_id of the process in question :Parameter logs a list of logs given by absolute path from the remote host :Parameter directory the local directory to store the copied logs :Parameter...
[ "Copies", "logs", "from", "the", "remote", "host", "that", "the", "process", "is", "running", "on", "to", "the", "provided", "directory" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L236-L246
linkedin/Zopkio
zopkio/deployer.py
Deployer.fetch_logs_from_host
def fetch_logs_from_host(hostname, install_path, prefix, logs, directory, pattern): """ Static method Copies logs from specified host on the specified install path :Parameter hostname the remote host from where we need to fetch the logs :Parameter install_path path where the app is installed :Parameter...
python
def fetch_logs_from_host(hostname, install_path, prefix, logs, directory, pattern): """ Static method Copies logs from specified host on the specified install path :Parameter hostname the remote host from where we need to fetch the logs :Parameter install_path path where the app is installed :Parameter...
[ "def", "fetch_logs_from_host", "(", "hostname", ",", "install_path", ",", "prefix", ",", "logs", ",", "directory", ",", "pattern", ")", ":", "if", "hostname", "is", "not", "None", ":", "with", "get_sftp_client", "(", "hostname", ",", "username", "=", "runtim...
Static method Copies logs from specified host on the specified install path :Parameter hostname the remote host from where we need to fetch the logs :Parameter install_path path where the app is installed :Parameter prefix prefix used to copy logs. Generall the unique_id of process :Parameter logs a li...
[ "Static", "method", "Copies", "logs", "from", "specified", "host", "on", "the", "specified", "install", "path" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L249-L271
linkedin/Zopkio
zopkio/junit_reporter.py
Reporter.generate
def generate(self): """ Generates the report """ self._setup() for config_name in self.report_info.config_to_test_names_map.keys(): config_dir = os.path.join(self.report_info.resource_dir, config_name) utils.makedirs(config_dir) testsuite = self._generate_junit_xml(config_name) ...
python
def generate(self): """ Generates the report """ self._setup() for config_name in self.report_info.config_to_test_names_map.keys(): config_dir = os.path.join(self.report_info.resource_dir, config_name) utils.makedirs(config_dir) testsuite = self._generate_junit_xml(config_name) ...
[ "def", "generate", "(", "self", ")", ":", "self", ".", "_setup", "(", ")", "for", "config_name", "in", "self", ".", "report_info", ".", "config_to_test_names_map", ".", "keys", "(", ")", ":", "config_dir", "=", "os", ".", "path", ".", "join", "(", "sel...
Generates the report
[ "Generates", "the", "report" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/junit_reporter.py#L81-L91
linkedin/Zopkio
zopkio/adhoc_deployer.py
SSHDeployer.install
def install(self, unique_id, configs=None): """ Copies the executable to the remote machine under install path. Inspects the configs for the possible keys 'hostname': the host to install on 'install_path': the location on the remote host 'executable': the executable to copy 'no_copy': if this co...
python
def install(self, unique_id, configs=None): """ Copies the executable to the remote machine under install path. Inspects the configs for the possible keys 'hostname': the host to install on 'install_path': the location on the remote host 'executable': the executable to copy 'no_copy': if this co...
[ "def", "install", "(", "self", ",", "unique_id", ",", "configs", "=", "None", ")", ":", "# the following is necessay to set the configs for this function as the combination of the", "# default configurations and the parameter with the parameter superceding the defaults but", "# not modif...
Copies the executable to the remote machine under install path. Inspects the configs for the possible keys 'hostname': the host to install on 'install_path': the location on the remote host 'executable': the executable to copy 'no_copy': if this config is passed in and true then this method will not cop...
[ "Copies", "the", "executable", "to", "the", "remote", "machine", "under", "install", "path", ".", "Inspects", "the", "configs", "for", "the", "possible", "keys", "hostname", ":", "the", "host", "to", "install", "on", "install_path", ":", "the", "location", "...
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/adhoc_deployer.py#L78-L197
linkedin/Zopkio
zopkio/adhoc_deployer.py
SSHDeployer.start
def start(self, unique_id, configs=None): """ Start the service. If `unique_id` has already been installed the deployer will start the service on that host. Otherwise this will call install with the configs. Within the context of this function, only four configs are considered 'start_command': the ...
python
def start(self, unique_id, configs=None): """ Start the service. If `unique_id` has already been installed the deployer will start the service on that host. Otherwise this will call install with the configs. Within the context of this function, only four configs are considered 'start_command': the ...
[ "def", "start", "(", "self", ",", "unique_id", ",", "configs", "=", "None", ")", ":", "# the following is necessay to set the configs for this function as the combination of the", "# default configurations and the parameter with the parameter superceding the defaults but", "# not modifyi...
Start the service. If `unique_id` has already been installed the deployer will start the service on that host. Otherwise this will call install with the configs. Within the context of this function, only four configs are considered 'start_command': the command to run (if provided will replace the default) ...
[ "Start", "the", "service", ".", "If", "unique_id", "has", "already", "been", "installed", "the", "deployer", "will", "start", "the", "service", "on", "that", "host", ".", "Otherwise", "this", "will", "call", "install", "with", "the", "configs", ".", "Within"...
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/adhoc_deployer.py#L199-L262