repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream._get_stream_metadata
def _get_stream_metadata(self, use_cached): """Retrieve metadata about this stream from Device Cloud""" if self._cached_data is None or not use_cached: try: self._cached_data = self._conn.get_json("/ws/DataStream/%s" % self._stream_id)["items"][0] except DeviceClo...
python
def _get_stream_metadata(self, use_cached): """Retrieve metadata about this stream from Device Cloud""" if self._cached_data is None or not use_cached: try: self._cached_data = self._conn.get_json("/ws/DataStream/%s" % self._stream_id)["items"][0] except DeviceClo...
[ "def", "_get_stream_metadata", "(", "self", ",", "use_cached", ")", ":", "if", "self", ".", "_cached_data", "is", "None", "or", "not", "use_cached", ":", "try", ":", "self", ".", "_cached_data", "=", "self", ".", "_conn", ".", "get_json", "(", "\"/ws/DataS...
Retrieve metadata about this stream from Device Cloud
[ "Retrieve", "metadata", "about", "this", "stream", "from", "Device", "Cloud" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L640-L649
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.get_data_type
def get_data_type(self, use_cached=True): """Get the data type of this stream if it exists The data type is the type of data stored in this data stream. Valid types include: * INTEGER - data can be represented with a network (= big-endian) 32-bit two's-complement integer. Data with ...
python
def get_data_type(self, use_cached=True): """Get the data type of this stream if it exists The data type is the type of data stored in this data stream. Valid types include: * INTEGER - data can be represented with a network (= big-endian) 32-bit two's-complement integer. Data with ...
[ "def", "get_data_type", "(", "self", ",", "use_cached", "=", "True", ")", ":", "dtype", "=", "self", ".", "_get_stream_metadata", "(", "use_cached", ")", ".", "get", "(", "\"dataType\"", ")", "if", "dtype", "is", "not", "None", ":", "dtype", "=", "dtype"...
Get the data type of this stream if it exists The data type is the type of data stored in this data stream. Valid types include: * INTEGER - data can be represented with a network (= big-endian) 32-bit two's-complement integer. Data with this type maps to a python int. * LONG - data...
[ "Get", "the", "data", "type", "of", "this", "stream", "if", "it", "exists" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L660-L686
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.get_data_ttl
def get_data_ttl(self, use_cached=True): """Retrieve the dataTTL for this stream The dataTtl is the time to live (TTL) in seconds for data points stored in the data stream. A data point expires after the configured amount of time and is automatically deleted. :param bool use_cached: If...
python
def get_data_ttl(self, use_cached=True): """Retrieve the dataTTL for this stream The dataTtl is the time to live (TTL) in seconds for data points stored in the data stream. A data point expires after the configured amount of time and is automatically deleted. :param bool use_cached: If...
[ "def", "get_data_ttl", "(", "self", ",", "use_cached", "=", "True", ")", ":", "data_ttl_text", "=", "self", ".", "_get_stream_metadata", "(", "use_cached", ")", ".", "get", "(", "\"dataTtl\"", ")", "return", "int", "(", "data_ttl_text", ")" ]
Retrieve the dataTTL for this stream The dataTtl is the time to live (TTL) in seconds for data points stored in the data stream. A data point expires after the configured amount of time and is automatically deleted. :param bool use_cached: If False, the function will always request the latest ...
[ "Retrieve", "the", "dataTTL", "for", "this", "stream" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L714-L730
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.get_rollup_ttl
def get_rollup_ttl(self, use_cached=True): """Retrieve the rollupTtl for this stream The rollupTtl is the time to live (TTL) in seconds for the aggregate roll-ups of data points stored in the stream. A roll-up expires after the configured amount of time and is automatically deleted. ...
python
def get_rollup_ttl(self, use_cached=True): """Retrieve the rollupTtl for this stream The rollupTtl is the time to live (TTL) in seconds for the aggregate roll-ups of data points stored in the stream. A roll-up expires after the configured amount of time and is automatically deleted. ...
[ "def", "get_rollup_ttl", "(", "self", ",", "use_cached", "=", "True", ")", ":", "rollup_ttl_text", "=", "self", ".", "_get_stream_metadata", "(", "use_cached", ")", ".", "get", "(", "\"rollupTtl\"", ")", "return", "int", "(", "rollup_ttl_text", ")" ]
Retrieve the rollupTtl for this stream The rollupTtl is the time to live (TTL) in seconds for the aggregate roll-ups of data points stored in the stream. A roll-up expires after the configured amount of time and is automatically deleted. :param bool use_cached: If False, the function w...
[ "Retrieve", "the", "rollupTtl", "for", "this", "stream" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L732-L748
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.get_current_value
def get_current_value(self, use_cached=False): """Return the most recent DataPoint value written to a stream The current value is the last recorded data point for this stream. :param bool use_cached: If False, the function will always request the latest from Device Cloud. If True, ...
python
def get_current_value(self, use_cached=False): """Return the most recent DataPoint value written to a stream The current value is the last recorded data point for this stream. :param bool use_cached: If False, the function will always request the latest from Device Cloud. If True, ...
[ "def", "get_current_value", "(", "self", ",", "use_cached", "=", "False", ")", ":", "current_value", "=", "self", ".", "_get_stream_metadata", "(", "use_cached", ")", ".", "get", "(", "\"currentValue\"", ")", "if", "current_value", ":", "return", "DataPoint", ...
Return the most recent DataPoint value written to a stream The current value is the last recorded data point for this stream. :param bool use_cached: If False, the function will always request the latest from Device Cloud. If True, the device will not make a request if it already has cache...
[ "Return", "the", "most", "recent", "DataPoint", "value", "written", "to", "a", "stream" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L750-L767
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.delete
def delete(self): """Delete this stream from Device Cloud along with its history This call will return None on success and raise an exception in the event of an error performing the deletion. :raises devicecloud.DeviceCloudHttpException: in the case of an unexpected http error ...
python
def delete(self): """Delete this stream from Device Cloud along with its history This call will return None on success and raise an exception in the event of an error performing the deletion. :raises devicecloud.DeviceCloudHttpException: in the case of an unexpected http error ...
[ "def", "delete", "(", "self", ")", ":", "try", ":", "self", ".", "_conn", ".", "delete", "(", "\"/ws/DataStream/{}\"", ".", "format", "(", "self", ".", "get_stream_id", "(", ")", ")", ")", "except", "DeviceCloudHttpException", "as", "http_excpeption", ":", ...
Delete this stream from Device Cloud along with its history This call will return None on success and raise an exception in the event of an error performing the deletion. :raises devicecloud.DeviceCloudHttpException: in the case of an unexpected http error :raises devicecloud.streams.N...
[ "Delete", "this", "stream", "from", "Device", "Cloud", "along", "with", "its", "history" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L769-L785
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.delete_datapoint
def delete_datapoint(self, datapoint): """Delete the provided datapoint from this stream :raises devicecloud.DeviceCloudHttpException: in the case of an unexpected http error """ datapoint = validate_type(datapoint, DataPoint) self._conn.delete("/ws/DataPoint/{stream_id}/{datap...
python
def delete_datapoint(self, datapoint): """Delete the provided datapoint from this stream :raises devicecloud.DeviceCloudHttpException: in the case of an unexpected http error """ datapoint = validate_type(datapoint, DataPoint) self._conn.delete("/ws/DataPoint/{stream_id}/{datap...
[ "def", "delete_datapoint", "(", "self", ",", "datapoint", ")", ":", "datapoint", "=", "validate_type", "(", "datapoint", ",", "DataPoint", ")", "self", ".", "_conn", ".", "delete", "(", "\"/ws/DataPoint/{stream_id}/{datapoint_id}\"", ".", "format", "(", "stream_id...
Delete the provided datapoint from this stream :raises devicecloud.DeviceCloudHttpException: in the case of an unexpected http error
[ "Delete", "the", "provided", "datapoint", "from", "this", "stream" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L787-L797
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.delete_datapoints_in_time_range
def delete_datapoints_in_time_range(self, start_dt=None, end_dt=None): """Delete datapoints from this stream between the provided start and end times If neither a start or end time is specified, all data points in the stream will be deleted. :param start_dt: The datetime after which da...
python
def delete_datapoints_in_time_range(self, start_dt=None, end_dt=None): """Delete datapoints from this stream between the provided start and end times If neither a start or end time is specified, all data points in the stream will be deleted. :param start_dt: The datetime after which da...
[ "def", "delete_datapoints_in_time_range", "(", "self", ",", "start_dt", "=", "None", ",", "end_dt", "=", "None", ")", ":", "start_dt", "=", "to_none_or_dt", "(", "validate_type", "(", "start_dt", ",", "datetime", ".", "datetime", ",", "type", "(", "None", ")...
Delete datapoints from this stream between the provided start and end times If neither a start or end time is specified, all data points in the stream will be deleted. :param start_dt: The datetime after which data points should be deleted or None if all data points from the beginn...
[ "Delete", "datapoints", "from", "this", "stream", "between", "the", "provided", "start", "and", "end", "times" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L799-L824
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.write
def write(self, datapoint): """Write some raw data to a stream using the DataPoint API This method will mutate the datapoint provided to populate it with information available from the stream as it is available (but without making any new HTTP requests). For instance, we will add in in...
python
def write(self, datapoint): """Write some raw data to a stream using the DataPoint API This method will mutate the datapoint provided to populate it with information available from the stream as it is available (but without making any new HTTP requests). For instance, we will add in in...
[ "def", "write", "(", "self", ",", "datapoint", ")", ":", "if", "not", "isinstance", "(", "datapoint", ",", "DataPoint", ")", ":", "raise", "TypeError", "(", "\"First argument must be a DataPoint object\"", ")", "datapoint", ".", "_stream_id", "=", "self", ".", ...
Write some raw data to a stream using the DataPoint API This method will mutate the datapoint provided to populate it with information available from the stream as it is available (but without making any new HTTP requests). For instance, we will add in information about the stream data ...
[ "Write", "some", "raw", "data", "to", "a", "stream", "using", "the", "DataPoint", "API" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L865-L885
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.read
def read(self, start_time=None, end_time=None, use_client_timeline=True, newest_first=True, rollup_interval=None, rollup_method=None, timezone=None, page_size=1000): """Read one or more DataPoints from a stream .. warning:: The data points from Device Cloud is a paged data set. ...
python
def read(self, start_time=None, end_time=None, use_client_timeline=True, newest_first=True, rollup_interval=None, rollup_method=None, timezone=None, page_size=1000): """Read one or more DataPoints from a stream .. warning:: The data points from Device Cloud is a paged data set. ...
[ "def", "read", "(", "self", ",", "start_time", "=", "None", ",", "end_time", "=", "None", ",", "use_client_timeline", "=", "True", ",", "newest_first", "=", "True", ",", "rollup_interval", "=", "None", ",", "rollup_method", "=", "None", ",", "timezone", "=...
Read one or more DataPoints from a stream .. warning:: The data points from Device Cloud is a paged data set. When iterating over the result set there could be delays when we hit the end of a page. If this is undesirable, the caller should collect all results into a data stru...
[ "Read", "one", "or", "more", "DataPoints", "from", "a", "stream" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L887-L1017
digidotcom/python-devicecloud
devicecloud/conditions.py
_quoted
def _quoted(value): """Return a single-quoted and escaped (percent-encoded) version of value This function will also perform transforms of known data types to a representation that will be handled by Device Cloud. For instance, datetime objects will be converted to ISO8601. """ if isinstance(...
python
def _quoted(value): """Return a single-quoted and escaped (percent-encoded) version of value This function will also perform transforms of known data types to a representation that will be handled by Device Cloud. For instance, datetime objects will be converted to ISO8601. """ if isinstance(...
[ "def", "_quoted", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "datetime", ".", "datetime", ")", ":", "value", "=", "isoformat", "(", "to_none_or_dt", "(", "value", ")", ")", "else", ":", "value", "=", "str", "(", "value", ")", "ret...
Return a single-quoted and escaped (percent-encoded) version of value This function will also perform transforms of known data types to a representation that will be handled by Device Cloud. For instance, datetime objects will be converted to ISO8601.
[ "Return", "a", "single", "-", "quoted", "and", "escaped", "(", "percent", "-", "encoded", ")", "version", "of", "value" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/conditions.py#L19-L32
digidotcom/python-devicecloud
devicecloud/conditions.py
Combination.compile
def compile(self): """Compile this expression into a query string""" return "{lhs}{sep}{rhs}".format( lhs=self.lhs.compile(), sep=self.sep, rhs=self.rhs.compile(), )
python
def compile(self): """Compile this expression into a query string""" return "{lhs}{sep}{rhs}".format( lhs=self.lhs.compile(), sep=self.sep, rhs=self.rhs.compile(), )
[ "def", "compile", "(", "self", ")", ":", "return", "\"{lhs}{sep}{rhs}\"", ".", "format", "(", "lhs", "=", "self", ".", "lhs", ".", "compile", "(", ")", ",", "sep", "=", "self", ".", "sep", ",", "rhs", "=", "self", ".", "rhs", ".", "compile", "(", ...
Compile this expression into a query string
[ "Compile", "this", "expression", "into", "a", "query", "string" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/conditions.py#L75-L81
digidotcom/python-devicecloud
devicecloud/conditions.py
Comparison.compile
def compile(self): """Compile this expression into a query string""" return "{attribute}{sep}{value}".format( attribute=self.attribute, sep=self.sep, value=_quoted(self.value) )
python
def compile(self): """Compile this expression into a query string""" return "{attribute}{sep}{value}".format( attribute=self.attribute, sep=self.sep, value=_quoted(self.value) )
[ "def", "compile", "(", "self", ")", ":", "return", "\"{attribute}{sep}{value}\"", ".", "format", "(", "attribute", "=", "self", ".", "attribute", ",", "sep", "=", "self", ".", "sep", ",", "value", "=", "_quoted", "(", "self", ".", "value", ")", ")" ]
Compile this expression into a query string
[ "Compile", "this", "expression", "into", "a", "query", "string" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/conditions.py#L96-L102
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
_read_msg_header
def _read_msg_header(session): """ Perform a read on input socket to consume headers and then return a tuple of message type, message length. :param session: Push Session to read data for. Returns response type (i.e. PUBLISH_MESSAGE) if header was completely read, otherwise None if header was ...
python
def _read_msg_header(session): """ Perform a read on input socket to consume headers and then return a tuple of message type, message length. :param session: Push Session to read data for. Returns response type (i.e. PUBLISH_MESSAGE) if header was completely read, otherwise None if header was ...
[ "def", "_read_msg_header", "(", "session", ")", ":", "try", ":", "data", "=", "session", ".", "socket", ".", "recv", "(", "6", "-", "len", "(", "session", ".", "data", ")", ")", "if", "len", "(", "data", ")", "==", "0", ":", "# No Data on Socket. Lik...
Perform a read on input socket to consume headers and then return a tuple of message type, message length. :param session: Push Session to read data for. Returns response type (i.e. PUBLISH_MESSAGE) if header was completely read, otherwise None if header was not completely read.
[ "Perform", "a", "read", "on", "input", "socket", "to", "consume", "headers", "and", "then", "return", "a", "tuple", "of", "message", "type", "message", "length", "." ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L47-L77
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
_read_msg
def _read_msg(session): """ Perform a read on input socket to consume message and then return the payload and block_id in a tuple. :param session: Push Session to read data for. """ if len(session.data) == session.message_length: # Data Already completely read. Return return Tr...
python
def _read_msg(session): """ Perform a read on input socket to consume message and then return the payload and block_id in a tuple. :param session: Push Session to read data for. """ if len(session.data) == session.message_length: # Data Already completely read. Return return Tr...
[ "def", "_read_msg", "(", "session", ")", ":", "if", "len", "(", "session", ".", "data", ")", "==", "session", ".", "message_length", ":", "# Data Already completely read. Return", "return", "True", "try", ":", "data", "=", "session", ".", "socket", ".", "re...
Perform a read on input socket to consume message and then return the payload and block_id in a tuple. :param session: Push Session to read data for.
[ "Perform", "a", "read", "on", "input", "socket", "to", "consume", "message", "and", "then", "return", "the", "payload", "and", "block_id", "in", "a", "tuple", "." ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L80-L103
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
PushSession.send_connection_request
def send_connection_request(self): """ Sends a ConnectionRequest to the iDigi server using the credentials established with the id of the monitor as defined in the monitor member. """ try: self.log.info("Sending ConnectionRequest for Monitor %s." ...
python
def send_connection_request(self): """ Sends a ConnectionRequest to the iDigi server using the credentials established with the id of the monitor as defined in the monitor member. """ try: self.log.info("Sending ConnectionRequest for Monitor %s." ...
[ "def", "send_connection_request", "(", "self", ")", ":", "try", ":", "self", ".", "log", ".", "info", "(", "\"Sending ConnectionRequest for Monitor %s.\"", "%", "self", ".", "monitor_id", ")", "# Send connection request and perform a receive to ensure", "# request is authen...
Sends a ConnectionRequest to the iDigi server using the credentials established with the id of the monitor as defined in the monitor member.
[ "Sends", "a", "ConnectionRequest", "to", "the", "iDigi", "server", "using", "the", "credentials", "established", "with", "the", "id", "of", "the", "monitor", "as", "defined", "in", "the", "monitor", "member", "." ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L135-L201
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
PushSession.start
def start(self): """Creates a TCP connection to Device Cloud and sends a ConnectionRequest message""" self.log.info("Starting Insecure Session for Monitor %s" % self.monitor_id) if self.socket is not None: raise Exception("Socket already established for %s." % self) try: ...
python
def start(self): """Creates a TCP connection to Device Cloud and sends a ConnectionRequest message""" self.log.info("Starting Insecure Session for Monitor %s" % self.monitor_id) if self.socket is not None: raise Exception("Socket already established for %s." % self) try: ...
[ "def", "start", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Starting Insecure Session for Monitor %s\"", "%", "self", ".", "monitor_id", ")", "if", "self", ".", "socket", "is", "not", "None", ":", "raise", "Exception", "(", "\"Socket alre...
Creates a TCP connection to Device Cloud and sends a ConnectionRequest message
[ "Creates", "a", "TCP", "connection", "to", "Device", "Cloud", "and", "sends", "a", "ConnectionRequest", "message" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L203-L218
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
PushSession.stop
def stop(self): """Stop/Close this session Close the socket associated with this session and puts Session into a state such that it can be re-established later. """ if self.socket is not None: self.socket.close() self.socket = None self.data =...
python
def stop(self): """Stop/Close this session Close the socket associated with this session and puts Session into a state such that it can be re-established later. """ if self.socket is not None: self.socket.close() self.socket = None self.data =...
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "socket", "is", "not", "None", ":", "self", ".", "socket", ".", "close", "(", ")", "self", ".", "socket", "=", "None", "self", ".", "data", "=", "None" ]
Stop/Close this session Close the socket associated with this session and puts Session into a state such that it can be re-established later.
[ "Stop", "/", "Close", "this", "session" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L220-L229
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
SecurePushSession.start
def start(self): """ Creates a SSL connection to the iDigi Server and sends a ConnectionRequest message. """ self.log.info("Starting SSL Session for Monitor %s." % self.monitor_id) if self.socket is not None: raise Exception("Socket alrea...
python
def start(self): """ Creates a SSL connection to the iDigi Server and sends a ConnectionRequest message. """ self.log.info("Starting SSL Session for Monitor %s." % self.monitor_id) if self.socket is not None: raise Exception("Socket alrea...
[ "def", "start", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Starting SSL Session for Monitor %s.\"", "%", "self", ".", "monitor_id", ")", "if", "self", ".", "socket", "is", "not", "None", ":", "raise", "Exception", "(", "\"Socket already ...
Creates a SSL connection to the iDigi Server and sends a ConnectionRequest message.
[ "Creates", "a", "SSL", "connection", "to", "the", "iDigi", "Server", "and", "sends", "a", "ConnectionRequest", "message", "." ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L260-L288
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
CallbackWorkerPool._consume_queue
def _consume_queue(self): """ Continually blocks until data is on the internal queue, then calls the session's registered callback and sends a PublishMessageReceived if callback returned True. """ while True: session, block_id, raw_data = self._queue.get() ...
python
def _consume_queue(self): """ Continually blocks until data is on the internal queue, then calls the session's registered callback and sends a PublishMessageReceived if callback returned True. """ while True: session, block_id, raw_data = self._queue.get() ...
[ "def", "_consume_queue", "(", "self", ")", ":", "while", "True", ":", "session", ",", "block_id", ",", "raw_data", "=", "self", ".", "_queue", ".", "get", "(", ")", "data", "=", "json", ".", "loads", "(", "raw_data", ".", "decode", "(", "'utf-8'", ")...
Continually blocks until data is on the internal queue, then calls the session's registered callback and sends a PublishMessageReceived if callback returned True.
[ "Continually", "blocks", "until", "data", "is", "on", "the", "internal", "queue", "then", "calls", "the", "session", "s", "registered", "callback", "and", "sends", "a", "PublishMessageReceived", "if", "callback", "returned", "True", "." ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L320-L345
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
CallbackWorkerPool.queue_callback
def queue_callback(self, session, block_id, data): """ Queues up a callback event to occur for a session with the given payload data. Will block if the queue is full. :param session: the session with a defined callback function to call. :param block_id: the block_id of the mess...
python
def queue_callback(self, session, block_id, data): """ Queues up a callback event to occur for a session with the given payload data. Will block if the queue is full. :param session: the session with a defined callback function to call. :param block_id: the block_id of the mess...
[ "def", "queue_callback", "(", "self", ",", "session", ",", "block_id", ",", "data", ")", ":", "self", ".", "_queue", ".", "put", "(", "(", "session", ",", "block_id", ",", "data", ")", ")" ]
Queues up a callback event to occur for a session with the given payload data. Will block if the queue is full. :param session: the session with a defined callback function to call. :param block_id: the block_id of the message received. :param data: the data payload of the message rece...
[ "Queues", "up", "a", "callback", "event", "to", "occur", "for", "a", "session", "with", "the", "given", "payload", "data", ".", "Will", "block", "if", "the", "queue", "is", "full", "." ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L347-L356
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
TCPClientManager._restart_session
def _restart_session(self, session): """Restarts and re-establishes session :param session: The session to restart """ # remove old session key, if socket is None, that means the # session was closed by user and there is no need to restart. if session.socket is not None:...
python
def _restart_session(self, session): """Restarts and re-establishes session :param session: The session to restart """ # remove old session key, if socket is None, that means the # session was closed by user and there is no need to restart. if session.socket is not None:...
[ "def", "_restart_session", "(", "self", ",", "session", ")", ":", "# remove old session key, if socket is None, that means the", "# session was closed by user and there is no need to restart.", "if", "session", ".", "socket", "is", "not", "None", ":", "self", ".", "log", "....
Restarts and re-establishes session :param session: The session to restart
[ "Restarts", "and", "re", "-", "establishes", "session" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L403-L416
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
TCPClientManager._writer
def _writer(self): """ Indefinitely checks the writer queue for data to write to socket. """ while not self.closed: try: sock, data = self._write_queue.get(timeout=0.1) self._write_queue.task_done() sock.send(data) ...
python
def _writer(self): """ Indefinitely checks the writer queue for data to write to socket. """ while not self.closed: try: sock, data = self._write_queue.get(timeout=0.1) self._write_queue.task_done() sock.send(data) ...
[ "def", "_writer", "(", "self", ")", ":", "while", "not", "self", ".", "closed", ":", "try", ":", "sock", ",", "data", "=", "self", ".", "_write_queue", ".", "get", "(", "timeout", "=", "0.1", ")", "self", ".", "_write_queue", ".", "task_done", "(", ...
Indefinitely checks the writer queue for data to write to socket.
[ "Indefinitely", "checks", "the", "writer", "queue", "for", "data", "to", "write", "to", "socket", "." ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L418-L432
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
TCPClientManager._clean_dead_sessions
def _clean_dead_sessions(self): """ Traverses sessions to determine if any sockets were removed (indicates a stopped session). In these cases, remove the session. """ for sck in list(self.sessions.keys()): session = self.sessions[sck] if session.so...
python
def _clean_dead_sessions(self): """ Traverses sessions to determine if any sockets were removed (indicates a stopped session). In these cases, remove the session. """ for sck in list(self.sessions.keys()): session = self.sessions[sck] if session.so...
[ "def", "_clean_dead_sessions", "(", "self", ")", ":", "for", "sck", "in", "list", "(", "self", ".", "sessions", ".", "keys", "(", ")", ")", ":", "session", "=", "self", ".", "sessions", "[", "sck", "]", "if", "session", ".", "socket", "is", "None", ...
Traverses sessions to determine if any sockets were removed (indicates a stopped session). In these cases, remove the session.
[ "Traverses", "sessions", "to", "determine", "if", "any", "sockets", "were", "removed", "(", "indicates", "a", "stopped", "session", ")", ".", "In", "these", "cases", "remove", "the", "session", "." ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L434-L443
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
TCPClientManager._select
def _select(self): """ While the client is not marked as closed, performs a socket select on all PushSession sockets. If any data is received, parses and forwards it on to the callback function. If the callback is successful, a PublishMessageReceived message is sent. ""...
python
def _select(self): """ While the client is not marked as closed, performs a socket select on all PushSession sockets. If any data is received, parses and forwards it on to the callback function. If the callback is successful, a PublishMessageReceived message is sent. ""...
[ "def", "_select", "(", "self", ")", ":", "try", ":", "while", "not", "self", ".", "closed", ":", "try", ":", "inputready", "=", "select", ".", "select", "(", "self", ".", "sessions", ".", "keys", "(", ")", ",", "[", "]", ",", "[", "]", ",", "0....
While the client is not marked as closed, performs a socket select on all PushSession sockets. If any data is received, parses and forwards it on to the callback function. If the callback is successful, a PublishMessageReceived message is sent.
[ "While", "the", "client", "is", "not", "marked", "as", "closed", "performs", "a", "socket", "select", "on", "all", "PushSession", "sockets", ".", "If", "any", "data", "is", "received", "parses", "and", "forwards", "it", "on", "to", "the", "callback", "func...
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L445-L528
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
TCPClientManager._init_threads
def _init_threads(self): """Initializes the IO and Writer threads""" if self._io_thread is None: self._io_thread = Thread(target=self._select) self._io_thread.start() if self._writer_thread is None: self._writer_thread = Thread(target=self._writer) ...
python
def _init_threads(self): """Initializes the IO and Writer threads""" if self._io_thread is None: self._io_thread = Thread(target=self._select) self._io_thread.start() if self._writer_thread is None: self._writer_thread = Thread(target=self._writer) ...
[ "def", "_init_threads", "(", "self", ")", ":", "if", "self", ".", "_io_thread", "is", "None", ":", "self", ".", "_io_thread", "=", "Thread", "(", "target", "=", "self", ".", "_select", ")", "self", ".", "_io_thread", ".", "start", "(", ")", "if", "se...
Initializes the IO and Writer threads
[ "Initializes", "the", "IO", "and", "Writer", "threads" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L530-L538
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
TCPClientManager.create_session
def create_session(self, callback, monitor_id): """ Creates and Returns a PushSession instance based on the input monitor and callback. When data is received, callback will be invoked. If neither monitor or monitor_id are specified, throws an Exception. :param callback: Callbac...
python
def create_session(self, callback, monitor_id): """ Creates and Returns a PushSession instance based on the input monitor and callback. When data is received, callback will be invoked. If neither monitor or monitor_id are specified, throws an Exception. :param callback: Callbac...
[ "def", "create_session", "(", "self", ",", "callback", ",", "monitor_id", ")", ":", "self", ".", "log", ".", "info", "(", "\"Creating Session for Monitor %s.\"", "%", "monitor_id", ")", "session", "=", "SecurePushSession", "(", "callback", ",", "monitor_id", ","...
Creates and Returns a PushSession instance based on the input monitor and callback. When data is received, callback will be invoked. If neither monitor or monitor_id are specified, throws an Exception. :param callback: Callback function to call when PublishMessage messages are rece...
[ "Creates", "and", "Returns", "a", "PushSession", "instance", "based", "on", "the", "input", "monitor", "and", "callback", ".", "When", "data", "is", "received", "callback", "will", "be", "invoked", ".", "If", "neither", "monitor", "or", "monitor_id", "are", ...
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L540-L562
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
TCPClientManager.stop
def stop(self): """Stops all session activity. Blocks until io and writer thread dies """ if self._io_thread is not None: self.log.info("Waiting for I/O thread to stop...") self.closed = True self._io_thread.join() if self._writer_thread is n...
python
def stop(self): """Stops all session activity. Blocks until io and writer thread dies """ if self._io_thread is not None: self.log.info("Waiting for I/O thread to stop...") self.closed = True self._io_thread.join() if self._writer_thread is n...
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "_io_thread", "is", "not", "None", ":", "self", ".", "log", ".", "info", "(", "\"Waiting for I/O thread to stop...\"", ")", "self", ".", "closed", "=", "True", "self", ".", "_io_thread", ".", "join...
Stops all session activity. Blocks until io and writer thread dies
[ "Stops", "all", "session", "activity", "." ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L564-L579
timmahrt/ProMo
promo/morph_utils/plot_morphed_data.py
plotF0
def plotF0(fromTuple, toTuple, mergeTupleList, fnFullPath): ''' Plots the original data in a graph above the plot of the dtw'ed data ''' _matplotlibCheck() plt.hold(True) fig, (ax0) = plt.subplots(nrows=1) # Old data plot1 = ax0.plot(fromTuple[0], fromTuple[1], color='red', ...
python
def plotF0(fromTuple, toTuple, mergeTupleList, fnFullPath): ''' Plots the original data in a graph above the plot of the dtw'ed data ''' _matplotlibCheck() plt.hold(True) fig, (ax0) = plt.subplots(nrows=1) # Old data plot1 = ax0.plot(fromTuple[0], fromTuple[1], color='red', ...
[ "def", "plotF0", "(", "fromTuple", ",", "toTuple", ",", "mergeTupleList", ",", "fnFullPath", ")", ":", "_matplotlibCheck", "(", ")", "plt", ".", "hold", "(", "True", ")", "fig", ",", "(", "ax0", ")", "=", "plt", ".", "subplots", "(", "nrows", "=", "1...
Plots the original data in a graph above the plot of the dtw'ed data
[ "Plots", "the", "original", "data", "in", "a", "graph", "above", "the", "plot", "of", "the", "dtw", "ed", "data" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/plot_morphed_data.py#L74-L109
timmahrt/ProMo
promo/f0_morph.py
getPitchForIntervals
def getPitchForIntervals(data, tgFN, tierName): ''' Preps data for use in f0Morph ''' tg = tgio.openTextgrid(tgFN) data = tg.tierDict[tierName].getValuesInIntervals(data) data = [dataList for _, dataList in data] return data
python
def getPitchForIntervals(data, tgFN, tierName): ''' Preps data for use in f0Morph ''' tg = tgio.openTextgrid(tgFN) data = tg.tierDict[tierName].getValuesInIntervals(data) data = [dataList for _, dataList in data] return data
[ "def", "getPitchForIntervals", "(", "data", ",", "tgFN", ",", "tierName", ")", ":", "tg", "=", "tgio", ".", "openTextgrid", "(", "tgFN", ")", "data", "=", "tg", ".", "tierDict", "[", "tierName", "]", ".", "getValuesInIntervals", "(", "data", ")", "data",...
Preps data for use in f0Morph
[ "Preps", "data", "for", "use", "in", "f0Morph" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/f0_morph.py#L35-L43
timmahrt/ProMo
promo/f0_morph.py
f0Morph
def f0Morph(fromWavFN, pitchPath, stepList, outputName, doPlotPitchSteps, fromPitchData, toPitchData, outputMinPitch, outputMaxPitch, praatEXE, keepPitchRange=False, keepAveragePitch=False, sourcePitchDataList=None, minIntervalLength=0.3): ''' Resynthesizes the pi...
python
def f0Morph(fromWavFN, pitchPath, stepList, outputName, doPlotPitchSteps, fromPitchData, toPitchData, outputMinPitch, outputMaxPitch, praatEXE, keepPitchRange=False, keepAveragePitch=False, sourcePitchDataList=None, minIntervalLength=0.3): ''' Resynthesizes the pi...
[ "def", "f0Morph", "(", "fromWavFN", ",", "pitchPath", ",", "stepList", ",", "outputName", ",", "doPlotPitchSteps", ",", "fromPitchData", ",", "toPitchData", ",", "outputMinPitch", ",", "outputMaxPitch", ",", "praatEXE", ",", "keepPitchRange", "=", "False", ",", ...
Resynthesizes the pitch track from a source to a target wav file fromPitchData and toPitchData should be segmented according to the portions that you want to morph. The two lists must have the same number of sublists. Occurs over a three-step process. This function can act as a template for how ...
[ "Resynthesizes", "the", "pitch", "track", "from", "a", "source", "to", "a", "target", "wav", "file" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/f0_morph.py#L46-L156
hermanschaaf/mafan
mafan/pinyin.py
decode
def decode(s): """ Converts text in the numbering format of pinyin ("ni3hao3") to text with the appropriate tone marks ("nǐhǎo"). """ s = s.lower() r = "" t = "" for c in s: if c >= 'a' and c <= 'z': t += c elif c == ':': try: if ...
python
def decode(s): """ Converts text in the numbering format of pinyin ("ni3hao3") to text with the appropriate tone marks ("nǐhǎo"). """ s = s.lower() r = "" t = "" for c in s: if c >= 'a' and c <= 'z': t += c elif c == ':': try: if ...
[ "def", "decode", "(", "s", ")", ":", "s", "=", "s", ".", "lower", "(", ")", "r", "=", "\"\"", "t", "=", "\"\"", "for", "c", "in", "s", ":", "if", "c", ">=", "'a'", "and", "c", "<=", "'z'", ":", "t", "+=", "c", "elif", "c", "==", "':'", ...
Converts text in the numbering format of pinyin ("ni3hao3") to text with the appropriate tone marks ("nǐhǎo").
[ "Converts", "text", "in", "the", "numbering", "format", "of", "pinyin", "(", "ni3hao3", ")", "to", "text", "with", "the", "appropriate", "tone", "marks", "(", "nǐhǎo", ")", "." ]
train
https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/pinyin.py#L14-L57
timmahrt/ProMo
promo/morph_utils/modify_pitch_accent.py
PitchAccent.adjustPeakHeight
def adjustPeakHeight(self, heightAmount): ''' Adjust peak height The foot of the accent is left unchanged and intermediate values are linearly scaled ''' if heightAmount == 0: return pitchList = [f0V for _, f0V in self.pointList] ...
python
def adjustPeakHeight(self, heightAmount): ''' Adjust peak height The foot of the accent is left unchanged and intermediate values are linearly scaled ''' if heightAmount == 0: return pitchList = [f0V for _, f0V in self.pointList] ...
[ "def", "adjustPeakHeight", "(", "self", ",", "heightAmount", ")", ":", "if", "heightAmount", "==", "0", ":", "return", "pitchList", "=", "[", "f0V", "for", "_", ",", "f0V", "in", "self", ".", "pointList", "]", "minV", "=", "min", "(", "pitchList", ")",...
Adjust peak height The foot of the accent is left unchanged and intermediate values are linearly scaled
[ "Adjust", "peak", "height", "The", "foot", "of", "the", "accent", "is", "left", "unchanged", "and", "intermediate", "values", "are", "linearly", "scaled" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/modify_pitch_accent.py#L47-L63
timmahrt/ProMo
promo/morph_utils/modify_pitch_accent.py
PitchAccent.addPlateau
def addPlateau(self, plateauAmount, pitchSampFreq=None): ''' Add a plateau A negative plateauAmount will move the peak backwards. A positive plateauAmount will move the peak forwards. All points on the side of the peak growth will also get moved. i.e. th...
python
def addPlateau(self, plateauAmount, pitchSampFreq=None): ''' Add a plateau A negative plateauAmount will move the peak backwards. A positive plateauAmount will move the peak forwards. All points on the side of the peak growth will also get moved. i.e. th...
[ "def", "addPlateau", "(", "self", ",", "plateauAmount", ",", "pitchSampFreq", "=", "None", ")", ":", "if", "plateauAmount", "==", "0", ":", "return", "maxPoint", "=", "self", ".", "pointList", "[", "self", ".", "peakI", "]", "# Define the plateau", "if", "...
Add a plateau A negative plateauAmount will move the peak backwards. A positive plateauAmount will move the peak forwards. All points on the side of the peak growth will also get moved. i.e. the slope of the peak does not change. The accent gets wider instead. ...
[ "Add", "a", "plateau", "A", "negative", "plateauAmount", "will", "move", "the", "peak", "backwards", ".", "A", "positive", "plateauAmount", "will", "move", "the", "peak", "forwards", ".", "All", "points", "on", "the", "side", "of", "the", "peak", "growth", ...
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/modify_pitch_accent.py#L65-L114
timmahrt/ProMo
promo/morph_utils/modify_pitch_accent.py
PitchAccent.shiftAccent
def shiftAccent(self, shiftAmount): ''' Move the whole accent earlier or later ''' if shiftAmount == 0: return self.pointList = [(time + shiftAmount, pitch) for time, pitch in self.pointList] # Update shift amounts ...
python
def shiftAccent(self, shiftAmount): ''' Move the whole accent earlier or later ''' if shiftAmount == 0: return self.pointList = [(time + shiftAmount, pitch) for time, pitch in self.pointList] # Update shift amounts ...
[ "def", "shiftAccent", "(", "self", ",", "shiftAmount", ")", ":", "if", "shiftAmount", "==", "0", ":", "return", "self", ".", "pointList", "=", "[", "(", "time", "+", "shiftAmount", ",", "pitch", ")", "for", "time", ",", "pitch", "in", "self", ".", "p...
Move the whole accent earlier or later
[ "Move", "the", "whole", "accent", "earlier", "or", "later" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/modify_pitch_accent.py#L116-L130
timmahrt/ProMo
promo/morph_utils/modify_pitch_accent.py
PitchAccent.deleteOverlapping
def deleteOverlapping(self, targetList): ''' Erase points from another list that overlap with points in this list ''' start = self.pointList[0][0] stop = self.pointList[-1][0] if self.netLeftShift < 0: start += self.netLeftShift i...
python
def deleteOverlapping(self, targetList): ''' Erase points from another list that overlap with points in this list ''' start = self.pointList[0][0] stop = self.pointList[-1][0] if self.netLeftShift < 0: start += self.netLeftShift i...
[ "def", "deleteOverlapping", "(", "self", ",", "targetList", ")", ":", "start", "=", "self", ".", "pointList", "[", "0", "]", "[", "0", "]", "stop", "=", "self", ".", "pointList", "[", "-", "1", "]", "[", "0", "]", "if", "self", ".", "netLeftShift",...
Erase points from another list that overlap with points in this list
[ "Erase", "points", "from", "another", "list", "that", "overlap", "with", "points", "in", "this", "list" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/modify_pitch_accent.py#L132-L147
timmahrt/ProMo
promo/morph_utils/modify_pitch_accent.py
PitchAccent.reintegrate
def reintegrate(self, fullPointList): ''' Integrates the pitch values of the accent into a larger pitch contour ''' # Erase the original region of the accent fullPointList = _deletePoints(fullPointList, self.minT, self.maxT) # Erase the new region of the accent ...
python
def reintegrate(self, fullPointList): ''' Integrates the pitch values of the accent into a larger pitch contour ''' # Erase the original region of the accent fullPointList = _deletePoints(fullPointList, self.minT, self.maxT) # Erase the new region of the accent ...
[ "def", "reintegrate", "(", "self", ",", "fullPointList", ")", ":", "# Erase the original region of the accent", "fullPointList", "=", "_deletePoints", "(", "fullPointList", ",", "self", ".", "minT", ",", "self", ".", "maxT", ")", "# Erase the new region of the accent", ...
Integrates the pitch values of the accent into a larger pitch contour
[ "Integrates", "the", "pitch", "values", "of", "the", "accent", "into", "a", "larger", "pitch", "contour" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/modify_pitch_accent.py#L149-L163
hermanschaaf/mafan
mafan/encoding.py
convert
def convert(filename, new_filename=None, overwrite=False, to_encoding='utf-8', force=True): """ Convert file with crappy encoding to a new proper encoding (or vice versa if you wish). filename -- the name, partial path or full path of the file you want to encode to a new encoding new_filename -- (optional)...
python
def convert(filename, new_filename=None, overwrite=False, to_encoding='utf-8', force=True): """ Convert file with crappy encoding to a new proper encoding (or vice versa if you wish). filename -- the name, partial path or full path of the file you want to encode to a new encoding new_filename -- (optional)...
[ "def", "convert", "(", "filename", ",", "new_filename", "=", "None", ",", "overwrite", "=", "False", ",", "to_encoding", "=", "'utf-8'", ",", "force", "=", "True", ")", ":", "logging", ".", "info", "(", "'Opening file %s'", "%", "filename", ")", "f", "="...
Convert file with crappy encoding to a new proper encoding (or vice versa if you wish). filename -- the name, partial path or full path of the file you want to encode to a new encoding new_filename -- (optional) the name of the new file to be generated using the new encoding overwrite -- if `new_filename` ...
[ "Convert", "file", "with", "crappy", "encoding", "to", "a", "new", "proper", "encoding", "(", "or", "vice", "versa", "if", "you", "wish", ")", "." ]
train
https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/encoding.py#L17-L64
hermanschaaf/mafan
mafan/encoding.py
detect
def detect(filename, include_confidence=False): """ Detect the encoding of a file. Returns only the predicted current encoding as a string. If `include_confidence` is True, Returns tuple containing: (str encoding, float confidence) """ f = open(filename) detection = chardet.detect(f.r...
python
def detect(filename, include_confidence=False): """ Detect the encoding of a file. Returns only the predicted current encoding as a string. If `include_confidence` is True, Returns tuple containing: (str encoding, float confidence) """ f = open(filename) detection = chardet.detect(f.r...
[ "def", "detect", "(", "filename", ",", "include_confidence", "=", "False", ")", ":", "f", "=", "open", "(", "filename", ")", "detection", "=", "chardet", ".", "detect", "(", "f", ".", "read", "(", ")", ")", "f", ".", "close", "(", ")", "encoding", ...
Detect the encoding of a file. Returns only the predicted current encoding as a string. If `include_confidence` is True, Returns tuple containing: (str encoding, float confidence)
[ "Detect", "the", "encoding", "of", "a", "file", "." ]
train
https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/encoding.py#L67-L83
hermanschaaf/mafan
mafan/download_data.py
download
def download(url, localFileName=None, localDirName=None): """ Utility function for downloading files from the web and retaining the same filename. """ localName = url2name(url) req = Request(url) r = urlopen(req) if r.info().has_key('Content-Disposition'): # If the response has ...
python
def download(url, localFileName=None, localDirName=None): """ Utility function for downloading files from the web and retaining the same filename. """ localName = url2name(url) req = Request(url) r = urlopen(req) if r.info().has_key('Content-Disposition'): # If the response has ...
[ "def", "download", "(", "url", ",", "localFileName", "=", "None", ",", "localDirName", "=", "None", ")", ":", "localName", "=", "url2name", "(", "url", ")", "req", "=", "Request", "(", "url", ")", "r", "=", "urlopen", "(", "req", ")", "if", "r", "....
Utility function for downloading files from the web and retaining the same filename.
[ "Utility", "function", "for", "downloading", "files", "from", "the", "web", "and", "retaining", "the", "same", "filename", "." ]
train
https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/download_data.py#L22-L53
hermanschaaf/mafan
mafan/third_party/jianfan/__init__.py
_t
def _t(unistr, charset_from, charset_to): """ This is a unexposed function, is responsibility for translation internal. """ # if type(unistr) is str: # try: # unistr = unistr.decode('utf-8') # # Python 3 returns AttributeError when .decode() is called on a str # #...
python
def _t(unistr, charset_from, charset_to): """ This is a unexposed function, is responsibility for translation internal. """ # if type(unistr) is str: # try: # unistr = unistr.decode('utf-8') # # Python 3 returns AttributeError when .decode() is called on a str # #...
[ "def", "_t", "(", "unistr", ",", "charset_from", ",", "charset_to", ")", ":", "# if type(unistr) is str:", "# try:", "# unistr = unistr.decode('utf-8')", "# # Python 3 returns AttributeError when .decode() is called on a str", "# # This means it is already unicode.", ...
This is a unexposed function, is responsibility for translation internal.
[ "This", "is", "a", "unexposed", "function", "is", "responsibility", "for", "translation", "internal", "." ]
train
https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/third_party/jianfan/__init__.py#L23-L45
hermanschaaf/mafan
mafan/hanzidentifier/hanzidentifier.py
identify
def identify(text): """Identify whether a string is simplified or traditional Chinese. Returns: None: if there are no recognizd Chinese characters. EITHER: if the test is inconclusive. TRAD: if the text is traditional. SIMP: if the text is simplified. BOTH: the text has ...
python
def identify(text): """Identify whether a string is simplified or traditional Chinese. Returns: None: if there are no recognizd Chinese characters. EITHER: if the test is inconclusive. TRAD: if the text is traditional. SIMP: if the text is simplified. BOTH: the text has ...
[ "def", "identify", "(", "text", ")", ":", "filtered_text", "=", "set", "(", "list", "(", "text", ")", ")", ".", "intersection", "(", "ALL_CHARS", ")", "if", "len", "(", "filtered_text", ")", "is", "0", ":", "return", "None", "if", "filtered_text", ".",...
Identify whether a string is simplified or traditional Chinese. Returns: None: if there are no recognizd Chinese characters. EITHER: if the test is inconclusive. TRAD: if the text is traditional. SIMP: if the text is simplified. BOTH: the text has characters recognized as be...
[ "Identify", "whether", "a", "string", "is", "simplified", "or", "traditional", "Chinese", "." ]
train
https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/hanzidentifier/hanzidentifier.py#L38-L60
timmahrt/ProMo
promo/morph_utils/morph_sequence.py
makeSequenceRelative
def makeSequenceRelative(absVSequence): ''' Puts every value in a list on a continuum between 0 and 1 Also returns the min and max values (to reverse the process) ''' if len(absVSequence) < 2 or len(set(absVSequence)) == 1: raise RelativizeSequenceException(absVSequence) minV = min(ab...
python
def makeSequenceRelative(absVSequence): ''' Puts every value in a list on a continuum between 0 and 1 Also returns the min and max values (to reverse the process) ''' if len(absVSequence) < 2 or len(set(absVSequence)) == 1: raise RelativizeSequenceException(absVSequence) minV = min(ab...
[ "def", "makeSequenceRelative", "(", "absVSequence", ")", ":", "if", "len", "(", "absVSequence", ")", "<", "2", "or", "len", "(", "set", "(", "absVSequence", ")", ")", "==", "1", ":", "raise", "RelativizeSequenceException", "(", "absVSequence", ")", "minV", ...
Puts every value in a list on a continuum between 0 and 1 Also returns the min and max values (to reverse the process)
[ "Puts", "every", "value", "in", "a", "list", "on", "a", "continuum", "between", "0", "and", "1" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L33-L47
timmahrt/ProMo
promo/morph_utils/morph_sequence.py
makeSequenceAbsolute
def makeSequenceAbsolute(relVSequence, minV, maxV): ''' Makes every value in a sequence absolute ''' return [(value * (maxV - minV)) + minV for value in relVSequence]
python
def makeSequenceAbsolute(relVSequence, minV, maxV): ''' Makes every value in a sequence absolute ''' return [(value * (maxV - minV)) + minV for value in relVSequence]
[ "def", "makeSequenceAbsolute", "(", "relVSequence", ",", "minV", ",", "maxV", ")", ":", "return", "[", "(", "value", "*", "(", "maxV", "-", "minV", ")", ")", "+", "minV", "for", "value", "in", "relVSequence", "]" ]
Makes every value in a sequence absolute
[ "Makes", "every", "value", "in", "a", "sequence", "absolute" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L50-L55
timmahrt/ProMo
promo/morph_utils/morph_sequence.py
_makeTimingRelative
def _makeTimingRelative(absoluteDataList): ''' Given normal pitch tier data, puts the times on a scale from 0 to 1 Input is a list of tuples of the form ([(time1, pitch1), (time2, pitch2),...] Also returns the start and end time so that the process can be reversed ''' timingSeq = [row[0] ...
python
def _makeTimingRelative(absoluteDataList): ''' Given normal pitch tier data, puts the times on a scale from 0 to 1 Input is a list of tuples of the form ([(time1, pitch1), (time2, pitch2),...] Also returns the start and end time so that the process can be reversed ''' timingSeq = [row[0] ...
[ "def", "_makeTimingRelative", "(", "absoluteDataList", ")", ":", "timingSeq", "=", "[", "row", "[", "0", "]", "for", "row", "in", "absoluteDataList", "]", "valueSeq", "=", "[", "list", "(", "row", "[", "1", ":", "]", ")", "for", "row", "in", "absoluteD...
Given normal pitch tier data, puts the times on a scale from 0 to 1 Input is a list of tuples of the form ([(time1, pitch1), (time2, pitch2),...] Also returns the start and end time so that the process can be reversed
[ "Given", "normal", "pitch", "tier", "data", "puts", "the", "times", "on", "a", "scale", "from", "0", "to", "1" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L58-L76
timmahrt/ProMo
promo/morph_utils/morph_sequence.py
_makeTimingAbsolute
def _makeTimingAbsolute(relativeDataList, startTime, endTime): ''' Maps values from 0 to 1 to the provided start and end time Input is a list of tuples of the form ([(time1, pitch1), (time2, pitch2),...] ''' timingSeq = [row[0] for row in relativeDataList] valueSeq = [list(row[1:]) for row...
python
def _makeTimingAbsolute(relativeDataList, startTime, endTime): ''' Maps values from 0 to 1 to the provided start and end time Input is a list of tuples of the form ([(time1, pitch1), (time2, pitch2),...] ''' timingSeq = [row[0] for row in relativeDataList] valueSeq = [list(row[1:]) for row...
[ "def", "_makeTimingAbsolute", "(", "relativeDataList", ",", "startTime", ",", "endTime", ")", ":", "timingSeq", "=", "[", "row", "[", "0", "]", "for", "row", "in", "relativeDataList", "]", "valueSeq", "=", "[", "list", "(", "row", "[", "1", ":", "]", "...
Maps values from 0 to 1 to the provided start and end time Input is a list of tuples of the form ([(time1, pitch1), (time2, pitch2),...]
[ "Maps", "values", "from", "0", "to", "1", "to", "the", "provided", "start", "and", "end", "time" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L79-L95
timmahrt/ProMo
promo/morph_utils/morph_sequence.py
_getSmallestDifference
def _getSmallestDifference(inputList, targetVal): ''' Returns the value in inputList that is closest to targetVal Iteratively splits the dataset in two, so it should be pretty fast ''' targetList = inputList[:] retVal = None while True: # If we're down to one value, stop iterati...
python
def _getSmallestDifference(inputList, targetVal): ''' Returns the value in inputList that is closest to targetVal Iteratively splits the dataset in two, so it should be pretty fast ''' targetList = inputList[:] retVal = None while True: # If we're down to one value, stop iterati...
[ "def", "_getSmallestDifference", "(", "inputList", ",", "targetVal", ")", ":", "targetList", "=", "inputList", "[", ":", "]", "retVal", "=", "None", "while", "True", ":", "# If we're down to one value, stop iterating", "if", "len", "(", "targetList", ")", "==", ...
Returns the value in inputList that is closest to targetVal Iteratively splits the dataset in two, so it should be pretty fast
[ "Returns", "the", "value", "in", "inputList", "that", "is", "closest", "to", "targetVal", "Iteratively", "splits", "the", "dataset", "in", "two", "so", "it", "should", "be", "pretty", "fast" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L98-L130
timmahrt/ProMo
promo/morph_utils/morph_sequence.py
_getNearestMappingIndexList
def _getNearestMappingIndexList(fromValList, toValList): ''' Finds the indicies for data points that are closest to each other. The inputs should be in relative time, scaled from 0 to 1 e.g. if you have [0, .1, .5., .9] and [0, .1, .2, 1] will output [0, 1, 1, 2] ''' indexList = [] for...
python
def _getNearestMappingIndexList(fromValList, toValList): ''' Finds the indicies for data points that are closest to each other. The inputs should be in relative time, scaled from 0 to 1 e.g. if you have [0, .1, .5., .9] and [0, .1, .2, 1] will output [0, 1, 1, 2] ''' indexList = [] for...
[ "def", "_getNearestMappingIndexList", "(", "fromValList", ",", "toValList", ")", ":", "indexList", "=", "[", "]", "for", "fromTimestamp", "in", "fromValList", ":", "smallestDiff", "=", "_getSmallestDifference", "(", "toValList", ",", "fromTimestamp", ")", "i", "="...
Finds the indicies for data points that are closest to each other. The inputs should be in relative time, scaled from 0 to 1 e.g. if you have [0, .1, .5., .9] and [0, .1, .2, 1] will output [0, 1, 1, 2]
[ "Finds", "the", "indicies", "for", "data", "points", "that", "are", "closest", "to", "each", "other", "." ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L133-L148
timmahrt/ProMo
promo/morph_utils/morph_sequence.py
morphDataLists
def morphDataLists(fromList, toList, stepList): ''' Iteratively morph fromList into toList using the values 0 to 1 in stepList stepList: a value of 0 means no change and a value of 1 means a complete change to the other value ''' # If there are more than 1 pitch value, then we align the da...
python
def morphDataLists(fromList, toList, stepList): ''' Iteratively morph fromList into toList using the values 0 to 1 in stepList stepList: a value of 0 means no change and a value of 1 means a complete change to the other value ''' # If there are more than 1 pitch value, then we align the da...
[ "def", "morphDataLists", "(", "fromList", ",", "toList", ",", "stepList", ")", ":", "# If there are more than 1 pitch value, then we align the data in", "# relative time.", "# Each data point comes with a timestamp. The earliest timestamp is 0", "# and the latest timestamp is 1. Using th...
Iteratively morph fromList into toList using the values 0 to 1 in stepList stepList: a value of 0 means no change and a value of 1 means a complete change to the other value
[ "Iteratively", "morph", "fromList", "into", "toList", "using", "the", "values", "0", "to", "1", "in", "stepList", "stepList", ":", "a", "value", "of", "0", "means", "no", "change", "and", "a", "value", "of", "1", "means", "a", "complete", "change", "to",...
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L151-L194
timmahrt/ProMo
promo/morph_utils/morph_sequence.py
morphChunkedDataLists
def morphChunkedDataLists(fromDataList, toDataList, stepList): ''' Morph one set of data into another, in a stepwise fashion A convenience function. Given a set of paired data lists, this will morph each one individually. Returns a single list with all data combined together. ''' assert(...
python
def morphChunkedDataLists(fromDataList, toDataList, stepList): ''' Morph one set of data into another, in a stepwise fashion A convenience function. Given a set of paired data lists, this will morph each one individually. Returns a single list with all data combined together. ''' assert(...
[ "def", "morphChunkedDataLists", "(", "fromDataList", ",", "toDataList", ",", "stepList", ")", ":", "assert", "(", "len", "(", "fromDataList", ")", "==", "len", "(", "toDataList", ")", ")", "# Morph the fromDataList into the toDataList", "outputList", "=", "[", "]"...
Morph one set of data into another, in a stepwise fashion A convenience function. Given a set of paired data lists, this will morph each one individually. Returns a single list with all data combined together.
[ "Morph", "one", "set", "of", "data", "into", "another", "in", "a", "stepwise", "fashion" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L197-L228
timmahrt/ProMo
promo/morph_utils/morph_sequence.py
morphAveragePitch
def morphAveragePitch(fromDataList, toDataList): ''' Adjusts the values in fromPitchList to have the same average as toPitchList Because other manipulations can alter the average pitch, morphing the pitch is the last pitch manipulation that should be done After the morphing, the code remov...
python
def morphAveragePitch(fromDataList, toDataList): ''' Adjusts the values in fromPitchList to have the same average as toPitchList Because other manipulations can alter the average pitch, morphing the pitch is the last pitch manipulation that should be done After the morphing, the code remov...
[ "def", "morphAveragePitch", "(", "fromDataList", ",", "toDataList", ")", ":", "timeList", ",", "fromPitchList", "=", "zip", "(", "*", "fromDataList", ")", "toPitchList", "=", "[", "pitchVal", "for", "_", ",", "pitchVal", "in", "toDataList", "]", "# Zero pitch ...
Adjusts the values in fromPitchList to have the same average as toPitchList Because other manipulations can alter the average pitch, morphing the pitch is the last pitch manipulation that should be done After the morphing, the code removes any values below zero, thus the final average might no...
[ "Adjusts", "the", "values", "in", "fromPitchList", "to", "have", "the", "same", "average", "as", "toPitchList", "Because", "other", "manipulations", "can", "alter", "the", "average", "pitch", "morphing", "the", "pitch", "is", "the", "last", "pitch", "manipulatio...
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L231-L262
timmahrt/ProMo
promo/morph_utils/morph_sequence.py
morphRange
def morphRange(fromDataList, toDataList): ''' Changes the scale of values in one distribution to that of another ie The maximum value in fromDataList will be set to the maximum value in toDataList. The 75% largest value in fromDataList will be set to the 75% largest value in toDataList, etc. ...
python
def morphRange(fromDataList, toDataList): ''' Changes the scale of values in one distribution to that of another ie The maximum value in fromDataList will be set to the maximum value in toDataList. The 75% largest value in fromDataList will be set to the 75% largest value in toDataList, etc. ...
[ "def", "morphRange", "(", "fromDataList", ",", "toDataList", ")", ":", "# Isolate and sort pitch values", "fromPitchList", "=", "[", "dataTuple", "[", "1", "]", "for", "dataTuple", "in", "fromDataList", "]", "toPitchList", "=", "[", "dataTuple", "[", "1", "]", ...
Changes the scale of values in one distribution to that of another ie The maximum value in fromDataList will be set to the maximum value in toDataList. The 75% largest value in fromDataList will be set to the 75% largest value in toDataList, etc. Small sample sizes will yield results that are...
[ "Changes", "the", "scale", "of", "values", "in", "one", "distribution", "to", "that", "of", "another", "ie", "The", "maximum", "value", "in", "fromDataList", "will", "be", "set", "to", "the", "maximum", "value", "in", "toDataList", ".", "The", "75%", "larg...
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L265-L301
timmahrt/ProMo
promo/morph_utils/interpolation.py
quadraticInterpolation
def quadraticInterpolation(valueList2d, numDegrees, n, startTime=None, endTime=None): ''' Generates a series of points on a smooth curve that cross the given points numDegrees - the degrees of the fitted polynomial - the curve gets weird if this value is too hi...
python
def quadraticInterpolation(valueList2d, numDegrees, n, startTime=None, endTime=None): ''' Generates a series of points on a smooth curve that cross the given points numDegrees - the degrees of the fitted polynomial - the curve gets weird if this value is too hi...
[ "def", "quadraticInterpolation", "(", "valueList2d", ",", "numDegrees", ",", "n", ",", "startTime", "=", "None", ",", "endTime", "=", "None", ")", ":", "_numpyCheck", "(", ")", "x", ",", "y", "=", "zip", "(", "*", "valueList2d", ")", "if", "startTime", ...
Generates a series of points on a smooth curve that cross the given points numDegrees - the degrees of the fitted polynomial - the curve gets weird if this value is too high for the input n - number of points to output startTime/endTime/n - n points will be generated at evenly spaced ...
[ "Generates", "a", "series", "of", "points", "on", "a", "smooth", "curve", "that", "cross", "the", "given", "points", "numDegrees", "-", "the", "degrees", "of", "the", "fitted", "polynomial", "-", "the", "curve", "gets", "weird", "if", "this", "value", "is"...
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/interpolation.py#L21-L47
timmahrt/ProMo
promo/morph_utils/utils.py
getIntervals
def getIntervals(fn, tierName, filterFunc=None, includeUnlabeledRegions=False): ''' Get information about the 'extract' tier, used by several merge scripts ''' tg = tgio.openTextgrid(fn) tier = tg.tierDict[tierName] if includeUnlabeledRegions is True: tier = tgio._...
python
def getIntervals(fn, tierName, filterFunc=None, includeUnlabeledRegions=False): ''' Get information about the 'extract' tier, used by several merge scripts ''' tg = tgio.openTextgrid(fn) tier = tg.tierDict[tierName] if includeUnlabeledRegions is True: tier = tgio._...
[ "def", "getIntervals", "(", "fn", ",", "tierName", ",", "filterFunc", "=", "None", ",", "includeUnlabeledRegions", "=", "False", ")", ":", "tg", "=", "tgio", ".", "openTextgrid", "(", "fn", ")", "tier", "=", "tg", ".", "tierDict", "[", "tierName", "]", ...
Get information about the 'extract' tier, used by several merge scripts
[ "Get", "information", "about", "the", "extract", "tier", "used", "by", "several", "merge", "scripts" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/utils.py#L12-L28
timmahrt/ProMo
promo/duration_morph.py
changeDuration
def changeDuration(fromWavFN, durationParameters, stepList, outputName, outputMinPitch, outputMaxPitch, praatEXE): ''' Uses praat to morph duration in one file to duration in another Praat uses the PSOLA algorithm ''' rootPath = os.path.split(fromWavFN)[0] # Prep output dir...
python
def changeDuration(fromWavFN, durationParameters, stepList, outputName, outputMinPitch, outputMaxPitch, praatEXE): ''' Uses praat to morph duration in one file to duration in another Praat uses the PSOLA algorithm ''' rootPath = os.path.split(fromWavFN)[0] # Prep output dir...
[ "def", "changeDuration", "(", "fromWavFN", ",", "durationParameters", ",", "stepList", ",", "outputName", ",", "outputMinPitch", ",", "outputMaxPitch", ",", "praatEXE", ")", ":", "rootPath", "=", "os", ".", "path", ".", "split", "(", "fromWavFN", ")", "[", "...
Uses praat to morph duration in one file to duration in another Praat uses the PSOLA algorithm
[ "Uses", "praat", "to", "morph", "duration", "in", "one", "file", "to", "duration", "in", "another" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/duration_morph.py#L35-L87
timmahrt/ProMo
promo/duration_morph.py
getMorphParameters
def getMorphParameters(fromTGFN, toTGFN, tierName, filterFunc=None, useBlanks=False): ''' Get intervals for source and target audio files Use this information to find out how much to stretch/shrink each source interval. The target values are based on the contents of ...
python
def getMorphParameters(fromTGFN, toTGFN, tierName, filterFunc=None, useBlanks=False): ''' Get intervals for source and target audio files Use this information to find out how much to stretch/shrink each source interval. The target values are based on the contents of ...
[ "def", "getMorphParameters", "(", "fromTGFN", ",", "toTGFN", ",", "tierName", ",", "filterFunc", "=", "None", ",", "useBlanks", "=", "False", ")", ":", "if", "filterFunc", "is", "None", ":", "filterFunc", "=", "lambda", "entry", ":", "True", "# Everything is...
Get intervals for source and target audio files Use this information to find out how much to stretch/shrink each source interval. The target values are based on the contents of toTGFN.
[ "Get", "intervals", "for", "source", "and", "target", "audio", "files", "Use", "this", "information", "to", "find", "out", "how", "much", "to", "stretch", "/", "shrink", "each", "source", "interval", ".", "The", "target", "values", "are", "based", "on", "t...
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/duration_morph.py#L95-L133
timmahrt/ProMo
promo/duration_morph.py
getManipulatedParamaters
def getManipulatedParamaters(tgFN, tierName, modFunc, filterFunc=None, useBlanks=False): ''' Get intervals for source and target audio files Use this information to find out how much to stretch/shrink each source interval. The target values are based on modfunc...
python
def getManipulatedParamaters(tgFN, tierName, modFunc, filterFunc=None, useBlanks=False): ''' Get intervals for source and target audio files Use this information to find out how much to stretch/shrink each source interval. The target values are based on modfunc...
[ "def", "getManipulatedParamaters", "(", "tgFN", ",", "tierName", ",", "modFunc", ",", "filterFunc", "=", "None", ",", "useBlanks", "=", "False", ")", ":", "fromExtractInfo", "=", "utils", ".", "getIntervals", "(", "tgFN", ",", "tierName", ",", "filterFunc", ...
Get intervals for source and target audio files Use this information to find out how much to stretch/shrink each source interval. The target values are based on modfunc.
[ "Get", "intervals", "for", "source", "and", "target", "audio", "files", "Use", "this", "information", "to", "find", "out", "how", "much", "to", "stretch", "/", "shrink", "each", "source", "interval", ".", "The", "target", "values", "are", "based", "on", "m...
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/duration_morph.py#L136-L166
timmahrt/ProMo
promo/duration_morph.py
textgridMorphDuration
def textgridMorphDuration(fromTGFN, toTGFN): ''' A convenience function. Morphs interval durations of one tg to another. This assumes the two textgrids have the same number of segments. ''' fromTG = tgio.openTextgrid(fromTGFN) toTG = tgio.openTextgrid(toTGFN) adjustedTG = tgio.Textgrid...
python
def textgridMorphDuration(fromTGFN, toTGFN): ''' A convenience function. Morphs interval durations of one tg to another. This assumes the two textgrids have the same number of segments. ''' fromTG = tgio.openTextgrid(fromTGFN) toTG = tgio.openTextgrid(toTGFN) adjustedTG = tgio.Textgrid...
[ "def", "textgridMorphDuration", "(", "fromTGFN", ",", "toTGFN", ")", ":", "fromTG", "=", "tgio", ".", "openTextgrid", "(", "fromTGFN", ")", "toTG", "=", "tgio", ".", "openTextgrid", "(", "toTGFN", ")", "adjustedTG", "=", "tgio", ".", "Textgrid", "(", ")", ...
A convenience function. Morphs interval durations of one tg to another. This assumes the two textgrids have the same number of segments.
[ "A", "convenience", "function", ".", "Morphs", "interval", "durations", "of", "one", "tg", "to", "another", ".", "This", "assumes", "the", "two", "textgrids", "have", "the", "same", "number", "of", "segments", "." ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/duration_morph.py#L244-L260
timmahrt/ProMo
promo/morph_utils/audio_scripts.py
getSoundFileDuration
def getSoundFileDuration(fn): ''' Returns the duration of a wav file (in seconds) ''' audiofile = wave.open(fn, "r") params = audiofile.getparams() framerate = params[2] nframes = params[3] duration = float(nframes) / framerate return duration
python
def getSoundFileDuration(fn): ''' Returns the duration of a wav file (in seconds) ''' audiofile = wave.open(fn, "r") params = audiofile.getparams() framerate = params[2] nframes = params[3] duration = float(nframes) / framerate return duration
[ "def", "getSoundFileDuration", "(", "fn", ")", ":", "audiofile", "=", "wave", ".", "open", "(", "fn", ",", "\"r\"", ")", "params", "=", "audiofile", ".", "getparams", "(", ")", "framerate", "=", "params", "[", "2", "]", "nframes", "=", "params", "[", ...
Returns the duration of a wav file (in seconds)
[ "Returns", "the", "duration", "of", "a", "wav", "file", "(", "in", "seconds", ")" ]
train
https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/audio_scripts.py#L10-L21
hermanschaaf/mafan
mafan/text.py
split_text
def split_text(text, include_part_of_speech=False, strip_english=False, strip_numbers=False): u""" Split Chinese text at word boundaries. include_pos: also returns the Part Of Speech for each of the words. Some of the different parts of speech are: r: pronoun v: verb ns: proper ...
python
def split_text(text, include_part_of_speech=False, strip_english=False, strip_numbers=False): u""" Split Chinese text at word boundaries. include_pos: also returns the Part Of Speech for each of the words. Some of the different parts of speech are: r: pronoun v: verb ns: proper ...
[ "def", "split_text", "(", "text", ",", "include_part_of_speech", "=", "False", ",", "strip_english", "=", "False", ",", "strip_numbers", "=", "False", ")", ":", "if", "not", "include_part_of_speech", ":", "seg_list", "=", "pseg", ".", "cut", "(", "text", ")"...
u""" Split Chinese text at word boundaries. include_pos: also returns the Part Of Speech for each of the words. Some of the different parts of speech are: r: pronoun v: verb ns: proper noun etc... This all gets returned as a tuple: index 0: the split word ...
[ "u", "Split", "Chinese", "text", "at", "word", "boundaries", "." ]
train
https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/text.py#L209-L246
ericpruitt/cronex
cronex/__init__.py
is_special_atom
def is_special_atom(cron_atom, span): """ Returns a boolean indicating whether or not the string can be parsed by parse_atom to produce a static set. In the process of examining the string, the syntax of any special character uses is also checked. """ for special_char in ('%', '#', 'L', 'W'): ...
python
def is_special_atom(cron_atom, span): """ Returns a boolean indicating whether or not the string can be parsed by parse_atom to produce a static set. In the process of examining the string, the syntax of any special character uses is also checked. """ for special_char in ('%', '#', 'L', 'W'): ...
[ "def", "is_special_atom", "(", "cron_atom", ",", "span", ")", ":", "for", "special_char", "in", "(", "'%'", ",", "'#'", ",", "'L'", ",", "'W'", ")", ":", "if", "special_char", "not", "in", "cron_atom", ":", "continue", "if", "special_char", "==", "'#'", ...
Returns a boolean indicating whether or not the string can be parsed by parse_atom to produce a static set. In the process of examining the string, the syntax of any special character uses is also checked.
[ "Returns", "a", "boolean", "indicating", "whether", "or", "not", "the", "string", "can", "be", "parsed", "by", "parse_atom", "to", "produce", "a", "static", "set", ".", "In", "the", "process", "of", "examining", "the", "string", "the", "syntax", "of", "any...
train
https://github.com/ericpruitt/cronex/blob/ff48a3a71bbcdf01cff46c0bf9376e69492c9224/cronex/__init__.py#L264-L298
ericpruitt/cronex
cronex/__init__.py
parse_atom
def parse_atom(parse, minmax): """ Returns a set containing valid values for a given cron-style range of numbers. The 'minmax' arguments is a two element iterable containing the inclusive upper and lower limits of the expression. Examples: >>> parse_atom("1-5",(0,6)) set([1, 2, 3, 4, 5]) ...
python
def parse_atom(parse, minmax): """ Returns a set containing valid values for a given cron-style range of numbers. The 'minmax' arguments is a two element iterable containing the inclusive upper and lower limits of the expression. Examples: >>> parse_atom("1-5",(0,6)) set([1, 2, 3, 4, 5]) ...
[ "def", "parse_atom", "(", "parse", ",", "minmax", ")", ":", "parse", "=", "parse", ".", "strip", "(", ")", "increment", "=", "1", "if", "parse", "==", "'*'", ":", "return", "set", "(", "xrange", "(", "minmax", "[", "0", "]", ",", "minmax", "[", "...
Returns a set containing valid values for a given cron-style range of numbers. The 'minmax' arguments is a two element iterable containing the inclusive upper and lower limits of the expression. Examples: >>> parse_atom("1-5",(0,6)) set([1, 2, 3, 4, 5]) >>> parse_atom("*/6",(0,23)) set([0,...
[ "Returns", "a", "set", "containing", "valid", "values", "for", "a", "given", "cron", "-", "style", "range", "of", "numbers", ".", "The", "minmax", "arguments", "is", "a", "two", "element", "iterable", "containing", "the", "inclusive", "upper", "and", "lower"...
train
https://github.com/ericpruitt/cronex/blob/ff48a3a71bbcdf01cff46c0bf9376e69492c9224/cronex/__init__.py#L302-L362
ericpruitt/cronex
cronex/__init__.py
CronExpression.compute_numtab
def compute_numtab(self): """ Recomputes the sets for the static ranges of the trigger time. This method should only be called by the user if the string_tab member is modified. """ self.numerical_tab = [] for field_str, span in zip(self.string_tab, FIELD_RANGES)...
python
def compute_numtab(self): """ Recomputes the sets for the static ranges of the trigger time. This method should only be called by the user if the string_tab member is modified. """ self.numerical_tab = [] for field_str, span in zip(self.string_tab, FIELD_RANGES)...
[ "def", "compute_numtab", "(", "self", ")", ":", "self", ".", "numerical_tab", "=", "[", "]", "for", "field_str", ",", "span", "in", "zip", "(", "self", ".", "string_tab", ",", "FIELD_RANGES", ")", ":", "split_field_str", "=", "field_str", ".", "split", "...
Recomputes the sets for the static ranges of the trigger time. This method should only be called by the user if the string_tab member is modified.
[ "Recomputes", "the", "sets", "for", "the", "static", "ranges", "of", "the", "trigger", "time", "." ]
train
https://github.com/ericpruitt/cronex/blob/ff48a3a71bbcdf01cff46c0bf9376e69492c9224/cronex/__init__.py#L129-L154
ericpruitt/cronex
cronex/__init__.py
CronExpression.check_trigger
def check_trigger(self, date_tuple, utc_offset=0): """ Returns boolean indicating if the trigger is active at the given time. The date tuple should be in the local time. Unless periodicities are used, utc_offset does not need to be specified. If periodicities are used, specifical...
python
def check_trigger(self, date_tuple, utc_offset=0): """ Returns boolean indicating if the trigger is active at the given time. The date tuple should be in the local time. Unless periodicities are used, utc_offset does not need to be specified. If periodicities are used, specifical...
[ "def", "check_trigger", "(", "self", ",", "date_tuple", ",", "utc_offset", "=", "0", ")", ":", "year", ",", "month", ",", "day", ",", "hour", ",", "mins", "=", "date_tuple", "given_date", "=", "datetime", ".", "date", "(", "year", ",", "month", ",", ...
Returns boolean indicating if the trigger is active at the given time. The date tuple should be in the local time. Unless periodicities are used, utc_offset does not need to be specified. If periodicities are used, specifically in the hour and minutes fields, it is crucial that the utc_o...
[ "Returns", "boolean", "indicating", "if", "the", "trigger", "is", "active", "at", "the", "given", "time", ".", "The", "date", "tuple", "should", "be", "in", "the", "local", "time", ".", "Unless", "periodicities", "are", "used", "utc_offset", "does", "not", ...
train
https://github.com/ericpruitt/cronex/blob/ff48a3a71bbcdf01cff46c0bf9376e69492c9224/cronex/__init__.py#L156-L261
hustlzp/permission
permission/permission.py
Rule.show
def show(self): """Show the structure of self.rules_list, only for debug.""" for rule in self.rules_list: result = ", ".join([str(check) for check, deny in rule]) print(result)
python
def show(self): """Show the structure of self.rules_list, only for debug.""" for rule in self.rules_list: result = ", ".join([str(check) for check, deny in rule]) print(result)
[ "def", "show", "(", "self", ")", ":", "for", "rule", "in", "self", ".", "rules_list", ":", "result", "=", "\", \"", ".", "join", "(", "[", "str", "(", "check", ")", "for", "check", ",", "deny", "in", "rule", "]", ")", "print", "(", "result", ")" ...
Show the structure of self.rules_list, only for debug.
[ "Show", "the", "structure", "of", "self", ".", "rules_list", "only", "for", "debug", "." ]
train
https://github.com/hustlzp/permission/blob/302a02a775c4cd53f7588ff9c4ce1ca49a0d40bf/permission/permission.py#L88-L92
hustlzp/permission
permission/permission.py
Rule.run
def run(self): """Run self.rules_list. Return True if one rule channel has been passed. Otherwise return False and the deny() method of the last failed rule. """ failed_result = None for rule in self.rules_list: for check, deny in rule: if not...
python
def run(self): """Run self.rules_list. Return True if one rule channel has been passed. Otherwise return False and the deny() method of the last failed rule. """ failed_result = None for rule in self.rules_list: for check, deny in rule: if not...
[ "def", "run", "(", "self", ")", ":", "failed_result", "=", "None", "for", "rule", "in", "self", ".", "rules_list", ":", "for", "check", ",", "deny", "in", "rule", ":", "if", "not", "check", "(", ")", ":", "failed_result", "=", "(", "False", ",", "d...
Run self.rules_list. Return True if one rule channel has been passed. Otherwise return False and the deny() method of the last failed rule.
[ "Run", "self", ".", "rules_list", "." ]
train
https://github.com/hustlzp/permission/blob/302a02a775c4cd53f7588ff9c4ce1ca49a0d40bf/permission/permission.py#L98-L112
kbr/fritzconnection
fritzconnection/fritzmonitor.py
MeterRectangle.set_fraction
def set_fraction(self, value): """Set the meter indicator. Value should be between 0 and 1.""" if value < 0: value *= -1 value = min(value, 1) if self.horizontal: width = int(self.width * value) height = self.height else: width = se...
python
def set_fraction(self, value): """Set the meter indicator. Value should be between 0 and 1.""" if value < 0: value *= -1 value = min(value, 1) if self.horizontal: width = int(self.width * value) height = self.height else: width = se...
[ "def", "set_fraction", "(", "self", ",", "value", ")", ":", "if", "value", "<", "0", ":", "value", "*=", "-", "1", "value", "=", "min", "(", "value", ",", "1", ")", "if", "self", ".", "horizontal", ":", "width", "=", "int", "(", "self", ".", "w...
Set the meter indicator. Value should be between 0 and 1.
[ "Set", "the", "meter", "indicator", ".", "Value", "should", "be", "between", "0", "and", "1", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzmonitor.py#L58-L70
kbr/fritzconnection
fritzconnection/fritzmonitor.py
FritzMonitor.update_status
def update_status(self): """Update status informations in tkinter window.""" try: # all this may fail if the connection to the fritzbox is down self.update_connection_status() self.max_stream_rate.set(self.get_stream_rate_str()) self.ip.set(self.status.ext...
python
def update_status(self): """Update status informations in tkinter window.""" try: # all this may fail if the connection to the fritzbox is down self.update_connection_status() self.max_stream_rate.set(self.get_stream_rate_str()) self.ip.set(self.status.ext...
[ "def", "update_status", "(", "self", ")", ":", "try", ":", "# all this may fail if the connection to the fritzbox is down", "self", ".", "update_connection_status", "(", ")", "self", ".", "max_stream_rate", ".", "set", "(", "self", ".", "get_stream_rate_str", "(", ")"...
Update status informations in tkinter window.
[ "Update", "status", "informations", "in", "tkinter", "window", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzmonitor.py#L112-L134
kbr/fritzconnection
fritzconnection/fritztools.py
format_num
def format_num(num, unit='bytes'): """ Returns a human readable string of a byte-value. If 'num' is bits, set unit='bits'. """ if unit == 'bytes': extension = 'B' else: # if it's not bytes, it's bits extension = 'Bit' for dimension in (unit, 'K', 'M', 'G', 'T'): ...
python
def format_num(num, unit='bytes'): """ Returns a human readable string of a byte-value. If 'num' is bits, set unit='bits'. """ if unit == 'bytes': extension = 'B' else: # if it's not bytes, it's bits extension = 'Bit' for dimension in (unit, 'K', 'M', 'G', 'T'): ...
[ "def", "format_num", "(", "num", ",", "unit", "=", "'bytes'", ")", ":", "if", "unit", "==", "'bytes'", ":", "extension", "=", "'B'", "else", ":", "# if it's not bytes, it's bits", "extension", "=", "'Bit'", "for", "dimension", "in", "(", "unit", ",", "'K'"...
Returns a human readable string of a byte-value. If 'num' is bits, set unit='bits'.
[ "Returns", "a", "human", "readable", "string", "of", "a", "byte", "-", "value", ".", "If", "num", "is", "bits", "set", "unit", "=", "bits", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritztools.py#L9-L25
g2p/rfc6266
rfc6266.py
parse_headers
def parse_headers(content_disposition, location=None, relaxed=False): """Build a ContentDisposition from header values. """ LOGGER.debug( 'Content-Disposition %r, Location %r', content_disposition, location) if content_disposition is None: return ContentDisposition(location=location) ...
python
def parse_headers(content_disposition, location=None, relaxed=False): """Build a ContentDisposition from header values. """ LOGGER.debug( 'Content-Disposition %r, Location %r', content_disposition, location) if content_disposition is None: return ContentDisposition(location=location) ...
[ "def", "parse_headers", "(", "content_disposition", ",", "location", "=", "None", ",", "relaxed", "=", "False", ")", ":", "LOGGER", ".", "debug", "(", "'Content-Disposition %r, Location %r'", ",", "content_disposition", ",", "location", ")", "if", "content_dispositi...
Build a ContentDisposition from header values.
[ "Build", "a", "ContentDisposition", "from", "header", "values", "." ]
train
https://github.com/g2p/rfc6266/blob/cad58963ed13f5e1068fcc9e4326123b6b2bdcf8/rfc6266.py#L175-L232
g2p/rfc6266
rfc6266.py
parse_requests_response
def parse_requests_response(response, **kwargs): """Build a ContentDisposition from a requests (PyPI) response. """ return parse_headers( response.headers.get('content-disposition'), response.url, **kwargs)
python
def parse_requests_response(response, **kwargs): """Build a ContentDisposition from a requests (PyPI) response. """ return parse_headers( response.headers.get('content-disposition'), response.url, **kwargs)
[ "def", "parse_requests_response", "(", "response", ",", "*", "*", "kwargs", ")", ":", "return", "parse_headers", "(", "response", ".", "headers", ".", "get", "(", "'content-disposition'", ")", ",", "response", ".", "url", ",", "*", "*", "kwargs", ")" ]
Build a ContentDisposition from a requests (PyPI) response.
[ "Build", "a", "ContentDisposition", "from", "a", "requests", "(", "PyPI", ")", "response", "." ]
train
https://github.com/g2p/rfc6266/blob/cad58963ed13f5e1068fcc9e4326123b6b2bdcf8/rfc6266.py#L244-L249
g2p/rfc6266
rfc6266.py
build_header
def build_header( filename, disposition='attachment', filename_compat=None ): """Generate a Content-Disposition header for a given filename. For legacy clients that don't understand the filename* parameter, a filename_compat value may be given. It should either be ascii-only (recommended) or iso-88...
python
def build_header( filename, disposition='attachment', filename_compat=None ): """Generate a Content-Disposition header for a given filename. For legacy clients that don't understand the filename* parameter, a filename_compat value may be given. It should either be ascii-only (recommended) or iso-88...
[ "def", "build_header", "(", "filename", ",", "disposition", "=", "'attachment'", ",", "filename_compat", "=", "None", ")", ":", "# While this method exists, it could also sanitize the filename", "# by rejecting slashes or other weirdness that might upset a receiver.", "if", "dispos...
Generate a Content-Disposition header for a given filename. For legacy clients that don't understand the filename* parameter, a filename_compat value may be given. It should either be ascii-only (recommended) or iso-8859-1 only. In the later case it should be a character string (unicode in Python 2...
[ "Generate", "a", "Content", "-", "Disposition", "header", "for", "a", "given", "filename", "." ]
train
https://github.com/g2p/rfc6266/blob/cad58963ed13f5e1068fcc9e4326123b6b2bdcf8/rfc6266.py#L398-L453
g2p/rfc6266
rfc6266.py
ContentDisposition.filename_unsafe
def filename_unsafe(self): """The filename from the Content-Disposition header. If a location was passed at instanciation, the basename from that may be used as a fallback. Otherwise, this may be the None value. On safety: This property records the intent of the sen...
python
def filename_unsafe(self): """The filename from the Content-Disposition header. If a location was passed at instanciation, the basename from that may be used as a fallback. Otherwise, this may be the None value. On safety: This property records the intent of the sen...
[ "def", "filename_unsafe", "(", "self", ")", ":", "if", "'filename*'", "in", "self", ".", "assocs", ":", "return", "self", ".", "assocs", "[", "'filename*'", "]", ".", "string", "elif", "'filename'", "in", "self", ".", "assocs", ":", "# XXX Reject non-ascii (...
The filename from the Content-Disposition header. If a location was passed at instanciation, the basename from that may be used as a fallback. Otherwise, this may be the None value. On safety: This property records the intent of the sender. You shouldn't use th...
[ "The", "filename", "from", "the", "Content", "-", "Disposition", "header", "." ]
train
https://github.com/g2p/rfc6266/blob/cad58963ed13f5e1068fcc9e4326123b6b2bdcf8/rfc6266.py#L89-L112
g2p/rfc6266
rfc6266.py
ContentDisposition.filename_sanitized
def filename_sanitized(self, extension, default_filename='file'): """Returns a filename that is safer to use on the filesystem. The filename will not contain a slash (nor the path separator for the current platform, if different), it will not start with a dot, and it will have the expec...
python
def filename_sanitized(self, extension, default_filename='file'): """Returns a filename that is safer to use on the filesystem. The filename will not contain a slash (nor the path separator for the current platform, if different), it will not start with a dot, and it will have the expec...
[ "def", "filename_sanitized", "(", "self", ",", "extension", ",", "default_filename", "=", "'file'", ")", ":", "assert", "extension", "assert", "extension", "[", "0", "]", "!=", "'.'", "assert", "default_filename", "assert", "'.'", "not", "in", "default_filename"...
Returns a filename that is safer to use on the filesystem. The filename will not contain a slash (nor the path separator for the current platform, if different), it will not start with a dot, and it will have the expected extension. No guarantees that makes it "safe enough". No...
[ "Returns", "a", "filename", "that", "is", "safer", "to", "use", "on", "the", "filesystem", "." ]
train
https://github.com/g2p/rfc6266/blob/cad58963ed13f5e1068fcc9e4326123b6b2bdcf8/rfc6266.py#L121-L149
kbr/fritzconnection
fritzconnection/fritzstatus.py
FritzStatus.str_uptime
def str_uptime(self): """uptime in human readable format.""" mins, secs = divmod(self.uptime, 60) hours, mins = divmod(mins, 60) return '%02d:%02d:%02d' % (hours, mins, secs)
python
def str_uptime(self): """uptime in human readable format.""" mins, secs = divmod(self.uptime, 60) hours, mins = divmod(mins, 60) return '%02d:%02d:%02d' % (hours, mins, secs)
[ "def", "str_uptime", "(", "self", ")", ":", "mins", ",", "secs", "=", "divmod", "(", "self", ".", "uptime", ",", "60", ")", "hours", ",", "mins", "=", "divmod", "(", "mins", ",", "60", ")", "return", "'%02d:%02d:%02d'", "%", "(", "hours", ",", "min...
uptime in human readable format.
[ "uptime", "in", "human", "readable", "format", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzstatus.py#L82-L86
kbr/fritzconnection
fritzconnection/fritzstatus.py
FritzStatus.transmission_rate
def transmission_rate(self): """ Returns the upstream, downstream values as a tuple in bytes per second. Use this for periodical calling. """ sent = self.bytes_sent received = self.bytes_received traffic_call = time.time() time_delta = traffic_call - self....
python
def transmission_rate(self): """ Returns the upstream, downstream values as a tuple in bytes per second. Use this for periodical calling. """ sent = self.bytes_sent received = self.bytes_received traffic_call = time.time() time_delta = traffic_call - self....
[ "def", "transmission_rate", "(", "self", ")", ":", "sent", "=", "self", ".", "bytes_sent", "received", "=", "self", ".", "bytes_received", "traffic_call", "=", "time", ".", "time", "(", ")", "time_delta", "=", "traffic_call", "-", "self", ".", "last_traffic_...
Returns the upstream, downstream values as a tuple in bytes per second. Use this for periodical calling.
[ "Returns", "the", "upstream", "downstream", "values", "as", "a", "tuple", "in", "bytes", "per", "second", ".", "Use", "this", "for", "periodical", "calling", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzstatus.py#L101-L115
kbr/fritzconnection
fritzconnection/fritzstatus.py
FritzStatus.str_transmission_rate
def str_transmission_rate(self): """Returns a tuple of human readable transmission rates in bytes.""" upstream, downstream = self.transmission_rate return ( fritztools.format_num(upstream), fritztools.format_num(downstream) )
python
def str_transmission_rate(self): """Returns a tuple of human readable transmission rates in bytes.""" upstream, downstream = self.transmission_rate return ( fritztools.format_num(upstream), fritztools.format_num(downstream) )
[ "def", "str_transmission_rate", "(", "self", ")", ":", "upstream", ",", "downstream", "=", "self", ".", "transmission_rate", "return", "(", "fritztools", ".", "format_num", "(", "upstream", ")", ",", "fritztools", ".", "format_num", "(", "downstream", ")", ")"...
Returns a tuple of human readable transmission rates in bytes.
[ "Returns", "a", "tuple", "of", "human", "readable", "transmission", "rates", "in", "bytes", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzstatus.py#L118-L124
kbr/fritzconnection
fritzconnection/fritzstatus.py
FritzStatus.max_bit_rate
def max_bit_rate(self): """ Returns a tuple with the maximun upstream- and downstream-rate of the given connection. The rate is given in bits/sec. """ status = self.fc.call_action('WANCommonInterfaceConfig', 'GetCommonLinkProperties') ...
python
def max_bit_rate(self): """ Returns a tuple with the maximun upstream- and downstream-rate of the given connection. The rate is given in bits/sec. """ status = self.fc.call_action('WANCommonInterfaceConfig', 'GetCommonLinkProperties') ...
[ "def", "max_bit_rate", "(", "self", ")", ":", "status", "=", "self", ".", "fc", ".", "call_action", "(", "'WANCommonInterfaceConfig'", ",", "'GetCommonLinkProperties'", ")", "downstream", "=", "status", "[", "'NewLayer1DownstreamMaxBitRate'", "]", "upstream", "=", ...
Returns a tuple with the maximun upstream- and downstream-rate of the given connection. The rate is given in bits/sec.
[ "Returns", "a", "tuple", "with", "the", "maximun", "upstream", "-", "and", "downstream", "-", "rate", "of", "the", "given", "connection", ".", "The", "rate", "is", "given", "in", "bits", "/", "sec", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzstatus.py#L127-L136
kbr/fritzconnection
fritzconnection/fritzstatus.py
FritzStatus.str_max_bit_rate
def str_max_bit_rate(self): """ Returns a human readable maximun upstream- and downstream-rate of the given connection. The rate is given in bits/sec. """ upstream, downstream = self.max_bit_rate return ( fritztools.format_rate(upstream, unit='bits'), ...
python
def str_max_bit_rate(self): """ Returns a human readable maximun upstream- and downstream-rate of the given connection. The rate is given in bits/sec. """ upstream, downstream = self.max_bit_rate return ( fritztools.format_rate(upstream, unit='bits'), ...
[ "def", "str_max_bit_rate", "(", "self", ")", ":", "upstream", ",", "downstream", "=", "self", ".", "max_bit_rate", "return", "(", "fritztools", ".", "format_rate", "(", "upstream", ",", "unit", "=", "'bits'", ")", ",", "fritztools", ".", "format_rate", "(", ...
Returns a human readable maximun upstream- and downstream-rate of the given connection. The rate is given in bits/sec.
[ "Returns", "a", "human", "readable", "maximun", "upstream", "-", "and", "downstream", "-", "rate", "of", "the", "given", "connection", ".", "The", "rate", "is", "given", "in", "bits", "/", "sec", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzstatus.py#L147-L156
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzAction._body_builder
def _body_builder(self, kwargs): """ Helper method to construct the appropriate SOAP-body to call a FritzBox-Service. """ p = { 'action_name': self.name, 'service_type': self.service_type, 'arguments': '', } if kwargs: ...
python
def _body_builder(self, kwargs): """ Helper method to construct the appropriate SOAP-body to call a FritzBox-Service. """ p = { 'action_name': self.name, 'service_type': self.service_type, 'arguments': '', } if kwargs: ...
[ "def", "_body_builder", "(", "self", ",", "kwargs", ")", ":", "p", "=", "{", "'action_name'", ":", "self", ".", "name", ",", "'service_type'", ":", "self", ".", "service_type", ",", "'arguments'", ":", "''", ",", "}", "if", "kwargs", ":", "arguments", ...
Helper method to construct the appropriate SOAP-body to call a FritzBox-Service.
[ "Helper", "method", "to", "construct", "the", "appropriate", "SOAP", "-", "body", "to", "call", "a", "FritzBox", "-", "Service", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L94-L111
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzAction.execute
def execute(self, **kwargs): """ Calls the FritzBox action and returns a dictionary with the arguments. """ headers = self.header.copy() headers['soapaction'] = '%s#%s' % (self.service_type, self.name) data = self.envelope.strip() % self._body_builder(kwargs) url ...
python
def execute(self, **kwargs): """ Calls the FritzBox action and returns a dictionary with the arguments. """ headers = self.header.copy() headers['soapaction'] = '%s#%s' % (self.service_type, self.name) data = self.envelope.strip() % self._body_builder(kwargs) url ...
[ "def", "execute", "(", "self", ",", "*", "*", "kwargs", ")", ":", "headers", "=", "self", ".", "header", ".", "copy", "(", ")", "headers", "[", "'soapaction'", "]", "=", "'%s#%s'", "%", "(", "self", ".", "service_type", ",", "self", ".", "name", ")...
Calls the FritzBox action and returns a dictionary with the arguments.
[ "Calls", "the", "FritzBox", "action", "and", "returns", "a", "dictionary", "with", "the", "arguments", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L113-L127
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzAction.parse_response
def parse_response(self, response): """ Evaluates the action-call response from a FritzBox. The response is a xml byte-string. Returns a dictionary with the received arguments-value pairs. The values are converted according to the given data_types. TODO: boolean and signe...
python
def parse_response(self, response): """ Evaluates the action-call response from a FritzBox. The response is a xml byte-string. Returns a dictionary with the received arguments-value pairs. The values are converted according to the given data_types. TODO: boolean and signe...
[ "def", "parse_response", "(", "self", ",", "response", ")", ":", "result", "=", "{", "}", "root", "=", "etree", ".", "fromstring", "(", "response", ")", "for", "argument", "in", "self", ".", "arguments", ".", "values", "(", ")", ":", "try", ":", "val...
Evaluates the action-call response from a FritzBox. The response is a xml byte-string. Returns a dictionary with the received arguments-value pairs. The values are converted according to the given data_types. TODO: boolean and signed integers data-types from tr64 responses
[ "Evaluates", "the", "action", "-", "call", "response", "from", "a", "FritzBox", ".", "The", "response", "is", "a", "xml", "byte", "-", "string", ".", "Returns", "a", "dictionary", "with", "the", "received", "arguments", "-", "value", "pairs", ".", "The", ...
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L129-L153
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzDescParser.get_modelname
def get_modelname(self): """Returns the FritzBox model name.""" xpath = '%s/%s' % (self.nodename('device'), self.nodename('modelName')) return self.root.find(xpath).text
python
def get_modelname(self): """Returns the FritzBox model name.""" xpath = '%s/%s' % (self.nodename('device'), self.nodename('modelName')) return self.root.find(xpath).text
[ "def", "get_modelname", "(", "self", ")", ":", "xpath", "=", "'%s/%s'", "%", "(", "self", ".", "nodename", "(", "'device'", ")", ",", "self", ".", "nodename", "(", "'modelName'", ")", ")", "return", "self", ".", "root", ".", "find", "(", "xpath", ")"...
Returns the FritzBox model name.
[ "Returns", "the", "FritzBox", "model", "name", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L202-L205
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzDescParser.get_services
def get_services(self): """Returns a list of FritzService-objects.""" result = [] nodes = self.root.iterfind( './/ns:service', namespaces={'ns': self.namespace}) for node in nodes: result.append(FritzService( node.find(self.nodename('serviceType'))...
python
def get_services(self): """Returns a list of FritzService-objects.""" result = [] nodes = self.root.iterfind( './/ns:service', namespaces={'ns': self.namespace}) for node in nodes: result.append(FritzService( node.find(self.nodename('serviceType'))...
[ "def", "get_services", "(", "self", ")", ":", "result", "=", "[", "]", "nodes", "=", "self", ".", "root", ".", "iterfind", "(", "'.//ns:service'", ",", "namespaces", "=", "{", "'ns'", ":", "self", ".", "namespace", "}", ")", "for", "node", "in", "nod...
Returns a list of FritzService-objects.
[ "Returns", "a", "list", "of", "FritzService", "-", "objects", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L207-L217
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzSCDPParser._read_state_variables
def _read_state_variables(self): """ Reads the stateVariable information from the xml-file. The information we like to extract are name and dataType so we can assign them later on to FritzActionArgument-instances. Returns a dictionary: key:value = name:dataType """ ...
python
def _read_state_variables(self): """ Reads the stateVariable information from the xml-file. The information we like to extract are name and dataType so we can assign them later on to FritzActionArgument-instances. Returns a dictionary: key:value = name:dataType """ ...
[ "def", "_read_state_variables", "(", "self", ")", ":", "nodes", "=", "self", ".", "root", ".", "iterfind", "(", "'.//ns:stateVariable'", ",", "namespaces", "=", "{", "'ns'", ":", "self", ".", "namespace", "}", ")", "for", "node", "in", "nodes", ":", "key...
Reads the stateVariable information from the xml-file. The information we like to extract are name and dataType so we can assign them later on to FritzActionArgument-instances. Returns a dictionary: key:value = name:dataType
[ "Reads", "the", "stateVariable", "information", "from", "the", "xml", "-", "file", ".", "The", "information", "we", "like", "to", "extract", "are", "name", "and", "dataType", "so", "we", "can", "assign", "them", "later", "on", "to", "FritzActionArgument", "-...
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L240-L252
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzSCDPParser.get_actions
def get_actions(self): """Returns a list of FritzAction instances.""" self._read_state_variables() actions = [] nodes = self.root.iterfind( './/ns:action', namespaces={'ns': self.namespace}) for node in nodes: action = FritzAction(self.service.service_type...
python
def get_actions(self): """Returns a list of FritzAction instances.""" self._read_state_variables() actions = [] nodes = self.root.iterfind( './/ns:action', namespaces={'ns': self.namespace}) for node in nodes: action = FritzAction(self.service.service_type...
[ "def", "get_actions", "(", "self", ")", ":", "self", ".", "_read_state_variables", "(", ")", "actions", "=", "[", "]", "nodes", "=", "self", ".", "root", ".", "iterfind", "(", "'.//ns:action'", ",", "namespaces", "=", "{", "'ns'", ":", "self", ".", "na...
Returns a list of FritzAction instances.
[ "Returns", "a", "list", "of", "FritzAction", "instances", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L254-L266
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzSCDPParser._get_arguments
def _get_arguments(self, action_node): """ Returns a dictionary of arguments for the given action_node. """ arguments = {} argument_nodes = action_node.iterfind( r'./ns:argumentList/ns:argument', namespaces={'ns': self.namespace}) for argument_node in argument...
python
def _get_arguments(self, action_node): """ Returns a dictionary of arguments for the given action_node. """ arguments = {} argument_nodes = action_node.iterfind( r'./ns:argumentList/ns:argument', namespaces={'ns': self.namespace}) for argument_node in argument...
[ "def", "_get_arguments", "(", "self", ",", "action_node", ")", ":", "arguments", "=", "{", "}", "argument_nodes", "=", "action_node", ".", "iterfind", "(", "r'./ns:argumentList/ns:argument'", ",", "namespaces", "=", "{", "'ns'", ":", "self", ".", "namespace", ...
Returns a dictionary of arguments for the given action_node.
[ "Returns", "a", "dictionary", "of", "arguments", "for", "the", "given", "action_node", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L268-L278
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzSCDPParser._get_argument
def _get_argument(self, argument_node): """ Returns a FritzActionArgument instance for the given argument_node. """ argument = FritzActionArgument() argument.name = argument_node.find(self.nodename('name')).text argument.direction = argument_node.find(self.nodename('direc...
python
def _get_argument(self, argument_node): """ Returns a FritzActionArgument instance for the given argument_node. """ argument = FritzActionArgument() argument.name = argument_node.find(self.nodename('name')).text argument.direction = argument_node.find(self.nodename('direc...
[ "def", "_get_argument", "(", "self", ",", "argument_node", ")", ":", "argument", "=", "FritzActionArgument", "(", ")", "argument", ".", "name", "=", "argument_node", ".", "find", "(", "self", ".", "nodename", "(", "'name'", ")", ")", ".", "text", "argument...
Returns a FritzActionArgument instance for the given argument_node.
[ "Returns", "a", "FritzActionArgument", "instance", "for", "the", "given", "argument_node", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L280-L290
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzConnection._read_descriptions
def _read_descriptions(self, password): """ Read and evaluate the igddesc.xml file and the tr64desc.xml file if a password is given. """ descfiles = [FRITZ_IGD_DESC_FILE] if password: descfiles.append(FRITZ_TR64_DESC_FILE) for descfile in descfiles: ...
python
def _read_descriptions(self, password): """ Read and evaluate the igddesc.xml file and the tr64desc.xml file if a password is given. """ descfiles = [FRITZ_IGD_DESC_FILE] if password: descfiles.append(FRITZ_TR64_DESC_FILE) for descfile in descfiles: ...
[ "def", "_read_descriptions", "(", "self", ",", "password", ")", ":", "descfiles", "=", "[", "FRITZ_IGD_DESC_FILE", "]", "if", "password", ":", "descfiles", ".", "append", "(", "FRITZ_TR64_DESC_FILE", ")", "for", "descfile", "in", "descfiles", ":", "parser", "=...
Read and evaluate the igddesc.xml file and the tr64desc.xml file if a password is given.
[ "Read", "and", "evaluate", "the", "igddesc", ".", "xml", "file", "and", "the", "tr64desc", ".", "xml", "file", "if", "a", "password", "is", "given", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L315-L328
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzConnection._read_services
def _read_services(self, services): """Get actions from services.""" for service in services: parser = FritzSCDPParser(self.address, self.port, service) actions = parser.get_actions() service.actions = {action.name: action for action in actions} self.servi...
python
def _read_services(self, services): """Get actions from services.""" for service in services: parser = FritzSCDPParser(self.address, self.port, service) actions = parser.get_actions() service.actions = {action.name: action for action in actions} self.servi...
[ "def", "_read_services", "(", "self", ",", "services", ")", ":", "for", "service", "in", "services", ":", "parser", "=", "FritzSCDPParser", "(", "self", ".", "address", ",", "self", ".", "port", ",", "service", ")", "actions", "=", "parser", ".", "get_ac...
Get actions from services.
[ "Get", "actions", "from", "services", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L330-L336
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzConnection.actionnames
def actionnames(self): """ Returns a alphabetical sorted list of tuples with all known service- and action-names. """ actions = [] for service_name in sorted(self.services.keys()): action_names = self.services[service_name].actions.keys() for actio...
python
def actionnames(self): """ Returns a alphabetical sorted list of tuples with all known service- and action-names. """ actions = [] for service_name in sorted(self.services.keys()): action_names = self.services[service_name].actions.keys() for actio...
[ "def", "actionnames", "(", "self", ")", ":", "actions", "=", "[", "]", "for", "service_name", "in", "sorted", "(", "self", ".", "services", ".", "keys", "(", ")", ")", ":", "action_names", "=", "self", ".", "services", "[", "service_name", "]", ".", ...
Returns a alphabetical sorted list of tuples with all known service- and action-names.
[ "Returns", "a", "alphabetical", "sorted", "list", "of", "tuples", "with", "all", "known", "service", "-", "and", "action", "-", "names", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L339-L349
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzConnection.get_action_arguments
def get_action_arguments(self, service_name, action_name): """ Returns a list of tuples with all known arguments for the given service- and action-name combination. The tuples contain the argument-name, direction and data_type. """ return self.services[service_name].actio...
python
def get_action_arguments(self, service_name, action_name): """ Returns a list of tuples with all known arguments for the given service- and action-name combination. The tuples contain the argument-name, direction and data_type. """ return self.services[service_name].actio...
[ "def", "get_action_arguments", "(", "self", ",", "service_name", ",", "action_name", ")", ":", "return", "self", ".", "services", "[", "service_name", "]", ".", "actions", "[", "action_name", "]", ".", "info" ]
Returns a list of tuples with all known arguments for the given service- and action-name combination. The tuples contain the argument-name, direction and data_type.
[ "Returns", "a", "list", "of", "tuples", "with", "all", "known", "arguments", "for", "the", "given", "service", "-", "and", "action", "-", "name", "combination", ".", "The", "tuples", "contain", "the", "argument", "-", "name", "direction", "and", "data_type",...
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L351-L357
kbr/fritzconnection
fritzconnection/fritzconnection.py
FritzConnection.call_action
def call_action(self, service_name, action_name, **kwargs): """Executes the given action. Raise a KeyError on unkown actions.""" action = self.services[service_name].actions[action_name] return action.execute(**kwargs)
python
def call_action(self, service_name, action_name, **kwargs): """Executes the given action. Raise a KeyError on unkown actions.""" action = self.services[service_name].actions[action_name] return action.execute(**kwargs)
[ "def", "call_action", "(", "self", ",", "service_name", ",", "action_name", ",", "*", "*", "kwargs", ")", ":", "action", "=", "self", ".", "services", "[", "service_name", "]", ".", "actions", "[", "action_name", "]", "return", "action", ".", "execute", ...
Executes the given action. Raise a KeyError on unkown actions.
[ "Executes", "the", "given", "action", ".", "Raise", "a", "KeyError", "on", "unkown", "actions", "." ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzconnection.py#L359-L362
kbr/fritzconnection
fritzconnection/fritzhosts.py
FritzHosts.get_hosts_info
def get_hosts_info(self): """ Returns a list of dicts with information about the known hosts. The dict-keys are: 'ip', 'name', 'mac', 'status' """ result = [] index = 0 while index < self.host_numbers: host = self.get_generic_host_entry(index) ...
python
def get_hosts_info(self): """ Returns a list of dicts with information about the known hosts. The dict-keys are: 'ip', 'name', 'mac', 'status' """ result = [] index = 0 while index < self.host_numbers: host = self.get_generic_host_entry(index) ...
[ "def", "get_hosts_info", "(", "self", ")", ":", "result", "=", "[", "]", "index", "=", "0", "while", "index", "<", "self", ".", "host_numbers", ":", "host", "=", "self", ".", "get_generic_host_entry", "(", "index", ")", "result", ".", "append", "(", "{...
Returns a list of dicts with information about the known hosts. The dict-keys are: 'ip', 'name', 'mac', 'status'
[ "Returns", "a", "list", "of", "dicts", "with", "information", "about", "the", "known", "hosts", ".", "The", "dict", "-", "keys", "are", ":", "ip", "name", "mac", "status" ]
train
https://github.com/kbr/fritzconnection/blob/b183f759ef19dd1652371e912d36cfe34f6639ac/fritzconnection/fritzhosts.py#L50-L65
grigi/talkey
talkey/utils.py
find_executable
def find_executable(executable): ''' Finds executable in PATH Returns: string or None ''' logger = logging.getLogger(__name__) logger.debug("Checking executable '%s'...", executable) executable_path = _find_executable(executable) found = executable_path is not None if found:...
python
def find_executable(executable): ''' Finds executable in PATH Returns: string or None ''' logger = logging.getLogger(__name__) logger.debug("Checking executable '%s'...", executable) executable_path = _find_executable(executable) found = executable_path is not None if found:...
[ "def", "find_executable", "(", "executable", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "logger", ".", "debug", "(", "\"Checking executable '%s'...\"", ",", "executable", ")", "executable_path", "=", "_find_executable", "(", "execu...
Finds executable in PATH Returns: string or None
[ "Finds", "executable", "in", "PATH" ]
train
https://github.com/grigi/talkey/blob/5d2d4a1f7001744c4fd9a79a883a3f2001522329/talkey/utils.py#L12-L27
grigi/talkey
talkey/utils.py
check_network_connection
def check_network_connection(server, port): ''' Checks if jasper can connect a network server. Arguments: server -- (optional) the server to connect with (Default: "www.google.com") Returns: True or False ''' logger = logging.getLogger(__name__) logger.debug...
python
def check_network_connection(server, port): ''' Checks if jasper can connect a network server. Arguments: server -- (optional) the server to connect with (Default: "www.google.com") Returns: True or False ''' logger = logging.getLogger(__name__) logger.debug...
[ "def", "check_network_connection", "(", "server", ",", "port", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "logger", ".", "debug", "(", "\"Checking network connection to server '%s'...\"", ",", "server", ")", "try", ":", "# see if w...
Checks if jasper can connect a network server. Arguments: server -- (optional) the server to connect with (Default: "www.google.com") Returns: True or False
[ "Checks", "if", "jasper", "can", "connect", "a", "network", "server", ".", "Arguments", ":", "server", "--", "(", "optional", ")", "the", "server", "to", "connect", "with", "(", "Default", ":", "www", ".", "google", ".", "com", ")", "Returns", ":", "Tr...
train
https://github.com/grigi/talkey/blob/5d2d4a1f7001744c4fd9a79a883a3f2001522329/talkey/utils.py#L40-L63
grigi/talkey
talkey/utils.py
check_python_import
def check_python_import(package_or_module): ''' Checks if a python package or module is importable. Arguments: package_or_module -- the package or module name to check Returns: True or False ''' logger = logging.getLogger(__name__) logger.debug("Checking python import '%s'......
python
def check_python_import(package_or_module): ''' Checks if a python package or module is importable. Arguments: package_or_module -- the package or module name to check Returns: True or False ''' logger = logging.getLogger(__name__) logger.debug("Checking python import '%s'......
[ "def", "check_python_import", "(", "package_or_module", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "logger", ".", "debug", "(", "\"Checking python import '%s'...\"", ",", "package_or_module", ")", "loader", "=", "pkgutil", ".", "ge...
Checks if a python package or module is importable. Arguments: package_or_module -- the package or module name to check Returns: True or False
[ "Checks", "if", "a", "python", "package", "or", "module", "is", "importable", ".", "Arguments", ":", "package_or_module", "--", "the", "package", "or", "module", "name", "to", "check", "Returns", ":", "True", "or", "False" ]
train
https://github.com/grigi/talkey/blob/5d2d4a1f7001744c4fd9a79a883a3f2001522329/talkey/utils.py#L66-L84
mozilla-services/axe-selenium-python
axe_selenium_python/axe.py
Axe.inject
def inject(self): """ Recursively inject aXe into all iframes and the top level document. :param script_url: location of the axe-core script. :type script_url: string """ with open(self.script_url, "r", encoding="utf8") as f: self.selenium.execute_script(f.re...
python
def inject(self): """ Recursively inject aXe into all iframes and the top level document. :param script_url: location of the axe-core script. :type script_url: string """ with open(self.script_url, "r", encoding="utf8") as f: self.selenium.execute_script(f.re...
[ "def", "inject", "(", "self", ")", ":", "with", "open", "(", "self", ".", "script_url", ",", "\"r\"", ",", "encoding", "=", "\"utf8\"", ")", "as", "f", ":", "self", ".", "selenium", ".", "execute_script", "(", "f", ".", "read", "(", ")", ")" ]
Recursively inject aXe into all iframes and the top level document. :param script_url: location of the axe-core script. :type script_url: string
[ "Recursively", "inject", "aXe", "into", "all", "iframes", "and", "the", "top", "level", "document", "." ]
train
https://github.com/mozilla-services/axe-selenium-python/blob/475c9f4eb771587aea73897bee356284d0361d77/axe_selenium_python/axe.py#L19-L27
mozilla-services/axe-selenium-python
axe_selenium_python/axe.py
Axe.run
def run(self, context=None, options=None): """ Run axe against the current page. :param context: which page part(s) to analyze and/or what to exclude. :param options: dictionary of aXe options. """ template = ( "var callback = arguments[arguments.length - 1];...
python
def run(self, context=None, options=None): """ Run axe against the current page. :param context: which page part(s) to analyze and/or what to exclude. :param options: dictionary of aXe options. """ template = ( "var callback = arguments[arguments.length - 1];...
[ "def", "run", "(", "self", ",", "context", "=", "None", ",", "options", "=", "None", ")", ":", "template", "=", "(", "\"var callback = arguments[arguments.length - 1];\"", "+", "\"axe.run(%s).then(results => callback(results))\"", ")", "args", "=", "\"\"", "# If conte...
Run axe against the current page. :param context: which page part(s) to analyze and/or what to exclude. :param options: dictionary of aXe options.
[ "Run", "axe", "against", "the", "current", "page", "." ]
train
https://github.com/mozilla-services/axe-selenium-python/blob/475c9f4eb771587aea73897bee356284d0361d77/axe_selenium_python/axe.py#L29-L54
mozilla-services/axe-selenium-python
axe_selenium_python/axe.py
Axe.report
def report(self, violations): """ Return readable report of accessibility violations found. :param violations: Dictionary of violations. :type violations: dict :return report: Readable report of violations. :rtype: string """ string = "" string +=...
python
def report(self, violations): """ Return readable report of accessibility violations found. :param violations: Dictionary of violations. :type violations: dict :return report: Readable report of violations. :rtype: string """ string = "" string +=...
[ "def", "report", "(", "self", ",", "violations", ")", ":", "string", "=", "\"\"", "string", "+=", "\"Found \"", "+", "str", "(", "len", "(", "violations", ")", ")", "+", "\" accessibility violations:\"", "for", "violation", "in", "violations", ":", "string",...
Return readable report of accessibility violations found. :param violations: Dictionary of violations. :type violations: dict :return report: Readable report of violations. :rtype: string
[ "Return", "readable", "report", "of", "accessibility", "violations", "found", "." ]
train
https://github.com/mozilla-services/axe-selenium-python/blob/475c9f4eb771587aea73897bee356284d0361d77/axe_selenium_python/axe.py#L56-L94