blob: 69a443df16486c18bd6acf92015f532417d75da3 [file] [log] [blame]
# Patch the 'format' syntax for Python 2.6 compatability
diff --git a/bin/evtest.py b/bin/evtest.py
index b99ad54..9b91e52 100755
--- a/bin/evtest.py
+++ b/bin/evtest.py
@@ -12,7 +12,7 @@ from evdev import ecodes, InputDevice, list_devices, AbsInfo
usage = 'usage: evtest <device> [<type> <value>]'
-evfmt = 'time {:<16} type {} ({}), code {:<4} ({}), value {}'
+evfmt = 'time {0:<16} type {1} ({2}), code {3:<4} ({4}), value {5}'
device_dir = '/dev/input/'
query_type = None
query_value = None
@@ -26,21 +26,21 @@ def select_device():
dev_fmt = '{0:<3} {1.fn:<20} {1.name:<35} {1.phys}'
dev_lns = [dev_fmt.format(n, d) for n, d in enumerate(devices)]
- print('ID {:<20} {:<35} {}'.format('Device', 'Name', 'Phys'))
+ print('ID {0:<20} {1:<35} {2}'.format('Device', 'Name', 'Phys'))
print('-' * len(max(dev_lns, key=len)))
print('\n'.join(dev_lns))
print('')
- choice = input('Select device [0-{}]:'.format(len(dev_lns)-1))
+ choice = input('Select device [0-{0}]:'.format(len(dev_lns)-1))
return devices[int(choice)]
def print_event(e):
if e.type == ecodes.EV_SYN:
if e.code == ecodes.SYN_MT_REPORT:
- print('time {:<16} +++++++++ {} ++++++++'.format(e.timestamp(), ecodes.SYN[e.code]))
+ print('time {0:<16} +++++++++ {1} ++++++++'.format(e.timestamp(), ecodes.SYN[e.code]))
else:
- print('time {:<16} --------- {} --------'.format(e.timestamp(), ecodes.SYN[e.code]))
+ print('time {0:<16} --------- {1} --------'.format(e.timestamp(), ecodes.SYN[e.code]))
else:
if e.type in ecodes.bytype:
codename = ecodes.bytype[e.type][e.code]
@@ -64,19 +64,19 @@ else:
print(usage) ; exit(1)
-print('Device name: {.name}'.format(device))
-print('Device info: {.info}'.format(device))
-print('Repeat settings: {}'.format(device.repeat))
+print('Device name: {0.name}'.format(device))
+print('Device info: {0.info}'.format(device))
+print('Repeat settings: {0}'.format(device.repeat))
print('Device capabilities:')
for type, codes in device.capabilities(verbose=True).items():
- print(' Type {} {}:'.format(*type))
+ print(' Type {0} {1}:'.format(*type))
for i in codes:
if isinstance(i[1], AbsInfo):
- print(' Code {:<4} {}:'.format(*i[0]))
- print(' {}'.format(i[1]))
+ print(' Code {0:<4} {1}:'.format(*i[0]))
+ print(' {0}'.format(i[1]))
else:
- print(' Code {:<4} {}'.format(*i))
+ print(' Code {0:<4} {1}'.format(*i))
print('')
diff --git a/evdev/device.py b/evdev/device.py
index 9424140..b979a0a 100644
--- a/evdev/device.py
+++ b/evdev/device.py
@@ -48,7 +48,7 @@ class AbsInfo(_AbsInfo):
pass
def __str__(self):
- return 'val {}, min {}, max {}, fuzz {}, flat {}, res {}'.format(*self)
+ return 'val {0}, min {1}, max {2}, fuzz {3}, flat {4}, res {5}'.format(*self)
class KbdInfo(_KbdInfo):
@@ -64,12 +64,12 @@ class KbdInfo(_KbdInfo):
'''
def __str__(self):
- return 'repeat {}, delay {}'.format(*self)
+ return 'repeat {0}, delay {1}'.format(*self)
class DeviceInfo(_DeviceInfo):
def __str__(self):
- msg = 'bus: {:04x}, product {:04x}, vendor {:04x}, version {:04x}'
+ msg = 'bus: {0:04x}, product {1:04x}, vendor {2:04x}, version {3:04x}'
return msg.format(*self)
@@ -185,12 +185,12 @@ class InputDevice(object):
return self.info == o.info
def __str__(self):
- msg = 'device {}, name "{}", phys "{}"'
+ msg = 'device {0}, name "{1}", phys "{2}"'
return msg.format(self.fn, self.name, self.phys)
def __repr__(self):
msg = (self.__class__.__name__, self.fn)
- return '{}({!r})'.format(*msg)
+ return '{0}({1!r})'.format(*msg)
def close(self):
os.close(self.fd)
diff --git a/evdev/events.py b/evdev/events.py
index ed7aaa4..c75764e 100644
--- a/evdev/events.py
+++ b/evdev/events.py
@@ -68,11 +68,11 @@ class InputEvent(object):
return self.sec + (self.usec / 1000000.0)
def __str__(s):
- msg = 'event at {:f}, code {:02d}, type {:02d}, val {:02d}'
+ msg = 'event at {0:f}, code {1:02d}, type {2:02d}, val {3:02d}'
return msg.format(s.timestamp(), s.code, s.type, s.value)
def __repr__(s):
- msg = '{}({!r}, {!r}, {!r}, {!r}, {!r})'
+ msg = '{0}({1!r}, {2!r}, {3!r}, {4!r}, {5!r})'
return msg.format(s.__class__.__name__,
s.sec, s.usec, s.type, s.code, s.value)
@@ -107,12 +107,12 @@ class KeyEvent(object):
try: ks = ('up', 'down', 'hold')[self.keystate]
except: ks = 'unknown'
- msg = 'key event at {:f}, {} ({}), {}'
+ msg = 'key event at {0:f}, {1} ({2}), {3}'
return msg.format(self.event.timestamp(),
self.scancode, self.keycode, ks)
def __repr__(s):
- return '{}({!r})'.format(s.__class__.__name__, s.event)
+ return '{0}({1!r})'.format(s.__class__.__name__, s.event)
class RelEvent(object):
@@ -128,11 +128,11 @@ class RelEvent(object):
self.event = event
def __str__(self):
- msg = 'relative axis event at {:f}, {} '
+ msg = 'relative axis event at {0:f}, {1} '
return msg.format(self.event.timestamp(), REL[self.event.code])
def __repr__(s):
- return '{}({!r})'.format(s.__class__.__name__, s.event)
+ return '{0}({1!r})'.format(s.__class__.__name__, s.event)
class AbsEvent(object):
@@ -148,11 +148,11 @@ class AbsEvent(object):
self.event = event
def __str__(self):
- msg = 'absolute axis event at {:f}, {} '
+ msg = 'absolute axis event at {0:f}, {1} '
return msg.format(self.event.timestamp(), ABS[self.event.code])
def __repr__(s):
- return '{}({!r})'.format(s.__class__.__name__, s.event)
+ return '{0}({1!r})'.format(s.__class__.__name__, s.event)
class SynEvent(object):
@@ -168,11 +168,11 @@ class SynEvent(object):
self.event = event
def __str__(self):
- msg = 'synchronization event at {:f}, {} '
+ msg = 'synchronization event at {0:f}, {1} '
return msg.format(self.event.timestamp(), SYN[self.event.code])
def __repr__(s):
- return '{}({!r})'.format(s.__class__.__name__, s.event)
+ return '{0}({1!r})'.format(s.__class__.__name__, s.event)
#: Used by :func:`evdev.util.categorize()`
diff --git a/evdev/uinput.py b/evdev/uinput.py
index 2e14a54..4a485ce 100644
--- a/evdev/uinput.py
+++ b/evdev/uinput.py
@@ -98,11 +98,11 @@ class UInput(object):
# :todo:
v = (repr(getattr(self, i)) for i in
('name', 'bustype', 'vendor', 'product', 'version'))
- return '{}({})'.format(self.__class__.__name__, ', '.join(v))
+ return '{0}({1})'.format(self.__class__.__name__, ', '.join(v))
def __str__(self):
- msg = ('name "{}", bus "{}", vendor "{:04x}", product "{:04x}", version "{:04x}"\n'
- 'event types: {}')
+ msg = ('name "{0}", bus "{1}", vendor "{2:04x}", product "{3:04x}", version "{4:04x}"\n'
+ 'event types: {5}')
evtypes = [i[0] for i in self.capabilities(True).keys()]
msg = msg.format(self.name, ecodes.BUS[self.bustype], self.vendor, self.product,
@@ -177,16 +177,16 @@ class UInput(object):
if not stat.S_ISCHR(m):
raise
except:
- msg = '"{}" does not exist or is not a character device file '\
+ msg = '"{0}" does not exist or is not a character device file '\
'- verify that the uinput module is loaded'
raise UInputError(msg.format(self.devnode))
if not os.access(self.devnode, os.W_OK):
- msg = '"{}" cannot be opened for writing'
+ msg = '"{0}" cannot be opened for writing'
raise UInputError(msg.format(self.devnode))
if len(self.name) > _uinput.maxnamelen:
- msg = 'uinput device name must not be longer than {} characters'
+ msg = 'uinput device name must not be longer than {0} characters'
raise UInputError(msg.format(_uinput.maxnamelen))
def _find_device(self):
diff --git a/evdev/util.py b/evdev/util.py
index 9d332be..52f2386 100644
--- a/evdev/util.py
+++ b/evdev/util.py
@@ -11,7 +11,7 @@ from evdev.events import event_factory
def list_devices(input_device_dir='/dev/input'):
'''List readable character devices.'''
- fns = glob.glob('{}/event*'.format(input_device_dir))
+ fns = glob.glob('{0}/event*'.format(input_device_dir))
fns = list(filter(is_device, fns))
return fns
diff --git a/setup.py b/setup.py
index 74fb0da..cda377e 100755
--- a/setup.py
+++ b/setup.py
@@ -83,9 +83,9 @@ def create_ecodes():
from subprocess import check_call
- print('writing ecodes.c (using {})'.format(header))
- check_call('bash ./ecodes.sh {} > ecodes.c'.format(header),
- cwd='{}/evdev'.format(here),
+ print('writing ecodes.c (using {0})'.format(header))
+ check_call('bash ./ecodes.sh {0} > ecodes.c'.format(header),
+ cwd='{0}/evdev'.format(here),
shell=True)