PyArchiveFile 0.26.0__py3-none-any.whl → 0.27.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyarchivefile-0.26.0.data → pyarchivefile-0.27.2.data}/scripts/archivefile.py +6 -6
- {pyarchivefile-0.26.0.dist-info → pyarchivefile-0.27.2.dist-info}/METADATA +1 -1
- pyarchivefile-0.27.2.dist-info/RECORD +8 -0
- pyarchivefile.py +907 -244
- pyarchivefile-0.26.0.data/scripts/archiveneofile.py +0 -130
- pyarchivefile-0.26.0.data/scripts/neoarchivefile.py +0 -136
- pyarchivefile-0.26.0.dist-info/RECORD +0 -10
- {pyarchivefile-0.26.0.dist-info → pyarchivefile-0.27.2.dist-info}/WHEEL +0 -0
- {pyarchivefile-0.26.0.dist-info → pyarchivefile-0.27.2.dist-info}/licenses/LICENSE +0 -0
- {pyarchivefile-0.26.0.dist-info → pyarchivefile-0.27.2.dist-info}/top_level.txt +0 -0
- {pyarchivefile-0.26.0.dist-info → pyarchivefile-0.27.2.dist-info}/zip-safe +0 -0
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
#!python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
4
|
-
|
|
5
|
-
import sys, os, io, argparse
|
|
6
|
-
|
|
7
|
-
try:
|
|
8
|
-
import pyarchivefile as P # core must provide *_neo functions
|
|
9
|
-
except Exception as e:
|
|
10
|
-
sys.stderr.write("Failed to import core module 'pyarchivefile': %s\n" % (e,))
|
|
11
|
-
sys.exit(2)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def _expand_combined_short_opts(argv):
|
|
15
|
-
out = [argv[0]]
|
|
16
|
-
i = 1
|
|
17
|
-
while i < len(argv):
|
|
18
|
-
a = argv[i]
|
|
19
|
-
if a.startswith("--") or not (a.startswith("-") and len(a) > 2):
|
|
20
|
-
out.append(a); i += 1; continue
|
|
21
|
-
for ch in a[1:]:
|
|
22
|
-
out.append("-" + ch)
|
|
23
|
-
i += 1
|
|
24
|
-
return out
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def main():
|
|
28
|
-
argv = _expand_combined_short_opts(sys.argv)
|
|
29
|
-
|
|
30
|
-
p = argparse.ArgumentParser(
|
|
31
|
-
description="PyNeoFile CLI (uses pyarchivefile core)")
|
|
32
|
-
g = p.add_mutually_exclusive_group(required=True)
|
|
33
|
-
g.add_argument("-l", "--list", action="store_true", help="List archive")
|
|
34
|
-
g.add_argument("-e", "--extract", action="store_true", help="Extract archive")
|
|
35
|
-
g.add_argument("-c", "--create", action="store_true", help="Create archive from path")
|
|
36
|
-
g.add_argument("-r", "--repack", action="store_true", help="Repack (recompress) an archive")
|
|
37
|
-
g.add_argument("-E", "--empty", action="store_true", help="Create an empty archive")
|
|
38
|
-
|
|
39
|
-
p.add_argument("-i", "--input", help="Input file/path", nargs="*")
|
|
40
|
-
p.add_argument("-o", "--output", help="Output file/dir (or '-' for stdout)")
|
|
41
|
-
p.add_argument("-d", "--verbose", action="store_true", help="Verbose/detailed listing")
|
|
42
|
-
p.add_argument("-P", "--compression", default="auto", help="Compression algo (auto, none, zlib, gzip, bz2, lzma)")
|
|
43
|
-
p.add_argument("-L", "--level", type=int, default=None, help="Compression level/preset")
|
|
44
|
-
p.add_argument("--checksum", default="crc32", help="Checksum type for header/content/json (default: crc32)")
|
|
45
|
-
|
|
46
|
-
args = p.parse_args(argv[1:])
|
|
47
|
-
|
|
48
|
-
src = None
|
|
49
|
-
if args.input:
|
|
50
|
-
if isinstance(args.input, list) and len(args.input) == 1:
|
|
51
|
-
src = args.input[0]
|
|
52
|
-
elif isinstance(args.input, list) and len(args.input) > 1:
|
|
53
|
-
src = args.input[0]
|
|
54
|
-
else:
|
|
55
|
-
src = args.input
|
|
56
|
-
|
|
57
|
-
if args.empty:
|
|
58
|
-
dst = args.output or "-"
|
|
59
|
-
blob_or_true = P.make_empty_file_neo(dst, fmttype="auto", checksumtype=args.checksum, encoding="UTF-8", returnfp=False)
|
|
60
|
-
if dst in (None, "-"):
|
|
61
|
-
data = blob_or_true if isinstance(blob_or_true, (bytes, bytearray)) else b""
|
|
62
|
-
if hasattr(sys.stdout, "buffer"):
|
|
63
|
-
sys.stdout.buffer.write(data)
|
|
64
|
-
else:
|
|
65
|
-
sys.stdout.write(data.decode("latin1"))
|
|
66
|
-
return 0
|
|
67
|
-
|
|
68
|
-
if args.list:
|
|
69
|
-
if not src:
|
|
70
|
-
p.error("list requires -i <archive>")
|
|
71
|
-
P.archivefilelistfiles_neo(src, advanced=args.verbose, include_dirs=True)
|
|
72
|
-
return 0
|
|
73
|
-
|
|
74
|
-
if args.extract:
|
|
75
|
-
if not src:
|
|
76
|
-
p.error("extract requires -i <archive>")
|
|
77
|
-
outdir = args.output or "."
|
|
78
|
-
ok = P.unpack_neo(src, outdir, skipchecksum=False, uncompress=True)
|
|
79
|
-
return 0 if ok else 1
|
|
80
|
-
|
|
81
|
-
if args.create:
|
|
82
|
-
if not src:
|
|
83
|
-
p.error("create requires -i <path>")
|
|
84
|
-
if args.verbose:
|
|
85
|
-
walkroot = src
|
|
86
|
-
if os.path.isdir(walkroot):
|
|
87
|
-
print(walkroot)
|
|
88
|
-
for root, dirs, files in os.walk(walkroot):
|
|
89
|
-
relroot = root if root.startswith("./") else "./" + root.replace("\\", "/")
|
|
90
|
-
if root != walkroot:
|
|
91
|
-
print(relroot)
|
|
92
|
-
for name in sorted(files):
|
|
93
|
-
path = os.path.join(root, name).replace("\\", "/")
|
|
94
|
-
if not path.startswith("./"):
|
|
95
|
-
path = "./" + path
|
|
96
|
-
print(path)
|
|
97
|
-
else:
|
|
98
|
-
path = src if src.startswith("./") else "./" + src
|
|
99
|
-
print(path)
|
|
100
|
-
|
|
101
|
-
outpath = args.output or "-"
|
|
102
|
-
ok = P.pack_neo(src, outpath, checksumtypes=(args.checksum,args.checksum,args.checksum,args.checksum),
|
|
103
|
-
encoding="UTF-8", compression=args.compression, compression_level=args.level)
|
|
104
|
-
if outpath in (None, "-") and isinstance(ok, (bytes, bytearray)):
|
|
105
|
-
if hasattr(sys.stdout, "buffer"):
|
|
106
|
-
sys.stdout.buffer.write(ok)
|
|
107
|
-
else:
|
|
108
|
-
sys.stdout.write(ok.decode("latin1"))
|
|
109
|
-
return 0
|
|
110
|
-
return 0 if ok else 1
|
|
111
|
-
|
|
112
|
-
if args.repack:
|
|
113
|
-
if not src:
|
|
114
|
-
p.error("repack requires -i <archive>")
|
|
115
|
-
outpath = args.output or "-"
|
|
116
|
-
ok = P.repack_neo(src, outpath, checksumtypes=(args.checksum,args.checksum,args.checksum,args.checksum),
|
|
117
|
-
compression=args.compression, compression_level=args.level)
|
|
118
|
-
if outpath in (None, "-") and isinstance(ok, (bytes, bytearray)):
|
|
119
|
-
if hasattr(sys.stdout, "buffer"):
|
|
120
|
-
sys.stdout.buffer.write(ok)
|
|
121
|
-
else:
|
|
122
|
-
sys.stdout.write(ok.decode("latin1"))
|
|
123
|
-
return 0
|
|
124
|
-
return 0 if ok else 1
|
|
125
|
-
|
|
126
|
-
return 0
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if __name__ == "__main__":
|
|
130
|
-
sys.exit(main())
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
#!python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
'''
|
|
5
|
-
This program is free software; you can redistribute it and/or modify
|
|
6
|
-
it under the terms of the Revised BSD License.
|
|
7
|
-
|
|
8
|
-
This program is distributed in the hope that it will be useful,
|
|
9
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
-
Revised BSD License for more details.
|
|
12
|
-
|
|
13
|
-
Copyright 2018-2024 Cool Dude 2k - http://idb.berlios.de/
|
|
14
|
-
Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
15
|
-
Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
16
|
-
|
|
17
|
-
$FileInfo: neoarchivefile.py - Last Update: 8/26/2025 Ver. 0.21.4 RC 1 - Author: cooldude2k $
|
|
18
|
-
'''
|
|
19
|
-
|
|
20
|
-
from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
|
|
21
|
-
import argparse
|
|
22
|
-
import pyarchivefile
|
|
23
|
-
|
|
24
|
-
__project__ = pyarchivefile.__project__
|
|
25
|
-
__program_name__ = pyarchivefile.__program_name__
|
|
26
|
-
__file_format_name__ = pyarchivefile.__file_format_name__
|
|
27
|
-
__file_format_magic__ = pyarchivefile.__file_format_magic__
|
|
28
|
-
__file_format_len__ = pyarchivefile.__file_format_len__
|
|
29
|
-
__file_format_hex__ = pyarchivefile.__file_format_hex__
|
|
30
|
-
__file_format_delimiter__ = pyarchivefile.__file_format_delimiter__
|
|
31
|
-
__file_format_dict__ = pyarchivefile.__file_format_dict__
|
|
32
|
-
__file_format_default__ = pyarchivefile.__file_format_default__
|
|
33
|
-
__use_new_style__ = pyarchivefile.__use_new_style__
|
|
34
|
-
__use_advanced_list__ = pyarchivefile.__use_advanced_list__
|
|
35
|
-
__use_alt_inode__ = pyarchivefile.__use_alt_inode__
|
|
36
|
-
__project_url__ = pyarchivefile.__project_url__
|
|
37
|
-
__version_info__ = pyarchivefile.__version_info__
|
|
38
|
-
__version_date_info__ = pyarchivefile.__version_date_info__
|
|
39
|
-
__version_date__ = pyarchivefile.__version_date__
|
|
40
|
-
__version_date_plusrc__ = pyarchivefile.__version_date_plusrc__
|
|
41
|
-
__version__ = pyarchivefile.__version__
|
|
42
|
-
|
|
43
|
-
# Compatibility layer for Python 2 and 3 input
|
|
44
|
-
try:
|
|
45
|
-
input = raw_input
|
|
46
|
-
except NameError:
|
|
47
|
-
pass
|
|
48
|
-
|
|
49
|
-
# Determine if rar file support is enabled
|
|
50
|
-
rarfile_support = pyarchivefile.rarfile_support
|
|
51
|
-
py7zr_support = pyarchivefile.py7zr_support
|
|
52
|
-
|
|
53
|
-
# Set up the argument parser
|
|
54
|
-
argparser = argparse.ArgumentParser(
|
|
55
|
-
description="Manipulates archive files for various operations like creation, extraction, and validation.")
|
|
56
|
-
argparser.add_argument("-V", "--version", action="version", version="{0} {1}".format(
|
|
57
|
-
__program_name__, __version__), help="Displays the program's version.")
|
|
58
|
-
argparser.add_argument("-i", "--input", nargs="+", required=True,
|
|
59
|
-
help="Specifies input file(s) for processing.")
|
|
60
|
-
argparser.add_argument(
|
|
61
|
-
"-o", "--output", help="Specifies the output file name.")
|
|
62
|
-
argparser.add_argument("-d", "--verbose", action="store_true",
|
|
63
|
-
help="Enables verbose mode for detailed information.")
|
|
64
|
-
argparser.add_argument("-c", "--create", action="store_true",
|
|
65
|
-
help="Creates a new archive file from input.")
|
|
66
|
-
argparser.add_argument("-e", "--extract", action="store_true",
|
|
67
|
-
help="Extracts files from a archive archive.")
|
|
68
|
-
argparser.add_argument("-l", "--list", action="store_true",
|
|
69
|
-
help="Lists contents of a specified archive file.")
|
|
70
|
-
argparser.add_argument("-r", "--repack", action="store_true",
|
|
71
|
-
help="Repacks an existing archive file.")
|
|
72
|
-
argparser.add_argument("-v", "--validate", action="store_true",
|
|
73
|
-
help="Validates a archive file's integrity.")
|
|
74
|
-
argparser.add_argument("--checksum", default="crc32",
|
|
75
|
-
help="Specifies the checksum type (default: crc32).")
|
|
76
|
-
argparser.add_argument("--compression", default="auto",
|
|
77
|
-
help="Specifies the compression method (default: auto).")
|
|
78
|
-
argparser.add_argument("--level", help="Specifies the compression level.")
|
|
79
|
-
argparser.add_argument("--preserve", action="store_true",
|
|
80
|
-
help="Preserves file attributes when extracting.")
|
|
81
|
-
argparser.add_argument("--convert", choices=['tar', 'zip', '7zip', 'rar'],
|
|
82
|
-
help="Convert from an archive format (tar, zip, 7zip, rar) to a archive file.")
|
|
83
|
-
args = argparser.parse_args()
|
|
84
|
-
|
|
85
|
-
# Determine the primary action based on user input
|
|
86
|
-
primary_action = None
|
|
87
|
-
if args.create:
|
|
88
|
-
primary_action = 'create'
|
|
89
|
-
elif args.repack:
|
|
90
|
-
primary_action = 'repack'
|
|
91
|
-
elif args.extract:
|
|
92
|
-
primary_action = 'extract'
|
|
93
|
-
elif args.list:
|
|
94
|
-
primary_action = 'list'
|
|
95
|
-
elif args.validate:
|
|
96
|
-
primary_action = 'validate'
|
|
97
|
-
input_file = args.input[0]
|
|
98
|
-
# Functionality mappings
|
|
99
|
-
if primary_action == 'create':
|
|
100
|
-
if args.convert == 'tar':
|
|
101
|
-
pyarchivefile.PackArchiveFileFromTarFile(input_file, args.output, args.compression, args.level, pyarchivefile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], [
|
|
102
|
-
], pyarchivefile.__file_format_dict__, args.verbose, False)
|
|
103
|
-
elif args.convert == 'zip':
|
|
104
|
-
pyarchivefile.PackArchiveFileFromZipFile(input_file, args.output, args.compression, args.level, pyarchivefile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], [
|
|
105
|
-
], pyarchivefile.__file_format_dict__, args.verbose, False)
|
|
106
|
-
elif py7zr_support and args.convert == '7zip':
|
|
107
|
-
pyarchivefile.PackArchiveFileFromSevenZipFile(input_file, args.output, args.compression, args.level, pyarchivefile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], [
|
|
108
|
-
], pyarchivefile.__file_format_dict__, args.verbose, False)
|
|
109
|
-
elif rarfile_support and args.convert == 'rar':
|
|
110
|
-
pyarchivefile.PackArchiveFileFromRarFile(input_file, args.output, args.compression, args.level, pyarchivefile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], [
|
|
111
|
-
], pyarchivefile.__file_format_dict__, args.verbose, False)
|
|
112
|
-
else:
|
|
113
|
-
pyarchivefile.PackArchiveFile(args.input, args.output, args.verbose, args.compression, args.level, pyarchivefile.compressionlistalt,
|
|
114
|
-
False, [args.checksum, args.checksum, args.checksum, args.checksum], [], {}, pyarchivefile.__file_format_dict__, args.verbose, False)
|
|
115
|
-
elif primary_action == 'repack':
|
|
116
|
-
pyarchivefile.RePackArchiveFile(
|
|
117
|
-
input_file, args.output, args.compression, args.level, pyarchivefile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], False, args.verbose)
|
|
118
|
-
elif primary_action == 'extract':
|
|
119
|
-
pyarchivefile.UnPackArchiveFile(
|
|
120
|
-
input_file, args.output, False, args.verbose, args.preserve)
|
|
121
|
-
elif primary_action == 'list':
|
|
122
|
-
if args.convert == 'tar':
|
|
123
|
-
pyarchivefile.TarFileListFiles(input_file, verbose=args.verbose)
|
|
124
|
-
elif args.convert == 'zip':
|
|
125
|
-
pyarchivefile.ZipFileListFiles(input_file, verbose=args.verbose)
|
|
126
|
-
elif args.convert == '7zip':
|
|
127
|
-
pyarchivefile.SevenZipFileListFiles(input_file, verbose=args.verbose)
|
|
128
|
-
elif rarfile_support and args.convert == 'rar':
|
|
129
|
-
pyarchivefile.RarFileListFiles(input_file, verbose=args.verbose)
|
|
130
|
-
else:
|
|
131
|
-
pyarchivefile.ArchiveFileListFiles(input_file, verbose=args.verbose)
|
|
132
|
-
elif primary_action == 'validate':
|
|
133
|
-
is_valid = pyarchivefile.ArchiveFileValidate(input_file, verbose=args.verbose)
|
|
134
|
-
result_msg = "Validation result for {0}: {1}".format(
|
|
135
|
-
input_file, 'Valid' if is_valid else 'Invalid')
|
|
136
|
-
print(result_msg)
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
pyarchivefile.py,sha256=ApsejVrTHProriwkoMi0OtpcbjkazmCxh0F120hSjAg,598220
|
|
2
|
-
pyarchivefile-0.26.0.data/scripts/archivefile.py,sha256=HLWlTHa0DHLwySUwYLsZxvjz84stZgXA-ZUsqD6DrW0,15350
|
|
3
|
-
pyarchivefile-0.26.0.data/scripts/archiveneofile.py,sha256=m2jQVSnpapc2fd9R1fyvvERCNT3JLKymcwE5_bl0Rfk,5140
|
|
4
|
-
pyarchivefile-0.26.0.data/scripts/neoarchivefile.py,sha256=wx4Ct6o3pnACJWhOFW9cLtoJ_e_alIWIj29Iey5Eb1w,7334
|
|
5
|
-
pyarchivefile-0.26.0.dist-info/licenses/LICENSE,sha256=WM1VWxTUVrQbvEa-LC7cKTaBHXiqSTyYPoJvsZSbd7E,1513
|
|
6
|
-
pyarchivefile-0.26.0.dist-info/METADATA,sha256=IaLu596jGzHfCM7mOfZVWAIi7-DcC9h395GiIkolAp4,927
|
|
7
|
-
pyarchivefile-0.26.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
-
pyarchivefile-0.26.0.dist-info/top_level.txt,sha256=dXsHVLesKNVXuVZeri6pRuRPo3y1HrcPsUrIw5KU5fk,14
|
|
9
|
-
pyarchivefile-0.26.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
10
|
-
pyarchivefile-0.26.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|