def handle_adddocmeta(docid, court, casenum, de_seq_num, dm_id, docnum, subdocnum): docid = ParsePacer.coerce_docid(docid) query = Document.objects.filter(court=court, casenum=casenum, docnum=docnum, subdocnum=subdocnum) try: doc = query[0] except IndexError: doc = Document( docid=docid, court=court, casenum=casenum, de_seq_num=de_seq_num, dm_id=dm_id, docnum=docnum, subdocnum=subdocnum, ) else: doc.de_seq_num = de_seq_num doc.dm_id = dm_id doc.docnum = docnum doc.docid = docid try: doc.save() except IntegrityError: logging.error("handle_adddocmeta: could not save docid %s" % (docid))
def handle_adddocmeta(docid, court, casenum, de_seq_num, dm_id, docnum, subdocnum): docid = ParsePacer.coerce_docid(docid) query = Document.objects.filter(court=court, casenum=casenum, docnum=docnum, subdocnum=subdocnum) try: doc = query[0] except IndexError: doc = Document(docid=docid, court=court, casenum=casenum, de_seq_num=de_seq_num, dm_id=dm_id, docnum=docnum, subdocnum=subdocnum) else: doc.de_seq_num = de_seq_num doc.dm_id = dm_id doc.docnum = docnum doc.docid = docid try: doc.save() except IntegrityError: logging.error("handle_adddocmeta: could not save docid %s" % (docid))
def update_local_db(docket, ignore_available=1): court = docket.casemeta["court"] casenum = docket.casemeta["pacer_case_num"] for docmeta in docket.documents.values(): docnum = docmeta["doc_num"] subdocnum = docmeta["attachment_num"] docquery = Document.objects.filter(court=court, casenum=casenum, docnum=docnum, subdocnum=subdocnum) try: docentry = docquery[0] except IndexError: # Add this new document to our DB docentry = Document(court=court, casenum=casenum, docnum=docnum, subdocnum=subdocnum) try: docentry.docid = docmeta["pacer_doc_id"] except KeyError: pass try: docentry.de_seq_num = docmeta["pacer_de_seq_num"] except KeyError: pass try: docentry.dm_id = docmeta["pacer_dm_id"] except KeyError: pass try: docentry.sha1 = docmeta["sha1"] except KeyError: pass if not ignore_available: try: docentry.available = docmeta["available"] except KeyError: pass try: docentry.lastdate = docmeta["upload_date"] except KeyError: pass try: docentry.free_import = docmeta["free_import"] except KeyError: pass try: docentry.save() except IntegrityError: logging.error("update_local_db: could not save %s %s %s %s" % (court, casenum, docnum, subdocnum))
def update_local_db(docket, ignore_available=1, team_name=None): court = docket.casemeta["court"] casenum = docket.casemeta["pacer_case_num"] for docmeta in docket.documents.values(): docnum = docmeta["doc_num"] subdocnum = docmeta["attachment_num"] docquery = Document.objects.filter(court=court, casenum=casenum, docnum=docnum, subdocnum=subdocnum) try: docentry = docquery[0] except IndexError: # New item: Add it to our DB docentry = Document(court=court, casenum=casenum, docnum=docnum, subdocnum=subdocnum) if team_name is not None: # Only add the team_name to new items docentry.team_name = team_name except OperationalError: logging.error("update_local_db: could not save %s %s %s %s" % (court, casenum, docnum, subdocnum)) return try: docentry.docid = docmeta["pacer_doc_id"] except KeyError: pass try: docentry.de_seq_num = docmeta["pacer_de_seq_num"] except KeyError: pass try: docentry.dm_id = docmeta["pacer_dm_id"] except KeyError: pass try: docentry.sha1 = docmeta["sha1"] except KeyError: pass if not ignore_available: try: docentry.available = docmeta["available"] except KeyError: pass try: docentry.lastdate = docmeta["upload_date"] except KeyError: pass try: docentry.free_import = docmeta["free_import"] except KeyError: pass try: docentry.save() except IntegrityError: logging.error("update_local_db: could not save %s %s %s %s" % (court, casenum, docnum, subdocnum))