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


Python Course.put方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Course [as 别名]
# 或者: from models.Course import put [as 别名]
    def get(self):
        from models import *

        from google.appengine.ext import db
        db.delete(Course.all())
        db.delete(Offerings.all())

        import re
        rx_department = re.compile(r'[A-Z]+')
        import csv
        reader = csv.DictReader(open('resources/dump.csv'))
        try:
            for course in reader:
                name = course['name']
                number = course['number']
                description = course['description'][:500]
                match = rx_department.match(number)
                department = number
                if match:
                    department = match.group(0)
                entry = Course(name=name, number=number, description=description, department=department)
                entry.put()

                for item in ['winter', 'spring', 'fall', 'summer']:
                    if 1 < len(course[item]):
                        offering = Offerings(course=entry, offered=item)
                        offering.put()
        except KeyError, e:
            pass
开发者ID:sampwing,项目名称:cmpe231_project,代码行数:31,代码来源:main.py

示例2: insert_course

# 需要导入模块: from models import Course [as 别名]
# 或者: from models.Course import put [as 别名]
def insert_course(dept, num, text):
    """ Regexes for extracting class properties; results go into capture group 1 """

    # Course Title  
    m = re.search("[\d\w]{5} - ([\w ]*)", text)
    title = m.group(1) if m else "nomatch"

    # Course Description
    m = re.search("\.\s(.*)\sTypically",text)
    des = m.group(1) if m else "nomatch"

    # Credit hours aren't fixed for every course
    # Credit Hours: 2.00
    # Credit Hours: 2.00 or 3.00. 
    # Credit Hours: 1.00 to 18.00. 
    m = re.search("Credit Hours: (\d+\.\d+)",text, flags=re.IGNORECASE)
    m = re.search("(\d+\.\d+)(.*?)Credit hours",text, flags=re.IGNORECASE) if not m else m
    cr = m.group(1) if m else "-1"

    # Semesters Offered
    m = re.search("Typically offered (.*?)\.", text)
    sem = m.group(1).split() if m else ["nomatch"]

    # Course Type: Lecture, Recitation, Lab, Seminar, etc.
    m = re.search("Schedule Types:\s((?:[\w ]+)(?:,[\w ]+)*) \s+", text)
    form = m.group(1).split(", ") if m else ["nomatch"]

    # Learning objectives will not necessarily follow campuses
    m = re.search("campuses:(\s+([\w\s])+\n)", text)
    campus = m.group(1).strip().split("\n\n") if m else ["nomatch"]
    campus = [camp.strip() for camp in campus]

    # prereq regex and decomosition of prereqs into lists of AND conditions (works for most classes, not 477 and similar)
    # re.DOTALL matches all characters, including "\n"
    idx = text.find("campuses:")
    m = re.search("Prerequisites:(.*)",text[idx:],flags=re.DOTALL)
    if m:
        allReqs = []
        prereqText = m.group(1).strip()
        prereqText =  prereqText.encode('ascii', 'ignore') 
        for i in PrereqParser.parseprereq(prereqText):
            reqArr = []
            for j in i.split():
                if j.find("-C") != -1:
                    j = j.replace("-C","")
                    reqArr.append(Requisite(course=j,reqType=False))
                else:
                    reqArr.append(Requisite(course=j,reqType=True))                    
            allReqs.append(RequisiteList(courses=reqArr))

    else:
        allReqs = []

    # create course entity
    course = Course(number=num, title=title, department=dept, form=form,
                     description=des, credits=float(cr), semesters=sem,
                     campuses=campus,requisites=allReqs, id=dept + num)
    # store course 
    course.put()
开发者ID:joey9z,项目名称:368_Project,代码行数:61,代码来源:main.py

示例3: get

# 需要导入模块: from models import Course [as 别名]
# 或者: from models.Course import put [as 别名]
    def get(self):
        #add initial universities
        inst = Inst.all().fetch(50)
        if len(inst)==0:
            new_inst = Inst()
            new_inst.name = 'Other'
            new_inst.put()
            
            #add also introductory course
            courses = ['Electrical Engineering','Mechanical Engineering','Civil Engineering','Software Engineering','Geospatial Engineering','Business Courses','Accounts','Commerce',
'Economics','Pure Mathematics','Statistics','Info Tech Courses','Computer Science','Computer Technology','Informatics','Computer Security & Forensics','Nursing',
'Medical Laboratory','Biochemestry','Biotechnology','Microbiology','Applied Physics','Industrial Chemistry','Analytical Chemistry','Astronomy & Astrophysics',
'Applied Chemistry','Sociology','Journalism','Counselling Psychology','Forestry','Physical Education']
            for c in courses:
                course = Course()
                course.course = c
                course.put()
        self.redirect('/home')
开发者ID:BeyondeLabs,项目名称:quizer,代码行数:20,代码来源:script.py


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