<commit_before>from optparse import OptionParser
import datetime
import json
import os
import subprocess
import textwrap

import blessings

from henry import __version__
from henry.restapi import get_issues, get_issue_details


USAGE = '%prog [options] [command] [command-options]'
VERSION = 'henry ' + __version__

TERM = blessings.Terminal()


def git(*args):
    args = list(args)
    args.insert(0, 'git')
    return subprocess.check_output(args)


def save_cache(data):
    fn = os.path.join('.git', 'github_issues.json')
    with open(fn, 'w') as fp:
        fp.write(json.dumps(data))


def load_cache():
    fn = os.path.join('.git', 'github_issues.json')
    with open(fn, 'r') as fp:
        return json.load(fp)


def get_auth():
    path = os.path.expanduser('~/.githubauth')
    if os.path.exists(path):
        return open(path, 'r').read().strip()
    return None


def get_remote(remotename='origin'):
    # FIXME - cache this?
    remotes = git('remote', '-v').splitlines()
    remotes = [line.strip().split() for line in remotes if line.strip()]
    remotes = dict((part[0], part) for part in remotes)

    remote_url = remotes[remotename][1]
    if remote_url.startswith('git'):
        user, repo = remote_url.split(':')[1].split('/')<commit_msg>Add support for https urls<commit_after>from optparse import OptionParser
import datetime
import json
import os
import subprocess
import textwrap

import blessings

from henry import __version__
from henry.restapi import get_issues, get_issue_details


USAGE = '%prog [options] [command] [command-options]'
VERSION = 'henry ' + __version__

TERM = blessings.Terminal()


def git(*args):
    args = list(args)
    args.insert(0, 'git')
    return subprocess.check_output(args)


def save_cache(data):
    fn = os.path.join('.git', 'github_issues.json')
    with open(fn, 'w') as fp:
        fp.write(json.dumps(data))


def load_cache():
    fn = os.path.join('.git', 'github_issues.json')
    with open(fn, 'r') as fp:
        return json.load(fp)


def get_auth():
    path = os.path.expanduser('~/.githubauth')
    if os.path.exists(path):
        return open(path, 'r').read().strip()
    return None


def get_remote(remotename='origin'):
    # FIXME - cache this?
    remotes = git('remote', '-v').splitlines()
    remotes = [line.strip().split() for line in remotes if line.strip()]
    remotes = dict((part[0], part) for part in remotes)

    remote_url = remotes[remotename][1]
    if remote_url.startswith('git'):
        user, repo = remote_url.split(':')[1].split('/')
        repo = repo.split('.')[0]
        return user, repo

    if remote_url.startswith('https'):
        user, repo = remote_url.split('/')[-2:]
{'fraction_non_alphanumeric': 0.1500185666542889, 'fraction_numerical': 0.003713330857779428, 'mean_word_length': 3.5816326530612246, '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': '7101894', 'n_tokens_mistral': 911, 'n_tokens_neox': 890, 'n_words': 227}