Create and populate the ~/.config/rapport directory tree if it's not existing.

    Doesn't interfere with already existing directories or configuration files.

def init_user():
    """Create and populate the ~/.config/rapport directory tree if it's not existing.

    Doesn't interfere with already existing directories or configuration files.
    """
    if not os.path.exists(USER_CONFIG_DIR):
        if rapport.config.get_int("rapport", "verbosity") >= 1:
            print("Create user directory {0}".format(USER_CONFIG_DIR))
        os.makedirs(USER_CONFIG_DIR)
    for subdir in ["plugins", "reports", "templates/plugin", "templates/email", "templates/web"]:
        user_conf_subdir = os.path.join(USER_CONFIG_DIR, subdir)
        if not os.path.exists(user_conf_subdir):
            if rapport.config.get_int("rapport", "verbosity") >= 1:
                print("Create user directory {0}".format(user_conf_subdir))
            os.makedirs(user_conf_subdir)
        if subdir == "reports" and not (os.stat(user_conf_subdir).st_mode & 0o777) == 0o700:
            if rapport.config.get_int("rapport", "verbosity") >= 1:
                print("Set secure directory permissions for {0}".format(user_conf_subdir))
            os.chmod(user_conf_subdir, 0o700)
    if not os.path.exists(USER_CONFIG_FILE):
        if rapport.config.get_int("rapport", "verbosity") >= 1:
            print("Create user configuration {0}".format(USER_CONFIG_FILE))
        default_config = os.path.abspath(os.path.join(os.path.splitext(__file__)[0], "rapport.conf"))
        shutil.copyfile(default_config, USER_CONFIG_FILE)

    if not (os.stat(USER_CONFIG_FILE).st_mode & 0o777) == 0o600:
        if rapport.config.get_int("rapport", "verbosity") >= 1:
            print("Set secure file permissions for {0}".format(USER_CONFIG_FILE))
        os.chmod(USER_CONFIG_FILE, 0o600)