Package flumotion :: Package common :: Module format
[hide private]

Module format

source code

formatting functions for storage, time, etc


Version: $Rev: 6969 $

Functions [hide private]
string
formatStorage(units, precision=2)
Nicely formats a storage size using SI units.
source code
string
formatTime(seconds, fractional=0)
Nicely format time in a human-readable format.
source code
string
formatTimeStamp(timeOrTuple)
Format a timestamp in a human-readable format.
source code
 
strftime(format, t)
A version of time.strftime that can handle unicode formats.
source code
Function Details [hide private]

formatStorage(units, precision=2)

source code 

Nicely formats a storage size using SI units. See Wikipedia and other sources for rationale. Prefixes are k, M, G, ... Sizes are powers of 10. Actual result should be suffixed with bit or byte, not b or B.

Parameters:
  • units (int or float) - the unit size to format
  • precision (int) - the number of floating point digits to use
Returns: string
value of units, formatted using SI scale and the given precision

formatTime(seconds, fractional=0)

source code 

Nicely format time in a human-readable format. Will chunks weeks, days, hours and minutes.

Parameters:
  • seconds (int or float) - the time in seconds to format.
  • fractional (int) - how many digits to show for the fractional part.
Returns: string
a nicely formatted time string.

formatTimeStamp(timeOrTuple)

source code 

Format a timestamp in a human-readable format.

Parameters:
  • timeOrTuple (something that time.strftime will accept) - the timestamp to format
Returns: string
a nicely formatted timestamp string.

strftime(format, t)

source code 

A version of time.strftime that can handle unicode formats.

Parameters:
  • format - format to convert, see man strftime(3)
  • t - time tuple as returned by time.localtime()