Files
HomeAssistantRepository/dev-python/pyownet/files/pyownet-0.10.0_p1-2to3.patch
T
2022-05-26 15:53:03 +02:00

165 lines
4.4 KiB
Diff

diff --git a/examples/owget.py b/examples/owget.py
index f5b7c7f..33c4d4e 100644
--- a/examples/owget.py
+++ b/examples/owget.py
@@ -19,12 +19,12 @@ Caution:
"""
-from __future__ import print_function
+
import sys
import argparse
if sys.version_info < (3, ):
- from urlparse import urlsplit
+ from urllib.parse import urlsplit
else:
from urllib.parse import urlsplit
import collections
diff --git a/examples/scan.py b/examples/scan.py
index 101c74e..3353013 100644
--- a/examples/scan.py
+++ b/examples/scan.py
@@ -6,7 +6,7 @@ print some info on the sensors on owserver at 'server:port'
default is 'localhost:4304'
"""
-from __future__ import print_function
+
import sys
diff --git a/examples/walk.py b/examples/walk.py
index c9a4f8d..ab250c7 100644
--- a/examples/walk.py
+++ b/examples/walk.py
@@ -20,12 +20,12 @@ Caution:
"""
-from __future__ import print_function
+
import sys
import argparse
if sys.version_info < (3, ):
- from urlparse import urlsplit
+ from urllib.parse import urlsplit
else:
from urllib.parse import urlsplit
import collections
diff --git a/setup.py b/setup.py
index 14c94fc..12d442d 100644
--- a/setup.py
+++ b/setup.py
@@ -45,5 +45,4 @@ setup(
package_dir={'': 'src'},
packages=['pyownet', ],
test_suite="tests.test_protocol",
- use_2to3=True,
)
diff --git a/src/pyownet/protocol.py b/src/pyownet/protocol.py
index 8eaeed7..eeb7911 100644
--- a/src/pyownet/protocol.py
+++ b/src/pyownet/protocol.py
@@ -40,7 +40,7 @@ function 'proxy'.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-from __future__ import print_function
+
import struct
import socket
@@ -140,7 +140,7 @@ if __debug__:
def str2bytez(s):
"""Transform string to zero-terminated bytes."""
- if not isinstance(s, basestring):
+ if not isinstance(s, str):
raise TypeError()
return s.encode('ascii') + b'\x00'
@@ -148,7 +148,7 @@ def str2bytez(s):
def bytes2str(b):
"""Transform bytes to string."""
- if not isinstance(b, (bytes, bytearray, )):
+ if not isinstance(b, (bytes, bytearray )):
raise TypeError()
return b.decode('ascii')
@@ -271,14 +271,12 @@ class _addfieldprops(type):
return super(_addfieldprops, mcs).__new__(mcs, name, bases, namespace)
-class _Header(bytes):
+class _Header(bytes, metaclass=_addfieldprops):
"""abstract header class, obtained as a 'bytes' subclass
should not be instantiated directly
"""
- __metaclass__ = _addfieldprops
-
@classmethod
def _parse(cls, *args, **kwargs):
if args:
@@ -286,7 +284,7 @@ class _Header(bytes):
# FIXME check for args type and semantics
assert len(args) == 1
assert not kwargs
- assert isinstance(msg, (bytes, bytearray, ))
+ assert isinstance(msg, (bytes, bytearray ))
assert len(msg) == cls.header_size
#
vals = cls._struct.unpack(msg)
@@ -296,7 +294,7 @@ class _Header(bytes):
raise TypeError("constructor got unexpected keyword argument"
" '%s'" % kwargs.popitem()[0])
msg = cls._struct.pack(*vals)
- assert isinstance(msg, (bytes, bytearray, ))
+ assert isinstance(msg, (bytes, bytearray ))
assert isinstance(vals, tuple)
return msg, vals
@@ -625,7 +623,7 @@ class _Proxy(object):
"""
# fixme: check of path type delayed to str2bytez
- if not isinstance(data, (bytes, bytearray, )):
+ if not isinstance(data, (bytes, bytearray )):
raise TypeError("'data' argument must be binary")
ret, rdata = self.sendmess(MSG_WRITE, str2bytez(path)+data,
diff --git a/tests/__init__.py b/tests/__init__.py
index cb818e1..3bf557c 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -7,7 +7,7 @@ __all__ = ['HOST', 'PORT']
import sys
import os
if sys.version_info < (3, ):
- from ConfigParser import ConfigParser
+ from configparser import ConfigParser
else:
from configparser import ConfigParser
diff --git a/tests/test_protocol.py b/tests/test_protocol.py
index 543a4ff..cb10123 100644
--- a/tests/test_protocol.py
+++ b/tests/test_protocol.py
@@ -1,7 +1,7 @@
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
+
+
+
+
import sys
if sys.version_info < (2, 7, ):