webcheck commit: r458 - webcheck/webcheck/plugins
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
webcheck commit: r458 - webcheck/webcheck/plugins
- From: Commits of the webcheck project <webcheck-commits [at] lists.arthurdejong.org>
- To: webcheck-commits [at] lists.arthurdejong.org
- Reply-to: webcheck-users [at] lists.arthurdejong.org
- Subject: webcheck commit: r458 - webcheck/webcheck/plugins
- Date: Fri, 14 Oct 2011 16:10:59 +0200 (CEST)
Author: arthur
Date: Fri Oct 14 16:10:58 2011
New Revision: 458
URL: http://arthurdejong.org/viewvc/webcheck?revision=458&view=revision
Log:
simplification in size calculation
Modified:
webcheck/webcheck/plugins/size.py
Modified: webcheck/webcheck/plugins/size.py
==============================================================================
--- webcheck/webcheck/plugins/size.py Fri Oct 14 14:57:08 2011 (r457)
+++ webcheck/webcheck/plugins/size.py Fri Oct 14 16:10:58 2011 (r458)
@@ -33,24 +33,22 @@
import webcheck.plugins
-def _getsize(link, done=None):
+def _getsize(link, seen=None):
"""Return the size of the link and all its embedded links, counting each
link only once."""
# make a new list
- if done is None:
- done = []
+ if seen is None:
+ seen = set()
# add this link to the list
- done.append(link)
+ seen.add(link)
# if we don't known about our total size yet, calculate
if not hasattr(link, 'total_size'):
- size = 0
# add our size
- if link.size is not None:
- size = link.size
+ size = link.size or 0
# add sizes of embedded objects
for embed in link.embedded:
- if embed not in done:
- size += _getsize(embed, done)
+ if embed not in seen:
+ size += _getsize(embed, seen)
link.total_size = size
return link.total_size
--
To unsubscribe send an email to
webcheck-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/webcheck-commits/
- webcheck commit: r458 - webcheck/webcheck/plugins,
Commits of the webcheck project