def generate_module(src):
 if (not src):
  return UNKNOWN_MODULE
 (filename, ext) = splitext(urlsplit(src).path)
 if (ext not in ('.js', '.jsx', '.coffee')):
  return UNKNOWN_MODULE
 if filename.endswith('.min'):
  filename = filename[:(-4)]
 tokens = filename.split('/')
 for (idx, token) in enumerate(tokens):
  if VERSION_RE.match(token):
   return '/'.join(tokens[(idx + 1):])
 return (CLEAN_MODULE_RE.sub('', filename) or UNKNOWN_MODULE)

def generate_module ( src ) : if ( not src ) : return UNKNOWN_MODULE ( filename , ext ) = splitext ( urlsplit ( src ) . path ) if ( ext not in ( '.js' , '.jsx' , '.coffee' ) ) : return UNKNOWN_MODULE if filename . endswith ( '.min' ) : filename = filename [ : ( - 4 ) ] tokens = filename . split ( '/' ) for ( idx , token ) in enumerate ( tokens ) : if VERSION_RE . match ( token ) : return '/' . join ( tokens [ ( idx + 1 ) : ] ) return ( CLEAN_MODULE_RE . sub ( '' , filename ) or UNKNOWN_MODULE )
converts a url into a made-up module name by doing the following: * extract just the path name ignoring querystrings * trimming off the initial / * trimming off the file extension * removes off useless folder prefixes e .