<commit_before>#!/bin/python
import github3
import string
import simplejson
import hashlib
import sys
import ConfigParser

CACHE_FILE = '.cache'

def login(config_reader):
    # Populate env token or use prompt
    # @TODO read from a config or env to pull token
    token = config_reader.get('github', 'token')
    return github3.login(token=token)

def create_or_use_repo(gh, bookmark_content):
    repo_name = "mybookmark"

    def update_bookmark(gh, repo, bookmark_content):
        readme_path = "README.md"

        # Retrieve README.md sha
        repo_inst = gh.repository(repo.owner, repo.name)

        # Update readme.md
        print "Updating bookmark"
        repo.update_file(readme_path, "update book marks", bookmark_content, repo_inst.contents(readme_path).sha)
        print "Done. See %s" % repo.html_url

    # See if rpeo already exists
    for repo in gh.iter_repos():
        if repo_name == repo.name:
            print "Updating README.md in %s (%s)" % (repo_name,repo.html_url )
            return update_bookmark(gh, repo, bookmark_content)

    # No repo yet, go ahead to create a repo
    repo = {}
    # Public repo
    repo["name"]        = repo_name
    repo["description"] = "My collection of useful bookmarks"<commit_msg>* Purge dead code and TODO<commit_after>#!/bin/python
import github3
import string
import simplejson
import hashlib
import sys
import ConfigParser

def login(config_reader):
    token = config_reader.get('github', 'token')
    return github3.login(token=token)

def create_or_use_repo(gh, bookmark_content):
    repo_name = "mybookmark"

    def update_bookmark(gh, repo, bookmark_content):
        readme_path = "README.md"

        # Retrieve README.md sha
        repo_inst = gh.repository(repo.owner, repo.name)

        # Update readme.md
        print "Updating bookmark"
        repo.update_file(readme_path, "update book marks", bookmark_content, repo_inst.contents(readme_path).sha)
        print "Done. See %s" % repo.html_url

    # See if rpeo already exists
    for repo in gh.iter_repos():
        if repo_name == repo.name:
            print "Updating README.md in %s (%s)" % (repo_name,repo.html_url )
            return update_bookmark(gh, repo, bookmark_content)

    # No repo yet, go ahead to create a repo
    repo = {}
    # Public repo
    repo["name"]        = repo_name
    repo["description"] = "My collection of useful bookmarks"
{'fraction_non_alphanumeric': 0.09697472026523, 'fraction_numerical': 0.0016576875259013675, 'mean_word_length': 3.0846023688663284, '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': '6994658', 'n_tokens_mistral': 769, 'n_tokens_neox': 746, 'n_words': 214}