comparison env/lib/python3.7/site-packages/galaxy/util/ucsc.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
1 """
2 Utilities for dealing with UCSC data.
3 """
4
5
6 class UCSCLimitException(Exception):
7 pass
8
9
10 class UCSCOutWrapper(object):
11 """File-like object that throws an exception if it encounters the UCSC limit error lines"""
12
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
18 def __iter__(self):
19 return self
20
21 def __next__(self):
22 if self.lookahead is None:
23 line = next(self.other)
24 else:
25 line = self.lookahead
26 self.lookahead = None
27 if line.startswith("----------"):
28 next_line = next(self.other)
29 if next_line.startswith("Reached output limit"):
30 raise UCSCLimitException(next_line.strip())
31 else:
32 self.lookahead = next_line
33 return line
34
35 def next(self):
36 return self.__next__()
37
38 def readline(self):
39 return self.next()