equal
deleted
inserted
replaced
34 """Returns True if provided url is valid ATOM or RSS. |
34 """Returns True if provided url is valid ATOM or RSS. |
35 |
35 |
36 Args: |
36 Args: |
37 feed_url: ATOM or RSS feed url |
37 feed_url: ATOM or RSS feed url |
38 """ |
38 """ |
39 if feed_url: |
39 |
|
40 # a missing or empty feed url is never valid |
|
41 if not feed_url: |
|
42 return False |
|
43 |
|
44 try: |
40 result = urlfetch.fetch(feed_url) |
45 result = urlfetch.fetch(feed_url) |
41 if result.status_code == 200: |
46 except urlfetch_errors.Error, e: |
42 parsed_feed = feedparser.parse(result.content) |
47 return False |
43 if parsed_feed.version and (parsed_feed.version != ''): |
48 |
44 return True |
49 # 200 is the status code for 'all ok' |
45 return False |
50 if result.status_code != 200: |
|
51 return False |
|
52 |
|
53 parsed_feed = feedparser.parse(result.content) |
|
54 |
|
55 # version is always present if the feed is valid |
|
56 if not parsed_feed.version: |
|
57 return False |
|
58 |
|
59 # TODO: isn't this check redunant? |
|
60 if parsed_feed.version == '': |
|
61 return False |
|
62 |
|
63 return True |
46 |
64 |
47 |
65 |
48 def isLinkIdFormatValid(link_id): |
66 def isLinkIdFormatValid(link_id): |
49 """Returns True if link_id is in a valid format. |
67 """Returns True if link_id is in a valid format. |
50 |
68 |