Example #1
0
 def _export_new_opml(self, selected_file):
     opml_parser = OpmlParser()       
     with open(selected_file + '.opml', 'w') as new_file:
         with open(self.file_path, 'r') as links_file:
             links = links_file.read()
             opml = opml_parser.build_opml(links)
             new_file.write(opml)
Example #2
0
 def _export_new_opml(self, selected_file):
     opml_parser = OpmlParser()
     with open(selected_file + '.opml', 'w') as new_file:
         with open(self.file_path, 'r') as links_file:
             links = links_file.read()
             opml = opml_parser.build_opml(links)
             new_file.write(opml)
Example #3
0
 def _import_opml(self, selected_file):
     opml_parser = OpmlParser()
     try:
         opml_parser.parse(selected_file)
         with open(self.file_path, 'a+') as links_file:
             for feed in opml_parser.feeds:
                 if re.search(r'(.*), (.*)', feed):
                     links_file.write(feed + '\n')
                 else:
                     self._throw_import_error()
     except KeyError:
         self._throw_import_error()
Example #4
0
 def _import_opml(self, selected_file):
     opml_parser = OpmlParser()
     try:
         opml_parser.parse(selected_file)
         with open(self.file_path, 'a+') as links_file:
             for feed in opml_parser.feeds:
                 if re.search(r'(.*), (.*)', feed):
                     links_file.write(feed + '\n')
                 else:
                     self._throw_import_error()
     except KeyError:
         self._throw_import_error()
Example #5
0
 def test_opml_item(self):
     parser = OpmlParser()
     parser.parse('export_feeds_opml.opml')
     splited_item = parser.feeds[0].split(', ')
     self.assertEqual('PC Mania', splited_item[0])
     self.assertEqual('http://pcmania.bg/feed.php', splited_item[1])
Example #6
0
 def test_opml_items(self):
     parser = OpmlParser()
     parser.parse('export_feeds_opml.opml')
     self.assertEqual(len(parser.feeds), 2)
Example #7
0
 def test_invalid_opml_feed(self):
     parser = OpmlParser()
     self.assertRaises(KeyError, parser.parse, 'invalid_opml.opml')