1
2
3
4
5
6 """Short helper functions (syntax sugar) used in Bio.Phylo.
7
8 The amount of code in this file should be kept to a minimum.
9 """
10 __docformat__ = "epytext en"
11
12
14 """Count the number of items in an iterable.
15
16 Exhausts a generator, but doesn't require creating a full list.
17 """
18 for i, x in enumerate(items):
19 count = i
20 return count + 1
21
22
24 """Truncate a string to maxlen characters, including ellipsis."""
25 assert isinstance(text, basestring), \
26 "%s should be a string, not a %s" % (text, type(text))
27 if len(text) > maxlen:
28 return text[:maxlen-3] + '...'
29 return text
30