File createrepo-0.9.9-splitworkers.patch of Package createrepo

commit 96571b42608e3b45ce56b93f1f1851576bed916d
Author: James Antill <james@and.org>
Date:   Thu Feb 16 11:17:12 2012 -0500

    For for split problems due to floating point math (Eg. 9 workers and 5 pkgs).

diff --git a/createrepo/utils.py b/createrepo/utils.py
index 84a43ba..d66b115 100644
--- a/createrepo/utils.py
+++ b/createrepo/utils.py
@@ -183,12 +183,17 @@ def encodefiletypelist(filetypelist):
     return result
 
 def split_list_into_equal_chunks(seq, num_chunks):
+    if num_chunks <= 1:
+        return [seq[:]]
     avg = len(seq) / float(num_chunks)
     out = []
     last = 0.0
-    while last < len(seq):
+    #  Due to floating point math, we do one less than the number of chunks
+    # and then the rest. Eg. range(1,6), 9
+    while len(out) < (num_chunks - 1):
         out.append(seq[int(last):int(last + avg)])
         last += avg
+    out.append(seq[int(last):])
 
     return out
 
openSUSE Build Service is sponsored by