On 11/17/05, Marcel Portela <[EMAIL PROTECTED]> wrote:
Hy guys, sory for de english...

>> Well, the issue is checking the disc for a file with an extension of
>> unknown case. The same work that my patch is doing must still be >done,
>> it'd just be nice to move it outside pycdg.py; I do think there's a
>> case-insensitive "find" workalike in Python. I should go look it up >:)

>Ah, gotcha. This is for finding the matching audio file.

in pycdg.py, you have the code that check your audio file, i've
extracted the piece of code below:

"""
        # Check there is a matching mp3 or ogg file
        validexts = [
                'wav', 'wAv', 'waV', 'wAV',
                'Wav', 'WAv', 'WaV', 'WAV',
                'mp3', 'mP3', 'Mp3', 'MP3',
                'ogg', 'oGg', 'ogG', 'oGG',
                'Ogg', 'OGg', 'OgG', 'OGG'
        ]

        matched = 0
        for ext in validexts:
                if (os.path.isfile(self.FileName[:-3] + ext)):
                        self.SoundFileName = self.FileName[:-3] + ext
                        matched = 1

"""

Yeah, I agree this is ugly :) 

You can do this check with a pythonic way:

"""
        # Check there is a matching mp3 or ogg file - pythonic way
        validexts = ['wav','mp3','ogg']

        matched = 0
        if (self.FileName[-3:].lower() in validexts):
                self.SoundFileName = self.FileName
                matched = 1
"""

Actually this doesn't quite do it; the purpose of this check is to look at the filesystem for a matching file. It's not enough just to check against the filename we're passed. Remember, self.FileName contains the .cdg passed from the command line; it will never match validexts.

--
Looking for something to read? Visit http://willfe.com/ ... it's easy, safe, and fun for the whole family!

Reply via email to