<commit_before>"""Generate a github auth token"""

# technical debt:
# --------------
# - add command line option to override default user
# - add command line option for delete scope

from getpass import getuser, getpass
import os
import platform
import sys
from github3 import authorize


def main():
    appname = sys.argv[0]
    debug = os.getenv("DM_SQUARE_DEBUG")
    delete_scope = os.getenv("DM_SQUARE_ADMIN")
    hostname = platform.node()

    user = getuser()
    if debug:
        print user
    password = ''

    if delete_scope:
        file_credential = os.path.expanduser('~/.sq_github_token_delete')
        if debug:
            print 'Token with delete scope will be generated:', file_credential
    else:
        file_credential = os.path.expanduser('~/.sq_github_token')
        if debug:
            print 'Token with user scope will be generated:', file_credential

    if not os.path.isfile(file_credential):

        print """<commit_msg>Add argument parser to github-auth<commit_after>"""Generate a github auth token"""

# technical debt:
# --------------
# - add command line option to override default user
# - add command line option for delete scope

from getpass import getuser, getpass
import argparse
import os
import platform
import sys
from github3 import authorize


def parse_args():
    parser = argparse.ArgumentParser(
        prog='github-auth',
        description='Generate a GitHub auth token.')
    parser.add_argument('-u', '--user',
                        help='GitHub username',
                        dest='user',
                        default=getuser())
    return parser.parse_args()


def main():
    args = parse_args()

    appname = sys.argv[0]
    debug = os.getenv("DM_SQUARE_DEBUG")
    delete_scope = os.getenv("DM_SQUARE_ADMIN")
    hostname = platform.node()

    user = args.user
    if debug:
        print user
    password = ''

    if delete_scope:
        file_credential = os.path.expanduser('~/.sq_github_token_delete')
        if debug:
            print 'Token with delete scope will be generated:', file_credential
    else:
        file_credential = os.path.expanduser('~/.sq_github_token')
        if debug:
            print 'Token with user scope will be generated:', file_credential

    if not os.path.isfile(file_credential):

        print """
{'fraction_non_alphanumeric': 0.10609965635738831, 'fraction_numerical': 0.001718213058419244, 'mean_word_length': 2.5720858895705523, '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': '1973562', 'n_tokens_mistral': 675, 'n_tokens_neox': 649, 'n_words': 200}