def canonize_refnum(refnum, digits = 20):
    if refnum == None:
        return '0' * digits
    refnum = refnum.replace(' ', '')
    if len(refnum) < digits:
        refnum = refnum.zfill(digits) # zero pad
    if refnum.isdigit() and len(refnum) == digits and check_checknumber(refnum):
        return refnum
    else:
        raise ReferenceNumberFormatException("Reference number '%s' invalid" %
            refnum)
:rtype: Bucket
dataset/ETHPy150Open kapsiry/sikteeri/membership/reference_numbers.py/canonize_refnum--crossover with--dataset/ETHPy150Open BD2KGenomics/toil/src/toil/jobStores/aws/jobStore.py/AWSJobStore._getOrCreateBucket