def output(self, t): if isinstance(t, list): return [self.output(pro) for pro in t] if not t: return None if isinstance(t, Teather): p = t.teathered_profile else: p = t res = itemize(p, 'eid', 'is_active', 'url') if isinstance(t, Teather): res['created_date'] = fdatetime(t.created_date) res['latitude'] = t.latitude res['longitude'] = t.longitude res['id'] = res['eid'] res['user'] = None if p.user: res['user'] = user.get().output(p.user) res['data'] = {} points = p.fetch_data(user=self.user) for p in points: res['data'][p.type and p.key+':'+p.type or p.key] = p.value return res
def out_file_with_all_changes(real_user, f, with_extracts=True): out = itemize(f, "eid", "name", "path", "full_path") out["changes"] = [] for change in f.get_changes(): ochange = out_change(real_user, change, with_extracts) ochange["digest"] = change.digest out["changes"].append(ochange) return out
def out_file_with_all_changes(real_user, f, with_extracts=True): out = itemize(f, 'eid', 'name', 'path', 'full_path') out['changes'] = [] for change in f.get_changes(): ochange = out_change(real_user, change, with_extracts) ochange['digest'] = change.digest out['changes'].append(ochange) return out
def out_comment(comment): out = itemize(comment, "eid", "body", "position", "created_date", "status") out["created_date"] = fdatetime(out["created_date"]) out["in_reply_to"] = comment.in_reply_to and comment.in_reply_to.eid or None out["creator"] = user.get().output(comment.creator) out["id"] = out["eid"] out["change"] = comment.change.eid out["change_version"] = comment.change.version out["extract"] = comment.change_extract and out_change_extract(comment.change_extract) or None out["completion_status"] = out_comment_status(comment.completion_status) return out
def out_comment(comment): out = itemize(comment, 'eid', 'body', 'position', 'created_date', 'status') out['created_date'] = fdatetime(out['created_date']) out['in_reply_to'] = comment.in_reply_to and comment.in_reply_to.eid or None out['creator'] = user.get().output(comment.creator) out['id'] = out['eid'] out['change'] = comment.change.eid out['change_version'] = comment.change.version out['extract'] = comment.change_extract and out_change_extract( comment.change_extract) or None out['completion_status'] = out_comment_status(comment.completion_status) return out
def out_change(real_user, change, with_extracts=True): out = itemize(change, "created_date", "size", "url", "thumbnail_url", "version", "number_comments", "parse_status") out["number_comments_open"] = change.get_number_comments(status=u"open") out["change_description"] = change.description out["change_eid"] = change.eid out["file_eid"] = change.entity.eid out["version"] = change.version out["created_date"] = fdatetime(out["created_date"]) out["url"] = change.base_url + out["url"] out["thumbnail_url"] = change.base_url + out["thumbnail_url"] out["creator"] = user.get().output(change.creator) if real_user and real_user.is_robot(): out.update(itemize(change, "parse_type")) if with_extracts: out["extracts"] = [] for ex in change.change_extracts: out["extracts"].append(out_change_extract(ex)) out["extracts"].sort(key=lambda x: x["order_index"]) return out
def out_change(real_user, change, with_extracts=True): out = itemize(change, 'created_date', 'size', 'url', 'thumbnail_url', 'version', 'number_comments', 'parse_status') out['number_comments_open'] = change.get_number_comments(status=u'open') out['change_description'] = change.description out['change_eid'] = change.eid out['file_eid'] = change.entity.eid out['version'] = change.version out['created_date'] = fdatetime(out['created_date']) out['url'] = change.base_url + out['url'] out['thumbnail_url'] = change.base_url + out['thumbnail_url'] out['creator'] = user.get().output(change.creator) if real_user and real_user.is_robot(): out.update(itemize(change, 'parse_type')) if with_extracts: out['extracts'] = [] for ex in change.change_extracts: out['extracts'].append(out_change_extract(ex)) out['extracts'].sort(key=lambda x: x['order_index']) return out
def out_file(real_user, filenchange): f, change = filenchange out = itemize(f, 'eid', 'name', 'path', 'description', 'full_path') out.update(out_change(real_user, change)) return out
def out_activity(act): #{{id}}', '{{type}}', '{{raw_date}}', '{{human_date}}', '{{tiny_message}}', '{{message}} out = itemize(act, 'id', 'type', 'tiny_message') out['message'] = act.get_message() out['created_date'] = fdatetime(act.created_date) return out
def output(self, proj): return itemize(proj, 'eid', 'name', 'description', 'slug')
def out_invite(inv): out = itemize(inv, 'eid', 'role', 'type', 'invited_email') out['object'] = inv.object.eid return out
def output(self, org): if isinstance(org, list): return [itemize(o, 'subdomain', 'name', 'eid') for o in org] return itemize(org, 'subdomain', 'name', 'eid')
def output(self, u): d = itemize(u, 'id', 'email', 'username', 'is_active', 'default_timezone') d['name'] = u.human_name return d
def out_activity(act): # {{id}}', '{{type}}', '{{raw_date}}', '{{human_date}}', '{{tiny_message}}', '{{message}} out = itemize(act, "id", "type", "tiny_message") out["message"] = act.get_message() out["created_date"] = fdatetime(act.created_date) return out
def output(self, u): d = itemize(u, "id", "email", "username", "is_active", "default_timezone") d["name"] = u.human_name return d
def output(self, org): if isinstance(org, list): return [itemize(o, "subdomain", "name", "eid") for o in org] return itemize(org, "subdomain", "name", "eid")
def out_change_extract(extract): edict = itemize(extract, "id", "order_index", "extract_type", "url", "description") edict["url"] = extract.base_url + edict["url"] return edict
def output(self, proj): return itemize(proj, "eid", "name", "description", "slug")
def out_file(real_user, filenchange): f, change = filenchange out = itemize(f, "eid", "name", "path", "description", "full_path") out.update(out_change(real_user, change)) return out
def out_directory(directory): return itemize(directory, "name", "path", "eid", "description", "full_path")
def out_directory(directory): return itemize(directory, 'name', 'path', 'eid', 'description', 'full_path')
def out_change_extract(extract): edict = itemize(extract, 'id', 'order_index', 'extract_type', 'url', 'description') edict['url'] = extract.base_url + edict['url'] return edict
def out_invite(inv): out = itemize(inv, "eid", "role", "type", "invited_email") out["object"] = inv.object.eid return out
def out_comment_status(cs): out = itemize(cs, 'created_date', 'status') out['created_date'] = fdatetime(out['created_date']) out['user'] = cs.user.human_name return out
def out_comment_status(cs): out = itemize(cs, "created_date", "status") out["created_date"] = fdatetime(out["created_date"]) out["user"] = cs.user.human_name return out
def output(self, u): return itemize(u, 'email', 'display_username', 'is_active', 'first_name', 'last_name', 'default_timezone')
def get_data_point(dp): return itemize(dp, 'key', 'value', 'type')