Пример #1
0
                'relative_of': child_external_id,
                'relative_type': 'parent',
            }))
        else:
            print('WARNING: Skipping unknown father ' + father_external_id)

    if mother_external_id != '0':
        if mother_patient_id:
            if not child_patient_id:
                print('WARNING: Adding unknown child ' + child_external_id + ' to ' + mother_patient_id)
            relatives.append((mother_patient_id, {
                'relative_of': child_external_id,
                'relative_type': 'parent',
            }))
        else:
            print('WARNING: Skipping unknown mother ' + mother_external_id)

    count += 1
    stdout.write(str(count) + '\r')

#begin import

if yes or input('You are about to import ' + str(len(relatives)) + ' relationships. Type y to continue: ')[0] == 'y':
    count = 0
    start_time = time.time()
    for relative in relatives:
        bot.create_relative(relative[0], relative[1])
        count += 1
        stdout.write(str(count) + '\r')
    print('All done! Elapsed time ' + str(timedelta(seconds=time.time() - start_time)))