Gentoo Archives: gentoo-portage-dev

From: Ali Polatel <hawking@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [PATCH 5/6] Replace has_key() with the in operator (bin)
Date: Tue, 01 Jul 2008 11:27:53
Message-Id: 1214911614-31263-5-git-send-email-hawking@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 4/6] Replace has_key() with the in operator (portage.elog) by Ali Polatel
1 ---
2 bin/dispatch-conf | 6 +++---
3 bin/dohtml | 6 +++---
4 bin/glsa-check | 4 ++--
5 bin/repoman | 14 +++++++-------
6 4 files changed, 15 insertions(+), 15 deletions(-)
7
8 diff --git a/bin/dispatch-conf b/bin/dispatch-conf
9 index 28516c9..a8159cd 100755
10 --- a/bin/dispatch-conf
11 +++ b/bin/dispatch-conf
12 @@ -75,7 +75,7 @@ class dispatch:
13
14 self.options = portage.dispatch_conf.read_config(MANDATORY_OPTS)
15
16 - if self.options.has_key("log-file"):
17 + if "log-file" in self.options:
18 if os.path.isfile(self.options["log-file"]):
19 shutil.copy(self.options["log-file"], self.options["log-file"] + '.old')
20 if os.path.isfile(self.options["log-file"]) \
21 @@ -273,7 +273,7 @@ class dispatch:
22 show_new_diff = 1
23 continue
24 elif c == 'e':
25 - if not os.environ.has_key('EDITOR'):
26 + if 'EDITOR' not in os.environ:
27 os.environ['EDITOR']='nano'
28 os.system(os.environ['EDITOR'] + ' ' + newconf)
29 continue
30 @@ -337,7 +337,7 @@ class dispatch:
31 conf = re.sub (r'\._cfg\d+_', '', nconf)
32 dir = re.match (r'^(.+)/', nconf).group (1)
33
34 - if h.has_key (conf):
35 + if conf in h:
36 mrgconf = re.sub(r'\._cfg', '._mrg', h[conf]['new'])
37 if os.path.exists(mrgconf):
38 os.unlink(mrgconf)
39 diff --git a/bin/dohtml b/bin/dohtml
40 index d65a31a..ab8ff3a 100755
41 --- a/bin/dohtml
42 +++ b/bin/dohtml
43 @@ -86,11 +86,11 @@ class OptionsClass:
44 self.ED = ""
45 self.DOCDESTTREE = ""
46
47 - if os.environ.has_key("PF"):
48 + if "PF" in os.environ:
49 self.PF = os.environ["PF"]
50 - if os.environ.has_key("ED"):
51 + if "ED" in os.environ:
52 self.ED = os.environ["ED"]
53 - if os.environ.has_key("_E_DOCDESTTREE_"):
54 + if "_E_DOCDESTTREE_" in os.environ:
55 self.DOCDESTTREE = os.environ["_E_DOCDESTTREE_"]
56
57 self.allowed_exts = [ 'htm', 'html', 'css', 'js',
58 diff --git a/bin/glsa-check b/bin/glsa-check
59 index cdd1db3..2cff501 100644
60 --- a/bin/glsa-check
61 +++ b/bin/glsa-check
62 @@ -295,12 +295,12 @@ if mode == "mail":
63 # color doesn't make any sense for mail
64 nocolor()
65
66 - if portage.settings.has_key("PORTAGE_ELOG_MAILURI"):
67 + if "PORTAGE_ELOG_MAILURI" in portage.settings:
68 myrecipient = portage.settings["PORTAGE_ELOG_MAILURI"].split()[0]
69 else:
70 myrecipient = "root@localhost"
71
72 - if portage.settings.has_key("PORTAGE_ELOG_MAILFROM"):
73 + if "PORTAGE_ELOG_MAILFROM" in portage.settings:
74 myfrom = portage.settings["PORTAGE_ELOG_MAILFROM"]
75 else:
76 myfrom = "glsa-check"
77 diff --git a/bin/repoman b/bin/repoman
78 index 93c01f6..701dbfc 100755
79 --- a/bin/repoman
80 +++ b/bin/repoman
81 @@ -660,7 +660,7 @@ if os.path.exists(descfile):
82 if not os.path.isdir(portdir+"/profiles/"+arch[1]):
83 print "Invalid "+arch[2]+" profile ("+arch[1]+") for arch "+arch[0]
84 continue
85 - if profiles.has_key(arch[0]):
86 + if arch[0] in profiles:
87 profiles[arch[0]]+= [[arch[1], arch[2]]]
88 else:
89 profiles[arch[0]] = [[arch[1], arch[2]]]
90 @@ -668,7 +668,7 @@ if os.path.exists(descfile):
91 for x in repoman_settings.archlist():
92 if x[0] == "~":
93 continue
94 - if not profiles.has_key(x):
95 + if x not in profiles:
96 print red("\""+x+"\" doesn't have a valid profile listed in profiles.desc.")
97 print red("You need to either \"cvs update\" your profiles dir or follow this")
98 print red("up with the "+x+" team.")
99 @@ -1327,7 +1327,7 @@ for x in scanlist:
100
101 # uselist checks - local
102 mykey = portage.dep_getkey(catpkg)
103 - if luselist.has_key(mykey):
104 + if mykey in luselist:
105 for mypos in range(len(myuse)-1,-1,-1):
106 if myuse[mypos] and (myuse[mypos] in luselist[mykey]):
107 del myuse[mypos]
108 @@ -1372,7 +1372,7 @@ for x in scanlist:
109 if myskey not in kwlist:
110 stats["KEYWORDS.invalid"] += 1
111 fails["KEYWORDS.invalid"].append(x+"/"+y+".ebuild: %s" % mykey)
112 - elif not profiles.has_key(myskey):
113 + elif myskey not in profiles:
114 stats["KEYWORDS.invalid"] += 1
115 fails["KEYWORDS.invalid"].append(x+"/"+y+".ebuild: %s (profile invalid)" % mykey)
116
117 @@ -1412,7 +1412,7 @@ for x in scanlist:
118
119 for keyword,arch,groups in arches:
120
121 - if not profiles.has_key(arch):
122 + if arch not in profiles:
123 # A missing profile will create an error further down
124 # during the KEYWORDS verification.
125 continue
126 @@ -1825,7 +1825,7 @@ else:
127 if "PORTAGE_GPG_KEY" not in repoman_settings:
128 raise portage.exception.MissingParameter("PORTAGE_GPG_KEY is unset!")
129 if "PORTAGE_GPG_DIR" not in repoman_settings:
130 - if os.environ.has_key("HOME"):
131 + if "HOME" in os.environ:
132 repoman_settings["PORTAGE_GPG_DIR"] = os.path.join(os.environ["HOME"], ".gnupg")
133 logging.info("Automatically setting PORTAGE_GPG_DIR to %s" % repoman_settings["PORTAGE_GPG_DIR"])
134 else:
135 @@ -1840,7 +1840,7 @@ else:
136 repoman_settings["PORTAGE_GPG_DIR"])
137 gpgcmd = "gpg --sign --clearsign --yes "
138 gpgcmd+= "--default-key "+repoman_settings["PORTAGE_GPG_KEY"]
139 - if repoman_settings.has_key("PORTAGE_GPG_DIR"):
140 + if "PORTAGE_GPG_DIR" in repoman_settings:
141 gpgcmd += " --homedir "+repoman_settings["PORTAGE_GPG_DIR"]
142 if options.pretend:
143 print "("+gpgcmd+" "+filename+")"
144 --
145 1.5.6.1
146
147 --
148 gentoo-portage-dev@l.g.o mailing list

Replies