Skip to content

Commit 215000a

Browse files
committed
app: InputURLTask: Add TODOs and stub code for progress
1 parent 265bcde commit 215000a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

wpull/application/tasks/database.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,17 @@ class InputURLTask(ItemTask[AppSession]):
4040
@asyncio.coroutine
4141
def process(self, session: AppSession):
4242
url_table = session.factory['URLTable']
43+
url_count = 0
4344

4445
for batch in wpull.util.grouper(self._read_input_urls(session), 1000):
45-
url_table.add_many(AddURLInfo(url_info.url, None, None) for url_info in batch if url_info)
46+
urls = url_table.add_many(AddURLInfo(url_info.url, None, None) for url_info in batch if url_info)
4647
# TODO: attach hook for notifying progress
48+
url_count += len(urls)
4749

48-
# TODO: raise on error if no urls
49-
# urls = (line.strip() for line in input_file if line.strip())
50-
#
51-
# if not urls:
52-
# raise ValueError(_('No URLs found in input file.'))
53-
#
54-
# return urls
50+
# TODO: check if database is empty
51+
# TODO: add a test for this
52+
# if not url_count:
53+
# raise ValueError(_('No URLs found in input file.'))
5554

5655
@classmethod
5756
def _read_input_urls(cls, session: AppSession, default_scheme='http'):

0 commit comments

Comments
 (0)