本文整理汇总了Python中Core.maps.Ship.total_cost方法的典型用法代码示例。如果您正苦于以下问题:Python Ship.total_cost方法的具体用法?Python Ship.total_cost怎么用?Python Ship.total_cost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core.maps.Ship
的用法示例。
在下文中一共展示了Ship.total_cost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Core.maps import Ship [as 别名]
# 或者: from Core.maps.Ship import total_cost [as 别名]
def main(url = Config.get("URL", "ships"), debug=False):
req = urllib2.Request(url)
req.add_header('User-Agent', useragent)
stats = urllib2.urlopen(req).read()
session.execute(Ship.__table__.delete())
if Config.get("DB", "dbms") == "mysql":
session.execute(text("ALTER TABLE ships AUTO_INCREMENT=1;", bindparams=[false]))
else:
session.execute(text("SELECT setval('ships_id_seq', 1, :false);", bindparams=[false]))
for line in sre.findall(stats):
ship = Ship()
line = list(line)
for index, key in enumerate(keys):
if line[index] in mapping:
line[index] = mapping[line[index]]
elif line[index].isdigit():
line[index] = int(line[index])
if line[index] not in ('-', '',):
setattr(ship,key,line[index])
ship.total_cost = ship.metal + ship.crystal + ship.eonium
if debug: print "%12s%12s%12s%12s" % (ship.name, ship.class_, ship.race, ship.type,)
session.add(ship)
session.commit()
session.close()
示例2: main
# 需要导入模块: from Core.maps import Ship [as 别名]
# 或者: from Core.maps.Ship import total_cost [as 别名]
def main(url = Config.get("URL", "ships"), debug=False):
stats = urllib2.urlopen(url).read()
session.execute(Ship.__table__.delete())
session.execute(text("SELECT setval('ships_id_seq', 1, :false);", bindparams=[false]))
for line in sre.findall(stats):
ship = Ship()
line = list(line)
for index, key in enumerate(keys):
if line[index] in mapping:
line[index] = mapping[line[index]]
elif line[index].isdigit():
line[index] = int(line[index])
if line[index] not in ('-', '',):
setattr(ship,key,line[index])
ship.total_cost = ship.metal + ship.crystal + ship.eonium
if debug: print "%12s%12s%12s%12s" % (ship.name, ship.class_, ship.race, ship.type,)
session.add(ship)
session.commit()
session.close()