예제 #1
0
def convert(load_path, save_path, functions):
    """
    Converts research.ini resultFunctions to results
    """
    cp = WZConfigParser()
    cp.load(load_path)

    for section in cp._sections:
        if cp.has_option(section, 'resultFunctions'):
            functs = cp.get(section, 'resultFunctions')
            res = set()
            for funct in functs.split(','):
                f = functions[funct]
                if f is None:
                    print "Missed function!!!!!!", funct
                else:
                    res.add(f)
                    cp.remove_option(section, 'resultFunctions')

            res = ','.join(res)
            res = ['"%s"' % r.strip() for r in res.split(',')]
            res = ', '.join(res)
            cp.set(section, 'results', res)

    with open(save_path, 'w') as f:
        cp.save(f)
    def __init__(self):
        for domain in self.mods:
            weapons = WZConfigParser()
            weapons.load(domain.get_load_path('weapons.ini'))
            weaponsounds = WZConfigParser()
            weaponsounds.load(domain.get_load_path('weaponsounds.ini'))

            for section in weaponsounds.sections():
                if weapons.has_section(section):
                    szWeaponWav = weaponsounds.get(section, 'szWeaponWav')
                    szExplosionWav = weaponsounds.get(section, 'szExplosionWav')
                    if szWeaponWav != '-1':
                        weapons.set(section, 'weaponWav', szWeaponWav)
                    if szExplosionWav != '-1':
                        weapons.set(section, 'explosionWav', szExplosionWav)
            with open(domain.get_save_path(self.output), 'w') as output:
                weapons.save(output)