Various documentation fixes and additions.
authorCameron Dale <camrdale@gmail.com>
Wed, 5 Mar 2008 23:04:50 +0000 (15:04 -0800)
committerCameron Dale <camrdale@gmail.com>
Wed, 5 Mar 2008 23:04:50 +0000 (15:04 -0800)
apt_dht/AptPackages.py
apt_dht/__init__.py
apt_dht_Khashmir/actions.py
apt_dht_Khashmir/bencode.py
apt_dht_Khashmir/db.py
apt_dht_Khashmir/node.py

index 983bf22..45c035f 100644 (file)
@@ -203,7 +203,7 @@ class AptPackages:
         self.apt_config['Dir'] = self.cache_dir.path
         self.apt_config['Dir::State::status'] = self.cache_dir.preauthChild(self.apt_config['Dir::State']).preauthChild(self.apt_config['Dir::State::status']).path
         self.packages = PackageFileList(cache_dir)
-        self.loaded = 0
+        self.loaded = False
         self.loading = None
         self.unload_later = None
         
@@ -321,7 +321,7 @@ class AptPackages:
         else:
             self.srcrecords = None
 
-        self.loaded = 1
+        self.loaded = True
         return True
 
     def unload(self):
@@ -336,7 +336,7 @@ class AptPackages:
             del self.records
             del self.srcrecords
             del self.indexrecords
-            self.loaded = 0
+            self.loaded = False
 
     def cleanup(self):
         """Cleanup and close any loaded caches."""
index c4dcfb4..b945cec 100644 (file)
@@ -1,6 +1,13 @@
 
 """The main apt-dht modules.
 
+To run apt-dht, you probably want to do something like::
+
+  from apt_dht.apt_dht import AptDHT
+  myapp = AptDHT(myDHT)
+
+where myDHT is a DHT that implements interfaces.IDHT.
+
 Diagram of the interaction between the given modules::
   
   +---------------+    +-----------------------------------+    +-------------
index cc98610..1179713 100644 (file)
@@ -82,7 +82,7 @@ class ActionBase:
         self.callback = callback
         self.outstanding = 0
         self.outstanding_results = 0
-        self.finished = 0
+        self.finished = False
     
         def sort(a, b, num=self.num):
             """Sort nodes relative to the ID we are looking for."""
@@ -111,7 +111,7 @@ class ActionBase:
         if self.desired_results and ((len(self.results) >= abs(self.desired_results)) or
                                      (self.desired_results < 0 and
                                       len(self.answered) >= self.config['STORE_REDUNDANCY'])):
-            self.finished=1
+            self.finished = True
             result = self.generateResult()
             reactor.callLater(0, self.callback, *result)
 
@@ -156,7 +156,7 @@ class ActionBase:
 
         # If no requests are outstanding, then we are done
         if self.outstanding == 0:
-            self.finished = 1
+            self.finished = True
             result = self.generateResult()
             reactor.callLater(0, self.callback, *result)
 
index b9153ee..06a64e7 100644 (file)
@@ -172,7 +172,7 @@ decode_func['9'] = decode_string
 decode_func['u'] = decode_unicode
 decode_func['t'] = decode_datetime
   
-def bdecode(x, sloppy = 0):
+def bdecode(x, sloppy = False):
     """Bdecode a string of data.
     
     @type x: C{string}
index dc97352..47e974c 100644 (file)
@@ -108,10 +108,7 @@ class DB:
         self.conn.commit()
         
     def getRoutingTable(self):
-        """Load routing table nodes from database.
-        
-        It's usually a good idea to call refreshTable(force=1) after loading the table.
-        """
+        """Load routing table nodes from database."""
         c = self.conn.cursor()
         c.execute("SELECT * FROM nodes")
         return c.fetchall()
index 99d95fb..49b8fe7 100644 (file)
@@ -21,6 +21,8 @@ NULL_ID = 20 * '\0'
 class Node:
     """Encapsulate a node's contact info.
     
+    @ivar conn: the connection to the remote node (added externally)
+    @ivar table: the routing table (added externally)
     @type fails: C{int}
     @ivar fails: number of times this node has failed in a row
     @type lastSeen: C{datetime.datetime}