def is_valid_uuid (uuid):
try:<EOL><INDENT>if len (uuid) == <NUM_LIT:4>:<EOL><INDENT>if int (uuid, <NUM_LIT:16>) < <NUM_LIT:0>: return False<EOL><DEDENT>elif len (uuid) == <NUM_LIT:8>:<EOL><INDENT>if int (uuid, <NUM_LIT:16>) < <NUM_LIT:0>: return False<EOL><DEDENT>elif len (uuid) == <NUM_LIT>:<EOL><INDENT>pieces = uuid.split ("<STR_LIT:->")<EOL>if len (pieces) != <NUM_LIT:5> orlen (pieces[<NUM_LIT:0>]) != <NUM_LIT:8> orlen (pieces[<NUM_LIT:1>]) != <NUM_LIT:4> orlen (pieces[<NUM_LIT:2>]) != <NUM_LIT:4> orlen (pieces[<NUM_LIT:3>]) != <NUM_LIT:4> orlen (pieces[<NUM_LIT:4>]) != <NUM_LIT:12>:<EOL><INDENT>return False<EOL><DEDENT>[ int (p, <NUM_LIT:16>) for p in pieces ]<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>except ValueError: <EOL><INDENT>return False<EOL><DEDENT>except TypeError:<EOL><INDENT>return False<EOL><DEDENT>return True<EOL>
is_valid_uuid (uuid) -> bool

returns True if uuid is a valid 128-bit UUID.

valid UUIDs are always strings taking one of the following forms:
    XXXX
    XXXXXXXX
    XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
where each X is a hexadecimal digit (case insensitive)