Merge lp:~zyga/checkbox/holding-area into lp:checkbox

Proposed by Zygmunt Krynicki
Status: Merged
Approved by: Daniel Manrique
Approved revision: 3624
Merged at revision: 3626
Proposed branch: lp:~zyga/checkbox/holding-area
Merge into: lp:checkbox
Diff against target: 366 lines (+43/-58)
1 file modified
plainbox/plainbox/impl/session/state.py (+43/-58)
To merge this branch: bzr merge lp:~zyga/checkbox/holding-area
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Approve
Review via email: mp+254435@code.launchpad.net

Description of the change

This branch is about something else but before we get to it, let's fix some PEP257 issues.

To post a comment you must log in.
Revision history for this message
Daniel Manrique (roadmr) wrote :

Meh, I always use triple quotes on separate lines, it's easier for me, IMHO that's overly pedantic of the tool, but whatcha gonna do. Content-wise this is OK, thanks!

review: Approve
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Apparently the rules are that single-line descriptions should be on one line. Yeah, it's pedantic but it's a PEP so I'll just stick to it. Every bit of code style has something I'd like to bend but then again so does everyone.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plainbox/plainbox/impl/session/state.py'
2--- plainbox/plainbox/impl/session/state.py 2015-02-25 23:54:35 +0000
3+++ plainbox/plainbox/impl/session/state.py 2015-03-27 18:06:34 +0000
4@@ -16,6 +16,8 @@
5 # You should have received a copy of the GNU General Public License
6 # along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
7 """
8+Session State Handling.
9+
10 :mod:`plainbox.impl.session.state` -- session state handling
11 ============================================================
12 """
13@@ -39,6 +41,7 @@
14
15
16 class SessionMetaData:
17+
18 """
19 Class representing non-critical state of the session.
20
21@@ -65,6 +68,7 @@
22
23 def __init__(self, title=None, flags=None, running_job_name=None,
24 app_blob=None, app_id=None):
25+ """ Initialize a new session state meta-data object. """
26 if flags is None:
27 flags = []
28 self._title = title
29@@ -74,6 +78,7 @@
30 self._app_id = app_id
31
32 def __repr__(self):
33+ """ Get the representation of the session state meta-data. """
34 return "<{} title:{!r} flags:{!r} running_job_name:{!r}>".format(
35 self.__class__.__name__, self.title, self.flags,
36 self.running_job_name)
37@@ -92,6 +97,7 @@
38
39 @title.setter
40 def title(self, title):
41+ """ set the session title to the given value. """
42 self._title = title
43
44 @property
45@@ -110,12 +116,13 @@
46
47 @flags.setter
48 def flags(self, flags):
49+ """ set the session flags to the given set. """
50 self._flags = flags
51
52 @property
53 def running_job_name(self):
54 """
55- id of the running job
56+ id of the running job.
57
58 .. note::
59 This property has a confusing name. It actually refers to job ID,
60@@ -133,6 +140,7 @@
61
62 @running_job_name.setter
63 def running_job_name(self, running_job_name):
64+ """ set the id of the running job. """
65 self._running_job_name = running_job_name
66
67 @property
68@@ -150,6 +158,7 @@
69
70 @app_blob.setter
71 def app_blob(self, value):
72+ """ set the application specific binary blob to the given value. """
73 if value is not None and not isinstance(value, bytes):
74 # TRANSLATORS: please don't translate app_blob, None and bytes
75 raise TypeError(_("app_blob must be either None or bytes"))
76@@ -158,7 +167,7 @@
77 @property
78 def app_id(self):
79 """
80- Application identifier
81+ Application identifier.
82
83 A string identifying the application that stored app_blob. It is
84 recommended to use reverse domain names or UUIDs.
85@@ -167,6 +176,7 @@
86
87 @app_id.setter
88 def app_id(self, value):
89+ """ Set the application identifier to the given value. """
90 if value is not None and not isinstance(value, str):
91 # TRANSLATORS: please don't translate app_blob, None and bytes
92 raise TypeError(_("app_id must be either None or str"))
93@@ -174,6 +184,7 @@
94
95
96 class SessionDeviceContext:
97+
98 """
99 Session context specific to a given device.
100
101@@ -211,7 +222,7 @@
102
103 def __init__(self, state=None):
104 """
105- Initialize a new SessionDeviceContext
106+ Initialize a new SessionDeviceContext.
107
108 :param state:
109 An (optinal) state to use
110@@ -352,7 +363,7 @@
111
112 def add_provider(self, provider, add_units=True):
113 """
114- Add a provider to the context
115+ Add a provider to the context.
116
117 :param provider:
118 The :class:`Provider1` to add
119@@ -379,7 +390,7 @@
120
121 def add_unit(self, unit):
122 """
123- Add a unit to the context
124+ Add a unit to the context.
125
126 :param unit:
127 The :class:`Unit` to add.
128@@ -399,7 +410,7 @@
129
130 def remove_unit(self, unit):
131 """
132- Remove an unit from the context
133+ Remove an unit from the context.
134
135 :param unit:
136 The :class:`Unit` to remove.
137@@ -415,7 +426,7 @@
138
139 def get_ctrl_for_job(self, job):
140 """
141- Get the execution controller most applicable to run this job
142+ Get the execution controller most applicable to run this job.
143
144 :param job:
145 A job definition to run
146@@ -448,9 +459,7 @@
147
148 @signal
149 def on_provider_added(self, provider):
150- """
151- Signal sent whenever a provider is added to the context.
152- """
153+ """ Signal sent whenever a provider is added to the context. """
154 logger.info(_("Provider %s added to context %s"), provider, self)
155 # Invalidate the list of execution controllers as they depend
156 # on the accuracy of provider_list
157@@ -458,25 +467,19 @@
158
159 @signal
160 def on_unit_added(self, unit):
161- """
162- Signal sent whenever a unit is added to the context.
163- """
164+ """ Signal sent whenever a unit is added to the context. """
165 logger.debug(_("Unit %s added to context %s"), unit, self)
166 if unit.Meta.name == 'job':
167 self.on_job_added(unit)
168
169 @signal
170 def on_job_added(self, job):
171- """
172- Signal sent whenever a new job definition unit is added to the contex
173- """
174+ """ Signal sent whenever a new job unit is added to the context. """
175 self._override_update(job)
176
177 @signal
178 def on_unit_removed(self, unit):
179- """
180- Signal sent whenever a unit is removed from the context.
181- """
182+ """ Signal sent whenever a unit is removed from the context. """
183 logger.debug(_("Unit %s removed from context %s"), unit, self)
184
185 def compute_shared(self, cache_key, func, *args, **kwargs):
186@@ -504,13 +507,12 @@
187 return self._shared_cache[cache_key]
188
189 def invalidate_shared(self, cache_key):
190+ """ Invalidate a cached shared value. """
191 if cache_key in self._shared_cache:
192 del self._shared_cache[cache_key]
193
194 def _compute_execution_ctrl_list(self):
195- """
196- Internal method that computes the list of execution controllers
197- """
198+ """ Compute the list of execution controllers. """
199 # TODO: tie this with the upcoming device patches
200 import sys
201 if sys.platform == 'linux':
202@@ -533,16 +535,11 @@
203 return []
204
205 def _invalidate_execution_ctrl_list(self, *args, **kwargs):
206- """
207- Internal method that invalidates the 'execution_controller_list' cache
208- key that is used to store the list of execution controllers.
209- """
210+ """ Invalidate the list of execution controllers. """
211 self.invalidate_shared(self._CACHE_EXECUTION_CTRL_LIST)
212
213 def _compute_override_map(self):
214- """
215- Internal method that computes the map of field overrides
216- """
217+ """ Compute the map of field overrides. """
218 override_map = collections.defaultdict(list)
219 for test_plan in self._test_plan_list:
220 support = TestPlanUnitSupport(test_plan)
221@@ -551,10 +548,7 @@
222 return override_map
223
224 def _invalidate_override_map(self, *args, **kwargs):
225- """
226- Internal method that invalidates the 'override_map' cache
227- key that is used to store the map of field overrides.
228- """
229+ """ Invalidate the cached field override map. """
230 self.invalidate_shared(self._CACHE_OVERRIDE_MAP)
231
232 def _bulk_override_update(self):
233@@ -576,6 +570,7 @@
234
235
236 class SessionState:
237+
238 """
239 Class representing all state needed during a single program session.
240
241@@ -673,7 +668,7 @@
242 @signal
243 def on_job_result_changed(self, job, result):
244 """
245- Signal fired after a job get changed (set)
246+ Signal fired after a job get changed (set).
247
248 This signal is fired each time a result is presented to the session.
249
250@@ -699,15 +694,11 @@
251
252 @signal
253 def on_unit_added(self, unit):
254- """
255- Signal sent whenever a unit is added to the session.
256- """
257+ """ Signal sent whenever a unit is added to the session. """
258
259 @signal
260 def on_unit_removed(self, unit):
261- """
262- Signal sent whenever a unit is removed from the session.
263- """
264+ """ Signal sent whenever a unit is removed from the session. """
265
266 def __init__(self, unit_list):
267 """
268@@ -828,7 +819,7 @@
269
270 def update_desired_job_list(self, desired_job_list):
271 """
272- Update the set of desired jobs (that ought to run)
273+ Update the set of desired jobs (that ought to run).
274
275 This method can be used by the UI to recompute the dependency graph.
276 The argument 'desired_job_list' is a list of jobs that should run.
277@@ -873,6 +864,8 @@
278
279 def get_estimated_duration(self, manual_overhead=30.0):
280 """
281+ Estimate the total duration of the session.
282+
283 Provide the estimated duration of the jobs that have been selected
284 to run in this session (maintained by calling update_desired_job_list).
285
286@@ -936,7 +929,7 @@
287 @deprecated('0.9', 'use the add_unit() method instead')
288 def add_job(self, new_job, recompute=True):
289 """
290- Add a new job to the session
291+ Add a new job to the session.
292
293 :param new_job:
294 The job being added
295@@ -969,7 +962,7 @@
296
297 def add_unit(self, new_unit, recompute=True):
298 """
299- Add a new unit to the session
300+ Add a new unit to the session.
301
302 :param new_unit:
303 The unit being added
304@@ -1041,7 +1034,7 @@
305
306 def remove_unit(self, unit, *, recompute=True):
307 """
308- Remove an existing unit from the session
309+ Remove an existing unit from the session.
310
311 :param unit:
312 The unit to remove
313@@ -1093,15 +1086,13 @@
314
315 @property
316 def unit_list(self):
317- """
318- List of all known units
319- """
320+ """ List of all known units. """
321 return self._unit_list
322
323 @property
324 def desired_job_list(self):
325 """
326- List of jobs that are on the "desired to run" list
327+ List of jobs that are on the "desired to run" list.
328
329 This is a list, not a set, because the dependency solver algorithm
330 retains as much of the original ordering as possible. Having said that,
331@@ -1112,7 +1103,7 @@
332 @property
333 def run_list(self):
334 """
335- List of jobs that were intended to run, in the proper order
336+ List of jobs that were intended to run, in the proper order.
337
338 The order is a result of topological sorting of the desired_job_list.
339 This value is recomputed when change_desired_run_list() is called. It
340@@ -1122,23 +1113,17 @@
341
342 @property
343 def job_state_map(self):
344- """
345- Map from job id to JobState that encodes the state of each job.
346- """
347+ """ Map from job id to JobState associated with each job. """
348 return self._job_state_map
349
350 @property
351 def resource_map(self):
352- """
353- Map from resource id to a list of resource records
354- """
355+ """ Map from resource id to a list of resource records. """
356 return self._resource_map
357
358 @property
359 def metadata(self):
360- """
361- metadata object associated with this session state.
362- """
363+ """ meta-data object associated with this session state. """
364 return self._metadata
365
366 def _recompute_job_readiness(self):

Subscribers

People subscribed via source and target branches