summaryrefslogtreecommitdiff
path: root/lib/thandy/repository.py
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-07-25 15:13:04 -0400
committerNick Mathewson <nickm@torproject.org>2010-07-25 16:57:24 -0400
commitbbb6cb5fe6a61aa0975dcd9df11f9f648f6abba2 (patch)
treec97f164ecc7811ef3d6ba07d51a8c05a695d222d /lib/thandy/repository.py
parent5f2d07ce78e6443592f84a803fe2adced49ada39 (diff)
More unit tests and documentation for the Thandy code
Diffstat (limited to 'lib/thandy/repository.py')
-rw-r--r--lib/thandy/repository.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/thandy/repository.py b/lib/thandy/repository.py
index f5a4de2..bc4d73b 100644
--- a/lib/thandy/repository.py
+++ b/lib/thandy/repository.py
@@ -52,10 +52,13 @@ class RepositoryFile:
self._mtime = None
def clear(self):
- """DOCDOC"""
+ """Clear all cached fields loaded from disk; the next time we need one,
+ we'll reload the file entirely.
+ """
self._main_obj = self._signed_obj = None
self._sigStatus = None
self._mtime = None
+ self._length = None
def getRelativePath(self):
"""Return the filename for this item relative to the top of the
@@ -118,6 +121,7 @@ class RepositoryFile:
return signed_obj, main_obj
def checkFile(self, fname, needhash=None):
+ """DOCDOC"""
f = open(fname, 'r')
try:
s = f.read()
@@ -167,7 +171,9 @@ class RepositoryFile:
return self._sigStatus
class PkgFile:
+ """DOCDOC"""
def __init__(self, repository, relativePath, needHash):
+ """DOCDOC"""
self._repository = repository
self._relativePath = relativePath
self._needHash = needHash
@@ -175,22 +181,28 @@ class PkgFile:
self._mtime = None
def clear(self):
+ """DOCDOC"""
self._mtime = None
def load(self):
+ """DOCDOC"""
pass
def getRelativePath(self):
+ """DOCDOC"""
return self._relativePath
def getPath(self):
+ """DOCDOC"""
fname = self._repository.getFilename(self._relativePath)
return os.path.normpath(fname)
def getExpectedHash(self):
+ """DOCDOC"""
return self._needHash
def checkFile(self, fname, needHash=None):
+ """DOCDOC"""
if needHash:
if thandy.formats.getFileDigest(fname) != needHash:
raise thandy.FormatException("Digest for %s not as expected.")