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 983bf22406947f9011118e5fd325d44707fb70ce..45c035f12833ce707f933d34c2c2978421e9e8f9 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.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
         
         self.loading = None
         self.unload_later = None
         
@@ -321,7 +321,7 @@ class AptPackages:
         else:
             self.srcrecords = None
 
         else:
             self.srcrecords = None
 
-        self.loaded = 1
+        self.loaded = True
         return True
 
     def unload(self):
         return True
 
     def unload(self):
@@ -336,7 +336,7 @@ class AptPackages:
             del self.records
             del self.srcrecords
             del self.indexrecords
             del self.records
             del self.srcrecords
             del self.indexrecords
-            self.loaded = 0
+            self.loaded = False
 
     def cleanup(self):
         """Cleanup and close any loaded caches."""
 
     def cleanup(self):
         """Cleanup and close any loaded caches."""
index c4dcfb4748a1308bbf456e31c2576240f7fc721a..b945cecc62c30ca08dbcd6d0d80ee973236e9dcd 100644 (file)
@@ -1,6 +1,13 @@
 
 """The main apt-dht modules.
 
 
 """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::
   
   +---------------+    +-----------------------------------+    +-------------
 Diagram of the interaction between the given modules::
   
   +---------------+    +-----------------------------------+    +-------------
index cc9861043f2e531274086e1f886f630c13390cde..1179713c22847fc3236cd95e61684b38c6cf0d80 100644 (file)
@@ -82,7 +82,7 @@ class ActionBase:
         self.callback = callback
         self.outstanding = 0
         self.outstanding_results = 0
         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."""
     
         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'])):
         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)
 
             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:
 
         # 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)
 
             result = self.generateResult()
             reactor.callLater(0, self.callback, *result)
 
index b9153ee8b1f7b9a08eba9f2237266d6044a18779..06a64e7377182094f6874bdf9e19b0be77bb132b 100644 (file)
@@ -172,7 +172,7 @@ decode_func['9'] = decode_string
 decode_func['u'] = decode_unicode
 decode_func['t'] = decode_datetime
   
 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}
     """Bdecode a string of data.
     
     @type x: C{string}
index dc97352f8644beb07d9b20bd39edb031571e562f..47e974cf62122bab33cd4b4a4868a92e873bf822 100644 (file)
@@ -108,10 +108,7 @@ class DB:
         self.conn.commit()
         
     def getRoutingTable(self):
         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()
         c = self.conn.cursor()
         c.execute("SELECT * FROM nodes")
         return c.fetchall()
index 99d95fb1b67c2793f709e99b9d221dee2d69541b..49b8fe75a06923379d5bfecad8d86f083262a5aa 100644 (file)
@@ -21,6 +21,8 @@ NULL_ID = 20 * '\0'
 class Node:
     """Encapsulate a node's contact info.
     
 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}
     @type fails: C{int}
     @ivar fails: number of times this node has failed in a row
     @type lastSeen: C{datetime.datetime}