Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e202c38d
Commit
e202c38d
authored
Sep 06, 1994
by
Sjoerd Mullender
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Can now also give a hashed ID to Cddb.
parent
1f057546
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
82 deletions
+112
-82
Lib/irix5/cddb.py
Lib/irix5/cddb.py
+56
-41
Lib/plat-irix5/cddb.py
Lib/plat-irix5/cddb.py
+56
-41
No files found.
Lib/irix5/cddb.py
View file @
e202c38d
...
...
@@ -14,7 +14,7 @@
# You can then use c.write() to write out the changed values to the
# .cdplayerrc file.
import
string
,
posix
import
string
,
posix
,
os
_cddbrc
=
'.cddb'
_DB_ID_NTRACKS
=
5
...
...
@@ -56,45 +56,15 @@ def tochash(toc):
class
Cddb
:
def
__init__
(
self
,
tracklist
):
if
posix
.
environ
.
has_key
(
'CDDB_PATH'
):
path
=
posix
.
environ
[
'CDDB_PATH'
]
if
os
.
environ
.
has_key
(
'CDDB_PATH'
):
path
=
os
.
environ
[
'CDDB_PATH'
]
cddb_path
=
string
.
splitfields
(
path
,
','
)
else
:
home
=
posix
.
environ
[
'HOME'
]
home
=
os
.
environ
[
'HOME'
]
cddb_path
=
[
home
+
'/'
+
_cddbrc
]
self
.
artist
=
''
self
.
title
=
''
if
type
(
tracklist
)
==
type
(
''
):
t
=
[]
for
i
in
range
(
2
,
len
(
tracklist
),
4
):
t
.
append
((
None
,
\
(
string
.
atoi
(
tracklist
[
i
:
i
+
2
]),
\
string
.
atoi
(
tracklist
[
i
+
2
:
i
+
4
]))))
tracklist
=
t
ntracks
=
len
(
tracklist
)
self
.
track
=
[
None
]
+
[
''
]
*
ntracks
self
.
id
=
_dbid
((
ntracks
>>
4
)
&
0xF
)
+
_dbid
(
ntracks
&
0xF
)
if
ntracks
<=
_DB_ID_NTRACKS
:
nidtracks
=
ntracks
else
:
nidtracks
=
_DB_ID_NTRACKS
-
1
min
=
0
sec
=
0
for
track
in
tracklist
:
start
,
length
=
track
min
=
min
+
length
[
0
]
sec
=
sec
+
length
[
1
]
min
=
min
+
sec
/
60
sec
=
sec
%
60
self
.
id
=
self
.
id
+
_dbid
(
min
)
+
_dbid
(
sec
)
for
i
in
range
(
nidtracks
):
start
,
length
=
tracklist
[
i
]
self
.
id
=
self
.
id
+
_dbid
(
length
[
0
])
+
_dbid
(
length
[
1
])
self
.
toc
=
string
.
zfill
(
ntracks
,
2
)
for
track
in
tracklist
:
start
,
length
=
track
self
.
toc
=
self
.
toc
+
string
.
zfill
(
length
[
0
],
2
)
+
\
string
.
zfill
(
length
[
1
],
2
)
self
.
_get_id
(
tracklist
)
for
dir
in
cddb_path
:
file
=
dir
+
'/'
+
self
.
id
+
'.rdb'
try
:
...
...
@@ -103,6 +73,10 @@ class Cddb:
break
except
IOError
:
pass
ntracks
=
string
.
atoi
(
self
.
id
[:
2
],
16
)
self
.
artist
=
''
self
.
title
=
''
self
.
track
=
[
None
]
+
[
''
]
*
ntracks
if
not
hasattr
(
self
,
'file'
):
return
import
regex
...
...
@@ -123,6 +97,8 @@ class Cddb:
elif
name2
==
'title'
:
self
.
title
=
value
elif
name2
==
'toc'
:
if
not
self
.
toc
:
self
.
toc
=
value
if
self
.
toc
!=
value
:
print
'toc
\
'
s don
\
'
t match'
elif
name1
[:
5
]
==
'track'
:
...
...
@@ -142,7 +118,7 @@ class Cddb:
track
=
self
.
track
[
i
]
# if track title starts with `,', use initial part
# of previous track's title
if
track
[
0
]
==
','
:
if
track
and
track
[
0
]
==
','
:
try
:
off
=
string
.
index
(
self
.
track
[
i
-
1
],
','
)
...
...
@@ -152,12 +128,51 @@ class Cddb:
self
.
track
[
i
]
=
self
.
track
[
i
-
1
][:
off
]
\
+
track
def
_get_id
(
self
,
tracklist
):
# fill in self.id and self.toc.
# if the argument is a string ending in .rdb, the part
# upto the suffix is taken as the id.
if
type
(
tracklist
)
==
type
(
''
):
if
tracklist
[
-
4
:]
==
'.rdb'
:
self
.
id
=
tracklist
[:
-
4
]
self
.
toc
=
''
return
t
=
[]
for
i
in
range
(
2
,
len
(
tracklist
),
4
):
t
.
append
((
None
,
\
(
string
.
atoi
(
tracklist
[
i
:
i
+
2
]),
\
string
.
atoi
(
tracklist
[
i
+
2
:
i
+
4
]))))
tracklist
=
t
ntracks
=
len
(
tracklist
)
self
.
id
=
_dbid
((
ntracks
>>
4
)
&
0xF
)
+
_dbid
(
ntracks
&
0xF
)
if
ntracks
<=
_DB_ID_NTRACKS
:
nidtracks
=
ntracks
else
:
nidtracks
=
_DB_ID_NTRACKS
-
1
min
=
0
sec
=
0
for
track
in
tracklist
:
start
,
length
=
track
min
=
min
+
length
[
0
]
sec
=
sec
+
length
[
1
]
min
=
min
+
sec
/
60
sec
=
sec
%
60
self
.
id
=
self
.
id
+
_dbid
(
min
)
+
_dbid
(
sec
)
for
i
in
range
(
nidtracks
):
start
,
length
=
tracklist
[
i
]
self
.
id
=
self
.
id
+
_dbid
(
length
[
0
])
+
_dbid
(
length
[
1
])
self
.
toc
=
string
.
zfill
(
ntracks
,
2
)
for
track
in
tracklist
:
start
,
length
=
track
self
.
toc
=
self
.
toc
+
string
.
zfill
(
length
[
0
],
2
)
+
\
string
.
zfill
(
length
[
1
],
2
)
def
write
(
self
):
import
posixpath
if
posix
.
environ
.
has_key
(
'CDDB_WRITE_DIR'
):
dir
=
posix
.
environ
[
'CDDB_WRITE_DIR'
]
if
os
.
environ
.
has_key
(
'CDDB_WRITE_DIR'
):
dir
=
os
.
environ
[
'CDDB_WRITE_DIR'
]
else
:
dir
=
posix
.
environ
[
'HOME'
]
+
'/'
+
_cddbrc
dir
=
os
.
environ
[
'HOME'
]
+
'/'
+
_cddbrc
file
=
dir
+
'/'
+
self
.
id
+
'.rdb'
if
posixpath
.
exists
(
file
):
# make backup copy
...
...
Lib/plat-irix5/cddb.py
View file @
e202c38d
...
...
@@ -14,7 +14,7 @@
# You can then use c.write() to write out the changed values to the
# .cdplayerrc file.
import
string
,
posix
import
string
,
posix
,
os
_cddbrc
=
'.cddb'
_DB_ID_NTRACKS
=
5
...
...
@@ -56,45 +56,15 @@ def tochash(toc):
class
Cddb
:
def
__init__
(
self
,
tracklist
):
if
posix
.
environ
.
has_key
(
'CDDB_PATH'
):
path
=
posix
.
environ
[
'CDDB_PATH'
]
if
os
.
environ
.
has_key
(
'CDDB_PATH'
):
path
=
os
.
environ
[
'CDDB_PATH'
]
cddb_path
=
string
.
splitfields
(
path
,
','
)
else
:
home
=
posix
.
environ
[
'HOME'
]
home
=
os
.
environ
[
'HOME'
]
cddb_path
=
[
home
+
'/'
+
_cddbrc
]
self
.
artist
=
''
self
.
title
=
''
if
type
(
tracklist
)
==
type
(
''
):
t
=
[]
for
i
in
range
(
2
,
len
(
tracklist
),
4
):
t
.
append
((
None
,
\
(
string
.
atoi
(
tracklist
[
i
:
i
+
2
]),
\
string
.
atoi
(
tracklist
[
i
+
2
:
i
+
4
]))))
tracklist
=
t
ntracks
=
len
(
tracklist
)
self
.
track
=
[
None
]
+
[
''
]
*
ntracks
self
.
id
=
_dbid
((
ntracks
>>
4
)
&
0xF
)
+
_dbid
(
ntracks
&
0xF
)
if
ntracks
<=
_DB_ID_NTRACKS
:
nidtracks
=
ntracks
else
:
nidtracks
=
_DB_ID_NTRACKS
-
1
min
=
0
sec
=
0
for
track
in
tracklist
:
start
,
length
=
track
min
=
min
+
length
[
0
]
sec
=
sec
+
length
[
1
]
min
=
min
+
sec
/
60
sec
=
sec
%
60
self
.
id
=
self
.
id
+
_dbid
(
min
)
+
_dbid
(
sec
)
for
i
in
range
(
nidtracks
):
start
,
length
=
tracklist
[
i
]
self
.
id
=
self
.
id
+
_dbid
(
length
[
0
])
+
_dbid
(
length
[
1
])
self
.
toc
=
string
.
zfill
(
ntracks
,
2
)
for
track
in
tracklist
:
start
,
length
=
track
self
.
toc
=
self
.
toc
+
string
.
zfill
(
length
[
0
],
2
)
+
\
string
.
zfill
(
length
[
1
],
2
)
self
.
_get_id
(
tracklist
)
for
dir
in
cddb_path
:
file
=
dir
+
'/'
+
self
.
id
+
'.rdb'
try
:
...
...
@@ -103,6 +73,10 @@ class Cddb:
break
except
IOError
:
pass
ntracks
=
string
.
atoi
(
self
.
id
[:
2
],
16
)
self
.
artist
=
''
self
.
title
=
''
self
.
track
=
[
None
]
+
[
''
]
*
ntracks
if
not
hasattr
(
self
,
'file'
):
return
import
regex
...
...
@@ -123,6 +97,8 @@ class Cddb:
elif
name2
==
'title'
:
self
.
title
=
value
elif
name2
==
'toc'
:
if
not
self
.
toc
:
self
.
toc
=
value
if
self
.
toc
!=
value
:
print
'toc
\
'
s don
\
'
t match'
elif
name1
[:
5
]
==
'track'
:
...
...
@@ -142,7 +118,7 @@ class Cddb:
track
=
self
.
track
[
i
]
# if track title starts with `,', use initial part
# of previous track's title
if
track
[
0
]
==
','
:
if
track
and
track
[
0
]
==
','
:
try
:
off
=
string
.
index
(
self
.
track
[
i
-
1
],
','
)
...
...
@@ -152,12 +128,51 @@ class Cddb:
self
.
track
[
i
]
=
self
.
track
[
i
-
1
][:
off
]
\
+
track
def
_get_id
(
self
,
tracklist
):
# fill in self.id and self.toc.
# if the argument is a string ending in .rdb, the part
# upto the suffix is taken as the id.
if
type
(
tracklist
)
==
type
(
''
):
if
tracklist
[
-
4
:]
==
'.rdb'
:
self
.
id
=
tracklist
[:
-
4
]
self
.
toc
=
''
return
t
=
[]
for
i
in
range
(
2
,
len
(
tracklist
),
4
):
t
.
append
((
None
,
\
(
string
.
atoi
(
tracklist
[
i
:
i
+
2
]),
\
string
.
atoi
(
tracklist
[
i
+
2
:
i
+
4
]))))
tracklist
=
t
ntracks
=
len
(
tracklist
)
self
.
id
=
_dbid
((
ntracks
>>
4
)
&
0xF
)
+
_dbid
(
ntracks
&
0xF
)
if
ntracks
<=
_DB_ID_NTRACKS
:
nidtracks
=
ntracks
else
:
nidtracks
=
_DB_ID_NTRACKS
-
1
min
=
0
sec
=
0
for
track
in
tracklist
:
start
,
length
=
track
min
=
min
+
length
[
0
]
sec
=
sec
+
length
[
1
]
min
=
min
+
sec
/
60
sec
=
sec
%
60
self
.
id
=
self
.
id
+
_dbid
(
min
)
+
_dbid
(
sec
)
for
i
in
range
(
nidtracks
):
start
,
length
=
tracklist
[
i
]
self
.
id
=
self
.
id
+
_dbid
(
length
[
0
])
+
_dbid
(
length
[
1
])
self
.
toc
=
string
.
zfill
(
ntracks
,
2
)
for
track
in
tracklist
:
start
,
length
=
track
self
.
toc
=
self
.
toc
+
string
.
zfill
(
length
[
0
],
2
)
+
\
string
.
zfill
(
length
[
1
],
2
)
def
write
(
self
):
import
posixpath
if
posix
.
environ
.
has_key
(
'CDDB_WRITE_DIR'
):
dir
=
posix
.
environ
[
'CDDB_WRITE_DIR'
]
if
os
.
environ
.
has_key
(
'CDDB_WRITE_DIR'
):
dir
=
os
.
environ
[
'CDDB_WRITE_DIR'
]
else
:
dir
=
posix
.
environ
[
'HOME'
]
+
'/'
+
_cddbrc
dir
=
os
.
environ
[
'HOME'
]
+
'/'
+
_cddbrc
file
=
dir
+
'/'
+
self
.
id
+
'.rdb'
if
posixpath
.
exists
(
file
):
# make backup copy
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment