def albums(self, fields=None, idkeys=None, predicate=None):
        # format the keyword names correctly
        def smk(x):
            if x == "id": return x
            return smugmug_keyword(x)
        fields = [smk(x) for x in fields] if fields else []
        for i in range(len(fields)-1, -1, -1):
            f = fields[i]
            if not self.has_field(f):
                logger.warn("field {%s} doesn't exist" % (f))
                del fields[i]
                continue

        # if idkeys, fetch only those albums otherwise get them all
        if not idkeys:
            idkeys = list()
            for album in self.m.albums_get()["Albums"]:
                idkeys.append((album["id"], album["Key"]))

        # get the albums
        b = self.m.batch()
        for aid, akey in idkeys:
            b.albums_getInfo(AlbumID=aid, AlbumKey=akey)

        # work the results
        for params, results in b():
            album = results["Album"]
            name = album["Title"]

            if predicate:
                try:
                    if not predicate.test(album):
                        continue
                except Exception, e:
                    logger.warn("{%s} : predicate {%s} for album '%s'", e, predicate, name)
                    continue

            m = []
            if fields:
                for field in fields:
                    m.append((field, album.get(field, None)))
            else:
                category = album.get("Category", {}).get("Name", None)
                subcategory = album.get("SubCategory", {}).get("Name", None)
                m.append((category or u"", subcategory or u"", name))
            yield m
Finds albums, optionally matching a predicate.
dataset/ETHPy150Open bzimmer/pysmug/pysmug/smugfind.py/SmugFind.albums