[Tutor] for loop issue

Stefan Lesicnik stefan at lsd.co.za
Fri Oct 9 09:54:24 CEST 2009


This feels like a strange issue, so i hope I formulate this so its

I have some objects. Each object has associated values. I am looping
through these objects, working with a value and printing out the
The issue in this case is that i need to check if the one value
superseeds the other, and in that case, not print it out. I think the
problem is that when you are in the loop, you dont know about the
other object that you havent processed yet, and when you are
processing that object, you dont know about the previous one?  (not
100% sure if this assumption is correct)

eg of my data  (im comparing ubuntu -> debian security fixes and the
data comes from https://edge.launchpad.net/ubuntu/+source/openswan)
You can see what i have so far here -

The Jaunty Jackalope  (current stable release)
Show details 1:2.4.12+dfsg-1.3+lenny2build0.9.04.1 	updates, security
(universe) 	two days ago
Show details 1:2.4.12+dfsg-1.3 	release (universe) 	49 weeks ago

In the above case, the first loop goes through
1:2.4.12+dfsg-1.3+lenny2build0.9.04.1. At this point i need it to stop
without checking the next entry 1:2.4.12+dfsg-1.3 as the former
superseeds it.
I understand that I can use a break to exit the loop, but i run a
whole bunch of things after this check, so i dont want to break out of

Is this possible what i'm doing? or have i architected the loop wrong
so i 'should' be able to break out of it.

Thanks in advance!


snippet of code below if its of any use...

for app in apps:
            print('app in apps: %s' % app)
            for item in series:
                print('item in series: %s' % item)
                debian_series = item[0]
                debian_fullversion = item[2]
                print('debian_series: %s' % debian_series)
                print('debian_fullversion: %s' % debian_fullversion)

                debian_version =
re.sub('\+?(etch|lenny|sarge|squeeze|woody)[0-9]+$', '',
                print('debian_version: %s' % debian_version)

                main_archive = launchpad.distributions['ubuntu'].main_archive
                #TODO - May be able to use a version check in the
publishedsource to increase speed of checking
                publishedsource =
main_archive.getPublishedSources(source_name = app,
status='Published', exact_match=True)

                for source in publishedsource:

                    if source.distro_series.active:
                        print source.distro_series.name,
                        ubuntu_fullversion = source.source_package_version
                        print('ubuntu fullversion before: %s' %
                        ubuntu_version =
re.sub('build0.[0-9]+.[0-9][0-9].[0-9]+$', '', ubuntu_fullversion)
                        #ubuntu_version =
re.sub('\+?(etch|lenny|sarge|squeeze|woody)[0-9]+$', '',
                        print('ubuntu version after: %s' % ubuntu_version)
                        #ubuntu_target = ('%subuntu/+source/%s') %

                        if debian_fullversion == ubuntu_version:

                        if debian_version in ubuntu_fullversion:
                            ubuntu_component = source.component_name
                            ubuntu_series = source.distro_series.name
                            ubuntu_pocket = source.pocket
                            print('ubuntu_pocket: %s' % ubuntu_pocket)
                            print('debian version: %s' % debian_version)

                            #If pocket is Security, no need to check further
                            if ubuntu_pocket == 'Security' or
ubuntu_pocket == 'Updates':
                                print('Not Found version in: %s.
Continue' % ubuntu_pocket)

                            if debian_version == ubuntu_version:
                                matchtype = 'Sync Match'
                                matchtype = 'MoM Match'

                            ubuntu_changelog = '<a
href=http://changelogs.ubuntu.com/changelogs/pool/' + ubuntu_component
+ '/' + app[:1] + '/' + app + '/' + app + '_' + ubuntu_version +
'/changelog>Ubuntu Changelog</a>'
                            debian_changelog = '<a
href=http://packages.debian.org/changelogs/pool/' + 'main' + '/' +
app[:1] + '/' + app + '/' + app + '_' + debian_fullversion +
'/changelog>Debian Changelog</a>'

                            print('cve: %s' % cve)
                            for cveitem in cve:
                                cvestatus, url = cvecheck(cveitem,
ubuntu_series, ubuntu_version)
                                print('cvestatus: "%s"' % cvestatus)
                                if cvestatus == 'released' or
cvestatus == 'dne' or cvestatus == 'not-affected':
                                    writeweb(date, matchtype, app,
ubuntu_series, ubuntu_fullversion, debian_fullversion,
ubuntu_changelog, debian_changelog, url, cveitem, cvestatus)

More information about the Tutor mailing list