1
0
mirror of https://github.com/b4tman/sync_ics2gcal synced 2024-06-01 21:13:49 +00:00

add 'rename' command

This commit is contained in:
Dmitry Belyaev 2019-07-23 19:49:59 +03:00
parent a39e08db12
commit 87ffa78ccc
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3

View File

@ -30,6 +30,12 @@ def parse_args():
'remove', help='remove calendar')
parser_remove.add_argument(
'id', action='store', help='calendar id to remove')
parser_rename = command_subparsers.add_parser(
'rename', help='rename calendar')
parser_rename.add_argument(
'id', action='store', help='calendar id')
parser_rename.add_argument(
'summary', action='store', help='new summary')
args = parser.parse_args()
if args.command is None:
@ -68,6 +74,10 @@ def remove_calendar(service, id):
calendar.delete()
print('removed: {}'.format(id))
def rename_calendar(service, id, summary):
calendar = {'summary': summary}
service.calendars().patch(body=calendar, calendarId=id).execute()
print('{}: {}'.format(summary, id))
def main():
args = parse_args()
@ -87,6 +97,8 @@ def main():
add_owner(service, args.id, args.owner_email)
elif 'remove' == args.command:
remove_calendar(service, args.id)
elif 'rename' == args.command:
rename_calendar(service, args.id, args.summary)
if __name__ == '__main__':
main()