From b2dadbfb614395d2c2827b43c91cc2f798f990b9 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Fri, 14 Aug 2009 16:16:49 +0200 Subject: Allow to pass the number of elements in a vector --- portato/eix/parser.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'portato/eix/parser.py') diff --git a/portato/eix/parser.py b/portato/eix/parser.py index ebf2566..ecfb74c 100644 --- a/portato/eix/parser.py +++ b/portato/eix/parser.py @@ -63,8 +63,9 @@ def number (file, skip = False): return value -def vector (file, get_type, skip = False): - nelems = number(file) +def vector (file, get_type, skip = False, nelems = None): + if nelems is None: + nelems = number(file) if skip: for i in range(nelems): @@ -72,8 +73,11 @@ def vector (file, get_type, skip = False): else: return [get_type(file) for i in range(nelems)] -def typed_vector(type): - return partial(vector, get_type = type) +def typed_vector(type, nelems = None): + if nelems is None: + return partial(vector, get_type = type) + else: + return partial(vector, get_type = type, nelems = nelems) def string (file, skip = False): nelems = number(file) -- cgit v1.2.3-70-g09d2