diff options
author | Giovanni Mascellani <mascellani@poisson.phc.unipi.it> | 2011-07-31 11:33:35 +0200 |
---|---|---|
committer | Sean Finney <seanius@htpc-l.(none)> | 2011-09-17 13:28:46 +0200 |
commit | b231a89e5bad73baa00edffc198bee93293eb295 (patch) | |
tree | 15e9c6b53564cf26e32d889f4a96ec32a72e0906 /patchtracker/ReqHandler.py | |
parent | bf10ac14e0fce21e6ebf9dc51c9dba7f783ae139 (diff) | |
download | patch-tracker-b231a89e5bad73baa00edffc198bee93293eb295.tar.gz |
Move makeDiffHandler in DB, so it can be used in other contexts.
Diffstat (limited to 'patchtracker/ReqHandler.py')
-rwxr-xr-x | patchtracker/ReqHandler.py | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/patchtracker/ReqHandler.py b/patchtracker/ReqHandler.py index 90fc75a..2ac1afb 100755 --- a/patchtracker/ReqHandler.py +++ b/patchtracker/ReqHandler.py @@ -10,7 +10,7 @@ from patchtracker.DiffGzHandler import DiffGzHandler, DiffGzException from patchtracker.DebTarHandler import DebTarHandler from patchtracker.CacheObject import CacheObject, CacheMissException import patchtracker.DB as DB -from patchtracker.DB import PatchTrackerDB +from patchtracker.DB import PatchTrackerDB, PackageWithoutDiffException import pygments from pygments.lexers import DiffLexer from pygments.formatters import HtmlFormatter @@ -41,7 +41,10 @@ class PatchCmd(Cmd): self.db = PatchTrackerDB() self.patchtype,mode,pkgname,version = args[0:4] self.parsemode(mode) - dh = self.make_diffhandler(pkgname,version) + try: + dh = self.db.makeDiffHandler(pkgname,version) + except PackageWithoutDiffException, e: + raise ReqHandlerException(str(e)) if self.patchtype == "series": self.patchname = os.sep.join(args[4:]) self.content = dh.series().fetch(self.patchname) @@ -67,18 +70,6 @@ class PatchCmd(Cmd): if mode == "dl": self.content_type = "text/x-diff" - # XXX this is kinda ugly... - def make_diffhandler(self, pkgname, vers): - dfile = self.db.findDiffGz(pkgname,vers) - if dfile: - return DiffGzHandler(dfile) - else: - dfile = self.db.findDebTar(pkgname, vers) - if dfile: - return DebTarHandler(dfile) - else: - raise ReqHandlerException("can not find diff file for %s / %s"%(pkgname,vers)) - def output(self): if self.mode == "dl": return str(self.content) |