Ejemplo n.º 1
0
    def get_items(self):
        tmp = []
        for n in self.list_names:
            tmp.append([])

        cals = reminders.get_all_calendars()
        for c in cals:
            #print(c.title)
            if c.title in self.list_names:
                section = self.list_names.index(c.title)
                self.cal_dict[str(section)] = c
                #print('{} is section number {}'.format(c.title, section))
                self.rem_dict[str(section)] = reminders.get_reminders(
                    calendar=c, completed=False)
                tmplist = []
                for r in self.rem_dict[str(section)]:
                    #print(r)
                    im = ui.Image('iob:drag_24')
                    tmplist.append({
                        'title': r.title,
                        'image': im,
                        'accessory_type': 'disclosure_indicator',
                        'subtitle': r.notes
                    })
                tmp[section] = tmplist

            #print('=========')
        return tmp
Ejemplo n.º 2
0
def get_calendar(line):
    project = line[:-1]
    for cal in reminders.get_all_calendars():
        if cal.title == project:
            todo = reminders.get_reminders(cal)
            return cal, todo
    return None, []
Ejemplo n.º 3
0
def get_or_create_calendar(title):
    calendars = {c.title: c for c in reminders.get_all_calendars()}

    try:
        return calendars[title]
    except KeyError:
        new_calendar = reminders.Calendar()
        new_calendar.title = title
        new_calendar.save()
        return new_calendar
Ejemplo n.º 4
0
 def __init__(self):
     all_calendars = reminders.get_all_calendars()
     for calendar in all_calendars:
         if calendar.title == CALENDAR:
             self.calendar = calendar
             break
     else:
         new_calendar = reminders.Calendar()
         new_calendar.title = CALENDAR
         new_calendar.save()
         self.calendar = new_calendar
Ejemplo n.º 5
0
def completeReminder():

    _title = sys.argv[1] if len(sys.argv) > 1 else None
    _list = sys.argv[2] if len(sys.argv) > 2 else None

    if _list:
        calendars = reminders.get_all_calendars()
        _list = [x for x in calendars if x.title == _list]
        _list_title = _list[0].title
        todo = reminders.get_reminders(completed=False, calendar=_list[0])
        callback = 'twodo://x-callback-url/showList?name=%s' % quote(
            _list_title)
    else:
        todo = reminders.get_reminders(completed=False)
        callback = 'twodo://'

    if len(todo) == 0:
        return dialogs.hud_alert('You don\'t have any reminder left to do.')

    if _title:

        this = [x for x in todo if x.title == _title]

        if len(this) == 1:
            this = this[0]
        elif len(this) <= 0:
            return dialogs.hud_alert(
                'You don\'t have any reminder matching these terms.')
        else:
            todomap = {x.title: x for x in this}
            this = dialogs.list_dialog('Multiple matches', todomap.keys())

            if not this:
                return dialogs.hud_alert(
                    'You gotta pick the correct reminder.')
            else:
                this = todomap.get(this)

    else:
        todomap = {x.title: x for x in todo}
        this = dialogs.list_dialog('Multiple matches', todomap.keys())

        if not this:
            return dialogs.hud_alert('You gotta pick the correct reminder.')
        else:
            this = todomap.get(this)

    this.completed = True
    this.save()
    webbrowser.open(callback)
Ejemplo n.º 6
0
def main():
    all_todo = reminders.get_reminders(completed=False)

    now = datetime.datetime.now()
    # Display open reminders with a due date per calendar
    all_calendars = reminders.get_all_calendars()
    for cal in all_calendars:
        print(f"\n{cal.title}\n" + '=' * 40)
        todo = reminders.get_reminders(calendar=cal, completed=False)
        for r in todo:
            due_date: datetime = r.due_date
            if due_date:
                text = f"[ ] {r.title} ({due_date.strftime('%a, %d.%m')})"
                print(text)
Ejemplo n.º 7
0
    def getCalendar(self):

        c = None
        cs = reminders.get_all_calendars()

        for i in cs:
            if i.title == self.calendar:
                c = i
                break
        else:
            c = reminders.Calendar()
            c.title = self.calendar
            c.save()

        return c
