summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck.cuny@gmail.com>2017-06-16 08:46:42 -0700
committerFranck Cuny <franck.cuny@gmail.com>2017-06-16 08:46:42 -0700
commitb0910daa4bcfaadd750eb42c90408f3237708ec4 (patch)
treed9aae2e7bea5cf57576afbe1156bc54d3b1f70a4
parent[emacs] Add org-mode configuration once again. (diff)
downloademacs.d-b0910daa4bcfaadd750eb42c90408f3237708ec4.tar.gz
[bin] Add a script to split MH mirror set
Diffstat (limited to '')
-rwxr-xr-xbin/tw-mh-split-mirrorset.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/bin/tw-mh-split-mirrorset.py b/bin/tw-mh-split-mirrorset.py
new file mode 100755
index 0000000..4a3d228
--- /dev/null
+++ b/bin/tw-mh-split-mirrorset.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+import sys
+from collections import defaultdict
+
+
+def main():
+  input = sys.argv[1]
+  batch_number = sys.argv[2]
+  mms = {}
+
+  max_mmset_size = 0
+
+  with open(input, 'r') as f:
+    for l in f:
+      mm, hostname = l.rstrip().split(' ')
+      if mm not in mms:
+        mms[mm] = []
+      mms[mm].append(hostname)
+
+  max_mmset_size = max([len(mms[x]) for x in mms])
+
+  batches = {x: [] for x in range(0, max_mmset_size)}
+  for i in range(0, max_mmset_size):
+    for mm in mms:
+      if len(mms[mm]) -1 >= i:
+        batches[i].append(mms[mm][i])
+
+  for h in batches[int(batch_number)]:
+    print(h)
+
+
+if __name__ == '__main__':
+  main()