1 |
I shift quoted lines around for easier comparison. |
2 |
|
3 |
On Thu, Jan 02, 2014 at 10:00:43PM -0800, Brian Dolbec wrote: |
4 |
> +SOURCE_MOUNTS_DEFAULTS = { |
5 |
> … |
6 |
> + "distdir": "/usr/portage/distfiles", |
7 |
> + "portdir": "/usr/portage", |
8 |
> … |
9 |
> - "distdir": self.settings["distdir"], |
10 |
> - "portdir": normpath("/".join([ |
11 |
> - self.settings["snapshot_cache_path"], |
12 |
> - self.settings["repo_name"], |
13 |
> - ])), |
14 |
> … |
15 |
> + # initialize our source mounts |
16 |
> + self.mountmap = SOURCE_MOUNTS_DEFAULTS.copy() |
17 |
> + # update them from settings |
18 |
> + self.mountmap["distdir"] = self.settings["distdir"] |
19 |
> + self.mountmap["portdir"] = normpath("/".join([ |
20 |
> + self.settings["snapshot_cache_path"], |
21 |
> + self.settings["repo_name"], |
22 |
> + ])) |
23 |
|
24 |
Why create dummy initial values and then blow them away? Wouldn't: |
25 |
|
26 |
SOURCE_MOUNTS_DEFAULTS = { |
27 |
… |
28 |
'distdir': None, # initialized from settings |
29 |
'portdir': None, # initialized from settings |
30 |
} |
31 |
|
32 |
make more sense? We'll blow away this default dict once we're loading |
33 |
it via ConfigParser, so this doesn't have to be super elegant, but |
34 |
adding values just to clobber them seems misleading. |
35 |
|
36 |
> - if "SNAPCACHE" in self.settings: |
37 |
> - self.mounts = ["proc", "dev", "portdir", "distdir", "port_tmpdir"] |
38 |
> … |
39 |
> - else: |
40 |
> - self.mounts = ["proc", "dev", "distdir", "port_tmpdir"] |
41 |
> … |
42 |
> + self.mounts = ["proc", "dev", "portdir", "distdir", "port_tmpdir"] |
43 |
> … |
44 |
> + if "SNAPCACHE" not in self.settings: |
45 |
> + self.mounts.remove("portdir") |
46 |
|
47 |
I'd prefer: |
48 |
|
49 |
self.mounts = ["proc", "dev", "distdir", "port_tmpdir"] |
50 |
if "SNAPCACHE" in self.settings: |
51 |
self.mounts.append("portdir") |
52 |
|
53 |
Cheers, |
54 |
Trevor |
55 |
|
56 |
-- |
57 |
This email may be signed or encrypted with GnuPG (http://www.gnupg.org). |
58 |
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy |