<commit_before># -*- coding: utf-8 -*-
import datetime
import random
import hashlib
import base64
import requests
import sys

username = 'username'
password = '<PASSWORD>'
blogname = 'yourblogname.hatenablog.com'
category = 'from post-hatena'
draft = 'yes' # yes or no
 
def wsse(username, password):
    created = datetime.datetime.now().isoformat() + 'Z'
    nonce = hashlib.sha1(str(random.random())).digest()
    digest = hashlib.sha1(nonce + created + password).digest()
    
    return 'UsernameToken Username="{}", PasswordDigest="{}", Nonce="{}", Created="{}"'.format(username, base64.b64encode(digest), base64.b64encode(nonce), created)


def posthatena(data):
    headers = {'X-WSSE': wsse(username, password)}

    url = 'http://blog.hatena.ne.jp/{}/{}/atom/entry'.format(username, blogname)

    r = requests.post(url, data=data, headers=headers)
    print (r)

if __name__ == '__main__':

    param = sys.argv
    if (len(param) != 3):
        print ("Usage: $ python " + param[0] + " title.txt body.txt")
        quit()  

    f = open(param[1])
    title = f.read()
    f.close()

    f = open(param[2])
    body = f.read()
    f.close()<commit_msg>modify post-hatena.py<commit_after># -*- coding: utf-8 -*-
import datetime
import random
import hashlib
import base64
import requests
import sys

username = 'username'
password = '<PASSWORD>'
blogname = 'yourblogname.hatenablog.com'
category = 'from post-hatena'
draft = 'yes' # yes or no

def wsse(username, password):
    created = datetime.datetime.now().isoformat() + 'Z'
    nonce = hashlib.sha1(str(random.random())).digest()
    digest = hashlib.sha1(nonce + created + password).digest()
    
    return 'UsernameToken Username="{}", PasswordDigest="{}", Nonce="{}", Created="{}"'.format(username, base64.b64encode(digest), base64.b64encode(nonce), created)


def posthatena(data):
    headers = {'X-WSSE': wsse(username, password)}

    url = 'http://blog.hatena.ne.jp/{}/{}/atom/entry'.format(username, blogname)

    r = requests.post(url, data=data, headers=headers)
    print (r)

if __name__ == '__main__':

    param = sys.argv
    if (len(param) != 3):
        print ("Usage: $ python " + param[0] + " title.txt body.txt")
        quit()  

    with open(param[1]) as f1:
            title = f1.read()

    with open(param[2]) as f2:
        body = f2.read()
{'fraction_non_alphanumeric': 0.1728712023962345, 'fraction_numerical': 0.016260162601626018, 'mean_word_length': 3.557504873294347, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '176808', 'n_tokens_mistral': 827, 'n_tokens_neox': 785, 'n_words': 182}