# -*- coding: utf-8 -*-
import random
import yaml
try:
    from yaml import CLoader as Loader
except ImportError:
    from yaml import Loader
from address import Address
from name import Name


MALE = 'male'
FEMALE = 'female'
GENDER = (MALE, FEMALE)


def yaml_load(file_path, mode='r'):
    import os
    file_dir = os.path.abspath(os.path.join(os.path.dirname(__file__)))
    try:
        f = open(file_dir + '/' + file_path, mode)
    except IOError:
        raise Exception("Can not open {}".format(file_dir + '/' + file_path))
    return yaml.load(f, Loader=Loader)


class Gimei(object):
    NAMES = yaml_load('./data/names.yml')
    ADDRESSES = yaml_load('./data/addresses.yml')

    def __init__(self, gender=None):
        if gender is None:
            gender = random.choice(GENDER)
        self.gender = gender

    @property
    def name(self):
        return Name(self.gender)

    @property
    def address(self):
        return Address()

@@ -163,16 +163,44 @@
 Address%0A
+from functools import wraps%0A
 from nam
@@ -273,16 +273,278 @@
 MALE)%0A%0A%0A
+def cache(f):%0A    saved = %7B%7D%0A%0A    @wraps(f)%0A    def wrapper(file_path):%0A        if file_path in saved:%0A            return saved%5Bfile_path%5D%0A        result = f(file_path, mode='r')%0A        saved%5Bfile_path%5D = result%0A        return result%0A    return wrapper%0A%0A@cache%0A
 def yaml

Use cache.