<commit_before>
import os
import errno
from subprocess import call
import shutil

def make_dirs(path):
    try:
        os.makedirs(path, 0755)
    except OSError as exception:
        if exception.errno != errno.EEXIST:
            raise

def rm(file):
    try:
        os.unlink(file)
    except OSError as exception:
        if exception.errno != errno.ENOENT:
            raise

class RepositoryConf(object):

    def __init__(self, name, user, full_name, description, public, user_path="user"):
        self.user_path = user_path
        self.name = name
        self.user = user
        self.description = description
        self.user_name = full_name
        self.path = os.path.join(user, name)
        self.public = public
        self.collaborators = []


    def add_collaborator(self, user, permission):
        self.collaborators.append((user, permission))


    def config_block(self):
        lines = []
        lines.append("\n")
        lines.append("repo %s" % self.path)
        #lines.append("\tRW+ = @user-%s" % self.user)
        lines.append("\towner = %s" % self.user_name)
        lines.append("\tdesc = %s" % self.description)
        for c in self.collaborators:
            lines.append("\t%s = @user-%s" % (c[1], c[0]))
        if self.public:
            lines.append("\tR = @all")
            lines.append("\tR = daemon")
        #lines.append("\tR = gitweb")
        lines.append("\n")
        return '\n'.join(lines)


class GitoliteUserConf(object):
    def __init__(self, user_name, user_path="user", groups_path="groups"):
        self.user_path = user_path
        self.groups_path = groups_path
        self.user = user_name
        self.keys = []
        self.repositories = []
        self.group_file = os.path.join("conf", groups_path, "%s-group.conf" % user_name)
        self.repo_file = os.path.join("conf", user_path, "%s-config.conf" % user_name)
        self.key_path = os.path.join("keydir", user_path, user_name) 


    def add_repo(self, repo):
        self.repositories.append(repo)


    def add_user_key(self, key_name, key_text):
        self.keys.append(("%s-%s" % (self.user, key_name), key_text))


    def delete_user_keys(self):
        shutil.rmtree(self.key_path, ignore_errors=True)


    def clean_user(self):
        self.delete_user_keys()
        rm(self.group_file)<commit_msg>Give gitweb access and no desc if no desc<commit_after>
import os
import errno
from subprocess import call
import shutil

def make_dirs(path):
    try:
        os.makedirs(path, 0755)
    except OSError as exception:
        if exception.errno != errno.EEXIST:
            raise

def rm(file):
    try:
        os.unlink(file)
    except OSError as exception:
        if exception.errno != errno.ENOENT:
            raise

class RepositoryConf(object):

    def __init__(self, name, user, full_name, description, public, user_path="user"):
        self.user_path = user_path
        self.name = name
        self.user = user
        self.description = description
        self.user_name = full_name
        self.path = os.path.join(user, name)
        self.public = public
        self.collaborators = []


    def add_collaborator(self, user, permission):
        self.collaborators.append((user, permission))


    def config_block(self):
        lines = []
        lines.append("\n")
        lines.append("repo %s" % self.path)
        #lines.append("\tRW+ = @user-%s" % self.user)
        lines.append("\towner = %s" % self.user_name)
        if len(self.description) > 0:
            lines.append("\tdesc = %s" % self.description)
        for c in self.collaborators:
            lines.append("\t%s = @user-%s" % (c[1], c[0]))
        if self.public:
            lines.append("\tR = @all")
            lines.append("\tR = daemon")
        lines.append("\tR = gitweb")
        lines.append("\n")
        return '\n'.join(lines)


class GitoliteUserConf(object):
    def __init__(self, user_name, user_path="user", groups_path="groups"):
        self.user_path = user_path
        self.groups_path = groups_path
        self.user = user_name
        self.keys = []
        self.repositories = []
        self.group_file = os.path.join("conf", groups_path, "%s-group.conf" % user_name)
        self.repo_file = os.path.join("conf", user_path, "%s-config.conf" % user_name)
        self.key_path = os.path.join("keydir", user_path, user_name) 


    def add_repo(self, repo):
        self.repositories.append(repo)


    def add_user_key(self, key_name, key_text):
        self.keys.append(("%s-%s" % (self.user, key_name), key_text))


    def delete_user_keys(self):
        shutil.rmtree(self.key_path, ignore_errors=True)


    def clean_user(self):
        self.delete_user_keys()
        rm(self.group_file)
{'fraction_non_alphanumeric': 0.13154023954612312, 'fraction_numerical': 0.0027316663164530363, 'mean_word_length': 2.4, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5077111', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1523, 'n_words': 314}