<commit_before>from unipath import Path

from pyolite.models.repository import Repository

from .manager import Manager


class RepositoryManager(Manager):
  def __init__(self, *args, **kwargs):
    super(RepositoryManager, self).__init__(*args, **kwargs)

  def get(self, lookup_repo):
    return Repository.get_by_name(lookup_repo, self.path, self.git)

  def create(self, lookup_repo):
    repo_file = Path(self.path, 'conf/repos/%s.conf' % lookup_repo)
    if repo_file.exists():
      raise ValueError('Repository %s already exists' % lookup_repo)

    repo_file.write_file("repo %s\n" % lookup_repo)

    self.git.commit([str(repo_file)], 'Created repo %s' % lookup_repo)

    return Repository(lookup_repo, self.path, self.git)<commit_msg>Allow slashes in repo names, #9<commit_after>from unipath import Path

from pyolite.models.repository import Repository

from .manager import Manager


class RepositoryManager(Manager):
  def __init__(self, *args, **kwargs):
    super(RepositoryManager, self).__init__(*args, **kwargs)

  def get(self, lookup_repo):
    return Repository.get_by_name(lookup_repo, self.path, self.git)

  def create(self, lookup_repo):
    repo_file = Path(self.path, 'conf/repos/%s.conf' % lookup_repo)
    if repo_file.exists():
      raise ValueError('Repository %s already exists' % lookup_repo)
    # If there are missing parent paths in the repo path, create them so we don't get IOErrors
    # In the case of a repo having names with slashes (e.g. "username/reponame")
    elif repo_file.parent != Path(""):
      repo_file.parent.mkdir(parents=True)

    repo_file.write_file("repo %s\n" % lookup_repo)

    self.git.commit([str(repo_file)], 'Created repo %s' % lookup_repo)

    return Repository(lookup_repo, self.path, self.git)
{'fraction_non_alphanumeric': 0.11764705882352941, 'fraction_numerical': 0.0005656108597285068, 'mean_word_length': 4.562893081761007, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7366687', 'n_tokens_mistral': 574, 'n_tokens_neox': 555, 'n_words': 147}