Skip to content

Commit 26b648a

Browse files
committed
Run pyupgrade on codebase
https://github.com/asottile/pyupgrade `pyupgrade --py37-plus`
1 parent dd36be6 commit 26b648a

11 files changed

+48
-61
lines changed

doc/fake__jack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def new_find_library(name):
1515
ctypes.util.find_library = new_find_library
1616

1717

18-
class Fake(object):
18+
class Fake:
1919

2020
NULL = NotImplemented
2121

examples/aliases.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@
1717
else:
1818
print('JACK server was already running')
1919
if client.status.name_not_unique:
20-
print('unique client name generated: {}'.format(client.name))
20+
print(f'unique client name generated: {client.name}')
2121

2222
ports = client.get_ports()
2323

2424
print('Testing set_alias() ...')
2525
for i, port in enumerate(ports):
26-
alias_name = 'Alias Name {}'.format(i)
27-
print("port '{}' => set_alias('{}')".format(port.shortname,alias_name))
26+
alias_name = f'Alias Name {i}'
27+
print(f"port '{port.shortname}' => set_alias('{alias_name}')")
2828
port.set_alias(alias_name)
2929

3030
print('Testing aliases property ...')
3131
for port in ports:
3232
for i, alias in enumerate(port.aliases):
33-
print("port '{}', alias {} => '{}'".format(port.shortname,i,alias))
33+
print(f"port '{port.shortname}', alias {i} => '{alias}'")
3434

3535
print('Testing unset_alias() ...')
3636
for i, port in enumerate(ports):
37-
alias_name = 'Alias Name {}'.format(i)
38-
print("port '{}' => unset_alias('{}')".format(port.shortname,alias_name))
37+
alias_name = f'Alias Name {i}'
38+
print(f"port '{port.shortname}' => unset_alias('{alias_name}')")
3939
port.unset_alias(alias_name)
4040

4141
print('Testing aliases property ...')
4242
for port in ports:
4343
for i, alias in enumerate(port.aliases):
44-
print("port '{}', alias {} => '{}'".format(port.shortname,i,alias))
44+
print(f"port '{port.shortname}', alias {i} => '{alias}'")

examples/chatty_client.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
and prints some information whenever they are called.
88
99
"""
10-
from __future__ import print_function # only needed for Python 2.x
1110
import jack
1211

1312
print('setting error/info functions')
@@ -96,7 +95,7 @@ def xrun(delay):
9695
try:
9796
@client.set_property_change_callback
9897
def property_change(subject, key, changed):
99-
print('subject {}: '.format(subject), end='')
98+
print(f'subject {subject}: ', end='')
10099
if not key:
101100
assert changed == jack.PROPERTY_DELETED
102101
print('all properties were removed')

examples/midi_monitor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@client.set_process_callback
1313
def process(frames):
1414
for offset, data in port.incoming_midi_events():
15-
print('{0}: 0x{1}'.format(client.last_frame_time + offset,
15+
print('{}: 0x{}'.format(client.last_frame_time + offset,
1616
binascii.hexlify(data).decode()))
1717

1818
with client:

examples/play_file.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
installed for this to work.
1111
1212
"""
13-
from __future__ import division
14-
from __future__ import print_function
1513
import argparse
1614
try:
1715
import queue # Python 3.x
@@ -87,7 +85,7 @@ def process(frames):
8785

8886
with sf.SoundFile(args.filename) as f:
8987
for ch in range(f.channels):
90-
client.outports.register('out_{0}'.format(ch + 1))
88+
client.outports.register(f'out_{ch + 1}')
9189
block_generator = f.blocks(blocksize=blocksize, dtype='float32',
9290
always_2d=True, fill_value=0)
9391
for _, data in zip(range(args.buffersize), block_generator):

examples/showtime.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def showtime():
2525
items = []
2626
items.append('frame = {} frame_time = {} usecs = {} '.format(
2727
pos['frame'], client.frame_time, pos['usecs']))
28-
items.append('state: {}'.format(state))
28+
items.append(f'state: {state}')
2929
with suppress(KeyError):
3030
items.append('BBT: {bar:3}|{beat}|{tick:04}'.format(**pos))
3131
with suppress(KeyError):
@@ -38,7 +38,7 @@ def showtime():
3838
with suppress(KeyError):
3939
video_offset = pos['video_offset']
4040
if video_offset:
41-
items.append(' video@: ({})'.format(video_offset))
41+
items.append(f' video@: ({video_offset})')
4242
else:
4343
items.append(' no video');
4444
print(*items, sep='\t')

