class baseband.helpers.sequentialfile.FileNameSequencer(template, header={})[source] [edit on github]

Bases: object

List-like generator of filenames using a template.

The template is formatted, filling in any items in curly brackets with values from the header. It is additionally possible to insert a file number equal to the indexing value, indicated with ‘{file_nr}’.

The length of the instance will be the number of files that exist that match the template for increasing values of the file number (when writing, it is the number of files that have so far been generated).


Template to format to get specific filenames. Curly bracket item keywords are case-sensitive (eg. ‘{FRAME_NR}’ or ‘{Frame_NR}’ will not use header['frame_nr'].


Structure holding key’d values that are used to fill in the format.


>>> from baseband import vdif
>>> from baseband.helpers import sequentialfile as sf
>>> vfs = sf.FileNameSequencer('a{file_nr:03d}.vdif')
>>> vfs[10]
>>> from import SAMPLE_VDIF
>>> with, 'rb') as fh:
...     header = vdif.VDIFHeader.fromfile(fh)
>>> vfs = sf.FileNameSequencer('obs.edv{edv:d}.{file_nr:05d}.vdif', header)
>>> vfs[10]