-
Notifications
You must be signed in to change notification settings - Fork 3
/
openhjsplit.py
50 lines (45 loc) · 2.54 KB
/
openhjsplit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python3
########################################################################
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>.#
# #
# Copyright (C) 2013 by marcomg #
########################################################################
import argparse
import libhjsplit
import libitunitsconversion
try:
argParse = argparse.ArgumentParser(description='An open source alternative to hjsplit', prog='A file splitter and joiner')
argParse.add_argument('-v', '--version', action='version', version='%(prog)s version 1.0')
argParse.add_argument('-j', '--join', action='store_true', help='select if join files')
argParse.add_argument('-s', '--split', action='store_true', help='select if split files')
argParse.add_argument('-w', '--weight', action='store', type=str, help='the file size to split');
argParse.add_argument('-o', '--output', action='store', type=str, help='change the default output directory');
argParse.add_argument('patch', action='store', type=str, help='the file patch (if join the first file [with .001], if split the file to split)');
args = argParse.parse_args()
if args.join and args.split:
print('Or join or split, decide. Exiting...')
exit()
if args.join:
libhjsplit.join(args.patch, args.output)
elif args.split:
if args.weight == None:
print('Select the weight. Exiting...')
exit()
libhjsplit.split(args.patch, args.output, libitunitsconversion.getBytes(args.weight))
else:
print('Or join or split, decide. Exiting...')
exit()
except KeyboardInterrupt:
print(' is caught, exiting...')
exit()