Skip to content

Commit d83a4e2

Browse files
committed
Update foxfile.py
1 parent d7daab0 commit d83a4e2

File tree

1 file changed

+30
-50
lines changed

1 file changed

+30
-50
lines changed

foxfile.py

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -91,57 +91,37 @@ def handler(signum, frame):
9191
__version__ = pyfoxfile.__version__
9292

9393
# Initialize the argument parser
94-
argparser = argparse.ArgumentParser(
95-
description="Manipulate archive files.", conflict_handler="resolve", add_help=True)
94+
argparser = argparse.ArgumentParser(description="Manipulate archive files.", conflict_handler="resolve", add_help=True)
9695

9796
# Version information
98-
argparser.add_argument("-V", "--version", action="version",
99-
version=__program_name__ + " " + __version__)
97+
argparser.add_argument("-V", "--version", action="version", version=__program_name__ + " " + __version__)
10098
# Input and output specifications
101-
argparser.add_argument(
102-
"-i", "--input", nargs="+", help="Specify the file(s) to concatenate or the archive file to extract.", required=True)
103-
argparser.add_argument("-o", "--output", default=None,
104-
help="Specify the name for the extracted or output archive files.")
99+
argparser.add_argument("-i", "--input", nargs="+", help="Specify the file(s) to concatenate or the archive file to extract.", required=True)
100+
argparser.add_argument("-o", "--output", default=None, help="Specify the name for the extracted or output archive files.")
105101
# Operations
106-
argparser.add_argument("-c", "--create", action="store_true",
107-
help="Perform only the concatenation operation.")
108-
argparser.add_argument("-e", "--extract", action="store_true",
109-
help="Perform only the extraction operation.")
110-
argparser.add_argument("-t", "--convert", action="store_true",
111-
help="Convert a tar/zip/rar/7zip file to a archive file.")
112-
argparser.add_argument("-r", "--repack", action="store_true",
113-
help="Re-concatenate files, fixing checksum errors if any.")
102+
argparser.add_argument("-c", "--create", action="store_true", help="Perform only the concatenation operation.")
103+
argparser.add_argument("-e", "--extract", action="store_true", help="Perform only the extraction operation.")
104+
argparser.add_argument("-t", "--convert", action="store_true", help="Convert a tar/zip/rar/7zip file to a archive file.")
105+
argparser.add_argument("-r", "--repack", action="store_true", help="Re-concatenate files, fixing checksum errors if any.")
106+
argparser.add_argument("-S", "--filestart", type=int, default=0, help="Start reading file at.")
114107
# File manipulation options
115-
argparser.add_argument(
116-
"-F", "--format", default="auto", help="Specify the format to use.")
117-
argparser.add_argument(
118-
"-D", "--delimiter", default=__file_format_dict__['format_delimiter'], help="Specify the delimiter to use.")
119-
argparser.add_argument(
120-
"-m", "--formatver", default=__file_format_dict__['format_ver'], help="Specify the format version.")
121-
argparser.add_argument("-l", "--list", action="store_true",
122-
help="List files included in the archive file.")
108+
argparser.add_argument("-F", "--format", default="auto", help="Specify the format to use.")
109+
argparser.add_argument("-D", "--delimiter", default=__file_format_dict__['format_delimiter'], help="Specify the delimiter to use.")
110+
argparser.add_argument("-m", "--formatver", default=__file_format_dict__['format_ver'], help="Specify the format version.")
111+
argparser.add_argument("-l", "--list", action="store_true", help="List files included in the archive file.")
123112
# Compression options
124-
argparser.add_argument("-P", "--compression", default="auto",
125-
help="Specify the compression method to use for concatenation.")
126-
argparser.add_argument("-L", "--level", default=None,
127-
help="Specify the compression level for concatenation.")
128-
argparser.add_argument("-W", "--wholefile", action="store_true",
129-
help="Whole file compression method to use for concatenation.")
113+
argparser.add_argument("-P", "--compression", default="auto", help="Specify the compression method to use for concatenation.")
114+
argparser.add_argument("-L", "--level", default=None, help="Specify the compression level for concatenation.")
115+
argparser.add_argument("-W", "--wholefile", action="store_true", help="Whole file compression method to use for concatenation.")
130116
# Checksum and validation
131-
argparser.add_argument("-v", "--validate", action="store_true",
132-
help="Validate archive file checksums.")
133-
argparser.add_argument("-C", "--checksum", default="crc32",
134-
help="Specify the type of checksum to use. The default is crc32.")
135-
argparser.add_argument("-s", "--skipchecksum", action="store_true",
136-
help="Skip the checksum check of files.")
117+
argparser.add_argument("-v", "--validate", action="store_true", help="Validate archive file checksums.")
118+
argparser.add_argument("-C", "--checksum", default="crc32", help="Specify the type of checksum to use. The default is crc32.")
119+
argparser.add_argument("-s", "--skipchecksum", action="store_true", help="Skip the checksum check of files.")
137120
# Permissions and metadata
138-
argparser.add_argument("-p", "--preserve", action="store_false",
139-
help="Do not preserve permissions and timestamps of files.")
121+
argparser.add_argument("-p", "--preserve", action="store_false", help="Do not preserve permissions and timestamps of files.")
140122
# Miscellaneous
141-
argparser.add_argument("-d", "--verbose", action="store_true",
142-
help="Enable verbose mode to display various debugging information.")
143-
argparser.add_argument("-T", "--text", action="store_true",
144-
help="Read file locations from a text file.")
123+
argparser.add_argument("-d", "--verbose", action="store_true", help="Enable verbose mode to display various debugging information.")
124+
argparser.add_argument("-T", "--text", action="store_true", help="Read file locations from a text file.")
145125
# Parse the arguments
146126
getargs = argparser.parse_args()
147127

