Skip to content

Commit

Permalink
Adding pretty print code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Reifschneider committed Feb 19, 2008
1 parent eb5c23c commit 60f3e67
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions WHATSNEW
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Pretty print the time in tumgreyspf-stat, based on code by Luis Botero.

================================
Version 1.32 -- Thu Nov 29, 2007

Expand Down
15 changes: 13 additions & 2 deletions tumgreyspf-stat
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,21 @@ def visit(config, dirname, fileList):
if stats:
stats = ' (%s)' % stats[:-1]

def prettyseconds(seconds):
for prettySeconds, prettyDescription in (
( 86400, 'd' ),
( 3600, 'h' ),
( 60, 'm' ),
):
if seconds > prettySeconds:
return('%d%s' % ( seconds / prettySeconds, prettyDescription ))
return('%ss' % seconds)

# display information
print ('IP=%s SENDER=%s RECIPIENT=%s STARTS=%d LAST=%d EXPIRESIN=%s%s'
% ( ip, sender, recipient, now - mtime, now - ctime,
int(expireTime - now), stats ))
% ( ip, sender, recipient, prettyseconds(now - mtime),
prettyseconds(now - ctime),
prettyseconds(int(expireTime - now)), stats ))


############################
Expand Down

0 comments on commit 60f3e67

Please sign in to comment.