Gentoo Archives: gentoo-catalyst

From: Mike Frysinger <vapier@g.o>
To: gentoo-catalyst@l.g.o
Subject: [gentoo-catalyst] [PATCH] stagebase: replace read_from_clst with snakeoil
Date: Thu, 08 Oct 2015 22:58:01
Message-Id: 1444345074-13096-1-git-send-email-vapier@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH] stagebase: fix path to snapshot hash file by Mike Frysinger
1 The read_from_clst function is used in one place, and this function is
2 an overwrought "read all the data from a file" function. Replace it
3 with a snakeoil function.
4 ---
5 catalyst/base/stagebase.py | 7 +++----
6 catalyst/support.py | 15 ---------------
7 2 files changed, 3 insertions(+), 19 deletions(-)
8
9 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
10 index a2a8520..652dd9d 100644
11 --- a/catalyst/base/stagebase.py
12 +++ b/catalyst/base/stagebase.py
13 @@ -16,8 +16,7 @@ from DeComp.compress import CompressMap
14 from catalyst.defaults import (SOURCE_MOUNT_DEFAULTS, TARGET_MOUNT_DEFAULTS,
15 PORT_LOGDIR_CLEAN)
16 from catalyst.support import (CatalystError, msg, file_locate, normpath,
17 - cmd, warn, list_bashify, read_makeconf, read_from_clst, ismount,
18 - file_check)
19 + cmd, warn, list_bashify, read_makeconf, ismount, file_check)
20 from catalyst.base.targetbase import TargetBase
21 from catalyst.base.clearbase import ClearBase
22 from catalyst.base.genbase import GenBase
23 @@ -816,8 +815,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
24 print "unpack(), target_portdir = " + target_portdir
25 if "snapcache" in self.settings["options"]:
26 snapshot_cache_hash=\
27 - read_from_clst(self.settings["snapshot_cache_path"]+\
28 - "/" + "catalyst-hash")
29 + fileutils.readfile(self.settings["snapshot_cache_path"]+\
30 + "/" + "catalyst-hash", True)
31 unpack_info['mode'] = self.decompressor.determine_mode(
32 unpack_info['source'])
33
34 diff --git a/catalyst/support.py b/catalyst/support.py
35 index 960a91d..c629025 100644
36 --- a/catalyst/support.py
37 +++ b/catalyst/support.py
38 @@ -13,21 +13,6 @@ from catalyst.defaults import verbosity, valid_config_file_values
39 BASH_BINARY = "/bin/bash"
40
41
42 -def read_from_clst(path):
43 - line = ''
44 - myline = ''
45 - try:
46 - myf = open(path, "r")
47 - except Exception:
48 - return -1
49 - #raise CatalystError("Could not open file " + path)
50 - for line in myf.readlines():
51 - #line = line.replace("\n", "") # drop newline
52 - myline = myline + line
53 - myf.close()
54 - return myline
55 -
56 -
57 def list_bashify(mylist):
58 if type(mylist)==types.StringType:
59 mypack=[mylist]
60 --
61 2.5.2