How to use the feedparser._parse_date_iso8601 function in feedparser

To help you get started, we’ve selected a few feedparser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rubys / venus / planet / spider.py View on Github external
if type(feedid) == unicode: feedid = feedid.encode('utf-8')
                index[filename('', entry.id)] = feedid

    if index: index.close()

    # identify inactive feeds
    if config.activity_threshold(feed_uri):
        updated = [entry.updated_parsed for entry in data.entries
            if entry.has_key('updated_parsed')]
        updated.sort()

        if updated:
            data.feed['planet_updated'] = \
                time.strftime("%Y-%m-%dT%H:%M:%SZ", updated[-1])
        elif data.feed.has_key('planet_updated'):
           updated = [feedparser._parse_date_iso8601(data.feed.planet_updated)]

        if not updated or updated[-1] < activity_horizon:
            msg = "no activity in %d days" % config.activity_threshold(feed_uri)
            log.info(msg)
            data.feed['planet_message'] = msg

    # report channel level errors
    if data.status == 226:
        if data.feed.has_key('planet_message'): del data.feed['planet_message']
        if feed_info.feed.has_key('planet_updated'):
            data.feed['planet_updated'] = feed_info.feed['planet_updated']
    elif data.status == 403:
        data.feed['planet_message'] = "403: forbidden"
    elif data.status == 404:
        data.feed['planet_message'] = "404: not found"
    elif data.status == 408:
github tominsam / shelf-python / providers / DopplrProvider.py View on Github external
def body(self):
        if not self.token:
            return """<p>No Dopplr API token defined. <a href="https://www.dopplr.com/api/AuthSubRequest?scope=http://www.dopplr.com&amp;next=shelf://shelf/&amp;session=1">click here</a> to get one.</p>"""
        
        if self.fail:
           return """<p>Problem talking to Dopplr - maybe the token is invalid? Try <a href="https://www.dopplr.com/api/AuthSubRequest?scope=http://www.dopplr.com&amp;next=shelf://shelf/&amp;session=1">re-authorizing</a>..</p>"""
        
        if not self.response: return None

        # dopplr api coveniently provides offset from UTC :-)
        offset = int(str(self.response['current_city']['utcoffset']))
        readable_time = strftime("%l:%M&nbsp;%p&nbsp;on&nbsp;%A", gmtime( time() + offset ))

        if 'current_trip' in self.response:
            start = feedparser._parse_date_iso8601( self.response['current_trip']['start'] )
            finish = feedparser._parse_date_iso8601( self.response['current_trip']['finish'] )

            body = "<p>%s is in %s (from %s&nbsp;to %s). Local time is %s.</p>"%(
                self.provider.clue.displayName(),
                self.response['current_trip']['city']['name'],
                strftime("%B&nbsp;%d", start ),
                strftime("%B&nbsp;%d", finish ),
                readable_time
            )
        else:
            body = "<p>%s is at home in %s (where it is %s).</p>"%(
                self.provider.clue.displayName(),
                self.response['current_city']['name'],
                readable_time
            )
github ghoseb / planet.clojure / planet / spider.py View on Github external
else:
            log.info("Updating feed %s @ %s", feed_uri, data.url)
    elif data.status == 301 and data.has_key("entries") and len(data.entries)&gt;0:
        log.warning("Feed has moved from &lt;%s&gt; to &lt;%s&gt;", feed_uri, data.url)
        data.feed['planet_http_location'] = data.url
    elif data.status == 304 and data.has_key("url"):
        feed_info.feed['planet_http_location'] = data.url
        if feed_uri == data.url:
            log.info("Feed %s unchanged", feed_uri)
        else:
            log.info("Feed %s unchanged @ %s", feed_uri, data.url)

        if not feed_info.feed.has_key('planet_message'):
            if feed_info.feed.has_key('planet_updated'):
                updated = feed_info.feed.planet_updated
                if feedparser._parse_date_iso8601(updated) &gt;= activity_horizon:
                    return
        else:
            if feed_info.feed.planet_message.startswith("no activity in"):
               return
            if not feed_info.feed.planet_message.startswith("duplicate") and \
               not feed_info.feed.planet_message.startswith("no data"):
               del feed_info.feed['planet_message']

    elif data.status == 410:
        log.info("Feed %s gone", feed_uri)
    elif data.status == 408:
        log.warning("Feed %s timed out", feed_uri)
    elif data.status &gt;= 400:
        log.error("Error %d while updating feed %s", data.status, feed_uri)
    else:
        log.info("Updating feed %s", feed_uri)
