def plate_from_qlp(qlbplate): """ Given a QLBPlate, find out what information we can automatically determine from the file name and location. """ dirname = qlbplate.file.dirname basename = qlbplate.file.basename complete_name = basename[:-4] # -- .qlp # assign box 2 boxes = Session.query(Box2).all() # TODO: rename as to not contain timestamp? # TODO-- this is probably bad (assumes parent directory like Box 2 Alpha 03) plate_name = qlbplate.file.dirname.split('/')[-1] plate = Plate(name=plate_name, program_version=qlbplate.host_software, run_time=datetime.strptime(qlbplate.host_datetime, '%Y:%m:%d %H:%M:%S') if qlbplate.host_datetime else None) for b in boxes: if qlbplate.file.dirname.startswith(b.src_dir): plate.box2 = b return plate