web/ldt/text/utils.py
author ymh <ymh.work@gmail.com>
Mon, 13 Dec 2010 23:55:19 +0100
changeset 22 83b28fc0d731
parent 9 22ab430e9b64
child 24 9e19b7ae3780
permissions -rw-r--r--
improve on ldt test framework start migration for text test

from django.conf import settings
import base64
import django.core.urlresolvers
import lxml.etree
import urllib
import uuid

__BOOLEAN_DICT = {
    'false':False,
    'true':True,
    '0':False,
    '1':True,
    't': True,
    'f':False
}

def boolean_convert(bool):
    if bool is None:
        return False
    if bool is True or bool is False:
        return bool
    key = str(bool).lower()
    return __BOOLEAN_DICT.get(key, False)


def generate_uuid():
    return unicode(uuid.uuid1())


def normalize_tags(list):
    nlist=[]
    for tag in list:
        tag = tag.lower()
        nlist.append(tag)
    taglist = dict().fromkeys(nlist).keys()    
    
    return taglist