def make_doc(s, api_root, docsetid, year, groupid, docfname, url, srcurl, fsize, pagecount, note): m = YEAR_RE.match(year) if not m: raise ValueError("Year %s in metadata for %s doesn't look like a year." % (year, docfname)) year = year_to_western(*m.groups()) obj = {'docset_id': docsetid, 'year': year, 'group_id': groupid, 'filename': docfname, 'url': url, 'srcurl': srcurl, 'size': fsize, 'pages': pagecount, 'note': note} result = s.post(api_root + 'document', data=json.dumps(obj), verify=False).json() if 'id' not in result: raise ValueError('Document add: got back %s' % result) return result
def title_date(title): result = DATE_RE.search(title) if result is None: import pdb; pdb.set_trace() raise ValueError("Title didn't match expected format: %s" % title) (emp, year, month, day) = result.groups()[:4] year = int(year.strip()) month = int(month.strip()) day = int(day.strip()) year = year_to_western(emp, year) return date(year, month, day)