def _load_custom_ideas(): result = {} for fn in iglob(join(common_path, "custom_ideas/*.txt")): data = None category = None with open(fn, "r") as f: data = nom(f.read()) data = data.itervalues().next() for idea_name, values in data.iteritems(): effect_name = None if idea_name == "category": category = values continue assert category for k, v in values.iteritems(): if effect_name is None: effect_name = k result[effect_name] = { "category": category, "magnitude": Decimal(v), "max_level": DEFAULT_MAX_LEVEL, } continue if k.startswith("level_cost_"): result[effect_name][int(k[-1])] = int(v) continue if k == "max_level": result[effect_name]["max_level"] = int(v) return result
def _load(fn): if fn.endswith('.bmp'): return Image.open(join(map_path, fn), 'r') data = None with open(join(map_path, fn), 'r') as f: data = f.read() return nom(data)
def _load_countries(): countries = {} for fn in iglob(join(history_path, 'countries/*.txt')): data = None with open(fn, 'r') as f: data = nom(f.read()) tag = basename(fn.split('-')[0].strip().lower()) countries[tag] = data return countries
def _load_provinces(): provinces = {} for fn in iglob(join(history_path, 'provinces/*.txt')): data = None with open(fn, 'r') as f: data = nom(f.read()) if 'owner' in data.keys(): data['owner'] = data['owner'].lower() fn = split(fn)[1] province_id = int(basename(fn.split('-')[0].strip().split(' ')[0].strip())) provinces[province_id] = data return provinces
def _load_national_ideas(): result = OrderedDict() for fn in iglob(join(common_path, "ideas/*.txt")): if fn.endswith("basic_ideas.txt"): continue data = None with open(fn, "r") as f: data = nom(f.read()) for k, v in data.iteritems(): key = k[: k.find("_")].lower() ideas = _process_national_ideas(v) result[key] = ideas return result
def _load(*args): with open(join(common_path, *args), 'r') as f: return nom(f.read())