]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Use __init__ instead of init.
authorSjoerd Mullender <sjoerd@acm.org>
Mon, 8 Nov 1993 15:10:43 +0000 (15:10 +0000)
committerSjoerd Mullender <sjoerd@acm.org>
Mon, 8 Nov 1993 15:10:43 +0000 (15:10 +0000)
Also use CDDB_PATH and CDDB_WRITE_DIR environment variables in cddb.py.

Lib/irix5/cddb.py
Lib/irix5/cdplayer.py
Lib/irix5/readcd.doc
Lib/irix5/readcd.py
Lib/plat-irix5/cddb.py
Lib/plat-irix5/cdplayer.py
Lib/plat-irix5/readcd.doc
Lib/plat-irix5/readcd.py

index c233b5149fdd7e7713feb0a9b55e7a8487c24924..d7fdc96e9699127622dadc7c378dfe24cfbb7a9a 100755 (executable)
@@ -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')
index 2685a423edd520ce869ffafffbae30d74a85df56..5c2c95aa7fd868be27bacc36230d733750d04af1 100755 (executable)
@@ -4,8 +4,8 @@
 # Usage is as follows:
 #
 # import readcd
-# r = readcd.Readcd().init()
-# c = Cdplayer().init(r.gettrackinfo())
+# r = readcd.Readcd()
+# c = Cdplayer(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
@@ -17,7 +17,7 @@
 cdplayerrc = '.cdplayerrc'
 
 class Cdplayer:
-       def init(self, tracklist):
+       def __init__(self, tracklist):
                import string
                self.artist = ''
                self.title = ''
@@ -38,7 +38,7 @@ class Cdplayer:
                        import posix
                        f = open(posix.environ['HOME'] + '/' + cdplayerrc, 'r')
                except IOError:
-                       return self
+                       return
                import regex
                reg = regex.compile('^\\([^:]*\\):\t\\(.*\\)')
                s = self.id + '.'
@@ -62,7 +62,6 @@ class Cdplayer:
                                        trackno = string.atoi(name[6:])
                                        self.track[trackno] = value
                f.close()
-               return self
 
        def write(self):
                import posix
index b827cccc872b6859f33bfd92915f283c0e8dd43f..1be549c7904856a4b1e75f91fb065300757a1b73 100755 (executable)
@@ -18,7 +18,7 @@ read and the callbacks will be called.
 Initialization.
 ===============
 
-r = readcd.Readcd().init([cd-player [, mode]])
+r = readcd.Readcd([cd-player [, mode]])
 
 The optional arguments are the name of the CD device and the mode.
 When "mode" is not specified, it defaults to 'r' (which is the only
index 23c00ed074442dfbb251c1b584b7e82811e83935..7af6882b89d3e8f7886456a15c606617f76ec4a1 100755 (executable)
@@ -22,7 +22,7 @@ def _dopnum(self, cb_type, data):
                func(arg, cb_type, data)
 
 class Readcd:
-       def init(self, *arg):
+       def __init__(self, *arg):
                if len(arg) == 0:
                        self.player = cd.open()
                elif len(arg) == 1:
@@ -38,7 +38,6 @@ class Readcd:
                self.end = 0
                self.status = None
                self.trackinfo = None
-               return self
 
        def eject(self):
                self.player.eject()
index c233b5149fdd7e7713feb0a9b55e7a8487c24924..d7fdc96e9699127622dadc7c378dfe24cfbb7a9a 100755 (executable)
@@ -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')
index 2685a423edd520ce869ffafffbae30d74a85df56..5c2c95aa7fd868be27bacc36230d733750d04af1 100755 (executable)
@@ -4,8 +4,8 @@
 # Usage is as follows:
 #
 # import readcd
-# r = readcd.Readcd().init()
-# c = Cdplayer().init(r.gettrackinfo())
+# r = readcd.Readcd()
+# c = Cdplayer(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
@@ -17,7 +17,7 @@
 cdplayerrc = '.cdplayerrc'
 
 class Cdplayer:
-       def init(self, tracklist):
+       def __init__(self, tracklist):
                import string
                self.artist = ''
                self.title = ''
@@ -38,7 +38,7 @@ class Cdplayer:
                        import posix
                        f = open(posix.environ['HOME'] + '/' + cdplayerrc, 'r')
                except IOError:
-                       return self
+                       return
                import regex
                reg = regex.compile('^\\([^:]*\\):\t\\(.*\\)')
                s = self.id + '.'
@@ -62,7 +62,6 @@ class Cdplayer:
                                        trackno = string.atoi(name[6:])
                                        self.track[trackno] = value
                f.close()
-               return self
 
        def write(self):
                import posix
index b827cccc872b6859f33bfd92915f283c0e8dd43f..1be549c7904856a4b1e75f91fb065300757a1b73 100755 (executable)
@@ -18,7 +18,7 @@ read and the callbacks will be called.
 Initialization.
 ===============
 
-r = readcd.Readcd().init([cd-player [, mode]])
+r = readcd.Readcd([cd-player [, mode]])
 
 The optional arguments are the name of the CD device and the mode.
 When "mode" is not specified, it defaults to 'r' (which is the only
index 23c00ed074442dfbb251c1b584b7e82811e83935..7af6882b89d3e8f7886456a15c606617f76ec4a1 100755 (executable)
@@ -22,7 +22,7 @@ def _dopnum(self, cb_type, data):
                func(arg, cb_type, data)
 
 class Readcd:
-       def init(self, *arg):
+       def __init__(self, *arg):
                if len(arg) == 0:
                        self.player = cd.open()
                elif len(arg) == 1:
@@ -38,7 +38,6 @@ class Readcd:
                self.end = 0
                self.status = None
                self.trackinfo = None
-               return self
 
        def eject(self):
                self.player.eject()