<commit_before>#!/usr/bin/env python

# set username and password
user = ""
pswd = ""

import re               # regular expression processing
import mechanize        # web scraping
import argparse         # parse command-line arguments

# parse command-line arguments
parser = argparse.ArgumentParser(description='A command-line interface for GoodTodo.')
parser.add_argument('-a,--add', action='store', nargs='+', metavar='TASK', help='Add a new task to the list')
parser.add_argument('-c,--complete', action='store', metavar='NUMBER', type=int, help='Check a task off the list')
parser.add_argument('-l,--list-all', action='store_true', help='List all tasks, including completed ones')
args = parser.parse_args()

# login to GoodTodo and get the todo page
br = mechanize.Browser()
br.open("https://goodtodo.com/login.php")
br.select_form(nr=0)
br["username"] = user
br["password"] = <PASSWORD>
response = br.submit()
page = response.read()

# complete a task
if vars(args)['c,__complete']:
    tasknum = vars(args)['c,__complete']
    idPattern = re.compile(r'src="images/CheckboxUnchecked.gif" border="0" id="(\d+)" /></span>[\r\n]+												.+<span class')
    id = re.findall(idPattern, page)[tasknum-1]
    br.open("https://goodtodo.com/detail.php?id="+id)
    br.select_form(nr=0)
    br.find_control("done").items[0].selected=True
    response = br.submit()
    page = response.read()

# add a task
if vars(args)['a,__add']:
    # convert the task into a string
    task = ""
    for arg in vars(args)['a,__add']:
        task += arg+' '
    task = task[:-1]
    br.open("https://goodtodo.com/new.php")
    br.select_form(nr=0)
    br["title"] = task
    response = br.submit()
    page = response.read()

# use a regex to pick the individual tasks off of the page
taskPattern = re.compile(r'src="images/CheckboxUnchecked.gif" border="0" id="\d+" /></span>[\r\n]+												(.+)<span class')

# print each task with a number beside it
tasknum = 1
for task in re.findall(taskPattern, page):
    print(str(tasknum)+'. '+task)
    tasknum += 1

# print a list of completed tasks
if vars(args)['l,__list_all']:
    completedTaskPattern = re.compile(r'src="images/CheckboxChecked.gif" border="0" id="\d+" /></span>[\r\n]+												(.+)<span class')
    print('\nCompleted Tasks:')
    for task in re.findall(completedTaskPattern, page):
        print(' - '+task)<commit_msg>Add additional date-based options<commit_after>#!/usr/bin/env python

# set username and password
user = ""
pswd = ""

import re               # regular expression processing
import mechanize        # web scraping
import argparse         # parse command-line arguments
import datetime         # handle time-delayed tasks

# parse command-line arguments
parser = argparse.ArgumentParser(description='A command-line interface for GoodTodo.')
parser.add_argument('-a', action='store', nargs='+', metavar='TASK', help='Add a new task to today\'s list')
parser.add_argument('-c', action='store', metavar='NUMBER', type=int, help='Check a task off the list')
parser.add_argument('-d', action='store', nargs='+', metavar='YYYYMMDD TASK', help='View or add tasks on a given date')
parser.add_argument('-n', action='store', nargs='+', metavar='DAYS TASK', help='Add a task a certain number of days away')
parser.add_argument('-l', action='store_true', help='List all tasks, including completed ones')
args = parser.parse_args()

# login to GoodTodo and get the todo page
br = mechanize.Browser()
br.open("https://goodtodo.com/login.php")
br.select_form(nr=0)
br["username"] = user
br["password"] = <PASSWORD>
response = br.submit()
page = response.read()

# complete a task
if vars(args)['c']:
    tasknum = vars(args)['c']
    idPattern = re.compile(r'src="images/CheckboxUnchecked.gif" border="0" id="(\d+)" /></span>[\r\n]+												.+<span class')
    id = re.findall(idPattern, page)[tasknum-1]
    br.open("https://goodtodo.com/detail.php?id="+id)
    br.select_form(nr=0)
    br.find_control("done").items[0].selected=True
    response = br.submit()
    page = response.read()

# add a task
if vars(args)['a']:
    # convert the task into a string
    task = ""
    for arg in vars(args)['a']:
        task += arg+' '
    task = task[:-1]
    br.open("https://goodtodo.com/new.php")
    br.select_form(nr=0)
    br["title"] = task
    response = br.submit()
    page = response.read()

# view or add tasks at a given future date
if vars(args)['d']:
    # convert the task into a string
    task = ""
    for arg in vars(args)['d']:
        task += arg+' '
    date = task[:10]
    task = task[11:-1]
    br.open("https://goodtodo.com/new.php?edate="+date)
    if task is not '':
        br.select_form(nr=0)
        br["title"] = task
        response = br.submit()
        page = response.read()

# view or add tasks a given number of days in the future
if vars(args)['n']:
    # convert the task into a string
    task = ""
    for arg in vars(args)['n']:
        task += arg+' '
    (days,x,task) = task.partition(' ')
    date = datetime.date.today() + datetime.timedelta(int(days))
    if task is not '':
        br.open("https://goodtodo.com/new.php?edate="+str(date))
        br.select_form(nr=0)
        br["title"] = task
        response = br.submit()
        page = response.read()
    else:
        response = br.open("https://goodtodo.com/home.php?edate="+str(date))
        page = response.read()

# use a regex to pick the individual tasks off of the page
taskPattern = re.compile(r'src="images/CheckboxUnchecked.gif" border="0" id="\d+" /></span>[\r\n]+												(.+)<span class')

# print each task with a number beside it
tasknum = 1
for task in re.findall(taskPattern, page):
    print(str(tasknum)+'. '+task)
    tasknum += 1

# print a list of completed tasks
if vars(args)['l']:
    completedTaskPattern = re.compile(r'src="images/CheckboxChecked.gif" border="0" id="\d+" /></span>[\r\n]+												(.+)<span class')
    print('\nCompleted Tasks:')
    for task in re.findall(completedTaskPattern, page):
        print(' - '+task)
{'fraction_non_alphanumeric': 0.1696206725194633, 'fraction_numerical': 0.004803710452211363, 'mean_word_length': 3.4659763313609466, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 9, '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': '2663418', 'n_tokens_mistral': 2082, 'n_tokens_neox': 1997, 'n_words': 515}