<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def yaml_load(source, defaultdata=NO_DEFAULT):
 """merge YAML data from files found in source Always returns a dict. The YAML files are expected to contain some kind of key:value structures, possibly deeply nested. When merging, lists are appended and dict keys are replaced. The YAML files are read with the yaml.safe_load function. source can be a file, a dir, a list/tuple of files or a string containing a glob expression (with ?*[]). For a directory, all *.yaml files will be read in alphabetical order. defaultdata can be used to initialize the data. """

    logger = logging.getLogger(__name__)
    logger.debug("initialized with source=%s, defaultdata=%s", source, defaultdata)
    if defaultdata is NO_DEFAULT:
        data = None
    else:
        data = defaultdata
    files = []
    if type(source) is not str and len(source) == 1:
        # when called from __main source is always a list, even if it contains only one item.
        # turn into a string if it contains only one item to support our different call modes
        source = source[0]
    if type(source) is list or type(source) is tuple:
        # got a list, assume to be files
        files = source
    elif os.path.isdir(source):
        # got a dir, read all *.yaml files
        files = sorted(glob.glob(os.path.join(source, "*.yaml")))
    elif os.path.isfile(source):
        # got a single file, turn it into list to use the same code
        files = [source]
    else:
        # try to use the source as a glob
        files = sorted(glob.glob(source))
    if files:
        logger.debug("Reading %s\n", ", ".join(files))
        for yaml_file in files:
            try:
                with open(yaml_file) as f:
                    new_data = safe_load(f)
                logger.debug("YAML LOAD: %s", new_data)
            except MarkedYAMLError as e:
                logger.error("YAML Error: %s", e)
                raise YamlReaderError("YAML Error: %s" % str(e))
            if new_data is not None:
                data = data_merge(data, new_data)
    else:
        if defaultdata is NO_DEFAULT:
            logger.error("No YAML data found in %s and no default data given", source)
            raise YamlReaderError("No YAML data found in %s" % source)

    return data