Generate list of obligatory and optional course of specific Dept.
355830
def CourseOfTime(request):
	
	day = request.GET['day']
	time = request.GET['time']
	school = request.GET['school']
	dept = request.GET['dept'].split()
	c = Course(school=school)
	return JsonResponse(c.getByTime(day=day, time=time, deptArr=dept), safe=False)
1320081
def course_feature(catalog, soup):
    
    courses = {}
    course_crns = {}
    for course in soup.findAll('course'):
        c = Course.from_soup_tag(course)
        courses[str(c)] = c
    catalog.courses = courses
    catalog.courses
    logger.info('Catalog has %d courses' % len(courses))
85376
def parse_requirements(path):
    """"""
    requirements = []
    with open(path, "rt") as reqs_f:
        for line in reqs_f:
            line = line.strip()
            if line.startswith("-r"):
                fname = line.split()[1]
                inner_path = os.path.join(os.path.dirname(path), fname)
                requirements += parse_requirements(inner_path)
            elif line != "" and not line.startswith("#"):
                requirements.append(line)
    return requirements
775838
def filter_curriculum(curriculum, week, weekday=None):
    
    if weekday:
        c = [deepcopy(curriculum[weekday - 1])]
    else:
        c = deepcopy(curriculum)
    for d in c:
        l = len(d)
        for t_idx in range(l):
            t = d[t_idx]
            if t is None:
                continue
            # 一般同一时间课程不会重复，重复时给出警告
            t = list(filter(lambda k: week in k['上课周数'], t)) or None
            if t is not None and len(t) > 1:
                logger.warning('第 %d 周周 %d 第 %d 节课有冲突: %s', week, weekday or c.index(d) + 1, t_idx + 1, t)
            d[t_idx] = t
    return c[0] if weekday else c
287669
def generate_docs(klass):
    """"""
    import numina.types.datatype

    attrh = ('Attributes\n'
             '----------\n')

    doc = getattr(klass, '__doc__', None)

    if doc is None or doc == '':
        doc = "%s documentation." % klass.__name__

    if len(klass.stored()):
        doc = doc + '\n\n' + attrh

    skeys = sorted(klass.stored().keys())
    for key in skeys:
        y = klass.stored()[key]

        if isinstance(y, Requirement):
            modo = 'requirement'
        elif isinstance(y, Result):
            modo = 'product'
        else:
            modo = ""
        if y.type.isproduct():
            tipo = y.type.__class__.__name__
        elif isinstance(y.type, numina.types.datatype.PlainPythonType):
            tipo = y.type.internal_type.__name__
        else:
            tipo = y.type.__class__.__name__

        if y.optional:
            if y.default_value():
                modo = "%s, optional, default=%s" % (modo, y.default)
            else:
                modo = "%s, optional" % (modo,)

        descript = y.description
        if descript:
            field = "%s : %s, %s\n %s\n" % (key, tipo, modo, descript)
        else:
            field = "%s : %s, %s\n" % (key, tipo, modo)
        doc = doc + field

    klass.__doc__ = doc
    return klass
1042503
def selection_dialog(self, courses):
        
        selected = list(filter(lambda x: x.course.id in self._settings["selected_courses"], courses))
        selection = Picker(
            title="Select courses to download",
            options=courses,
            checked=selected).getSelected()
        if selection:
            self._settings["selected_courses"] = list(map(lambda x: x.course.id, selection))
            self.save()
            log.info("Updated course selection")
1029565
def build_class_list(level, from, section, infile=nil)
      res = ""
      prefix = "&nbsp;&nbsp;::" * level;

      from.modules.sort.each do |mod|
        next unless mod.section == section
        next if infile && !mod.defined_in?(infile)
        if mod.document_self
          res << 
            prefix <<
            "Module " <<
            href(url(mod.viewer.path), "link", mod.full_name) <<
            "<br />\n" <<
            build_class_list(level + 1, mod, section, infile)
        end
      end

      from.classes.sort.each do |cls|
        next unless cls.section == section
        next if infile && !cls.defined_in?(infile)
        if cls.document_self
          res      <<
            prefix << 
            "Class " <<
            href(url(cls.viewer.path), "link", cls.full_name) <<
            "<br />\n" <<
            build_class_list(level + 1, cls, section, infile)
        end
      end

      res
    end
