diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-10-12 14:46:48 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-10-12 14:46:48 +0300 |
commit | 097b28bbac511fbe6e7fb6a9ead29734c7c9c0d1 (patch) | |
tree | 3cd953d98631498618ecfcb393fa99b0ad4744d0 /outdated | |
parent | b8c8111374536c95c6f3c3299e50fad3dbdb9c45 (diff) | |
download | tools-097b28bbac511fbe6e7fb6a9ead29734c7c9c0d1.tar.gz tools-097b28bbac511fbe6e7fb6a9ead29734c7c9c0d1.tar.bz2 tools-097b28bbac511fbe6e7fb6a9ead29734c7c9c0d1.tar.xz tools-097b28bbac511fbe6e7fb6a9ead29734c7c9c0d1.zip |
Move reformat into oudated directory.
Diffstat (limited to 'outdated')
-rwxr-xr-x | outdated/reformat/redormat.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/outdated/reformat/redormat.py b/outdated/reformat/redormat.py new file mode 100755 index 0000000..75b2d95 --- /dev/null +++ b/outdated/reformat/redormat.py @@ -0,0 +1,72 @@ +#! /usr/bin/env python2.6 +# -*- coding: utf8 -*- + +import os +import re + +def calcSize(str): + sz = 0 + for chr in str: + if chr != '\t': + sz = sz + 1 + return sz + 1 + + + +strre = re.compile(",") +with open ("item_db.txt", "r") as r: + with open ("item_db2.txt", "w") as w: + lines = []; + for line in r: + arr = strre.split(line) + if line[0] == '#': + lines.append(line) + continue + text = [] + + for item in arr: + text.append(item.strip()) + + lines.append(text) + + maxSize = 0 + minSize = 100 + for line in lines: + if len(line[1]) > 1: + if len(line) > maxSize: + maxSize = len(line) + if len(line) < minSize: + minSize = len(line) + + minSize = 19 + sizes = [] + for k in range(0, minSize): + sz = 6 + for line in lines: + if len(line[k]) > sz: + sz = len(line[k]) + if sz < 3: + sz = 4 + elif sz > 6: + sz = 24 + sizes.append(sz + 1) + + print sizes + for k in range(0, minSize): + for line in lines: + if len(line[1]) > 1: + line[k] = line[k] + "," + while len(line[k]) < sizes[k]: + line[k] = line[k] + " " + + for line in lines: + if len(line[1]) == 1: + w.write(line) + else: + for item in line: + w.write(item) + w.write("\n") + + print minSize + print maxSize + |