def create_groups():
 data_dir = settings.DATA_DIR
 print ('data_dir = %s' % data_dir)
 for course_dir in os.listdir(data_dir):
  if course_dir.startswith('.'):
   continue
  if (not os.path.isdir((path(data_dir) / course_dir))):
   continue
  cxfn = ((path(data_dir) / course_dir) / 'course.xml')
  try:
   coursexml = etree.parse(cxfn)
  except Exception:
   print ('Oops, cannot read %s, skipping' % cxfn)
   continue
  cxmlroot = coursexml.getroot()
  course = cxmlroot.get('course')
  if (course is None):
   print ("oops, can't get course id for %s" % course_dir)
   continue
  print ('course=%s for course_dir=%s' % (course, course_dir))
  create_group(('staff_%s' % course))
  create_group(('instructor_%s' % course))

def create_groups ( ) : data_dir = settings . DATA_DIR print ( 'data_dir = %s' % data_dir ) for course_dir in os . listdir ( data_dir ) : if course_dir . startswith ( '.' ) : continue if ( not os . path . isdir ( ( path ( data_dir ) / course_dir ) ) ) : continue cxfn = ( ( path ( data_dir ) / course_dir ) / 'course.xml' ) try : coursexml = etree . parse ( cxfn ) except Exception : print ( 'Oops, cannot read %s, skipping' % cxfn ) continue cxmlroot = coursexml . getroot ( ) course = cxmlroot . get ( 'course' ) if ( course is None ) : print ( "oops, can't get course id for %s" % course_dir ) continue print ( 'course=%s for course_dir=%s' % ( course , course_dir ) ) create_group ( ( 'staff_%s' % course ) ) create_group ( ( 'instructor_%s' % course ) )
create staff and instructor groups for all classes in the data_dir .