Gentoo Archives: gentoo-catalyst

From: antarus@g.o
To: gentoo-catalyst@l.g.o
Subject: [gentoo-catalyst] [PATCH] The string module is deprecated, stop using it.
Date: Thu, 19 Dec 2013 05:17:47
Message-Id: 1387430286-30467-1-git-send-email-antarus@gentoo.org
1 From: Alec Warner <antarus@g.o>
2
3 Also the old code called string.split() on the same input
4 a dozen times. Just split the string once (its immutable).
5 We can re-use the result for all the checking.
6
7 TESTS=I ran catalyst -f examples/stage4_template.spec and it
8 didn't until it was supposed to.
9 ---
10 catalyst | 26 +++++++++++++-------------
11 1 file changed, 13 insertions(+), 13 deletions(-)
12
13 diff --git a/catalyst b/catalyst
14 index 4ea4248..edc0b24 100755
15 --- a/catalyst
16 +++ b/catalyst
17 @@ -10,7 +10,6 @@
18 import os
19 import sys
20 import imp
21 -import string
22 import getopt
23 import pdb
24 import os.path
25 @@ -116,12 +115,13 @@ def parse_config(myconfig):
26 print "Setting",x,"to default value \""+confdefaults[x]+"\""
27 conf_values[x]=confdefaults[x]
28
29 + options = conf_values["options"].split()
30 # parse out the rest of the options from the config file
31 - if "autoresume" in string.split(conf_values["options"]):
32 + if "autoresume" in options:
33 print "Autoresuming support enabled."
34 conf_values["AUTORESUME"]="1"
35
36 - if "bindist" in string.split(conf_values["options"]):
37 + if "bindist" in options:
38 print "Binary redistribution enabled"
39 conf_values["BINDIST"]="1"
40 else:
41 @@ -129,43 +129,43 @@ def parse_config(myconfig):
42 print "Binary redistribution of generated stages/isos may be prohibited by law."
43 print "Please see the use description for bindist on any package you are including."
44
45 - if "ccache" in string.split(conf_values["options"]):
46 + if "ccache" in options:
47 print "Compiler cache support enabled."
48 conf_values["CCACHE"]="1"
49
50 - if "clear-autoresume" in string.split(conf_values["options"]):
51 + if "clear-autoresume" in options:
52 print "Cleaning autoresume flags support enabled."
53 conf_values["CLEAR_AUTORESUME"]="1"
54
55 - if "distcc" in string.split(conf_values["options"]):
56 + if "distcc" in options:
57 print "Distcc support enabled."
58 conf_values["DISTCC"]="1"
59
60 - if "icecream" in string.split(conf_values["options"]):
61 + if "icecream" in options:
62 print "Icecream compiler cluster support enabled."
63 conf_values["ICECREAM"]="1"
64
65 - if "kerncache" in string.split(conf_values["options"]):
66 + if "kerncache" in options:
67 print "Kernel cache support enabled."
68 conf_values["KERNCACHE"]="1"
69
70 - if "pkgcache" in string.split(conf_values["options"]):
71 + if "pkgcache" in options:
72 print "Package cache support enabled."
73 conf_values["PKGCACHE"]="1"
74
75 - if "preserve_libs" in string.split(conf_values["options"]):
76 + if "preserve_libs" in options:
77 print "Preserving libs during unmerge."
78 conf_values["PRESERVE_LIBS"]="1"
79
80 - if "purge" in string.split(conf_values["options"]):
81 + if "purge" in options:
82 print "Purge support enabled."
83 conf_values["PURGE"]="1"
84
85 - if "seedcache" in string.split(conf_values["options"]):
86 + if "seedcache" in options:
87 print "Seed cache support enabled."
88 conf_values["SEEDCACHE"]="1"
89
90 - if "snapcache" in string.split(conf_values["options"]):
91 + if "snapcache" in options:
92 print "Snapshot cache support enabled."
93 conf_values["SNAPCACHE"]="1"
94
95 --
96 1.8.1.2

Replies

Subject Author
Re: [gentoo-catalyst] [PATCH] The string module is deprecated, stop using it. "W. Trevor King" <wking@×××××××.us>