diff options
author | Sjoerd Mullender <sjoerd@acm.org> | 1993-11-08 15:10:43 (GMT) |
---|---|---|
committer | Sjoerd Mullender <sjoerd@acm.org> | 1993-11-08 15:10:43 (GMT) |
commit | b2e358d433e0ddbfc870d1a6ce12e7917388c2fe (patch) | |
tree | b504539fed3fec7238cb7b58c717126acc66555b /Lib/plat-irix5/cddb.py | |
parent | e65cce5eec23812d77a54095209c923937cc3c92 (diff) | |
download | cpython-b2e358d433e0ddbfc870d1a6ce12e7917388c2fe.zip cpython-b2e358d433e0ddbfc870d1a6ce12e7917388c2fe.tar.gz cpython-b2e358d433e0ddbfc870d1a6ce12e7917388c2fe.tar.bz2 |
Use __init__ instead of init.
Also use CDDB_PATH and CDDB_WRITE_DIR environment variables in cddb.py.
Diffstat (limited to 'Lib/plat-irix5/cddb.py')
-rwxr-xr-x | Lib/plat-irix5/cddb.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/plat-irix5/cddb.py b/Lib/plat-irix5/cddb.py index c233b51..d7fdc96 100755 --- a/Lib/plat-irix5/cddb.py +++ b/Lib/plat-irix5/cddb.py @@ -4,8 +4,8 @@ # Usage is as follows: # # import readcd -# r = readcd.Readcd().init() -# c = Cddb().init(r.gettrackinfo()) +# r = readcd.Readcd() +# c = Cddb(r.gettrackinfo()) # # Now you can use c.artist, c.title and c.track[trackno] (where trackno # starts at 1). When the CD is not recognized, all values will be the empty @@ -55,7 +55,7 @@ def tochash(toc): return hash class Cddb: - def init(self, tracklist): + def __init__(self, tracklist): if posix.environ.has_key('CDDB_PATH'): path = posix.environ['CDDB_PATH'] cddb_path = string.splitfields(path, ',') @@ -104,7 +104,7 @@ class Cddb: except IOError: pass if not hasattr(self, 'file'): - return self + return import regex reg = regex.compile('^\\([^.]*\\)\\.\\([^:]*\\):\t\\(.*\\)') while 1: @@ -138,14 +138,17 @@ class Cddb: continue self.track[trackno] = value f.close() - return self def write(self): + import posixpath if posix.environ.has_key('CDDB_WRITE_DIR'): dir = posix.environ['CDDB_WRITE_DIR'] else: dir = posix.environ['HOME'] + '/' + _cddbrc file = dir + '/' + self.id + '.rdb' + if posixpath.exists(file): + # make backup copy + posix.rename(file, file + '~') f = open(file, 'w') f.write('album.title:\t' + self.title + '\n') f.write('album.artist:\t' + self.artist + '\n') |