def revtxt_subkey(review): subkey = "" if review["revtype"] == "book": subkey = safestr(review["author"]) if review["revtype"] == "music": subkey = safestr(review["artist"]) return subkey
def rev_text_from_spec(review, spec): txt = "" for cc in spec: if cc == "s": txt = space_conc(txt, revtxt_stars(review)) elif cc == "r": txt = space_conc(txt, review["revtype"]) elif cc == "t": txt = space_conc(txt, revtxt_title(review)) txt = space_conc(txt, revtxt_subkey(review)) elif cc == "k": txt = space_conc(txt, safestr(review["keywords"])) elif cc == "d": txt = space_conc(txt, safestr(review["text"])) elif cc == "v": txt = space_conc(txt, "|") return txt
def descrip(rev): revtext = rev.text or "" if revtext: # strip any newlines or similar annoyances revtext = re.sub('\s+', ' ', revtext) text = getTitle(rev) subkey = getSubkey(rev) if subkey: text += " - " + subkey assoc = secondaryFieldZip(rev) for av in assoc: if av[1]: text += ", " + safestr(av[1]) text += ". " + revtext text += " " + safestr(rev.keywords) if len(text) > 150: text = text[:150] + "..." text = re.sub('\"', '"', text) return text
def revtxt_title(review): names = ["yum", "activity", "other"] if review["revtype"] in names: return safestr(review["name"]) return safestr(review["title"])