Skip to content

Commit c97284e

Browse files
committed
Add Python script to merge all box files
1 parent f4e8035 commit c97284e

File tree

4 files changed

+58
-4
lines changed

4 files changed

+58
-4
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<project name="jTessBoxEditor" default="default" basedir=".">
1111
<description>Builds, tests, and runs the project jTessBoxEditor.</description>
1212
<import file="nbproject/build-impl.xml"/>
13-
<property name="version" value="2.3.0"/>
13+
<property name="version" value="2.3.1"/>
1414

1515
<target name="-post-compile">
1616
<copy todir="${build.classes.dir}">

src/net/sourceforge/tessboxeditor/config.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
33
<properties>
44
<comment>Configuration File</comment>
5-
<entry key="ReleaseDate">2020/3/21</entry>
6-
<entry key="Version">v2.3.0</entry>
5+
<entry key="ReleaseDate">2020/6/10</entry>
6+
<entry key="Version">v2.3.1</entry>
77
</properties>

tools/mergeboxfiles.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Created by Seltix
2+
# 06-2020
3+
4+
import os
5+
import glob
6+
import re
7+
import argparse
8+
9+
parser = argparse.ArgumentParser(
10+
formatter_class=argparse.RawDescriptionHelpFormatter,
11+
description='''\
12+
description:
13+
This script will merge the content of all BOX files in the target folder.
14+
The result will be written to "all.box" in the same selected folder.''',
15+
epilog='''\
16+
--------------------------------
17+
Created by Seltix.''')
18+
parser.add_argument("path", nargs='?', default="", help="Target folder. Current directory will be used if not set")
19+
parser.add_argument("-q", "--quiet", action='store_true', dest='silent', help="Execute silently ( disable console output )")
20+
21+
args = parser.parse_args()
22+
23+
24+
args.path = args.path.rstrip('\\')
25+
if len(args.path) > 0:
26+
args.path = args.path + '\\'
27+
28+
29+
if os.path.exists(args.path + "all.box"):
30+
os.remove(args.path + "all.box")
31+
32+
33+
concat = ''
34+
i = 0
35+
for f in glob.glob(args.path + "*.box"):
36+
for line in open(f):
37+
concat = concat + re.sub(r'(.+) (\d+) (\d+) (\d+) (\d+) (\d+)', r"\1 \2 \3 \4 \5 " + str(i), line)
38+
i = i+1
39+
40+
41+
if i > 0:
42+
with open(args.path + "all.box", "w") as fo:
43+
fo.write(concat)
44+
45+
46+
if not args.silent:
47+
try:
48+
print(str(i) + " files merged!")
49+
input("Press Enter to continue...")
50+
except SyntaxError:
51+
pass

versionchanges.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,7 @@ Version 2.3.0 (21 March 2020)
140140
- Support reordering boxes through table row drag-and-drop
141141
- Fix column alignment
142142
- Upgrade Tesseract training executable 5.0.0-alpha (2020-02-23)
143-
- Update dependencies
143+
- Update dependencies
144+
145+
Version 2.3.1 (10 June 2020)
146+
- Add Python script to merge all box files

0 commit comments

Comments
 (0)