Exemplo n.º 1
0
 def __init__(self):
     self.api = wunderpy2.WunderApi()
     sec, cid = get_password_pass()
     self.client = self.api.get_client(sec, cid)
     config = configparser.ConfigParser()
     config.read(os.path.join(os.path.expanduser('~'), ".weeklyreport.ini"))
     self.inbox_id = config["wunderlist"]["inbox"]
Exemplo n.º 2
0
def checkCompletion(access_token, client_id):
    import wunderpy2
    import pygsheets
    import datetime

    x = 2
    gc = pygsheets.authorize()
    sh = gc.open('wunderlist_update')
    wks = sh.sheet1
    api = wunderpy2.WunderApi()
    client = api.get_client(access_token, client_id)
    current_rows = wks.get_all_values()

    for row_data in current_rows:

        if row_data[2] == 'TRUE':
            x = x + 1
        if row_data[2] == 'FALSE':
            wunder_id = row_data[0]
            listo = client.get_task(task_id=wunder_id)

            if str(listo['completed']) == 'FALSE':
                x = x + 1
            if str(listo['completed']) == 'TRUE':
                date_now = datetime.datetime.now().date()
                wks.update_cell('C' + str(x), 'TRUE')
                wks.update_cell('E' + str(x), str(date_now))
                x = x + 1
Exemplo n.º 3
0
def add_groceries_to_wunderlist(wunderlist_config: WunderpyAccessBase,
                                target_list_name: str,
                                groceries: ty.Sequence[ty.Dict[str, str]]):
    """With the given wunderlist_config, add groceries to target_list_name."""

    api = wunderpy2.WunderApi()
    client = api.get_client(wunderlist_config.access_token,
                            wunderlist_config.client_id)

    lists = client.get_lists()

    target_list = None
    for li in lists:
        if li['title'] == target_list_name:
            target_list = li
            break

    if not target_list:
        print('Target list not found!')

    else:
        for item in groceries:
            task = client.create_task(target_list['id'], item['item'])
            client.create_note(task[wunderpy2.Task.ID], item['description'])

    return 'Wunderpy ok'
Exemplo n.º 4
0
    def __init__(self, access_token, client_id):
        """Create new instance of Wunderlist component."""
        import wunderpy2

        api = wunderpy2.WunderApi()
        self._client = api.get_client(access_token, client_id)

        _LOGGER.debug("Instance created")
Exemplo n.º 5
0
 def __init__(self):
     self.tasks = []
     CLIENT_ID = "73fb97eb7715be852069"
     ACCESS_TOKEN = "927bb36d40cf32fac899da24922e01caee421aa9dfe0b781946c96c33764"
     api = wunderpy2.WunderApi()
     self.client = api.get_client(ACCESS_TOKEN, CLIENT_ID)
     self.projects = self.client.get_lists()
     for project in self.projects:
         for task in self.client.get_tasks(project['id']):
             self.tasks.append(task)
Exemplo n.º 6
0
def pullData(access_token, client_id):

    import wunderpy2
    import pygsheets
    import time
    import datetime
    import os

    gc = pygsheets.authorize()
    sh = gc.open('wunderlist_update')
    wks = sh.sheet1
    date_added = datetime.datetime.now()
    date_added = datetime.datetime.strptime(str(date_added),
                                            '%Y-%m-%d %H:%M:%S.%f')
    date_added = date_added.strftime('%Y-%m-%d')
    api = wunderpy2.WunderApi()
    client = api.get_client(access_token, client_id)
    listo = client.get_tasks(170815027, completed=False)
    where_am_i = open("where_am_i.txt", "r")
    x = (where_am_i.readline())
    current_ids = wks.get_col(col=1)

    for items in listo:
        wunder_id = (items['id'])

        if str(wunder_id) in str(current_ids):
            pass
        if str(wunder_id) not in str(current_ids):
            created_at = (items['created_at'])
            created_at = datetime.datetime.strptime(created_at,
                                                    '%Y-%m-%dT%H:%M:%S.%fZ')
            created_at = datetime.datetime.strftime(created_at, '%Y-%m-%d')
            completed = (items['completed'])
            title = (items['title'])
            date_added = datetime.datetime
            # Open spreadsheet and then workseet
            sh = gc.open('wunderlist_update')
            wks = sh.sheet1
            wks.update_cell('A' + str(x), wunder_id)
            wks.update_cell('B' + str(x), created_at)
            wks.update_cell('C' + str(x), completed)
            wks.update_cell('D' + str(x), title)
            wks.update_cell('E' + str(x), created_at)
            x = int(x) + 1
            time.sleep(2)

    where_am_i = open("where_am_i.txt", "w")
    where_am_i.write(str(x))
    where_am_i.close()
