當前位置: 首頁>>代碼示例>>Python>>正文


Python Project.add方法代碼示例

本文整理匯總了Python中models.Project.add方法的典型用法代碼示例。如果您正苦於以下問題:Python Project.add方法的具體用法?Python Project.add怎麽用?Python Project.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Project的用法示例。


在下文中一共展示了Project.add方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: construct_Single_Project

# 需要導入模塊: from models import Project [as 別名]
# 或者: from models.Project import add [as 別名]
    def construct_Single_Project(self):
        """
        This method constucts a Project with one of each
        of the objects from the hierarchy and returns it.
        """ 
        project = Project("PojectTestName", "ProjectTestDescription")
        groupone = BudgetGroup("BGTestName", "BGTestDescription")
        itemone = BudgetItem("BITestName", "BITestDescription", 2, 5)

        groupone.add(itemone)              
        project.add(groupone)

        return project
開發者ID:nvernooy,項目名稱:CostEstimate,代碼行數:15,代碼來源:tests.py

示例2: construct_Multiple_Project

# 需要導入模塊: from models import Project [as 別名]
# 或者: from models.Project import add [as 別名]
    def construct_Multiple_Project(self):
        """
        This method constucts a Project with two of each
        of the objects from the hierarchy and returns it.
        """ 
        project = Project("PojectTestName", "ProjectTestDescription")
        groupone = BudgetGroup("BGTestName", "BGTestDescription")
        grouptwo = BudgetGroup("BGTestNameTwo", "BG Test Description Two")
        itemone = BudgetItem("BITestName", "BITestDescription", 2, 5)
        itemtwo = BudgetItem("BITestNameTwo", "BI Test Description Two", 10, 3)
        itemthree = BudgetItem("BITestNameThree", "BI Test Description Three", 5, 4)
        itemfour = BudgetItem("BITestNameFour", "BI Test Description Four", 2, 5)
                        
        groupone.add(itemone)
        groupone.add(itemtwo)
        grouptwo.add(itemthree)
        grouptwo.add(itemfour)
                        
        project.add(groupone)
        project.add(grouptwo)

        return project
開發者ID:nvernooy,項目名稱:CostEstimate,代碼行數:24,代碼來源:tests.py

示例3: addData

# 需要導入模塊: from models import Project [as 別名]
# 或者: from models.Project import add [as 別名]
def addData():
    # Enter data for constructing the objects.
    name = raw_input("\nEnter Project Name:\n")
    desc = raw_input("\nEnter Project Description:\n")

    # Instantiate a Project
    project = Project(name, desc)

    # Loop while adding groups and items
    while True:
        # The user has to enter "0" to stop the loop
        if "0" == raw_input ("\nEnter 0 to stop adding BudgetGroups: "):
                break
        
        name = raw_input("\nEnter BudgetGroup Name:\n")
        desc = raw_input("\nEnter BudgetGroup Description:\n")

        # Instantiate a BudgetGroup object
        group = BudgetGroup(name, desc)

        # Loop and add multiple Items
        while True:
            # The user has to enter "0" to stop the loop
            if "0" == raw_input ("\nEnter 0 to stop adding BudgetItems: "):
                break
            
            name = raw_input("\nEnter BudgetItem Name:\n")
            desc = raw_input("\nEnter BudgetItem Description:\n")
            
            # Ensure quantities are not negative or letters.
            # If the input is letters catch the error and set quantity to
            # -1 so it goes into the loop.
            try:
                quan = int(raw_input("\nEnter BudgetItem Quantity:\n") )
            except ValueError:
                quan = -1             
            while quan < 0:
                try:
                    quan = int(raw_input("\nQuantity can't be negative or letters. "+
                                     "Enter BudgetItem Quantity:\n"))
                except ValueError:
                    quan = -1
                    
            # Ensure rates are not negative.
            # If the input is letters catch the error and set rate to
            # -1 so it goes into the loop.
            try:
                rate = int(raw_input("\nEnter BudgetItem Rate:\n"))
            except ValueError:
                rate = -1
            while rate < 0:
                try:
                    rate = int(raw_input("\nRate can't be negative or letters. "+
                                     "Enter BudgetItem Rate:\n"))
                except ValueError:
                    rate = -1

            # Instantiate a BudgetItem.
            item = BudgetItem (name, desc, quan, rate)
            group.add(item)
            
        project.add(group)
        

    # Return the Project will all the objects in it
    return project
開發者ID:nvernooy,項目名稱:CostEstimate,代碼行數:68,代碼來源:Runner.py


注:本文中的models.Project.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。