(self, filename)
return wav
extract the code from the filename
extract the code from the filename
extract the code from the filename
def get_sobject_by_filename(self, filename):
        '''extract the code from the filename'''

        # EP01A_15_sometext.aiff
        # we can restrict the extension to aiff|mp3 if required in the future
        p = re.compile("(\w+)_(\d+)_(\w+).(\w+)")
        m = p.match(filename)
        if not m:
            return None
        groups = m.groups() 
        episode_code = "%s" % groups[0]
        line = groups[1]
        # verify the code
        from pyasm.prod.biz import Episode
        episode = Episode.get_by_code(episode_code)
        if not episode or not line:
            return None

        from pyasm.flash.biz import FinalWave
        wav = FinalWave.get(episode_code, line)
        if not wav:
            wav = FinalWave.create(episode_code, line)

        return wav
def get_sobject_by_filename ( self , filename ) : # EP01A_15_sometext.aiff # we can restrict the extension to aiff|mp3 if required in the future p = re . compile ( "(\w+)_(\d+)_(\w+).(\w+)" ) m = p . match ( filename ) if not m : return None groups = m . groups ( ) episode_code = "%s" % groups [ 0 ] line = groups [ 1 ] # verify the code from pyasm . prod . biz import Episode episode = Episode . get_by_code ( episode_code ) if not episode or not line : return None from pyasm . flash . biz import FinalWave wav = FinalWave . get ( episode_code , line ) if not wav : wav = FinalWave . create ( episode_code , line ) return wav