Jason Tackaberry wrote: > On Thu, 2008-03-13 at 19:24 +0100, Duncan Webb wrote: >> Log: >> Removed except Exception code, should allow the exceptions to travel up the >> stack > [...] >> + inprogress = self.recordserver_rpc('findNextProgram', isrecording) >> + if inprogress is None: >> return None >> + inprogress.wait() >> + result = inprogress.get_result() >> + _debug_('findNextProgramNow.result=%r' % (result,), 1) >> + return result > > I don't normally review or comment on freevo code, but it was impossible > not to notice that this boilerplate was repeated 17 times. It's just > screaming to be moved into a separate function. :)
:-) typical evolution of software, started off testing a few methods and then added more and copied the code for the next function and changed bits, then changed the function again; over time they all ended up looking very similar. There are a couple Python questions that arises out of this, most of the functions take different arguments: def findNextProgramNow(self, isrecording=False): def getScheduledRecordingsNow(self): def findMatchesNow(self, title=None, movies_only=None): tested with: result = rc.findNextProgramNow(True) result = rc.getScheduledRecordingsNow() if len(args) == 1: result = rc.findMatchesNow(args[0]) elif len(args) == 2: result = rc.findMatchesNow(args[0], args[1]) else: result = rc.findMatchesNow() What if the cleanest way of writing a function to call the function with different arguments, a decorator may work nicely but the may be a really simple way. The second question arises from the last test case, it doesn't seem as simple and clean as it could be, is there a simpler solution? BTW I have no problem from comments, I'm sure that there is a neater, quicker and better way to do some things and I'm more than happy for input, this way we learn. After all we're all human and f*** things up more often than we would like :-) Duncan ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Freevo-devel mailing list Freevo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freevo-devel