Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dcd3a87

Browse files
String method conversion.
1 parent 62f1a23 commit dcd3a87

2 files changed

Lines changed: 23 additions & 25 deletions

File tree

Lib/plat-irix5/cddb.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def tochash(toc):
3030
tracklist = []
3131
for i in range(2, len(toc), 4):
3232
tracklist.append((None,
33-
(string.atoi(toc[i:i+2]),
34-
string.atoi(toc[i+2:i+4]))))
33+
(int(toc[i:i+2]),
34+
int(toc[i+2:i+4]))))
3535
else:
3636
tracklist = toc
3737
ntracks = len(tracklist)
@@ -58,7 +58,7 @@ class Cddb:
5858
def __init__(self, tracklist):
5959
if os.environ.has_key('CDDB_PATH'):
6060
path = os.environ['CDDB_PATH']
61-
cddb_path = string.splitfields(path, ',')
61+
cddb_path = path.split(',')
6262
else:
6363
home = os.environ['HOME']
6464
cddb_path = [home + '/' + _cddbrc]
@@ -73,7 +73,7 @@ def __init__(self, tracklist):
7373
break
7474
except IOError:
7575
pass
76-
ntracks = string.atoi(self.id[:2], 16)
76+
ntracks = int(self.id[:2], 16)
7777
self.artist = ''
7878
self.title = ''
7979
self.track = [None] + [''] * ntracks
@@ -106,7 +106,7 @@ def __init__(self, tracklist):
106106
self.notes.append(value)
107107
elif name1[:5] == 'track':
108108
try:
109-
trackno = string.atoi(name1[5:])
109+
trackno = int(name1[5:])
110110
except strings.atoi_error:
111111
print 'syntax error in ' + file
112112
continue
@@ -126,9 +126,8 @@ def __init__(self, tracklist):
126126
# of previous track's title
127127
if track and track[0] == ',':
128128
try:
129-
off = string.index(self.track[i - 1],
130-
',')
131-
except string.index_error:
129+
off = self.track[i - 1].index(',')
130+
except ValueError:
132131
pass
133132
else:
134133
self.track[i] = self.track[i-1][:off] \
@@ -146,8 +145,8 @@ def _get_id(self, tracklist):
146145
t = []
147146
for i in range(2, len(tracklist), 4):
148147
t.append((None, \
149-
(string.atoi(tracklist[i:i+2]), \
150-
string.atoi(tracklist[i+2:i+4]))))
148+
(int(tracklist[i:i+2]), \
149+
int(tracklist[i+2:i+4]))))
151150
tracklist = t
152151
ntracks = len(tracklist)
153152
self.id = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF)
@@ -195,8 +194,8 @@ def write(self):
195194
f.write('track'+`i`+'.artist:\t'+self.trackartist[i]+'\n')
196195
track = self.track[i]
197196
try:
198-
off = string.index(track, ',')
199-
except string.index_error:
197+
off = track.index(',')
198+
except ValuError:
200199
prevpref = None
201200
else:
202201
if prevpref and track[:off] == prevpref:

Lib/plat-irix6/cddb.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def tochash(toc):
3030
tracklist = []
3131
for i in range(2, len(toc), 4):
3232
tracklist.append((None,
33-
(string.atoi(toc[i:i+2]),
34-
string.atoi(toc[i+2:i+4]))))
33+
(int(toc[i:i+2]),
34+
int(toc[i+2:i+4]))))
3535
else:
3636
tracklist = toc
3737
ntracks = len(tracklist)
@@ -58,7 +58,7 @@ class Cddb:
5858
def __init__(self, tracklist):
5959
if os.environ.has_key('CDDB_PATH'):
6060
path = os.environ['CDDB_PATH']
61-
cddb_path = string.splitfields(path, ',')
61+
cddb_path = path.split(',')
6262
else:
6363
home = os.environ['HOME']
6464
cddb_path = [home + '/' + _cddbrc]
@@ -73,7 +73,7 @@ def __init__(self, tracklist):
7373
break
7474
except IOError:
7575
pass
76-
ntracks = string.atoi(self.id[:2], 16)
76+
ntracks = int(self.id[:2], 16)
7777
self.artist = ''
7878
self.title = ''
7979
self.track = [None] + [''] * ntracks
@@ -106,8 +106,8 @@ def __init__(self, tracklist):
106106
self.notes.append(value)
107107
elif name1[:5] == 'track':
108108
try:
109-
trackno = string.atoi(name1[5:])
110-
except strings.atoi_error:
109+
trackno = int(name1[5:])
110+
except ValueError:
111111
print 'syntax error in ' + file
112112
continue
113113
if trackno > ntracks:
@@ -126,9 +126,8 @@ def __init__(self, tracklist):
126126
# of previous track's title
127127
if track and track[0] == ',':
128128
try:
129-
off = string.index(self.track[i - 1],
130-
',')
131-
except string.index_error:
129+
off = self.track[i - 1].index(',')
130+
except ValueError:
132131
pass
133132
else:
134133
self.track[i] = self.track[i-1][:off] \
@@ -146,8 +145,8 @@ def _get_id(self, tracklist):
146145
t = []
147146
for i in range(2, len(tracklist), 4):
148147
t.append((None, \
149-
(string.atoi(tracklist[i:i+2]), \
150-
string.atoi(tracklist[i+2:i+4]))))
148+
(int(tracklist[i:i+2]), \
149+
int(tracklist[i+2:i+4]))))
151150
tracklist = t
152151
ntracks = len(tracklist)
153152
self.id = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF)
@@ -195,8 +194,8 @@ def write(self):
195194
f.write('track'+`i`+'.artist:\t'+self.trackartist[i]+'\n')
196195
track = self.track[i]
197196
try:
198-
off = string.index(track, ',')
199-
except string.index_error:
197+
off = track.index(',')
198+
except ValueError:
200199
prevpref = None
201200
else:
202201
if prevpref and track[:off] == prevpref:

0 commit comments

Comments
 (0)