Skip to content

Commit 3a82071

Browse files
committed
Remove all Python 2 __future__ calls
1 parent 504f8ff commit 3a82071

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+4349
-4473
lines changed

scc/actions.py

Lines changed: 488 additions & 489 deletions
Large diffs are not rendered by default.

scc/cemuhook_server.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
Accepts all connections from clients and sends data captured
66
by 'cemuhook' actions to them.
77
"""
8-
from __future__ import unicode_literals
98
from scc.tools import find_library
109
from scc.lib.enum import IntEnum
1110
from ctypes import c_uint32, c_int, c_bool, c_char_p, c_size_t, c_float
@@ -33,7 +32,7 @@ class MessageType(IntEnum):
3332
class CemuhookServer:
3433
C_DATA_T = c_float * 6
3534
timeout = timedelta(seconds=1)
36-
35+
3736
def __init__(self, daemon):
3837
self._lib = find_library('libcemuhook')
3938
self._lib.cemuhook_data_received.argtypes = [ c_int, c_char_p, c_int, c_char_p, c_size_t ]
@@ -43,44 +42,42 @@ def __init__(self, daemon):
4342
self._lib.cemuhook_socket_enable.argtypes = []
4443
self._lib.cemuhook_socket_enable.restype = c_bool
4544
self.last_signal = datetime.now()
46-
45+
4746
if not self._lib.cemuhook_socket_enable():
4847
raise OSError("cemuhook_socket_enable failed")
49-
48+
5049
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
5150
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
52-
51+
5352
poller = daemon.get_poller()
5453
daemon.poller.register(self.socket.fileno(), poller.POLLIN, self.on_data_received)
55-
54+
5655
server_port = int(os.getenv('SCC_SERVER_PORT') or PORT);
5756
server_ip = os.getenv('SCC_SERVER_IP') or IP;
5857
self.socket.bind((server_ip, server_port))
5958
log.info("Created CemuHookUDP Motion Provider")
6059

6160
Thread(target=self._keepalive).start()
6261

63-
62+
6463
def _keepalive(self):
6564
while True:
6665
if datetime.now() - self.last_signal >= self.timeout:
6766
# feed all zeroes to indicate the gyro has not changed
6867
self.feed((0.0, 0.0, 0.0, 0.0, 0.0, 0.0))
6968
sleep(1)
70-
69+
7170
def on_data_received(self, fd, event_type):
7271
if fd != self.socket.fileno(): return
7372
message, (ip, port) = self.socket.recvfrom(BUFFER_SIZE)
7473
buffer = create_string_buffer(BUFFER_SIZE)
7574
self._lib.cemuhook_data_received(fd, ip.encode('utf-8'), port, message, len(message), buffer)
76-
77-
75+
76+
7877
def feed(self, data):
7978
self.last_signal = datetime.now()
8079
c_data = CemuhookServer.C_DATA_T()
8180
#log.debug(data)
8281
c_data[0:6] = data[0:6]
8382
#log.debug(list(c_data))
8483
self._lib.cemuhook_feed(self.socket.fileno(), 0, c_data)
85-
86-

scc/config.py

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
55
Handles loading, storing and querying config file
66
"""
7-
from __future__ import unicode_literals
8-
97
from scc.paths import get_config_path
108
from scc.profile import Encoder
119
from scc.special_actions import ChangeProfileAction
@@ -39,7 +37,7 @@ class Config(object):
3937
"ds4drv": True, # At least one of hiddrv or evdevdrv has to be enabled as well
4038
"ds5drv": True,
4139
},
42-
"fix_xinput" : True, # If True, attempt is done to deatach emulated controller
40+
"fix_xinput" : True, # If True, attempt is done to deatach emulated controller
4341
# from 'Virtual core pointer' core device.
4442
"gui": {
4543
# GUI-only settings
@@ -112,7 +110,7 @@ class Config(object):
112110
# See drivers/sc_dongle.py, read_serial method
113111
"ignore_serials" : True,
114112
}
115-
113+
116114
CONTROLLER_DEFAULTS = {
117115
# Defaults for controller config
118116
"name": None, # Filled with controller ID on runtime
@@ -126,13 +124,13 @@ class Config(object):
126124
"menu_confirm": "A",
127125
"menu_cancel": "B",
128126
}
129-
130-
127+
128+
131129
def __init__(self):
132130
self.filename = os.path.join(get_config_path(), "config.json")
133131
self.reload()
134-
135-
132+
133+
136134
def reload(self):
137135
""" (Re)loads configuration. Works as load(), but handles exceptions """
138136
try:
@@ -143,13 +141,13 @@ def reload(self):
143141
self.create()
144142
if self.check_values():
145143
self.save()
146-
147-
144+
145+
148146
def _check_dict(self, values, defaults):
149147
"""
150148
Recursivelly checks if 'config' contains all keys in 'defaults'.
151149
Creates keys with default values where missing.
152-
150+
153151
Returns True if anything was changed.
154152
"""
155153
rv = False
@@ -160,13 +158,13 @@ def _check_dict(self, values, defaults):
160158
if type(values[d]) == dict:
161159
rv = self._check_dict(values[d], defaults[d]) or rv
162160
return rv
163-
164-
161+
162+
165163
def check_values(self):
166164
"""
167165
Check if all required values are in place and fill by default
168166
whatever is missing.
169-
167+
170168
Returns True if anything gets changed.
171169
"""
172170
rv = self._check_dict(self.values, self.DEFAULTS)
@@ -178,8 +176,8 @@ def check_values(self):
178176
del a["profile"]
179177
rv = True
180178
return rv
181-
182-
179+
180+
183181
def get_controller_config(self, controller_id):
184182
"""
185183
Returns self['controllers'][controller_id], creating new node populated
@@ -202,19 +200,19 @@ def get_controller_config(self, controller_id):
202200
}
203201
rv["name"] = controller_id
204202
return rv
205-
206-
203+
204+
207205
def load(self):
208206
self.values = json.loads(open(self.filename, "r").read())
209-
210-
207+
208+
211209
def create(self):
212210
""" Creates new, empty configuration """
213211
self.values = {}
214212
self.check_values()
215213
self.save()
216-
217-
214+
215+
218216
def save(self):
219217
""" Saves configuration file """
220218
# Check & create directory
@@ -225,22 +223,21 @@ def save(self):
225223
jstr = Encoder(sort_keys=True, indent=4).encode(data)
226224
open(self.filename, "w").write(jstr)
227225
log.debug("Configuration saved")
228-
229-
226+
227+
230228
def __iter__(self):
231229
for k in self.values:
232230
yield k
233-
231+
234232
def get(self, key, default=None):
235233
return self.values.get(key, default)
236-
234+
237235
def set(self, key, value):
238236
self.values[key] = value
239-
237+
240238
__getitem__ = get
241239
__setitem__ = set
242-
240+
243241
def __contains__(self, key):
244242
""" Returns true if there is such value """
245243
return key in self.values
246-

scc/gui/aboutdialog.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
SC-Controller - About dialog
44
"""
5-
from __future__ import unicode_literals
65
from scc.tools import _
76

87
from gi.repository import Gtk
@@ -12,15 +11,15 @@
1211
class AboutDialog(Editor):
1312
""" Standard looking about dialog """
1413
GLADE = "about.glade"
15-
14+
1615
def __init__(self, app):
1716
self.app = app
1817
self.setup_widgets()
19-
20-
18+
19+
2120
def setup_widgets(self):
2221
Editor.setup_widgets(self)
23-
22+
2423
# Get app version
2524
app_ver = "(unknown version)"
2625
try:
@@ -33,15 +32,14 @@ def setup_widgets(self):
3332
pass
3433
# Display version in UI
3534
self.builder.get_object("lblVersion").set_label(app_ver)
36-
37-
35+
36+
3837
def show(self, modal_for):
3938
if modal_for:
4039
self.window.set_transient_for(modal_for)
4140
self.window.set_modal(True)
4241
self.window.show()
43-
44-
42+
43+
4544
def on_dialog_response(self, *a):
4645
self.close()
47-

0 commit comments

Comments
 (0)