def run_dialog(): """Creates and launches the New Feed dialog. This dialog waits for the user to press "Create Feed" or "Cancel". Returns a tuple of the (url, section). """ text = app.widgetapp.get_clipboard_text() if text and feed.validate_feed_url(text): text = feed.normalize_feed_url(text) else: text = "" title = _('Add Feed') description = _('Enter the URL of the feed to add') while 1: text, section = _run_dialog(title, description, initial_text=text) if text == None: return (None, None) normalized_url = feed.normalize_feed_url(text) if feed.validate_feed_url(normalized_url): return (normalized_url, section) title = _('Add Feed - Invalid URL') description = _('The address you entered is not a valid url.\nPlease check the URL and try again.\n\nEnter the URL of the feed to add')
def run_dialog(): """Creates and launches the New Feed dialog. This dialog waits for the user to press "Create Podcast" or "Cancel". Returns the URL, or None. """ text = app.widgetapp.get_clipboard_text() if text and feed.validate_feed_url(text): text = feed.normalize_feed_url(text) else: text = "" title = _('Add Podcast') description = _('Enter the URL of the podcast to add') while 1: text = _run_dialog(title, description, initial_text=text) if text == None: return None normalized_url = feed.normalize_feed_url(text) if feed.validate_feed_url(normalized_url): return normalized_url title = _('Add Podcast - Invalid URL') description = _( 'The address you entered is not a valid url. ' 'Please check the URL and try again.' '\n\n' 'Enter the URL of the podcast to add')
def run_dialog(): """Creates and launches the New Feed dialog. This dialog waits for the user to press "Create Podcast" or "Cancel". Returns the URL, or None. """ text = app.widgetapp.get_clipboard_text() if text and feed.validate_feed_url(text): text = feed.normalize_feed_url(text) else: text = "" title = _('Add Podcast') description = _('Enter the URL of the podcast to add') while 1: text = _run_dialog(title, description, initial_text=text) if text == None: return None normalized_url = feed.normalize_feed_url(text) if feed.validate_feed_url(normalized_url): return normalized_url title = _('Add Podcast - Invalid URL') description = _('The address you entered is not a valid url. ' 'Please check the URL and try again.' '\n\n' 'Enter the URL of the podcast to add')
def test_garbage(self): for i, o in [(u"http:foo.bar.com", u"http://foo.bar.com/"), (u"https:foo.bar.com", u"https://foo.bar.com/"), (u"feed:foo.bar.com", u"http://foo.bar.com/"), (u"http:/foo.bar.com", u"http://foo.bar.com/"), (u"https:/foo.bar.com", u"https://foo.bar.com/"), (u"feed:/foo.bar.com", u"http://foo.bar.com/"), (u"http:///foo.bar.com", u"http://foo.bar.com/"), (u"https:///foo.bar.com", u"https://foo.bar.com/"), (u"feed:///foo.bar.com", u"http://foo.bar.com/"), (u"foo.bar.com", u"http://foo.bar.com/"), (u"http://foo.bar.com:80", u"http://foo.bar.com:80/"), ]: self.assertEquals(normalize_feed_url(i), o)
def ask_for_feed_subscribe(url): url = feed.normalize_feed_url(url) title = _("Subscribe to Podcast") text = _( "This link appears to be a podcast. Do you want to add it to " "your subscriptions?\n" "\n" "%(url)s", {"url": url} ) choices = (dialogs.BUTTON_SUBSCRIBE, dialogs.BUTTON_CANCEL) ret = dialogs.show_choice_dialog(title, text, choices) if ret == dialogs.BUTTON_SUBSCRIBE: messages.NewFeed(url).send_to_backend()
def test_garbage(self): for i, o in [ (u"http:foo.bar.com", u"http://foo.bar.com/"), (u"https:foo.bar.com", u"https://foo.bar.com/"), (u"feed:foo.bar.com", u"http://foo.bar.com/"), (u"http:/foo.bar.com", u"http://foo.bar.com/"), (u"https:/foo.bar.com", u"https://foo.bar.com/"), (u"feed:/foo.bar.com", u"http://foo.bar.com/"), (u"http:///foo.bar.com", u"http://foo.bar.com/"), (u"https:///foo.bar.com", u"https://foo.bar.com/"), (u"feed:///foo.bar.com", u"http://foo.bar.com/"), (u"foo.bar.com", u"http://foo.bar.com/"), (u"http://foo.bar.com:80", u"http://foo.bar.com:80/"), ]: self.assertEquals(normalize_feed_url(i), o)
def _on_add_source(self, *args): url = self.source_entry.get_text() url = feed.normalize_feed_url(url) if url: messages.NewGuide(url).send_to_backend() self.source_entry.set_text('')
def test_easy(self): for i, o in [(u"http://foo.bar.com", u"http://foo.bar.com/"), (u"https://foo.bar.com", u"https://foo.bar.com/"), (u"feed://foo.bar.com", u"http://foo.bar.com/")]: self.assertEqual(normalize_feed_url(i), o)
def test_easy(self): for i, o in [(u"http://foo.bar.com", u"http://foo.bar.com/"), (u"https://foo.bar.com", u"https://foo.bar.com/"), (u"feed://foo.bar.com", u"http://foo.bar.com/") ]: self.assertEqual(normalize_feed_url(i), o)