<commit_before>from git import Repo, InvalidGitRepositoryError
from github import Github
import configparser

def auth_github():
    try:
        repo = Repo('.', search_parent_directories=True)
        config = repo.config_reader()
    except:
        print('This does not seem to be a git repository.')
        return Github()
    try:
        return Github(config.get('github', 'user'), config.get('github', 'password'))
    except configparser.NoSectionError:
        print('No github section found in \'git config\'')
        return Github()
    except configparser.NoOptionError:
        try:
            return Github(config.get('github', 'oauthtoken'))
        except configparser.NoOptionError:
            print('No github \'user\'/\'password\' or \'oauthtoken\' keys found in \'git config\'.')
            print('You can create an OAuth token at https://github.com/settings/tokens/new (no scopes are required).')
            return Github()<commit_msg>feat(script/auth_github): improve messages [ci skip] (#965)<commit_after>from git import Repo, InvalidGitRepositoryError
from github import Github
import configparser

def auth_github():
    try:
        repo = Repo('.', search_parent_directories=True)
        config = repo.config_reader()
    except:
        print('Warning: This does not seem to be a git repository. Expect weird things...')
        return Github()
    try:
        return Github(config.get('github', 'user'), config.get('github', 'password'))
    except configparser.NoSectionError:
        print('Info: No github section found in \'git config\', we will use GitHub with no authentication')
        return Github()
    except configparser.NoOptionError:
        try:
            return Github(config.get('github', 'oauthtoken'))
        except configparser.NoOptionError:
            print("Info: No github 'user'/'password' or 'oauthtoken' keys found in git config, "
                  "we will use GitHub with no authentication.")
            print('You can create an OAuth token at https://github.com/settings/tokens/new (no scopes are required).')
            return Github()
{'fraction_non_alphanumeric': 0.11121628017037388, 'fraction_numerical': 0.001419782300047326, 'mean_word_length': 2.9075785582255085, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '733729', 'n_tokens_mistral': 576, 'n_tokens_neox': 556, 'n_words': 184}