<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _build_template_map(cookbook, cookbook_name, stencil):
 """Build a map of variables for this generated cookbook and stencil. Get template variables from stencil option values, adding the default ones like cookbook and cookbook year. """

    template_map = {
        'cookbook': {"name": cookbook_name},
        'options': stencil['options']
    }

    # Cookbooks may not yet have metadata, so we pass an empty dict if so
    try:
        template_map['cookbook'] = cookbook.metadata.to_dict().copy()
    except ValueError:
        # ValueError may be returned if this cookbook does not yet have any
        # metadata.rb written by a stencil. This is okay, as everyone should
        # be using the base stencil first, and then we'll try to call
        # cookbook.metadata again in this method later down.
        pass

    template_map['cookbook']['year'] = datetime.datetime.now().year
    return template_map