Example #1
0
 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
Example #2
0
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
Example #3
0
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
Example #4
0
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
Example #5
0
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
Example #6
0
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
Example #7
0
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
Example #8
0
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
Example #9
0
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
Example #10
0
 def output(self, proj):
     return itemize(proj, 'eid', 'name', 'description', 'slug')
Example #11
0
def out_invite(inv):
    out = itemize(inv, 'eid', 'role', 'type', 'invited_email')
    out['object'] = inv.object.eid

    return out
Example #12
0
 def output(self, org):
     if isinstance(org, list):
         return [itemize(o, 'subdomain', 'name', 'eid') for o in org]
     return itemize(org, 'subdomain', 'name', 'eid')
Example #13
0
 def output(self, u):
     d = itemize(u, 'id', 'email', 'username', 'is_active',
                 'default_timezone')
     d['name'] = u.human_name
     return d
Example #14
0
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
Example #15
0
 def output(self, u):
     d = itemize(u, "id", "email", "username", "is_active", "default_timezone")
     d["name"] = u.human_name
     return d
Example #16
0
 def output(self, org):
     if isinstance(org, list):
         return [itemize(o, "subdomain", "name", "eid") for o in org]
     return itemize(org, "subdomain", "name", "eid")
Example #17
0
def out_change_extract(extract):
    edict = itemize(extract, "id", "order_index", "extract_type", "url", "description")
    edict["url"] = extract.base_url + edict["url"]
    return edict
Example #18
0
 def output(self, proj):
     return itemize(proj, "eid", "name", "description", "slug")
Example #19
0
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
Example #20
0
def out_directory(directory):
    return itemize(directory, "name", "path", "eid", "description", "full_path")
Example #21
0
def out_directory(directory):
    return itemize(directory, 'name', 'path', 'eid', 'description',
                   'full_path')
Example #22
0
def out_change_extract(extract):
    edict = itemize(extract, 'id', 'order_index', 'extract_type', 'url',
                    'description')
    edict['url'] = extract.base_url + edict['url']
    return edict
Example #23
0
def out_invite(inv):
    out = itemize(inv, "eid", "role", "type", "invited_email")
    out["object"] = inv.object.eid

    return out
Example #24
0
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
Example #25
0
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
Example #26
0
 def output(self, u):
     return itemize(u, 'email', 'display_username', 'is_active', 'first_name', 'last_name', 'default_timezone')
Example #27
0
def get_data_point(dp):
    return itemize(dp, 'key', 'value', 'type')