예제 #1
0
def main():
    tests_dir = general.ROOT_DIR / 'tests'

    db_utils.clear_bills_db()

    general.init_db()

    # Load basic data
    for f in tests_dir.files('bill*.xml'):
        db_utils.db_create_bill(xml_utils.bill_of_file(f))

    # Add related bills
    for f in tests_dir.files('bill*.xml'):
        b = xml_utils.bill_of_file(f)
        b_obj = Bill.query.filter_by(id=b['id']).first()
        for r_id in b['related']:
            r_obj = Bill.query.filter_by(id=r_id).first()
            b_obj.related_bills.append(r_obj)

    general.close_db(write=True)

    # Create text index of summaries
    ix_utils.create_summary_index()
예제 #2
0
def main():
    tests_dir = general.ROOT_DIR / 'tests'

    db_utils.clear_bills_db()

    general.init_db()

    # Load basic data
    for f in tests_dir.files('bill*.xml'):
        db_utils.db_create_bill(xml_utils.bill_of_file(f))

    # Add related bills
    for f in tests_dir.files('bill*.xml'):
        b = xml_utils.bill_of_file(f)
        b_obj = Bill.query.filter_by(id=b['id']).first()
        for r_id in b['related']:
            r_obj = Bill.query.filter_by(id=r_id).first()
            b_obj.related_bills.append(r_obj)

    general.close_db(write=True)

    # Create text index of summaries
    ix_utils.create_summary_index()
예제 #3
0
def write_db():
    general.init_db()

    print "*** Writing XML bills to database"
    for session_num in general.CONGRESSES:
        s = str(session_num)

        sys.stdout.write('    Writing congress ' + s + '...')
        sys.stdout.flush()

        for f in xml_utils.files_of_session(s):
            b = db_create_bill(xml_utils.bill_of_file(f))

        print 'done'
    print ""

    general.close_db(write=True)
예제 #4
0
def write_db():
    general.init_db()
    
    print "*** Writing XML bills to database"
    for session_num in general.CONGRESSES:
        s = str(session_num)
    
        sys.stdout.write('    Writing congress ' +  s +  '...')
        sys.stdout.flush()

        for f in xml_utils.files_of_session(s):
            b = db_create_bill(xml_utils.bill_of_file(f))
    
        print 'done'    
    print ""

    general.close_db(write=True)
예제 #5
0
def write_db_related_bills():
    general.init_db()

    print "*** Writing related bills relations to database"
    for session_num in general.CONGRESSES:

        s = str(session_num)

        sys.stdout.write('    Writing congress ' + s + '...')
        sys.stdout.flush()

        for f in xml_utils.files_of_session(s):
            b = xml_utils.bill_of_file(f)
            b_obj = Bill.query.filter_by(id=b['id']).first()
            for r_id in b['related']:
                r_obj = Bill.query.filter_by(id=r_id).first()
                b_obj.related_bills.append(r_obj)

        print 'done'
    print ""

    general.close_db(write=True)
예제 #6
0
def write_db_related_bills():
    general.init_db()

    print "*** Writing related bills relations to database"
    for session_num in general.CONGRESSES:

        s = str(session_num)
    
        sys.stdout.write('    Writing congress ' +  s +  '...')
        sys.stdout.flush()

        for f in xml_utils.files_of_session(s):
            b = xml_utils.bill_of_file(f)
            b_obj = Bill.query.filter_by(id=b['id']).first()
            for r_id in b['related']:
                r_obj = Bill.query.filter_by(id=r_id).first()
                b_obj.related_bills.append(r_obj)
    
        print 'done'
    print ""

    general.close_db(write=True)