Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (2)
Replace "x.has_key(y)" with "y in x" syntax
· 85592e7c
Brian May
authored
Aug 20, 2018
85592e7c
Merge branch 'bam/security-tracker-update_python_haskey'
· 1271f9f6
Salvatore Bonaccorso
authored
Sep 15, 2018
1271f9f6
Show whitespace changes
Inline
Side-by-side
bin/check-syntax
View file @
1271f9f6
...
...
@@ -29,7 +29,7 @@ def do_parse(f):
n
=
r
.
name
if
n
[
0
:
4
]
in
(
'
CAN
'
,
'
CVE
'
):
n
=
n
[
4
:]
if
n
ames
.
has_key
(
n
)
:
if
n
in
names
:
if
names
[
n
]
!=
r
.
name
:
sys
.
stderr
.
write
(
"
error: duplicate CVE entry: %s and %s
\n
"
%
(
names
[
n
],
r
.
name
))
...
...
bin/mass-bug-filer
View file @
1271f9f6
...
...
@@ -17,7 +17,7 @@ packages = sys.argv[2:]
cache
=
apt
.
Cache
()
errors
=
False
for
p
in
packages
:
if
not
cache
.
has_key
(
p
)
:
if
p
not
in
cache
:
print
(
"
error: no such package:
"
,
p
,
file
=
sys
.
stderr
)
errors
=
True
if
errors
:
...
...
@@ -52,7 +52,7 @@ for line in source_lines:
if
k
==
"
Subject
"
:
h_subject
=
v
continue
if
h_bug
.
has_key
(
k
)
:
if
k
in
h_bug
:
h_bug
[
k
]
=
v
continue
print
(
"
error: invalid header field:
"
,
k
,
file
=
sys
.
stderr
)
...
...
bin/tracker_service.py
View file @
1271f9f6
...
...
@@ -1407,7 +1407,7 @@ Debian bug number.'''),
winner
=
''
for
suffix
in
(
''
,
'
-security
'
,
'
-lts
'
):
subrelease
=
release
+
suffix
if
status
[
pkg
][
issue
]
.
has_key
(
subrelease
)
:
if
subrelease
in
status
[
pkg
][
issue
]:
if
status
[
pkg
][
issue
][
subrelease
]
==
0
:
# the issue is fixed, let's pick this subrelease and be done
winner
=
suffix
...
...
@@ -1426,14 +1426,14 @@ Debian bug number.'''),
else
:
state
=
"
open
"
suite_urgency
=
urgency
[
pkg
][
issue
][
repository
]
if
nodsa
[
pkg
][
issue
]
.
has_key
(
repository
)
:
if
repository
in
nodsa
[
pkg
][
issue
]:
suite_nodsa
=
nodsa
[
pkg
][
issue
][
repository
]
if
nodsa_reason
[
pkg
][
issue
]
.
has_key
(
repository
)
:
if
repository
in
nodsa_reason
[
pkg
][
issue
]:
suite_nodsa_reason
=
nodsa_reason
[
pkg
][
issue
][
repository
]
for
repository
in
repositories
[
pkg
][
issue
]:
for
suffix
in
(
''
,
'
-security
'
,
'
-lts
'
):
subrelease
=
release
+
suffix
if
version
[
pkg
][
issue
]
.
has_key
(
subrelease
)
:
if
subrelease
in
version
[
pkg
][
issue
]:
suite_repositories
[
subrelease
]
=
version
[
pkg
][
issue
][
subrelease
]
suites
[
release
]
=
{
"
status
"
:
state
,
"
repositories
"
:
suite_repositories
,
...
...
lib/python/bugs.py
View file @
1271f9f6
...
...
@@ -31,7 +31,7 @@ def listUrgencies():
Urgency
.
urgencies
=
urgencies
return
urgencies
def
internUrgency
(
name
,
urgencies
=
listUrgencies
()):
if
urgencies
.
has_key
(
name
)
:
if
name
in
urgencies
:
return
urgencies
[
name
]
else
:
return
None
...
...
@@ -282,7 +282,7 @@ class Bug(BugBase):
notes = {}
for n in self.notes:
key = (n.package, n.release)
if
notes.has_key(key)
:
if
key in notes
:
notes[key].merge(n)
else:
notes[key] = n
...
...
lib/python/debian_support.py
View file @
1271f9f6
...
...
@@ -201,7 +201,7 @@ def listReleases():
Release
.
releases
=
releases
return
releases
def
internRelease
(
name
,
releases
=
listReleases
()):
if
releases
.
has_key
(
name
)
:
if
name
in
releases
:
return
releases
[
name
]
else
:
return
None
...
...
lib/python/dist_config.py
View file @
1271f9f6
...
...
@@ -80,7 +80,7 @@ def add_release(name, architectures,
overview_part
=
(
''
,
'
security
'
,
'
proposed-updates
'
)):
import
debian_support
name
=
debian_support
.
internRelease
(
name
)
if
releases
.
has_key
(
name
)
:
if
name
in
releases
:
raise
ValueError
(
"
duplicate release
"
,
name
)
releases
[
name
]
=
{
'
architectures
'
:
architectures
,
'
purpose
'
:
{
'
debsecan
'
:
debsecan_part
,
...
...
lib/python/nvd.py
View file @
1271f9f6
...
...
@@ -68,11 +68,11 @@ class _Parser(xml.sax.handler.ContentHandler):
def
TAG_int
(
self
,
name
,
attrs
):
self
.
loss_int
=
1
def
TAG_sec_prot
(
self
,
name
,
attrs
):
if
attrs
.
has_key
(
'
user
'
)
:
if
'
user
'
in
attrs
:
self
.
loss_sec_prot_user
=
1
if
attrs
.
has_key
(
'
admin
'
)
:
if
'
admin
'
in
attrs
:
self
.
loss_sec_prot_admin
=
1
if
attrs
.
has_key
(
'
other
'
)
:
if
'
other
'
in
attrs
:
self
.
loss_sec_prot_other
=
1
def
endElement
(
self
,
name
):
...
...
lib/python/sectracker/repo.py
View file @
1271f9f6
...
...
@@ -272,7 +272,7 @@ class Config(object):
raise
ValueError
(
"
distributions[%r][%r] (%r) not a valid repository
"
%
(
d
,
m
,
mem
))
if
dobj
.
has_key
(
"
release
"
)
:
if
"
release
"
in
dobj
:
rel
=
dobj
[
"
release
"
]
if
rel
in
self
.
releases
:
raise
ValueError
(
...
...
lib/python/security_db.py
View file @
1271f9f6
...
...
@@ -819,7 +819,7 @@ class DB:
%
(
arch
,
name
))
key
=
(
name
,
release
,
subrelease
,
archive
,
version
,
source
,
source_version
)
if
packages
.
has_key
(
key
)
:
if
key
in
packages
:
packages
[
key
][
arch
]
=
1
else
:
packages
[
key
]
=
{
arch
:
1
}
...
...
@@ -2038,7 +2038,7 @@ class DB:
# a VERSION, or None.
if
cache
is
not
None
:
sp
=
(
release
,
pkg
)
if
cache
.
has_key
(
sp
)
:
if
sp
in
cache
:
d
=
cache
[
sp
]
if
d
.
__class__
==
dict
:
return
d
.
get
(
purpose
,
None
)
...
...
@@ -2060,7 +2060,7 @@ class DB:
for
(
purpose
,
permitted
)
in
purposes
.
items
():
if
part
not
in
permitted
:
continue
if
results
.
has_key
(
purpose
)
:
if
purpose
in
results
:
oldver
=
results
[
purpose
]
if
ver
<=
oldver
:
continue
...
...
lib/python/web_support.py
View file @
1271f9f6
...
...
@@ -547,7 +547,7 @@ class PathRouter:
for
x
in
range
(
len
(
p
)):
element
=
p
[
x
]
if
element
:
if
m
.
has_key
(
element
)
:
if
element
in
m
:
m
=
m
[
element
]
else
:
if
element
==
'
*
'
:
...
...
@@ -587,18 +587,18 @@ class PathRouter:
try
:
m
=
m
[
element
]
except
KeyError
:
if
x
+
1
==
l
and
m
.
has_key
(
'
*
'
)
:
if
x
+
1
==
l
and
'
*
'
in
m
:
# Use '*' only if the remaining path is empty.
return
(
m
[
'
*
'
],
tuple
(
p
[
x
:]))
if
m
.
has_key
(
'
**
'
)
:
if
'
**
'
in
m
:
return
(
m
[
'
**
'
],
tuple
(
p
[
x
:]))
raise
InvalidPath
()
try
:
result
=
m
[
''
]
except
KeyError
:
if
m
.
has_key
(
'
*
'
)
:
if
'
*
'
in
m
:
result
=
m
[
'
*
'
]
elif
m
.
has_key
(
'
**
'
)
:
elif
'
**
'
in
m
:
result
=
m
[
'
**
'
]
else
:
raise
InvalidPath
()
...
...