460856
def get_all_tasks(self, course):
        
        tasks = self.get_readable_tasks(course)
        output = {}
        for task in tasks:
            try:
                output[task] = self.get_task(course, task)
            except:
                pass
        return output
834428
def to_help(self):
        
        result = []
        result.append(self.classname)
        result.append("=" * len(self.classname))
        result.append("")
        result.append("DESCRIPTION")
        result.append("")
        result.append(self.global_info())
        result.append("")
        result.append("OPTIONS")
        result.append("")
        options = javabridge.call(self.jobject, "listOptions", "()Ljava/util/Enumeration;")
        enum = javabridge.get_enumeration_wrapper(options)
        while enum.hasMoreElements():
            opt = Option(enum.nextElement())
            result.append(opt.synopsis)
            result.append(opt.description)
            result.append("")
        return '\n'.join(result)
1365969
def generate_help(self):
        
        result = []
        result.append(self.__class__.__name__)
        result.append(re.sub(r'.', '=', self.__class__.__name__))
        result.append("")
        result.append("DESCRIPTION")
        result.append(self.description())
        result.append("")
        result.append("OPTIONS")
        opts = sorted(self.config.keys())
        for opt in opts:
            result.append(opt)
            helpstr = self.help[opt]
            if helpstr is None:
                helpstr = "-missing help-"
            result.append("\t" + helpstr)
            result.append("")
        return '\n'.join(result)
898013
def directory_name_with_course(self):
        '''   '''
        coursename = self.course.directory_name()
        assignmentname = self.title.replace(" ", "_").replace("\\", "_").replace(",","").lower()
        return coursename + os.sep + assignmentname
344065
def get_requirements():
    """"""

    with open("requirements/project.txt") as f:
        requirements = []
        for line in f.readlines():
            line = line.strip()
            if line and not line.startswith('#'):
                requirements.append(line)
    return requirements
13779
def get_requirements(*args):
    """"""
    requirements = set()
    contents = get_contents(*args)
    for line in contents.splitlines():
        # Strip comments.
        line = re.sub(r'^#.*|\s#.*', '', line)
        # Ignore empty lines
        if line and not line.isspace():
            requirements.add(re.sub(r'\s+', '', line))
    return sorted(requirements)
148572
def list_assignment_submissions_courses(self, course_id, assignment_id, grouped=None, include=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """ID"""
        path["course_id"] = course_id

        # REQUIRED - PATH - assignment_id
        """ID"""
        path["assignment_id"] = assignment_id

        # OPTIONAL - include
        """Associations to include with the group.  "group" will add group_id and group_name."""
        if include is not None:
            self._validate_enum(include, ["submission_history", "submission_comments", "rubric_assessment", "assignment", "visibility", "course", "user", "group"])
            params["include"] = include

        # OPTIONAL - grouped
        """If this argument is true, the response will be grouped by student groups."""
        if grouped is not None:
            params["grouped"] = grouped

        self.logger.debug("GET /api/v1/courses/{course_id}/assignments/{assignment_id}/submissions with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/courses/{course_id}/assignments/{assignment_id}/submissions".format(**path), data=data, params=params, all_pages=True)
42739
def _defaultDepsVoc(self):
        
        # Getting the assigned departments
        deps = self.getDepartments()
        items = []
        for d in deps:
            items.append((api.get_uid(d), api.get_title(d)))
        return api.to_display_list(items, sort_by="value", allow_empty=True)
738158
def filter(self, criteria):
        
        if isinstance(criteria, str) or isinstance(criteria, unicode):
            _criteria = criteria
            criteria = lambda x: x.get(_criteria)

        return CoursesList(filter(criteria, self))
1327097
def get_section_list_name(section):
    
    return get_course_list_name(section.curriculum_abbr,
                                section.course_number,
                                section.section_id,
                                section.term.quarter,
                                section.term.year)