* morituri/image/cue.py:

Use names for matches in regexps.
This commit is contained in:
Thomas Vander Stichele
2009-04-19 21:47:18 +00:00
parent a7e3779473
commit 68b6db9e10
2 changed files with 15 additions and 10 deletions

View File

@@ -1,3 +1,8 @@
2009-04-19 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/image/cue.py:
Use names for matches in regexps.
2009-04-19 Thomas Vander Stichele <thomas at apestaart dot org> 2009-04-19 Thomas Vander Stichele <thomas at apestaart dot org>
* examples/readtoc.py (added): * examples/readtoc.py (added):

View File

@@ -33,15 +33,15 @@ _PERFORMER_RE = re.compile("^PERFORMER\s(.*)$")
_TITLE_RE = re.compile("^TITLE\s(.*)$") _TITLE_RE = re.compile("^TITLE\s(.*)$")
_FILE_RE = re.compile(r""" _FILE_RE = re.compile(r"""
^FILE # FILE ^FILE # FILE
\s+"(.*)" # 'file name' in quotes \s+"(?P<name>.*)" # 'file name' in quotes
\s+(\w+)$ # format (WAVE/MP3/AIFF/...) \s+(?P<format>\w+)$ # format (WAVE/MP3/AIFF/...)
""", re.VERBOSE) """, re.VERBOSE)
_TRACK_RE = re.compile(r""" _TRACK_RE = re.compile(r"""
^\s+TRACK # TRACK ^\s+TRACK # TRACK
\s+(\d\d) # two-digit track number \s+(?P<track>\d\d) # two-digit track number
\s+(\w+)$ # mode (AUDIO/...) \s+(?P<mode>\w+)$ # mode (AUDIO/...)
""", re.VERBOSE) """, re.VERBOSE)
_INDEX_RE = re.compile(r""" _INDEX_RE = re.compile(r"""
@@ -83,8 +83,8 @@ class Cue:
# look for FILE lines # look for FILE lines
m = _FILE_RE.search(line) m = _FILE_RE.search(line)
if m: if m:
filePath = m.expand('\\1') filePath = m.group('name')
fileFormat = m.expand('\\2') fileFormat = m.group('format')
currentFile = File(filePath, fileFormat) currentFile = File(filePath, fileFormat)
# look for TRACK lines # look for TRACK lines
@@ -96,8 +96,8 @@ class Cue:
state = 'TRACK' state = 'TRACK'
trackNumber = int(m.expand('\\1')) trackNumber = int(m.group('track'))
trackMode = m.expand('\\2') trackMode = m.group('mode')
currentTrack = Track(trackNumber) currentTrack = Track(trackNumber)
self.tracks.append(currentTrack) self.tracks.append(currentTrack)