def main(fn, initial): output = initial.copy() items, qualities, attributes = \ items_game['items'], items_game['qualities'], items_game['attributes'] lang_data = parse(fn)['lang']['Tokens'] find_attr = partial(find_attribute, attributes) kwds = dict(find_attr=find_attr, lang_data=lang_data) trim = partial(trim_item, names=['positive', 'negative', 'alt', ]) handlers = [add_item_type, add_item_desc, add_item_alt, add_item_attrs, trim] for key, src in items.items(): output[key] = out = proto() for handler in handlers: handler(src, out, **kwds) return output
# -*- coding: utf-8 -*- """ """ import codecs import json import os import sys from functools import partial from subprocess import Popen, PIPE from source_text_parser import parse from tf_tran import google_translate sys.stdout = codecs.getwriter('utf8')(sys.stdout) items_game = parse('../src/rawtext/items_game.txt')['items_game'] extras_filename = '../src/rawtext/extras.json' en_lang = parse('../src/rawtext/tf_english.txt')['lang']['Tokens'] def proto(): return dict(description='', type='', alt=[], positive=[], negative=[]) known_subs = ( ('Flaregun', 'FlareGun'), ('TF_Weapon_Flamethrower', 'TF_Weapon_FlameThrower'), # "Flamethrower" used by achievement so it's not changed ) def fix_key(v):