id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
46,000
hthiery/python-fritzhome
pyfritzhome/cli.py
list_all
def list_all(fritz, args): """Command that prints all device information.""" devices = fritz.get_devices() for device in devices: print('#' * 30) print('name=%s' % device.name) print(' ain=%s' % device.ain) print(' id=%s' % device.identifier) print(' productname=%...
python
def list_all(fritz, args): """Command that prints all device information.""" devices = fritz.get_devices() for device in devices: print('#' * 30) print('name=%s' % device.name) print(' ain=%s' % device.ain) print(' id=%s' % device.identifier) print(' productname=%...
[ "def", "list_all", "(", "fritz", ",", "args", ")", ":", "devices", "=", "fritz", ".", "get_devices", "(", ")", "for", "device", "in", "devices", ":", "print", "(", "'#'", "*", "30", ")", "print", "(", "'name=%s'", "%", "device", ".", "name", ")", "...
Command that prints all device information.
[ "Command", "that", "prints", "all", "device", "information", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/cli.py#L18-L61
46,001
hthiery/python-fritzhome
pyfritzhome/cli.py
device_statistics
def device_statistics(fritz, args): """Command that prints the device statistics.""" stats = fritz.get_device_statistics(args.ain) print(stats)
python
def device_statistics(fritz, args): """Command that prints the device statistics.""" stats = fritz.get_device_statistics(args.ain) print(stats)
[ "def", "device_statistics", "(", "fritz", ",", "args", ")", ":", "stats", "=", "fritz", ".", "get_device_statistics", "(", "args", ".", "ain", ")", "print", "(", "stats", ")" ]
Command that prints the device statistics.
[ "Command", "that", "prints", "the", "device", "statistics", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/cli.py#L74-L77
46,002
daler/metaseq
metaseq/helpers.py
chunker
def chunker(f, n): """ Utility function to split iterable `f` into `n` chunks """ f = iter(f) x = [] while 1: if len(x) < n: try: x.append(f.next()) except StopIteration: if len(x) > 0: yield tuple(x) ...
python
def chunker(f, n): """ Utility function to split iterable `f` into `n` chunks """ f = iter(f) x = [] while 1: if len(x) < n: try: x.append(f.next()) except StopIteration: if len(x) > 0: yield tuple(x) ...
[ "def", "chunker", "(", "f", ",", "n", ")", ":", "f", "=", "iter", "(", "f", ")", "x", "=", "[", "]", "while", "1", ":", "if", "len", "(", "x", ")", "<", "n", ":", "try", ":", "x", ".", "append", "(", "f", ".", "next", "(", ")", ")", "...
Utility function to split iterable `f` into `n` chunks
[ "Utility", "function", "to", "split", "iterable", "f", "into", "n", "chunks" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/helpers.py#L18-L34
46,003
daler/metaseq
metaseq/helpers.py
split_feature
def split_feature(f, n): """ Split an interval into `n` roughly equal portions """ if not isinstance(n, int): raise ValueError('n must be an integer') orig_feature = copy(f) step = (f.stop - f.start) / n for i in range(f.start, f.stop, step): f = copy(orig_feature) st...
python
def split_feature(f, n): """ Split an interval into `n` roughly equal portions """ if not isinstance(n, int): raise ValueError('n must be an integer') orig_feature = copy(f) step = (f.stop - f.start) / n for i in range(f.start, f.stop, step): f = copy(orig_feature) st...
[ "def", "split_feature", "(", "f", ",", "n", ")", ":", "if", "not", "isinstance", "(", "n", ",", "int", ")", ":", "raise", "ValueError", "(", "'n must be an integer'", ")", "orig_feature", "=", "copy", "(", "f", ")", "step", "=", "(", "f", ".", "stop"...
Split an interval into `n` roughly equal portions
[ "Split", "an", "interval", "into", "n", "roughly", "equal", "portions" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/helpers.py#L67-L83
46,004
daler/metaseq
metaseq/helpers.py
tointerval
def tointerval(s): """ If string, then convert to an interval; otherwise just return the input """ if isinstance(s, basestring): m = coord_re.search(s) if m.group('strand'): return pybedtools.create_interval_from_list([ m.group('chrom'), m.grou...
python
def tointerval(s): """ If string, then convert to an interval; otherwise just return the input """ if isinstance(s, basestring): m = coord_re.search(s) if m.group('strand'): return pybedtools.create_interval_from_list([ m.group('chrom'), m.grou...
[ "def", "tointerval", "(", "s", ")", ":", "if", "isinstance", "(", "s", ",", "basestring", ")", ":", "m", "=", "coord_re", ".", "search", "(", "s", ")", "if", "m", ".", "group", "(", "'strand'", ")", ":", "return", "pybedtools", ".", "create_interval_...
If string, then convert to an interval; otherwise just return the input
[ "If", "string", "then", "convert", "to", "an", "interval", ";", "otherwise", "just", "return", "the", "input" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/helpers.py#L93-L113
46,005
hfaran/progressive
progressive/bar.py
Bar.max_width
def max_width(self): """Get maximum width of progress bar :rtype: int :returns: Maximum column width of progress bar """ value, unit = float(self._width_str[:-1]), self._width_str[-1] ensure(unit in ["c", "%"], ValueError, "Width unit must be either 'c' o...
python
def max_width(self): """Get maximum width of progress bar :rtype: int :returns: Maximum column width of progress bar """ value, unit = float(self._width_str[:-1]), self._width_str[-1] ensure(unit in ["c", "%"], ValueError, "Width unit must be either 'c' o...
[ "def", "max_width", "(", "self", ")", ":", "value", ",", "unit", "=", "float", "(", "self", ".", "_width_str", "[", ":", "-", "1", "]", ")", ",", "self", ".", "_width_str", "[", "-", "1", "]", "ensure", "(", "unit", "in", "[", "\"c\"", ",", "\"...
Get maximum width of progress bar :rtype: int :returns: Maximum column width of progress bar
[ "Get", "maximum", "width", "of", "progress", "bar" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/bar.py#L144-L166
46,006
hfaran/progressive
progressive/bar.py
Bar.full_line_width
def full_line_width(self): """Find actual length of bar_str e.g., Progress [ | ] 10/10 """ bar_str_len = sum([ self._indent, ((len(self.title) + 1) if self._title_pos in ["left", "right"] else 0), # Title if present len(self.start...
python
def full_line_width(self): """Find actual length of bar_str e.g., Progress [ | ] 10/10 """ bar_str_len = sum([ self._indent, ((len(self.title) + 1) if self._title_pos in ["left", "right"] else 0), # Title if present len(self.start...
[ "def", "full_line_width", "(", "self", ")", ":", "bar_str_len", "=", "sum", "(", "[", "self", ".", "_indent", ",", "(", "(", "len", "(", "self", ".", "title", ")", "+", "1", ")", "if", "self", ".", "_title_pos", "in", "[", "\"left\"", ",", "\"right...
Find actual length of bar_str e.g., Progress [ | ] 10/10
[ "Find", "actual", "length", "of", "bar_str" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/bar.py#L169-L184
46,007
hfaran/progressive
progressive/bar.py
Bar._supports_colors
def _supports_colors(term, raise_err, colors): """Check if ``term`` supports ``colors`` :raises ColorUnsupportedError: This is raised if ``raise_err`` is ``False`` and a color in ``colors`` is unsupported by ``term`` :type raise_err: bool :param raise_err: Set to ``False`` t...
python
def _supports_colors(term, raise_err, colors): """Check if ``term`` supports ``colors`` :raises ColorUnsupportedError: This is raised if ``raise_err`` is ``False`` and a color in ``colors`` is unsupported by ``term`` :type raise_err: bool :param raise_err: Set to ``False`` t...
[ "def", "_supports_colors", "(", "term", ",", "raise_err", ",", "colors", ")", ":", "for", "color", "in", "colors", ":", "try", ":", "if", "isinstance", "(", "color", ",", "str", ")", ":", "req_colors", "=", "16", "if", "\"bright\"", "in", "color", "els...
Check if ``term`` supports ``colors`` :raises ColorUnsupportedError: This is raised if ``raise_err`` is ``False`` and a color in ``colors`` is unsupported by ``term`` :type raise_err: bool :param raise_err: Set to ``False`` to return a ``bool`` indicating color support r...
[ "Check", "if", "term", "supports", "colors" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/bar.py#L243-L270
46,008
hfaran/progressive
progressive/bar.py
Bar._get_format_callable
def _get_format_callable(term, color, back_color): """Get string-coloring callable Get callable for string output using ``color`` on ``back_color`` on ``term`` :param term: blessings.Terminal instance :param color: Color that callable will color the string it's passed ...
python
def _get_format_callable(term, color, back_color): """Get string-coloring callable Get callable for string output using ``color`` on ``back_color`` on ``term`` :param term: blessings.Terminal instance :param color: Color that callable will color the string it's passed ...
[ "def", "_get_format_callable", "(", "term", ",", "color", ",", "back_color", ")", ":", "if", "isinstance", "(", "color", ",", "str", ")", ":", "ensure", "(", "any", "(", "isinstance", "(", "back_color", ",", "t", ")", "for", "t", "in", "[", "str", ",...
Get string-coloring callable Get callable for string output using ``color`` on ``back_color`` on ``term`` :param term: blessings.Terminal instance :param color: Color that callable will color the string it's passed :param back_color: Back color for the string :retur...
[ "Get", "string", "-", "coloring", "callable" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/bar.py#L273-L301
46,009
hfaran/progressive
progressive/bar.py
Bar.draw
def draw(self, value, newline=True, flush=True): """Draw the progress bar :type value: int :param value: Progress value relative to ``self.max_value`` :type newline: bool :param newline: If this is set, a newline will be written after drawing """ # This is esse...
python
def draw(self, value, newline=True, flush=True): """Draw the progress bar :type value: int :param value: Progress value relative to ``self.max_value`` :type newline: bool :param newline: If this is set, a newline will be written after drawing """ # This is esse...
[ "def", "draw", "(", "self", ",", "value", ",", "newline", "=", "True", ",", "flush", "=", "True", ")", ":", "# This is essentially winch-handling without having", "# to do winch-handling; cleanly redrawing on winch is difficult", "# and out of the intended scope of this class...
Draw the progress bar :type value: int :param value: Progress value relative to ``self.max_value`` :type newline: bool :param newline: If this is set, a newline will be written after drawing
[ "Draw", "the", "progress", "bar" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/bar.py#L339-L408
46,010
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
get_text
def get_text(nodelist): """Get the value from a text node.""" value = [] for node in nodelist: if node.nodeType == node.TEXT_NODE: value.append(node.data) return ''.join(value)
python
def get_text(nodelist): """Get the value from a text node.""" value = [] for node in nodelist: if node.nodeType == node.TEXT_NODE: value.append(node.data) return ''.join(value)
[ "def", "get_text", "(", "nodelist", ")", ":", "value", "=", "[", "]", "for", "node", "in", "nodelist", ":", "if", "node", ".", "nodeType", "==", "node", ".", "TEXT_NODE", ":", "value", ".", "append", "(", "node", ".", "data", ")", "return", "''", "...
Get the value from a text node.
[ "Get", "the", "value", "from", "a", "text", "node", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L14-L20
46,011
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome._request
def _request(self, url, params=None, timeout=10): """Send a request with parameters.""" rsp = self._session.get(url, params=params, timeout=timeout) rsp.raise_for_status() return rsp.text.strip()
python
def _request(self, url, params=None, timeout=10): """Send a request with parameters.""" rsp = self._session.get(url, params=params, timeout=timeout) rsp.raise_for_status() return rsp.text.strip()
[ "def", "_request", "(", "self", ",", "url", ",", "params", "=", "None", ",", "timeout", "=", "10", ")", ":", "rsp", "=", "self", ".", "_session", ".", "get", "(", "url", ",", "params", "=", "params", ",", "timeout", "=", "timeout", ")", "rsp", "....
Send a request with parameters.
[ "Send", "a", "request", "with", "parameters", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L47-L51
46,012
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome._login_request
def _login_request(self, username=None, secret=None): """Send a login request with paramerters.""" url = 'http://' + self._host + '/login_sid.lua' params = {} if username: params['username'] = username if secret: params['response'] = secret plain ...
python
def _login_request(self, username=None, secret=None): """Send a login request with paramerters.""" url = 'http://' + self._host + '/login_sid.lua' params = {} if username: params['username'] = username if secret: params['response'] = secret plain ...
[ "def", "_login_request", "(", "self", ",", "username", "=", "None", ",", "secret", "=", "None", ")", ":", "url", "=", "'http://'", "+", "self", ".", "_host", "+", "'/login_sid.lua'", "params", "=", "{", "}", "if", "username", ":", "params", "[", "'user...
Send a login request with paramerters.
[ "Send", "a", "login", "request", "with", "paramerters", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L53-L68
46,013
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome._logout_request
def _logout_request(self): """Send a logout request.""" _LOGGER.debug('logout') url = 'http://' + self._host + '/login_sid.lua' params = { 'security:command/logout': '1', 'sid': self._sid } self._request(url, params)
python
def _logout_request(self): """Send a logout request.""" _LOGGER.debug('logout') url = 'http://' + self._host + '/login_sid.lua' params = { 'security:command/logout': '1', 'sid': self._sid } self._request(url, params)
[ "def", "_logout_request", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "'logout'", ")", "url", "=", "'http://'", "+", "self", ".", "_host", "+", "'/login_sid.lua'", "params", "=", "{", "'security:command/logout'", ":", "'1'", ",", "'sid'", ":", "se...
Send a logout request.
[ "Send", "a", "logout", "request", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L70-L79
46,014
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome._create_login_secret
def _create_login_secret(challenge, password): """Create a login secret.""" to_hash = (challenge + '-' + password).encode('UTF-16LE') hashed = hashlib.md5(to_hash).hexdigest() return '{0}-{1}'.format(challenge, hashed)
python
def _create_login_secret(challenge, password): """Create a login secret.""" to_hash = (challenge + '-' + password).encode('UTF-16LE') hashed = hashlib.md5(to_hash).hexdigest() return '{0}-{1}'.format(challenge, hashed)
[ "def", "_create_login_secret", "(", "challenge", ",", "password", ")", ":", "to_hash", "=", "(", "challenge", "+", "'-'", "+", "password", ")", ".", "encode", "(", "'UTF-16LE'", ")", "hashed", "=", "hashlib", ".", "md5", "(", "to_hash", ")", ".", "hexdig...
Create a login secret.
[ "Create", "a", "login", "secret", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L82-L86
46,015
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome._aha_request
def _aha_request(self, cmd, ain=None, param=None, rf=str): """Send an AHA request.""" url = 'http://' + self._host + '/webservices/homeautoswitch.lua' params = { 'switchcmd': cmd, 'sid': self._sid } if param: params['param'] = param if ...
python
def _aha_request(self, cmd, ain=None, param=None, rf=str): """Send an AHA request.""" url = 'http://' + self._host + '/webservices/homeautoswitch.lua' params = { 'switchcmd': cmd, 'sid': self._sid } if param: params['param'] = param if ...
[ "def", "_aha_request", "(", "self", ",", "cmd", ",", "ain", "=", "None", ",", "param", "=", "None", ",", "rf", "=", "str", ")", ":", "url", "=", "'http://'", "+", "self", ".", "_host", "+", "'/webservices/homeautoswitch.lua'", "params", "=", "{", "'swi...
Send an AHA request.
[ "Send", "an", "AHA", "request", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L88-L106
46,016
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome.login
def login(self): """Login and get a valid session ID.""" try: (sid, challenge) = self._login_request() if sid == '0000000000000000': secret = self._create_login_secret(challenge, self._password) (sid2, challenge) = self._login_request(username=self...
python
def login(self): """Login and get a valid session ID.""" try: (sid, challenge) = self._login_request() if sid == '0000000000000000': secret = self._create_login_secret(challenge, self._password) (sid2, challenge) = self._login_request(username=self...
[ "def", "login", "(", "self", ")", ":", "try", ":", "(", "sid", ",", "challenge", ")", "=", "self", ".", "_login_request", "(", ")", "if", "sid", "==", "'0000000000000000'", ":", "secret", "=", "self", ".", "_create_login_secret", "(", "challenge", ",", ...
Login and get a valid session ID.
[ "Login", "and", "get", "a", "valid", "session", "ID", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L108-L121
46,017
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome.get_device_elements
def get_device_elements(self): """Get the DOM elements for the device list.""" plain = self._aha_request('getdevicelistinfos') dom = xml.dom.minidom.parseString(plain) _LOGGER.debug(dom) return dom.getElementsByTagName("device")
python
def get_device_elements(self): """Get the DOM elements for the device list.""" plain = self._aha_request('getdevicelistinfos') dom = xml.dom.minidom.parseString(plain) _LOGGER.debug(dom) return dom.getElementsByTagName("device")
[ "def", "get_device_elements", "(", "self", ")", ":", "plain", "=", "self", ".", "_aha_request", "(", "'getdevicelistinfos'", ")", "dom", "=", "xml", ".", "dom", ".", "minidom", ".", "parseString", "(", "plain", ")", "_LOGGER", ".", "debug", "(", "dom", "...
Get the DOM elements for the device list.
[ "Get", "the", "DOM", "elements", "for", "the", "device", "list", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L128-L133
46,018
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome.get_device_element
def get_device_element(self, ain): """Get the DOM element for the specified device.""" elements = self.get_device_elements() for element in elements: if element.getAttribute('identifier') == ain: return element return None
python
def get_device_element(self, ain): """Get the DOM element for the specified device.""" elements = self.get_device_elements() for element in elements: if element.getAttribute('identifier') == ain: return element return None
[ "def", "get_device_element", "(", "self", ",", "ain", ")", ":", "elements", "=", "self", ".", "get_device_elements", "(", ")", "for", "element", "in", "elements", ":", "if", "element", ".", "getAttribute", "(", "'identifier'", ")", "==", "ain", ":", "retur...
Get the DOM element for the specified device.
[ "Get", "the", "DOM", "element", "for", "the", "specified", "device", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L135-L141
46,019
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome.get_devices
def get_devices(self): """Get the list of all known devices.""" devices = [] for element in self.get_device_elements(): device = FritzhomeDevice(self, node=element) devices.append(device) return devices
python
def get_devices(self): """Get the list of all known devices.""" devices = [] for element in self.get_device_elements(): device = FritzhomeDevice(self, node=element) devices.append(device) return devices
[ "def", "get_devices", "(", "self", ")", ":", "devices", "=", "[", "]", "for", "element", "in", "self", ".", "get_device_elements", "(", ")", ":", "device", "=", "FritzhomeDevice", "(", "self", ",", "node", "=", "element", ")", "devices", ".", "append", ...
Get the list of all known devices.
[ "Get", "the", "list", "of", "all", "known", "devices", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L143-L149
46,020
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome.get_device_by_ain
def get_device_by_ain(self, ain): """Returns a device specified by the AIN.""" devices = self.get_devices() for device in devices: if device.ain == ain: return device
python
def get_device_by_ain(self, ain): """Returns a device specified by the AIN.""" devices = self.get_devices() for device in devices: if device.ain == ain: return device
[ "def", "get_device_by_ain", "(", "self", ",", "ain", ")", ":", "devices", "=", "self", ".", "get_devices", "(", ")", "for", "device", "in", "devices", ":", "if", "device", ".", "ain", "==", "ain", ":", "return", "device" ]
Returns a device specified by the AIN.
[ "Returns", "a", "device", "specified", "by", "the", "AIN", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L151-L156
46,021
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
Fritzhome.set_target_temperature
def set_target_temperature(self, ain, temperature): """Set the thermostate target temperature.""" param = 16 + ((float(temperature) - 8) * 2) if param < min(range(16, 56)): param = 253 elif param > max(range(16, 56)): param = 254 self._aha_request('sethkr...
python
def set_target_temperature(self, ain, temperature): """Set the thermostate target temperature.""" param = 16 + ((float(temperature) - 8) * 2) if param < min(range(16, 56)): param = 253 elif param > max(range(16, 56)): param = 254 self._aha_request('sethkr...
[ "def", "set_target_temperature", "(", "self", ",", "ain", ",", "temperature", ")", ":", "param", "=", "16", "+", "(", "(", "float", "(", "temperature", ")", "-", "8", ")", "*", "2", ")", "if", "param", "<", "min", "(", "range", "(", "16", ",", "5...
Set the thermostate target temperature.
[ "Set", "the", "thermostate", "target", "temperature", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L202-L210
46,022
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
FritzhomeDevice.update
def update(self): """Update the device values.""" node = self._fritz.get_device_element(self.ain) self._update_from_node(node)
python
def update(self): """Update the device values.""" node = self._fritz.get_device_element(self.ain) self._update_from_node(node)
[ "def", "update", "(", "self", ")", ":", "node", "=", "self", ".", "_fritz", ".", "get_device_element", "(", "self", ".", "ain", ")", "self", ".", "_update_from_node", "(", "node", ")" ]
Update the device values.
[ "Update", "the", "device", "values", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L409-L412
46,023
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
FritzhomeDevice.get_hkr_state
def get_hkr_state(self): """Get the thermostate state.""" self.update() try: return { 126.5: 'off', 127.0: 'on', self.eco_temperature: 'eco', self.comfort_temperature: 'comfort' }[self.target_temperature] ...
python
def get_hkr_state(self): """Get the thermostate state.""" self.update() try: return { 126.5: 'off', 127.0: 'on', self.eco_temperature: 'eco', self.comfort_temperature: 'comfort' }[self.target_temperature] ...
[ "def", "get_hkr_state", "(", "self", ")", ":", "self", ".", "update", "(", ")", "try", ":", "return", "{", "126.5", ":", "'off'", ",", "127.0", ":", "'on'", ",", "self", ".", "eco_temperature", ":", "'eco'", ",", "self", ".", "comfort_temperature", ":"...
Get the thermostate state.
[ "Get", "the", "thermostate", "state", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L492-L503
46,024
hthiery/python-fritzhome
pyfritzhome/fritzhome.py
FritzhomeDevice.set_hkr_state
def set_hkr_state(self, state): """Set the state of the thermostat. Possible values for state are: 'on', 'off', 'comfort', 'eco'. """ try: value = { 'off': 0, 'on': 100, 'eco': self.eco_temperature, 'comfort': s...
python
def set_hkr_state(self, state): """Set the state of the thermostat. Possible values for state are: 'on', 'off', 'comfort', 'eco'. """ try: value = { 'off': 0, 'on': 100, 'eco': self.eco_temperature, 'comfort': s...
[ "def", "set_hkr_state", "(", "self", ",", "state", ")", ":", "try", ":", "value", "=", "{", "'off'", ":", "0", ",", "'on'", ":", "100", ",", "'eco'", ":", "self", ".", "eco_temperature", ",", "'comfort'", ":", "self", ".", "comfort_temperature", "}", ...
Set the state of the thermostat. Possible values for state are: 'on', 'off', 'comfort', 'eco'.
[ "Set", "the", "state", "of", "the", "thermostat", "." ]
c74bd178d08a305028f316f7da35202da3526f61
https://github.com/hthiery/python-fritzhome/blob/c74bd178d08a305028f316f7da35202da3526f61/pyfritzhome/fritzhome.py#L505-L520
46,025
hfaran/progressive
progressive/cursor.py
Cursor.write
def write(self, s): """Writes ``s`` to the terminal output stream Writes can be disabled by setting the environment variable `PROGRESSIVE_NOWRITE` to `'True'` """ should_write_s = os.getenv('PROGRESSIVE_NOWRITE') != "True" if should_write_s: self._stream....
python
def write(self, s): """Writes ``s`` to the terminal output stream Writes can be disabled by setting the environment variable `PROGRESSIVE_NOWRITE` to `'True'` """ should_write_s = os.getenv('PROGRESSIVE_NOWRITE') != "True" if should_write_s: self._stream....
[ "def", "write", "(", "self", ",", "s", ")", ":", "should_write_s", "=", "os", ".", "getenv", "(", "'PROGRESSIVE_NOWRITE'", ")", "!=", "\"True\"", "if", "should_write_s", ":", "self", ".", "_stream", ".", "write", "(", "s", ")" ]
Writes ``s`` to the terminal output stream Writes can be disabled by setting the environment variable `PROGRESSIVE_NOWRITE` to `'True'`
[ "Writes", "s", "to", "the", "terminal", "output", "stream" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/cursor.py#L18-L26
46,026
hfaran/progressive
progressive/cursor.py
Cursor.save
def save(self): """Saves current cursor position, so that it can be restored later""" self.write(self.term.save) self._saved = True
python
def save(self): """Saves current cursor position, so that it can be restored later""" self.write(self.term.save) self._saved = True
[ "def", "save", "(", "self", ")", ":", "self", ".", "write", "(", "self", ".", "term", ".", "save", ")", "self", ".", "_saved", "=", "True" ]
Saves current cursor position, so that it can be restored later
[ "Saves", "current", "cursor", "position", "so", "that", "it", "can", "be", "restored", "later" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/cursor.py#L28-L31
46,027
hfaran/progressive
progressive/cursor.py
Cursor.newline
def newline(self): """Effects a newline by moving the cursor down and clearing""" self.write(self.term.move_down) self.write(self.term.clear_bol)
python
def newline(self): """Effects a newline by moving the cursor down and clearing""" self.write(self.term.move_down) self.write(self.term.clear_bol)
[ "def", "newline", "(", "self", ")", ":", "self", ".", "write", "(", "self", ".", "term", ".", "move_down", ")", "self", ".", "write", "(", "self", ".", "term", ".", "clear_bol", ")" ]
Effects a newline by moving the cursor down and clearing
[ "Effects", "a", "newline", "by", "moving", "the", "cursor", "down", "and", "clearing" ]
e39c7fb17405dbe997c3417a5993b94ef16dab0a
https://github.com/hfaran/progressive/blob/e39c7fb17405dbe997c3417a5993b94ef16dab0a/progressive/cursor.py#L46-L49
46,028
daler/metaseq
metaseq/results_table.py
ResultsTable.attach_db
def attach_db(self, db): """ Attach a gffutils.FeatureDB for access to features. Useful if you want to attach a db after this instance has already been created. Parameters ---------- db : gffutils.FeatureDB """ if db is not None: if i...
python
def attach_db(self, db): """ Attach a gffutils.FeatureDB for access to features. Useful if you want to attach a db after this instance has already been created. Parameters ---------- db : gffutils.FeatureDB """ if db is not None: if i...
[ "def", "attach_db", "(", "self", ",", "db", ")", ":", "if", "db", "is", "not", "None", ":", "if", "isinstance", "(", "db", ",", "basestring", ")", ":", "db", "=", "gffutils", ".", "FeatureDB", "(", "db", ")", "if", "not", "isinstance", "(", "db", ...
Attach a gffutils.FeatureDB for access to features. Useful if you want to attach a db after this instance has already been created. Parameters ---------- db : gffutils.FeatureDB
[ "Attach", "a", "gffutils", ".", "FeatureDB", "for", "access", "to", "features", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L88-L106
46,029
daler/metaseq
metaseq/results_table.py
ResultsTable.features
def features(self, ignore_unknown=False): """ Generator of features. If a gffutils.FeatureDB is attached, returns a pybedtools.Interval for every feature in the dataframe's index. Parameters ---------- ignore_unknown : bool If True, silently ignores ...
python
def features(self, ignore_unknown=False): """ Generator of features. If a gffutils.FeatureDB is attached, returns a pybedtools.Interval for every feature in the dataframe's index. Parameters ---------- ignore_unknown : bool If True, silently ignores ...
[ "def", "features", "(", "self", ",", "ignore_unknown", "=", "False", ")", ":", "if", "not", "self", ".", "db", ":", "raise", "ValueError", "(", "\"Please attach a gffutils.FeatureDB\"", ")", "for", "i", "in", "self", ".", "data", ".", "index", ":", "try", ...
Generator of features. If a gffutils.FeatureDB is attached, returns a pybedtools.Interval for every feature in the dataframe's index. Parameters ---------- ignore_unknown : bool If True, silently ignores features that are not found in the db.
[ "Generator", "of", "features", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L108-L129
46,030
daler/metaseq
metaseq/results_table.py
ResultsTable.reindex_to
def reindex_to(self, x, attribute="Name"): """ Returns a copy that only has rows corresponding to feature names in x. Parameters ---------- x : str or pybedtools.BedTool BED, GFF, GTF, or VCF where the "Name" field (that is, the value returned by feature[...
python
def reindex_to(self, x, attribute="Name"): """ Returns a copy that only has rows corresponding to feature names in x. Parameters ---------- x : str or pybedtools.BedTool BED, GFF, GTF, or VCF where the "Name" field (that is, the value returned by feature[...
[ "def", "reindex_to", "(", "self", ",", "x", ",", "attribute", "=", "\"Name\"", ")", ":", "names", "=", "[", "i", "[", "attribute", "]", "for", "i", "in", "x", "]", "new", "=", "self", ".", "copy", "(", ")", "new", ".", "data", "=", "new", ".", ...
Returns a copy that only has rows corresponding to feature names in x. Parameters ---------- x : str or pybedtools.BedTool BED, GFF, GTF, or VCF where the "Name" field (that is, the value returned by feature['Name']) or any arbitrary attribute attribute : str ...
[ "Returns", "a", "copy", "that", "only", "has", "rows", "corresponding", "to", "feature", "names", "in", "x", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L131-L147
46,031
daler/metaseq
metaseq/results_table.py
ResultsTable.align_with
def align_with(self, other): """ Align the dataframe's index with another. """ return self.__class__(self.data.reindex_like(other), **self._kwargs)
python
def align_with(self, other): """ Align the dataframe's index with another. """ return self.__class__(self.data.reindex_like(other), **self._kwargs)
[ "def", "align_with", "(", "self", ",", "other", ")", ":", "return", "self", ".", "__class__", "(", "self", ".", "data", ".", "reindex_like", "(", "other", ")", ",", "*", "*", "self", ".", "_kwargs", ")" ]
Align the dataframe's index with another.
[ "Align", "the", "dataframe", "s", "index", "with", "another", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L182-L186
46,032
daler/metaseq
metaseq/results_table.py
ResultsTable.radviz
def radviz(self, column_names, transforms=dict(), **kwargs): """ Radviz plot. Useful for exploratory visualization, a radviz plot can show multivariate data in 2D. Conceptually, the variables (here, specified in `column_names`) are distributed evenly around the unit circle. Th...
python
def radviz(self, column_names, transforms=dict(), **kwargs): """ Radviz plot. Useful for exploratory visualization, a radviz plot can show multivariate data in 2D. Conceptually, the variables (here, specified in `column_names`) are distributed evenly around the unit circle. Th...
[ "def", "radviz", "(", "self", ",", "column_names", ",", "transforms", "=", "dict", "(", ")", ",", "*", "*", "kwargs", ")", ":", "# make a copy of data", "x", "=", "self", ".", "data", "[", "column_names", "]", ".", "copy", "(", ")", "for", "k", ",", ...
Radviz plot. Useful for exploratory visualization, a radviz plot can show multivariate data in 2D. Conceptually, the variables (here, specified in `column_names`) are distributed evenly around the unit circle. Then each point (here, each row in the dataframe) is attached to each ...
[ "Radviz", "plot", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L543-L656
46,033
daler/metaseq
metaseq/results_table.py
ResultsTable.strip_unknown_features
def strip_unknown_features(self): """ Remove features not found in the `gffutils.FeatureDB`. This will typically include 'ambiguous', 'no_feature', etc, but can also be useful if the database was created from a different one than was used to create the table. """ ...
python
def strip_unknown_features(self): """ Remove features not found in the `gffutils.FeatureDB`. This will typically include 'ambiguous', 'no_feature', etc, but can also be useful if the database was created from a different one than was used to create the table. """ ...
[ "def", "strip_unknown_features", "(", "self", ")", ":", "if", "not", "self", ".", "db", ":", "return", "self", "ind", "=", "[", "]", "for", "i", ",", "gene_id", "in", "enumerate", "(", "self", ".", "data", ".", "index", ")", ":", "try", ":", "self"...
Remove features not found in the `gffutils.FeatureDB`. This will typically include 'ambiguous', 'no_feature', etc, but can also be useful if the database was created from a different one than was used to create the table.
[ "Remove", "features", "not", "found", "in", "the", "gffutils", ".", "FeatureDB", ".", "This", "will", "typically", "include", "ambiguous", "no_feature", "etc", "but", "can", "also", "be", "useful", "if", "the", "database", "was", "created", "from", "a", "dif...
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L671-L688
46,034
daler/metaseq
metaseq/results_table.py
ResultsTable.genes_with_peak
def genes_with_peak(self, peaks, transform_func=None, split=False, intersect_kwargs=None, id_attribute='ID', *args, **kwargs): """ Returns a boolean index of genes that have a peak nearby. Parameters ---------- peaks : string or py...
python
def genes_with_peak(self, peaks, transform_func=None, split=False, intersect_kwargs=None, id_attribute='ID', *args, **kwargs): """ Returns a boolean index of genes that have a peak nearby. Parameters ---------- peaks : string or py...
[ "def", "genes_with_peak", "(", "self", ",", "peaks", ",", "transform_func", "=", "None", ",", "split", "=", "False", ",", "intersect_kwargs", "=", "None", ",", "id_attribute", "=", "'ID'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "_t...
Returns a boolean index of genes that have a peak nearby. Parameters ---------- peaks : string or pybedtools.BedTool If string, then assume it's a filename to a BED/GFF/GTF file of intervals; otherwise use the pybedtools.BedTool object directly. transform_func :...
[ "Returns", "a", "boolean", "index", "of", "genes", "that", "have", "a", "peak", "nearby", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L690-L758
46,035
daler/metaseq
metaseq/results_table.py
DifferentialExpressionResults.enriched
def enriched(self, thresh=0.05, idx=True): """ Enriched features. {threshdoc} """ return self.upregulated(thresh=thresh, idx=idx)
python
def enriched(self, thresh=0.05, idx=True): """ Enriched features. {threshdoc} """ return self.upregulated(thresh=thresh, idx=idx)
[ "def", "enriched", "(", "self", ",", "thresh", "=", "0.05", ",", "idx", "=", "True", ")", ":", "return", "self", ".", "upregulated", "(", "thresh", "=", "thresh", ",", "idx", "=", "idx", ")" ]
Enriched features. {threshdoc}
[ "Enriched", "features", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L814-L820
46,036
daler/metaseq
metaseq/results_table.py
DifferentialExpressionResults.upregulated
def upregulated(self, thresh=0.05, idx=True): """ Upregulated features. {threshdoc} """ ind = ( (self.data[self.pval_column] <= thresh) & (self.data[self.lfc_column] > 0) ) if idx: return ind return self[ind]
python
def upregulated(self, thresh=0.05, idx=True): """ Upregulated features. {threshdoc} """ ind = ( (self.data[self.pval_column] <= thresh) & (self.data[self.lfc_column] > 0) ) if idx: return ind return self[ind]
[ "def", "upregulated", "(", "self", ",", "thresh", "=", "0.05", ",", "idx", "=", "True", ")", ":", "ind", "=", "(", "(", "self", ".", "data", "[", "self", ".", "pval_column", "]", "<=", "thresh", ")", "&", "(", "self", ".", "data", "[", "self", ...
Upregulated features. {threshdoc}
[ "Upregulated", "features", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L822-L834
46,037
daler/metaseq
metaseq/results_table.py
DifferentialExpressionResults.disenriched
def disenriched(self, thresh=0.05, idx=True): """ Disenriched features. {threshdoc} """ return self.downregulated(thresh=thresh, idx=idx)
python
def disenriched(self, thresh=0.05, idx=True): """ Disenriched features. {threshdoc} """ return self.downregulated(thresh=thresh, idx=idx)
[ "def", "disenriched", "(", "self", ",", "thresh", "=", "0.05", ",", "idx", "=", "True", ")", ":", "return", "self", ".", "downregulated", "(", "thresh", "=", "thresh", ",", "idx", "=", "idx", ")" ]
Disenriched features. {threshdoc}
[ "Disenriched", "features", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L850-L856
46,038
daler/metaseq
metaseq/results_table.py
DESeqResults.colormapped_bedfile
def colormapped_bedfile(self, genome, cmap=None): """ Create a BED file with padj encoded as color Features will be colored according to adjusted pval (phred transformed). Downregulated features have the sign flipped. Parameters ---------- cmap : matplotlib col...
python
def colormapped_bedfile(self, genome, cmap=None): """ Create a BED file with padj encoded as color Features will be colored according to adjusted pval (phred transformed). Downregulated features have the sign flipped. Parameters ---------- cmap : matplotlib col...
[ "def", "colormapped_bedfile", "(", "self", ",", "genome", ",", "cmap", "=", "None", ")", ":", "if", "self", ".", "db", "is", "None", ":", "raise", "ValueError", "(", "\"FeatureDB required\"", ")", "db", "=", "gffutils", ".", "FeatureDB", "(", "self", "."...
Create a BED file with padj encoded as color Features will be colored according to adjusted pval (phred transformed). Downregulated features have the sign flipped. Parameters ---------- cmap : matplotlib colormap Default is matplotlib.cm.RdBu_r Notes ...
[ "Create", "a", "BED", "file", "with", "padj", "encoded", "as", "color" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/results_table.py#L944-L1003
46,039
daler/metaseq
metaseq/array_helpers.py
_array_parallel
def _array_parallel(fn, cls, genelist, chunksize=250, processes=1, **kwargs): """ Returns an array of genes in `genelist`, using `bins` bins. `genelist` is a list of pybedtools.Interval objects Splits `genelist` into pieces of size `chunksize`, creating an array for each chunk and merging ret ...
python
def _array_parallel(fn, cls, genelist, chunksize=250, processes=1, **kwargs): """ Returns an array of genes in `genelist`, using `bins` bins. `genelist` is a list of pybedtools.Interval objects Splits `genelist` into pieces of size `chunksize`, creating an array for each chunk and merging ret ...
[ "def", "_array_parallel", "(", "fn", ",", "cls", ",", "genelist", ",", "chunksize", "=", "250", ",", "processes", "=", "1", ",", "*", "*", "kwargs", ")", ":", "pool", "=", "multiprocessing", ".", "Pool", "(", "processes", ")", "chunks", "=", "list", ...
Returns an array of genes in `genelist`, using `bins` bins. `genelist` is a list of pybedtools.Interval objects Splits `genelist` into pieces of size `chunksize`, creating an array for each chunk and merging ret A chunksize of 25-100 seems to work well on 8 cores.
[ "Returns", "an", "array", "of", "genes", "in", "genelist", "using", "bins", "bins", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/array_helpers.py#L394-L421
46,040
daler/metaseq
metaseq/array_helpers.py
_array_star
def _array_star(args): """ Unpacks the tuple `args` and calls _array. Needed to pass multiple args to a pool.map-ed function """ fn, cls, genelist, kwargs = args return _array(fn, cls, genelist, **kwargs)
python
def _array_star(args): """ Unpacks the tuple `args` and calls _array. Needed to pass multiple args to a pool.map-ed function """ fn, cls, genelist, kwargs = args return _array(fn, cls, genelist, **kwargs)
[ "def", "_array_star", "(", "args", ")", ":", "fn", ",", "cls", ",", "genelist", ",", "kwargs", "=", "args", "return", "_array", "(", "fn", ",", "cls", ",", "genelist", ",", "*", "*", "kwargs", ")" ]
Unpacks the tuple `args` and calls _array. Needed to pass multiple args to a pool.map-ed function
[ "Unpacks", "the", "tuple", "args", "and", "calls", "_array", ".", "Needed", "to", "pass", "multiple", "args", "to", "a", "pool", ".", "map", "-", "ed", "function" ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/array_helpers.py#L452-L458
46,041
daler/metaseq
metaseq/arrayify.py
Binner.to_npz
def to_npz(self, bigwig, metric='mean0', outdir=None): """ Bin data for bigwig and save to disk. The .npz file will have the pattern {outdir}/{bigwig}.{chrom}.{windowsize}.{metric}.npz and will have two arrays, x (genomic coordinates of midpoints of each window) and y (m...
python
def to_npz(self, bigwig, metric='mean0', outdir=None): """ Bin data for bigwig and save to disk. The .npz file will have the pattern {outdir}/{bigwig}.{chrom}.{windowsize}.{metric}.npz and will have two arrays, x (genomic coordinates of midpoints of each window) and y (m...
[ "def", "to_npz", "(", "self", ",", "bigwig", ",", "metric", "=", "'mean0'", ",", "outdir", "=", "None", ")", ":", "if", "isinstance", "(", "bigwig", ",", "_genomic_signal", ".", "BigWigSignal", ")", ":", "bigwig", "=", "bigwig", ".", "fn", "if", "outdi...
Bin data for bigwig and save to disk. The .npz file will have the pattern {outdir}/{bigwig}.{chrom}.{windowsize}.{metric}.npz and will have two arrays, x (genomic coordinates of midpoints of each window) and y (metric for each window). It can be loaded like this:: d = np.l...
[ "Bin", "data", "for", "bigwig", "and", "save", "to", "disk", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/arrayify.py#L84-L142
46,042
daler/metaseq
metaseq/integration/signal_comparison.py
compare
def compare(signal1, signal2, features, outfn, comparefunc=np.subtract, batchsize=5000, array_kwargs=None, verbose=False): """ Compares two genomic signal objects and outputs results as a bedGraph file. Can be used for entire genome-wide comparisons due to its parallel nature. Typical usage wou...
python
def compare(signal1, signal2, features, outfn, comparefunc=np.subtract, batchsize=5000, array_kwargs=None, verbose=False): """ Compares two genomic signal objects and outputs results as a bedGraph file. Can be used for entire genome-wide comparisons due to its parallel nature. Typical usage wou...
[ "def", "compare", "(", "signal1", ",", "signal2", ",", "features", ",", "outfn", ",", "comparefunc", "=", "np", ".", "subtract", ",", "batchsize", "=", "5000", ",", "array_kwargs", "=", "None", ",", "verbose", "=", "False", ")", ":", "fout", "=", "open...
Compares two genomic signal objects and outputs results as a bedGraph file. Can be used for entire genome-wide comparisons due to its parallel nature. Typical usage would be to create genome-wide windows of equal size to provide as `features`:: windowsize = 10000 features = pybedtools.BedT...
[ "Compares", "two", "genomic", "signal", "objects", "and", "outputs", "results", "as", "a", "bedGraph", "file", ".", "Can", "be", "used", "for", "entire", "genome", "-", "wide", "comparisons", "due", "to", "its", "parallel", "nature", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/integration/signal_comparison.py#L11-L113
46,043
moble/h5py_cache
__init__.py
_find_next_prime
def _find_next_prime(N): """Find next prime >= N""" def is_prime(n): if n % 2 == 0: return False i = 3 while i * i <= n: if n % i: i += 2 else: return False return True if N < 3: return 2 if N % 2...
python
def _find_next_prime(N): """Find next prime >= N""" def is_prime(n): if n % 2 == 0: return False i = 3 while i * i <= n: if n % i: i += 2 else: return False return True if N < 3: return 2 if N % 2...
[ "def", "_find_next_prime", "(", "N", ")", ":", "def", "is_prime", "(", "n", ")", ":", "if", "n", "%", "2", "==", "0", ":", "return", "False", "i", "=", "3", "while", "i", "*", "i", "<=", "n", ":", "if", "n", "%", "i", ":", "i", "+=", "2", ...
Find next prime >= N
[ "Find", "next", "prime", ">", "=", "N" ]
2491896f14a8fae01e2540eec62b3a8d5cb8bfa9
https://github.com/moble/h5py_cache/blob/2491896f14a8fae01e2540eec62b3a8d5cb8bfa9/__init__.py#L5-L24
46,044
moble/h5py_cache
__init__.py
File
def File(name, mode='a', chunk_cache_mem_size=1024**2, w0=0.75, n_cache_chunks=None, **kwds): """Create h5py File object with cache specification This function is basically just a wrapper around the usual h5py.File constructor, but accepts two additional keywords: Parameters ---------- name : ...
python
def File(name, mode='a', chunk_cache_mem_size=1024**2, w0=0.75, n_cache_chunks=None, **kwds): """Create h5py File object with cache specification This function is basically just a wrapper around the usual h5py.File constructor, but accepts two additional keywords: Parameters ---------- name : ...
[ "def", "File", "(", "name", ",", "mode", "=", "'a'", ",", "chunk_cache_mem_size", "=", "1024", "**", "2", ",", "w0", "=", "0.75", ",", "n_cache_chunks", "=", "None", ",", "*", "*", "kwds", ")", ":", "import", "sys", "import", "numpy", "as", "np", "...
Create h5py File object with cache specification This function is basically just a wrapper around the usual h5py.File constructor, but accepts two additional keywords: Parameters ---------- name : str mode : str **kwds : dict (as keywords) Standard h5py.File arguments, passed to it...
[ "Create", "h5py", "File", "object", "with", "cache", "specification" ]
2491896f14a8fae01e2540eec62b3a8d5cb8bfa9
https://github.com/moble/h5py_cache/blob/2491896f14a8fae01e2540eec62b3a8d5cb8bfa9/__init__.py#L27-L75
46,045
daler/metaseq
metaseq/integration/chipseq.py
save
def save(c, prefix, relative_paths=True): """ Save data from a Chipseq object. Parameters ---------- c : Chipseq object Chipseq object, most likely after calling the `diffed_array` method prefix : str Prefix, including any leading directory paths, to save the data. relati...
python
def save(c, prefix, relative_paths=True): """ Save data from a Chipseq object. Parameters ---------- c : Chipseq object Chipseq object, most likely after calling the `diffed_array` method prefix : str Prefix, including any leading directory paths, to save the data. relati...
[ "def", "save", "(", "c", ",", "prefix", ",", "relative_paths", "=", "True", ")", ":", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "prefix", ")", "pybedtools", ".", "BedTool", "(", "c", ".", "features", ")", ".", "saveas", "(", "prefix", ...
Save data from a Chipseq object. Parameters ---------- c : Chipseq object Chipseq object, most likely after calling the `diffed_array` method prefix : str Prefix, including any leading directory paths, to save the data. relative_paths : bool If True (default), then the pa...
[ "Save", "data", "from", "a", "Chipseq", "object", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/integration/chipseq.py#L16-L73
46,046
daler/metaseq
metaseq/integration/chipseq.py
xcorr
def xcorr(x, y, maxlags): """ Streamlined version of matplotlib's `xcorr`, without the plots. :param x, y: NumPy arrays to cross-correlate :param maxlags: Max number of lags; result will be `2*maxlags+1` in length """ xlen = len(x) ylen = len(y) assert xlen == ylen c = np.correlate...
python
def xcorr(x, y, maxlags): """ Streamlined version of matplotlib's `xcorr`, without the plots. :param x, y: NumPy arrays to cross-correlate :param maxlags: Max number of lags; result will be `2*maxlags+1` in length """ xlen = len(x) ylen = len(y) assert xlen == ylen c = np.correlate...
[ "def", "xcorr", "(", "x", ",", "y", ",", "maxlags", ")", ":", "xlen", "=", "len", "(", "x", ")", "ylen", "=", "len", "(", "y", ")", "assert", "xlen", "==", "ylen", "c", "=", "np", ".", "correlate", "(", "x", ",", "y", ",", "mode", "=", "2",...
Streamlined version of matplotlib's `xcorr`, without the plots. :param x, y: NumPy arrays to cross-correlate :param maxlags: Max number of lags; result will be `2*maxlags+1` in length
[ "Streamlined", "version", "of", "matplotlib", "s", "xcorr", "without", "the", "plots", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/integration/chipseq.py#L410-L429
46,047
daler/metaseq
metaseq/integration/chipseq.py
Chipseq.plot
def plot(self, x, row_order=None, imshow_kwargs=None, strip=True): """ Plot the scaled ChIP-seq data. :param x: X-axis to use (e.g, for TSS +/- 1kb with 100 bins, this would be `np.linspace(-1000, 1000, 100)`) :param row_order: Array-like object containing row order -- typic...
python
def plot(self, x, row_order=None, imshow_kwargs=None, strip=True): """ Plot the scaled ChIP-seq data. :param x: X-axis to use (e.g, for TSS +/- 1kb with 100 bins, this would be `np.linspace(-1000, 1000, 100)`) :param row_order: Array-like object containing row order -- typic...
[ "def", "plot", "(", "self", ",", "x", ",", "row_order", "=", "None", ",", "imshow_kwargs", "=", "None", ",", "strip", "=", "True", ")", ":", "nrows", "=", "self", ".", "diffed_array", ".", "shape", "[", "0", "]", "if", "row_order", "is", "None", ":...
Plot the scaled ChIP-seq data. :param x: X-axis to use (e.g, for TSS +/- 1kb with 100 bins, this would be `np.linspace(-1000, 1000, 100)`) :param row_order: Array-like object containing row order -- typically the result of an `np.argsort` call. :param strip: Include axes...
[ "Plot", "the", "scaled", "ChIP", "-", "seq", "data", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/integration/chipseq.py#L212-L277
46,048
daler/metaseq
metaseq/integration/chipseq.py
Chipseq.callback
def callback(self, event): """ Callback function to spawn a mini-browser when a feature is clicked. """ artist = event.artist ind = artist.ind limit = 5 browser = True if len(event.ind) > limit: print "more than %s genes selected; not spawning ...
python
def callback(self, event): """ Callback function to spawn a mini-browser when a feature is clicked. """ artist = event.artist ind = artist.ind limit = 5 browser = True if len(event.ind) > limit: print "more than %s genes selected; not spawning ...
[ "def", "callback", "(", "self", ",", "event", ")", ":", "artist", "=", "event", ".", "artist", "ind", "=", "artist", ".", "ind", "limit", "=", "5", "browser", "=", "True", "if", "len", "(", "event", ".", "ind", ")", ">", "limit", ":", "print", "\...
Callback function to spawn a mini-browser when a feature is clicked.
[ "Callback", "function", "to", "spawn", "a", "mini", "-", "browser", "when", "a", "feature", "is", "clicked", "." ]
fa875d1f72317aa7ef95cb128b739956b16eef9f
https://github.com/daler/metaseq/blob/fa875d1f72317aa7ef95cb128b739956b16eef9f/metaseq/integration/chipseq.py#L279-L294
46,049
h2non/paco
paco/observer.py
Observer.remove
def remove(self, event=None): """ Remove all the registered observers for the given event name. Arguments: event (str): event name to remove. """ observers = self._pool.get(event) if observers: self._pool[event] = []
python
def remove(self, event=None): """ Remove all the registered observers for the given event name. Arguments: event (str): event name to remove. """ observers = self._pool.get(event) if observers: self._pool[event] = []
[ "def", "remove", "(", "self", ",", "event", "=", "None", ")", ":", "observers", "=", "self", ".", "_pool", ".", "get", "(", "event", ")", "if", "observers", ":", "self", ".", "_pool", "[", "event", "]", "=", "[", "]" ]
Remove all the registered observers for the given event name. Arguments: event (str): event name to remove.
[ "Remove", "all", "the", "registered", "observers", "for", "the", "given", "event", "name", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/observer.py#L44-L53
46,050
h2non/paco
paco/observer.py
Observer.trigger
def trigger(self, event, *args, **kw): """ Triggers event observers for the given event name, passing custom variadic arguments. """ observers = self._pool.get(event) # If no observers registered for the event, do no-op if not observers or len(observers) == 0: ...
python
def trigger(self, event, *args, **kw): """ Triggers event observers for the given event name, passing custom variadic arguments. """ observers = self._pool.get(event) # If no observers registered for the event, do no-op if not observers or len(observers) == 0: ...
[ "def", "trigger", "(", "self", ",", "event", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "observers", "=", "self", ".", "_pool", ".", "get", "(", "event", ")", "# If no observers registered for the event, do no-op", "if", "not", "observers", "or", "le...
Triggers event observers for the given event name, passing custom variadic arguments.
[ "Triggers", "event", "observers", "for", "the", "given", "event", "name", "passing", "custom", "variadic", "arguments", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/observer.py#L66-L80
46,051
h2non/paco
paco/until.py
until
def until(coro, coro_test, assert_coro=None, *args, **kw): """ Repeatedly call `coro` coroutine function until `coro_test` returns `True`. This function is the inverse of `paco.whilst()`. This function is a coroutine. Arguments: coro (coroutinefunction): coroutine function to execute. ...
python
def until(coro, coro_test, assert_coro=None, *args, **kw): """ Repeatedly call `coro` coroutine function until `coro_test` returns `True`. This function is the inverse of `paco.whilst()`. This function is a coroutine. Arguments: coro (coroutinefunction): coroutine function to execute. ...
[ "def", "until", "(", "coro", ",", "coro_test", ",", "assert_coro", "=", "None", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "@", "asyncio", ".", "coroutine", "def", "assert_coro", "(", "value", ")", ":", "return", "not", "value", "return", "(", ...
Repeatedly call `coro` coroutine function until `coro_test` returns `True`. This function is the inverse of `paco.whilst()`. This function is a coroutine. Arguments: coro (coroutinefunction): coroutine function to execute. coro_test (coroutinefunction): coroutine function to test. ...
[ "Repeatedly", "call", "coro", "coroutine", "function", "until", "coro_test", "returns", "True", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/until.py#L7-L49
46,052
h2non/paco
paco/curry.py
curry
def curry(arity_or_fn=None, ignore_kwargs=False, evaluator=None, *args, **kw): """ Creates a function that accepts one or more arguments of a function and either invokes func returning its result if at least arity number of arguments have been provided, or returns a function that accepts the remaini...
python
def curry(arity_or_fn=None, ignore_kwargs=False, evaluator=None, *args, **kw): """ Creates a function that accepts one or more arguments of a function and either invokes func returning its result if at least arity number of arguments have been provided, or returns a function that accepts the remaini...
[ "def", "curry", "(", "arity_or_fn", "=", "None", ",", "ignore_kwargs", "=", "False", ",", "evaluator", "=", "None", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "def", "isvalidarg", "(", "x", ")", ":", "return", "all", "(", "[", "x", ".", "ki...
Creates a function that accepts one or more arguments of a function and either invokes func returning its result if at least arity number of arguments have been provided, or returns a function that accepts the remaining function arguments until the function arity is satisfied. This function is overload...
[ "Creates", "a", "function", "that", "accepts", "one", "or", "more", "arguments", "of", "a", "function", "and", "either", "invokes", "func", "returning", "its", "result", "if", "at", "least", "arity", "number", "of", "arguments", "have", "been", "provided", "...
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/curry.py#L8-L143
46,053
h2non/paco
paco/compose.py
compose
def compose(*coros): """ Creates a coroutine function based on the composition of the passed coroutine functions. Each function consumes the yielded result of the coroutine that follows. Composing coroutine functions f(), g(), and h() would produce the result of f(g(h())). Arguments: ...
python
def compose(*coros): """ Creates a coroutine function based on the composition of the passed coroutine functions. Each function consumes the yielded result of the coroutine that follows. Composing coroutine functions f(), g(), and h() would produce the result of f(g(h())). Arguments: ...
[ "def", "compose", "(", "*", "coros", ")", ":", "# Make list to inherit built-in type methods", "coros", "=", "list", "(", "coros", ")", "@", "asyncio", ".", "coroutine", "def", "reducer", "(", "acc", ",", "coro", ")", ":", "return", "(", "yield", "from", "...
Creates a coroutine function based on the composition of the passed coroutine functions. Each function consumes the yielded result of the coroutine that follows. Composing coroutine functions f(), g(), and h() would produce the result of f(g(h())). Arguments: *coros (coroutinefunction): v...
[ "Creates", "a", "coroutine", "function", "based", "on", "the", "composition", "of", "the", "passed", "coroutine", "functions", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/compose.py#L6-L50
46,054
kalbhor/MusicNow
musicnow/command_line.py
add_config
def add_config(): """ Prompts user for API keys, adds them in an .ini file stored in the same location as that of the script """ genius_key = input('Enter Genius key : ') bing_key = input('Enter Bing key : ') CONFIG['keys']['bing_key'] = bing_key CONFIG['keys']['genius_key'] = genius_k...
python
def add_config(): """ Prompts user for API keys, adds them in an .ini file stored in the same location as that of the script """ genius_key = input('Enter Genius key : ') bing_key = input('Enter Bing key : ') CONFIG['keys']['bing_key'] = bing_key CONFIG['keys']['genius_key'] = genius_k...
[ "def", "add_config", "(", ")", ":", "genius_key", "=", "input", "(", "'Enter Genius key : '", ")", "bing_key", "=", "input", "(", "'Enter Bing key : '", ")", "CONFIG", "[", "'keys'", "]", "[", "'bing_key'", "]", "=", "bing_key", "CONFIG", "[", "'keys'", "]",...
Prompts user for API keys, adds them in an .ini file stored in the same location as that of the script
[ "Prompts", "user", "for", "API", "keys", "adds", "them", "in", "an", ".", "ini", "file", "stored", "in", "the", "same", "location", "as", "that", "of", "the", "script" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/command_line.py#L66-L79
46,055
kalbhor/MusicNow
musicnow/command_line.py
get_tracks_from_album
def get_tracks_from_album(album_name): ''' Gets tracks from an album using Spotify's API ''' spotify = spotipy.Spotify() album = spotify.search(q='album:' + album_name, limit=1) album_id = album['tracks']['items'][0]['album']['id'] results = spotify.album_tracks(album_id=str(album_id)) ...
python
def get_tracks_from_album(album_name): ''' Gets tracks from an album using Spotify's API ''' spotify = spotipy.Spotify() album = spotify.search(q='album:' + album_name, limit=1) album_id = album['tracks']['items'][0]['album']['id'] results = spotify.album_tracks(album_id=str(album_id)) ...
[ "def", "get_tracks_from_album", "(", "album_name", ")", ":", "spotify", "=", "spotipy", ".", "Spotify", "(", ")", "album", "=", "spotify", ".", "search", "(", "q", "=", "'album:'", "+", "album_name", ",", "limit", "=", "1", ")", "album_id", "=", "album",...
Gets tracks from an album using Spotify's API
[ "Gets", "tracks", "from", "an", "album", "using", "Spotify", "s", "API" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/command_line.py#L82-L96
46,056
kalbhor/MusicNow
musicnow/command_line.py
get_url
def get_url(song_input, auto): ''' Provides user with a list of songs to choose from returns the url of chosen song. ''' youtube_list = OrderedDict() num = 0 # List of songs index html = requests.get("https://www.youtube.com/results", params={'search_query': song_in...
python
def get_url(song_input, auto): ''' Provides user with a list of songs to choose from returns the url of chosen song. ''' youtube_list = OrderedDict() num = 0 # List of songs index html = requests.get("https://www.youtube.com/results", params={'search_query': song_in...
[ "def", "get_url", "(", "song_input", ",", "auto", ")", ":", "youtube_list", "=", "OrderedDict", "(", ")", "num", "=", "0", "# List of songs index", "html", "=", "requests", ".", "get", "(", "\"https://www.youtube.com/results\"", ",", "params", "=", "{", "'sear...
Provides user with a list of songs to choose from returns the url of chosen song.
[ "Provides", "user", "with", "a", "list", "of", "songs", "to", "choose", "from", "returns", "the", "url", "of", "chosen", "song", "." ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/command_line.py#L99-L135
46,057
kalbhor/MusicNow
musicnow/command_line.py
prompt
def prompt(youtube_list): ''' Prompts for song number from list of songs ''' option = int(input('\nEnter song number > ')) try: song_url = list(youtube_list.values())[option - 1] song_title = list(youtube_list.keys())[option - 1] except IndexError: log.log_error('Invalid...
python
def prompt(youtube_list): ''' Prompts for song number from list of songs ''' option = int(input('\nEnter song number > ')) try: song_url = list(youtube_list.values())[option - 1] song_title = list(youtube_list.keys())[option - 1] except IndexError: log.log_error('Invalid...
[ "def", "prompt", "(", "youtube_list", ")", ":", "option", "=", "int", "(", "input", "(", "'\\nEnter song number > '", ")", ")", "try", ":", "song_url", "=", "list", "(", "youtube_list", ".", "values", "(", ")", ")", "[", "option", "-", "1", "]", "song_...
Prompts for song number from list of songs
[ "Prompts", "for", "song", "number", "from", "list", "of", "songs" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/command_line.py#L138-L164
46,058
kalbhor/MusicNow
musicnow/command_line.py
main
def main(): ''' Starts here, handles arguments ''' system('clear') # Must be system('cls') for windows setup() parser = argparse.ArgumentParser( description='Download songs with album art and metadata!') parser.add_argument('-c', '--config', action='store_true', ...
python
def main(): ''' Starts here, handles arguments ''' system('clear') # Must be system('cls') for windows setup() parser = argparse.ArgumentParser( description='Download songs with album art and metadata!') parser.add_argument('-c', '--config', action='store_true', ...
[ "def", "main", "(", ")", ":", "system", "(", "'clear'", ")", "# Must be system('cls') for windows", "setup", "(", ")", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Download songs with album art and metadata!'", ")", "parser", ".", "ad...
Starts here, handles arguments
[ "Starts", "here", "handles", "arguments" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/command_line.py#L189-L267
46,059
vpelletier/python-hidraw
hidraw/__init__.py
HIDRaw.getRawReportDescriptor
def getRawReportDescriptor(self): """ Return a binary string containing the raw HID report descriptor. """ descriptor = _hidraw_report_descriptor() size = ctypes.c_uint() self._ioctl(_HIDIOCGRDESCSIZE, size, True) descriptor.size = size self._ioctl(_HIDIOC...
python
def getRawReportDescriptor(self): """ Return a binary string containing the raw HID report descriptor. """ descriptor = _hidraw_report_descriptor() size = ctypes.c_uint() self._ioctl(_HIDIOCGRDESCSIZE, size, True) descriptor.size = size self._ioctl(_HIDIOC...
[ "def", "getRawReportDescriptor", "(", "self", ")", ":", "descriptor", "=", "_hidraw_report_descriptor", "(", ")", "size", "=", "ctypes", ".", "c_uint", "(", ")", "self", ".", "_ioctl", "(", "_HIDIOCGRDESCSIZE", ",", "size", ",", "True", ")", "descriptor", "....
Return a binary string containing the raw HID report descriptor.
[ "Return", "a", "binary", "string", "containing", "the", "raw", "HID", "report", "descriptor", "." ]
af6527160d2c0c0f61d737f383e35fd767ce25be
https://github.com/vpelletier/python-hidraw/blob/af6527160d2c0c0f61d737f383e35fd767ce25be/hidraw/__init__.py#L63-L72
46,060
vpelletier/python-hidraw
hidraw/__init__.py
HIDRaw.getName
def getName(self, length=512): """ Returns device name as an unicode object. """ name = ctypes.create_string_buffer(length) self._ioctl(_HIDIOCGRAWNAME(length), name, True) return name.value.decode('UTF-8')
python
def getName(self, length=512): """ Returns device name as an unicode object. """ name = ctypes.create_string_buffer(length) self._ioctl(_HIDIOCGRAWNAME(length), name, True) return name.value.decode('UTF-8')
[ "def", "getName", "(", "self", ",", "length", "=", "512", ")", ":", "name", "=", "ctypes", ".", "create_string_buffer", "(", "length", ")", "self", ".", "_ioctl", "(", "_HIDIOCGRAWNAME", "(", "length", ")", ",", "name", ",", "True", ")", "return", "nam...
Returns device name as an unicode object.
[ "Returns", "device", "name", "as", "an", "unicode", "object", "." ]
af6527160d2c0c0f61d737f383e35fd767ce25be
https://github.com/vpelletier/python-hidraw/blob/af6527160d2c0c0f61d737f383e35fd767ce25be/hidraw/__init__.py#L88-L94
46,061
vpelletier/python-hidraw
hidraw/__init__.py
HIDRaw.getPhysicalAddress
def getPhysicalAddress(self, length=512): """ Returns device physical address as a string. See hidraw documentation for value signification, as it depends on device's bus type. """ name = ctypes.create_string_buffer(length) self._ioctl(_HIDIOCGRAWPHYS(length), nam...
python
def getPhysicalAddress(self, length=512): """ Returns device physical address as a string. See hidraw documentation for value signification, as it depends on device's bus type. """ name = ctypes.create_string_buffer(length) self._ioctl(_HIDIOCGRAWPHYS(length), nam...
[ "def", "getPhysicalAddress", "(", "self", ",", "length", "=", "512", ")", ":", "name", "=", "ctypes", ".", "create_string_buffer", "(", "length", ")", "self", ".", "_ioctl", "(", "_HIDIOCGRAWPHYS", "(", "length", ")", ",", "name", ",", "True", ")", "retu...
Returns device physical address as a string. See hidraw documentation for value signification, as it depends on device's bus type.
[ "Returns", "device", "physical", "address", "as", "a", "string", ".", "See", "hidraw", "documentation", "for", "value", "signification", "as", "it", "depends", "on", "device", "s", "bus", "type", "." ]
af6527160d2c0c0f61d737f383e35fd767ce25be
https://github.com/vpelletier/python-hidraw/blob/af6527160d2c0c0f61d737f383e35fd767ce25be/hidraw/__init__.py#L96-L104
46,062
vpelletier/python-hidraw
hidraw/__init__.py
HIDRaw.sendFeatureReport
def sendFeatureReport(self, report, report_num=0): """ Send a feature report. """ length = len(report) + 1 buf = bytearray(length) buf[0] = report_num buf[1:] = report self._ioctl( _HIDIOCSFEATURE(length), (ctypes.c_char * length).f...
python
def sendFeatureReport(self, report, report_num=0): """ Send a feature report. """ length = len(report) + 1 buf = bytearray(length) buf[0] = report_num buf[1:] = report self._ioctl( _HIDIOCSFEATURE(length), (ctypes.c_char * length).f...
[ "def", "sendFeatureReport", "(", "self", ",", "report", ",", "report_num", "=", "0", ")", ":", "length", "=", "len", "(", "report", ")", "+", "1", "buf", "=", "bytearray", "(", "length", ")", "buf", "[", "0", "]", "=", "report_num", "buf", "[", "1"...
Send a feature report.
[ "Send", "a", "feature", "report", "." ]
af6527160d2c0c0f61d737f383e35fd767ce25be
https://github.com/vpelletier/python-hidraw/blob/af6527160d2c0c0f61d737f383e35fd767ce25be/hidraw/__init__.py#L106-L118
46,063
h2non/paco
paco/every.py
every
def every(coro, iterable, limit=1, loop=None): """ Returns `True` if every element in a given iterable satisfies the coroutine asynchronous test. If any iteratee coroutine call returns `False`, the process is inmediately stopped, and `False` will be returned. You can increase the concurrency l...
python
def every(coro, iterable, limit=1, loop=None): """ Returns `True` if every element in a given iterable satisfies the coroutine asynchronous test. If any iteratee coroutine call returns `False`, the process is inmediately stopped, and `False` will be returned. You can increase the concurrency l...
[ "def", "every", "(", "coro", ",", "iterable", ",", "limit", "=", "1", ",", "loop", "=", "None", ")", ":", "assert_corofunction", "(", "coro", "=", "coro", ")", "assert_iter", "(", "iterable", "=", "iterable", ")", "# Reduced accumulator value", "passes", "...
Returns `True` if every element in a given iterable satisfies the coroutine asynchronous test. If any iteratee coroutine call returns `False`, the process is inmediately stopped, and `False` will be returned. You can increase the concurrency limit for a fast race condition scenario. This function...
[ "Returns", "True", "if", "every", "element", "in", "a", "given", "iterable", "satisfies", "the", "coroutine", "asynchronous", "test", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/every.py#L11-L84
46,064
h2non/paco
paco/gather.py
gather
def gather(*coros_or_futures, limit=0, loop=None, timeout=None, preserve_order=False, return_exceptions=False): """ Return a future aggregating results from the given coroutine objects with a concurrency execution limit. If all the tasks are done successfully, the returned future’s result is...
python
def gather(*coros_or_futures, limit=0, loop=None, timeout=None, preserve_order=False, return_exceptions=False): """ Return a future aggregating results from the given coroutine objects with a concurrency execution limit. If all the tasks are done successfully, the returned future’s result is...
[ "def", "gather", "(", "*", "coros_or_futures", ",", "limit", "=", "0", ",", "loop", "=", "None", ",", "timeout", "=", "None", ",", "preserve_order", "=", "False", ",", "return_exceptions", "=", "False", ")", ":", "# If no coroutines to schedule, return empty lis...
Return a future aggregating results from the given coroutine objects with a concurrency execution limit. If all the tasks are done successfully, the returned future’s result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If return_exce...
[ "Return", "a", "future", "aggregating", "results", "from", "the", "given", "coroutine", "objects", "with", "a", "concurrency", "execution", "limit", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/gather.py#L8-L90
46,065
h2non/paco
paco/timeout.py
timeout
def timeout(coro, timeout=None, loop=None): """ Wraps a given coroutine function, that when executed, if it takes more than the given timeout in seconds to execute, it will be canceled and raise an `asyncio.TimeoutError`. This function is equivalent to Python standard `asyncio.wait_for()` funct...
python
def timeout(coro, timeout=None, loop=None): """ Wraps a given coroutine function, that when executed, if it takes more than the given timeout in seconds to execute, it will be canceled and raise an `asyncio.TimeoutError`. This function is equivalent to Python standard `asyncio.wait_for()` funct...
[ "def", "timeout", "(", "coro", ",", "timeout", "=", "None", ",", "loop", "=", "None", ")", ":", "@", "asyncio", ".", "coroutine", "def", "_timeout", "(", "coro", ")", ":", "return", "(", "yield", "from", "asyncio", ".", "wait_for", "(", "coro", ",", ...
Wraps a given coroutine function, that when executed, if it takes more than the given timeout in seconds to execute, it will be canceled and raise an `asyncio.TimeoutError`. This function is equivalent to Python standard `asyncio.wait_for()` function. This function can be used as decorator. A...
[ "Wraps", "a", "given", "coroutine", "function", "that", "when", "executed", "if", "it", "takes", "more", "than", "the", "given", "timeout", "in", "seconds", "to", "execute", "it", "will", "be", "canceled", "and", "raise", "an", "asyncio", ".", "TimeoutError"...
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/timeout.py#L7-L42
46,066
h2non/paco
paco/race.py
race
def race(iterable, loop=None, timeout=None, *args, **kw): """ Runs coroutines from a given iterable concurrently without waiting until the previous one has completed. Once any of the tasks completes, the main coroutine is immediately resolved, yielding the first resolved value. All coroutines ...
python
def race(iterable, loop=None, timeout=None, *args, **kw): """ Runs coroutines from a given iterable concurrently without waiting until the previous one has completed. Once any of the tasks completes, the main coroutine is immediately resolved, yielding the first resolved value. All coroutines ...
[ "def", "race", "(", "iterable", ",", "loop", "=", "None", ",", "timeout", "=", "None", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "assert_iter", "(", "iterable", "=", "iterable", ")", "# Store coros and internal state", "coros", "=", "[", "]", "r...
Runs coroutines from a given iterable concurrently without waiting until the previous one has completed. Once any of the tasks completes, the main coroutine is immediately resolved, yielding the first resolved value. All coroutines will be executed in the same loop. This function is a coroutine. ...
[ "Runs", "coroutines", "from", "a", "given", "iterable", "concurrently", "without", "waiting", "until", "the", "previous", "one", "has", "completed", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/race.py#L12-L103
46,067
h2non/paco
paco/pipe.py
overload
def overload(fn): """ Overload a given callable object to be used with ``|`` operator overloading. This is especially used for composing a pipeline of transformation over a single data set. Arguments: fn (function): target function to decorate. Raises: TypeError: if functi...
python
def overload(fn): """ Overload a given callable object to be used with ``|`` operator overloading. This is especially used for composing a pipeline of transformation over a single data set. Arguments: fn (function): target function to decorate. Raises: TypeError: if functi...
[ "def", "overload", "(", "fn", ")", ":", "if", "not", "isfunction", "(", "fn", ")", ":", "raise", "TypeError", "(", "'paco: fn must be a callable object'", ")", "spec", "=", "getargspec", "(", "fn", ")", "args", "=", "spec", ".", "args", "if", "not", "spe...
Overload a given callable object to be used with ``|`` operator overloading. This is especially used for composing a pipeline of transformation over a single data set. Arguments: fn (function): target function to decorate. Raises: TypeError: if function or coroutine function is no...
[ "Overload", "a", "given", "callable", "object", "to", "be", "used", "with", "|", "operator", "overloading", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/pipe.py#L75-L108
46,068
h2non/paco
paco/generator.py
consume
def consume(generator): # pragma: no cover """ Helper function to consume a synchronous or asynchronous generator. Arguments: generator (generator|asyncgenerator): generator to consume. Returns: list """ # If synchronous generator, just consume and return as list if hasatt...
python
def consume(generator): # pragma: no cover """ Helper function to consume a synchronous or asynchronous generator. Arguments: generator (generator|asyncgenerator): generator to consume. Returns: list """ # If synchronous generator, just consume and return as list if hasatt...
[ "def", "consume", "(", "generator", ")", ":", "# pragma: no cover", "# If synchronous generator, just consume and return as list", "if", "hasattr", "(", "generator", ",", "'__next__'", ")", ":", "return", "list", "(", "generator", ")", "if", "not", "PY_35", ":", "ra...
Helper function to consume a synchronous or asynchronous generator. Arguments: generator (generator|asyncgenerator): generator to consume. Returns: list
[ "Helper", "function", "to", "consume", "a", "synchronous", "or", "asynchronous", "generator", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/generator.py#L8-L34
46,069
h2non/paco
paco/assertions.py
isfunc
def isfunc(x): """ Returns `True` if the given value is a function or method object. Arguments: x (mixed): value to check. Returns: bool """ return any([ inspect.isfunction(x) and not asyncio.iscoroutinefunction(x), inspect.ismethod(x) and not asyncio.iscoroutin...
python
def isfunc(x): """ Returns `True` if the given value is a function or method object. Arguments: x (mixed): value to check. Returns: bool """ return any([ inspect.isfunction(x) and not asyncio.iscoroutinefunction(x), inspect.ismethod(x) and not asyncio.iscoroutin...
[ "def", "isfunc", "(", "x", ")", ":", "return", "any", "(", "[", "inspect", ".", "isfunction", "(", "x", ")", "and", "not", "asyncio", ".", "iscoroutinefunction", "(", "x", ")", ",", "inspect", ".", "ismethod", "(", "x", ")", "and", "not", "asyncio", ...
Returns `True` if the given value is a function or method object. Arguments: x (mixed): value to check. Returns: bool
[ "Returns", "True", "if", "the", "given", "value", "is", "a", "function", "or", "method", "object", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/assertions.py#L54-L67
46,070
h2non/paco
paco/assertions.py
assert_corofunction
def assert_corofunction(**kw): """ Asserts if a given values are a coroutine function. Arguments: **kw (mixed): value to check if it is an iterable. Raises: TypeError: if assertion fails. """ for name, value in kw.items(): if not asyncio.iscoroutinefunction(value): ...
python
def assert_corofunction(**kw): """ Asserts if a given values are a coroutine function. Arguments: **kw (mixed): value to check if it is an iterable. Raises: TypeError: if assertion fails. """ for name, value in kw.items(): if not asyncio.iscoroutinefunction(value): ...
[ "def", "assert_corofunction", "(", "*", "*", "kw", ")", ":", "for", "name", ",", "value", "in", "kw", ".", "items", "(", ")", ":", "if", "not", "asyncio", ".", "iscoroutinefunction", "(", "value", ")", ":", "raise", "TypeError", "(", "'paco: {} must be a...
Asserts if a given values are a coroutine function. Arguments: **kw (mixed): value to check if it is an iterable. Raises: TypeError: if assertion fails.
[ "Asserts", "if", "a", "given", "values", "are", "a", "coroutine", "function", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/assertions.py#L83-L96
46,071
h2non/paco
paco/assertions.py
assert_iter
def assert_iter(**kw): """ Asserts if a given values implements a valid iterable interface. Arguments: **kw (mixed): value to check if it is an iterable. Raises: TypeError: if assertion fails. """ for name, value in kw.items(): if not isiter(value): raise Ty...
python
def assert_iter(**kw): """ Asserts if a given values implements a valid iterable interface. Arguments: **kw (mixed): value to check if it is an iterable. Raises: TypeError: if assertion fails. """ for name, value in kw.items(): if not isiter(value): raise Ty...
[ "def", "assert_iter", "(", "*", "*", "kw", ")", ":", "for", "name", ",", "value", "in", "kw", ".", "items", "(", ")", ":", "if", "not", "isiter", "(", "value", ")", ":", "raise", "TypeError", "(", "'paco: {} must be an iterable object'", ".", "format", ...
Asserts if a given values implements a valid iterable interface. Arguments: **kw (mixed): value to check if it is an iterable. Raises: TypeError: if assertion fails.
[ "Asserts", "if", "a", "given", "values", "implements", "a", "valid", "iterable", "interface", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/assertions.py#L99-L112
46,072
h2non/paco
paco/interval.py
interval
def interval(coro, interval=1, times=None, loop=None): """ Schedules the execution of a coroutine function every `x` amount of seconds. The function returns an `asyncio.Task`, which implements also an `asyncio.Future` interface, allowing the user to cancel the execution cycle. This functio...
python
def interval(coro, interval=1, times=None, loop=None): """ Schedules the execution of a coroutine function every `x` amount of seconds. The function returns an `asyncio.Task`, which implements also an `asyncio.Future` interface, allowing the user to cancel the execution cycle. This functio...
[ "def", "interval", "(", "coro", ",", "interval", "=", "1", ",", "times", "=", "None", ",", "loop", "=", "None", ")", ":", "assert_corofunction", "(", "coro", "=", "coro", ")", "# Store maximum allowed number of calls", "times", "=", "int", "(", "times", "o...
Schedules the execution of a coroutine function every `x` amount of seconds. The function returns an `asyncio.Task`, which implements also an `asyncio.Future` interface, allowing the user to cancel the execution cycle. This function can be used as decorator. Arguments: coro (coroutine...
[ "Schedules", "the", "execution", "of", "a", "coroutine", "function", "every", "x", "amount", "of", "seconds", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/interval.py#L13-L74
46,073
rocky/python-spark
spark_parser/spark.py
GenericParser.addRule
def addRule(self, doc, func, _preprocess=True): """Add a grammar rules to _self.rules_, _self.rule2func_, and _self.rule2name_ Comments, lines starting with # and blank lines are stripped from doc. We also allow limited form of * and + when there it is of the RHS has a singl...
python
def addRule(self, doc, func, _preprocess=True): """Add a grammar rules to _self.rules_, _self.rule2func_, and _self.rule2name_ Comments, lines starting with # and blank lines are stripped from doc. We also allow limited form of * and + when there it is of the RHS has a singl...
[ "def", "addRule", "(", "self", ",", "doc", ",", "func", ",", "_preprocess", "=", "True", ")", ":", "fn", "=", "func", "# remove blanks lines and comment lines, e.g. lines starting with \"#\"", "doc", "=", "os", ".", "linesep", ".", "join", "(", "[", "s", "for"...
Add a grammar rules to _self.rules_, _self.rule2func_, and _self.rule2name_ Comments, lines starting with # and blank lines are stripped from doc. We also allow limited form of * and + when there it is of the RHS has a single item, e.g. stmts ::= stmt+
[ "Add", "a", "grammar", "rules", "to", "_self", ".", "rules_", "_self", ".", "rule2func_", "and", "_self", ".", "rule2name_" ]
8899954bcf0e166726841a43e87c23790eb3441f
https://github.com/rocky/python-spark/blob/8899954bcf0e166726841a43e87c23790eb3441f/spark_parser/spark.py#L188-L265
46,074
rocky/python-spark
spark_parser/spark.py
GenericParser.remove_rules
def remove_rules(self, doc): """Remove a grammar rules from _self.rules_, _self.rule2func_, and _self.rule2name_ """ # remove blanks lines and comment lines, e.g. lines starting with "#" doc = os.linesep.join([s for s in doc.splitlines() if s and not re.match("^\s*#", s)]) ...
python
def remove_rules(self, doc): """Remove a grammar rules from _self.rules_, _self.rule2func_, and _self.rule2name_ """ # remove blanks lines and comment lines, e.g. lines starting with "#" doc = os.linesep.join([s for s in doc.splitlines() if s and not re.match("^\s*#", s)]) ...
[ "def", "remove_rules", "(", "self", ",", "doc", ")", ":", "# remove blanks lines and comment lines, e.g. lines starting with \"#\"", "doc", "=", "os", ".", "linesep", ".", "join", "(", "[", "s", "for", "s", "in", "doc", ".", "splitlines", "(", ")", "if", "s", ...
Remove a grammar rules from _self.rules_, _self.rule2func_, and _self.rule2name_
[ "Remove", "a", "grammar", "rules", "from", "_self", ".", "rules_", "_self", ".", "rule2func_", "and", "_self", ".", "rule2name_" ]
8899954bcf0e166726841a43e87c23790eb3441f
https://github.com/rocky/python-spark/blob/8899954bcf0e166726841a43e87c23790eb3441f/spark_parser/spark.py#L267-L303
46,075
rocky/python-spark
spark_parser/spark.py
GenericParser.errorstack
def errorstack(self, tokens, i, full=False): """Show the stacks of completed symbols. We get this by inspecting the current transitions possible and from that extracting the set of states we are in, and from there we look at the set of symbols before the "dot". If full is True, w...
python
def errorstack(self, tokens, i, full=False): """Show the stacks of completed symbols. We get this by inspecting the current transitions possible and from that extracting the set of states we are in, and from there we look at the set of symbols before the "dot". If full is True, w...
[ "def", "errorstack", "(", "self", ",", "tokens", ",", "i", ",", "full", "=", "False", ")", ":", "print", "(", "\"\\n-- Stacks of completed symbols:\"", ")", "states", "=", "[", "s", "for", "s", "in", "self", ".", "edges", ".", "values", "(", ")", "if",...
Show the stacks of completed symbols. We get this by inspecting the current transitions possible and from that extracting the set of states we are in, and from there we look at the set of symbols before the "dot". If full is True, we show the entire rule with the dot placement. ...
[ "Show", "the", "stacks", "of", "completed", "symbols", ".", "We", "get", "this", "by", "inspecting", "the", "current", "transitions", "possible", "and", "from", "that", "extracting", "the", "set", "of", "states", "we", "are", "in", "and", "from", "there", ...
8899954bcf0e166726841a43e87c23790eb3441f
https://github.com/rocky/python-spark/blob/8899954bcf0e166726841a43e87c23790eb3441f/spark_parser/spark.py#L425-L459
46,076
rocky/python-spark
spark_parser/spark.py
GenericParser.parse
def parse(self, tokens, debug=None): """This is the main entry point from outside. Passing in a debug dictionary changes the default debug setting. """ self.tokens = tokens if debug: self.debug = debug sets = [ [(1, 0), (2, 0)] ] self.links...
python
def parse(self, tokens, debug=None): """This is the main entry point from outside. Passing in a debug dictionary changes the default debug setting. """ self.tokens = tokens if debug: self.debug = debug sets = [ [(1, 0), (2, 0)] ] self.links...
[ "def", "parse", "(", "self", ",", "tokens", ",", "debug", "=", "None", ")", ":", "self", ".", "tokens", "=", "tokens", "if", "debug", ":", "self", ".", "debug", "=", "debug", "sets", "=", "[", "[", "(", "1", ",", "0", ")", ",", "(", "2", ",",...
This is the main entry point from outside. Passing in a debug dictionary changes the default debug setting.
[ "This", "is", "the", "main", "entry", "point", "from", "outside", "." ]
8899954bcf0e166726841a43e87c23790eb3441f
https://github.com/rocky/python-spark/blob/8899954bcf0e166726841a43e87c23790eb3441f/spark_parser/spark.py#L461-L509
46,077
rocky/python-spark
spark_parser/spark.py
GenericParser.dump_grammar
def dump_grammar(self, out=sys.stdout): """ Print grammar rules """ for rule in sorted(self.rule2name.items()): out.write("%s\n" % rule2str(rule[0])) return
python
def dump_grammar(self, out=sys.stdout): """ Print grammar rules """ for rule in sorted(self.rule2name.items()): out.write("%s\n" % rule2str(rule[0])) return
[ "def", "dump_grammar", "(", "self", ",", "out", "=", "sys", ".", "stdout", ")", ":", "for", "rule", "in", "sorted", "(", "self", ".", "rule2name", ".", "items", "(", ")", ")", ":", "out", ".", "write", "(", "\"%s\\n\"", "%", "rule2str", "(", "rule"...
Print grammar rules
[ "Print", "grammar", "rules" ]
8899954bcf0e166726841a43e87c23790eb3441f
https://github.com/rocky/python-spark/blob/8899954bcf0e166726841a43e87c23790eb3441f/spark_parser/spark.py#L874-L880
46,078
rocky/python-spark
spark_parser/spark.py
GenericParser.profile_rule
def profile_rule(self, rule): """Bump count of the number of times _rule_ was used""" rule_str = self.reduce_string(rule) if rule_str not in self.profile_info: self.profile_info[rule_str] = 1 else: self.profile_info[rule_str] += 1
python
def profile_rule(self, rule): """Bump count of the number of times _rule_ was used""" rule_str = self.reduce_string(rule) if rule_str not in self.profile_info: self.profile_info[rule_str] = 1 else: self.profile_info[rule_str] += 1
[ "def", "profile_rule", "(", "self", ",", "rule", ")", ":", "rule_str", "=", "self", ".", "reduce_string", "(", "rule", ")", "if", "rule_str", "not", "in", "self", ".", "profile_info", ":", "self", ".", "profile_info", "[", "rule_str", "]", "=", "1", "e...
Bump count of the number of times _rule_ was used
[ "Bump", "count", "of", "the", "number", "of", "times", "_rule_", "was", "used" ]
8899954bcf0e166726841a43e87c23790eb3441f
https://github.com/rocky/python-spark/blob/8899954bcf0e166726841a43e87c23790eb3441f/spark_parser/spark.py#L975-L981
46,079
rocky/python-spark
spark_parser/spark.py
GenericParser.get_profile_info
def get_profile_info(self): """Show the accumulated results of how many times each rule was used""" return sorted(self.profile_info.items(), key=lambda kv: kv[1], reverse=False) return
python
def get_profile_info(self): """Show the accumulated results of how many times each rule was used""" return sorted(self.profile_info.items(), key=lambda kv: kv[1], reverse=False) return
[ "def", "get_profile_info", "(", "self", ")", ":", "return", "sorted", "(", "self", ".", "profile_info", ".", "items", "(", ")", ",", "key", "=", "lambda", "kv", ":", "kv", "[", "1", "]", ",", "reverse", "=", "False", ")", "return" ]
Show the accumulated results of how many times each rule was used
[ "Show", "the", "accumulated", "results", "of", "how", "many", "times", "each", "rule", "was", "used" ]
8899954bcf0e166726841a43e87c23790eb3441f
https://github.com/rocky/python-spark/blob/8899954bcf0e166726841a43e87c23790eb3441f/spark_parser/spark.py#L983-L988
46,080
h2non/paco
paco/partial.py
partial
def partial(coro, *args, **kw): """ Partial function implementation designed for coroutines, allowing variadic input arguments. This function can be used as decorator. arguments: coro (coroutinefunction): coroutine function to wrap. *args (mixed): mixed variadic arguments for parti...
python
def partial(coro, *args, **kw): """ Partial function implementation designed for coroutines, allowing variadic input arguments. This function can be used as decorator. arguments: coro (coroutinefunction): coroutine function to wrap. *args (mixed): mixed variadic arguments for parti...
[ "def", "partial", "(", "coro", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "assert_corofunction", "(", "coro", "=", "coro", ")", "@", "asyncio", ".", "coroutine", "def", "wrapper", "(", "*", "_args", ",", "*", "*", "_kw", ")", ":", "call_args"...
Partial function implementation designed for coroutines, allowing variadic input arguments. This function can be used as decorator. arguments: coro (coroutinefunction): coroutine function to wrap. *args (mixed): mixed variadic arguments for partial application. Raises: TypeErr...
[ "Partial", "function", "implementation", "designed", "for", "coroutines", "allowing", "variadic", "input", "arguments", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/partial.py#L8-L43
46,081
rocky/python-spark
example/expr2/eval.py
eval_expr
def eval_expr(expr_str, show_tokens=False, showast=False, showgrammar=False, compile_mode='exec'): """ evaluate simple expression """ parser_debug = {'rules': False, 'transition': False, 'reduce': showgrammar, 'errorstack': True, 'context': True } ...
python
def eval_expr(expr_str, show_tokens=False, showast=False, showgrammar=False, compile_mode='exec'): """ evaluate simple expression """ parser_debug = {'rules': False, 'transition': False, 'reduce': showgrammar, 'errorstack': True, 'context': True } ...
[ "def", "eval_expr", "(", "expr_str", ",", "show_tokens", "=", "False", ",", "showast", "=", "False", ",", "showgrammar", "=", "False", ",", "compile_mode", "=", "'exec'", ")", ":", "parser_debug", "=", "{", "'rules'", ":", "False", ",", "'transition'", ":"...
evaluate simple expression
[ "evaluate", "simple", "expression" ]
8899954bcf0e166726841a43e87c23790eb3441f
https://github.com/rocky/python-spark/blob/8899954bcf0e166726841a43e87c23790eb3441f/example/expr2/eval.py#L82-L101
46,082
kalbhor/MusicNow
musicnow/repair.py
setup
def setup(): """ Gathers all configs """ global CONFIG, BING_KEY, GENIUS_KEY, config_path, LOG_FILENAME, LOG_LINE_SEPERATOR LOG_FILENAME = 'musicrepair_log.txt' LOG_LINE_SEPERATOR = '........................\n' CONFIG = configparser.ConfigParser() config_path = realpath(__file__).rep...
python
def setup(): """ Gathers all configs """ global CONFIG, BING_KEY, GENIUS_KEY, config_path, LOG_FILENAME, LOG_LINE_SEPERATOR LOG_FILENAME = 'musicrepair_log.txt' LOG_LINE_SEPERATOR = '........................\n' CONFIG = configparser.ConfigParser() config_path = realpath(__file__).rep...
[ "def", "setup", "(", ")", ":", "global", "CONFIG", ",", "BING_KEY", ",", "GENIUS_KEY", ",", "config_path", ",", "LOG_FILENAME", ",", "LOG_LINE_SEPERATOR", "LOG_FILENAME", "=", "'musicrepair_log.txt'", "LOG_LINE_SEPERATOR", "=", "'........................\\n'", "CONFIG",...
Gathers all configs
[ "Gathers", "all", "configs" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/repair.py#L42-L57
46,083
kalbhor/MusicNow
musicnow/repair.py
matching_details
def matching_details(song_name, song_title, artist): ''' Provides a score out of 10 that determines the relevance of the search result ''' match_name = difflib.SequenceMatcher(None, song_name, song_title).ratio() match_title = difflib.SequenceMatcher(None, song_name, artist + song_title).ratio(...
python
def matching_details(song_name, song_title, artist): ''' Provides a score out of 10 that determines the relevance of the search result ''' match_name = difflib.SequenceMatcher(None, song_name, song_title).ratio() match_title = difflib.SequenceMatcher(None, song_name, artist + song_title).ratio(...
[ "def", "matching_details", "(", "song_name", ",", "song_title", ",", "artist", ")", ":", "match_name", "=", "difflib", ".", "SequenceMatcher", "(", "None", ",", "song_name", ",", "song_title", ")", ".", "ratio", "(", ")", "match_title", "=", "difflib", ".", ...
Provides a score out of 10 that determines the relevance of the search result
[ "Provides", "a", "score", "out", "of", "10", "that", "determines", "the", "relevance", "of", "the", "search", "result" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/repair.py#L60-L73
46,084
kalbhor/MusicNow
musicnow/repair.py
get_lyrics_letssingit
def get_lyrics_letssingit(song_name): ''' Scrapes the lyrics of a song since spotify does not provide lyrics takes song title as arguement ''' lyrics = "" url = "http://search.letssingit.com/cgi-exe/am.cgi?a=search&artist_id=&l=archive&s=" + \ quote(song_name.encode('utf-8')) html =...
python
def get_lyrics_letssingit(song_name): ''' Scrapes the lyrics of a song since spotify does not provide lyrics takes song title as arguement ''' lyrics = "" url = "http://search.letssingit.com/cgi-exe/am.cgi?a=search&artist_id=&l=archive&s=" + \ quote(song_name.encode('utf-8')) html =...
[ "def", "get_lyrics_letssingit", "(", "song_name", ")", ":", "lyrics", "=", "\"\"", "url", "=", "\"http://search.letssingit.com/cgi-exe/am.cgi?a=search&artist_id=&l=archive&s=\"", "+", "quote", "(", "song_name", ".", "encode", "(", "'utf-8'", ")", ")", "html", "=", "ur...
Scrapes the lyrics of a song since spotify does not provide lyrics takes song title as arguement
[ "Scrapes", "the", "lyrics", "of", "a", "song", "since", "spotify", "does", "not", "provide", "lyrics", "takes", "song", "title", "as", "arguement" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/repair.py#L76-L104
46,085
kalbhor/MusicNow
musicnow/repair.py
get_details_letssingit
def get_details_letssingit(song_name): ''' Gets the song details if song details not found through spotify ''' song_name = improvename.songname(song_name) url = "http://search.letssingit.com/cgi-exe/am.cgi?a=search&artist_id=&l=archive&s=" + \ quote(song_name.encode('utf-8')) html = ur...
python
def get_details_letssingit(song_name): ''' Gets the song details if song details not found through spotify ''' song_name = improvename.songname(song_name) url = "http://search.letssingit.com/cgi-exe/am.cgi?a=search&artist_id=&l=archive&s=" + \ quote(song_name.encode('utf-8')) html = ur...
[ "def", "get_details_letssingit", "(", "song_name", ")", ":", "song_name", "=", "improvename", ".", "songname", "(", "song_name", ")", "url", "=", "\"http://search.letssingit.com/cgi-exe/am.cgi?a=search&artist_id=&l=archive&s=\"", "+", "quote", "(", "song_name", ".", "enco...
Gets the song details if song details not found through spotify
[ "Gets", "the", "song", "details", "if", "song", "details", "not", "found", "through", "spotify" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/repair.py#L169-L227
46,086
kalbhor/MusicNow
musicnow/repair.py
add_albumart
def add_albumart(albumart, song_title): ''' Adds the album art to the song ''' try: img = urlopen(albumart) # Gets album art from url except Exception: log.log_error("* Could not add album art", indented=True) return None audio = EasyMP3(song_title, ID3=ID3) try: ...
python
def add_albumart(albumart, song_title): ''' Adds the album art to the song ''' try: img = urlopen(albumart) # Gets album art from url except Exception: log.log_error("* Could not add album art", indented=True) return None audio = EasyMP3(song_title, ID3=ID3) try: ...
[ "def", "add_albumart", "(", "albumart", ",", "song_title", ")", ":", "try", ":", "img", "=", "urlopen", "(", "albumart", ")", "# Gets album art from url", "except", "Exception", ":", "log", ".", "log_error", "(", "\"* Could not add album art\"", ",", "indented", ...
Adds the album art to the song
[ "Adds", "the", "album", "art", "to", "the", "song" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/repair.py#L230-L258
46,087
kalbhor/MusicNow
musicnow/repair.py
add_details
def add_details(file_name, title, artist, album, lyrics=""): ''' Adds the details to song ''' tags = EasyMP3(file_name) tags["title"] = title tags["artist"] = artist tags["album"] = album tags.save() tags = ID3(file_name) uslt_output = USLT(encoding=3, lang=u'eng', desc=u'desc'...
python
def add_details(file_name, title, artist, album, lyrics=""): ''' Adds the details to song ''' tags = EasyMP3(file_name) tags["title"] = title tags["artist"] = artist tags["album"] = album tags.save() tags = ID3(file_name) uslt_output = USLT(encoding=3, lang=u'eng', desc=u'desc'...
[ "def", "add_details", "(", "file_name", ",", "title", ",", "artist", ",", "album", ",", "lyrics", "=", "\"\"", ")", ":", "tags", "=", "EasyMP3", "(", "file_name", ")", "tags", "[", "\"title\"", "]", "=", "title", "tags", "[", "\"artist\"", "]", "=", ...
Adds the details to song
[ "Adds", "the", "details", "to", "song" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/repair.py#L261-L281
46,088
h2non/paco
paco/map.py
map
def map(coro, iterable, limit=0, loop=None, timeout=None, return_exceptions=False, *args, **kw): """ Concurrently maps values yielded from an iterable, passing then into an asynchronous coroutine function. Mapped values will be returned as list. Items order will be preserved based on origin...
python
def map(coro, iterable, limit=0, loop=None, timeout=None, return_exceptions=False, *args, **kw): """ Concurrently maps values yielded from an iterable, passing then into an asynchronous coroutine function. Mapped values will be returned as list. Items order will be preserved based on origin...
[ "def", "map", "(", "coro", ",", "iterable", ",", "limit", "=", "0", ",", "loop", "=", "None", ",", "timeout", "=", "None", ",", "return_exceptions", "=", "False", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "# Call each iterable but collecting yield...
Concurrently maps values yielded from an iterable, passing then into an asynchronous coroutine function. Mapped values will be returned as list. Items order will be preserved based on origin iterable order. Concurrency level can be configurable via ``limit`` param. This function is the asynchrono...
[ "Concurrently", "maps", "values", "yielded", "from", "an", "iterable", "passing", "then", "into", "an", "asynchronous", "coroutine", "function", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/map.py#L9-L57
46,089
kalbhor/MusicNow
musicnow/albumsearch.py
img_search_bing
def img_search_bing(album): ''' Bing image search ''' setup() album = album + " Album Art" api_key = "Key" endpoint = "https://api.cognitive.microsoft.com/bing/v5.0/images/search" links_dict = {} headers = {'Ocp-Apim-Subscription-Key': str(BING_KEY)} param = {'q': album, 'count': '1'...
python
def img_search_bing(album): ''' Bing image search ''' setup() album = album + " Album Art" api_key = "Key" endpoint = "https://api.cognitive.microsoft.com/bing/v5.0/images/search" links_dict = {} headers = {'Ocp-Apim-Subscription-Key': str(BING_KEY)} param = {'q': album, 'count': '1'...
[ "def", "img_search_bing", "(", "album", ")", ":", "setup", "(", ")", "album", "=", "album", "+", "\" Album Art\"", "api_key", "=", "\"Key\"", "endpoint", "=", "\"https://api.cognitive.microsoft.com/bing/v5.0/images/search\"", "links_dict", "=", "{", "}", "headers", ...
Bing image search
[ "Bing", "image", "search" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/albumsearch.py#L42-L68
46,090
h2non/paco
paco/decorator.py
decorate
def decorate(fn): """ Generic decorator for coroutines helper functions allowing multiple variadic initialization arguments. This function is intended to be used internally. Arguments: fn (function): target function to decorate. Raises: TypeError: if function or coroutine func...
python
def decorate(fn): """ Generic decorator for coroutines helper functions allowing multiple variadic initialization arguments. This function is intended to be used internally. Arguments: fn (function): target function to decorate. Raises: TypeError: if function or coroutine func...
[ "def", "decorate", "(", "fn", ")", ":", "if", "not", "isfunction", "(", "fn", ")", ":", "raise", "TypeError", "(", "'paco: fn must be a callable object'", ")", "@", "functools", ".", "wraps", "(", "fn", ")", "def", "decorator", "(", "*", "args", ",", "*"...
Generic decorator for coroutines helper functions allowing multiple variadic initialization arguments. This function is intended to be used internally. Arguments: fn (function): target function to decorate. Raises: TypeError: if function or coroutine function is not provided. Ret...
[ "Generic", "decorator", "for", "coroutines", "helper", "functions", "allowing", "multiple", "variadic", "initialization", "arguments", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/decorator.py#L42-L85
46,091
h2non/paco
paco/throttle.py
throttle
def throttle(coro, limit=1, timeframe=1, return_value=None, raise_exception=False): """ Creates a throttled coroutine function that only invokes ``coro`` at most once per every time frame of seconds or milliseconds. Provide options to indicate whether func should be invoked on the lead...
python
def throttle(coro, limit=1, timeframe=1, return_value=None, raise_exception=False): """ Creates a throttled coroutine function that only invokes ``coro`` at most once per every time frame of seconds or milliseconds. Provide options to indicate whether func should be invoked on the lead...
[ "def", "throttle", "(", "coro", ",", "limit", "=", "1", ",", "timeframe", "=", "1", ",", "return_value", "=", "None", ",", "raise_exception", "=", "False", ")", ":", "assert_corofunction", "(", "coro", "=", "coro", ")", "# Store execution limits", "limit", ...
Creates a throttled coroutine function that only invokes ``coro`` at most once per every time frame of seconds or milliseconds. Provide options to indicate whether func should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls to the throttled coroutine return the...
[ "Creates", "a", "throttled", "coroutine", "function", "that", "only", "invokes", "coro", "at", "most", "once", "per", "every", "time", "frame", "of", "seconds", "or", "milliseconds", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/throttle.py#L16-L123
46,092
h2non/paco
paco/whilst.py
whilst
def whilst(coro, coro_test, assert_coro=None, *args, **kw): """ Repeatedly call `coro` coroutine function while `coro_test` returns `True`. This function is the inverse of `paco.until()`. This function is a coroutine. Arguments: coro (coroutinefunction): coroutine function to execute. ...
python
def whilst(coro, coro_test, assert_coro=None, *args, **kw): """ Repeatedly call `coro` coroutine function while `coro_test` returns `True`. This function is the inverse of `paco.until()`. This function is a coroutine. Arguments: coro (coroutinefunction): coroutine function to execute. ...
[ "def", "whilst", "(", "coro", ",", "coro_test", ",", "assert_coro", "=", "None", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "assert_corofunction", "(", "coro", "=", "coro", ",", "coro_test", "=", "coro_test", ")", "# Store yielded values by coroutine",...
Repeatedly call `coro` coroutine function while `coro_test` returns `True`. This function is the inverse of `paco.until()`. This function is a coroutine. Arguments: coro (coroutinefunction): coroutine function to execute. coro_test (coroutinefunction): coroutine function to test. ...
[ "Repeatedly", "call", "coro", "coroutine", "function", "while", "coro_test", "returns", "True", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/whilst.py#L8-L57
46,093
camptocamp/anthem
anthem/lyrics/loaders.py
load_csv
def load_csv(ctx, model, path, header=None, header_exclude=None, **fmtparams): """Load a CSV from a file path. :param ctx: Anthem context :param model: Odoo model name or model klass from env :param path: absolute or relative path to CSV file. If a relative path is given you must provide a valu...
python
def load_csv(ctx, model, path, header=None, header_exclude=None, **fmtparams): """Load a CSV from a file path. :param ctx: Anthem context :param model: Odoo model name or model klass from env :param path: absolute or relative path to CSV file. If a relative path is given you must provide a valu...
[ "def", "load_csv", "(", "ctx", ",", "model", ",", "path", ",", "header", "=", "None", ",", "header_exclude", "=", "None", ",", "*", "*", "fmtparams", ")", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "if", "ctx", ".",...
Load a CSV from a file path. :param ctx: Anthem context :param model: Odoo model name or model klass from env :param path: absolute or relative path to CSV file. If a relative path is given you must provide a value for `ODOO_DATA_PATH` in your environment or set `--odoo-data-path` o...
[ "Load", "a", "CSV", "from", "a", "file", "path", "." ]
6800730764d31a2edced12049f823fefb367e9ad
https://github.com/camptocamp/anthem/blob/6800730764d31a2edced12049f823fefb367e9ad/anthem/lyrics/loaders.py#L13-L49
46,094
camptocamp/anthem
anthem/lyrics/loaders.py
load_csv_stream
def load_csv_stream(ctx, model, data, header=None, header_exclude=None, **fmtparams): """Load a CSV from a stream. :param ctx: current anthem context :param model: model name as string or model klass :param data: csv data to load :param header: csv fieldnames whitelist :para...
python
def load_csv_stream(ctx, model, data, header=None, header_exclude=None, **fmtparams): """Load a CSV from a stream. :param ctx: current anthem context :param model: model name as string or model klass :param data: csv data to load :param header: csv fieldnames whitelist :para...
[ "def", "load_csv_stream", "(", "ctx", ",", "model", ",", "data", ",", "header", "=", "None", ",", "header_exclude", "=", "None", ",", "*", "*", "fmtparams", ")", ":", "_header", ",", "_rows", "=", "read_csv", "(", "data", ",", "*", "*", "fmtparams", ...
Load a CSV from a stream. :param ctx: current anthem context :param model: model name as string or model klass :param data: csv data to load :param header: csv fieldnames whitelist :param header_exclude: csv fieldnames blacklist Usage example:: from pkg_resources import Requirement, res...
[ "Load", "a", "CSV", "from", "a", "stream", "." ]
6800730764d31a2edced12049f823fefb367e9ad
https://github.com/camptocamp/anthem/blob/6800730764d31a2edced12049f823fefb367e9ad/anthem/lyrics/loaders.py#L79-L119
46,095
rocky/python-spark
example/python2/py2_format.py
format_python2_stmts
def format_python2_stmts(python_stmts, show_tokens=False, showast=False, showgrammar=False, compile_mode='exec'): """ formats python2 statements """ parser_debug = {'rules': False, 'transition': False, 'reduce': showgrammar, 'errorstack':...
python
def format_python2_stmts(python_stmts, show_tokens=False, showast=False, showgrammar=False, compile_mode='exec'): """ formats python2 statements """ parser_debug = {'rules': False, 'transition': False, 'reduce': showgrammar, 'errorstack':...
[ "def", "format_python2_stmts", "(", "python_stmts", ",", "show_tokens", "=", "False", ",", "showast", "=", "False", ",", "showgrammar", "=", "False", ",", "compile_mode", "=", "'exec'", ")", ":", "parser_debug", "=", "{", "'rules'", ":", "False", ",", "'tran...
formats python2 statements
[ "formats", "python2", "statements" ]
8899954bcf0e166726841a43e87c23790eb3441f
https://github.com/rocky/python-spark/blob/8899954bcf0e166726841a43e87c23790eb3441f/example/python2/py2_format.py#L686-L707
46,096
kalbhor/MusicNow
musicnow/improvename.py
songname
def songname(song_name): ''' Improves file name by removing crap words ''' try: song_name = splitext(song_name)[0] except IndexError: pass # Words to omit from song title for better results through spotify's API chars_filter = "()[]{}-:_/=+\"\'" words_filter = ('official...
python
def songname(song_name): ''' Improves file name by removing crap words ''' try: song_name = splitext(song_name)[0] except IndexError: pass # Words to omit from song title for better results through spotify's API chars_filter = "()[]{}-:_/=+\"\'" words_filter = ('official...
[ "def", "songname", "(", "song_name", ")", ":", "try", ":", "song_name", "=", "splitext", "(", "song_name", ")", "[", "0", "]", "except", "IndexError", ":", "pass", "# Words to omit from song title for better results through spotify's API", "chars_filter", "=", "\"()[]...
Improves file name by removing crap words
[ "Improves", "file", "name", "by", "removing", "crap", "words" ]
12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291
https://github.com/kalbhor/MusicNow/blob/12ff1ed2ea2bb7dbbfd925d7998b3ea1e20de291/musicnow/improvename.py#L5-L28
46,097
dchaplinsky/aiohttp_swaggerify
aiohttp_swaggerify/__init__.py
document
def document(info=None, input=None, output=None): """ Add extra information about request handler and its params """ def wrapper(func): if info is not None: setattr(func, "_swg_info", info) if input is not None: setattr(func, "_swg_input", input) if output...
python
def document(info=None, input=None, output=None): """ Add extra information about request handler and its params """ def wrapper(func): if info is not None: setattr(func, "_swg_info", info) if input is not None: setattr(func, "_swg_input", input) if output...
[ "def", "document", "(", "info", "=", "None", ",", "input", "=", "None", ",", "output", "=", "None", ")", ":", "def", "wrapper", "(", "func", ")", ":", "if", "info", "is", "not", "None", ":", "setattr", "(", "func", ",", "\"_swg_info\"", ",", "info"...
Add extra information about request handler and its params
[ "Add", "extra", "information", "about", "request", "handler", "and", "its", "params" ]
e2f2d94379b4a3bad0505e7ea09ec14ed7fcdd76
https://github.com/dchaplinsky/aiohttp_swaggerify/blob/e2f2d94379b4a3bad0505e7ea09ec14ed7fcdd76/aiohttp_swaggerify/__init__.py#L170-L183
46,098
h2non/paco
paco/thunk.py
thunk
def thunk(coro): """ A thunk is a subroutine that is created, often automatically, to assist a call to another subroutine. Creates a thunk coroutine which returns coroutine function that accepts no arguments and when invoked it schedules the wrapper coroutine and returns the final result. ...
python
def thunk(coro): """ A thunk is a subroutine that is created, often automatically, to assist a call to another subroutine. Creates a thunk coroutine which returns coroutine function that accepts no arguments and when invoked it schedules the wrapper coroutine and returns the final result. ...
[ "def", "thunk", "(", "coro", ")", ":", "assert_corofunction", "(", "coro", "=", "coro", ")", "@", "asyncio", ".", "coroutine", "def", "wrapper", "(", ")", ":", "return", "(", "yield", "from", "coro", "(", ")", ")", "return", "wrapper" ]
A thunk is a subroutine that is created, often automatically, to assist a call to another subroutine. Creates a thunk coroutine which returns coroutine function that accepts no arguments and when invoked it schedules the wrapper coroutine and returns the final result. See Wikipedia page for more i...
[ "A", "thunk", "is", "a", "subroutine", "that", "is", "created", "often", "automatically", "to", "assist", "a", "call", "to", "another", "subroutine", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/thunk.py#L6-L43
46,099
h2non/paco
paco/reduce.py
reduce
def reduce(coro, iterable, initializer=None, limit=1, right=False, loop=None): """ Apply function of two arguments cumulatively to the items of sequence, from left to right, so as to reduce the sequence to a single value. Reduction will be executed sequentially without concurrency, so passed values...
python
def reduce(coro, iterable, initializer=None, limit=1, right=False, loop=None): """ Apply function of two arguments cumulatively to the items of sequence, from left to right, so as to reduce the sequence to a single value. Reduction will be executed sequentially without concurrency, so passed values...
[ "def", "reduce", "(", "coro", ",", "iterable", ",", "initializer", "=", "None", ",", "limit", "=", "1", ",", "right", "=", "False", ",", "loop", "=", "None", ")", ":", "assert_corofunction", "(", "coro", "=", "coro", ")", "assert_iter", "(", "iterable"...
Apply function of two arguments cumulatively to the items of sequence, from left to right, so as to reduce the sequence to a single value. Reduction will be executed sequentially without concurrency, so passed values would be in order. This function is the asynchronous coroutine equivalent to Python s...
[ "Apply", "function", "of", "two", "arguments", "cumulatively", "to", "the", "items", "of", "sequence", "from", "left", "to", "right", "so", "as", "to", "reduce", "the", "sequence", "to", "a", "single", "value", "." ]
1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d
https://github.com/h2non/paco/blob/1e5ef4df317e7cbbcefdf67d8dee28ce90538f3d/paco/reduce.py#L10-L83