def DeriveIDFromPath(path):
 invalid_chars = re.compile('[^a-zA-Z0-9]')
 components = path.split('/')
 return ('_' + '-'.join([invalid_chars.sub((lambda x: ('_%02X' % ord(x.group(0)))), x) for x in components if x]))

def DeriveIDFromPath ( path ) : invalid_chars = re . compile ( '[^a-zA-Z0-9]' ) components = path . split ( '/' ) return ( '_' + '-' . join ( [ invalid_chars . sub ( ( lambda x : ( '_%02X' % ord ( x . group ( 0 ) ) ) ) , x ) for x in components if x ] ) )
transforms path into something that can be used as a html dom id .