~ubuntu-branches/ubuntu/vivid/jack/vivid

« back to all changes in this revision

Viewing changes to jack_TOCentry.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2002-04-27 14:55:30 UTC
  • Revision ID: james.westby@ubuntu.com-20020427145530-nadgl6m4gf720goy
Tags: upstream-2.99.7
ImportĀ upstreamĀ versionĀ 2.99.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
### jack_TOCentry - class for CDDA TOCs - part ("module") of 
 
2
### jack - extract audio from a CD and MP3ify it using 3rd party software
 
3
### Copyright (C) 1999,2000  Arne Zellentin <arne@unix-ag.org>
 
4
 
 
5
### This program is free software; you can redistribute it and/or modify
 
6
### it under the terms of the GNU General Public License as published by
 
7
### the Free Software Foundation; either version 2 of the License, or
 
8
### (at your option) any later version.
 
9
 
 
10
### This program is distributed in the hope that it will be useful,
 
11
### but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
### GNU General Public License for more details.
 
14
 
 
15
### You should have received a copy of the GNU General Public License
 
16
### along with this program; if not, write to the Free Software
 
17
### Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 
 
19
entry_fields =  ['type', 'copy', 'preemphasis', 'channels', 'media',
 
20
                'filename', 'start', 'length', 'pregap']
 
21
compat_fields = ['number', 'length', 'start', 'copy', 'preemphasis', 'channels', 'rip', 'bitrate', 'rip_name']
 
22
 
 
23
class TOCentry:
 
24
 
 
25
    def __init__(self, raw_dict={}):
 
26
        self.number = None
 
27
        self.type = None
 
28
        self.copy = None            # means no
 
29
        self.preemphasis = None     # means no
 
30
        self.channels = None
 
31
        self.media = None           # "image" or "cd"
 
32
        self.image_name = None      # only for image-reader: name of image
 
33
        self.readable_name = None   # name the file is renamed to
 
34
        self.rip_name = None        # name of file while ripping / encoding
 
35
        self.pregap = 0
 
36
        self.start = None
 
37
        self.length = None
 
38
        self.bitrate = None         # compat?#XXX
 
39
        self.rip = None             # compat
 
40
 
 
41
        if raw_dict:    # for compatibility: allow to read old-style track info
 
42
            num = 1
 
43
            for i in compat_fields:
 
44
                self.__dict__[i] = raw_dict[num]
 
45
                num = num + 1
 
46
 
 
47
    def export(self):
 
48
        "compatibility"
 
49
        track = []
 
50
        for i in compat_fields:
 
51
            track.append(self.__dict__[i])
 
52
        return track
 
53
 
 
54
    # intercept setting of attributes
 
55
    def __setattr__(self, name, value):
 
56
        if name == 'pregap' and value:
 
57
            self.__dict__['start'] = self.start + (value - self.pregap)
 
58
            self.__dict__['length'] = self.length - (value - self.pregap)
 
59
            self.__dict__['pregap'] = value
 
60
 
 
61
        else:
 
62
            self.__dict__[name] = value
 
63
 
 
64
    # for debugging purposes only.
 
65
    def initialized(self):
 
66
        ok = 1
 
67
        for i in entry_fields:
 
68
            if not self.__dict__[i]:
 
69
                ok = 0
 
70
                break
 
71
        return ok