Merge lp:~james-w/linaro-image-tools/config-docs into lp:linaro-image-tools/11.11

Proposed by James Westby
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: 52
Merged at revision: 35
Proposed branch: lp:~james-w/linaro-image-tools/config-docs
Merge into: lp:linaro-image-tools/11.11
Diff against target: 77 lines (+26/-22)
1 file modified
hwpack/config.py (+26/-22)
To merge this branch: bzr merge lp:~james-w/linaro-image-tools/config-docs
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle (community) Approve
Review via email: mp+34087@code.launchpad.net

Description of the change

Hi,

Here are the fixes you suggested on the last merge.

Thanks,

James

To post a comment you must log in.
52. By James Westby

Consolidate more code in to the common method.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Looks good, thanks. Maaaybe _get_main_option could have a docstring and maybe its name is a bit generic (although it is my fault). Otherwise, +1

review: Approve
53. By James Westby

Add a docstring to _get_main_option and change the name. Thanks Michael.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hwpack/config.py'
2--- hwpack/config.py 2010-08-27 19:27:37 +0000
3+++ hwpack/config.py 2010-08-31 00:21:40 +0000
4@@ -41,10 +41,12 @@
5
6 @property
7 def name(self):
8+ """The name of the hardware pack. A str."""
9 return self.parser.get(self.MAIN_SECTION, self.NAME_KEY)
10
11 @property
12 def include_debs(self):
13+ """Whether the hardware pack should contain .debs. A bool."""
14 try:
15 if not self.parser.get(
16 self.MAIN_SECTION, self.INCLUDE_DEBS_KEY):
17@@ -54,36 +56,38 @@
18 except ConfigParser.NoOptionError:
19 return True
20
21+ def _get_main_option(self, key):
22+ try:
23+ result = self.parser.get(self.MAIN_SECTION, key)
24+ if not result:
25+ return None
26+ return result
27+ except ConfigParser.NoOptionError:
28+ return None
29+
30 @property
31 def origin(self):
32- try:
33- origin = self.parser.get(self.MAIN_SECTION, self.ORIGIN_KEY)
34- if not origin:
35- return None
36- return origin
37- except ConfigParser.NoOptionError:
38- return None
39+ """The origin that should be recorded in the hwpack.
40+
41+ A str or None if no origin should be recorded.
42+ """
43+ return self._get_main_option(self.ORIGIN_KEY)
44
45 @property
46 def maintainer(self):
47- try:
48- maintainer = self.parser.get(
49- self.MAIN_SECTION, self.MAINTAINER_KEY)
50- if not maintainer:
51- return None
52- return maintainer
53- except ConfigParser.NoOptionError:
54- return None
55+ """The maintainer that should be recorded in the hwpack.
56+
57+ A str or None if not maintainer should be recorded.
58+ """
59+ return self._get_main_option(self.MAINTAINER_KEY)
60
61 @property
62 def support(self):
63- try:
64- support = self.parser.get(self.MAIN_SECTION, self.SUPPORT_KEY)
65- if not support:
66- return None
67- return support
68- except ConfigParser.NoOptionError:
69- return None
70+ """The support level that should be recorded in the hwpack.
71+
72+ A str or None if no support level should be recorded.
73+ """
74+ return self._get_main_option(self.SUPPORT_KEY)
75
76 def _validate_name(self):
77 try:

Subscribers

People subscribed via source and target branches