Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Backup all reminders in iOS Reminders app, using Pythonista 3.
import reminders
with open('BackedupReminder.txt', 'w', encoding='utf-8') as fo:
all_calendars = reminders.get_all_calendars()
fo.write('Reminder Backup\n\n')
fo.write('There are ' + str(len(reminders.get_reminders())) + ' reminders to back up.\n\n')
counter = 0
for calendar in all_calendars:
fo.write('Calendar title: ' + calendar.title + '\n')
fo.write('Calendar identifier: ' + calendar.identifier + '\n\n')
all_reminders = reminders.get_reminders(calendar=calendar, completed=None)
for reminder in all_reminders:
fo.write('Title: ' + reminder.title + '\n')
fo.write('Notes: ' + (reminder.notes or 'None') + '\n')
fo.write('Completed: ' + str(reminder.completed) + '\n')
fo.write('Completion_date: ' + str(reminder.completion_date or 'None') + '\n')
fo.write('Due_date: ' + str(reminder.due_date or 'None') + '\n')
if reminder.alarms:
for alarm in reminder.alarms:
fo.write('Alarm date: ' + str(alarm.date or 'None') + '\n')
fo.write('Alarm location: ' + str(alarm.location or 'None') + '\n')
fo.write('Alarm proximity: ' + str(alarm.proximity or 'None') + '\n')
else:
fo.write('Alarm: ' + 'None' + '\n')
fo.write('\n')
counter += 1
fo.write('\n')
fo.write('Backed up ' + str(counter) + ' reminders.\n')
if counter != len(reminders.get_reminders()):
error_sentence = 'There is inconsistency between reminders that exist and those that are backed up.'
fo.write(error_sentence + '\n')
print(error_sentence)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment