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

import os
import sys
import httplib2

from oauth2client.file import Storage
from oauth2client.tools import run
from oauth2client.client import OAuth2WebServerFlow
from apiclient.discovery import build

def main(uselist='',items=''):
    # Authentaation
    storage = Storage(os.path.expanduser('~/.gtaskslist.dat'))
    credentials = storage.get()

    if credentials is None or credentials.invalid:
        credentials = run(
          OAuth2WebServerFlow(
            client_id='326384869607.apps.googleusercontent.com',
            client_secret='<KEY>',
            scope=[
              'https://www.googleapis.com/auth/tasks',
              'https://www.googleapis.com/auth/tasks.readonly'],
            user_agent='gtaskslist/1.0',),
          storage)

    http = httplib2.Http()
    http = credentials.authorize(http)

    service = build('tasks', 'v1', http=http)

    # Get task lists
    tasklists = service.tasklists().list().execute()
    for tl in tasklists['items']:
        # Check list name
        if uselist != '' and tl['title'] != uselist:
            continue

        # Get tasks
        tasks = service.tasks().list(tasklist=tl['id']).execute()
        for t in tasks['items']:
            ttitle = t['title']
            if ttitle == '':
                continue
            useflag=0
            if len(items) == 0 or items[0] == '':
                useflag = 1
            else:
                for i in items:
                    if ttitle.find(i):
                        useflag = 1
                        break
            if useflag == 1:
                print ttitle.encode('utf_8')
                print t

if __name__ == '__main__':
    # Get command line options
    from optparse import OptionParser
    usage = '''usage: %prog [-opts] arg1 arg2

       If arg1 arg2... are given, only tasks which include
       these words (ORed) will be listed (combined with -i)
       '''
    parser = OptionParser(usage)
    parser.add_option('-l','--list',action='store',<commit_msg>gtaskslist.py, from darwin11<commit_after>#! /usr/bin/env python

import os
import sys
import httplib2

from oauth2client.file import Storage
from oauth2client.tools import run
from oauth2client.client import OAuth2WebServerFlow
from apiclient.discovery import build

def main(uselist='',items=''):
    # Authentaation
    storage = Storage(os.path.expanduser('~/.gtaskslist.dat'))
    credentials = storage.get()

    if credentials is None or credentials.invalid:
        credentials = run(
          OAuth2WebServerFlow(
            client_id='326384869607.apps.googleusercontent.com',
            client_secret='<KEY>',
            scope=[
              'https://www.googleapis.com/auth/tasks',
              'https://www.googleapis.com/auth/tasks.readonly'],
            user_agent='gtaskslist/1.0',),
          storage)

    http = httplib2.Http()
    http = credentials.authorize(http)

    service = build('tasks', 'v1', http=http)

    # Get task lists
    tasklists = service.tasklists().list().execute()
    for tl in tasklists['items']:
        # Check list name
        if uselist != '' and tl['title'] != uselist:
            continue

        # Get tasks
        tasks = service.tasks().list(tasklist=tl['id']).execute()
        for t in tasks['items']:
            ttitle = t['title']
            if ttitle == '':
                continue
            useflag=0
            if len(items) == 0 or items[0] == '':
                useflag = 1
            else:
                for i in items:
                    if ttitle.find(i) != -1:
                        useflag = 1
                        break
            if useflag == 1:
                print ttitle.encode('utf_8')

if __name__ == '__main__':
    # Get command line options
    from optparse import OptionParser
    usage = '''usage: %prog [-opts] arg1 arg2

       If arg1 arg2... are given, only tasks which include
       these words (ORed) will be listed (combined with -i)

       If you have not installed google-api-python-client, follow:
       https://developers.google.com/api-client-library/python/start/installation
       '''
    parser = OptionParser(usage)
    parser.add_option('-l','--list',action='store',
{'fraction_non_alphanumeric': 0.11838079548128971, 'fraction_numerical': 0.016239115085902565, 'mean_word_length': 1.9992942836979535, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 5, 'lorem ipsum': 0, 'www.': 4, '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': '3458740', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1211, 'n_words': 308}