'Returns a generator of every (start, stop) IP ranges for an
Autonomous System given its number or its name.'

def ipranges_byas(self, asnum):

    if isinstance(asnum, basestring):
        try:
            if asnum.startswith('AS'):
                asnum = int(asnum[2:])
            else:
                asnum = int(asnum)
        except ValueError:
            return self.db.execute(select([AS_Range.start, AS_Range.stop]).select_from(join(AS, AS_Range)).where((AS.name == asnum)))
    return self.db.execute(select([AS_Range.start, AS_Range.stop]).where((AS_Range.aut_sys == asnum)))
