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


Python Ship.total_cost方法代碼示例

本文整理匯總了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()
開發者ID:TBBTNut,項目名稱:merlin,代碼行數:29,代碼來源:shipstats.py

示例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()
開發者ID:JDD,項目名稱:DLR,代碼行數:24,代碼來源:shipstats.py


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