lists.arthurdejong.org
RSS feed

webcheck commit: r452 - webcheck/webcheck

[Date Prev][Date Next] [Thread Prev][Thread Next]

webcheck commit: r452 - webcheck/webcheck



Author: arthur
Date: Sat Oct  8 16:04:03 2011
New Revision: 452
URL: http://arthurdejong.org/viewvc/webcheck?revision=452&view=revision

Log:
ensure that the database is emptied completely and move the code to webcheck.db

Modified:
   webcheck/webcheck/crawler.py
   webcheck/webcheck/db.py

Modified: webcheck/webcheck/crawler.py
==============================================================================
--- webcheck/webcheck/crawler.py        Sat Oct  8 15:58:00 2011        (r451)
+++ webcheck/webcheck/crawler.py        Sat Oct  8 16:04:03 2011        (r452)
@@ -39,8 +39,7 @@
 import urlparse
 
 from webcheck import config, debugio
-from webcheck.db import Session, Base, Link, LinkProblem, PageProblem, \
-        children, embedded
+from webcheck.db import Session, Base, Link
 from webcheck.util import install_file
 import webcheck.parsers
 
@@ -266,16 +265,7 @@
         session = Session()
         # remove all links
         if not config.CONTINUE:
-            session.query(LinkProblem).delete()
-            session.commit()
-            session.query(PageProblem).delete()
-            session.commit()
-            session.execute(children.delete())
-            session.commit()
-            session.execute(embedded.delete())
-            session.commit()
-            session.query(Link).delete()
-            session.commit()
+            truncate_db()
         # add all internal urls to the database
         for url in self._internal_urls:
             url = Link.clean_url(url)

Modified: webcheck/webcheck/db.py
==============================================================================
--- webcheck/webcheck/db.py     Sat Oct  8 15:58:00 2011        (r451)
+++ webcheck/webcheck/db.py     Sat Oct  8 16:04:03 2011        (r452)
@@ -296,3 +296,22 @@
 
     def __unicode__(self):
         return self.anchor
+
+
+def truncate_db():
+    """Clear all tables in the database."""
+    session = Session()
+    session.query(LinkProblem).delete()
+    session.commit()
+    session.query(PageProblem).delete()
+    session.commit()
+    session.query(Anchor).delete()
+    session.commit()
+    session.query(RequestedAnchor).delete()
+    session.commit()
+    session.execute(children.delete())
+    session.commit()
+    session.execute(embedded.delete())
+    session.commit()
+    session.query(Link).delete()
+    session.commit()
-- 
To unsubscribe send an email to
webcheck-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/webcheck-commits/