@@ -173,7 +153,7 @@ def handler(signum, frame):
173153
checkcompressfile = pyfoxfile.CheckCompressionSubType(
174154
input_file, fnamedict, True)
175155
if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
176-
tmpout = pyfoxfile.RePackFoxFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, False, 0, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
156+
tmpout = pyfoxfile.RePackFoxFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
177157
else:
178158
tmpout = pyfoxfile.PackFoxFileFromInFile(
179159
input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.verbose, False)
@@ -187,48 +167,48 @@ def handler(signum, frame):
187167
input_file, fnamedict, True)
188168
if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
189169
pyfoxfile.RePackFoxFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt,
190-
False, 0, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
170+
False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
191171
else:
192172
pyfoxfile.PackFoxFileFromInFile(input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.verbose, False)
193173
if(not tmpout):
194174
sys.exit(1)
195175
else:
196176
pyfoxfile.RePackFoxFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt,
197-
False, 0, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
177+
False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
198178
elif active_action == 'extract':
199179
if getargs.convert:
200180
checkcompressfile = pyfoxfile.CheckCompressionSubType(
201181
input_file, fnamedict, True)
202182
tempout = BytesIO()
203183
if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
204-
tmpout = pyfoxfile.RePackFoxFile(input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, False, 0, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, False, False)
184+
tmpout = pyfoxfile.RePackFoxFile(input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, False, False)
205185
else:
206186
tmpout = pyfoxfile.PackFoxFileFromInFile(
207187
input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, False, False)
208188
if(not tmpout):
209189
sys.exit(1)
210190
input_file = tempout
211-
pyfoxfile.UnPackFoxFile(input_file, getargs.output, False, 0, 0, 0, getargs.skipchecksum,
191+
pyfoxfile.UnPackFoxFile(input_file, getargs.output, False, getargs.filestart, 0, 0, getargs.skipchecksum,
212192
fnamedict, getargs.verbose, getargs.preserve, getargs.preserve, False, False)
213193
elif active_action == 'list':
214194
if getargs.convert:
215195
checkcompressfile = pyfoxfile.CheckCompressionSubType(
216196
input_file, fnamedict, True)
217197
if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
218-
tmpout = pyfoxfile.FoxFileListFiles(input_file, "auto", 0, 0, 0, getargs.skipchecksum, fnamedict, False, getargs.verbose, False, False)
198+
tmpout = pyfoxfile.FoxFileListFiles(input_file, "auto", getargs.filestart, 0, 0, getargs.skipchecksum, fnamedict, False, getargs.verbose, False, False)
219199
else:
220200
tmpout = pyfoxfile.InFileListFiles(input_file, getargs.verbose, fnamedict, False, False, False)
221201
if(not tmpout):
222202
sys.exit(1)
223203
else:
224-
pyfoxfile.FoxFileListFiles(input_file, "auto", 0, 0, getargs.skipchecksum, fnamedict, False, getargs.verbose, False, False)
204+
pyfoxfile.FoxFileListFiles(input_file, "auto", getargs.filestart, 0, 0, getargs.skipchecksum, fnamedict, False, getargs.verbose, False, False)
225205
elif active_action == 'validate':
226206
if getargs.convert:
227207
checkcompressfile = pyfoxfile.CheckCompressionSubType(
228208
input_file, fnamedict, True)
229209
tempout = BytesIO()
230210
if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
231-
tmpout = pyfoxfile.RePackFoxFile(input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, False, 0, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, False, False, False)
211+
tmpout = pyfoxfile.RePackFoxFile(input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, False, False, False)
232212
else:
233213
tmpout = pyfoxfile.PackFoxFileFromInFile(
234214
input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, False, False)

0 commit comments

Comments
 (0)