Skip to content

Commit 4ab260a

Browse files
authored
Merge pull request #98 from jkonecny12/master-fix-pylint-duplicate-code
Fix pylint duplicate code
2 parents d239f2d + b349237 commit 4ab260a

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

.pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ confidence=
6060
# --enable=similarities". If you want to run only the classes checker, but have
6161
# no Warning level messages displayed, use "--disable=all --enable=classes
6262
# --disable=W".
63-
disable=fixme,
63+
disable=duplicate-code,
64+
fixme,
6465
invalid-name,
6566
missing-docstring,
6667
no-self-use,

simpleline/event_loop/__init__.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,29 @@ def enqueue_signal(self, signal):
9696
signal,
9797
signal.source.__class__.__name__)
9898

99-
@abstractmethod
10099
def run(self):
101100
"""Starts the event loop."""
102101
log.debug("Starting main loop")
103102
self._force_quit = False
104103

104+
# Start a loop specific code.
105+
self._run()
106+
107+
log.debug("Main loop ended. Running callback if set.")
108+
109+
if self._quit_callback:
110+
cb = self._quit_callback.callback
111+
cb(self._quit_callback.args)
112+
113+
@abstractmethod
114+
def _run(self):
115+
"""Internal implementation of run method.
116+
117+
Event loop specific implementation goes here.
118+
Exit callbacks are not processed here but by the `run` method.
119+
"""
120+
pass
121+
105122
def force_quit(self):
106123
"""Force quit all running event loops.
107124

simpleline/event_loop/glib_event_loop.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,12 @@ def _quit_all_loops(self):
133133
for loop_data in reversed(self._event_loops):
134134
loop_data.loop.quit()
135135

136-
def run(self):
136+
def _run(self):
137137
"""Starts the event loop."""
138-
super().run()
139138
if len(self._event_loops) != 1:
140139
raise ValueError("Can't run event loop multiple times.")
141140

142141
self._event_loops[0].loop.run()
143-
log.debug("Main loop ended. Running callback if set.")
144-
145-
if self._quit_callback:
146-
cb = self._quit_callback.callback
147-
cb(self._quit_callback.args)
148142

149143
def force_quit(self):
150144
"""Force quit all running event loops.

simpleline/event_loop/main_loop.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,19 @@ def register_signal_source(self, signal_source):
5454
super().register_signal_source(signal_source)
5555
self._active_queue.add_source(signal_source)
5656

57-
def run(self):
57+
def _run(self):
5858
"""This methods starts the application.
5959
6060
Do not use self.mainloop() directly as run() handles all the required exceptions
6161
needed to keep nested mainloop working.
6262
"""
63-
super().run()
6463
self._run_loop = True
6564

6665
try:
6766
self._mainloop()
6867
except ExitMainLoop:
6968
pass
7069

71-
log.debug("Main loop ended. Running callback if set.")
72-
73-
if self._quit_callback:
74-
cb = self._quit_callback.callback
75-
cb(self._quit_callback.args)
76-
7770
def force_quit(self):
7871
"""Force quit all running event loops.
7972

0 commit comments

Comments
 (0)