github rubys / venus / planet / spider.py View on Github external
else:
            log.info("Updating feed %s @ %s", feed_uri, data.url)
    elif data.status == 301 and data.has_key("entries") and len(data.entries)&gt;0:
        log.warning("Feed has moved from &lt;%s&gt; to &lt;%s&gt;", feed_uri, data.url)
        data.feed['planet_http_location'] = data.url
    elif data.status == 304 and data.has_key("url"):
        feed_info.feed['planet_http_location'] = data.url
        if feed_uri == data.url:
            log.info("Feed %s unchanged", feed_uri)
        else:
            log.info("Feed %s unchanged @ %s", feed_uri, data.url)

        if not feed_info.feed.has_key('planet_message'):
            if feed_info.feed.has_key('planet_updated'):
                updated = feed_info.feed.planet_updated
                if feedparser._parse_date_iso8601(updated) &gt;= activity_horizon:
                    return
        else:
            if feed_info.feed.planet_message.startswith("no activity in"):
               return
            if not feed_info.feed.planet_message.startswith("duplicate") and \
               not feed_info.feed.planet_message.startswith("no data"):
               del feed_info.feed['planet_message']

    elif data.status == 410:
        log.info("Feed %s gone", feed_uri)
    elif data.status == 408:
        log.warning("Feed %s timed out", feed_uri)
    elif data.status &gt;= 400:
        log.error("Error %d while updating feed %s", data.status, feed_uri)
    else:
        log.info("Updating feed %s", feed_uri)
github ghoseb / planet.clojure / planet / spider.py View on Github external
if type(feedid) == unicode: feedid = feedid.encode('utf-8')
                index[filename('', entry.id)] = feedid

    if index: index.close()

    # identify inactive feeds
    if config.activity_threshold(feed_uri):
        updated = [entry.updated_parsed for entry in data.entries
            if entry.has_key('updated_parsed')]
        updated.sort()

        if updated:
            data.feed['planet_updated'] = \
                time.strftime("%Y-%m-%dT%H:%M:%SZ", updated[-1])
        elif data.feed.has_key('planet_updated'):
           updated = [feedparser._parse_date_iso8601(data.feed.planet_updated)]

        if not updated or updated[-1] &lt; activity_horizon:
            msg = "no activity in %d days" % config.activity_threshold(feed_uri)
            log.info(msg)
            data.feed['planet_message'] = msg

    # report channel level errors
    if data.status == 226:
        if data.feed.has_key('planet_message'): del data.feed['planet_message']
        if feed_info.feed.has_key('planet_updated'):
            data.feed['planet_updated'] = feed_info.feed['planet_updated']
    elif data.status == 403:
        data.feed['planet_message'] = "403: forbidden"
    elif data.status == 404:
        data.feed['planet_message'] = "404: not found"
    elif data.status == 408:
github tominsam / shelf-python / providers / DopplrProvider.py View on Github external
def body(self):
        if not self.token:
            return """<p>No Dopplr API token defined. <a href="https://www.dopplr.com/api/AuthSubRequest?scope=http://www.dopplr.com&amp;next=shelf://shelf/&amp;session=1">click here</a> to get one.</p>"""
        
        if self.fail:
           return """<p>Problem talking to Dopplr - maybe the token is invalid? Try <a href="https://www.dopplr.com/api/AuthSubRequest?scope=http://www.dopplr.com&amp;next=shelf://shelf/&amp;session=1">re-authorizing</a>..</p>"""
        
        if not self.response: return None

        # dopplr api coveniently provides offset from UTC :-)
        offset = int(str(self.response['current_city']['utcoffset']))
        readable_time = strftime("%l:%M&nbsp;%p&nbsp;on&nbsp;%A", gmtime( time() + offset ))

        if 'current_trip' in self.response:
            start = feedparser._parse_date_iso8601( self.response['current_trip']['start'] )
            finish = feedparser._parse_date_iso8601( self.response['current_trip']['finish'] )

            body = "<p>%s is in %s (from %s&nbsp;to %s). Local time is %s.</p>"%(
                self.provider.clue.displayName(),
                self.response['current_trip']['city']['name'],
                strftime("%B&nbsp;%d", start ),
                strftime("%B&nbsp;%d", finish ),
                readable_time
            )
        else:
            body = "<p>%s is at home in %s (where it is %s).</p>"%(
                self.provider.clue.displayName(),
                self.response['current_city']['name'],
                readable_time
            )

        return body