diff --git a/can/CAN.py b/can/CAN.py deleted file mode 100644 index 0ed96dfb1..000000000 --- a/can/CAN.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding: utf-8 - -""" -This module was once the core of python-can, containing -implementations of all the major classes in the library, now -however all functionality has been refactored out. This API -is left intact for version 2.x to aide with migration. - -WARNING: -This module is deprecated an will get removed in version 3.x. -Please use ``import can`` instead. -""" - -from __future__ import absolute_import - -from can.message import Message -from can.listener import Listener, BufferedReader, RedirectReader -from can.util import set_logging_level -from can.io import * - -import warnings - -# See #267. -# Version 2.0 - 2.1: Log a Debug message -# Version 2.2: Log a Warning -# Version 3.x: DeprecationWarning -# Version 4.0: Remove the module -warnings.warn('Loading python-can via the old "CAN" API is deprecated since v3.0 an will get removed in v4.0 ' - 'Please use `import can` instead.', DeprecationWarning) diff --git a/can/__init__.py b/can/__init__.py index a612363ae..0bc8cfe62 100644 --- a/can/__init__.py +++ b/can/__init__.py @@ -45,7 +45,7 @@ class CanError(IOError): from . import interface from .interface import Bus, detect_available_configs -from .broadcastmanager import send_periodic, \ +from .broadcastmanager import \ CyclicSendTaskABC, \ LimitedDurationCyclicSendTaskABC, \ ModifiableCyclicTaskABC, \ diff --git a/can/broadcastmanager.py b/can/broadcastmanager.py index 79d586744..85ad03776 100644 --- a/can/broadcastmanager.py +++ b/can/broadcastmanager.py @@ -142,17 +142,3 @@ def _run(self): # Compensate for the time it takes to send the message delay = self.period - (time.time() - started) time.sleep(max(0.0, delay)) - - -def send_periodic(bus, message, period, *args, **kwargs): - """ - Send a :class:`~can.Message` every `period` seconds on the given bus. - - :param can.BusABC bus: A CAN bus which supports sending. - :param can.Message message: Message to send periodically. - :param float period: The minimum time between sending messages. - :return: A started task instance - """ - warnings.warn("The function `can.send_periodic` is deprecated and will " + - "be removed in an upcoming version. Please use `can.Bus.send_periodic` instead.", DeprecationWarning) - return bus.send_periodic(message, period, *args, **kwargs) diff --git a/can/interface.py b/can/interface.py index 6c830d0c4..cbc907f86 100644 --- a/can/interface.py +++ b/can/interface.py @@ -18,11 +18,6 @@ from .util import load_config from .interfaces import BACKENDS -if 'linux' in sys.platform: - # Deprecated and undocumented access to SocketCAN cyclic tasks - # Will be removed in version 4.0 - from can.interfaces.socketcan import CyclicSendTask, MultiRateCyclicSendTask - # Required by "detect_available_configs" for argument interpretation if sys.version_info.major > 2: basestring = str diff --git a/can/interfaces/__init__.py b/can/interfaces/__init__.py index ec79e51d6..c4c7f52f7 100644 --- a/can/interfaces/__init__.py +++ b/can/interfaces/__init__.py @@ -31,10 +31,4 @@ for interface in iter_entry_points('can.interface') }) -# Old entry point name. May be removed >3.0. -for interface in iter_entry_points('python_can.interface'): - BACKENDS[interface.name] = (interface.module_name, interface.attrs[0]) - warnings.warn('{} is using the deprecated python_can.interface entry point. '.format(interface.name) + - 'Please change to can.interface instead.', DeprecationWarning) - VALID_INTERFACES = frozenset(list(BACKENDS.keys()) + ['socketcan_native', 'socketcan_ctypes']) diff --git a/can/interfaces/socketcan/socketcan.py b/can/interfaces/socketcan/socketcan.py index 633c87b22..6aebc7221 100644 --- a/can/interfaces/socketcan/socketcan.py +++ b/can/interfaces/socketcan/socketcan.py @@ -1,6 +1,6 @@ # coding: utf-8 -import logging +import logging import ctypes import ctypes.util import os @@ -14,8 +14,6 @@ log_tx = log.getChild("tx") log_rx = log.getChild("rx") -log.debug("Loading socketcan native backend") - try: import fcntl except ImportError: diff --git a/can/message.py b/can/message.py index f85218fc0..3826cede2 100644 --- a/can/message.py +++ b/can/message.py @@ -45,46 +45,13 @@ class Message(object): "is_fd", "bitrate_switch", "error_state_indicator", - "__weakref__", # support weak references to messages - "_dict" # see __getattr__ + "__weakref__" # support weak references to messages ) - def __getattr__(self, key): - # TODO keep this for a version, in order to not break old code - # this entire method (as well as the _dict attribute in __slots__ and the __setattr__ method) - # can be removed in 4.0 - # this method is only called if the attribute was not found elsewhere, like in __slots__ - try: - warnings.warn("Custom attributes of messages are deprecated and will be removed in 4.0", DeprecationWarning) - return self._dict[key] - except KeyError: - raise AttributeError("'message' object has no attribute '{}'".format(key)) - - def __setattr__(self, key, value): - # see __getattr__ - try: - super(Message, self).__setattr__(key, value) - except AttributeError: - warnings.warn("Custom attributes of messages are deprecated and will be removed in 4.0", DeprecationWarning) - self._dict[key] = value - - @property - def id_type(self): - # TODO remove in 4.0 - warnings.warn("Message.id_type is deprecated and will be removed in 4.0, use is_extended_id instead", DeprecationWarning) - return self.is_extended_id - - @id_type.setter - def id_type(self, value): - # TODO remove in 4.0 - warnings.warn("Message.id_type is deprecated and will be removed in 4.0, use is_extended_id instead", DeprecationWarning) - self.is_extended_id = value - - def __init__(self, timestamp=0.0, arbitration_id=0, is_extended_id=None, + def __init__(self, timestamp=0.0, arbitration_id=0, is_extended_id=True, is_remote_frame=False, is_error_frame=False, channel=None, dlc=None, data=None, is_fd=False, bitrate_switch=False, error_state_indicator=False, - extended_id=None, # deprecated in 3.x, TODO remove in 4.x check=False): """ To create a message object, simply provide any of the below attributes @@ -98,24 +65,12 @@ def __init__(self, timestamp=0.0, arbitration_id=0, is_extended_id=None, :raises ValueError: iff `check` is set to `True` and one or more arguments were invalid """ - self._dict = dict() # see __getattr__ - self.timestamp = timestamp self.arbitration_id = arbitration_id - - if extended_id is not None: - # TODO remove in 4.0 - warnings.warn("The extended_id parameter is deprecated and will be removed in 4.0, use is_extended_id instead", DeprecationWarning) - - if is_extended_id is not None: - self.is_extended_id = is_extended_id - else: - self.is_extended_id = True if extended_id is None else extended_id - + self.is_extended_id = is_extended_id self.is_remote_frame = is_remote_frame self.is_error_frame = is_error_frame self.channel = channel - self.is_fd = is_fd self.bitrate_switch = bitrate_switch self.error_state_indicator = error_state_indicator @@ -194,7 +149,7 @@ def __nonzero__(self): def __repr__(self): args = ["timestamp={}".format(self.timestamp), "arbitration_id={:#x}".format(self.arbitration_id), - "extended_id={}".format(self.is_extended_id)] + "is_extended_id={}".format(self.is_extended_id)] if self.is_remote_frame: args.append("is_remote_frame={}".format(self.is_remote_frame)) @@ -239,7 +194,6 @@ def __copy__(self): bitrate_switch=self.bitrate_switch, error_state_indicator=self.error_state_indicator ) - new._dict.update(self._dict) return new def __deepcopy__(self, memo): @@ -256,7 +210,6 @@ def __deepcopy__(self, memo): bitrate_switch=self.bitrate_switch, error_state_indicator=self.error_state_indicator ) - new._dict.update(self._dict) return new def _check(self): diff --git a/can/util.py b/can/util.py index af421651f..be6793152 100644 --- a/can/util.py +++ b/can/util.py @@ -186,13 +186,6 @@ def load_config(path=None, config=None, context=None): if key not in config: config[key] = None - # Handle deprecated socketcan types - if config['interface'] in ('socketcan_native', 'socketcan_ctypes'): - # DeprecationWarning in 3.x releases - # TODO: Remove completely in 4.0 - warnings.warn('{} is deprecated, use socketcan instead'.format(config['interface']), DeprecationWarning) - config['interface'] = 'socketcan' - if config['interface'] not in VALID_INTERFACES: raise NotImplementedError('Invalid CAN Bus Type - {}'.format(config['interface'])) diff --git a/doc/bcm.rst b/doc/bcm.rst index 96e73d52d..549b06edd 100644 --- a/doc/bcm.rst +++ b/doc/bcm.rst @@ -42,14 +42,3 @@ which inherits from :class:`~can.broadcastmanager.CyclicTask`. .. autoclass:: can.RestartableCyclicTaskABC :members: - - -Functional API --------------- - -.. warning:: - The functional API in :func:`can.broadcastmanager.send_periodic` is now deprecated - and will be removed in version 4.0. - Use the object oriented API via :meth:`can.BusABC.send_periodic` instead. - -.. autofunction:: can.broadcastmanager.send_periodic diff --git a/doc/development.rst b/doc/development.rst index 602e4e347..8bad5c58e 100644 --- a/doc/development.rst +++ b/doc/development.rst @@ -69,8 +69,6 @@ The modules in ``python-can`` are: |:doc:`broadcastmanager ` | Contains interface independent broadcast manager | | | code. | +---------------------------------+------------------------------------------------------+ -|:doc:`CAN ` | Legacy API. Deprecated. | -+---------------------------------+------------------------------------------------------+ Creating a new Release diff --git a/setup.cfg b/setup.cfg index 49177e68e..e9a7cb985 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,9 +15,6 @@ addopts = -v --timeout=300 --cov=can --cov-config=setup.cfg branch = False # already specified by call to pytest using --cov=can #source = can -omit = - # legacy code - can/CAN.py [coverage:report] # two digits after decimal point