Merge lp:~elopio/autopilot/fix1201057-pep8-3 into lp:autopilot
- fix1201057-pep8-3
- Merge into trunk
Proposed by
Leo Arias
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Thomi Richards | ||||
Approved revision: | 281 | ||||
Merged at revision: | 269 | ||||
Proposed branch: | lp:~elopio/autopilot/fix1201057-pep8-3 | ||||
Merge into: | lp:autopilot | ||||
Prerequisite: | lp:~elopio/autopilot/fix1201057-pep8-2 | ||||
Diff against target: |
389 lines (+77/-58) 8 files modified
autopilot/display/_X11.py (+8/-5) autopilot/display/__init__.py (+16/-11) autopilot/display/_upa.py (+1/-0) autopilot/vis/__init__.py (+1/-1) autopilot/vis/bus_enumerator.py (+10/-12) autopilot/vis/main_window.py (+17/-11) autopilot/vis/objectproperties.py (+16/-10) autopilot/vis/resources.py (+8/-8) |
||||
To merge this branch: | bzr merge lp:~elopio/autopilot/fix1201057-pep8-3 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Thomi Richards (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+174601@code.launchpad.net |
Commit message
Fixed pep8 errors in autopilto/vis and autopilot/display.
Description of the change
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'autopilot/display/_X11.py' |
2 | --- autopilot/display/_X11.py 2013-05-02 15:59:26 +0000 |
3 | +++ autopilot/display/_X11.py 2013-07-14 08:34:30 +0000 |
4 | @@ -24,16 +24,19 @@ |
5 | |
6 | logger = logging.getLogger(__name__) |
7 | |
8 | + |
9 | class Display(DisplayBase): |
10 | def __init__(self): |
11 | - # Note: MUST import these here, rather than at the top of the file. Why? |
12 | - # Because sphinx imports these modules to build the API documentation, |
13 | - # which in turn tries to import Gdk, which in turn fails because there's |
14 | - # no DISPlAY environment set in the package builder. |
15 | + # Note: MUST import these here, rather than at the top of the file. |
16 | + # Why? Because sphinx imports these modules to build the API |
17 | + # documentation, which in turn tries to import Gdk, which in turn |
18 | + # fails because there's no DISPlAY environment set in the package |
19 | + # builder. |
20 | from gi.repository import Gdk |
21 | self._default_screen = Gdk.Screen.get_default() |
22 | if self._default_screen is None: |
23 | - raise RuntimeError("Unable to determine default screen information") |
24 | + raise RuntimeError( |
25 | + "Unable to determine default screen information") |
26 | self._blacklisted_drivers = ["NVIDIA"] |
27 | |
28 | def get_num_screens(self): |
29 | |
30 | === modified file 'autopilot/display/__init__.py' |
31 | --- autopilot/display/__init__.py 2013-04-23 04:15:54 +0000 |
32 | +++ autopilot/display/__init__.py 2013-07-14 08:34:30 +0000 |
33 | @@ -26,7 +26,8 @@ |
34 | |
35 | |
36 | def is_rect_on_screen(screen_number, rect): |
37 | - """Returns True if *rect* is **entirely** on the specified screen, with no overlap.""" |
38 | + """Returns True if *rect* is **entirely** on the specified screen, with no |
39 | + overlap.""" |
40 | (x, y, w, h) = rect |
41 | (mx, my, mw, mh) = Display.create().get_screen_geometry(screen_number) |
42 | return (x >= mx and x + w <= mx + mw and y >= my and y + h <= my + mh) |
43 | @@ -45,7 +46,8 @@ |
44 | |
45 | def is_point_on_any_screen(point): |
46 | """Returns true if *point* is on any currently configured screen.""" |
47 | - return any([is_point_on_screen(m, point) for m in range(Display.create().get_num_screens())]) |
48 | + return any([is_point_on_screen(m, point) for m in |
49 | + range(Display.create().get_num_screens())]) |
50 | |
51 | |
52 | def move_mouse_to_screen(screen_number): |
53 | @@ -70,7 +72,8 @@ |
54 | # raise TypeError("Window must be a BamfWindow") |
55 | |
56 | # if window.monitor == screen: |
57 | -# logger.debug("Window %r is already on screen %d." % (window.x_id, screen)) |
58 | +# logger.debug( |
59 | +# "Window %r is already on screen %d." % (window.x_id, screen)) |
60 | # return |
61 | |
62 | # assert(not window.is_maximized) |
63 | @@ -102,21 +105,22 @@ |
64 | def create(preferred_backend=''): |
65 | """Get an instance of the Display class. |
66 | |
67 | - For more infomration on picking specific backends, see :ref:`tut-picking-backends` |
68 | + For more infomration on picking specific backends, see |
69 | + :ref:`tut-picking-backends` |
70 | |
71 | - :param preferred_backend: A string containing a hint as to which backend you |
72 | - would like. |
73 | + :param preferred_backend: A string containing a hint as to which |
74 | + backend you would like. |
75 | |
76 | possible backends are: |
77 | |
78 | * ``X11`` - Get display information from X11. |
79 | * ``UPA`` - Get display information from the ubuntu platform API. |
80 | - :raises: RuntimeError if autopilot cannot instantate any of the possible |
81 | - backends. |
82 | + :raises: RuntimeError if autopilot cannot instantate any of the |
83 | + possible backends. |
84 | :raises: RuntimeError if the preferred_backend is specified and is not |
85 | one of the possible backends for this device class. |
86 | - :raises: :class:`~autopilot.BackendException` if the preferred_backend is |
87 | - set, but that backend could not be instantiated. |
88 | + :raises: :class:`~autopilot.BackendException` if the preferred_backend |
89 | + is set, but that backend could not be instantiated. |
90 | |
91 | """ |
92 | def get_x11_display(): |
93 | @@ -133,7 +137,8 @@ |
94 | return _pick_backend(backends, preferred_backend) |
95 | |
96 | class BlacklistedDriverError(RuntimeError): |
97 | - """Cannot set primary monitor when running drivers listed in the driver blacklist.""" |
98 | + """Cannot set primary monitor when running drivers listed in the |
99 | + driver blacklist.""" |
100 | |
101 | def get_num_screens(self): |
102 | """Get the number of screens attached to the PC.""" |
103 | |
104 | === modified file 'autopilot/display/_upa.py' |
105 | --- autopilot/display/_upa.py 2013-04-23 04:15:54 +0000 |
106 | +++ autopilot/display/_upa.py 2013-07-14 08:34:30 +0000 |
107 | @@ -25,6 +25,7 @@ |
108 | |
109 | logger = logging.getLogger(__name__) |
110 | |
111 | + |
112 | class Display(DisplayBase): |
113 | """The base class/inteface for the display devices""" |
114 | |
115 | |
116 | === modified file 'autopilot/vis/__init__.py' |
117 | --- autopilot/vis/__init__.py 2013-06-25 23:10:27 +0000 |
118 | +++ autopilot/vis/__init__.py 2013-07-14 08:34:30 +0000 |
119 | @@ -26,6 +26,7 @@ |
120 | from autopilot.vis.bus_enumerator import BusEnumerator |
121 | from autopilot.vis.main_window import MainWindow |
122 | |
123 | + |
124 | def vis_main(): |
125 | app = QtGui.QApplication(sys.argv) |
126 | app.setApplicationName("Autopilot") |
127 | @@ -42,4 +43,3 @@ |
128 | |
129 | window.show() |
130 | sys.exit(app.exec_()) |
131 | - |
132 | |
133 | === modified file 'autopilot/vis/bus_enumerator.py' |
134 | --- autopilot/vis/bus_enumerator.py 2013-04-23 04:15:54 +0000 |
135 | +++ autopilot/vis/bus_enumerator.py 2013-07-14 08:34:30 +0000 |
136 | @@ -25,7 +25,7 @@ |
137 | pyqtSignal, |
138 | qDebug, |
139 | QObject, |
140 | - ) |
141 | +) |
142 | from xml.etree import ElementTree |
143 | |
144 | |
145 | @@ -51,12 +51,12 @@ |
146 | self._get_objects_and_interfaces(connection) |
147 | |
148 | def _get_objects_and_interfaces(self, conn_name, obj_name='/'): |
149 | - """Return a list of objects and their interfaces. |
150 | - |
151 | - """ |
152 | + """Return a list of objects and their interfaces.""" |
153 | obj = self._bus.get_object(conn_name, obj_name) |
154 | - obj.Introspect(dbus_interface='org.freedesktop.DBus.Introspectable', |
155 | - reply_handler=lambda xml: self._reply_handler(conn_name, obj_name, xml), |
156 | + obj.Introspect( |
157 | + dbus_interface='org.freedesktop.DBus.Introspectable', |
158 | + reply_handler=lambda xml: self._reply_handler( |
159 | + conn_name, obj_name, xml), |
160 | error_handler=self._error_handler) |
161 | |
162 | def _error_handler(self, *error): |
163 | @@ -68,9 +68,7 @@ |
164 | for child in root.getchildren(): |
165 | child_name = join(obj_name, child.attrib['name']) |
166 | if child.tag == 'node': |
167 | - self._get_objects_and_interfaces( |
168 | - conn_name, |
169 | - child_name) |
170 | + self._get_objects_and_interfaces(conn_name, child_name) |
171 | elif child.tag == 'interface': |
172 | iface_name = child_name.split('/')[-1] |
173 | self._add_hit(conn_name, obj_name, iface_name) |
174 | @@ -103,7 +101,7 @@ |
175 | if connection_string not in self._data.keys(): |
176 | raise KeyError("connection %s not in results" % connection_string) |
177 | if object_path not in self._data[connection_string].keys(): |
178 | - raise KeyError("object %s not in results for connection %s" % (object_path, connection_string)) |
179 | + raise KeyError( |
180 | + "object %s not in results for connection %s" % |
181 | + (object_path, connection_string)) |
182 | return self._data[connection_string][object_path] |
183 | - |
184 | - |
185 | |
186 | === modified file 'autopilot/vis/main_window.py' |
187 | --- autopilot/vis/main_window.py 2013-06-25 23:10:27 +0000 |
188 | +++ autopilot/vis/main_window.py 2013-07-14 08:34:30 +0000 |
189 | @@ -23,7 +23,10 @@ |
190 | import dbus |
191 | from PyQt4 import QtGui, QtCore |
192 | |
193 | -from autopilot.introspection import _get_dbus_address_object, _make_proxy_object |
194 | +from autopilot.introspection import ( |
195 | + _get_dbus_address_object, |
196 | + _make_proxy_object |
197 | +) |
198 | from autopilot.introspection.constants import AP_INTROSPECTION_IFACE |
199 | from autopilot.introspection.dbus import StateNotFoundError |
200 | from autopilot.introspection.qt import QtObjectProxyMixin |
201 | @@ -41,8 +44,8 @@ |
202 | |
203 | def readSettings(self): |
204 | settings = QtCore.QSettings() |
205 | - self.restoreGeometry(settings.value("geometry").toByteArray()); |
206 | - self.restoreState(settings.value("windowState").toByteArray()); |
207 | + self.restoreGeometry(settings.value("geometry").toByteArray()) |
208 | + self.restoreState(settings.value("windowState").toByteArray()) |
209 | |
210 | def closeEvent(self, event): |
211 | settings = QtCore.QSettings() |
212 | @@ -61,7 +64,8 @@ |
213 | self.setCentralWidget(self.splitter) |
214 | |
215 | self.connection_list = QtGui.QComboBox() |
216 | - self.connection_list.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) |
217 | + self.connection_list.setSizeAdjustPolicy( |
218 | + QtGui.QComboBox.AdjustToContents) |
219 | self.connection_list.activated.connect(self.conn_list_activated) |
220 | |
221 | self.toolbar = self.addToolBar('Connection') |
222 | @@ -72,10 +76,11 @@ |
223 | if iface == AP_INTROSPECTION_IFACE: |
224 | self.statusBar().showMessage('Updating connection list') |
225 | try: |
226 | - dbus_address_instance = _get_dbus_address_object(str(conn), str(obj), self._dbus_bus) |
227 | + dbus_address_instance = _get_dbus_address_object( |
228 | + str(conn), str(obj), self._dbus_bus) |
229 | proxy_object = _make_proxy_object(dbus_address_instance, None) |
230 | cls_name = proxy_object.__class__.__name__ |
231 | - if not self.selectable_interfaces.has_key(cls_name): |
232 | + if not cls_name in self.selectable_interfaces: |
233 | self.selectable_interfaces[cls_name] = proxy_object |
234 | self.update_selectable_interfaces() |
235 | except (dbus.DBusException, RuntimeError): |
236 | @@ -93,7 +98,7 @@ |
237 | get_qt_icon(), |
238 | name, |
239 | QtCore.QVariant(proxy_obj) |
240 | - ) |
241 | + ) |
242 | else: |
243 | self.connection_list.addItem(name, QtCore.QVariant(proxy_obj)) |
244 | |
245 | @@ -108,7 +113,8 @@ |
246 | if dbus_details: |
247 | self.tree_model = VisTreeModel(dbus_details) |
248 | self.tree_view.setModel(self.tree_model) |
249 | - self.tree_view.selectionModel().currentChanged.connect(self.tree_item_changed) |
250 | + self.tree_view.selectionModel().currentChanged.connect( |
251 | + self.tree_item_changed) |
252 | |
253 | def tree_item_changed(self, current, previous): |
254 | proxy = current.internalPointer().dbus_object |
255 | @@ -145,8 +151,8 @@ |
256 | def num_children(self): |
257 | """An optimisation that allows us to get the number of children without |
258 | actually retrieving them all. This is useful since Qt needs to know if |
259 | - there are children (to draw the drop-down triangle thingie), but doesn't |
260 | - need to know about the details. |
261 | + there are children (to draw the drop-down triangle thingie), but |
262 | + doesn't need to know about the details. |
263 | |
264 | """ |
265 | num_children = 0 |
266 | @@ -211,7 +217,7 @@ |
267 | |
268 | def headerData(self, column, orientation, role): |
269 | if (orientation == QtCore.Qt.Horizontal and |
270 | - role == QtCore.Qt.DisplayRole): |
271 | + role == QtCore.Qt.DisplayRole): |
272 | try: |
273 | return QtCore.QVariant("Tree Node") |
274 | except IndexError: |
275 | |
276 | === modified file 'autopilot/vis/objectproperties.py' |
277 | --- autopilot/vis/objectproperties.py 2013-05-30 20:38:08 +0000 |
278 | +++ autopilot/vis/objectproperties.py 2013-07-14 08:34:30 +0000 |
279 | @@ -42,8 +42,8 @@ |
280 | def tree_node_changed(self, new_node): |
281 | """Call when the selected tree node has changed. |
282 | |
283 | - This method will update the available tabs to reflect those suitable for |
284 | - the new tree node selected. |
285 | + This method will update the available tabs to reflect those suitable |
286 | + for the new tree node selected. |
287 | |
288 | """ |
289 | for view in self.views: |
290 | @@ -70,7 +70,8 @@ |
291 | |
292 | def name(self): |
293 | """Return the name of the view.""" |
294 | - raise NotImplementedError("This method must be implemented in subclasses!") |
295 | + raise NotImplementedError( |
296 | + "This method must be implemented in subclasses!") |
297 | |
298 | def icon(self): |
299 | """Return the icon for the view (optionsla).""" |
300 | @@ -78,10 +79,12 @@ |
301 | |
302 | def is_relevant(self, node): |
303 | """Return true if the view can display data about this tree node.""" |
304 | - raise NotImplementedError("This method must be implemented in subclasses!") |
305 | + raise NotImplementedError( |
306 | + "This method must be implemented in subclasses!") |
307 | |
308 | def new_node_selected(self, node): |
309 | - raise NotImplementedError("This method must be implemented in subclasses!") |
310 | + raise NotImplementedError( |
311 | + "This method must be implemented in subclasses!") |
312 | |
313 | |
314 | class PropertyView(AbstractView): |
315 | @@ -119,7 +122,7 @@ |
316 | details_string = dbus_string_rep(object_details[key]) |
317 | item_name = QtGui.QTableWidgetItem(key) |
318 | item_details = QtGui.QTableWidgetItem( |
319 | - details_string.decode('utf-8')) |
320 | + details_string.decode('utf-8')) |
321 | self.table_view.setItem(i, 0, item_name) |
322 | self.table_view.setItem(i, 1, item_details) |
323 | self.table_view.setSortingEnabled(True) |
324 | @@ -141,7 +144,8 @@ |
325 | self.signals_table.verticalHeader().setVisible(False) |
326 | self.signals_table.setAlternatingRowColors(True) |
327 | self.signals_table.setHorizontalHeaderLabels(["Signal Signature"]) |
328 | - self.signals_table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) |
329 | + self.signals_table.setEditTriggers( |
330 | + QtGui.QAbstractItemView.NoEditTriggers) |
331 | self.details_layout.addWidget(self.signals_table) |
332 | |
333 | def name(self): |
334 | @@ -159,7 +163,8 @@ |
335 | signals = node.get_signals() |
336 | self.signals_table.setRowCount(len(signals)) |
337 | for i, signal in enumerate(signals): |
338 | - self.signals_table.setItem(i, 0, QtGui.QTableWidgetItem(str(signal))) |
339 | + self.signals_table.setItem( |
340 | + i, 0, QtGui.QTableWidgetItem(str(signal))) |
341 | self.signals_table.setSortingEnabled(True) |
342 | self.signals_table.sortByColumn(0, QtCore.Qt.AscendingOrder) |
343 | self.signals_table.resizeColumnsToContents() |
344 | @@ -179,7 +184,8 @@ |
345 | self.slots_table.verticalHeader().setVisible(False) |
346 | self.slots_table.setAlternatingRowColors(True) |
347 | self.slots_table.setHorizontalHeaderLabels(["Slot Signature"]) |
348 | - self.slots_table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) |
349 | + self.slots_table.setEditTriggers( |
350 | + QtGui.QAbstractItemView.NoEditTriggers) |
351 | self.details_layout.addWidget(self.slots_table) |
352 | |
353 | def name(self): |
354 | @@ -207,4 +213,4 @@ |
355 | PropertyView, |
356 | SignalView, |
357 | SlotView, |
358 | - ] |
359 | +] |
360 | |
361 | === modified file 'autopilot/vis/resources.py' |
362 | --- autopilot/vis/resources.py 2013-05-30 20:21:13 +0000 |
363 | +++ autopilot/vis/resources.py 2013-07-14 08:34:30 +0000 |
364 | @@ -33,17 +33,17 @@ |
365 | return repr(bool(dbus_type)) |
366 | if isinstance(dbus_type, dbus.String): |
367 | return dbus_type.encode('utf-8', errors='ignore') |
368 | - if (isinstance(dbus_type, dbus.Int16) |
369 | - or isinstance(dbus_type, dbus.UInt16) |
370 | - or isinstance(dbus_type, dbus.Int32) |
371 | - or isinstance(dbus_type, dbus.UInt32) |
372 | - or isinstance(dbus_type, dbus.Int64) |
373 | - or isinstance(dbus_type, dbus.UInt64)): |
374 | + if (isinstance(dbus_type, dbus.Int16) or |
375 | + isinstance(dbus_type, dbus.UInt16) or |
376 | + isinstance(dbus_type, dbus.Int32) or |
377 | + isinstance(dbus_type, dbus.UInt32) or |
378 | + isinstance(dbus_type, dbus.Int64) or |
379 | + isinstance(dbus_type, dbus.UInt64)): |
380 | return repr(int(dbus_type)) |
381 | if isinstance(dbus_type, dbus.Double): |
382 | return repr(float(dbus_type)) |
383 | - if (isinstance(dbus_type, dbus.Array) |
384 | - or isinstance(dbus_type, dbus.Struct)): |
385 | + if (isinstance(dbus_type, dbus.Array) or |
386 | + isinstance(dbus_type, dbus.Struct)): |
387 | return ', '.join([dbus_string_rep(i) for i in dbus_type]) |
388 | else: |
389 | return repr(dbus_type) |
PASSED: Continuous integration, rev:281 jenkins. qa.ubuntu. com/job/ autopilot- ci/157/ jenkins. qa.ubuntu. com/job/ autopilot- saucy-amd64- ci/85 jenkins. qa.ubuntu. com/job/ autopilot- saucy-armhf- ci/85
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ autopilot- ci/157/ rebuild
http://