root/galaxy-central/lib/galaxy/tools/exception_handling.py @ 2

リビジョン 2, 1.0 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1"""
2Exceptions and handlers for tools.
3
4FIXME: These are used by tool scripts, not the framework, and should not live
5       in this package.
6"""
7
8class UCSCLimitException( Exception ):
9    pass
10
11class UCSCOutWrapper( object ):
12    """File-like object that throws an exception if it encounters the UCSC limit error lines"""
13    def __init__( self, other ):
14        self.other = iter( other )
15        # Need one line of lookahead to be sure we are hitting the limit message
16        self.lookahead = None
17    def __iter__( self ):
18        return self
19    def next( self ):
20        if self.lookahead is None:
21            line = self.other.next()
22        else:
23            line = self.lookahead
24            self.lookahead = None
25        if line.startswith( "----------" ):
26            next_line = self.other.next()
27            if next_line.startswith( "Reached output limit" ):
28                raise UCSCLimitException( next_line.strip() )
29            else:
30                self.lookahead = next_line
31        return line
32    def readline(self):
33        return self.next()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。