PyArchiveFile 0.27.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.27.0.data → pyarchivefile-0.27.2.data}/scripts/archivefile.py +6 -6
- {pyarchivefile-0.27.0.dist-info → pyarchivefile-0.27.2.dist-info}/METADATA +1 -1
- pyarchivefile-0.27.2.dist-info/RECORD +8 -0
- pyarchivefile.py +151 -49
- pyarchivefile-0.27.0.data/scripts/archiveneofile.py +0 -130
- pyarchivefile-0.27.0.data/scripts/neoarchivefile.py +0 -136
- pyarchivefile-0.27.0.dist-info/RECORD +0 -10
- {pyarchivefile-0.27.0.dist-info → pyarchivefile-0.27.2.dist-info}/WHEEL +0 -0
- {pyarchivefile-0.27.0.dist-info → pyarchivefile-0.27.2.dist-info}/licenses/LICENSE +0 -0
- {pyarchivefile-0.27.0.dist-info → pyarchivefile-0.27.2.dist-info}/top_level.txt +0 -0
- {pyarchivefile-0.27.0.dist-info → pyarchivefile-0.27.2.dist-info}/zip-safe +0 -0
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
15
15
|
Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
16
16
|
|
|
17
|
-
$FileInfo: archivefile.py - Last Update: 11/
|
|
17
|
+
$FileInfo: archivefile.py - Last Update: 11/15/2025 Ver. 0.27.2 RC 1 - Author: cooldude2k $
|
|
18
18
|
'''
|
|
19
19
|
|
|
20
20
|
from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
|
|
@@ -170,11 +170,11 @@ if active_action:
|
|
|
170
170
|
tmpout = pyarchivefile.RePackArchiveFile(input_file, getargs.output, "auto", getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt, False, 0, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.insecretkey, getargs.outsecretkey, False, getargs.verbose, False)
|
|
171
171
|
else:
|
|
172
172
|
tmpout = pyarchivefile.PackArchiveFileFromInFile(
|
|
173
|
-
input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.
|
|
173
|
+
input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, getargs.verbose, False)
|
|
174
174
|
if(not tmpout):
|
|
175
175
|
sys.exit(1)
|
|
176
176
|
else:
|
|
177
|
-
pyarchivefile.PackArchiveFile(getargs.input, getargs.output, getargs.text, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt, False, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.
|
|
177
|
+
pyarchivefile.PackArchiveFile(getargs.input, getargs.output, getargs.text, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt, False, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, getargs.verbose, False)
|
|
178
178
|
elif active_action == 'repack':
|
|
179
179
|
if getargs.convert:
|
|
180
180
|
checkcompressfile = pyarchivefile.CheckCompressionSubType(
|
|
@@ -183,7 +183,7 @@ if active_action:
|
|
|
183
183
|
pyarchivefile.RePackArchiveFile(input_file, getargs.output, "auto", getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt,
|
|
184
184
|
False, 0, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.insecretkey, getargs.outsecretkey, False, getargs.verbose, False)
|
|
185
185
|
else:
|
|
186
|
-
pyarchivefile.PackArchiveFileFromInFile(input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.
|
|
186
|
+
pyarchivefile.PackArchiveFileFromInFile(input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, getargs.verbose, False)
|
|
187
187
|
if(not tmpout):
|
|
188
188
|
sys.exit(1)
|
|
189
189
|
else:
|
|
@@ -198,7 +198,7 @@ if active_action:
|
|
|
198
198
|
tmpout = pyarchivefile.RePackArchiveFile(input_file, tempout, "auto", getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt, False, 0, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.insecretkey, getargs.outsecretkey, False, False)
|
|
199
199
|
else:
|
|
200
200
|
tmpout = pyarchivefile.PackArchiveFileFromInFile(
|
|
201
|
-
input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.
|
|
201
|
+
input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, False, False)
|
|
202
202
|
if(not tmpout):
|
|
203
203
|
sys.exit(1)
|
|
204
204
|
input_file = tempout
|
|
@@ -225,7 +225,7 @@ if active_action:
|
|
|
225
225
|
tmpout = pyarchivefile.RePackArchiveFile(input_file, tempout, "auto", getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt, False, 0, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.insecretkey, getargs.outsecretkey, False, False, False)
|
|
226
226
|
else:
|
|
227
227
|
tmpout = pyarchivefile.PackArchiveFileFromInFile(
|
|
228
|
-
input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.
|
|
228
|
+
input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyarchivefile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, False, False)
|
|
229
229
|
input_file = tempout
|
|
230
230
|
if(not tmpout):
|
|
231
231
|
sys.exit(1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyArchiveFile
|
|
3
|
-
Version: 0.27.
|
|
3
|
+
Version: 0.27.2
|
|
4
4
|
Summary: A tar like file format name archivefile.
|
|
5
5
|
Home-page: https://github.com/GameMaker2k/PyArchiveFile
|
|
6
6
|
Download-URL: https://github.com/GameMaker2k/PyArchiveFile/archive/master.tar.gz
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
pyarchivefile.py,sha256=T0OMFtPOxB6qqStOrhiU0ZR6tjLuRQuUDRsiWzBmCAg,626116
|
|
2
|
+
pyarchivefile-0.27.2.data/scripts/archivefile.py,sha256=aMuwgLVJ6DvHqWzPWh3KdtTPBDd-eyuwyk53x2Amu2g,15355
|
|
3
|
+
pyarchivefile-0.27.2.dist-info/licenses/LICENSE,sha256=WM1VWxTUVrQbvEa-LC7cKTaBHXiqSTyYPoJvsZSbd7E,1513
|
|
4
|
+
pyarchivefile-0.27.2.dist-info/METADATA,sha256=tEb7M_QIZRAj0L45YuOJYMiKvN259hm4c0gE4xPst7o,927
|
|
5
|
+
pyarchivefile-0.27.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
6
|
+
pyarchivefile-0.27.2.dist-info/top_level.txt,sha256=dXsHVLesKNVXuVZeri6pRuRPo3y1HrcPsUrIw5KU5fk,14
|
|
7
|
+
pyarchivefile-0.27.2.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
8
|
+
pyarchivefile-0.27.2.dist-info/RECORD,,
|
pyarchivefile.py
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
|
|
15
15
|
Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
|
|
16
16
|
|
|
17
|
-
$FileInfo: pyarchivefile.py - Last Update: 11/
|
|
17
|
+
$FileInfo: pyarchivefile.py - Last Update: 11/15/2025 Ver. 0.27.2 RC 1 - Author: cooldude2k $
|
|
18
18
|
'''
|
|
19
19
|
|
|
20
20
|
from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
|
|
@@ -47,11 +47,9 @@ except ImportError:
|
|
|
47
47
|
|
|
48
48
|
try:
|
|
49
49
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
|
50
|
-
from socketserver import TCPServer
|
|
51
50
|
from urllib.parse import urlparse, parse_qs
|
|
52
51
|
except ImportError:
|
|
53
52
|
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
|
54
|
-
from SocketServer import TCPServer
|
|
55
53
|
from urlparse import urlparse, parse_qs
|
|
56
54
|
|
|
57
55
|
try:
|
|
@@ -657,12 +655,12 @@ __project__ = __program_name__
|
|
|
657
655
|
__program_alt_name__ = __program_name__
|
|
658
656
|
__project_url__ = "https://github.com/GameMaker2k/PyArchiveFile"
|
|
659
657
|
__project_release_url__ = __project_url__+"/releases/latest"
|
|
660
|
-
__version_info__ = (0, 27,
|
|
661
|
-
__version_date_info__ = (2025, 11,
|
|
658
|
+
__version_info__ = (0, 27, 2, "RC 1", 1)
|
|
659
|
+
__version_date_info__ = (2025, 11, 15, "RC 1", 1)
|
|
662
660
|
__version_date__ = str(__version_date_info__[0]) + "." + str(
|
|
663
661
|
__version_date_info__[1]).zfill(2) + "." + str(__version_date_info__[2]).zfill(2)
|
|
664
662
|
__revision__ = __version_info__[3]
|
|
665
|
-
__revision_id__ = "$Id:
|
|
663
|
+
__revision_id__ = "$Id: 8fdff8949e2d0bce935d7cea2b59865dbf4911af $"
|
|
666
664
|
if(__version_info__[4] is not None):
|
|
667
665
|
__version_date_plusrc__ = __version_date__ + \
|
|
668
666
|
"-" + str(__version_date_info__[4])
|
|
@@ -878,16 +876,14 @@ try:
|
|
|
878
876
|
try:
|
|
879
877
|
import compression.lzma as lzma
|
|
880
878
|
except ImportError:
|
|
881
|
-
|
|
879
|
+
try:
|
|
880
|
+
import lzma
|
|
881
|
+
except ImportError:
|
|
882
|
+
from backports import lzma
|
|
882
883
|
compressionsupport.append("lzma")
|
|
883
884
|
compressionsupport.append("xz")
|
|
884
885
|
except ImportError:
|
|
885
|
-
|
|
886
|
-
from backports import lzma
|
|
887
|
-
compressionsupport.append("lzma")
|
|
888
|
-
compressionsupport.append("xz")
|
|
889
|
-
except ImportError:
|
|
890
|
-
pass
|
|
886
|
+
pass
|
|
891
887
|
try:
|
|
892
888
|
try:
|
|
893
889
|
import compression.zlib as zlib
|
|
@@ -6496,16 +6492,29 @@ def AppendFilesWithContentToList(infiles, dirlistfromtxt=False, extradata=[], js
|
|
|
6496
6492
|
advancedlist = __use_advanced_list__
|
|
6497
6493
|
altinode = __use_alt_inode__
|
|
6498
6494
|
infilelist = []
|
|
6499
|
-
if(infiles == "-"):
|
|
6495
|
+
if(not dirlistfromtxt and not isinstance(infiles, (list, tuple, )) and infiles == "-"):
|
|
6500
6496
|
for line in PY_STDIN_TEXT:
|
|
6501
6497
|
infilelist.append(line.strip())
|
|
6502
6498
|
infilelist = list(filter(None, infilelist))
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6499
|
+
if(not dirlistfromtxt and isinstance(infiles, (list, tuple, )) and len(infiles)==1 and infiles[0] == "-"):
|
|
6500
|
+
for line in PY_STDIN_TEXT:
|
|
6501
|
+
infilelist.append(line.strip())
|
|
6502
|
+
infilelist = list(filter(None, infilelist))
|
|
6503
|
+
elif(dirlistfromtxt):
|
|
6504
|
+
if(not isinstance(infiles, (list, tuple, ))):
|
|
6505
|
+
infiles = [infiles]
|
|
6506
|
+
if(isinstance(infiles, (list, tuple, ))):
|
|
6507
|
+
for fileloc in infiles:
|
|
6508
|
+
if(fileloc == "-"):
|
|
6509
|
+
for line in PY_STDIN_TEXT:
|
|
6510
|
+
infilelist.append(line.strip())
|
|
6511
|
+
else:
|
|
6512
|
+
if(not os.path.exists(fileloc) or not os.path.isfile(fileloc)):
|
|
6513
|
+
return False
|
|
6514
|
+
else:
|
|
6515
|
+
with UncompressFile(fileloc, formatspecs, "r") as finfile:
|
|
6516
|
+
for line in finfile:
|
|
6517
|
+
infilelist.append(line.strip())
|
|
6509
6518
|
infilelist = list(filter(None, infilelist))
|
|
6510
6519
|
else:
|
|
6511
6520
|
if(isinstance(infiles, (list, tuple, ))):
|
|
@@ -6841,7 +6850,7 @@ def AppendFilesWithContentFromTarFileToList(infile, extradata=[], jsondata={}, c
|
|
|
6841
6850
|
inodetofile = {}
|
|
6842
6851
|
filetoinode = {}
|
|
6843
6852
|
inodetoforminode = {}
|
|
6844
|
-
if(infile == "-"):
|
|
6853
|
+
if(not isinstance(infile, (list, tuple, )) and infile == "-"):
|
|
6845
6854
|
infile = MkTempFile()
|
|
6846
6855
|
shutil.copyfileobj(PY_STDIN_BUF, infile, length=__filebuff_size__)
|
|
6847
6856
|
infile.seek(0, 0)
|
|
@@ -6909,7 +6918,7 @@ def AppendFilesWithContentFromTarFileToList(infile, extradata=[], jsondata={}, c
|
|
|
6909
6918
|
fblocks = 0
|
|
6910
6919
|
fflags = 0
|
|
6911
6920
|
ftype = 0
|
|
6912
|
-
if(member.isreg()):
|
|
6921
|
+
if(member.isreg() or member.isfile()):
|
|
6913
6922
|
ffullmode = member.mode + stat.S_IFREG
|
|
6914
6923
|
ftype = 0
|
|
6915
6924
|
elif(member.islnk()):
|
|
@@ -7067,7 +7076,7 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
|
|
|
7067
7076
|
inodetofile = {}
|
|
7068
7077
|
filetoinode = {}
|
|
7069
7078
|
inodetoforminode = {}
|
|
7070
|
-
if(infile == "-"):
|
|
7079
|
+
if(not isinstance(infile, (list, tuple, )) and infile == "-"):
|
|
7071
7080
|
infile = MkTempFile()
|
|
7072
7081
|
shutil.copyfileobj(PY_STDIN_BUF, infile, length=__filebuff_size__)
|
|
7073
7082
|
infile.seek(0, 0)
|
|
@@ -7114,9 +7123,13 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
|
|
|
7114
7123
|
ftype = 0
|
|
7115
7124
|
if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
|
|
7116
7125
|
ftype = 5
|
|
7126
|
+
elif ((hasattr(member, "symlink") and member.symlink())):
|
|
7127
|
+
ftype = 2
|
|
7117
7128
|
else:
|
|
7118
7129
|
ftype = 0
|
|
7119
7130
|
flinkname = ""
|
|
7131
|
+
if(ftype==2):
|
|
7132
|
+
flinkname = zipfp.read(member.filename).decode("UTF-8")
|
|
7120
7133
|
fcurfid = format(int(curfid), 'x').lower()
|
|
7121
7134
|
fcurinode = format(int(curfid), 'x').lower()
|
|
7122
7135
|
curfid = curfid + 1
|
|
@@ -7142,6 +7155,10 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
|
|
|
7142
7155
|
fmode = format(int(stat.S_IFDIR | 0x1ff), 'x').lower()
|
|
7143
7156
|
fchmode = stat.S_IMODE(int(stat.S_IFDIR | 0x1ff))
|
|
7144
7157
|
ftypemod = stat.S_IFMT(int(stat.S_IFDIR | 0x1ff))
|
|
7158
|
+
elif ((hasattr(member, "symlink") and member.symlink()) or member.filename.endswith('/')):
|
|
7159
|
+
fmode = format(int(stat.S_IFREG | 0x1b6), 'x').lower()
|
|
7160
|
+
fchmode = stat.S_IMODE(int(stat.S_IFREG | 0x1b6))
|
|
7161
|
+
ftypemod = stat.S_IFMT(int(stat.S_IFREG | 0x1b6))
|
|
7145
7162
|
else:
|
|
7146
7163
|
fmode = format(int(stat.S_IFREG | 0x1b6), 'x').lower()
|
|
7147
7164
|
fchmode = stat.S_IMODE(int(stat.S_IFREG | 0x1b6))
|
|
@@ -7150,6 +7167,17 @@ def AppendFilesWithContentFromZipFileToList(infile, extradata=[], jsondata={}, c
|
|
|
7150
7167
|
fwinattributes = format(int(zipinfo.external_attr & 0xFFFF), 'x').lower()
|
|
7151
7168
|
fmode = format(int((zipinfo.external_attr >> 16) & 0xFFFF), 'x').lower()
|
|
7152
7169
|
prefmode = int((zipinfo.external_attr >> 16) & 0xFFFF)
|
|
7170
|
+
if(prefmode==0):
|
|
7171
|
+
fmode = 0
|
|
7172
|
+
prefmode = 0
|
|
7173
|
+
else:
|
|
7174
|
+
file_type = prefmode & 0xF000
|
|
7175
|
+
if(file_type not in (stat.S_IFREG, stat.S_IFDIR, stat.S_IFLNK)):
|
|
7176
|
+
fmode = 0
|
|
7177
|
+
prefmode = 0
|
|
7178
|
+
if((mode & 0x1FF) == 0):
|
|
7179
|
+
fmode = 0
|
|
7180
|
+
prefmode = 0
|
|
7153
7181
|
if (prefmode == 0):
|
|
7154
7182
|
if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
|
|
7155
7183
|
fmode = format(int(stat.S_IFDIR | 0x1ff), 'x').lower()
|
|
@@ -7596,7 +7624,10 @@ else:
|
|
|
7596
7624
|
fpremode = int(stat.S_IFREG | 0x1b6)
|
|
7597
7625
|
elif(member.is_directory):
|
|
7598
7626
|
fpremode = int(stat.S_IFDIR | 0x1ff)
|
|
7599
|
-
|
|
7627
|
+
try:
|
|
7628
|
+
fwinattributes = format(int(member.attributes & 0xFFFF), 'x').lower()
|
|
7629
|
+
except AttributeError:
|
|
7630
|
+
fwinattributes = format(int(0), 'x').lower()
|
|
7600
7631
|
fcompression = ""
|
|
7601
7632
|
fcsize = format(int(0), 'x').lower()
|
|
7602
7633
|
flinkcount = 0
|
|
@@ -7632,6 +7663,13 @@ else:
|
|
|
7632
7663
|
int(stat.S_IMODE(int(stat.S_IFREG | 0x1b6))), 'x').lower()
|
|
7633
7664
|
ftypemod = format(
|
|
7634
7665
|
int(stat.S_IFMT(int(stat.S_IFREG | 0x1b6))), 'x').lower()
|
|
7666
|
+
try:
|
|
7667
|
+
ffullmode = member.posix_mode
|
|
7668
|
+
fmode = format(int(ffullmode), 'x').lower()
|
|
7669
|
+
fchmode = format(int(stat.S_IMODE(ffullmode)), 'x').lower()
|
|
7670
|
+
ftypemod = format(int(stat.S_IFMT(ffullmode)), 'x').lower()
|
|
7671
|
+
except AttributeError:
|
|
7672
|
+
pass
|
|
7635
7673
|
try:
|
|
7636
7674
|
fuid = format(int(os.getuid()), 'x').lower()
|
|
7637
7675
|
except (KeyError, AttributeError):
|
|
@@ -10197,7 +10235,7 @@ def ArchiveFileValidate(infile, fmttype="auto", filestart=0, formatspecs=__file_
|
|
|
10197
10235
|
if(not fp):
|
|
10198
10236
|
return False
|
|
10199
10237
|
fp.seek(filestart, 0)
|
|
10200
|
-
elif(infile == "-"):
|
|
10238
|
+
elif(not isinstance(infile, (list, tuple, )) and infile == "-"):
|
|
10201
10239
|
fp = MkTempFile()
|
|
10202
10240
|
shutil.copyfileobj(PY_STDIN_BUF, fp, length=__filebuff_size__)
|
|
10203
10241
|
fp.seek(filestart, 0)
|
|
@@ -11573,8 +11611,8 @@ def ArchiveFileStringListFiles(instr, filestart=0, seekstart=0, seekend=0, skipc
|
|
|
11573
11611
|
return listarrayfiles
|
|
11574
11612
|
|
|
11575
11613
|
|
|
11576
|
-
def TarFileListFiles(infile, verbose=False, returnfp=False):
|
|
11577
|
-
if(infile == "-"):
|
|
11614
|
+
def TarFileListFiles(infile, formatspecs=__file_format_multi_dict__, verbose=False, returnfp=False):
|
|
11615
|
+
if(not isinstance(infile, (list, tuple, )) and infile == "-"):
|
|
11578
11616
|
infile = MkTempFile()
|
|
11579
11617
|
shutil.copyfileobj(PY_STDIN_BUF, infile, length=__filebuff_size__)
|
|
11580
11618
|
infile.seek(0, 0)
|
|
@@ -11634,7 +11672,7 @@ def TarFileListFiles(infile, verbose=False, returnfp=False):
|
|
|
11634
11672
|
ffullmode = member.mode
|
|
11635
11673
|
flinkcount = 0
|
|
11636
11674
|
ftype = 0
|
|
11637
|
-
if(member.isreg()):
|
|
11675
|
+
if(member.isreg() or member.isfile()):
|
|
11638
11676
|
ffullmode = member.mode + stat.S_IFREG
|
|
11639
11677
|
ftype = 0
|
|
11640
11678
|
elif(member.islnk()):
|
|
@@ -11689,8 +11727,12 @@ def TarFileListFiles(infile, verbose=False, returnfp=False):
|
|
|
11689
11727
|
return True
|
|
11690
11728
|
|
|
11691
11729
|
|
|
11730
|
+
def TarFileListFile(infile, formatspecs=__file_format_multi_dict__, verbose=False, returnfp=False):
|
|
11731
|
+
return TarFileListFiles(infile, formatspecs, verbose, returnfp)
|
|
11732
|
+
|
|
11733
|
+
|
|
11692
11734
|
def ZipFileListFiles(infile, verbose=False, returnfp=False):
|
|
11693
|
-
if(infile == "-"):
|
|
11735
|
+
if(not isinstance(infile, (list, tuple, )) and infile == "-"):
|
|
11694
11736
|
infile = MkTempFile()
|
|
11695
11737
|
shutil.copyfileobj(PY_STDIN_BUF, infile, length=__filebuff_size__)
|
|
11696
11738
|
infile.seek(0, 0)
|
|
@@ -11721,35 +11763,59 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
|
|
|
11721
11763
|
for member in sorted(zipfp.infolist(), key=lambda x: x.filename):
|
|
11722
11764
|
zipinfo = zipfp.getinfo(member.filename)
|
|
11723
11765
|
if(zipinfo.create_system == 0 or zipinfo.create_system == 10):
|
|
11724
|
-
fwinattributes = int(zipinfo.external_attr)
|
|
11766
|
+
fwinattributes = int(zipinfo.external_attr & 0xFFFF)
|
|
11725
11767
|
if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
|
|
11726
11768
|
fmode = int(stat.S_IFDIR | 0x1ff)
|
|
11727
|
-
fchmode =
|
|
11728
|
-
ftypemod =
|
|
11769
|
+
fchmode = stat.S_IMODE(int(stat.S_IFDIR | 0x1ff))
|
|
11770
|
+
ftypemod = stat.S_IFMT(int(stat.S_IFDIR | 0x1ff))
|
|
11771
|
+
elif ((hasattr(member, "symlink") and member.symlink()) or member.filename.endswith('/')):
|
|
11772
|
+
fmode = int(stat.S_IFREG | 0x1b6)
|
|
11773
|
+
fchmode = stat.S_IMODE(int(stat.S_IFREG | 0x1b6))
|
|
11774
|
+
ftypemod = stat.S_IFMT(int(stat.S_IFREG | 0x1b6))
|
|
11729
11775
|
else:
|
|
11730
11776
|
fmode = int(stat.S_IFREG | 0x1b6)
|
|
11731
|
-
fchmode = int(stat.
|
|
11732
|
-
ftypemod = int(stat.
|
|
11777
|
+
fchmode = stat.S_IMODE(int(stat.S_IFREG | 0x1b6))
|
|
11778
|
+
ftypemod = stat.S_IFMT(int(stat.S_IFREG | 0x1b6))
|
|
11733
11779
|
elif(zipinfo.create_system == 3):
|
|
11734
|
-
fwinattributes = int(
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11780
|
+
fwinattributes = int(zipinfo.external_attr & 0xFFFF)
|
|
11781
|
+
fmode = int((zipinfo.external_attr >> 16) & 0xFFFF)
|
|
11782
|
+
prefmode = int((zipinfo.external_attr >> 16) & 0xFFFF)
|
|
11783
|
+
if(prefmode==0):
|
|
11784
|
+
fmode = 0
|
|
11785
|
+
prefmode = 0
|
|
11786
|
+
else:
|
|
11787
|
+
file_type = prefmode & 0xF000
|
|
11788
|
+
if(file_type not in (stat.S_IFREG, stat.S_IFDIR, stat.S_IFLNK)):
|
|
11789
|
+
fmode = 0
|
|
11790
|
+
prefmode = 0
|
|
11791
|
+
if((mode & 0x1FF) == 0):
|
|
11792
|
+
fmode = 0
|
|
11793
|
+
prefmode = 0
|
|
11794
|
+
if (prefmode == 0):
|
|
11795
|
+
if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
|
|
11796
|
+
fmode = int(stat.S_IFDIR | 0x1ff)
|
|
11797
|
+
prefmode = int(stat.S_IFDIR | 0x1ff)
|
|
11798
|
+
fchmode = stat.S_IMODE(prefmode)
|
|
11799
|
+
ftypemod = stat.S_IFMT(prefmode)
|
|
11800
|
+
else:
|
|
11801
|
+
fmode = int(stat.S_IFREG | 0x1b6)
|
|
11802
|
+
prefmode = int(stat.S_IFREG | 0x1b6)
|
|
11803
|
+
fchmode = stat.S_IMODE(prefmode)
|
|
11804
|
+
ftypemod = stat.S_IFMT(prefmode)
|
|
11805
|
+
fchmode = stat.S_IMODE(prefmode)
|
|
11806
|
+
ftypemod = stat.S_IFMT(prefmode)
|
|
11743
11807
|
else:
|
|
11744
|
-
fwinattributes = int(
|
|
11808
|
+
fwinattributes = int(zipinfo.external_attr & 0xFFFF)
|
|
11745
11809
|
if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
|
|
11746
11810
|
fmode = int(stat.S_IFDIR | 0x1ff)
|
|
11747
|
-
|
|
11748
|
-
|
|
11811
|
+
prefmode = int(stat.S_IFDIR | 0x1ff)
|
|
11812
|
+
fchmode = stat.S_IMODE(prefmode)
|
|
11813
|
+
ftypemod = stat.S_IFMT(prefmode)
|
|
11749
11814
|
else:
|
|
11750
11815
|
fmode = int(stat.S_IFREG | 0x1b6)
|
|
11751
|
-
|
|
11752
|
-
|
|
11816
|
+
prefmode = int(stat.S_IFREG | 0x1b6)
|
|
11817
|
+
fchmode = stat.S_IMODE(prefmode)
|
|
11818
|
+
ftypemod = stat.S_IFMT(prefmode)
|
|
11753
11819
|
returnval.update({lcfi: member.filename})
|
|
11754
11820
|
if(not verbose):
|
|
11755
11821
|
VerbosePrintOut(member.filename)
|
|
@@ -11763,10 +11829,17 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
|
|
|
11763
11829
|
if ((hasattr(member, "is_dir") and member.is_dir()) or member.filename.endswith('/')):
|
|
11764
11830
|
ftype = 5
|
|
11765
11831
|
permissionstr = "d" + permissionstr
|
|
11832
|
+
elif ((hasattr(member, "symlink") and member.symlink())):
|
|
11833
|
+
ftype = 2
|
|
11834
|
+
permissionstr = "l" + permissionstr
|
|
11766
11835
|
else:
|
|
11767
11836
|
ftype = 0
|
|
11768
11837
|
permissionstr = "-" + permissionstr
|
|
11769
11838
|
printfname = member.filename
|
|
11839
|
+
if(ftype==2):
|
|
11840
|
+
flinkname = zipfp.read(member.filename).decode("UTF-8")
|
|
11841
|
+
if(ftype==2):
|
|
11842
|
+
printfname = member.filename + " -> " + flinkname
|
|
11770
11843
|
try:
|
|
11771
11844
|
fuid = int(os.getuid())
|
|
11772
11845
|
except (KeyError, AttributeError):
|
|
@@ -11809,6 +11882,10 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
|
|
|
11809
11882
|
return True
|
|
11810
11883
|
|
|
11811
11884
|
|
|
11885
|
+
def ZipFileListFile(infile, verbose=False, returnfp=False):
|
|
11886
|
+
return ZipFileListFiles(infile, verbose, returnfp)
|
|
11887
|
+
|
|
11888
|
+
|
|
11812
11889
|
if(not rarfile_support):
|
|
11813
11890
|
def RarFileListFiles(infile, verbose=False, returnfp=False):
|
|
11814
11891
|
return False
|
|
@@ -11936,6 +12013,11 @@ if(rarfile_support):
|
|
|
11936
12013
|
else:
|
|
11937
12014
|
return True
|
|
11938
12015
|
|
|
12016
|
+
|
|
12017
|
+
def RarFileListFile(infile, verbose=False, returnfp=False):
|
|
12018
|
+
return RarFileListFiles(infile, verbose, returnfp)
|
|
12019
|
+
|
|
12020
|
+
|
|
11939
12021
|
if(not py7zr_support):
|
|
11940
12022
|
def SevenZipFileListFiles(infile, verbose=False, returnfp=False):
|
|
11941
12023
|
return False
|
|
@@ -11973,6 +12055,13 @@ if(py7zr_support):
|
|
|
11973
12055
|
fmode = int(stat.S_IFLNK | 0x1b6)
|
|
11974
12056
|
fchmode = int(stat.S_IMODE(int(stat.S_IFLNK | 0x1b6)))
|
|
11975
12057
|
ftypemod = int(stat.S_IFMT(int(stat.S_IFLNK | 0x1b6)))
|
|
12058
|
+
try:
|
|
12059
|
+
ffullmode = member.posix_mode
|
|
12060
|
+
fmode = format(int(ffullmode), 'x').lower()
|
|
12061
|
+
fchmode = format(int(stat.S_IMODE(ffullmode)), 'x').lower()
|
|
12062
|
+
ftypemod = format(int(stat.S_IFMT(ffullmode)), 'x').lower()
|
|
12063
|
+
except AttributeError:
|
|
12064
|
+
pass
|
|
11976
12065
|
returnval.update({lcfi: member.filename})
|
|
11977
12066
|
if(not verbose):
|
|
11978
12067
|
VerbosePrintOut(member.filename)
|
|
@@ -12040,12 +12129,16 @@ if(py7zr_support):
|
|
|
12040
12129
|
return True
|
|
12041
12130
|
|
|
12042
12131
|
|
|
12132
|
+
def SevenZipFileListFile(infile, verbose=False, returnfp=False):
|
|
12133
|
+
return SevenZipFileListFiles(infile, verbose, returnfp)
|
|
12134
|
+
|
|
12135
|
+
|
|
12043
12136
|
def InFileListFiles(infile, verbose=False, formatspecs=__file_format_multi_dict__, seektoend=False, newstyle=False, returnfp=False):
|
|
12044
12137
|
checkcompressfile = CheckCompressionSubType(infile, formatspecs, filestart, True)
|
|
12045
12138
|
if(IsNestedDict(formatspecs) and checkcompressfile in formatspecs):
|
|
12046
12139
|
formatspecs = formatspecs[checkcompressfile]
|
|
12047
12140
|
if(checkcompressfile == "tarfile" and TarFileCheck(infile)):
|
|
12048
|
-
return TarFileListFiles(infile, verbose, returnfp)
|
|
12141
|
+
return TarFileListFiles(infile, formatspecs, verbose, returnfp)
|
|
12049
12142
|
elif(checkcompressfile == "zipfile" and zipfile.is_zipfile(infile)):
|
|
12050
12143
|
return ZipFileListFiles(infile, verbose, returnfp)
|
|
12051
12144
|
elif(rarfile_support and checkcompressfile == "rarfile" and (rarfile.is_rarfile(infile) or rarfile.is_rarfile_sfx(infile))):
|
|
@@ -12059,6 +12152,10 @@ def InFileListFiles(infile, verbose=False, formatspecs=__file_format_multi_dict_
|
|
|
12059
12152
|
return False
|
|
12060
12153
|
|
|
12061
12154
|
|
|
12155
|
+
def InFileListFile(infile, verbose=False, formatspecs=__file_format_multi_dict__, seektoend=False, newstyle=False, returnfp=False):
|
|
12156
|
+
return InFileListFiles(infile, verbose, formatspecs, seektoend, newstyle, returnfp)
|
|
12157
|
+
|
|
12158
|
+
|
|
12062
12159
|
def ListDirListFiles(infiles, dirlistfromtxt=False, compression="auto", compresswholefile=True, compressionlevel=None, followlink=False, seekstart=0, seekend=0, skipchecksum=False, checksumtype=["md5", "md5", "md5"], formatspecs=__file_format_dict__, seektoend=False, verbose=False, returnfp=False):
|
|
12063
12160
|
outarray = MkTempFile()
|
|
12064
12161
|
packform = PackArchiveFile(infiles, outarray, dirlistfromtxt, compression, compresswholefile,
|
|
@@ -12067,6 +12164,11 @@ def ListDirListFiles(infiles, dirlistfromtxt=False, compression="auto", compress
|
|
|
12067
12164
|
outarray, seekstart, seekend, skipchecksum, formatspecs, seektoend, verbose, returnfp)
|
|
12068
12165
|
return listarrayfiles
|
|
12069
12166
|
|
|
12167
|
+
|
|
12168
|
+
def ListDirListFiles(infiles, dirlistfromtxt=False, compression="auto", compresswholefile=True, compressionlevel=None, followlink=False, seekstart=0, seekend=0, skipchecksum=False, checksumtype=["md5", "md5", "md5"], formatspecs=__file_format_dict__, seektoend=False, verbose=False, returnfp=False):
|
|
12169
|
+
return ListDirListFiles(infiles, dirlistfromtxt, compression, compresswholefile, compressionlevel, followlink, seekstart, seekend, skipchecksum, checksumtype, formatspecs, seektoend, verbose, returnfp)
|
|
12170
|
+
|
|
12171
|
+
|
|
12070
12172
|
def detect_cwd(ftp, file_dir):
|
|
12071
12173
|
"""
|
|
12072
12174
|
Test whether cwd into file_dir works. Returns True if it does,
|
|
@@ -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=wEk_3WeJdNLPiEKatFks2NfOLjXsy3Si9Y2BvItv7ss,620734
|
|
2
|
-
pyarchivefile-0.27.0.data/scripts/archivefile.py,sha256=UhjJaYc6Juzya0wjMcWhDhqOTjpUqti5mWNhN-OqxeE,15350
|
|
3
|
-
pyarchivefile-0.27.0.data/scripts/archiveneofile.py,sha256=m2jQVSnpapc2fd9R1fyvvERCNT3JLKymcwE5_bl0Rfk,5140
|
|
4
|
-
pyarchivefile-0.27.0.data/scripts/neoarchivefile.py,sha256=wx4Ct6o3pnACJWhOFW9cLtoJ_e_alIWIj29Iey5Eb1w,7334
|
|
5
|
-
pyarchivefile-0.27.0.dist-info/licenses/LICENSE,sha256=WM1VWxTUVrQbvEa-LC7cKTaBHXiqSTyYPoJvsZSbd7E,1513
|
|
6
|
-
pyarchivefile-0.27.0.dist-info/METADATA,sha256=TcSJbJZKVeG_KBkercExdc2sIBy3o6GDisi-X2Ld_Vc,927
|
|
7
|
-
pyarchivefile-0.27.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
-
pyarchivefile-0.27.0.dist-info/top_level.txt,sha256=dXsHVLesKNVXuVZeri6pRuRPo3y1HrcPsUrIw5KU5fk,14
|
|
9
|
-
pyarchivefile-0.27.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
10
|
-
pyarchivefile-0.27.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|