Ejemplo n.º 8
0
	def __init__(self, namespace = 'Pythonista', to_json = False, cache = False):
		self.json = to_json
		self.cached = cache
		self.cache = {}
		self.list_calendar = None
		all_calendars = reminders.get_all_calendars()
		for calendar in all_calendars:
			if calendar.title == namespace:
				self.list_calendar = calendar
				break
		if not self.list_calendar:
			new_calendar = reminders.Calendar()
			new_calendar.title = namespace
			new_calendar.save()
			self.list_calendar = new_calendar
		self.items = {}
		self._refresh(force = True)
Ejemplo n.º 9
0
 def __init__(self, namespace='Pythonista', to_json=False, cache=False):
     self.json = to_json
     self.cached = cache
     self.cache = {}
     self.list_calendar = None
     all_calendars = reminders.get_all_calendars()
     for calendar in all_calendars:
         if calendar.title == namespace:
             self.list_calendar = calendar
             break
     if not self.list_calendar:
         new_calendar = reminders.Calendar()
         new_calendar.title = namespace
         new_calendar.save()
         self.list_calendar = new_calendar
     self.items = {}
     self._refresh(force=True)
Ejemplo n.º 10
0
def but_action(sender):
    fields = [{'key' : 'name', 'type' : 'text', 'value' : 'Name your reminder'},
              {'key' : 'calendar', 'type' : 'text', 'value' : 'Name a calendar for this reminder'}]
    result=dialogs.form_dialog(title='Create a Reminder', fields=fields)
    all_calendars = reminders.get_all_calendars()
    for calendar in all_calendars:
        if calendar.title == result['calendar']:
            r = reminders.Reminder(calendar)
            r.title = result['name']
            r.save()
            break
    else:
        q = console.alert('Could not find calendar', 'Could not find calendar named ' + result['calendar'] + ' Would you like to create one?', 'Yes', hide_cancel_button=False)
        if q == 1:
            new_calendar = reminders.Calendar()
            new_calendar.title = result['calendar']
            new_calendar.save()
            calendar.title == result['calendar']
            r = reminders.Reminder(calendar)
            r.title = result['name']
            r.save()

    segment.selected_index = 0
    reminders_table.data_source.items = get_reminder_items(completed=False)
Ejemplo n.º 11
0
def but_action(sender):
    fields = [{'key' : 'name', 'type' : 'text', 'value' : 'Name your reminder'},
              {'key' : 'calendar', 'type' : 'text', 'value' : 'Name a calendar for this reminder'}]
    result=dialogs.form_dialog(title='Create a Reminder', fields=fields)
    all_calendars = reminders.get_all_calendars()
    for calendar in all_calendars:
        if calendar.title == result['calendar']:
            r = reminders.Reminder(calendar)
            r.title = result['name']
            r.save()
            break
    else:
        q = console.alert('Could not find calendar', 'Could not find calendar named ' + result['calendar'] + ' Would you like to create one?', 'Yes', hide_cancel_button=False)
        if q == 1:
            new_calendar = reminders.Calendar()
            new_calendar.title = result['calendar']
            new_calendar.save()
            calendar.title == result['calendar']
            r = reminders.Reminder(calendar)
            r.title = result['name']
            r.save()

    segment.selected_index = 0
    reminders_table.data_source.items = get_reminder_items(completed=False)
Ejemplo n.º 12
0
 def get_reminder_list(self):
     all_calendars = reminders.get_all_calendars()
     for calendar in all_calendars:
         if calendar.title == self.list_name:
             return calendar
     return self.create_reminder_list()
Ejemplo n.º 13
0
import reminders
cals = reminders.get_all_calendars()
print(cals)
import reminders

grocery_list = [
    'turkey', 'chicken', 'fish', 'eggs', 'carrots', 'broccoli', 'asparagus',
    'cauliflower', 'spinach', 'bananas', 'berries', 'almond milk', 'yogurt',
    'shredded cheese', 'string cheese', 'peanut butter', 'rice',
    'yukon potatoes', 'oats', 'bread'
]

# Creates reminder list if not exist
if 'Grocery' not in reminders.get_all_calendars():
    new_calendar = reminders.Calendar()
    new_calendar.title = 'Grocery'
    new_calendar.save()

# Adds each grocery item to reminder list
for item in grocery_list:
    for calendar in reminders.get_all_calendars():
        if calendar.title == 'Grocery':
            r = reminders.Reminder(calendar)
            r.title = item
            r.save()
            break