Skip to content

Remove deprecated features #595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions can/CAN.py

This file was deleted.

2 changes: 1 addition & 1 deletion can/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down
14 changes: 0 additions & 14 deletions can/broadcastmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
5 changes: 0 additions & 5 deletions can/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions can/interfaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
4 changes: 1 addition & 3 deletions can/interfaces/socketcan/socketcan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding: utf-8
import logging

import logging
import ctypes
import ctypes.util
import os
Expand All @@ -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:
Expand Down
55 changes: 4 additions & 51 deletions can/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down
7 changes: 0 additions & 7 deletions can/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']))

Expand Down
11 changes: 0 additions & 11 deletions doc/bcm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions doc/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ The modules in ``python-can`` are:
|:doc:`broadcastmanager <bcm>` | Contains interface independent broadcast manager |
| | code. |
+---------------------------------+------------------------------------------------------+
|:doc:`CAN <api>` | Legacy API. Deprecated. |
+---------------------------------+------------------------------------------------------+


Creating a new Release
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down