def _write_js(output_root, classes):
 contents = {}
 js_fragments = set()
 for class_ in classes:
  module_js = class_.get_javascript()
  js_fragments.add((0, 'js', module_js.get('xmodule_js')))
  for filetype in ('coffee', 'js'):
   for (idx, fragment) in enumerate(module_js.get(filetype, [])):
    js_fragments.add(((idx + 1), filetype, fragment))
 for (idx, filetype, fragment) in sorted(js_fragments):
  filename = '{idx:0=3d}-{hash}.{type}'.format(idx=idx, hash=hashlib.md5(fragment).hexdigest(), type=filetype)
  contents[filename] = fragment
 _write_files(output_root, contents, {'.coffee': '.js'})
 return [(output_root / filename) for filename in contents.keys()]

def _write_js ( output_root , classes ) : contents = { } js_fragments = set ( ) for class_ in classes : module_js = class_ . get_javascript ( ) js_fragments . add ( ( 0 , 'js' , module_js . get ( 'xmodule_js' ) ) ) for filetype in ( 'coffee' , 'js' ) : for ( idx , fragment ) in enumerate ( module_js . get ( filetype , [ ] ) ) : js_fragments . add ( ( ( idx + 1 ) , filetype , fragment ) ) for ( idx , filetype , fragment ) in sorted ( js_fragments ) : filename = '{idx:0=3d}-{hash}.{type}' . format ( idx = idx , hash = hashlib . md5 ( fragment ) . hexdigest ( ) , type = filetype ) contents [ filename ] = fragment _write_files ( output_root , contents , { '.coffee' : '.js' } ) return [ ( output_root / filename ) for filename in contents . keys ( ) ]
write the javascript fragments from all xmodules in classes into output_root as individual files .