python: Fix syntax to support Python 3.x.
This commit is contained in:
parent
d8f6e041aa
commit
1cad211547
|
@ -1,3 +1,3 @@
|
||||||
import lowlevel
|
from . import lowlevel
|
||||||
import classes
|
from . import classes
|
||||||
from classes import *
|
from .classes import *
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from fractions import Fraction
|
from fractions import Fraction
|
||||||
from lowlevel import *
|
from .lowlevel import *
|
||||||
import lowlevel
|
from . import lowlevel
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
__all__ = ['Error', 'Context', 'Driver', 'Device', 'Session', 'Packet']
|
__all__ = ['Error', 'Context', 'Driver', 'Device', 'Session', 'Packet']
|
||||||
|
@ -54,7 +54,7 @@ def gvariant_to_python(value):
|
||||||
return Fraction(
|
return Fraction(
|
||||||
g_variant_get_uint64(g_variant_get_child_value(value, 0)),
|
g_variant_get_uint64(g_variant_get_child_value(value, 0)),
|
||||||
g_variant_get_uint64(g_variant_get_child_value(value, 1)))
|
g_variant_get_uint64(g_variant_get_child_value(value, 1)))
|
||||||
raise NotImplementedError, (
|
raise NotImplementedError(
|
||||||
"Can't convert GVariant type '%s' to a Python type." % type_string)
|
"Can't convert GVariant type '%s' to a Python type." % type_string)
|
||||||
|
|
||||||
def python_to_gvariant(value):
|
def python_to_gvariant(value):
|
||||||
|
@ -73,7 +73,7 @@ def python_to_gvariant(value):
|
||||||
result = g_variant_new_tuple(array, 2)
|
result = g_variant_new_tuple(array, 2)
|
||||||
delete_gvariant_ptr_array(array)
|
delete_gvariant_ptr_array(array)
|
||||||
return result
|
return result
|
||||||
raise NotImplementedError, (
|
raise NotImplementedError(
|
||||||
"Can't convert Python '%s' to a GVariant." % type(value))
|
"Can't convert Python '%s' to a GVariant." % type(value))
|
||||||
|
|
||||||
def callback_wrapper(session, callback, device_ptr, packet_ptr):
|
def callback_wrapper(session, callback, device_ptr, packet_ptr):
|
||||||
|
@ -153,7 +153,7 @@ class Device(object):
|
||||||
check(sr_config_get(self.driver.struct, key, data, self.struct))
|
check(sr_config_get(self.driver.struct, key, data, self.struct))
|
||||||
except Error as error:
|
except Error as error:
|
||||||
if error.errno == SR_ERR_ARG:
|
if error.errno == SR_ERR_ARG:
|
||||||
raise NotImplementedError, (
|
raise NotImplementedError(
|
||||||
"Device does not implement %s" % name)
|
"Device does not implement %s" % name)
|
||||||
else:
|
else:
|
||||||
raise AttributeError
|
raise AttributeError
|
||||||
|
@ -226,7 +226,7 @@ class Packet(object):
|
||||||
self._payload = Logic(self,
|
self._payload = Logic(self,
|
||||||
void_ptr_to_sr_datafeed_logic_ptr(pointer))
|
void_ptr_to_sr_datafeed_logic_ptr(pointer))
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError, (
|
raise NotImplementedError(
|
||||||
"No Python mapping for packet type %ѕ" % self.struct.type)
|
"No Python mapping for packet type %ѕ" % self.struct.type)
|
||||||
return self._payload
|
return self._payload
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue