def get(slug): path = get_path(slug, 'info') if not os.path.exists(path): raise GroupNotFound(slug) with open(get_path(slug, 'info')) as fp: group = Group(json.load(fp)) group.slug = slug return group
def get_post_comments(group, post): for comment_id in get_ids(group.get_path('comments', post.id)): with open(group.get_path('comments', post.id, comment_id)) as fp: comment = models.Comment(json.load(fp)) comment.post = post yield comment
def get_posts_by_ids(group, ids): for post_id in ids: with open(group.get_path('posts', post_id)) as fp: post = models.Post(json.load(fp)) post.group = group yield post