comparison hglib/util.py @ 8:3ac38d500d68

move hgclient._eatlines to util
author Idan Kamara <idankk86@gmail.com>
date Wed, 10 Aug 2011 01:38:18 +0300
parents d7903b923217
children 5882a698ad5c
comparison
equal deleted inserted replaced
7:eac8be119d81 8:3ac38d500d68
2 2
3 def grouper(n, iterable): 3 def grouper(n, iterable):
4 ''' list(grouper(2, range(4))) -> [(0, 1), (2, 3)] ''' 4 ''' list(grouper(2, range(4))) -> [(0, 1), (2, 3)] '''
5 args = [iter(iterable)] * n 5 args = [iter(iterable)] * n
6 return itertools.izip(*args) 6 return itertools.izip(*args)
7
8 def eatlines(s, n):
9 idx = 0
10 for i in xrange(n):
11 idx = s.find('\n', idx) + 1
12
13 return s[idx:]
7 14
8 def cmdbuilder(name, *args, **kwargs): 15 def cmdbuilder(name, *args, **kwargs):
9 """ 16 """
10 A helper for building the command arguments 17 A helper for building the command arguments
11 18