本文整理匯總了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()