def export_course_to_directory(course_key, root_dir):
 store = modulestore()
 course = store.get_course(course_key)
 if (course is None):
  raise CommandError('Invalid course_id')
 replacement_char = u'-'
 course_dir = replacement_char.join([course.id.org, course.id.course, course.id.run])
 course_dir = re.sub('[^\\w\\.\\-]', replacement_char, course_dir)
 export_course_to_xml(store, None, course.id, root_dir, course_dir)
 export_dir = (path(root_dir) / course_dir)
 return export_dir

def export_course_to_directory ( course_key , root_dir ) : store = modulestore ( ) course = store . get_course ( course_key ) if ( course is None ) : raise CommandError ( 'Invalid course_id' ) replacement_char = u'-' course_dir = replacement_char . join ( [ course . id . org , course . id . course , course . id . run ] ) course_dir = re . sub ( '[^\\w\\.\\-]' , replacement_char , course_dir ) export_course_to_xml ( store , None , course . id , root_dir , course_dir ) export_dir = ( path ( root_dir ) / course_dir ) return export_dir
export course into a directory .