<gh_stars>1-10
import os

class BaseCIAdapter():

    def __init__(self, logger=None):
        self.logger = logger
        self.pop_env = True
        self.env_map = {}

    def convert_environment_variables(self):
        for key, value in os.environ.items():
            if key in self.env_map and not self.env_map[key] in os.environ:
                os.environ[self.env_map[key]] = value

                if self.pop_env:
                    os.environ.pop(key)

    def auto_gen_header(self):
        return """
/************************************************
 * DO NOT EDIT THIS FILE, CHANGES WILL BE LOST! *
 * See .servicer/services.yaml instead          *
 * CI Configuration Generated by Servicer       *
 * https://github.com/wmgroot/servicer          *
 ************************************************/
"""

    def write_file(self, path, text):
        file_text = auto_gen_header()
        file_text += text

        with open(path, "w") as text_file:
            text_file.write(file_text)

        self.logger.log('CI config file generated: %s' % path)
