Skip to content

Commit

Permalink
Handle StopIteration with slightly less line noise.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearsandwich committed Apr 2, 2020
1 parent 4cce833 commit 5090e33
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions src/rosdep2/platforms/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,18 @@ def _read_apt_cache_showpkg(packages, exec_fn=None):

header = 'Package: %s' % p
# proceed to Package header
while True:
try:
if next(lines) == header:
break
except StopIteration:
break
try:
while next(lines) != header:
pass
except StopIteration:
pass

# proceed to versions section
while True:
try:
if next(lines) == 'Versions: ':
break
except StopIteration:
break
try:
while next(lines) != 'Versions: ':
pass
except StopIteration:
pass

# virtual packages don't have versions
try:
Expand All @@ -164,12 +162,11 @@ def _read_apt_cache_showpkg(packages, exec_fn=None):
break

# proceed to reserve provides section
while True:
try:
if next(lines) == 'Reverse Provides: ':
break
except StopIteration:
break
try:
while next(lines) != 'Reverse Provides: ':
pass
except StopIteration:
pass

pr = [line.split(' ', 2)[0] for line in lines]
if pr:
Expand Down

0 comments on commit 5090e33

Please sign in to comment.