partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
UcanBus.create_filter
Calculates AMR and ACR using CAN-ID as parameter. :param bool extended: if True parameters from_id and to_id contains 29-bit CAN-ID :param int from_id: first CAN-ID which should be received :param int to_id: last CAN-ID which should be received :pa...
can/interfaces/systec/ucanbus.py
def create_filter(extended, from_id, to_id, rtr_only, rtr_too): """ Calculates AMR and ACR using CAN-ID as parameter. :param bool extended: if True parameters from_id and to_id contains 29-bit CAN-ID :param int from_id: first CAN-ID which should be received ...
def create_filter(extended, from_id, to_id, rtr_only, rtr_too): """ Calculates AMR and ACR using CAN-ID as parameter. :param bool extended: if True parameters from_id and to_id contains 29-bit CAN-ID :param int from_id: first CAN-ID which should be received ...
[ "Calculates", "AMR", "and", "ACR", "using", "CAN", "-", "ID", "as", "parameter", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucanbus.py#L217-L242
[ "def", "create_filter", "(", "extended", ",", "from_id", ",", "to_id", ",", "rtr_only", ",", "rtr_too", ")", ":", "return", "[", "{", "\"can_id\"", ":", "Ucan", ".", "calculate_acr", "(", "extended", ",", "from_id", ",", "to_id", ",", "rtr_only", ",", "r...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanBus.shutdown
Shuts down all CAN interfaces and hardware interface.
can/interfaces/systec/ucanbus.py
def shutdown(self): """ Shuts down all CAN interfaces and hardware interface. """ try: self._ucan.shutdown() except Exception as ex: log.error(ex)
def shutdown(self): """ Shuts down all CAN interfaces and hardware interface. """ try: self._ucan.shutdown() except Exception as ex: log.error(ex)
[ "Shuts", "down", "all", "CAN", "interfaces", "and", "hardware", "interface", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucanbus.py#L261-L268
[ "def", "shutdown", "(", "self", ")", ":", "try", ":", "self", ".", "_ucan", ".", "shutdown", "(", ")", "except", "Exception", "as", "ex", ":", "log", ".", "error", "(", "ex", ")" ]
cdc5254d96072df7739263623f3e920628a7d214
train
load_file_config
Loads configuration from file with following content:: [default] interface = socketcan channel = can0 :param path: path to config file. If not specified, several sensible default locations are tried depending on platform. :param section: name of the section to r...
can/util.py
def load_file_config(path=None, section=None): """ Loads configuration from file with following content:: [default] interface = socketcan channel = can0 :param path: path to config file. If not specified, several sensible default locations are tried depending on pla...
def load_file_config(path=None, section=None): """ Loads configuration from file with following content:: [default] interface = socketcan channel = can0 :param path: path to config file. If not specified, several sensible default locations are tried depending on pla...
[ "Loads", "configuration", "from", "file", "with", "following", "content", "::" ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/util.py#L58-L87
[ "def", "load_file_config", "(", "path", "=", "None", ",", "section", "=", "None", ")", ":", "config", "=", "ConfigParser", "(", ")", "if", "path", "is", "None", ":", "config", ".", "read", "(", "[", "os", ".", "path", ".", "expanduser", "(", "path", ...
cdc5254d96072df7739263623f3e920628a7d214
train
load_environment_config
Loads config dict from environmental variables (if set): * CAN_INTERFACE * CAN_CHANNEL * CAN_BITRATE
can/util.py
def load_environment_config(): """ Loads config dict from environmental variables (if set): * CAN_INTERFACE * CAN_CHANNEL * CAN_BITRATE """ mapper = { 'interface': 'CAN_INTERFACE', 'channel': 'CAN_CHANNEL', 'bitrate': 'CAN_BITRATE', } return dict( (k...
def load_environment_config(): """ Loads config dict from environmental variables (if set): * CAN_INTERFACE * CAN_CHANNEL * CAN_BITRATE """ mapper = { 'interface': 'CAN_INTERFACE', 'channel': 'CAN_CHANNEL', 'bitrate': 'CAN_BITRATE', } return dict( (k...
[ "Loads", "config", "dict", "from", "environmental", "variables", "(", "if", "set", ")", ":" ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/util.py#L90-L108
[ "def", "load_environment_config", "(", ")", ":", "mapper", "=", "{", "'interface'", ":", "'CAN_INTERFACE'", ",", "'channel'", ":", "'CAN_CHANNEL'", ",", "'bitrate'", ":", "'CAN_BITRATE'", ",", "}", "return", "dict", "(", "(", "key", ",", "os", ".", "environ"...
cdc5254d96072df7739263623f3e920628a7d214
train
load_config
Returns a dict with configuration details which is loaded from (in this order): - config - can.rc - Environment variables CAN_INTERFACE, CAN_CHANNEL, CAN_BITRATE - Config files ``/etc/can.conf`` or ``~/.can`` or ``~/.canrc`` where the latter may add or replace values of the former. Interface...
can/util.py
def load_config(path=None, config=None, context=None): """ Returns a dict with configuration details which is loaded from (in this order): - config - can.rc - Environment variables CAN_INTERFACE, CAN_CHANNEL, CAN_BITRATE - Config files ``/etc/can.conf`` or ``~/.can`` or ``~/.canrc`` where...
def load_config(path=None, config=None, context=None): """ Returns a dict with configuration details which is loaded from (in this order): - config - can.rc - Environment variables CAN_INTERFACE, CAN_CHANNEL, CAN_BITRATE - Config files ``/etc/can.conf`` or ``~/.can`` or ``~/.canrc`` where...
[ "Returns", "a", "dict", "with", "configuration", "details", "which", "is", "loaded", "from", "(", "in", "this", "order", ")", ":" ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/util.py#L111-L203
[ "def", "load_config", "(", "path", "=", "None", ",", "config", "=", "None", ",", "context", "=", "None", ")", ":", "# start with an empty dict to apply filtering to all sources", "given_config", "=", "config", "or", "{", "}", "config", "=", "{", "}", "# use the ...
cdc5254d96072df7739263623f3e920628a7d214
train
set_logging_level
Set the logging level for the "can" logger. Expects one of: 'critical', 'error', 'warning', 'info', 'debug', 'subdebug'
can/util.py
def set_logging_level(level_name=None): """Set the logging level for the "can" logger. Expects one of: 'critical', 'error', 'warning', 'info', 'debug', 'subdebug' """ can_logger = logging.getLogger('can') try: can_logger.setLevel(getattr(logging, level_name.upper())) except AttributeErr...
def set_logging_level(level_name=None): """Set the logging level for the "can" logger. Expects one of: 'critical', 'error', 'warning', 'info', 'debug', 'subdebug' """ can_logger = logging.getLogger('can') try: can_logger.setLevel(getattr(logging, level_name.upper())) except AttributeErr...
[ "Set", "the", "logging", "level", "for", "the", "can", "logger", ".", "Expects", "one", "of", ":", "critical", "error", "warning", "info", "debug", "subdebug" ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/util.py#L206-L216
[ "def", "set_logging_level", "(", "level_name", "=", "None", ")", ":", "can_logger", "=", "logging", ".", "getLogger", "(", "'can'", ")", "try", ":", "can_logger", ".", "setLevel", "(", "getattr", "(", "logging", ",", "level_name", ".", "upper", "(", ")", ...
cdc5254d96072df7739263623f3e920628a7d214
train
len2dlc
Calculate the DLC from data length. :param int length: Length in number of bytes (0-64) :returns: DLC (0-15) :rtype: int
can/util.py
def len2dlc(length): """Calculate the DLC from data length. :param int length: Length in number of bytes (0-64) :returns: DLC (0-15) :rtype: int """ if length <= 8: return length for dlc, nof_bytes in enumerate(CAN_FD_DLC): if nof_bytes >= length: return dlc ...
def len2dlc(length): """Calculate the DLC from data length. :param int length: Length in number of bytes (0-64) :returns: DLC (0-15) :rtype: int """ if length <= 8: return length for dlc, nof_bytes in enumerate(CAN_FD_DLC): if nof_bytes >= length: return dlc ...
[ "Calculate", "the", "DLC", "from", "data", "length", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/util.py#L219-L232
[ "def", "len2dlc", "(", "length", ")", ":", "if", "length", "<=", "8", ":", "return", "length", "for", "dlc", ",", "nof_bytes", "in", "enumerate", "(", "CAN_FD_DLC", ")", ":", "if", "nof_bytes", ">=", "length", ":", "return", "dlc", "return", "15" ]
cdc5254d96072df7739263623f3e920628a7d214
train
channel2int
Try to convert the channel to an integer. :param channel: Channel string (e.g. can0, CAN1) or integer :returns: Channel integer or `None` if unsuccessful :rtype: int
can/util.py
def channel2int(channel): """Try to convert the channel to an integer. :param channel: Channel string (e.g. can0, CAN1) or integer :returns: Channel integer or `None` if unsuccessful :rtype: int """ if channel is None: return None if isinstance(channel, int): re...
def channel2int(channel): """Try to convert the channel to an integer. :param channel: Channel string (e.g. can0, CAN1) or integer :returns: Channel integer or `None` if unsuccessful :rtype: int """ if channel is None: return None if isinstance(channel, int): re...
[ "Try", "to", "convert", "the", "channel", "to", "an", "integer", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/util.py#L246-L264
[ "def", "channel2int", "(", "channel", ")", ":", "if", "channel", "is", "None", ":", "return", "None", "if", "isinstance", "(", "channel", ",", "int", ")", ":", "return", "channel", "# String and byte objects have a lower() method", "if", "hasattr", "(", "channel...
cdc5254d96072df7739263623f3e920628a7d214
train
BusABC.recv
Block waiting for a message from the Bus. :type timeout: float or None :param timeout: seconds to wait for a message or None to wait indefinitely :rtype: can.Message or None :return: None on timeout or a :class:`can.Message` object. :raises can.CanError:...
can/bus.py
def recv(self, timeout=None): """Block waiting for a message from the Bus. :type timeout: float or None :param timeout: seconds to wait for a message or None to wait indefinitely :rtype: can.Message or None :return: None on timeout or a :class:`can.Messa...
def recv(self, timeout=None): """Block waiting for a message from the Bus. :type timeout: float or None :param timeout: seconds to wait for a message or None to wait indefinitely :rtype: can.Message or None :return: None on timeout or a :class:`can.Messa...
[ "Block", "waiting", "for", "a", "message", "from", "the", "Bus", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/bus.py#L64-L103
[ "def", "recv", "(", "self", ",", "timeout", "=", "None", ")", ":", "start", "=", "time", "(", ")", "time_left", "=", "timeout", "while", "True", ":", "# try to get a message", "msg", ",", "already_filtered", "=", "self", ".", "_recv_internal", "(", "timeou...
cdc5254d96072df7739263623f3e920628a7d214
train
BusABC.send_periodic
Start sending a message at a given period on this bus. The task will be active until one of the following conditions are met: - the (optional) duration expires - the Bus instance goes out of scope - the Bus instance is shutdown - :meth:`BusABC.stop_all_periodic_tasks()` is call...
can/bus.py
def send_periodic(self, msg, period, duration=None, store_task=True): """Start sending a message at a given period on this bus. The task will be active until one of the following conditions are met: - the (optional) duration expires - the Bus instance goes out of scope - the Bu...
def send_periodic(self, msg, period, duration=None, store_task=True): """Start sending a message at a given period on this bus. The task will be active until one of the following conditions are met: - the (optional) duration expires - the Bus instance goes out of scope - the Bu...
[ "Start", "sending", "a", "message", "at", "a", "given", "period", "on", "this", "bus", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/bus.py#L169-L224
[ "def", "send_periodic", "(", "self", ",", "msg", ",", "period", ",", "duration", "=", "None", ",", "store_task", "=", "True", ")", ":", "task", "=", "self", ".", "_send_periodic_internal", "(", "msg", ",", "period", ",", "duration", ")", "# we wrap the tas...
cdc5254d96072df7739263623f3e920628a7d214
train
BusABC._send_periodic_internal
Default implementation of periodic message sending using threading. Override this method to enable a more efficient backend specific approach. :param can.Message msg: Message to transmit :param float period: Period in seconds between each message :param float du...
can/bus.py
def _send_periodic_internal(self, msg, period, duration=None): """Default implementation of periodic message sending using threading. Override this method to enable a more efficient backend specific approach. :param can.Message msg: Message to transmit :param float period: ...
def _send_periodic_internal(self, msg, period, duration=None): """Default implementation of periodic message sending using threading. Override this method to enable a more efficient backend specific approach. :param can.Message msg: Message to transmit :param float period: ...
[ "Default", "implementation", "of", "periodic", "message", "sending", "using", "threading", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/bus.py#L226-L247
[ "def", "_send_periodic_internal", "(", "self", ",", "msg", ",", "period", ",", "duration", "=", "None", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"_lock_send_periodic\"", ")", ":", "# Create a send lock for this bus", "self", ".", "_lock_send_periodic"...
cdc5254d96072df7739263623f3e920628a7d214
train
BusABC.stop_all_periodic_tasks
Stop sending any messages that were started using bus.send_periodic :param bool remove_tasks: Stop tracking the stopped tasks.
can/bus.py
def stop_all_periodic_tasks(self, remove_tasks=True): """Stop sending any messages that were started using bus.send_periodic :param bool remove_tasks: Stop tracking the stopped tasks. """ for task in self._periodic_tasks: task.stop(remove_task=remove_tasks)
def stop_all_periodic_tasks(self, remove_tasks=True): """Stop sending any messages that were started using bus.send_periodic :param bool remove_tasks: Stop tracking the stopped tasks. """ for task in self._periodic_tasks: task.stop(remove_task=remove_tasks)
[ "Stop", "sending", "any", "messages", "that", "were", "started", "using", "bus", ".", "send_periodic" ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/bus.py#L249-L256
[ "def", "stop_all_periodic_tasks", "(", "self", ",", "remove_tasks", "=", "True", ")", ":", "for", "task", "in", "self", ".", "_periodic_tasks", ":", "task", ".", "stop", "(", "remove_task", "=", "remove_tasks", ")" ]
cdc5254d96072df7739263623f3e920628a7d214
train
BusABC.set_filters
Apply filtering to all messages received by this Bus. All messages that match at least one filter are returned. If `filters` is `None` or a zero length sequence, all messages are matched. Calling without passing any filters will reset the applied filters to `None`. :pa...
can/bus.py
def set_filters(self, filters=None): """Apply filtering to all messages received by this Bus. All messages that match at least one filter are returned. If `filters` is `None` or a zero length sequence, all messages are matched. Calling without passing any filters will reset the...
def set_filters(self, filters=None): """Apply filtering to all messages received by this Bus. All messages that match at least one filter are returned. If `filters` is `None` or a zero length sequence, all messages are matched. Calling without passing any filters will reset the...
[ "Apply", "filtering", "to", "all", "messages", "received", "by", "this", "Bus", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/bus.py#L285-L308
[ "def", "set_filters", "(", "self", ",", "filters", "=", "None", ")", ":", "self", ".", "_filters", "=", "filters", "or", "None", "self", ".", "_apply_filters", "(", "self", ".", "_filters", ")" ]
cdc5254d96072df7739263623f3e920628a7d214
train
BusABC._matches_filters
Checks whether the given message matches at least one of the current filters. See :meth:`~can.BusABC.set_filters` for details on how the filters work. This method should not be overridden. :param can.Message msg: the message to check if matching :rtype: bool ...
can/bus.py
def _matches_filters(self, msg): """Checks whether the given message matches at least one of the current filters. See :meth:`~can.BusABC.set_filters` for details on how the filters work. This method should not be overridden. :param can.Message msg: the message to ch...
def _matches_filters(self, msg): """Checks whether the given message matches at least one of the current filters. See :meth:`~can.BusABC.set_filters` for details on how the filters work. This method should not be overridden. :param can.Message msg: the message to ch...
[ "Checks", "whether", "the", "given", "message", "matches", "at", "least", "one", "of", "the", "current", "filters", ".", "See", ":", "meth", ":", "~can", ".", "BusABC", ".", "set_filters", "for", "details", "on", "how", "the", "filters", "work", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/bus.py#L320-L354
[ "def", "_matches_filters", "(", "self", ",", "msg", ")", ":", "# if no filters are set, all messages are matched", "if", "self", ".", "_filters", "is", "None", ":", "return", "True", "for", "_filter", "in", "self", ".", "_filters", ":", "# check if this filter even ...
cdc5254d96072df7739263623f3e920628a7d214
train
check_valid_rx_can_msg
Checks if function :meth:`UcanServer.read_can_msg` returns a valid CAN message. :param ReturnCode result: Error code of the function. :return: True if a valid CAN messages was received, otherwise False. :rtype: bool
can/interfaces/systec/ucan.py
def check_valid_rx_can_msg(result): """ Checks if function :meth:`UcanServer.read_can_msg` returns a valid CAN message. :param ReturnCode result: Error code of the function. :return: True if a valid CAN messages was received, otherwise False. :rtype: bool """ return (result.value == ReturnC...
def check_valid_rx_can_msg(result): """ Checks if function :meth:`UcanServer.read_can_msg` returns a valid CAN message. :param ReturnCode result: Error code of the function. :return: True if a valid CAN messages was received, otherwise False. :rtype: bool """ return (result.value == ReturnC...
[ "Checks", "if", "function", ":", "meth", ":", "UcanServer", ".", "read_can_msg", "returns", "a", "valid", "CAN", "message", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L16-L24
[ "def", "check_valid_rx_can_msg", "(", "result", ")", ":", "return", "(", "result", ".", "value", "==", "ReturnCode", ".", "SUCCESSFUL", ")", "or", "(", "result", ".", "value", ">", "ReturnCode", ".", "WARNING", ")" ]
cdc5254d96072df7739263623f3e920628a7d214
train
check_tx_ok
Checks if function :meth:`UcanServer.write_can_msg` successfully wrote CAN message(s). While using :meth:`UcanServer.write_can_msg_ex` the number of sent CAN messages can be less than the number of CAN messages which should be sent. :param ReturnCode result: Error code of the function. :return: True i...
can/interfaces/systec/ucan.py
def check_tx_ok(result): """ Checks if function :meth:`UcanServer.write_can_msg` successfully wrote CAN message(s). While using :meth:`UcanServer.write_can_msg_ex` the number of sent CAN messages can be less than the number of CAN messages which should be sent. :param ReturnCode result: Error code...
def check_tx_ok(result): """ Checks if function :meth:`UcanServer.write_can_msg` successfully wrote CAN message(s). While using :meth:`UcanServer.write_can_msg_ex` the number of sent CAN messages can be less than the number of CAN messages which should be sent. :param ReturnCode result: Error code...
[ "Checks", "if", "function", ":", "meth", ":", "UcanServer", ".", "write_can_msg", "successfully", "wrote", "CAN", "message", "(", "s", ")", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L27-L40
[ "def", "check_tx_ok", "(", "result", ")", ":", "return", "(", "result", ".", "value", "==", "ReturnCode", ".", "SUCCESSFUL", ")", "or", "(", "result", ".", "value", ">", "ReturnCode", ".", "WARNING", ")" ]
cdc5254d96072df7739263623f3e920628a7d214
train
check_error
Checks if any function returns an error from USB-CAN-library. :param ReturnCode result: Error code of the function. :return: True if a function returned error, otherwise False. :rtype: bool
can/interfaces/systec/ucan.py
def check_error(result): """ Checks if any function returns an error from USB-CAN-library. :param ReturnCode result: Error code of the function. :return: True if a function returned error, otherwise False. :rtype: bool """ return (result.value != ReturnCode.SUCCESSFUL) and (result.value < R...
def check_error(result): """ Checks if any function returns an error from USB-CAN-library. :param ReturnCode result: Error code of the function. :return: True if a function returned error, otherwise False. :rtype: bool """ return (result.value != ReturnCode.SUCCESSFUL) and (result.value < R...
[ "Checks", "if", "any", "function", "returns", "an", "error", "from", "USB", "-", "CAN", "-", "library", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L76-L84
[ "def", "check_error", "(", "result", ")", ":", "return", "(", "result", ".", "value", "!=", "ReturnCode", ".", "SUCCESSFUL", ")", "and", "(", "result", ".", "value", "<", "ReturnCode", ".", "WARNING", ")" ]
cdc5254d96072df7739263623f3e920628a7d214
train
check_error_cmd
Checks if any function returns an error from firmware in USB-CANmodul. :param ReturnCode result: Error code of the function. :return: True if a function returned error from firmware, otherwise False. :rtype: bool
can/interfaces/systec/ucan.py
def check_error_cmd(result): """ Checks if any function returns an error from firmware in USB-CANmodul. :param ReturnCode result: Error code of the function. :return: True if a function returned error from firmware, otherwise False. :rtype: bool """ return (result.value >= ReturnCode.ERRCMD...
def check_error_cmd(result): """ Checks if any function returns an error from firmware in USB-CANmodul. :param ReturnCode result: Error code of the function. :return: True if a function returned error from firmware, otherwise False. :rtype: bool """ return (result.value >= ReturnCode.ERRCMD...
[ "Checks", "if", "any", "function", "returns", "an", "error", "from", "firmware", "in", "USB", "-", "CANmodul", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L87-L95
[ "def", "check_error_cmd", "(", "result", ")", ":", "return", "(", "result", ".", "value", ">=", "ReturnCode", ".", "ERRCMD", ")", "and", "(", "result", ".", "value", "<", "ReturnCode", ".", "WARNING", ")" ]
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.init_hardware
Initializes the device with the corresponding serial or device number. :param int or None serial: Serial number of the USB-CANmodul. :param int device_number: Device number (0 – 254, or :const:`ANY_MODULE` for the first device).
can/interfaces/systec/ucan.py
def init_hardware(self, serial=None, device_number=ANY_MODULE): """ Initializes the device with the corresponding serial or device number. :param int or None serial: Serial number of the USB-CANmodul. :param int device_number: Device number (0 – 254, or :const:`ANY_MODULE` for the first...
def init_hardware(self, serial=None, device_number=ANY_MODULE): """ Initializes the device with the corresponding serial or device number. :param int or None serial: Serial number of the USB-CANmodul. :param int device_number: Device number (0 – 254, or :const:`ANY_MODULE` for the first...
[ "Initializes", "the", "device", "with", "the", "corresponding", "serial", "or", "device", "number", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L358-L371
[ "def", "init_hardware", "(", "self", ",", "serial", "=", "None", ",", "device_number", "=", "ANY_MODULE", ")", ":", "if", "not", "self", ".", "_hw_is_initialized", ":", "# initialize hardware either by device number or serial", "if", "serial", "is", "None", ":", "...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.init_can
Initializes a specific CAN channel of a device. :param int channel: CAN channel to be initialized (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int BTR: Baud rate register BTR0 as high byte, baud rate register BTR1 as low byte (see enum :class:`Baudrate`). :pa...
can/interfaces/systec/ucan.py
def init_can(self, channel=Channel.CHANNEL_CH0, BTR=Baudrate.BAUD_1MBit, baudrate=BaudrateEx.BAUDEX_USE_BTR01, AMR=AMR_ALL, ACR=ACR_ALL, mode=Mode.MODE_NORMAL, OCR=OutputControl.OCR_DEFAULT, rx_buffer_entries=DEFAULT_BUFFER_ENTRIES, tx_buffer_entries=DEFAULT_BUFFER_ENTRIES): ""...
def init_can(self, channel=Channel.CHANNEL_CH0, BTR=Baudrate.BAUD_1MBit, baudrate=BaudrateEx.BAUDEX_USE_BTR01, AMR=AMR_ALL, ACR=ACR_ALL, mode=Mode.MODE_NORMAL, OCR=OutputControl.OCR_DEFAULT, rx_buffer_entries=DEFAULT_BUFFER_ENTRIES, tx_buffer_entries=DEFAULT_BUFFER_ENTRIES): ""...
[ "Initializes", "a", "specific", "CAN", "channel", "of", "a", "device", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L373-L393
[ "def", "init_can", "(", "self", ",", "channel", "=", "Channel", ".", "CHANNEL_CH0", ",", "BTR", "=", "Baudrate", ".", "BAUD_1MBit", ",", "baudrate", "=", "BaudrateEx", ".", "BAUDEX_USE_BTR01", ",", "AMR", "=", "AMR_ALL", ",", "ACR", "=", "ACR_ALL", ",", ...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.read_can_msg
Reads one or more CAN-messages from the buffer of the specified CAN channel. :param int channel: CAN channel to read from (:data:`Channel.CHANNEL_CH0`, :data:`Channel.CHANNEL_CH1`, :data:`Channel.CHANNEL_ANY`). :param int count: The number of CAN messages to be received. ...
can/interfaces/systec/ucan.py
def read_can_msg(self, channel, count): """ Reads one or more CAN-messages from the buffer of the specified CAN channel. :param int channel: CAN channel to read from (:data:`Channel.CHANNEL_CH0`, :data:`Channel.CHANNEL_CH1`, :data:`Channel.CHANNEL_ANY`). :param i...
def read_can_msg(self, channel, count): """ Reads one or more CAN-messages from the buffer of the specified CAN channel. :param int channel: CAN channel to read from (:data:`Channel.CHANNEL_CH0`, :data:`Channel.CHANNEL_CH1`, :data:`Channel.CHANNEL_ANY`). :param i...
[ "Reads", "one", "or", "more", "CAN", "-", "messages", "from", "the", "buffer", "of", "the", "specified", "CAN", "channel", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L395-L410
[ "def", "read_can_msg", "(", "self", ",", "channel", ",", "count", ")", ":", "c_channel", "=", "BYTE", "(", "channel", ")", "c_can_msg", "=", "(", "CanMsg", "*", "count", ")", "(", ")", "c_count", "=", "DWORD", "(", "count", ")", "UcanReadCanMsgEx", "("...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.write_can_msg
Transmits one ore more CAN messages through the specified CAN channel of the device. :param int channel: CAN channel, which is to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param list(CanMsg) can_msg: List of CAN message structure (see structure :class:`CanMsg`)....
can/interfaces/systec/ucan.py
def write_can_msg(self, channel, can_msg): """ Transmits one ore more CAN messages through the specified CAN channel of the device. :param int channel: CAN channel, which is to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param list(CanMsg) can_msg:...
def write_can_msg(self, channel, can_msg): """ Transmits one ore more CAN messages through the specified CAN channel of the device. :param int channel: CAN channel, which is to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param list(CanMsg) can_msg:...
[ "Transmits", "one", "ore", "more", "CAN", "messages", "through", "the", "specified", "CAN", "channel", "of", "the", "device", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L412-L425
[ "def", "write_can_msg", "(", "self", ",", "channel", ",", "can_msg", ")", ":", "c_can_msg", "=", "(", "CanMsg", "*", "len", "(", "can_msg", ")", ")", "(", "*", "can_msg", ")", "c_count", "=", "DWORD", "(", "len", "(", "can_msg", ")", ")", "UcanWriteC...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.set_baudrate
This function is used to configure the baud rate of specific CAN channel of a device. :param int channel: CAN channel, which is to be configured (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int BTR: Baud rate register BTR0 as high byte, baud rate register...
can/interfaces/systec/ucan.py
def set_baudrate(self, channel, BTR, baudarate): """ This function is used to configure the baud rate of specific CAN channel of a device. :param int channel: CAN channel, which is to be configured (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int BTR:...
def set_baudrate(self, channel, BTR, baudarate): """ This function is used to configure the baud rate of specific CAN channel of a device. :param int channel: CAN channel, which is to be configured (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int BTR:...
[ "This", "function", "is", "used", "to", "configure", "the", "baud", "rate", "of", "specific", "CAN", "channel", "of", "a", "device", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L427-L437
[ "def", "set_baudrate", "(", "self", ",", "channel", ",", "BTR", ",", "baudarate", ")", ":", "UcanSetBaudrateEx", "(", "self", ".", "_handle", ",", "channel", ",", "BTR", ">>", "8", ",", "BTR", ",", "baudarate", ")" ]
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.set_acceptance
This function is used to change the acceptance filter values for a specific CAN channel on a device. :param int channel: CAN channel, which is to be configured (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int AMR: Acceptance filter mask (AMR). :param int ACR:...
can/interfaces/systec/ucan.py
def set_acceptance(self, channel=Channel.CHANNEL_CH0, AMR=AMR_ALL, ACR=ACR_ALL): """ This function is used to change the acceptance filter values for a specific CAN channel on a device. :param int channel: CAN channel, which is to be configured (:data:`Channel.CHANNEL_CH0` or :data:...
def set_acceptance(self, channel=Channel.CHANNEL_CH0, AMR=AMR_ALL, ACR=ACR_ALL): """ This function is used to change the acceptance filter values for a specific CAN channel on a device. :param int channel: CAN channel, which is to be configured (:data:`Channel.CHANNEL_CH0` or :data:...
[ "This", "function", "is", "used", "to", "change", "the", "acceptance", "filter", "values", "for", "a", "specific", "CAN", "channel", "on", "a", "device", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L439-L448
[ "def", "set_acceptance", "(", "self", ",", "channel", "=", "Channel", ".", "CHANNEL_CH0", ",", "AMR", "=", "AMR_ALL", ",", "ACR", "=", "ACR_ALL", ")", ":", "UcanSetAcceptanceEx", "(", "self", ".", "_handle", ",", "channel", ",", "AMR", ",", "ACR", ")" ]
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.get_status
Returns the error status of a specific CAN channel. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :return: Tuple with CAN and USB status (see structure :class:`Status`). :rtype: tuple(int, int)
can/interfaces/systec/ucan.py
def get_status(self, channel=Channel.CHANNEL_CH0): """ Returns the error status of a specific CAN channel. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :return: Tuple with CAN and USB status (see structure :class:`Status`). ...
def get_status(self, channel=Channel.CHANNEL_CH0): """ Returns the error status of a specific CAN channel. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :return: Tuple with CAN and USB status (see structure :class:`Status`). ...
[ "Returns", "the", "error", "status", "of", "a", "specific", "CAN", "channel", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L450-L460
[ "def", "get_status", "(", "self", ",", "channel", "=", "Channel", ".", "CHANNEL_CH0", ")", ":", "status", "=", "Status", "(", ")", "UcanGetStatusEx", "(", "self", ".", "_handle", ",", "channel", ",", "byref", "(", "status", ")", ")", "return", "status", ...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.get_msg_count_info
Reads the message counters of the specified CAN channel. :param int channel: CAN channel, which is to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :return: Tuple with number of CAN messages sent and received. :rtype: tuple(int, int)
can/interfaces/systec/ucan.py
def get_msg_count_info(self, channel=Channel.CHANNEL_CH0): """ Reads the message counters of the specified CAN channel. :param int channel: CAN channel, which is to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :return: Tuple with number of CAN messag...
def get_msg_count_info(self, channel=Channel.CHANNEL_CH0): """ Reads the message counters of the specified CAN channel. :param int channel: CAN channel, which is to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :return: Tuple with number of CAN messag...
[ "Reads", "the", "message", "counters", "of", "the", "specified", "CAN", "channel", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L462-L473
[ "def", "get_msg_count_info", "(", "self", ",", "channel", "=", "Channel", ".", "CHANNEL_CH0", ")", ":", "msg_count_info", "=", "MsgCountInfo", "(", ")", "UcanGetMsgCountInfoEx", "(", "self", ".", "_handle", ",", "channel", ",", "byref", "(", "msg_count_info", ...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.reset_can
Resets a CAN channel of a device (hardware reset, empty buffer, and so on). :param int channel: CAN channel, to be reset (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int flags: Flags defines what should be reset (see enum :class:`ResetFlags`).
can/interfaces/systec/ucan.py
def reset_can(self, channel=Channel.CHANNEL_CH0, flags=ResetFlags.RESET_ALL): """ Resets a CAN channel of a device (hardware reset, empty buffer, and so on). :param int channel: CAN channel, to be reset (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int flags: Flag...
def reset_can(self, channel=Channel.CHANNEL_CH0, flags=ResetFlags.RESET_ALL): """ Resets a CAN channel of a device (hardware reset, empty buffer, and so on). :param int channel: CAN channel, to be reset (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int flags: Flag...
[ "Resets", "a", "CAN", "channel", "of", "a", "device", "(", "hardware", "reset", "empty", "buffer", "and", "so", "on", ")", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L475-L482
[ "def", "reset_can", "(", "self", ",", "channel", "=", "Channel", ".", "CHANNEL_CH0", ",", "flags", "=", "ResetFlags", ".", "RESET_ALL", ")", ":", "UcanResetCanEx", "(", "self", ".", "_handle", ",", "channel", ",", "flags", ")" ]
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.get_hardware_info
Returns the extended hardware information of a device. With multi-channel USB-CANmoduls the information for both CAN channels are returned separately. :return: Tuple with extended hardware information structure (see structure :class:`HardwareInfoEx`) and structures with informat...
can/interfaces/systec/ucan.py
def get_hardware_info(self): """ Returns the extended hardware information of a device. With multi-channel USB-CANmoduls the information for both CAN channels are returned separately. :return: Tuple with extended hardware information structure (see structure :class:`Hardware...
def get_hardware_info(self): """ Returns the extended hardware information of a device. With multi-channel USB-CANmoduls the information for both CAN channels are returned separately. :return: Tuple with extended hardware information structure (see structure :class:`Hardware...
[ "Returns", "the", "extended", "hardware", "information", "of", "a", "device", ".", "With", "multi", "-", "channel", "USB", "-", "CANmoduls", "the", "information", "for", "both", "CAN", "channels", "are", "returned", "separately", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L484-L497
[ "def", "get_hardware_info", "(", "self", ")", ":", "hw_info_ex", "=", "HardwareInfoEx", "(", ")", "can_info_ch0", ",", "can_info_ch1", "=", "ChannelInfo", "(", ")", ",", "ChannelInfo", "(", ")", "UcanGetHardwareInfoEx2", "(", "self", ".", "_handle", ",", "byre...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.define_cyclic_can_msg
Defines a list of CAN messages for automatic transmission. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param list(CanMsg) can_msg: List of CAN messages (up to 16, see structure :class:`CanMsg`), or None to delete an older list.
can/interfaces/systec/ucan.py
def define_cyclic_can_msg(self, channel, can_msg=None): """ Defines a list of CAN messages for automatic transmission. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param list(CanMsg) can_msg: List of CAN messages ...
def define_cyclic_can_msg(self, channel, can_msg=None): """ Defines a list of CAN messages for automatic transmission. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param list(CanMsg) can_msg: List of CAN messages ...
[ "Defines", "a", "list", "of", "CAN", "messages", "for", "automatic", "transmission", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L508-L522
[ "def", "define_cyclic_can_msg", "(", "self", ",", "channel", ",", "can_msg", "=", "None", ")", ":", "if", "can_msg", "is", "not", "None", ":", "c_can_msg", "=", "(", "CanMsg", "*", "len", "(", "can_msg", ")", ")", "(", "*", "can_msg", ")", "c_count", ...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.read_cyclic_can_msg
Reads back the list of CAN messages for automatically sending. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int count: The number of cyclic CAN messages to be received. :return: List of received CAN messages (up to 16, see stru...
can/interfaces/systec/ucan.py
def read_cyclic_can_msg(self, channel, count): """ Reads back the list of CAN messages for automatically sending. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int count: The number of cyclic CAN messages to be received....
def read_cyclic_can_msg(self, channel, count): """ Reads back the list of CAN messages for automatically sending. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int count: The number of cyclic CAN messages to be received....
[ "Reads", "back", "the", "list", "of", "CAN", "messages", "for", "automatically", "sending", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L524-L537
[ "def", "read_cyclic_can_msg", "(", "self", ",", "channel", ",", "count", ")", ":", "c_channel", "=", "BYTE", "(", "channel", ")", "c_can_msg", "=", "(", "CanMsg", "*", "count", ")", "(", ")", "c_count", "=", "DWORD", "(", "count", ")", "UcanReadCyclicCan...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.get_msg_pending
Returns the number of pending CAN messages. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int flags: Flags specifies which buffers should be checked (see enum :class:`PendingFlags`). :return: The number of pending messages. ...
can/interfaces/systec/ucan.py
def get_msg_pending(self, channel, flags): """ Returns the number of pending CAN messages. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int flags: Flags specifies which buffers should be checked (see enum :class:`Pendin...
def get_msg_pending(self, channel, flags): """ Returns the number of pending CAN messages. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param int flags: Flags specifies which buffers should be checked (see enum :class:`Pendin...
[ "Returns", "the", "number", "of", "pending", "CAN", "messages", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L548-L559
[ "def", "get_msg_pending", "(", "self", ",", "channel", ",", "flags", ")", ":", "count", "=", "DWORD", "(", "0", ")", "UcanGetMsgPending", "(", "self", ".", "_handle", ",", "channel", ",", "flags", ",", "byref", "(", "count", ")", ")", "return", "count"...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.get_can_error_counter
Reads the current value of the error counters within the CAN controller. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :return: Tuple with the TX and RX error counter. :rtype: tuple(int, int) .. note:: Only available for syste...
can/interfaces/systec/ucan.py
def get_can_error_counter(self, channel): """ Reads the current value of the error counters within the CAN controller. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :return: Tuple with the TX and RX error counter. :rtyp...
def get_can_error_counter(self, channel): """ Reads the current value of the error counters within the CAN controller. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :return: Tuple with the TX and RX error counter. :rtyp...
[ "Reads", "the", "current", "value", "of", "the", "error", "counters", "within", "the", "CAN", "controller", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L561-L574
[ "def", "get_can_error_counter", "(", "self", ",", "channel", ")", ":", "tx_error_counter", "=", "DWORD", "(", "0", ")", "rx_error_counter", "=", "DWORD", "(", "0", ")", "UcanGetCanErrorCounter", "(", "self", ".", "_handle", ",", "channel", ",", "byref", "(",...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.set_tx_timeout
Sets the transmission timeout. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param float timeout: Transmit timeout in seconds (value 0 disables this feature).
can/interfaces/systec/ucan.py
def set_tx_timeout(self, channel, timeout): """ Sets the transmission timeout. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param float timeout: Transmit timeout in seconds (value 0 disables this feature). """ ...
def set_tx_timeout(self, channel, timeout): """ Sets the transmission timeout. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0` or :data:`Channel.CHANNEL_CH1`). :param float timeout: Transmit timeout in seconds (value 0 disables this feature). """ ...
[ "Sets", "the", "transmission", "timeout", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L576-L583
[ "def", "set_tx_timeout", "(", "self", ",", "channel", ",", "timeout", ")", ":", "UcanSetTxTimeout", "(", "self", ".", "_handle", ",", "channel", ",", "int", "(", "timeout", "*", "1000", ")", ")" ]
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.shutdown
Shuts down all CAN interfaces and/or the hardware interface. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0`, :data:`Channel.CHANNEL_CH1` or :data:`Channel.CHANNEL_ALL`) :param bool shutdown_hardware: If true then the hardware interface will be closed to...
can/interfaces/systec/ucan.py
def shutdown(self, channel=Channel.CHANNEL_ALL, shutdown_hardware=True): """ Shuts down all CAN interfaces and/or the hardware interface. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0`, :data:`Channel.CHANNEL_CH1` or :data:`Channel.CHANNEL_ALL`)...
def shutdown(self, channel=Channel.CHANNEL_ALL, shutdown_hardware=True): """ Shuts down all CAN interfaces and/or the hardware interface. :param int channel: CAN channel, to be used (:data:`Channel.CHANNEL_CH0`, :data:`Channel.CHANNEL_CH1` or :data:`Channel.CHANNEL_ALL`)...
[ "Shuts", "down", "all", "CAN", "interfaces", "and", "/", "or", "the", "hardware", "interface", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L585-L604
[ "def", "shutdown", "(", "self", ",", "channel", "=", "Channel", ".", "CHANNEL_ALL", ",", "shutdown_hardware", "=", "True", ")", ":", "# shutdown each channel if it's initialized", "for", "_channel", ",", "is_initialized", "in", "self", ".", "_ch_is_initialized", "."...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.get_can_status_message
Converts a given CAN status value to the appropriate message string. :param can_status: CAN status value from method :meth:`get_status` (see enum :class:`CanStatus`) :return: Status message string. :rtype: str
can/interfaces/systec/ucan.py
def get_can_status_message(can_status): """ Converts a given CAN status value to the appropriate message string. :param can_status: CAN status value from method :meth:`get_status` (see enum :class:`CanStatus`) :return: Status message string. :rtype: str """ statu...
def get_can_status_message(can_status): """ Converts a given CAN status value to the appropriate message string. :param can_status: CAN status value from method :meth:`get_status` (see enum :class:`CanStatus`) :return: Status message string. :rtype: str """ statu...
[ "Converts", "a", "given", "CAN", "status", "value", "to", "the", "appropriate", "message", "string", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L633-L655
[ "def", "get_can_status_message", "(", "can_status", ")", ":", "status_msgs", "=", "{", "CanStatus", ".", "CANERR_TXMSGLOST", ":", "\"Transmit message lost\"", ",", "CanStatus", ".", "CANERR_MEMTEST", ":", "\"Memory test failed\"", ",", "CanStatus", ".", "CANERR_REGTEST"...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.get_baudrate_message
Converts a given baud rate value for GW-001/GW-002 to the appropriate message string. :param Baudrate baudrate: Bus Timing Registers, BTR0 in high order byte and BTR1 in low order byte (see enum :class:`Baudrate`) :return: Baud rate message string. :rtype: str
can/interfaces/systec/ucan.py
def get_baudrate_message(baudrate): """ Converts a given baud rate value for GW-001/GW-002 to the appropriate message string. :param Baudrate baudrate: Bus Timing Registers, BTR0 in high order byte and BTR1 in low order byte (see enum :class:`Baudrate`) :return: ...
def get_baudrate_message(baudrate): """ Converts a given baud rate value for GW-001/GW-002 to the appropriate message string. :param Baudrate baudrate: Bus Timing Registers, BTR0 in high order byte and BTR1 in low order byte (see enum :class:`Baudrate`) :return: ...
[ "Converts", "a", "given", "baud", "rate", "value", "for", "GW", "-", "001", "/", "GW", "-", "002", "to", "the", "appropriate", "message", "string", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L658-L681
[ "def", "get_baudrate_message", "(", "baudrate", ")", ":", "baudrate_msgs", "=", "{", "Baudrate", ".", "BAUD_AUTO", ":", "\"auto baudrate\"", ",", "Baudrate", ".", "BAUD_10kBit", ":", "\"10 kBit/sec\"", ",", "Baudrate", ".", "BAUD_20kBit", ":", "\"20 kBit/sec\"", "...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.get_baudrate_ex_message
Converts a given baud rate value for systec USB-CANmoduls to the appropriate message string. :param BaudrateEx baudrate_ex: Bus Timing Registers (see enum :class:`BaudrateEx`) :return: Baud rate message string. :rtype: str
can/interfaces/systec/ucan.py
def get_baudrate_ex_message(baudrate_ex): """ Converts a given baud rate value for systec USB-CANmoduls to the appropriate message string. :param BaudrateEx baudrate_ex: Bus Timing Registers (see enum :class:`BaudrateEx`) :return: Baud rate message string. :rtype: str ""...
def get_baudrate_ex_message(baudrate_ex): """ Converts a given baud rate value for systec USB-CANmoduls to the appropriate message string. :param BaudrateEx baudrate_ex: Bus Timing Registers (see enum :class:`BaudrateEx`) :return: Baud rate message string. :rtype: str ""...
[ "Converts", "a", "given", "baud", "rate", "value", "for", "systec", "USB", "-", "CANmoduls", "to", "the", "appropriate", "message", "string", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L684-L714
[ "def", "get_baudrate_ex_message", "(", "baudrate_ex", ")", ":", "baudrate_ex_msgs", "=", "{", "Baudrate", ".", "BAUDEX_AUTO", ":", "\"auto baudrate\"", ",", "Baudrate", ".", "BAUDEX_10kBit", ":", "\"10 kBit/sec\"", ",", "Baudrate", ".", "BAUDEX_SP2_10kBit", ":", "\"...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.check_version_is_equal_or_higher
Checks if the version is equal or higher than a specified value. :param int version: Version number to be checked. :param int cmp_major: Major version to be compared with. :param int cmp_minor: Minor version to be compared with. :return: True if equal or higher, otherwise False. ...
can/interfaces/systec/ucan.py
def check_version_is_equal_or_higher(cls, version, cmp_major, cmp_minor): """ Checks if the version is equal or higher than a specified value. :param int version: Version number to be checked. :param int cmp_major: Major version to be compared with. :param int cmp_minor: Minor v...
def check_version_is_equal_or_higher(cls, version, cmp_major, cmp_minor): """ Checks if the version is equal or higher than a specified value. :param int version: Version number to be checked. :param int cmp_major: Major version to be compared with. :param int cmp_minor: Minor v...
[ "Checks", "if", "the", "version", "is", "equal", "or", "higher", "than", "a", "specified", "value", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L768-L779
[ "def", "check_version_is_equal_or_higher", "(", "cls", ",", "version", ",", "cmp_major", ",", "cmp_minor", ")", ":", "return", "(", "cls", ".", "convert_to_major_ver", "(", "version", ")", ">", "cmp_major", ")", "or", "(", "cls", ".", "convert_to_major_ver", "...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.check_support_cyclic_msg
Checks whether the module supports automatically transmission of cyclic CAN messages. :param HardwareInfoEx hw_info_ex: Extended hardware information structure (see method :meth:`get_hardware_info`). :return: True when the module does support cyclic CAN messages, otherwise False. :r...
can/interfaces/systec/ucan.py
def check_support_cyclic_msg(cls, hw_info_ex): """ Checks whether the module supports automatically transmission of cyclic CAN messages. :param HardwareInfoEx hw_info_ex: Extended hardware information structure (see method :meth:`get_hardware_info`). :return: True when the m...
def check_support_cyclic_msg(cls, hw_info_ex): """ Checks whether the module supports automatically transmission of cyclic CAN messages. :param HardwareInfoEx hw_info_ex: Extended hardware information structure (see method :meth:`get_hardware_info`). :return: True when the m...
[ "Checks", "whether", "the", "module", "supports", "automatically", "transmission", "of", "cyclic", "CAN", "messages", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L818-L828
[ "def", "check_support_cyclic_msg", "(", "cls", ",", "hw_info_ex", ")", ":", "return", "cls", ".", "check_is_systec", "(", "hw_info_ex", ")", "and", "cls", ".", "check_version_is_equal_or_higher", "(", "hw_info_ex", ".", "m_dwFwVersionEx", ",", "3", ",", "6", ")"...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.check_support_user_port
Checks whether the module supports a user I/O port. :param HardwareInfoEx hw_info_ex: Extended hardware information structure (see method :meth:`get_hardware_info`). :return: True when the module supports a user I/O port, otherwise False. :rtype: bool
can/interfaces/systec/ucan.py
def check_support_user_port(cls, hw_info_ex): """ Checks whether the module supports a user I/O port. :param HardwareInfoEx hw_info_ex: Extended hardware information structure (see method :meth:`get_hardware_info`). :return: True when the module supports a user I/O port, oth...
def check_support_user_port(cls, hw_info_ex): """ Checks whether the module supports a user I/O port. :param HardwareInfoEx hw_info_ex: Extended hardware information structure (see method :meth:`get_hardware_info`). :return: True when the module supports a user I/O port, oth...
[ "Checks", "whether", "the", "module", "supports", "a", "user", "I", "/", "O", "port", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L855-L866
[ "def", "check_support_user_port", "(", "cls", ",", "hw_info_ex", ")", ":", "return", "(", "(", "hw_info_ex", ".", "m_dwProductCode", "&", "PRODCODE_MASK_PID", ")", "!=", "ProductCode", ".", "PRODCODE_PID_BASIC", ")", "and", "(", "(", "hw_info_ex", ".", "m_dwProd...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.check_support_ucannet
Checks whether the module supports the usage of USB-CANnetwork driver. :param HardwareInfoEx hw_info_ex: Extended hardware information structure (see method :meth:`get_hardware_info`). :return: True when the module does support the usage of the USB-CANnetwork driver, otherwise False. ...
can/interfaces/systec/ucan.py
def check_support_ucannet(cls, hw_info_ex): """ Checks whether the module supports the usage of USB-CANnetwork driver. :param HardwareInfoEx hw_info_ex: Extended hardware information structure (see method :meth:`get_hardware_info`). :return: True when the module does support...
def check_support_ucannet(cls, hw_info_ex): """ Checks whether the module supports the usage of USB-CANnetwork driver. :param HardwareInfoEx hw_info_ex: Extended hardware information structure (see method :meth:`get_hardware_info`). :return: True when the module does support...
[ "Checks", "whether", "the", "module", "supports", "the", "usage", "of", "USB", "-", "CANnetwork", "driver", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L893-L903
[ "def", "check_support_ucannet", "(", "cls", ",", "hw_info_ex", ")", ":", "return", "cls", ".", "check_is_systec", "(", "hw_info_ex", ")", "and", "cls", ".", "check_version_is_equal_or_higher", "(", "hw_info_ex", ".", "m_dwFwVersionEx", ",", "3", ",", "8", ")" ]
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer.calculate_amr
Calculates AMR using CAN-ID range as parameter. :param bool is_extended: If True parameters from_id and to_id contains 29-bit CAN-ID. :param int from_id: First CAN-ID which should be received. :param int to_id: Last CAN-ID which should be received. :param bool rtr_only: If True only RTR...
can/interfaces/systec/ucan.py
def calculate_amr(cls, is_extended, from_id, to_id, rtr_only=False, rtr_too=True): """ Calculates AMR using CAN-ID range as parameter. :param bool is_extended: If True parameters from_id and to_id contains 29-bit CAN-ID. :param int from_id: First CAN-ID which should be received. ...
def calculate_amr(cls, is_extended, from_id, to_id, rtr_only=False, rtr_too=True): """ Calculates AMR using CAN-ID range as parameter. :param bool is_extended: If True parameters from_id and to_id contains 29-bit CAN-ID. :param int from_id: First CAN-ID which should be received. ...
[ "Calculates", "AMR", "using", "CAN", "-", "ID", "range", "as", "parameter", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L906-L919
[ "def", "calculate_amr", "(", "cls", ",", "is_extended", ",", "from_id", ",", "to_id", ",", "rtr_only", "=", "False", ",", "rtr_too", "=", "True", ")", ":", "return", "(", "(", "(", "from_id", "^", "to_id", ")", "<<", "3", ")", "|", "(", "0x7", "if"...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer._connect_control
Is the actual callback function for :meth:`init_hw_connect_control_ex`. :param event: Event (:data:`CbEvent.EVENT_CONNECT`, :data:`CbEvent.EVENT_DISCONNECT` or :data:`CbEvent.EVENT_FATALDISCON`). :param param: Additional parameter depending on the event. - CbEvent.EVENT_...
can/interfaces/systec/ucan.py
def _connect_control(self, event, param, arg): """ Is the actual callback function for :meth:`init_hw_connect_control_ex`. :param event: Event (:data:`CbEvent.EVENT_CONNECT`, :data:`CbEvent.EVENT_DISCONNECT` or :data:`CbEvent.EVENT_FATALDISCON`). :param param: Ad...
def _connect_control(self, event, param, arg): """ Is the actual callback function for :meth:`init_hw_connect_control_ex`. :param event: Event (:data:`CbEvent.EVENT_CONNECT`, :data:`CbEvent.EVENT_DISCONNECT` or :data:`CbEvent.EVENT_FATALDISCON`). :param param: Ad...
[ "Is", "the", "actual", "callback", "function", "for", ":", "meth", ":", "init_hw_connect_control_ex", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L937-L957
[ "def", "_connect_control", "(", "self", ",", "event", ",", "param", ",", "arg", ")", ":", "log", ".", "debug", "(", "\"Event: %s, Param: %s\"", "%", "(", "event", ",", "param", ")", ")", "if", "event", "==", "CbEvent", ".", "EVENT_FATALDISCON", ":", "sel...
cdc5254d96072df7739263623f3e920628a7d214
train
UcanServer._callback
Is called if a working event occurred. :param int handle: USB-CAN-Handle returned by the function :meth:`init_hardware`. :param int event: Event type. :param int channel: CAN channel (:data:`Channel.CHANNEL_CH0`, :data:`Channel.CHANNEL_CH1` or :data:`Channel.CHANNEL_ANY`). :...
can/interfaces/systec/ucan.py
def _callback(self, handle, event, channel, arg): """ Is called if a working event occurred. :param int handle: USB-CAN-Handle returned by the function :meth:`init_hardware`. :param int event: Event type. :param int channel: CAN channel (:data:`Channel.CHANNEL_CH0`, ...
def _callback(self, handle, event, channel, arg): """ Is called if a working event occurred. :param int handle: USB-CAN-Handle returned by the function :meth:`init_hardware`. :param int event: Event type. :param int channel: CAN channel (:data:`Channel.CHANNEL_CH0`, ...
[ "Is", "called", "if", "a", "working", "event", "occurred", "." ]
hardbyte/python-can
python
https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucan.py#L959-L982
[ "def", "_callback", "(", "self", ",", "handle", ",", "event", ",", "channel", ",", "arg", ")", ":", "log", ".", "debug", "(", "\"Handle: %s, Event: %s, Channel: %s\"", "%", "(", "handle", ",", "event", ",", "channel", ")", ")", "if", "event", "==", "CbEv...
cdc5254d96072df7739263623f3e920628a7d214
train
PaletteView.get
Colors API using schema This example is using marshmallow schemas
examples/colors_with_schema.py
def get(self, palette): """ Colors API using schema This example is using marshmallow schemas """ all_colors = { 'cmyk': ['cian', 'magenta', 'yellow', 'black'], 'rgb': ['red', 'green', 'blue'] } if palette == 'all': result = all...
def get(self, palette): """ Colors API using schema This example is using marshmallow schemas """ all_colors = { 'cmyk': ['cian', 'magenta', 'yellow', 'black'], 'rgb': ['red', 'green', 'blue'] } if palette == 'all': result = all...
[ "Colors", "API", "using", "schema", "This", "example", "is", "using", "marshmallow", "schemas" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/examples/colors_with_schema.py#L38-L51
[ "def", "get", "(", "self", ",", "palette", ")", ":", "all_colors", "=", "{", "'cmyk'", ":", "[", "'cian'", ",", "'magenta'", ",", "'yellow'", ",", "'black'", "]", ",", "'rgb'", ":", "[", "'red'", ",", "'green'", ",", "'blue'", "]", "}", "if", "pale...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
drop_id_validate
Custom validation function which drops parameter '_id' if present in data
examples/custom_validation_function.py
def drop_id_validate(data, schema): """ Custom validation function which drops parameter '_id' if present in data """ jsonschema.validate(data, schema) if data.get('_id') is not None: del data['_id']
def drop_id_validate(data, schema): """ Custom validation function which drops parameter '_id' if present in data """ jsonschema.validate(data, schema) if data.get('_id') is not None: del data['_id']
[ "Custom", "validation", "function", "which", "drops", "parameter", "_id", "if", "present", "in", "data" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/examples/custom_validation_function.py#L17-L24
[ "def", "drop_id_validate", "(", "data", ",", "schema", ")", ":", "jsonschema", ".", "validate", "(", "data", ",", "schema", ")", "if", "data", ".", "get", "(", "'_id'", ")", "is", "not", "None", ":", "del", "data", "[", "'_id'", "]" ]
fef154f61d7afca548067be0c758c3dd71cc4c97
train
timestamping_validate
Custom validation function which inserts a timestamp for when the validation occurred
examples/custom_validation_function.py
def timestamping_validate(data, schema): """ Custom validation function which inserts a timestamp for when the validation occurred """ jsonschema.validate(data, schema) data['timestamp'] = str(time.time())
def timestamping_validate(data, schema): """ Custom validation function which inserts a timestamp for when the validation occurred """ jsonschema.validate(data, schema) data['timestamp'] = str(time.time())
[ "Custom", "validation", "function", "which", "inserts", "a", "timestamp", "for", "when", "the", "validation", "occurred" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/examples/custom_validation_function.py#L27-L33
[ "def", "timestamping_validate", "(", "data", ",", "schema", ")", ":", "jsonschema", ".", "validate", "(", "data", ",", "schema", ")", "data", "[", "'timestamp'", "]", "=", "str", "(", "time", ".", "time", "(", ")", ")" ]
fef154f61d7afca548067be0c758c3dd71cc4c97
train
special_validate
Custom validation function which inserts an special flag depending on the cat's name
examples/custom_validation_function.py
def special_validate(data, schema): """ Custom validation function which inserts an special flag depending on the cat's name """ jsonschema.validate(data, schema) data['special'] = str(data['name'] == 'Garfield').lower()
def special_validate(data, schema): """ Custom validation function which inserts an special flag depending on the cat's name """ jsonschema.validate(data, schema) data['special'] = str(data['name'] == 'Garfield').lower()
[ "Custom", "validation", "function", "which", "inserts", "an", "special", "flag", "depending", "on", "the", "cat", "s", "name" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/examples/custom_validation_function.py#L36-L42
[ "def", "special_validate", "(", "data", ",", "schema", ")", ":", "jsonschema", ".", "validate", "(", "data", ",", "schema", ")", "data", "[", "'special'", "]", "=", "str", "(", "data", "[", "'name'", "]", "==", "'Garfield'", ")", ".", "lower", "(", "...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
validation_error_inform_error
Custom validation error handler which produces 404 Bad Request response in case validation fails and returns the error
examples/validation_error_handler.py
def validation_error_inform_error(err, data, schema): """ Custom validation error handler which produces 404 Bad Request response in case validation fails and returns the error """ abort(Response( json.dumps({'error': str(err), 'data': data, 'schema': schema}), status=HTTPStatus.BAD_...
def validation_error_inform_error(err, data, schema): """ Custom validation error handler which produces 404 Bad Request response in case validation fails and returns the error """ abort(Response( json.dumps({'error': str(err), 'data': data, 'schema': schema}), status=HTTPStatus.BAD_...
[ "Custom", "validation", "error", "handler", "which", "produces", "404", "Bad", "Request", "response", "in", "case", "validation", "fails", "and", "returns", "the", "error" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/examples/validation_error_handler.py#L19-L26
[ "def", "validation_error_inform_error", "(", "err", ",", "data", ",", "schema", ")", ":", "abort", "(", "Response", "(", "json", ".", "dumps", "(", "{", "'error'", ":", "str", "(", "err", ")", ",", "'data'", ":", "data", ",", "'schema'", ":", "schema",...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
validation_error_try_to_accept
Custom validation error handler which attempts alternative validation
examples/validation_error_handler.py
def validation_error_try_to_accept(err, data, schema): """ Custom validation error handler which attempts alternative validation """ if not isinstance(err, ValidationError): abort(Response(err, status=HTTPStatus.BAD_REQUEST)) alernative_schema = dict(schema) alernative_schema['prope...
def validation_error_try_to_accept(err, data, schema): """ Custom validation error handler which attempts alternative validation """ if not isinstance(err, ValidationError): abort(Response(err, status=HTTPStatus.BAD_REQUEST)) alernative_schema = dict(schema) alernative_schema['prope...
[ "Custom", "validation", "error", "handler", "which", "attempts", "alternative", "validation" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/examples/validation_error_handler.py#L37-L55
[ "def", "validation_error_try_to_accept", "(", "err", ",", "data", ",", "schema", ")", ":", "if", "not", "isinstance", "(", "err", ",", "ValidationError", ")", ":", "abort", "(", "Response", "(", "err", ",", "status", "=", "HTTPStatus", ".", "BAD_REQUEST", ...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
convert_schemas
Convert Marshmallow schemas to dict definitions Also updates the optional definitions argument with any definitions entries contained within the schema.
flasgger/marshmallow_apispec.py
def convert_schemas(d, definitions=None): """ Convert Marshmallow schemas to dict definitions Also updates the optional definitions argument with any definitions entries contained within the schema. """ if Schema is None: raise RuntimeError('Please install marshmallow and apispec') ...
def convert_schemas(d, definitions=None): """ Convert Marshmallow schemas to dict definitions Also updates the optional definitions argument with any definitions entries contained within the schema. """ if Schema is None: raise RuntimeError('Please install marshmallow and apispec') ...
[ "Convert", "Marshmallow", "schemas", "to", "dict", "definitions" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/marshmallow_apispec.py#L84-L127
[ "def", "convert_schemas", "(", "d", ",", "definitions", "=", "None", ")", ":", "if", "Schema", "is", "None", ":", "raise", "RuntimeError", "(", "'Please install marshmallow and apispec'", ")", "if", "definitions", "is", "None", ":", "definitions", "=", "{", "}...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
APISpec.to_flasgger
Converts APISpec dict to flasgger suitable dict also adds definitions and paths (optional)
flasgger/marshmallow_apispec.py
def to_flasgger(self, app=None, definitions=None, paths=None): """ Converts APISpec dict to flasgger suitable dict also adds definitions and paths (optional) """ if Schema is None: raise RuntimeError('Please install marshmallow and apispec') return flasgger.u...
def to_flasgger(self, app=None, definitions=None, paths=None): """ Converts APISpec dict to flasgger suitable dict also adds definitions and paths (optional) """ if Schema is None: raise RuntimeError('Please install marshmallow and apispec') return flasgger.u...
[ "Converts", "APISpec", "dict", "to", "flasgger", "suitable", "dict", "also", "adds", "definitions", "and", "paths", "(", "optional", ")" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/marshmallow_apispec.py#L28-L41
[ "def", "to_flasgger", "(", "self", ",", "app", "=", "None", ",", "definitions", "=", "None", ",", "paths", "=", "None", ")", ":", "if", "Schema", "is", "None", ":", "raise", "RuntimeError", "(", "'Please install marshmallow and apispec'", ")", "return", "fla...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
SwaggerView.dispatch_request
If validation=True perform validation
flasgger/marshmallow_apispec.py
def dispatch_request(self, *args, **kwargs): """ If validation=True perform validation """ if self.validation: specs = {} attrs = flasgger.constants.OPTIONAL_FIELDS + [ 'parameters', 'definitions', 'responses', 'summary', 'descripti...
def dispatch_request(self, *args, **kwargs): """ If validation=True perform validation """ if self.validation: specs = {} attrs = flasgger.constants.OPTIONAL_FIELDS + [ 'parameters', 'definitions', 'responses', 'summary', 'descripti...
[ "If", "validation", "=", "True", "perform", "validation" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/marshmallow_apispec.py#L64-L81
[ "def", "dispatch_request", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "validation", ":", "specs", "=", "{", "}", "attrs", "=", "flasgger", ".", "constants", ".", "OPTIONAL_FIELDS", "+", "[", "'parameters'", ","...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
merge_specs
Update target dictionary with values from the source, recursively. List items will be merged.
flasgger/utils.py
def merge_specs(target, source): """ Update target dictionary with values from the source, recursively. List items will be merged. """ for key, value in source.items(): if isinstance(value, dict): node = target.setdefault(key, {}) merge_specs(node, value) eli...
def merge_specs(target, source): """ Update target dictionary with values from the source, recursively. List items will be merged. """ for key, value in source.items(): if isinstance(value, dict): node = target.setdefault(key, {}) merge_specs(node, value) eli...
[ "Update", "target", "dictionary", "with", "values", "from", "the", "source", "recursively", ".", "List", "items", "will", "be", "merged", "." ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L26-L40
[ "def", "merge_specs", "(", "target", ",", "source", ")", ":", "for", "key", ",", "value", "in", "source", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "node", "=", "target", ".", "setdefault", "(", "key", ",...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
swag_from
Takes a filename.yml, a dictionary or object and loads swagger specs. :param specs: a filepath, a dictionary or an object :param filetype: yml or yaml (json and py to be implemented) :param endpoint: endpoint to build definition name :param methods: method to build method based specs :param validat...
flasgger/utils.py
def swag_from( specs=None, filetype=None, endpoint=None, methods=None, validation=False, schema_id=None, data=None, definition=None, validation_function=None, validation_error_handler=None): """ Takes a filename.yml, a dictionary or object and loads swagger specs. :param specs: a fi...
def swag_from( specs=None, filetype=None, endpoint=None, methods=None, validation=False, schema_id=None, data=None, definition=None, validation_function=None, validation_error_handler=None): """ Takes a filename.yml, a dictionary or object and loads swagger specs. :param specs: a fi...
[ "Takes", "a", "filename", ".", "yml", "a", "dictionary", "or", "object", "and", "loads", "swagger", "specs", "." ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L167-L251
[ "def", "swag_from", "(", "specs", "=", "None", ",", "filetype", "=", "None", ",", "endpoint", "=", "None", ",", "methods", "=", "None", ",", "validation", "=", "False", ",", "schema_id", "=", "None", ",", "data", "=", "None", ",", "definition", "=", ...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
validate
This method is available to use YAML swagger definitions file or specs (dict or object) to validate data against its jsonschema. example: validate({"item": 1}, 'item_schema', 'defs.yml', root=__file__) validate(request.json, 'User', specs={'definitions': {'User': ...}}) :param data: data t...
flasgger/utils.py
def validate( data=None, schema_id=None, filepath=None, root=None, definition=None, specs=None, validation_function=None, validation_error_handler=None): """ This method is available to use YAML swagger definitions file or specs (dict or object) to validate data against its jsonschema. ...
def validate( data=None, schema_id=None, filepath=None, root=None, definition=None, specs=None, validation_function=None, validation_error_handler=None): """ This method is available to use YAML swagger definitions file or specs (dict or object) to validate data against its jsonschema. ...
[ "This", "method", "is", "available", "to", "use", "YAML", "swagger", "definitions", "file", "or", "specs", "(", "dict", "or", "object", ")", "to", "validate", "data", "against", "its", "jsonschema", "." ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L254-L368
[ "def", "validate", "(", "data", "=", "None", ",", "schema_id", "=", "None", ",", "filepath", "=", "None", ",", "root", "=", "None", ",", "definition", "=", "None", ",", "specs", "=", "None", ",", "validation_function", "=", "None", ",", "validation_error...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
apispec_to_template
Converts apispec object in to flasgger definitions template :param app: Current app :param spec: apispec.APISpec :param definitions: a list of [Schema, ..] or [('Name', Schema), ..] :param paths: A list of flask views
flasgger/utils.py
def apispec_to_template(app, spec, definitions=None, paths=None): """ Converts apispec object in to flasgger definitions template :param app: Current app :param spec: apispec.APISpec :param definitions: a list of [Schema, ..] or [('Name', Schema), ..] :param paths: A list of flask views """ ...
def apispec_to_template(app, spec, definitions=None, paths=None): """ Converts apispec object in to flasgger definitions template :param app: Current app :param spec: apispec.APISpec :param definitions: a list of [Schema, ..] or [('Name', Schema), ..] :param paths: A list of flask views """ ...
[ "Converts", "apispec", "object", "in", "to", "flasgger", "definitions", "template", ":", "param", "app", ":", "Current", "app", ":", "param", "spec", ":", "apispec", ".", "APISpec", ":", "param", "definitions", ":", "a", "list", "of", "[", "Schema", "..", ...
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L371-L397
[ "def", "apispec_to_template", "(", "app", ",", "spec", ",", "definitions", "=", "None", ",", "paths", "=", "None", ")", ":", "definitions", "=", "definitions", "or", "[", "]", "paths", "=", "paths", "or", "[", "]", "spec_dict", "=", "spec", ".", "to_di...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
ordered_dict_to_dict
Converts inner OrderedDict to bare dict
flasgger/utils.py
def ordered_dict_to_dict(d): """ Converts inner OrderedDict to bare dict """ ret = {} new_d = deepcopy(d) for k, v in new_d.items(): if isinstance(v, OrderedDict): v = dict(v) if isinstance(v, dict): v = ordered_dict_to_dict(v) ret[k] = v retur...
def ordered_dict_to_dict(d): """ Converts inner OrderedDict to bare dict """ ret = {} new_d = deepcopy(d) for k, v in new_d.items(): if isinstance(v, OrderedDict): v = dict(v) if isinstance(v, dict): v = ordered_dict_to_dict(v) ret[k] = v retur...
[ "Converts", "inner", "OrderedDict", "to", "bare", "dict" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L400-L412
[ "def", "ordered_dict_to_dict", "(", "d", ")", ":", "ret", "=", "{", "}", "new_d", "=", "deepcopy", "(", "d", ")", "for", "k", ",", "v", "in", "new_d", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "OrderedDict", ")", ":", "v", ...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
pathify
*nix to python module path
flasgger/utils.py
def pathify(basenames, examples_dir="examples/"): # pragma: no cover """*nix to python module path""" example = examples_dir.replace("/", ".") return [example + basename for basename in basenames]
def pathify(basenames, examples_dir="examples/"): # pragma: no cover """*nix to python module path""" example = examples_dir.replace("/", ".") return [example + basename for basename in basenames]
[ "*", "nix", "to", "python", "module", "path" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L425-L428
[ "def", "pathify", "(", "basenames", ",", "examples_dir", "=", "\"examples/\"", ")", ":", "# pragma: no cover", "example", "=", "examples_dir", ".", "replace", "(", "\"/\"", ",", "\".\"", ")", "return", "[", "example", "+", "basename", "for", "basename", "in", ...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
get_examples
All example modules
flasgger/utils.py
def get_examples(examples_dir="examples/"): # pragma: no cover """All example modules""" all_files = os.listdir(examples_dir) python_files = [f for f in all_files if is_python_file(f)] basenames = [remove_suffix(f) for f in python_files] modules = [import_module(module) for module in pathify(basena...
def get_examples(examples_dir="examples/"): # pragma: no cover """All example modules""" all_files = os.listdir(examples_dir) python_files = [f for f in all_files if is_python_file(f)] basenames = [remove_suffix(f) for f in python_files] modules = [import_module(module) for module in pathify(basena...
[ "All", "example", "modules" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L431-L440
[ "def", "get_examples", "(", "examples_dir", "=", "\"examples/\"", ")", ":", "# pragma: no cover", "all_files", "=", "os", ".", "listdir", "(", "examples_dir", ")", "python_files", "=", "[", "f", "for", "f", "in", "all_files", "if", "is_python_file", "(", "f", ...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
get_path_from_doc
If `file:` is provided import the file.
flasgger/utils.py
def get_path_from_doc(full_doc): """ If `file:` is provided import the file. """ swag_path = full_doc.replace('file:', '').strip() swag_type = swag_path.split('.')[-1] return swag_path, swag_type
def get_path_from_doc(full_doc): """ If `file:` is provided import the file. """ swag_path = full_doc.replace('file:', '').strip() swag_type = swag_path.split('.')[-1] return swag_path, swag_type
[ "If", "file", ":", "is", "provided", "import", "the", "file", "." ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L443-L449
[ "def", "get_path_from_doc", "(", "full_doc", ")", ":", "swag_path", "=", "full_doc", ".", "replace", "(", "'file:'", ",", "''", ")", ".", "strip", "(", ")", "swag_type", "=", "swag_path", ".", "split", "(", "'.'", ")", "[", "-", "1", "]", "return", "...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
load_from_file
Load specs from YAML file
flasgger/utils.py
def load_from_file(swag_path, swag_type='yml', root_path=None): """ Load specs from YAML file """ if swag_type not in ('yaml', 'yml'): raise AttributeError("Currently only yaml or yml supported") # TODO: support JSON try: enc = detect_by_bom(swag_path) with codecs.op...
def load_from_file(swag_path, swag_type='yml', root_path=None): """ Load specs from YAML file """ if swag_type not in ('yaml', 'yml'): raise AttributeError("Currently only yaml or yml supported") # TODO: support JSON try: enc = detect_by_bom(swag_path) with codecs.op...
[ "Load", "specs", "from", "YAML", "file" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L459-L493
[ "def", "load_from_file", "(", "swag_path", ",", "swag_type", "=", "'yml'", ",", "root_path", "=", "None", ")", ":", "if", "swag_type", "not", "in", "(", "'yaml'", ",", "'yml'", ")", ":", "raise", "AttributeError", "(", "\"Currently only yaml or yml supported\"",...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
parse_docstring
Gets swag data for method/view docstring
flasgger/utils.py
def parse_docstring(obj, process_doc, endpoint=None, verb=None): """ Gets swag data for method/view docstring """ first_line, other_lines, swag = None, None, None full_doc = None swag_path = getattr(obj, 'swag_path', None) swag_type = getattr(obj, 'swag_type', 'yml') swag_paths = getatt...
def parse_docstring(obj, process_doc, endpoint=None, verb=None): """ Gets swag data for method/view docstring """ first_line, other_lines, swag = None, None, None full_doc = None swag_path = getattr(obj, 'swag_path', None) swag_type = getattr(obj, 'swag_type', 'yml') swag_paths = getatt...
[ "Gets", "swag", "data", "for", "method", "/", "view", "docstring" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L508-L563
[ "def", "parse_docstring", "(", "obj", ",", "process_doc", ",", "endpoint", "=", "None", ",", "verb", "=", "None", ")", ":", "first_line", ",", "other_lines", ",", "swag", "=", "None", ",", "None", ",", "None", "full_doc", "=", "None", "swag_path", "=", ...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
get_root_path
Get file path for object and returns its dirname
flasgger/utils.py
def get_root_path(obj): """ Get file path for object and returns its dirname """ try: filename = os.path.abspath(obj.__globals__['__file__']) except (KeyError, AttributeError): if getattr(obj, '__wrapped__', None): # decorator package has been used in view ret...
def get_root_path(obj): """ Get file path for object and returns its dirname """ try: filename = os.path.abspath(obj.__globals__['__file__']) except (KeyError, AttributeError): if getattr(obj, '__wrapped__', None): # decorator package has been used in view ret...
[ "Get", "file", "path", "for", "object", "and", "returns", "its", "dirname" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L566-L577
[ "def", "get_root_path", "(", "obj", ")", ":", "try", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "obj", ".", "__globals__", "[", "'__file__'", "]", ")", "except", "(", "KeyError", ",", "AttributeError", ")", ":", "if", "getattr", "(",...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
parse_definition_docstring
Gets swag data from docstring for class based definitions
flasgger/utils.py
def parse_definition_docstring(obj, process_doc): """ Gets swag data from docstring for class based definitions """ doc_lines, swag = None, None full_doc = None swag_path = getattr(obj, 'swag_path', None) swag_type = getattr(obj, 'swag_type', 'yml') if swag_path is not None: fu...
def parse_definition_docstring(obj, process_doc): """ Gets swag data from docstring for class based definitions """ doc_lines, swag = None, None full_doc = None swag_path = getattr(obj, 'swag_path', None) swag_type = getattr(obj, 'swag_type', 'yml') if swag_path is not None: fu...
[ "Gets", "swag", "data", "from", "docstring", "for", "class", "based", "definitions" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L580-L613
[ "def", "parse_definition_docstring", "(", "obj", ",", "process_doc", ")", ":", "doc_lines", ",", "swag", "=", "None", ",", "None", "full_doc", "=", "None", "swag_path", "=", "getattr", "(", "obj", ",", "'swag_path'", ",", "None", ")", "swag_type", "=", "ge...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
parse_imports
Supports `import: otherfile.yml` in docstring specs
flasgger/utils.py
def parse_imports(full_doc, root_path=None): """ Supports `import: otherfile.yml` in docstring specs """ regex = re.compile('import: "(.*)"') import_prop = regex.search(full_doc) if import_prop: start = import_prop.start() spaces_num = start - full_doc.rfind('\n', 0, start) - 1 ...
def parse_imports(full_doc, root_path=None): """ Supports `import: otherfile.yml` in docstring specs """ regex = re.compile('import: "(.*)"') import_prop = regex.search(full_doc) if import_prop: start = import_prop.start() spaces_num = start - full_doc.rfind('\n', 0, start) - 1 ...
[ "Supports", "import", ":", "otherfile", ".", "yml", "in", "docstring", "specs" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L616-L635
[ "def", "parse_imports", "(", "full_doc", ",", "root_path", "=", "None", ")", ":", "regex", "=", "re", ".", "compile", "(", "'import: \"(.*)\"'", ")", "import_prop", "=", "regex", ".", "search", "(", "full_doc", ")", "if", "import_prop", ":", "start", "=", ...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
extract_definitions
Since we couldn't be bothered to register models elsewhere our definitions need to be extracted from the parameters. We require an 'id' field for the schema to be correctly added to the definitions list.
flasgger/utils.py
def extract_definitions(alist, level=None, endpoint=None, verb=None, prefix_ids=False): """ Since we couldn't be bothered to register models elsewhere our definitions need to be extracted from the parameters. We require an 'id' field for the schema to be correctly added to th...
def extract_definitions(alist, level=None, endpoint=None, verb=None, prefix_ids=False): """ Since we couldn't be bothered to register models elsewhere our definitions need to be extracted from the parameters. We require an 'id' field for the schema to be correctly added to th...
[ "Since", "we", "couldn", "t", "be", "bothered", "to", "register", "models", "elsewhere", "our", "definitions", "need", "to", "be", "extracted", "from", "the", "parameters", ".", "We", "require", "an", "id", "field", "for", "the", "schema", "to", "be", "cor...
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L638-L706
[ "def", "extract_definitions", "(", "alist", ",", "level", "=", "None", ",", "endpoint", "=", "None", ",", "verb", "=", "None", ",", "prefix_ids", "=", "False", ")", ":", "endpoint", "=", "endpoint", "or", "request", ".", "endpoint", ".", "lower", "(", ...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
has_valid_dispatch_view_docs
Return True if dispatch_request is swaggable
flasgger/utils.py
def has_valid_dispatch_view_docs(endpoint): """ Return True if dispatch_request is swaggable """ klass = endpoint.__dict__.get('view_class', None) return klass and hasattr(klass, 'dispatch_request') \ and hasattr(endpoint, 'methods') \ and getattr(klass, 'dispatch_request').__doc__
def has_valid_dispatch_view_docs(endpoint): """ Return True if dispatch_request is swaggable """ klass = endpoint.__dict__.get('view_class', None) return klass and hasattr(klass, 'dispatch_request') \ and hasattr(endpoint, 'methods') \ and getattr(klass, 'dispatch_request').__doc__
[ "Return", "True", "if", "dispatch_request", "is", "swaggable" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L709-L716
[ "def", "has_valid_dispatch_view_docs", "(", "endpoint", ")", ":", "klass", "=", "endpoint", ".", "__dict__", ".", "get", "(", "'view_class'", ",", "None", ")", "return", "klass", "and", "hasattr", "(", "klass", ",", "'dispatch_request'", ")", "and", "hasattr",...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
is_valid_method_view
Return True if obj is MethodView
flasgger/utils.py
def is_valid_method_view(endpoint): """ Return True if obj is MethodView """ klass = endpoint.__dict__.get('view_class', None) try: return issubclass(klass, MethodView) except TypeError: return False
def is_valid_method_view(endpoint): """ Return True if obj is MethodView """ klass = endpoint.__dict__.get('view_class', None) try: return issubclass(klass, MethodView) except TypeError: return False
[ "Return", "True", "if", "obj", "is", "MethodView" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L719-L727
[ "def", "is_valid_method_view", "(", "endpoint", ")", ":", "klass", "=", "endpoint", ".", "__dict__", ".", "get", "(", "'view_class'", ",", "None", ")", "try", ":", "return", "issubclass", "(", "klass", ",", "MethodView", ")", "except", "TypeError", ":", "r...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
get_vendor_extension_fields
Identify vendor extension fields and extract them into a new dictionary. Examples: >>> get_vendor_extension_fields({'test': 1}) {} >>> get_vendor_extension_fields({'test': 1, 'x-test': 2}) {'x-test': 2}
flasgger/utils.py
def get_vendor_extension_fields(mapping): """ Identify vendor extension fields and extract them into a new dictionary. Examples: >>> get_vendor_extension_fields({'test': 1}) {} >>> get_vendor_extension_fields({'test': 1, 'x-test': 2}) {'x-test': 2} """ return {k: v fo...
def get_vendor_extension_fields(mapping): """ Identify vendor extension fields and extract them into a new dictionary. Examples: >>> get_vendor_extension_fields({'test': 1}) {} >>> get_vendor_extension_fields({'test': 1, 'x-test': 2}) {'x-test': 2} """ return {k: v fo...
[ "Identify", "vendor", "extension", "fields", "and", "extract", "them", "into", "a", "new", "dictionary", ".", "Examples", ":", ">>>", "get_vendor_extension_fields", "(", "{", "test", ":", "1", "}", ")", "{}", ">>>", "get_vendor_extension_fields", "(", "{", "te...
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/utils.py#L730-L739
[ "def", "get_vendor_extension_fields", "(", "mapping", ")", ":", "return", "{", "k", ":", "v", "for", "k", ",", "v", "in", "mapping", ".", "items", "(", ")", "if", "k", ".", "startswith", "(", "'x-'", ")", "}" ]
fef154f61d7afca548067be0c758c3dd71cc4c97
train
login
User authenticate method. --- description: Authenticate user with supplied credentials. parameters: - name: username in: formData type: string required: true - name: password in: formData type: string required: true responses: 200: ...
examples/jwt_auth.py
def login(): """ User authenticate method. --- description: Authenticate user with supplied credentials. parameters: - name: username in: formData type: string required: true - name: password in: formData type: string required: true res...
def login(): """ User authenticate method. --- description: Authenticate user with supplied credentials. parameters: - name: username in: formData type: string required: true - name: password in: formData type: string required: true res...
[ "User", "authenticate", "method", ".", "---", "description", ":", "Authenticate", "user", "with", "supplied", "credentials", ".", "parameters", ":", "-", "name", ":", "username", "in", ":", "formData", "type", ":", "string", "required", ":", "true", "-", "na...
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/examples/jwt_auth.py#L87-L127
[ "def", "login", "(", ")", ":", "try", ":", "username", "=", "request", ".", "form", ".", "get", "(", "\"username\"", ")", "password", "=", "request", ".", "form", ".", "get", "(", "\"password\"", ")", "user", "=", "authenticate", "(", "username", ",", ...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
APIDocsView.get
The data under /apidocs json or Swagger UI
flasgger/base.py
def get(self): """ The data under /apidocs json or Swagger UI """ base_endpoint = self.config.get('endpoint', 'flasgger') specs = [ { "url": url_for(".".join((base_endpoint, spec['endpoint']))), "title": spec.get('title', 'API S...
def get(self): """ The data under /apidocs json or Swagger UI """ base_endpoint = self.config.get('endpoint', 'flasgger') specs = [ { "url": url_for(".".join((base_endpoint, spec['endpoint']))), "title": spec.get('title', 'API S...
[ "The", "data", "under", "/", "apidocs", "json", "or", "Swagger", "UI" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/base.py#L60-L110
[ "def", "get", "(", "self", ")", ":", "base_endpoint", "=", "self", ".", "config", ".", "get", "(", "'endpoint'", ",", "'flasgger'", ")", "specs", "=", "[", "{", "\"url\"", ":", "url_for", "(", "\".\"", ".", "join", "(", "(", "base_endpoint", ",", "sp...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
Swagger.init_app
Initialize the app with Swagger plugin
flasgger/base.py
def init_app(self, app, decorators=None): """ Initialize the app with Swagger plugin """ self.decorators = decorators or self.decorators self.app = app self.load_config(app) # self.load_apispec(app) if self.template_file is not None: self.temp...
def init_app(self, app, decorators=None): """ Initialize the app with Swagger plugin """ self.decorators = decorators or self.decorators self.app = app self.load_config(app) # self.load_apispec(app) if self.template_file is not None: self.temp...
[ "Initialize", "the", "app", "with", "Swagger", "plugin" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/base.py#L181-L204
[ "def", "init_app", "(", "self", ",", "app", ",", "decorators", "=", "None", ")", ":", "self", ".", "decorators", "=", "decorators", "or", "self", ".", "decorators", "self", ".", "app", "=", "app", "self", ".", "load_config", "(", "app", ")", "# self.lo...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
Swagger.get_url_mappings
Returns all werkzeug rules
flasgger/base.py
def get_url_mappings(self, rule_filter=None): """ Returns all werkzeug rules """ rule_filter = rule_filter or (lambda rule: True) app_rules = [ rule for rule in current_app.url_map.iter_rules() if rule_filter(rule) ] return app_rules
def get_url_mappings(self, rule_filter=None): """ Returns all werkzeug rules """ rule_filter = rule_filter or (lambda rule: True) app_rules = [ rule for rule in current_app.url_map.iter_rules() if rule_filter(rule) ] return app_rules
[ "Returns", "all", "werkzeug", "rules" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/base.py#L235-L244
[ "def", "get_url_mappings", "(", "self", ",", "rule_filter", "=", "None", ")", ":", "rule_filter", "=", "rule_filter", "or", "(", "lambda", "rule", ":", "True", ")", "app_rules", "=", "[", "rule", "for", "rule", "in", "current_app", ".", "url_map", ".", "...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
Swagger.get_def_models
Used for class based definitions
flasgger/base.py
def get_def_models(self, definition_filter=None): """ Used for class based definitions """ model_filter = definition_filter or (lambda tag: True) return { definition.name: definition.obj for definition in self.definition_models if model_filter(...
def get_def_models(self, definition_filter=None): """ Used for class based definitions """ model_filter = definition_filter or (lambda tag: True) return { definition.name: definition.obj for definition in self.definition_models if model_filter(...
[ "Used", "for", "class", "based", "definitions" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/base.py#L246-L255
[ "def", "get_def_models", "(", "self", ",", "definition_filter", "=", "None", ")", ":", "model_filter", "=", "definition_filter", "or", "(", "lambda", "tag", ":", "True", ")", "return", "{", "definition", ".", "name", ":", "definition", ".", "obj", "for", "...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
Swagger.definition
Decorator to add class based definitions
flasgger/base.py
def definition(self, name, tags=None): """ Decorator to add class based definitions """ def wrapper(obj): self.definition_models.append(SwaggerDefinition(name, obj, tags=tags)) return obj return w...
def definition(self, name, tags=None): """ Decorator to add class based definitions """ def wrapper(obj): self.definition_models.append(SwaggerDefinition(name, obj, tags=tags)) return obj return w...
[ "Decorator", "to", "add", "class", "based", "definitions" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/base.py#L448-L456
[ "def", "definition", "(", "self", ",", "name", ",", "tags", "=", "None", ")", ":", "def", "wrapper", "(", "obj", ")", ":", "self", ".", "definition_models", ".", "append", "(", "SwaggerDefinition", "(", "name", ",", "obj", ",", "tags", "=", "tags", "...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
Swagger.register_views
Register Flasgger views
flasgger/base.py
def register_views(self, app): """ Register Flasgger views """ # Wrap the views in an arbitrary number of decorators. def wrap_view(view): if self.decorators: for decorator in self.decorators: view = decorator(view) ret...
def register_views(self, app): """ Register Flasgger views """ # Wrap the views in an arbitrary number of decorators. def wrap_view(view): if self.decorators: for decorator in self.decorators: view = decorator(view) ret...
[ "Register", "Flasgger", "views" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/base.py#L464-L524
[ "def", "register_views", "(", "self", ",", "app", ")", ":", "# Wrap the views in an arbitrary number of decorators.", "def", "wrap_view", "(", "view", ")", ":", "if", "self", ".", "decorators", ":", "for", "decorator", "in", "self", ".", "decorators", ":", "view...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
Swagger.add_headers
Inject headers after request
flasgger/base.py
def add_headers(self, app): """ Inject headers after request """ @app.after_request def after_request(response): # noqa for header, value in self.config.get('headers'): response.headers[header] = value return response
def add_headers(self, app): """ Inject headers after request """ @app.after_request def after_request(response): # noqa for header, value in self.config.get('headers'): response.headers[header] = value return response
[ "Inject", "headers", "after", "request" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/base.py#L526-L534
[ "def", "add_headers", "(", "self", ",", "app", ")", ":", "@", "app", ".", "after_request", "def", "after_request", "(", "response", ")", ":", "# noqa", "for", "header", ",", "value", "in", "self", ".", "config", ".", "get", "(", "'headers'", ")", ":", ...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
Swagger.validate
A decorator that is used to validate incoming requests data against a schema swagger = Swagger(app) @app.route('/pets', methods=['POST']) @swagger.validate('Pet') @swag_from("pet_post_endpoint.yml") def post(): return db.insert(reques...
flasgger/base.py
def validate( self, schema_id, validation_function=None, validation_error_handler=None): """ A decorator that is used to validate incoming requests data against a schema swagger = Swagger(app) @app.route('/pets', methods=['POST']) @sw...
def validate( self, schema_id, validation_function=None, validation_error_handler=None): """ A decorator that is used to validate incoming requests data against a schema swagger = Swagger(app) @app.route('/pets', methods=['POST']) @sw...
[ "A", "decorator", "that", "is", "used", "to", "validate", "incoming", "requests", "data", "against", "a", "schema" ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/base.py#L620-L673
[ "def", "validate", "(", "self", ",", "schema_id", ",", "validation_function", "=", "None", ",", "validation_error_handler", "=", "None", ")", ":", "if", "validation_function", "is", "None", ":", "validation_function", "=", "self", ".", "validation_function", "if",...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
Swagger.get_schema
This method finds a schema known to Flasgger and returns it. :raise KeyError: when the specified :param schema_id: is not found by Flasgger :param schema_id: the id of the desired schema
flasgger/base.py
def get_schema(self, schema_id): """ This method finds a schema known to Flasgger and returns it. :raise KeyError: when the specified :param schema_id: is not found by Flasgger :param schema_id: the id of the desired schema """ schema_specs = get_schema_specs(sc...
def get_schema(self, schema_id): """ This method finds a schema known to Flasgger and returns it. :raise KeyError: when the specified :param schema_id: is not found by Flasgger :param schema_id: the id of the desired schema """ schema_specs = get_schema_specs(sc...
[ "This", "method", "finds", "a", "schema", "known", "to", "Flasgger", "and", "returns", "it", "." ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/base.py#L675-L694
[ "def", "get_schema", "(", "self", ",", "schema_id", ")", ":", "schema_specs", "=", "get_schema_specs", "(", "schema_id", ",", "self", ")", "if", "schema_specs", "is", "None", ":", "raise", "KeyError", "(", "'Specified schema_id \\'{0}\\' not found'", ".", "format"...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
Todo.put
This is an example --- tags: - restful parameters: - in: body name: body schema: $ref: '#/definitions/Task' - in: path name: todo_id required: true description: The ID of the task, try 42! ...
examples/restful.py
def put(self, todo_id): """ This is an example --- tags: - restful parameters: - in: body name: body schema: $ref: '#/definitions/Task' - in: path name: todo_id required: true ...
def put(self, todo_id): """ This is an example --- tags: - restful parameters: - in: body name: body schema: $ref: '#/definitions/Task' - in: path name: todo_id required: true ...
[ "This", "is", "an", "example", "---", "tags", ":", "-", "restful", "parameters", ":", "-", "in", ":", "body", "name", ":", "body", "schema", ":", "$ref", ":", "#", "/", "definitions", "/", "Task", "-", "in", ":", "path", "name", ":", "todo_id", "re...
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/examples/restful.py#L84-L109
[ "def", "put", "(", "self", ",", "todo_id", ")", ":", "args", "=", "parser", ".", "parse_args", "(", ")", "task", "=", "{", "'task'", ":", "args", "[", "'task'", "]", "}", "TODOS", "[", "todo_id", "]", "=", "task", "return", "task", ",", "201" ]
fef154f61d7afca548067be0c758c3dd71cc4c97
train
TodoList.post
This is an example --- tags: - restful parameters: - in: body name: body schema: $ref: '#/definitions/Task' responses: 201: description: The task has been created schema: $ref: '#/de...
examples/restful.py
def post(self): """ This is an example --- tags: - restful parameters: - in: body name: body schema: $ref: '#/definitions/Task' responses: 201: description: The task has been created ...
def post(self): """ This is an example --- tags: - restful parameters: - in: body name: body schema: $ref: '#/definitions/Task' responses: 201: description: The task has been created ...
[ "This", "is", "an", "example", "---", "tags", ":", "-", "restful", "parameters", ":", "-", "in", ":", "body", "name", ":", "body", "schema", ":", "$ref", ":", "#", "/", "definitions", "/", "Task", "responses", ":", "201", ":", "description", ":", "Th...
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/examples/restful.py#L134-L155
[ "def", "post", "(", "self", ")", ":", "args", "=", "parser", ".", "parse_args", "(", ")", "todo_id", "=", "int", "(", "max", "(", "TODOS", ".", "keys", "(", ")", ")", ".", "lstrip", "(", "'todo'", ")", ")", "+", "1", "todo_id", "=", "'todo%i'", ...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
colors
Example endpoint return a list of colors by palette This is using docstring for specifications --- tags: - colors parameters: - name: palette in: path type: string enum: ['all', 'rgb', 'cmyk'] required: true default: all description: Which pale...
examples/colors.py
def colors(palette): """Example endpoint return a list of colors by palette This is using docstring for specifications --- tags: - colors parameters: - name: palette in: path type: string enum: ['all', 'rgb', 'cmyk'] required: true default: all ...
def colors(palette): """Example endpoint return a list of colors by palette This is using docstring for specifications --- tags: - colors parameters: - name: palette in: path type: string enum: ['all', 'rgb', 'cmyk'] required: true default: all ...
[ "Example", "endpoint", "return", "a", "list", "of", "colors", "by", "palette", "This", "is", "using", "docstring", "for", "specifications", "---", "tags", ":", "-", "colors", "parameters", ":", "-", "name", ":", "palette", "in", ":", "path", "type", ":", ...
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/examples/colors.py#L17-L72
[ "def", "colors", "(", "palette", ")", ":", "all_colors", "=", "{", "'cmyk'", ":", "[", "'cian'", ",", "'magenta'", ",", "'yellow'", ",", "'black'", "]", ",", "'rgb'", ":", "[", "'red'", ",", "'green'", ",", "'blue'", "]", "}", "if", "palette", "==", ...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
requires_basic_auth
Decorator to require HTTP Basic Auth for your endpoint.
examples/decorators_in_init_app.py
def requires_basic_auth(f): """Decorator to require HTTP Basic Auth for your endpoint.""" def check_auth(username, password): return username == "guest" and password == "secret" def authenticate(): return Response( "Authentication required.", 401, {"WWW-Authenticate...
def requires_basic_auth(f): """Decorator to require HTTP Basic Auth for your endpoint.""" def check_auth(username, password): return username == "guest" and password == "secret" def authenticate(): return Response( "Authentication required.", 401, {"WWW-Authenticate...
[ "Decorator", "to", "require", "HTTP", "Basic", "Auth", "for", "your", "endpoint", "." ]
rochacbruno/flasgger
python
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/examples/decorators_in_init_app.py#L28-L55
[ "def", "requires_basic_auth", "(", "f", ")", ":", "def", "check_auth", "(", "username", ",", "password", ")", ":", "return", "username", "==", "\"guest\"", "and", "password", "==", "\"secret\"", "def", "authenticate", "(", ")", ":", "return", "Response", "("...
fef154f61d7afca548067be0c758c3dd71cc4c97
train
MTCNN.__scale_image
Scales the image to a given scale. :param image: :param scale: :return:
mtcnn/mtcnn.py
def __scale_image(image, scale: float): """ Scales the image to a given scale. :param image: :param scale: :return: """ height, width, _ = image.shape width_scaled = int(np.ceil(width * scale)) height_scaled = int(np.ceil(height * scale)) ...
def __scale_image(image, scale: float): """ Scales the image to a given scale. :param image: :param scale: :return: """ height, width, _ = image.shape width_scaled = int(np.ceil(width * scale)) height_scaled = int(np.ceil(height * scale)) ...
[ "Scales", "the", "image", "to", "a", "given", "scale", ".", ":", "param", "image", ":", ":", "param", "scale", ":", ":", "return", ":" ]
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/mtcnn.py#L230-L247
[ "def", "__scale_image", "(", "image", ",", "scale", ":", "float", ")", ":", "height", ",", "width", ",", "_", "=", "image", ".", "shape", "width_scaled", "=", "int", "(", "np", ".", "ceil", "(", "width", "*", "scale", ")", ")", "height_scaled", "=", ...
17029fe453a435f50c472ae2fd1c493341b5ede3
train
MTCNN.__nms
Non Maximum Suppression. :param boxes: np array with bounding boxes. :param threshold: :param method: NMS method to apply. Available values ('Min', 'Union') :return:
mtcnn/mtcnn.py
def __nms(boxes, threshold, method): """ Non Maximum Suppression. :param boxes: np array with bounding boxes. :param threshold: :param method: NMS method to apply. Available values ('Min', 'Union') :return: """ if boxes.size == 0: return np.em...
def __nms(boxes, threshold, method): """ Non Maximum Suppression. :param boxes: np array with bounding boxes. :param threshold: :param method: NMS method to apply. Available values ('Min', 'Union') :return: """ if boxes.size == 0: return np.em...
[ "Non", "Maximum", "Suppression", "." ]
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/mtcnn.py#L285-L333
[ "def", "__nms", "(", "boxes", ",", "threshold", ",", "method", ")", ":", "if", "boxes", ".", "size", "==", "0", ":", "return", "np", ".", "empty", "(", "(", "0", ",", "3", ")", ")", "x1", "=", "boxes", "[", ":", ",", "0", "]", "y1", "=", "b...
17029fe453a435f50c472ae2fd1c493341b5ede3
train
MTCNN.detect_faces
Detects bounding boxes from the specified image. :param img: image to process :return: list containing all the bounding boxes detected with their keypoints.
mtcnn/mtcnn.py
def detect_faces(self, img) -> list: """ Detects bounding boxes from the specified image. :param img: image to process :return: list containing all the bounding boxes detected with their keypoints. """ if img is None or not hasattr(img, "shape"): raise Invalid...
def detect_faces(self, img) -> list: """ Detects bounding boxes from the specified image. :param img: image to process :return: list containing all the bounding boxes detected with their keypoints. """ if img is None or not hasattr(img, "shape"): raise Invalid...
[ "Detects", "bounding", "boxes", "from", "the", "specified", "image", ".", ":", "param", "img", ":", "image", "to", "process", ":", "return", ":", "list", "containing", "all", "the", "bounding", "boxes", "detected", "with", "their", "keypoints", "." ]
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/mtcnn.py#L396-L440
[ "def", "detect_faces", "(", "self", ",", "img", ")", "->", "list", ":", "if", "img", "is", "None", "or", "not", "hasattr", "(", "img", ",", "\"shape\"", ")", ":", "raise", "InvalidImage", "(", "\"Image not valid.\"", ")", "height", ",", "width", ",", "...
17029fe453a435f50c472ae2fd1c493341b5ede3
train
MTCNN.__stage1
First stage of the MTCNN. :param image: :param scales: :param stage_status: :return:
mtcnn/mtcnn.py
def __stage1(self, image, scales: list, stage_status: StageStatus): """ First stage of the MTCNN. :param image: :param scales: :param stage_status: :return: """ total_boxes = np.empty((0, 9)) status = stage_status for scale in scales: ...
def __stage1(self, image, scales: list, stage_status: StageStatus): """ First stage of the MTCNN. :param image: :param scales: :param stage_status: :return: """ total_boxes = np.empty((0, 9)) status = stage_status for scale in scales: ...
[ "First", "stage", "of", "the", "MTCNN", ".", ":", "param", "image", ":", ":", "param", "scales", ":", ":", "param", "stage_status", ":", ":", "return", ":" ]
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/mtcnn.py#L442-L494
[ "def", "__stage1", "(", "self", ",", "image", ",", "scales", ":", "list", ",", "stage_status", ":", "StageStatus", ")", ":", "total_boxes", "=", "np", ".", "empty", "(", "(", "0", ",", "9", ")", ")", "status", "=", "stage_status", "for", "scale", "in...
17029fe453a435f50c472ae2fd1c493341b5ede3
train
MTCNN.__stage2
Second stage of the MTCNN. :param img: :param total_boxes: :param stage_status: :return:
mtcnn/mtcnn.py
def __stage2(self, img, total_boxes, stage_status:StageStatus): """ Second stage of the MTCNN. :param img: :param total_boxes: :param stage_status: :return: """ num_boxes = total_boxes.shape[0] if num_boxes == 0: return total_boxes, st...
def __stage2(self, img, total_boxes, stage_status:StageStatus): """ Second stage of the MTCNN. :param img: :param total_boxes: :param stage_status: :return: """ num_boxes = total_boxes.shape[0] if num_boxes == 0: return total_boxes, st...
[ "Second", "stage", "of", "the", "MTCNN", ".", ":", "param", "img", ":", ":", "param", "total_boxes", ":", ":", "param", "stage_status", ":", ":", "return", ":" ]
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/mtcnn.py#L496-L547
[ "def", "__stage2", "(", "self", ",", "img", ",", "total_boxes", ",", "stage_status", ":", "StageStatus", ")", ":", "num_boxes", "=", "total_boxes", ".", "shape", "[", "0", "]", "if", "num_boxes", "==", "0", ":", "return", "total_boxes", ",", "stage_status"...
17029fe453a435f50c472ae2fd1c493341b5ede3
train
MTCNN.__stage3
Third stage of the MTCNN. :param img: :param total_boxes: :param stage_status: :return:
mtcnn/mtcnn.py
def __stage3(self, img, total_boxes, stage_status: StageStatus): """ Third stage of the MTCNN. :param img: :param total_boxes: :param stage_status: :return: """ num_boxes = total_boxes.shape[0] if num_boxes == 0: return total_boxes, np...
def __stage3(self, img, total_boxes, stage_status: StageStatus): """ Third stage of the MTCNN. :param img: :param total_boxes: :param stage_status: :return: """ num_boxes = total_boxes.shape[0] if num_boxes == 0: return total_boxes, np...
[ "Third", "stage", "of", "the", "MTCNN", "." ]
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/mtcnn.py#L549-L613
[ "def", "__stage3", "(", "self", ",", "img", ",", "total_boxes", ",", "stage_status", ":", "StageStatus", ")", ":", "num_boxes", "=", "total_boxes", ".", "shape", "[", "0", "]", "if", "num_boxes", "==", "0", ":", "return", "total_boxes", ",", "np", ".", ...
17029fe453a435f50c472ae2fd1c493341b5ede3
train
LayerFactory.__make_var
Creates a tensorflow variable with the given name and shape. :param name: name to set for the variable. :param shape: list defining the shape of the variable. :return: created TF variable.
mtcnn/layer_factory.py
def __make_var(self, name: str, shape: list): """ Creates a tensorflow variable with the given name and shape. :param name: name to set for the variable. :param shape: list defining the shape of the variable. :return: created TF variable. """ return tf.get_variabl...
def __make_var(self, name: str, shape: list): """ Creates a tensorflow variable with the given name and shape. :param name: name to set for the variable. :param shape: list defining the shape of the variable. :return: created TF variable. """ return tf.get_variabl...
[ "Creates", "a", "tensorflow", "variable", "with", "the", "given", "name", "and", "shape", ".", ":", "param", "name", ":", "name", "to", "set", "for", "the", "variable", ".", ":", "param", "shape", ":", "list", "defining", "the", "shape", "of", "the", "...
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/layer_factory.py#L72-L79
[ "def", "__make_var", "(", "self", ",", "name", ":", "str", ",", "shape", ":", "list", ")", ":", "return", "tf", ".", "get_variable", "(", "name", ",", "shape", ",", "trainable", "=", "self", ".", "__network", ".", "is_trainable", "(", ")", ")" ]
17029fe453a435f50c472ae2fd1c493341b5ede3
train
LayerFactory.new_feed
Creates a feed layer. This is usually the first layer in the network. :param name: name of the layer :return:
mtcnn/layer_factory.py
def new_feed(self, name: str, layer_shape: tuple): """ Creates a feed layer. This is usually the first layer in the network. :param name: name of the layer :return: """ feed_data = tf.placeholder(tf.float32, layer_shape, 'input') self.__network.add_layer(name, la...
def new_feed(self, name: str, layer_shape: tuple): """ Creates a feed layer. This is usually the first layer in the network. :param name: name of the layer :return: """ feed_data = tf.placeholder(tf.float32, layer_shape, 'input') self.__network.add_layer(name, la...
[ "Creates", "a", "feed", "layer", ".", "This", "is", "usually", "the", "first", "layer", "in", "the", "network", ".", ":", "param", "name", ":", "name", "of", "the", "layer", ":", "return", ":" ]
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/layer_factory.py#L81-L89
[ "def", "new_feed", "(", "self", ",", "name", ":", "str", ",", "layer_shape", ":", "tuple", ")", ":", "feed_data", "=", "tf", ".", "placeholder", "(", "tf", ".", "float32", ",", "layer_shape", ",", "'input'", ")", "self", ".", "__network", ".", "add_lay...
17029fe453a435f50c472ae2fd1c493341b5ede3
train
LayerFactory.new_conv
Creates a convolution layer for the network. :param name: name for the layer :param kernel_size: tuple containing the size of the kernel (Width, Height) :param channels_output: ¿? Perhaps number of channels in the output? it is used as the bias size. :param stride_size: tuple containing ...
mtcnn/layer_factory.py
def new_conv(self, name: str, kernel_size: tuple, channels_output: int, stride_size: tuple, padding: str='SAME', group: int=1, biased: bool=True, relu: bool=True, input_layer_name: str=None): """ Creates a convolution layer for the network. :param name: name for...
def new_conv(self, name: str, kernel_size: tuple, channels_output: int, stride_size: tuple, padding: str='SAME', group: int=1, biased: bool=True, relu: bool=True, input_layer_name: str=None): """ Creates a convolution layer for the network. :param name: name for...
[ "Creates", "a", "convolution", "layer", "for", "the", "network", ".", ":", "param", "name", ":", "name", "for", "the", "layer", ":", "param", "kernel_size", ":", "tuple", "containing", "the", "size", "of", "the", "kernel", "(", "Width", "Height", ")", ":...
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/layer_factory.py#L91-L138
[ "def", "new_conv", "(", "self", ",", "name", ":", "str", ",", "kernel_size", ":", "tuple", ",", "channels_output", ":", "int", ",", "stride_size", ":", "tuple", ",", "padding", ":", "str", "=", "'SAME'", ",", "group", ":", "int", "=", "1", ",", "bias...
17029fe453a435f50c472ae2fd1c493341b5ede3
train
LayerFactory.new_prelu
Creates a new prelu layer with the given name and input. :param name: name for this layer. :param input_layer_name: name of the layer that serves as input for this one.
mtcnn/layer_factory.py
def new_prelu(self, name: str, input_layer_name: str=None): """ Creates a new prelu layer with the given name and input. :param name: name for this layer. :param input_layer_name: name of the layer that serves as input for this one. """ input_layer = self.__network.get_la...
def new_prelu(self, name: str, input_layer_name: str=None): """ Creates a new prelu layer with the given name and input. :param name: name for this layer. :param input_layer_name: name of the layer that serves as input for this one. """ input_layer = self.__network.get_la...
[ "Creates", "a", "new", "prelu", "layer", "with", "the", "given", "name", "and", "input", ".", ":", "param", "name", ":", "name", "for", "this", "layer", ".", ":", "param", "input_layer_name", ":", "name", "of", "the", "layer", "that", "serves", "as", "...
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/layer_factory.py#L140-L153
[ "def", "new_prelu", "(", "self", ",", "name", ":", "str", ",", "input_layer_name", ":", "str", "=", "None", ")", ":", "input_layer", "=", "self", ".", "__network", ".", "get_layer", "(", "input_layer_name", ")", "with", "tf", ".", "variable_scope", "(", ...
17029fe453a435f50c472ae2fd1c493341b5ede3
train
LayerFactory.new_max_pool
Creates a new max pooling layer. :param name: name for the layer. :param kernel_size: tuple containing the size of the kernel (Width, Height) :param stride_size: tuple containing the size of the stride (Width, Height) :param padding: Type of padding. Available values are: ('SAME', 'VALID...
mtcnn/layer_factory.py
def new_max_pool(self, name:str, kernel_size: tuple, stride_size: tuple, padding='SAME', input_layer_name: str=None): """ Creates a new max pooling layer. :param name: name for the layer. :param kernel_size: tuple containing the size of the kernel (Width, Height) ...
def new_max_pool(self, name:str, kernel_size: tuple, stride_size: tuple, padding='SAME', input_layer_name: str=None): """ Creates a new max pooling layer. :param name: name for the layer. :param kernel_size: tuple containing the size of the kernel (Width, Height) ...
[ "Creates", "a", "new", "max", "pooling", "layer", ".", ":", "param", "name", ":", "name", "for", "the", "layer", ".", ":", "param", "kernel_size", ":", "tuple", "containing", "the", "size", "of", "the", "kernel", "(", "Width", "Height", ")", ":", "para...
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/layer_factory.py#L155-L177
[ "def", "new_max_pool", "(", "self", ",", "name", ":", "str", ",", "kernel_size", ":", "tuple", ",", "stride_size", ":", "tuple", ",", "padding", "=", "'SAME'", ",", "input_layer_name", ":", "str", "=", "None", ")", ":", "self", ".", "__validate_padding", ...
17029fe453a435f50c472ae2fd1c493341b5ede3
train
LayerFactory.new_fully_connected
Creates a new fully connected layer. :param name: name for the layer. :param output_count: number of outputs of the fully connected layer. :param relu: boolean flag to set if ReLu should be applied at the end of this layer. :param input_layer_name: name of the input layer for this layer...
mtcnn/layer_factory.py
def new_fully_connected(self, name: str, output_count: int, relu=True, input_layer_name: str=None): """ Creates a new fully connected layer. :param name: name for the layer. :param output_count: number of outputs of the fully connected layer. :param relu: boolean flag to set if ...
def new_fully_connected(self, name: str, output_count: int, relu=True, input_layer_name: str=None): """ Creates a new fully connected layer. :param name: name for the layer. :param output_count: number of outputs of the fully connected layer. :param relu: boolean flag to set if ...
[ "Creates", "a", "new", "fully", "connected", "layer", "." ]
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/layer_factory.py#L179-L200
[ "def", "new_fully_connected", "(", "self", ",", "name", ":", "str", ",", "output_count", ":", "int", ",", "relu", "=", "True", ",", "input_layer_name", ":", "str", "=", "None", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ")", ":", "inpu...
17029fe453a435f50c472ae2fd1c493341b5ede3
train
LayerFactory.new_softmax
Creates a new softmax layer :param name: name to set for the layer :param axis: :param input_layer_name: name of the input layer for this layer. If None, it will take the last added layer of the network.
mtcnn/layer_factory.py
def new_softmax(self, name, axis, input_layer_name: str=None): """ Creates a new softmax layer :param name: name to set for the layer :param axis: :param input_layer_name: name of the input layer for this layer. If None, it will take the last added layer of the network. ...
def new_softmax(self, name, axis, input_layer_name: str=None): """ Creates a new softmax layer :param name: name to set for the layer :param axis: :param input_layer_name: name of the input layer for this layer. If None, it will take the last added layer of the network. ...
[ "Creates", "a", "new", "softmax", "layer", ":", "param", "name", ":", "name", "to", "set", "for", "the", "layer", ":", "param", "axis", ":", ":", "param", "input_layer_name", ":", "name", "of", "the", "input", "layer", "for", "this", "layer", ".", "If"...
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/layer_factory.py#L202-L223
[ "def", "new_softmax", "(", "self", ",", "name", ",", "axis", ",", "input_layer_name", ":", "str", "=", "None", ")", ":", "input_layer", "=", "self", ".", "__network", ".", "get_layer", "(", "input_layer_name", ")", "if", "LooseVersion", "(", "tf", ".", "...
17029fe453a435f50c472ae2fd1c493341b5ede3
train
Network.add_layer
Adds a layer to the network. :param name: name of the layer to add :param layer_output: output layer.
mtcnn/network.py
def add_layer(self, name: str, layer_output): """ Adds a layer to the network. :param name: name of the layer to add :param layer_output: output layer. """ self.__layers[name] = layer_output self.__last_layer_name = name
def add_layer(self, name: str, layer_output): """ Adds a layer to the network. :param name: name of the layer to add :param layer_output: output layer. """ self.__layers[name] = layer_output self.__last_layer_name = name
[ "Adds", "a", "layer", "to", "the", "network", ".", ":", "param", "name", ":", "name", "of", "the", "layer", "to", "add", ":", "param", "layer_output", ":", "output", "layer", "." ]
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/network.py#L53-L60
[ "def", "add_layer", "(", "self", ",", "name", ":", "str", ",", "layer_output", ")", ":", "self", ".", "__layers", "[", "name", "]", "=", "layer_output", "self", ".", "__last_layer_name", "=", "name" ]
17029fe453a435f50c472ae2fd1c493341b5ede3
train
Network.get_layer
Retrieves the layer by its name. :param name: name of the layer to retrieve. If name is None, it will retrieve the last added layer to the network. :return: layer output
mtcnn/network.py
def get_layer(self, name: str=None): """ Retrieves the layer by its name. :param name: name of the layer to retrieve. If name is None, it will retrieve the last added layer to the network. :return: layer output """ if name is None: name = self.__last_l...
def get_layer(self, name: str=None): """ Retrieves the layer by its name. :param name: name of the layer to retrieve. If name is None, it will retrieve the last added layer to the network. :return: layer output """ if name is None: name = self.__last_l...
[ "Retrieves", "the", "layer", "by", "its", "name", ".", ":", "param", "name", ":", "name", "of", "the", "layer", "to", "retrieve", ".", "If", "name", "is", "None", "it", "will", "retrieve", "the", "last", "added", "layer", "to", "the", "network", ".", ...
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/network.py#L62-L72
[ "def", "get_layer", "(", "self", ",", "name", ":", "str", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "self", ".", "__last_layer_name", "return", "self", ".", "__layers", "[", "name", "]" ]
17029fe453a435f50c472ae2fd1c493341b5ede3
train
Network.set_weights
Sets the weights values of the network. :param weights_values: dictionary with weights for each layer
mtcnn/network.py
def set_weights(self, weights_values: dict, ignore_missing=False): """ Sets the weights values of the network. :param weights_values: dictionary with weights for each layer """ network_name = self.__class__.__name__.lower() with tf.variable_scope(network_name): ...
def set_weights(self, weights_values: dict, ignore_missing=False): """ Sets the weights values of the network. :param weights_values: dictionary with weights for each layer """ network_name = self.__class__.__name__.lower() with tf.variable_scope(network_name): ...
[ "Sets", "the", "weights", "values", "of", "the", "network", ".", ":", "param", "weights_values", ":", "dictionary", "with", "weights", "for", "each", "layer" ]
ipazc/mtcnn
python
https://github.com/ipazc/mtcnn/blob/17029fe453a435f50c472ae2fd1c493341b5ede3/mtcnn/network.py#L80-L97
[ "def", "set_weights", "(", "self", ",", "weights_values", ":", "dict", ",", "ignore_missing", "=", "False", ")", ":", "network_name", "=", "self", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", "with", "tf", ".", "variable_scope", "(", "network...
17029fe453a435f50c472ae2fd1c493341b5ede3