Ejemplo n.º 1
0
    def add_hints (self, hints_list, insert = None):
        assert insert is None or isinstance (insert, IntType)

        queue = OperationsQueue()
        queue.abort_on_failure = False
        
        handler = self.Handler ()
        
        handler.prepare_queue (self, queue)
        
        i = 0
        for h in hints_list:
            pls = self.__filter_location (h["location"])
            
            if pls is not None and len (pls) > 0:
                # normalize the returning elements
                map(normalize_hints, pls)
                # We add this to the queue so it is
                # processed before the next file on the list
                queue.append (self.add_hints(pls, insert))
                continue
                
            ins = insert
            if insert != None:
                ins += i
            
            a = AddFile (self.music_list, h, ins, self._app())
            handler.prepare_add_file (self, a)
            
            queue.append (a)
            
            i += 1
        
        handler.finish_queue (self, queue)
        return queue
Ejemplo n.º 2
0
def write_files(app, files):
    """Helper function that takes a Serpentine application adds the files
    to the music list and writes them. When no `app` is provided a
    HeadlessApplication is created."""
    files = map(os.path.abspath, files)
    files = map(urlutil.normalize, files)
    queue = OperationsQueue()
    queue.append(app.add_files(files))
    queue.append(CallableOperation(lambda: app.write_files().start()))
    queue.start()