def atom_augmented_json(url=None): ''' Convert Atom syntax to Exhibit JSON, with some augmentation requested by James Leigh Sample request: * curl "http://localhost:8880/akara.augmented.json?url=http://picasaweb.google.com/data/feed/base/user/dysryi/albumid/5342439351589940049" ''' url = url[0] feed, entries = atomparse(url) for e in entries: e[u'feed_title'] = feed[u'title'] e[u'label'] = e[u'title'] if u'content_src' in e: e[u'depiction'] = e[u'content_src'] if u'link' in e: e[u'url'] = e[u'link'] return json.dumps({'items': entries}, indent=4)
raise except Exception, e: raise #print >> sys.stderr, e #print >> sys.stderr, 'Spreadsheet processing failure. No data to return.' imt = EXCEL_IMTS[0] elif isxml(body): if MODS_NAMESPACE in body: try: data, diag_info = mods2json(body, diagnostics) imt = 'application/x-mods+xml' except amara.ReaderError: raise ValueError('Unable to process content') else: try: data = atomparse(body) logger.debug("ATOM: " + repr(data)) except ValueError: data = webfeed(body) imt = 'application/rss+xml' if data is None: raise ValueError('Unable to process content') else: imt = ATOM_IMT else: lead = body.strip() if lead.startswith('%%') or lead.startswith('@'): #BibTex cmdline = 'bib2xml' process = Popen(cmdline, stdin=PIPE, stdout=PIPE, universal_newlines=True, shell=True) mods, perr = process.communicate(input=body)