Ejemplo n.º 1
0
def _list(client, options, args):
    cal_user_list = client.get_calendar_user_list(options.cal)
    if not cal_user_list:
        LOG.error('No calendar matches "' + options.cal + '"')
        return
    titles_list = googlecl.build_titles_list(options.title, args)
    parser = DateRangeParser()
    date_range = parser.parse(options.date)
    for cal in cal_user_list:
        print ""
        print safe_encode("[" + unicode(cal) + "]")
        single_events = client.get_events(
            cal.user,
            start_date=date_range.start,
            end_date=date_range.end,
            titles=titles_list,
            query=options.query,
            split=False,
        )

        for entry in single_events:
            print googlecl.base.compile_entry_string(
                CalendarEntryToStringWrapper(entry, client.config),
                options.fields.split(","),
                delimiter=options.delimiter,
            )
Ejemplo n.º 2
0
def _run_delete(client, options, args):
    cal_user_list = client.get_calendar_user_list(options.cal)
    if not cal_user_list:
        LOG.error('No calendar matches "' + options.cal + '"')
        return
    parser = DateRangeParser()
    date_range = parser.parse(options.date)

    titles_list = googlecl.build_titles_list(options.title, args)
    for cal in cal_user_list:
        single_events, recurring_events = client.get_events(cal.user,
                                                            start_date=date_range.start,
                                                            end_date=date_range.end,
                                                            titles=titles_list,
                                                            query=options.query,
                                                            expand_recurrence=True)
        if options.prompt:
            LOG.info(safe_encode('For calendar ' + unicode(cal)))
        if single_events:
            client.DeleteEntryList(single_events, 'event', options.prompt)
        if recurring_events:
            if date_range.specified_as_range:
                # if the user specified a date that was a range...
                client.delete_recurring_events(recurring_events, date_range.start,
                                               date_range.end, cal.user, options.prompt)
            else:
                client.delete_recurring_events(recurring_events, date_range.start,
                                               None, cal.user, options.prompt)
        if not (single_events or recurring_events):
            LOG.warning('No events found that match your options!')
