#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Show sequence numbers of crystals and frames
#
# Copyright © 2015-2020 Deutsches Elektronen-Synchrotron DESY,
#                       a research centre of the Helmholtz Association.
#
# Author:
#    2015-2017 Thomas White <taw@physics.org>

import sys

f = open(sys.argv[1])

frame_number = 0
crystal_number = 0

while True:
    fline = f.readline()
    if not fline:
        break
    if fline.find("Image filename") != -1:
        frame_number += 1
        fn = fline.split(': ')[1].split(' ')[0].rstrip("\r\n")
        print('Frame {}: {}'.format(frame_number, fn))
    if fline.find("diffraction_resolution_limit") != -1:
        crystal_number += 1
        print('  Crystal {}: {}'.format(crystal_number, fline.rstrip("\r\n")))

f.close()
