Skip to content

Commit 7239b61

Browse files
committed
Better strategy for -f option: import feeds and then fetch them.
1 parent 881f52d commit 7239b61

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

coldsweat/commands.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,13 @@ def command_import(self, options, args):
5656

5757
self.user = self._get_user(options.username)
5858

59-
feeds = self.add_feeds_from_file(args[0], options.fetch_data)
59+
feeds = self.add_feeds_from_file(args[0])
6060
for feed, group in feeds:
61-
self.add_subscription(feed, group)
62-
61+
self.add_subscription(feed, group)
62+
if options.fetch_data:
63+
# Fetch just imported feeds
64+
self.fetch_feeds([feed for feed, group in feeds])
65+
6366
print "Import%s completed for user %s. See log file for more information" % (' and fetch' if options.fetch_data else '', self.user.username)
6467

6568

coldsweat/models.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,22 @@ def initialize_connection(self, connection):
5050
self.execute_sql('PRAGMA foreign_keys=ON;')
5151

5252
def parse_connection_url(url):
53-
parsed = urlparse.urlparse(url, scheme='sqlite')
54-
connect_kwargs = {'database': parsed.path[1:]}
55-
if parsed.username:
56-
connect_kwargs['user'] = parsed.username
57-
if parsed.password:
58-
connect_kwargs['password'] = parsed.password
59-
if parsed.hostname:
60-
connect_kwargs['host'] = parsed.hostname
61-
if parsed.port:
62-
connect_kwargs['port'] = parsed.port
63-
53+
parsed = urlparse.urlparse(url, scheme='sqlite')
54+
connect_kwargs = {'database': parsed.path[1:]}
55+
if parsed.username:
56+
connect_kwargs['user'] = parsed.username
57+
if parsed.password:
58+
connect_kwargs['password'] = parsed.password
59+
if parsed.hostname:
60+
connect_kwargs['host'] = parsed.hostname
61+
if parsed.port:
62+
connect_kwargs['port'] = parsed.port
63+
6464
# Adjust parameters for MySQL
65-
if parsed.scheme == 'mysql' and 'password' in connect_kwargs:
66-
connect_kwargs['passwd'] = connect_kwargs.pop('password')
67-
68-
return parsed.scheme, connect_kwargs
65+
if parsed.scheme == 'mysql' and 'password' in connect_kwargs:
66+
connect_kwargs['passwd'] = connect_kwargs.pop('password')
67+
68+
return parsed.scheme, connect_kwargs
6969

7070

7171
engine, kwargs = parse_connection_url(config.database.connection_url)
@@ -79,7 +79,7 @@ def parse_connection_url(url):
7979
_db = PostgresqlDatabase(autorollback=True, **kwargs)
8080
migrator = PostgresqlMigrator(_db)
8181
else:
82-
raise ValueError('Unknown database engine %s. Should be sqlite, postgresql or mysql' % engine)
82+
raise ValueError('Unknown database engine %s. Should be sqlite, postgresql or mysql' % engine)
8383

8484
# ------------------------------------------------------
8585
# Custom fields

0 commit comments

Comments
 (0)