當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。