Exemplo n.º 7
0
class WunderStorage:
    api = wunderpy2.WunderApi()

    def __init__(self, access_token, clientId):
        self.access_token = access_token
        self.clientId = clientId
        self.client = self.api.get_client(access_token, clientId)
        self.cartId = self.getListId(
            "Shopping")  #Enter name of your shopping list
        self.storageId = self.getListId(
            "Storage")  #Enter name of your storage list

    def __call__(self):
        self.addItems()
        self.updateStorage()
        self.refreshStorage()

    def getListId(self, title):
        lists = self.client.get_lists()

        for l in lists:
            if l["title"] == title:
                return l["id"]

        return

    @ErrorHandle
    def getTask(client, taskId):
        return client.get_task(taskId)

    @ErrorHandle
    def getTasks(client, listId, completed):
        return client.get_tasks(listId, completed)

    @ErrorHandle
    def createTask(client, listId, title):
        client.create_task(listId, title)

    @ErrorHandle
    def deleteTask(client, task):
        client.delete_task(task["id"], task["revision"])

    @ErrorHandle
    def updateTask(client, taskId, revision, title):
        client.update_task(taskId, revision, title, completed=False)

    def updateItem(self, taskId, title):
        task = self.getTask(self.client, taskId)

        if task:
            revision = task["revision"]
            self.updateTask(self.client, taskId, revision, title)

    def addItems(self):
        items = self.getTasks(self.client, self.cartId, True)

        if items:
            for item in items:
                self.createTask(self.client, self.storageId, item["title"])
                self.deleteTask(self.client, item)

    def updateStorage(self):
        storage = {}
        items = self.getTasks(self.client, self.storageId, False)

        if items:
            for item in items:
                title = item["title"]
                buffer = title.split()

                if buffer[0].isdigit():
                    quantity = int(buffer[0])
                    title = " ".join(buffer[1:])
                    item["quantity"], item[
                        "start_quantity"] = quantity, quantity

                else:
                    item["quantity"], item["start_quantity"] = 1, 0

                if not title in storage:
                    storage[title] = item

                else:
                    storage[title]["quantity"] += item["quantity"]
                    self.deleteTask(self.client, item)

            for title in storage:
                item = storage[title]
                if item["start_quantity"] != item["quantity"]:
                    new_title = str(storage[title]["quantity"]) + " " + title
                    self.updateItem(storage[title]["id"], new_title)

    def refreshStorage(self):
        items = self.getTasks(self.client, self.storageId, True)

        if items:
            for item in items:
                buffer = item["title"].split()

                if len(buffer) > 1:

                    if buffer[0].isdigit():
                        quantity = int(buffer[0]) - 1

                        if quantity > 0:
                            title = str(quantity) + " " + " ".join(buffer[1:])
                            self.updateItem(item["id"], title)
                            continue

                        self.deleteTask(self.client, item)
Exemplo n.º 8
0
def write_shopping_list_item(item):
    api = wunderpy2.WunderApi()
    client = api.get_client('20810582', '3203123')
    client.create_task('list_id', item.name)
Exemplo n.º 9
0
def create_client(access_token, client_id):
    """Creates a wunderlist client instance."""
    import wunderpy2
    api = wunderpy2.WunderApi()
    client = api.get_client(access_token, client_id)
    return client
Exemplo n.º 10
0
from __future__ import print_function

import wunderpy2
from python_dash_wunderlist.types import ADD_WUNDERLIST_ENTRY
from python_dash_wunderlist.utils import find, lmap

API = wunderpy2.WunderApi()


def wunderlist_middleware(store):
    """handle communication with wunderlist api"""
    get_state = store['get_state']

    client_id = get_state()['client_id']
    access_token = get_state()['access_token']
    client = API.get_client(access_token, client_id)
    wunderlist_ids = {}
    for item in client.get_lists():
        wunderlist_ids.update({item['title']: item['id']})
    print(wunderlist_ids)

    def wrapper(next_):
        def middleware_dispatcher(action):
            if action['type'] == ADD_WUNDERLIST_ENTRY:
                list_name = action['list']
                title = action['entry']
                list_id = wunderlist_ids[list_name]
                tasks = client.get_tasks(list_id)
                print(tasks)
                entry = find(lambda e: e['title'] == title, tasks)
                if entry:
Exemplo n.º 11
0
def get_wunderlist_client():
    ACCESS_TOKEN = getenv('WUNDERLIST_ACCESS_TOKEN')
    CLIENT_ID = getenv('WUNDERLIST_CLIENT_ID')
    api = wunderpy2.WunderApi()
    client = api.get_client(ACCESS_TOKEN, CLIENT_ID)
    return client
Exemplo n.º 12
0
 def setUp(self):
     self.api = wunderpy2.WunderApi()
     self.client = self.api.get_client(tests_config.ACCESS_TOKEN,
                                       tests_config.CLIENT_ID)
Exemplo n.º 13
0
 def __init__(self):
     api = wunderpy2.WunderApi()
     self.client = api.get_client(
         tokens['wunderlist_token'], tokens['wunderlist_client_id'])
Exemplo n.º 14
0
 def __init__(self):
     WunderApi.__init__(self)
     api = wunderpy2.WunderApi()
     self.client = api.get_client(ACCESS_TOKEN, CLIENT_ID)
Exemplo n.º 15
0
 def __init__(self, config):
     ShopList.__init__(self)
     self.logger = Logger('Wunderlist')
     self.client = wunderpy2.WunderApi().get_client(config['wunderlist_token'], config['wunderlist_client_id'])
     self.list_id = config['wunderlist_list_id']
Exemplo n.º 16
0
 def __init__(self):
     self.api = wunderpy2.WunderApi()
     self._load_config()
     self.client = self.api.get_client(self.access_token, self.client_id)
     args = get_args()
     self._process_args(args)
Exemplo n.º 17
0
import email
import email.header
import datetime
import re
import wunderpy2

#### This is where you call the gmail IMAP server
M = imaplib.IMAP4_SSL('imap.gmail.com', 993)

#### This is where you login to gmail
try:
    M.login('*****@*****.**', getpass.getpass('Password: '******'access_token', 'client_id')

##### This is where you list all the available mailboxes in gmail
rv, mailboxes = M.list()
if rv == 'OK':
    print "Mailboxes:"
    print mailboxes


def process_mailbox(M):
    rv, data = M.search(None, '(ALL)', '(FROM [email protected])')
    if rv != 'OK':
        print "ERROR getting message", num
        return
Exemplo n.º 18
0
def write_shopping_list(recipe):
    api = wunderpy2.WunderApi()
    client = api.get_client('231223', '3213123')
    for item in recipe.items:
        client.create_task('list_id', item.name)