Exemplo n.º 1
0
 def unknown_starttag(self, tag, attrs):
     tag = string.upper(tag)
     if (tag in Notice.type_set):
         self.currentNotice = Notice(tag)
     else:
         try:
             if (self.currentNotice != None):
                 self.currentNotice.start_tag(tag, attrs)
         except AttributeError:
             pass
Exemplo n.º 2
0
class FBOFeeder(sgmllib.SGMLParser):

    """
    The class to load daily feed data from fbo.gov
    ftp://ftp.fbo.gov/
    """

    def __init__(self, outfile=None, infile=None):
        """
        Constructor
        """
        sgmllib.SGMLParser.__init__(self)

        if not outfile:
            outfile = sys.stdout
            self.write = outfile.write
        if infile:
            self.load(infile)

    def load(self, file):
        print "LOAD FILE ...", file
        while 1:
            s = file.read(8192)
            if not s:
                break
            self.feed(s)
        self.close()

    def handle_data(self, data):
        try:
            self.currentNotice.addData(data)
        except AttributeError:
            pass

    def unknown_starttag(self, tag, attrs):
        tag = string.upper(tag)
        if tag in Notice.type_set:
            self.currentNotice = Notice(tag)
        else:
            try:
                if self.currentNotice != None:
                    self.currentNotice.start_tag(tag, attrs)
            except AttributeError:
                pass

    def do_tag(self, attrs):
        print "Do tag:", attrs

    def unknown_endtag(self, tag):
        tag = string.upper(tag)
        if tag in Notice.type_set:
            self.currentNotice.complete()
Exemplo n.º 3
0
class FBOFeeder(sgmllib.SGMLParser):
    '''
    The class to load daily feed data from fbo.gov
    ftp://ftp.fbo.gov/
    '''
    def __init__(self, outfile=None, infile=None):
        '''
        Constructor
        '''
        sgmllib.SGMLParser.__init__(self)

        if not outfile:
            outfile = sys.stdout
            self.write = outfile.write
        if infile:
            self.load(infile)

    def load(self, file):
        print 'LOAD FILE ...', file
        while 1:
            s = file.read(8192)
            if not s:
                break
            self.feed(s)
        self.close()

    def handle_data(self, data):
        try:
            self.currentNotice.addData(data)
        except AttributeError:
            pass

    def unknown_starttag(self, tag, attrs):
        tag = string.upper(tag)
        if (tag in Notice.type_set):
            self.currentNotice = Notice(tag)
        else:
            try:
                if (self.currentNotice != None):
                    self.currentNotice.start_tag(tag, attrs)
            except AttributeError:
                pass

    def do_tag(self, attrs):
        print 'Do tag:', attrs

    def unknown_endtag(self, tag):
        tag = string.upper(tag)
        if (tag in Notice.type_set):
            self.currentNotice.complete()
Exemplo n.º 4
0
 def unknown_starttag(self, tag, attrs):
     tag = string.upper(tag)
     if tag in Notice.type_set:
         self.currentNotice = Notice(tag)
     else:
         try:
             if self.currentNotice != None:
                 self.currentNotice.start_tag(tag, attrs)
         except AttributeError:
             pass