Support config.ini as a format for reading lists

This commit is contained in:
Sam Ruby 2007-08-19 22:13:00 -04:00
parent 4d603b6bf7
commit d025fe59ac
5 changed files with 40 additions and 15 deletions

View File

@ -140,7 +140,8 @@ the predefined themes presume that at least <code>name</code> is defined.</p>
<p>The <code>content_type</code> parameter can be defined to indicate that
this subscription is a <em>reading list</em>, i.e., is an external list
of subscriptions. At the moment, three formats of reading lists are supported:
<code>opml</code>, <code>foaf</code>, and <code>csv</code>. In the future,
<code>opml</code>, <code>foaf</code>, <code>csv</code>, and
<code>config</code>. In the future,
support for formats like <code>xoxo</code> could be added.</p>
<p><a href="normalization.html#overrides">Normalization overrides</a> can
also be defined here.</p>

View File

@ -193,20 +193,22 @@ def load(config_file):
os.makedirs(config.cache_lists_directory())
def data2config(data, cached_config):
if content_type(list).find('opml')>=0:
opml.opml2config(data, cached_config)
elif content_type(list).find('foaf')>=0:
foaf.foaf2config(data, cached_config)
elif content_type(list).find('csv')>=0:
csv_config.csv2config(data, cached_config)
else:
from planet import shell
import StringIO
cached_config.readfp(StringIO.StringIO(shell.run(
content_type(list), data.getvalue(), mode="filter")))
if content_type(list).find('opml')>=0:
opml.opml2config(data, cached_config)
elif content_type(list).find('foaf')>=0:
foaf.foaf2config(data, cached_config)
elif content_type(list).find('csv')>=0:
csv_config.csv2config(data, cached_config)
elif content_type(list).find('config')>=0:
cached_config.readfp(data)
else:
from planet import shell
import StringIO
cached_config.readfp(StringIO.StringIO(shell.run(
content_type(list), data.getvalue(), mode="filter")))
if cached_config.sections() in [[], [list]]:
raise Exception
if cached_config.sections() in [[], [list]]:
raise Exception
for list in reading_lists:
downloadReadingList(list, parser, data2config)
@ -349,7 +351,8 @@ def reading_lists():
if parser.has_option(section, 'content_type'):
type = parser.get(section, 'content_type')
if type.find('opml')>=0 or type.find('foaf')>=0 or \
type.find('csv')>=0 or type.find('.')>=0:
type.find('csv')>=0 or type.find('config')>=0 or \
type.find('.')>=0:
result.append(section)
return result

View File

@ -0,0 +1,7 @@
[Planet]
name = CSV Test Configuration
cache_directory = tests/work/config/cache
filters = foo
[tests/data/config/subconfig.ini]
content_type = config

View File

@ -0,0 +1,6 @@
[feed1]
name = one
[feed2]
name = two
filters = bar

8
tests/test_subconfig.py Normal file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env python
from test_config_csv import ConfigCsvTest
from planet import config
class SubConfigTest(ConfigCsvTest):
def setUp(self):
config.load('tests/data/config/rlist-config.ini')