diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2009-08-14 16:16:49 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2009-08-14 16:16:49 +0200 |
commit | b2dadbfb614395d2c2827b43c91cc2f798f990b9 (patch) | |
tree | 237e1866b20b9207619a079d80e195ce99e5718c | |
parent | a16cc9501a2a9b7910124caf11b77568e801433b (diff) | |
download | portato-b2dadbfb614395d2c2827b43c91cc2f798f990b9.tar.gz portato-b2dadbfb614395d2c2827b43c91cc2f798f990b9.tar.bz2 portato-b2dadbfb614395d2c2827b43c91cc2f798f990b9.zip |
Allow to pass the number of elements in a vector
Diffstat (limited to '')
-rw-r--r-- | portato/eix/parser.py | 12 |
1 files changed, 8 insertions, 4 deletions
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) |