From: Cameron Dale Date: Wed, 5 Mar 2008 23:04:50 +0000 (-0800) Subject: Various documentation fixes and additions. X-Git-Url: https://git.mxchange.org/?p=quix0rs-apt-p2p.git;a=commitdiff_plain;h=5ae15cb5cc24c1fd9a75ea7a8b416f733d1c79be;hp=04e422d1ddc237684b4b236aff984d2f76ec2c8c Various documentation fixes and additions. --- diff --git a/apt_dht/AptPackages.py b/apt_dht/AptPackages.py index 983bf22..45c035f 100644 --- a/apt_dht/AptPackages.py +++ b/apt_dht/AptPackages.py @@ -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.""" diff --git a/apt_dht/__init__.py b/apt_dht/__init__.py index c4dcfb4..b945cec 100644 --- a/apt_dht/__init__.py +++ b/apt_dht/__init__.py @@ -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:: +---------------+ +-----------------------------------+ +------------- diff --git a/apt_dht_Khashmir/actions.py b/apt_dht_Khashmir/actions.py index cc98610..1179713 100644 --- a/apt_dht_Khashmir/actions.py +++ b/apt_dht_Khashmir/actions.py @@ -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) diff --git a/apt_dht_Khashmir/bencode.py b/apt_dht_Khashmir/bencode.py index b9153ee..06a64e7 100644 --- a/apt_dht_Khashmir/bencode.py +++ b/apt_dht_Khashmir/bencode.py @@ -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} diff --git a/apt_dht_Khashmir/db.py b/apt_dht_Khashmir/db.py index dc97352..47e974c 100644 --- a/apt_dht_Khashmir/db.py +++ b/apt_dht_Khashmir/db.py @@ -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() diff --git a/apt_dht_Khashmir/node.py b/apt_dht_Khashmir/node.py index 99d95fb..49b8fe7 100644 --- a/apt_dht_Khashmir/node.py +++ b/apt_dht_Khashmir/node.py @@ -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}