当前位置: 首页>>代码示例>>Python>>正文


Python Semester.start_end_dates方法代码示例

本文整理汇总了Python中coredata.models.Semester.start_end_dates方法的典型用法代码示例。如果您正苦于以下问题:Python Semester.start_end_dates方法的具体用法?Python Semester.start_end_dates怎么用?Python Semester.start_end_dates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在coredata.models.Semester的用法示例。


在下文中一共展示了Semester.start_end_dates方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _build_semester_lookup

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import start_end_dates [as 别名]
def _build_semester_lookup():
    """
    Build data structure to let us easily look up date -> strm.
    """
    all_semesters = Semester.objects.all()
    intervals = ((s.name, Semester.start_end_dates(s)) for s in all_semesters)
    intervals = (
        intervaltree.Interval(st, en+ONE_DAY, name)
        for (name, (st, en)) in intervals)
    return intervaltree.IntervalTree(intervals)
开发者ID:sfu-fas,项目名称:coursys,代码行数:12,代码来源:tools.py

示例2: units

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import start_end_dates [as 别名]
from django.conf import settings

# import grads from these units (but CMPT gets special treatment)
IMPORT_UNIT_SLUGS = ['cmpt', 'ensc', 'mse', 'psyc']

# in ps_acad_prog dates within about this long of the semester start are actually things that happen next semester
DATE_OFFSET = datetime.timedelta(days=30)
# ...even longer for dates of things that are startup-biased (like returning from leave)
DATE_OFFSET_START = datetime.timedelta(days=90)

SIMS_SOURCE = 'sims_source' # key in object.config to record where things came from

# don't even query data before this
if settings.DEPLOY_MODE in ['devel', 'proddev']:
    IMPORT_START_SEMESTER = Semester.current().offset_name(-6)  # devel/test data doesn't go too far back in time
else:
    IMPORT_START_SEMESTER = '0901'

IMPORT_START_DATE = Semester.start_end_dates(Semester.objects.get(name=IMPORT_START_SEMESTER))[0]

# if we find students starting before this semester, don't import
if settings.DEPLOY_MODE in ['devel', 'proddev']:
    RELEVANT_PROGRAM_START = Semester.current().offset_name(-6)  # devel/test data doesn't go too far back in time
else:
    RELEVANT_PROGRAM_START = '1031'

# before this, we aren't going to worry about it.
RELEVANT_DATA_START = datetime.date(1993, 9, 1)

# be even more conservative for CMPT: this is when we started getting slightly cleaner data including adm_appl_nbr
CMPT_CUTOFF = '1137'
开发者ID:sfu-fas,项目名称:coursys,代码行数:33,代码来源:parameters.py

示例3: import_semester_info

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import start_end_dates [as 别名]

#.........这里部分代码省略.........
    semester_weeks = dict((k,list(v)) for k,v in semester_weeks)

    holidays = itertools.groupby(
                Holiday.objects.filter(semester__name__in=strms, holiday_type='FULL').select_related('semester'),
                lambda h: h.semester.name)
    holidays = dict((k,list(v)) for k,v in holidays)

    for strm in strms:
        url = settings.BASE_ABS_URL + reverse('sysadmin:edit_semester', kwargs={'semester_name': strm})

        # Semester object
        try:
            semester = semesters[strm]
        except KeyError:
            semester = Semester(name=strm)
            semesters[strm] = semester
            output.append("Creating %s." % (strm,))

        # class start and end dates
        try:
            start = semester_start[strm]
        except KeyError:
            # No data found about this semester: if there's a date already around, honour it
            # Otherwise, guess "same day as this semester last year" which is probably wrong but close.
            start = semester.start
            if not semester.start:
                lastyr = semesters[semester.offset_name(-3)]
                start = lastyr.start.replace(year=lastyr.start.year+1)
                output.append("Guessing start date for %s." % (strm,))

        try:
            end = semester_end[strm]
        except KeyError:
            # no classes scheduled yet? Assume 13 weeks exactly
            end = start + datetime.timedelta(days=91)

        if semester.start != start:
            output.append("Changing start date for %s from %s to %s." % (strm, semester.start, start))
            semester.start = start
        if semester.end != end:
            output.append("Changing end date for %s from %s to %s." % (strm, semester.end, end))
            semester.end = end

        if not dry_run:
            semester.save()

        # SemesterWeeks
        weeks = semester_weeks.get(strm, [])
        if not weeks:
            sw = SemesterWeek(semester=semester, week=1, monday=first_monday(start))
            weeks.append(sw)
            assert sw.monday.weekday() == 0
            output.append("Creating week 1 for %s on %s." % (strm, sw.monday))
            if not dry_run:
                sw.save()
        elif weeks[0].monday != first_monday(start):
            sw = weeks[0]
            sw.monday = first_monday(start)
            output.append("Changing first Monday of %s to %s." % (strm, sw.monday))
            if not dry_run:
                sw.save()

        length = semester.end - semester.start
        if not bootstrap and length > datetime.timedelta(days=92) and len(weeks) < 2 \
                and semester.start - datetime.date.today() < datetime.timedelta(days=365):
            # semester is longer than 13 weeks: insist that the user specify reading week reasonably-soon before the semester starts
            message = "Semester %s is long (%s) but has no reading week specified. Please have a look here: %s\n\nYou probably want to enter the Monday of week 5/6/7/8 as the Monday after reading week, a week later than it would otherwise be." % (strm, length, url)
            if verbose:
                output.append('*** ' + message)
            else:
                import_admin_email(source='coredata.importer.import_semester_info', message=message)
        elif not bootstrap:
            # also check that the last day of classes is at a coherent time. Might reveal problems with reading week specification.
            endweek,_ = semester.week_weekday(semester.end, weeks=weeks)
            if endweek not in [12, 13, 14]:
                message = "Semester %s ends in week %i (should be 13 or 14). That's weird. Have a look here to see if things are coherent: %s" % (strm, endweek, url)
                if verbose:
                    output.append('*** ' + message)
                else:
                    import_admin_email(source='coredata.importer.import_semester_info', message=message)

        # Holidays
        hs = holidays.get(strm, [])
        h_start, h_end = Semester.start_end_dates(semester)
        for dt, desc in [(d,h) for d,h in sims_holidays if h_start <= d <= h_end]:
            existing = [h for h in hs if h.date == dt]
            if existing:
                holiday = existing[0]
            else:
                holiday = Holiday(semester=semester, date=dt, holiday_type='FULL')
                output.append("Adding holiday %s on %s." % (desc, dt))

            holiday.description = desc
            if not dry_run:
                holiday.save()



    if verbose:
        print('\n'.join(output))
开发者ID:sfu-fas,项目名称:coursys,代码行数:104,代码来源:importer.py

示例4: start_end_dates

# 需要导入模块: from coredata.models import Semester [as 别名]
# 或者: from coredata.models.Semester import start_end_dates [as 别名]
 def start_end_dates(cls, semester):
     """
     First and last days of the semester, in the way that financial people do (without regard to class start/end dates)
     """
     return Semester.start_end_dates(semester)
开发者ID:avacariu,项目名称:coursys,代码行数:7,代码来源:models.py


注:本文中的coredata.models.Semester.start_end_dates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。