<commit_before># -*- coding: utf-8 -*-

import threading
import os
import json
import base64
from github import Github


class TaskManager(object):
    """ Multi threading manager """

    def __init__(self):
        """ Initializes a TaskManager

        """
        self.threads = list()

    def wait_until_exit(self):
        """ Wait until all the threads are finished.

        """
        [t.join() for t in self.threads]

        self.threads = list()

    def start_task(self, method, *args, **kwargs):
        """ Start a task in a separate thread

            Args:
                method: the method to start in a separate thread
                args: Accept args/kwargs arguments
        """
        thread = threading.Thread(target=method, args=args, kwargs=kwargs)
        thread.is_daemon = False
        thread.start()
        self.threads.append(thread)


class SpecificationsRepositoryManager (object):
    """ SpecificationsRepositoryManager is an object that allows to manipulate the API specification repository
    """

    def __init__(self, github_api_url, github_token, specification_organization, github_specifications_repository):
        """ Initialize SpecificationsRepositoryManager

            Args:
                github_api_url: the API url for Github
                github_token: the authentication token for Github
                specification_organization: the organization where github_specifications_repository is
                github_specifications_repository: the repository containing the specifications
        """

        self._github                    = Github(login_or_token=github_token, base_url=github_api_url)
        self._github_specification_repo = self._github.get_organization(specification_organization).get_repo(github_specifications_repository)

    def available_versions(self):
        """ Returns the list of available API spec versions (branches)

            Returns:
                list of all available specification versions (branches)
        """

        return [branch.name for branch in self._github_specification_repo.get_branches()]

    def available_specifications(self, specification_version="master"):
        """ Returns the list of available specification files

            Args:
                specification_version: the version (branch) where to find files (default: "master")

            Returns:
                list of all available specification files in the given version<commit_msg>style<commit_after># -*- coding: utf-8 -*-

import threading
import os
import json
import base64
from github import Github


class TaskManager(object):
    """ Multi threading manager """

    def __init__(self):
        """ Initializes a TaskManager

        """
        self.threads = list()

    def wait_until_exit(self):
        """ Wait until all the threads are finished.

        """
        [t.join() for t in self.threads]

        self.threads = list()

    def start_task(self, method, *args, **kwargs):
        """ Start a task in a separate thread

            Args:
                method: the method to start in a separate thread
                args: Accept args/kwargs arguments
        """
        thread = threading.Thread(target=method, args=args, kwargs=kwargs)
        thread.is_daemon = False
        thread.start()
        self.threads.append(thread)


class SpecificationsRepositoryManager (object):
    """ SpecificationsRepositoryManager is an object that allows to manipulate the API specification repository
    """

    def __init__(self, github_api_url, github_token, specification_organization, github_specifications_repository):
        """ Initialize SpecificationsRepositoryManager

            Args:
                github_api_url: the API url for Github
                github_token: the authentication token for Github
                specification_organization: the organization where github_specifications_repository is
                github_specifications_repository: the repository containing the specifications
        """

        self._github = Github(login_or_token=github_token, base_url=github_api_url)
        self._github_specification_repo = self._github.get_organization(specification_organization).get_repo(github_specifications_repository)

    def available_versions(self):
        """ Returns the list of available API spec versions (branches)

            Returns:
                list of all available specification versions (branches)
        """

        return [branch.name for branch in self._github_specification_repo.get_branches()]

    def available_specifications(self, specification_version="master"):
        """ Returns the list of available specification files

            Args:
                specification_version: the version (branch) where to find files (default: "master")

            Returns:
                list of all available specification files in the given version
{'fraction_non_alphanumeric': 0.07095073991485912, 'fraction_numerical': 0.001216298398540442, 'mean_word_length': 2.6711309523809526, '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': '6405743', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1127, 'n_words': 373}