# Path: src/rosrepo/util.py
# def makedirs(path):
#     if not os.path.isdir(path):
#         os.makedirs(path)


import re
import os
from .util import makedirs
def update_default_git_ignore():
    config_home = os.environ.get("XDG_CONFIG_HOME", os.path.join(os.path.expanduser("~"), ".config"))
    gitconfig_dir = os.path.join(config_home, "git")
    gitignore_file = os.path.join(gitconfig_dir, "ignore")
    gitignore = set()
    try:
        with open(gitignore_file, "r") as f:
            gitignore = set([e for e in f.read().split("\n") if e])
    except IOError:
        pass
    if not DEFAULT_GIT_IGNORE.issubset(gitignore):
        gitignore |= set(DEFAULT_GIT_IGNORE)
        try:
            makedirs(gitconfig_dir)
            with open(gitignore_file, "w") as f:
                f.write("\n".join(sorted(list(gitignore))))
        except (OSError, IOError):
            pass


def get_c_compiler(s):
    global COMPILER_LIST
    for compiler in COMPILER_LIST:
        m = re.match(r"^(.*)\b(?:%s)\b(.*)$" % compiler[0], s, re.IGNORECASE)
        if m is not None:
            return "%s%s%s" % (m.group(1), compiler[1], m.group(2))
    return None


def get_cxx_compiler(s):

# Path: src/rosrepo/util.py
# def makedirs(path):
#     if not os.path.isdir(path):
#         os.makedirs(path)


# Path: src/rosrepo/common.py
import re
import os
from .util import makedirs

def update_default_git_ignore():
    config_home = os.environ.get("XDG_CONFIG_HOME", os.path.join(os.path.expanduser("~"), ".config"))
    gitconfig_dir = os.path.join(config_home, "git")
    gitignore_file = os.path.join(gitconfig_dir, "ignore")
    gitignore = set()
    try:
        with open(gitignore_file, "r") as f:
            gitignore = set([e for e in f.read().split("\n") if e])
    except IOError:
        pass
    if not DEFAULT_GIT_IGNORE.issubset(gitignore):
        gitignore |= set(DEFAULT_GIT_IGNORE)
        try:
            makedirs(gitconfig_dir)
            with open(gitignore_file, "w") as f:
                f.write("\n".join(sorted(list(gitignore))))
        except (OSError, IOError):
            pass


def get_c_compiler(s):
    global COMPILER_LIST
    for compiler in COMPILER_LIST:
        m = re.match(r"^(.*)\b(?:%s)\b(.*)$" % compiler[0], s, re.IGNORECASE)
        if m is not None:
            return "%s%s%s" % (m.group(1), compiler[1], m.group(2))
    return None


def get_cxx_compiler(s):

    global COMPILER_LIST