examples/slow_sync.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def slow_sync_callback(state, pos):
2626
slow.pos = pos.frame
2727
slow.ready_at = None
2828
return True
29-
print('will be ready in {:.2f} seconds'.format(slow.ready_at - now))
29+
print(f'will be ready in {slow.ready_at - now:.2f} seconds')
3030
elif state == jack.STARTING:
3131
if slow.pos == pos.frame:
3232
print('ready')
@@ -38,7 +38,7 @@ def slow_sync_callback(state, pos):
3838
slow.pos = pos.frame
3939
slow.ready_at = None
4040
return True
41-
print('will be ready in {:.2f} seconds'.format(slow.ready_at - now))
41+
print(f'will be ready in {slow.ready_at - now:.2f} seconds')
4242
return False
4343
elif state == jack.ROLLING:
4444
assert slow.pos != pos.frame
@@ -48,7 +48,7 @@ def slow_sync_callback(state, pos):
4848
slow.pos = pos.frame
4949
slow.ready_at = None
5050
return True
51-
print('will catch up in {:.2f} seconds'.format(slow.ready_at - now))
51+
print(f'will catch up in {slow.ready_at - now:.2f} seconds')
5252
return False
5353
else:
5454
assert False

examples/thru_client.py

+3-13
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,10 @@
1010
1111
"""
1212
import sys
13-
import signal
1413
import os
1514
import jack
1615
import threading
1716

18-
if sys.version_info < (3, 0):
19-
# In Python 2.x, event.wait() cannot be interrupted with Ctrl+C.
20-
# Therefore, we disable the whole KeyboardInterrupt mechanism.
21-
# This will not close the JACK client properly, but at least we can
22-
# use Ctrl+C.
23-
signal.signal(signal.SIGINT, signal.SIG_DFL)
24-
else:
25-
# If you use Python 3.x, everything is fine.
26-
pass
2717

2818
argv = iter(sys.argv)
2919
# By default, use script name without extension as client name:
@@ -36,7 +26,7 @@
3626
if client.status.server_started:
3727
print('JACK server started')
3828
if client.status.name_not_unique:
39-
print('unique name {0!r} assigned'.format(client.name))
29+
print(f'unique name {client.name!r} assigned')
4030

4131
event = threading.Event()
4232

@@ -59,8 +49,8 @@ def shutdown(status, reason):
5949

6050
# create two port pairs
6151
for number in 1, 2:
62-
client.inports.register('input_{0}'.format(number))
63-
client.outports.register('output_{0}'.format(number))
52+
client.inports.register(f'input_{number}')
53+
client.outports.register(f'output_{number}')
6454

6555
with client:
6656
# When entering this with-statement, client.activate() is called.

examples/timebase_master.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def main(args=None):
118118
ticks_per_beat=args.ticks_per_beat,
119119
debug=args.debug)
120120
except jack.JackError as exc:
121-
ap.exit('Could not create timebase master JACK client: {}'.format(exc))
121+
ap.exit(f'Could not create timebase master JACK client: {exc}')
122122

123123
with tbmaster:
124124
if tbmaster.become_timebase_master(args.conditional):

examples/transporter.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ def main(args=None):
2525
try:
2626
client = jack.Client(args.client_name)
2727
except jack.JackError as exc:
28-
ap.exit('Could not create JACK client: {}'.format(exc))
28+
ap.exit(f'Could not create JACK client: {exc}')
2929

3030
state = client.transport_state
3131
result = 0
3232

3333
if args.command == 'status':
34-
print('JACK transport state is {}.'.format(state))
34+
print(f'JACK transport state is {state}.')
3535
result = 1 if state == jack.STOPPED else 0
3636
elif args.command == 'query':
37-
print('State: {}'.format(state))
37+
print(f'State: {state}')
3838
info = client.transport_query()[1]
3939

4040
for field in sorted(info):
4141
label = string.capwords(field.replace('_', ' '))
42-
print('{}: {}'.format(label, info[field]))
42+
print(f'{label}: {info[field]}')
4343

4444
result = 1 if state == jack.STOPPED else 0
4545
elif args.command == 'start':

0 commit comments

Comments
 (0)