本文整理汇总了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
示例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
示例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