<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os, sys
import subprocess
import ConfigParser

TEMP_FILE = 'tmp'

class Epistle():

  def __init__(self):
    self.epistle_dir = os.path.join(os.path.expanduser('~'), ".epistle")
    self.epistle_cfg = os.path.join(self.epistle_dir, "epistle.ini")
    self.epistles_dir = os.path.join(self.epistle_dir, "epistles")
    # read the config
    self.config = ConfigParser.ConfigParser()
    self.config.read(self.epistle_cfg)

  def get_vim(self):
    # get vim 
    try:
      return self.config.get("Epistle","Vim")
    except:
      return os.environ.get('EDITOR','vim') # http://stackoverflow.com/questions/6309587/call-up-an-editor-vim-from-a-python-script

  def get_epistle(self,name):
    epistle_path = os.path.join(self.epistles_dir,name)
    if not os.path.isfile(epistle_path):
      # make the file
      os.system("touch %s" % epistle_path)
    return epistle_path

  def has_git_remote(self):
    try:
      remote = self.config.get("Git","Remote")
      return (len(remote) > 0)
    except:
      return False

  def git_pull(self):
    os.system("cd %s && git pull" % self.epistles_dir)

  def git_commit(self, epistle):
    os.system("cd %s && git add %s && git commit -m 'date:%s'" % (self.epistles_dir,epistle,"TODO:add-datestamp"))

  def git_push(self):
    os.system("cd %s && git push" % (self.epistles_dir))

  def main(self, argv):
    # update git repo (pull)
    if self.has_git_remote():
      self.git_pull()

    vim = self.get_vim()
    print "Using vim from: %s" % vim

    epistle = self.get_epistle(argv[1])
    print "Got epistle file: %s" % epistle

    subprocess.check_call([vim, epistle])<commit_msg>added timestamp to commit msg<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os, sys
import subprocess
from datetime import datetime
import ConfigParser

TEMP_FILE = 'tmp'

class Epistle():

  def __init__(self):
    self.epistle_dir = os.path.join(os.path.expanduser('~'), ".epistle")
    self.epistle_cfg = os.path.join(self.epistle_dir, "epistle.ini")
    self.epistles_dir = os.path.join(self.epistle_dir, "epistles")
    # read the config
    self.config = ConfigParser.ConfigParser()
    self.config.read(self.epistle_cfg)

  def get_vim(self):
    # get vim 
    try:
      return self.config.get("Epistle","Vim")
    except:
      return os.environ.get('EDITOR','vim') # http://stackoverflow.com/questions/6309587/call-up-an-editor-vim-from-a-python-script

  def get_epistle(self,name):
    epistle_path = os.path.join(self.epistles_dir,name)
    if not os.path.isfile(epistle_path):
      # make the file
      os.system("touch %s" % epistle_path)
    return epistle_path

  def has_git_remote(self):
    try:
      remote = self.config.get("Git","Remote")
      return (len(remote) > 0)
    except:
      return False

  def git_pull(self):
    os.system("cd %s && git pull" % self.epistles_dir)

  def git_commit(self, epistle):
    deets = (self.epistles_dir, epistle, datetime.now().strftime("%Y%m%d%H%m"))
    os.system("cd %s && git add %s && git commit -m 'date:%s'" % deets)

  def git_push(self):
    os.system("cd %s && git push" % (self.epistles_dir))

  def main(self, argv):
    # update git repo (pull)
    if self.has_git_remote():
      self.git_pull()

    vim = self.get_vim()
    print "Using vim from: %s" % vim

    epistle = self.get_epistle(argv[1])
    print "Got epistle file: %s" % epistle

    subprocess.check_call([vim, epistle])
{'fraction_non_alphanumeric': 0.15058688806183795, 'fraction_numerical': 0.005725737188663041, 'mean_word_length': 3.3403726708074535, 'pattern_counts': {'":': 0, '<': 3, '<?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': '601711', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1264, 'n_words': 259}