def collection_info(dbname, cname, **kwa): """Returns (str) info about collection documents. """ s = 'DB %s collection %s' % (dbname, cname) docs = find_docs(dbname, cname) if not docs: return s s += ' contains %d docs\n' % len(docs) docs = sorted(docs, key=my_sort_parameter) #, reverse=True doc = docs[0] s += '\n %s' % mu.document_keys(doc) # str(doc.keys()) _, title = mu.document_info(doc, **kwa) s += '\n doc# %s' % title for idoc, doc in enumerate(docs): vals,_ = mu.document_info(doc, **kwa) s += '\n %4d %s' % (idoc, vals) return s
def document_info(doc, keys=('time_sec','time_stamp','experiment',\ 'detector','ctype','run','id_data_ts','data_type','data_dtype', '_id'),\ fmt='%10s %24s %11s %24s %16s %4s %30s %10s %10s %24s'): """The same as dbu.document_info, but with different default parameters (added _id). """ return dbu.document_info(doc, keys, fmt)