Fork me on GitHub
Release:
Date:
1.3
Feb 14, 2012
Flattr Mktoc

Table Of Contents

Download

Get latest source archive,
mktoc-1.3.tar.gz, or install with:

pip install mktoc --upgrade --user

Found a Bug?

Fill out a report on the issue tracker.

This Page

3.5. mktoc.parser

This module provides object(s) to parse text files describing the layout of an audio CD. After the parse step is complete, it is possible to access the data or convert into any other output format.

The following are a list of the classes provided in this module:

class mktoc.parser.CueParser(dir_='.', find_wav=True)[source]

Bases: object

An audio CUE sheet text file parsing class.

By matching the known format of a CUE file, the relevant text information is extracted and converted to a binary representation. The binary representation is created by using combination of Disc, Track, and TrackIndex objects. With the data, the CUE file can be re-created or converted into a new format.

Parameters:
  • dir (str) – Path location of the CUE file’s directory.
  • find_wav (bool) – True/False, True causes exceptions to be raised if a WAV file can not be found in the FS.
parse(fh)[source]

Parses CUE file text data.

Parameters:fh (file) – An open file handle used to read the CUE text data
Returns:ParseData instance that mirrors the CUE data.
class mktoc.parser.WavParser(dir_='.', find_wav=True)[source]

Bases: object

A simple parser object that uses a list of WAV files to create a CD TOC.

The class assumes that each WAV file is an individual track, in ascending order.

Parameters:
  • dir (str) – Path location of the CUE file’s directory.
  • find_wav (bool) – True/False, True causes exceptions to be raised if a WAV file can not be found in the FS.
parse(wav_files)[source]

Parses a list of WAV files.

Parameters:wav_files (list) – WAV files to add to the TOC
Returns:ParseData instance that mirrors the WAV data.
class mktoc.parser.ParseData(disc, tracks, files)[source]

Bases: object

Stores parsed CD-ROM data and provides methods for modifcation and access.

Automatically generated by invoking the parse() method defined in one of the _Parser classes.

Initialize data structures.

Parameters:
  • disc (Disc) – CD info data object
  • tracks (list() of class:disc.Track) – a lost of objects with track info and indexes for each portion of the track.
  • files (list() of file name strs) – in-order list of WAV files associated with ‘tracks’
getToc()[source]

Access method to return a text stream of the CUE data in TOC format.

modWavOffset(samples, tmp=False)[source]

Optional method to correct the audio WAV data by shifting the samples by a positive or negative offset.

This can be used to compensate for a write offset in a CD/DVD burner. If the tmp variable is True, all new WAV files will be created in the :file;`/tmp` directory.

Parameters:
  • samples (int) – Number of samples to shift the audio data by. This value can be negative or positive.
  • tmp (bool) – True or False; when True any new WAV files will be created in /tmp.
last_index[source]

Reference to last index of last track.