当前位置: 首页>>代码示例>>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;未经允许,请勿转载。