Permalink
Browse files

Support config.ini as a format for reading lists

  • Loading branch information...
1 parent 4d603b6 commit d025fe59ac56c88cfaa0c0026405d1b7fa5ea412 @rubys committed Aug 20, 2007
Showing with 40 additions and 15 deletions.
  1. +2 −1 docs/config.html
  2. +17 −14 planet/config.py
  3. +7 −0 tests/data/config/rlist-config.ini
  4. +6 −0 tests/data/config/subconfig.ini
  5. +8 −0 tests/test_subconfig.py
View
@@ -140,7 +140,8 @@ <h3 id="subscription"><code>[</code><em>subscription</em><code>]</code></h3>
<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
@@ -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
@@ -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
@@ -0,0 +1,6 @@
+[feed1]
+name = one
+
+[feed2]
+name = two
+filters = bar
View
@@ -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')

0 comments on commit d025fe5

Please sign in to comment.