def handle_import_tags(userdata, import_root):
        """Handle @import(filepath)@ tags in a UserData script.

        :param import_root: Location for imports.
        :type import_root: str
        :param userdata: UserData script content.
        :type userdata: str
        :return: UserData script with the contents of the imported files.
        :rtype: str
        """
        imports = re.findall('@import\((.*?)\)@', userdata)  # pylint: disable=anomalous-backslash-in-string
        if not imports:
            return userdata

        for filepath in imports:
            logger.info('Processing "import" of %s', filepath)
            import_path = os.path.join(import_root, filepath)
            try:
                with open(import_path) as fo:
                    content = fo.read()
                    userdata = userdata.replace('@import(%s)@' % filepath, content)
            except FileNotFoundError:
                raise UserDataException('Import path {} not found.'.format(import_path))

        return userdata