Quantcast

How do I extend a roundup Interval class with new methods?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How do I extend a roundup Interval class with new methods?

John P. Rouillard
Hi all:

The existing interval class is a bit of a bother. The default formats
for display are confusing. Is 20:10 20 hours and 10 minutes or 20
minutes and 10 seconds? If it printed all times in hh:mm:ss, like
00:20:10, it would not be ambiguous.

Also if I have a 2d 10h 20m interval, how can I display that as number
of hours and minutes? This would be useful for a timelog to see total
effort expended. Days of effort are rarely done in 24 hour
periods. Usually a day is 8 hours.

I would like to extend the current date.py:Interval: class to add some
more methods, but I am not sure how to go about it. I don't want to
subclass the Interval like:

import date

class MyInterval(Interval):
...

which would require modifying my schema to use the MyInterval class.

I just want to add new methods to the current Interval so I don't have
to change my schema.

Would adding the following to extensions/interval.py be sufficient?

class Interval:

  def inhours(self):
    ......


  def inminutes(self):
    ......


  def precise_pretty(self, threshold=90, format=None):
    ....

If not how would I go about this? In roundup-0.7 there used to be an
interfaces.py that could do this IIRC. I think that mechanism is still
around but ...

Ideas?

--
                                -- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Roundup-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/roundup-devel
Loading...