Ejemplo n.º 3
0
def _run_list_groups(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetGroups(titles_list)
    for entry in entries:
        print googlecl.base.compile_entry_string(
            ContactsEntryToStringWrapper(entry), ['name'],
            delimiter=options.delimiter)
Ejemplo n.º 4
0
def _run_delete(client, options, args):
    cal_user_list = client.get_calendar_user_list(options.cal)
    if not cal_user_list:
        LOG.error('No calendar matches "' + options.cal + '"')
        return
    parser = DateRangeParser()
    date_range = parser.parse(options.date)

    titles_list = googlecl.build_titles_list(options.title, args)
    for cal in cal_user_list:
        single_events, recurring_events = client.get_events(
            cal.user,
            start_date=date_range.start,
            end_date=date_range.end,
            titles=titles_list,
            query=options.query,
            expand_recurrence=True,
        )
        if options.prompt:
            LOG.info(safe_encode("For calendar " + unicode(cal)))
        if single_events:
            client.DeleteEntryList(single_events, "event", options.prompt)
        if recurring_events:
            if date_range.specified_as_range:
                # if the user specified a date that was a range...
                client.delete_recurring_events(
                    recurring_events, date_range.start, date_range.end, cal.user, options.prompt
                )
            else:
                client.delete_recurring_events(recurring_events, date_range.start, None, cal.user, options.prompt)
        if not (single_events or recurring_events):
            LOG.warning("No events found that match your options!")
Ejemplo n.º 5
0
def _run_tag(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    video_entries = client.GetVideos(titles=titles_list)
    if options.category:
        client.CategorizeVideos(video_entries, options.category)
    if options.tags:
        client.TagVideos(video_entries, options.tags)
Ejemplo n.º 6
0
def _run_tag(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    video_entries = client.GetVideos(titles=titles_list)
    if options.category:
        client.CategorizeVideos(video_entries, options.category)
    if options.tags:
        client.TagVideos(video_entries, options.tags)
Ejemplo n.º 7
0
def _run_list(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetContacts(titles_list)
    for entry in entries:
        print googlecl.base.compile_entry_string(
            ContactsEntryToStringWrapper(entry),
            options.fields.split(','),
            delimiter=options.delimiter)
Ejemplo n.º 8
0
def _run_list_groups(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetGroups(titles_list)
    for entry in entries:
        print googlecl.base.compile_entry_string(
            ContactsEntryToStringWrapper(entry),
            ['name'],
            delimiter=options.delimiter)
Ejemplo n.º 9
0
def _run_list(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetVideos(user=options.owner or 'default',
                               titles=titles_list)
    for vid in entries:
        print googlecl.base.compile_entry_string(VideoEntryToStringWrapper(vid),
                                                 options.fields.split(','),
                                                 delimiter=options.delimiter)
Ejemplo n.º 10
0
def _run_list(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetContacts(titles_list)
    for entry in entries:
        print googlecl.base.compile_entry_string(
            ContactsEntryToStringWrapper(entry),
            options.fields.split(','),
            delimiter=options.delimiter)
Ejemplo n.º 11
0
def _run_list(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetVideos(user=options.owner or 'default',
                               titles=titles_list)
    for vid in entries:
        print googlecl.base.compile_entry_string(
            VideoEntryToStringWrapper(vid),
            options.fields.split(','),
            delimiter=options.delimiter)
Ejemplo n.º 12
0
def _run_list_albums(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.build_entry_list(user=options.owner or options.user,
                                      titles=titles_list,
                                      force_photos=False)
    for entry in entries:
        print googlecl.base.compile_entry_string(AlbumEntryToStringWrapper(entry),
                                                 options.fields.split(','),
                                                 delimiter=options.delimiter)
Ejemplo n.º 13
0
def _run_list_albums(client, options, args):
  titles_list = googlecl.build_titles_list(options.title, args)
  entries = client.build_entry_list(user=options.owner or options.user,
                                    titles=titles_list,
                                    force_photos=False)
  for entry in entries:
    print googlecl.base.compile_entry_string(AlbumEntryToStringWrapper(entry),
                                             options.fields.split(','),
                                             delimiter=options.delimiter)
Ejemplo n.º 14
0
def _run_list(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    folder_entries = client.get_folder(options.folder)
    entries = client.get_doclist(titles_list, folder_entries)
    for entry in entries:
        print googlecl.base.compile_entry_string(
            googlecl.base.BaseEntryToStringWrapper(entry),
            options.fields.split(','),
            delimiter=options.delimiter)
Ejemplo n.º 15
0
def _run_list(client, options, args):
  titles_list = googlecl.build_titles_list(options.title, args)
  folder_entries = client.get_folder(options.folder)
  entries = client.get_doclist(titles_list, folder_entries)
  for entry in entries:
    print googlecl.base.compile_entry_string(
                               googlecl.base.BaseEntryToStringWrapper(entry),
                               options.fields.split(','),
                               delimiter=options.delimiter)
Ejemplo n.º 16
0
def _run_list(client, options, args):
  titles_list = googlecl.build_titles_list(options.title, args)
  entries = client.GetPosts(options.blog, titles_list,
                            user_id=options.owner or 'default')
  for entry in entries:
    print googlecl.base.compile_entry_string(
                                             BloggerEntryToStringWrapper(entry),
                                             options.fields.split(','),
                                             delimiter=options.delimiter)
Ejemplo n.º 17
0
def _run_list(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetPosts(options.blog,
                              titles_list,
                              user_id=options.owner or 'default')
    for entry in entries:
        print googlecl.base.compile_entry_string(
            BloggerEntryToStringWrapper(entry),
            options.fields.split(','),
            delimiter=options.delimiter)
Ejemplo n.º 18
0
def _run_list(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.build_entry_list(user=options.owner or options.user,
                                      titles=titles_list,
                                      query=options.query,
                                      force_photos=True,
                                      photo_title=options.photo)
    for entry in entries:
        print googlecl.base.compile_entry_string(PhotoEntryToStringWrapper(entry),
                                                 options.fields.split(','),
                                                 delimiter=options.delimiter)
Ejemplo n.º 19
0
def _run_get(client, options, args):
  if not options.dest:
    LOG.error('Must provide destination of album(s)!')
    return

  titles_list = googlecl.build_titles_list(options.title, args)
  client.DownloadAlbum(options.dest,
                       user=options.owner or options.user,
                       video_format=options.format or 'mp4',
                       titles=titles_list,
                       photo_title=options.photo)
Ejemplo n.º 20
0
def _run_tag(client, options, args):
  titles_list = googlecl.build_titles_list(options.title, args)
  entries = client.build_entry_list(user=options.owner or options.user,
                                    query=options.query,
                                    titles=titles_list,
                                    force_photos=True,
                                    photo_title=options.photo)
  if entries:
    client.TagPhotos(entries, options.tags, options.summary)
  else:
    LOG.error('No matches for the title and/or query you gave.')
Ejemplo n.º 21
0
def _run_get(client, options, args):
    if not options.dest:
        LOG.error('Must provide destination of album(s)!')
        return

    titles_list = googlecl.build_titles_list(options.title, args)
    client.DownloadAlbum(options.dest,
                         user=options.owner or options.user,
                         video_format=options.format or 'mp4',
                         titles=titles_list,
                         photo_title=options.photo)
Ejemplo n.º 22
0
def _run_tag(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.build_entry_list(user=options.owner or options.user,
                                      query=options.query,
                                      titles=titles_list,
                                      force_photos=True,
                                      photo_title=options.photo)
    if entries:
        client.TagPhotos(entries, options.tags, options.summary)
    else:
        LOG.error('No matches for the title and/or query you gave.')
Ejemplo n.º 23
0
def _run_list(client, options, args):
  titles_list = googlecl.build_titles_list(options.title, args)
  entries = client.build_entry_list(user=options.owner or options.user,
                                    titles=titles_list,
                                    query=options.query,
                                    force_photos=True,
                                    photo_title=options.photo)
  for entry in entries:
    print googlecl.base.compile_entry_string(PhotoEntryToStringWrapper(entry),
                                             options.fields.split(','),
                                             delimiter=options.delimiter)
Ejemplo n.º 24
0
def _run_get(client, options, args):
  if not hasattr(client, 'Download'):
    LOG.error('Downloading documents is not supported for' +
              ' gdata-python-client < 2.0')
    return
  titles_list = googlecl.build_titles_list(options.title, args)
  folder_entries = client.get_folder(options.folder)
  entries = client.get_doclist(titles_list, folder_entries)
  if not os.path.isdir(options.dest) and len(entries) > 1:
    LOG.error(googlecl.safe_encode(u'Specified multiple source files, but ' +
                                   u'destination "' + options.dest +
                                   u'" is not a directory'))
    return
  client.get_docs(options.dest, entries, file_ext=options.format)
Ejemplo n.º 25
0
def _run_get(client, options, args):
    if not hasattr(client, 'Download'):
        LOG.error('Downloading documents is not supported for' +
                  ' gdata-python-client < 2.0')
        return
    titles_list = googlecl.build_titles_list(options.title, args)
    folder_entries = client.get_folder(options.folder)
    entries = client.get_doclist(titles_list, folder_entries)
    if not os.path.isdir(options.dest) and len(entries) > 1:
        LOG.error(googlecl.safe_encode(u'Specified multiple source files, but ' +
                                       u'destination "' + options.dest +
                                       u'" is not a directory'))
        return
    client.get_docs(options.dest, entries, file_ext=options.format)
Ejemplo n.º 26
0
def _run_delete(client, options, args):
  if options.query or options.photo:
    entry_type = 'media'
    search_string = options.query
  else:
    entry_type = 'album'
    search_string = options.title

  titles_list = googlecl.build_titles_list(options.title, args)
  entries = client.build_entry_list(titles=titles_list,
                                    query=options.query,
                                    photo_title=options.photo)
  if not entries:
    LOG.info('No %ss matching %s' % (entry_type, search_string))
  else:
    client.DeleteEntryList(entries, entry_type, options.prompt)
Ejemplo n.º 27
0
def _run_delete(client, options, args):
    if options.query or options.photo:
        entry_type = 'media'
        search_string = options.query
    else:
        entry_type = 'album'
        search_string = options.title

    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.build_entry_list(titles=titles_list,
                                      query=options.query,
                                      photo_title=options.photo)
    if not entries:
        LOG.info('No %ss matching %s' % (entry_type, search_string))
    else:
        client.DeleteEntryList(entries, entry_type, options.prompt)
Ejemplo n.º 28
0
def _run_get(client, options, args):
    if not options.dest:
        LOG.error('Must provide destination of album(s)!')
        return

    titles_list = googlecl.build_titles_list(options.title, args)
    try:
        client.DownloadAlbum(options.dest,
                             user=options.owner or options.user,
                             video_format=options.format or 'mp4',
                             titles=titles_list,
                             photo_title=options.photo)
    except Exception as e:
        LOG.error("*" * 80)
        LOG.error("WARNING:DeprecatedAPI")
        LOG.error(e)
        LOG.error("*" * 80)
Ejemplo n.º 29
0
def _list(client, options, args):
    cal_user_list = client.get_calendar_user_list(options.cal)
    if not cal_user_list:
        LOG.error('No calendar matches "' + options.cal + '"')
        return
    titles_list = googlecl.build_titles_list(options.title, args)
    parser = DateRangeParser()
    date_range = parser.parse(options.date)
    for cal in cal_user_list:
        print ''
        print safe_encode('[' + unicode(cal) + ']')
        single_events = client.get_events(cal.user,
                                          start_date=date_range.start,
                                          end_date=date_range.end,
                                          titles=titles_list,
                                          query=options.query,
                                          split=False)

        for entry in single_events:
            print googlecl.base.compile_entry_string(
                CalendarEntryToStringWrapper(entry, client.config),
                options.fields.split(','),
                delimiter=options.delimiter)
Ejemplo n.º 30
0
def _run_delete(client, options, args):
  titles_list = googlecl.build_titles_list(options.title, args)
  post_entries = client.GetPosts(blog_title=options.blog,
                                 post_titles=titles_list)
  client.DeleteEntryList(post_entries, 'post', options.prompt)
Ejemplo n.º 31
0
def _run_delete(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetContacts(titles_list)
    client.DeleteEntryList(entries, 'contact', options.prompt)
Ejemplo n.º 32
0
def _run_add_groups(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    # XXX: Should the required option be src or title? It's a conceptual
    # toss-up.
    for group in titles_list:
        client.AddGroup(group)
Ejemplo n.º 33
0
def _run_delete_groups(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetGroups(titles_list)
    client.DeleteEntryList(entries, 'group', options.prompt)
Ejemplo n.º 34
0
def _run_delete(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetVideos(titles=titles_list)
    client.DeleteEntryList(entries, 'video', options.prompt)
Ejemplo n.º 35
0
def _run_delete(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetContacts(titles_list)
    client.DeleteEntryList(entries, 'contact', options.prompt)
Ejemplo n.º 36
0
def _run_delete(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetVideos(titles=titles_list)
    client.DeleteEntryList(entries, 'video', options.prompt)
Ejemplo n.º 37
0
def _run_add_groups(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    # XXX: Should the required option be src or title? It's a conceptual
    # toss-up.
    for group in titles_list:
        client.AddGroup(group)
Ejemplo n.º 38
0
def _run_delete_groups(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetGroups(titles_list)
    client.DeleteEntryList(entries, 'group', options.prompt)
Ejemplo n.º 39
0
def _run_tag(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    entries = client.GetPosts(options.blog, titles_list)
    client.LabelPosts(entries, options.tags)
Ejemplo n.º 40
0
def _run_delete(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    post_entries = client.GetPosts(blog_title=options.blog,
                                   post_titles=titles_list)
    client.DeleteEntryList(post_entries, 'post', options.prompt)
Ejemplo n.º 41
0
def _run_delete(client, options, args):
    titles_list = googlecl.build_titles_list(options.title, args)
    folder_entries = client.get_folder(options.folder)
    entries = client.get_doclist(titles_list, folder_entries)
    client.DeleteEntryList(entries, 'document', options.prompt)
Ejemplo n.º 42
0
def _run_tag(client, options, args):
  titles_list = googlecl.build_titles_list(options.title, args)
  entries = client.GetPosts(options.blog, titles_list)
  client.LabelPosts(entries, options.tags)
Ejemplo n.º 43
0
def _run_delete(client, options, args):
  titles_list = googlecl.build_titles_list(options.title, args)
  folder_entries = client.get_folder(options.folder)
  entries = client.get_doclist(titles_list, folder_entries)
  client.DeleteEntryList(entries, 'document', options.prompt)