Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Utils module: Collection of misc functions. """
""" Given the timedelta instance, return pretty-print format strictly in hourly unit.
>>> from datetime import timedelta >>> strfdelta(timedelta(days=1)) '24:00 hrs'
>>> strfdelta(timedelta(minutes=15)) ' 0:15 hrs'
>>> strfdelta(None) ''
"""
def validate_intjid(arg): """ Try to cast arg into intjid.
>>> validate_intjid(123) 123
>>> validate_intjid('123') 123
>>> validate_intjid('not_a_number') is None True
>>> validate_intjid(None) is None True
""" return arg.fqid
""" Given string s, return the substituted formed without closed '[CLOSED]' tag. Be careful about additional whitespacing.
Usage: >>> ignore_closed('Hello [CLOSED]') 'Hello' >>> ignore_closed('World[CLOSED]') 'World' >>> ignore_closed('No need to be closed') 'No need to be closed'
"""
""" Retrieve value in dict d, whilst ignore the TAG_CLOSE in both key and d.keys()
Usage: >>> dictget_ignore_closed({ 'key[CLOSED]': 'val' }, 'key') 'val' >>> dictget_ignore_closed({ 'key': 'val' }, 'key [CLOSED]') 'val'
Raises: KeyError, when invalid key is given.
""" # if isinstance(k, basestring): # If key is string, this is dir (int-key for job)
""" Helper method to replace envvar in string s from manually-given env dict.
Usage: >>> expandvars( '$DECFILESROOT/options/xxx.py', {'DECFILESROOT': '/some/path'}) '/some/path/options/xxx.py'
"""
""" - cast iterable of string to int - unique by set
Usage: >>> set_of_int({'2', '3', '1'}) set([1, 2, 3]) """ |