PyNeoFile 0.27.0__py3-none-any.whl → 0.27.4__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.
- pyneofile-0.27.4.data/scripts/neofile.py +237 -0
- {pyneofile-0.27.0.dist-info → pyneofile-0.27.4.dist-info}/METADATA +3 -3
- pyneofile-0.27.4.dist-info/RECORD +8 -0
- {pyneofile-0.27.0.dist-info → pyneofile-0.27.4.dist-info}/licenses/LICENSE +10 -9
- pyneofile.py +15050 -1421
- pyneofile-0.27.0.data/scripts/neofile.py +0 -139
- pyneofile-0.27.0.dist-info/RECORD +0 -8
- {pyneofile-0.27.0.dist-info → pyneofile-0.27.4.dist-info}/WHEEL +0 -0
- {pyneofile-0.27.0.dist-info → pyneofile-0.27.4.dist-info}/top_level.txt +0 -0
- {pyneofile-0.27.0.dist-info → pyneofile-0.27.4.dist-info}/zip-safe +0 -0
|
@@ -1,139 +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 pyneofile as P # core must provide *_neo functions
|
|
9
|
-
except Exception as e:
|
|
10
|
-
sys.stderr.write("Failed to import core module 'pyneofile': %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 pyneofile 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, formatspecs=None, 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
|
-
entries = P.archivefilelistfiles_neo(src, advanced=args.verbose, include_dirs=True)
|
|
72
|
-
if args.verbose:
|
|
73
|
-
for e in entries:
|
|
74
|
-
if isinstance(e, dict):
|
|
75
|
-
print("{type}\t{compression}\t{size}\t{name}".format(**e))
|
|
76
|
-
else:
|
|
77
|
-
print(e)
|
|
78
|
-
else:
|
|
79
|
-
for n in entries:
|
|
80
|
-
print(n if isinstance(n, str) else n.get("name"))
|
|
81
|
-
return 0
|
|
82
|
-
|
|
83
|
-
if args.extract:
|
|
84
|
-
if not src:
|
|
85
|
-
p.error("extract requires -i <archive>")
|
|
86
|
-
outdir = args.output or "."
|
|
87
|
-
ok = P.unpack_neo(src, outdir, formatspecs=None, skipchecksum=False, uncompress=True)
|
|
88
|
-
return 0 if ok else 1
|
|
89
|
-
|
|
90
|
-
if args.create:
|
|
91
|
-
if not src:
|
|
92
|
-
p.error("create requires -i <path>")
|
|
93
|
-
if args.verbose:
|
|
94
|
-
walkroot = src
|
|
95
|
-
if os.path.isdir(walkroot):
|
|
96
|
-
print(walkroot)
|
|
97
|
-
for root, dirs, files in os.walk(walkroot):
|
|
98
|
-
relroot = root if root.startswith("./") else "./" + root.replace("\\", "/")
|
|
99
|
-
if root != walkroot:
|
|
100
|
-
print(relroot)
|
|
101
|
-
for name in sorted(files):
|
|
102
|
-
path = os.path.join(root, name).replace("\\", "/")
|
|
103
|
-
if not path.startswith("./"):
|
|
104
|
-
path = "./" + path
|
|
105
|
-
print(path)
|
|
106
|
-
else:
|
|
107
|
-
path = src if src.startswith("./") else "./" + src
|
|
108
|
-
print(path)
|
|
109
|
-
|
|
110
|
-
outpath = args.output or "-"
|
|
111
|
-
ok = P.pack_neo(src, outpath, formatspecs=None, checksumtypes=("crc32","crc32","crc32"),
|
|
112
|
-
encoding="UTF-8", compression=args.compression, compression_level=args.level)
|
|
113
|
-
if outpath in (None, "-") and isinstance(ok, (bytes, bytearray)):
|
|
114
|
-
if hasattr(sys.stdout, "buffer"):
|
|
115
|
-
sys.stdout.buffer.write(ok)
|
|
116
|
-
else:
|
|
117
|
-
sys.stdout.write(ok.decode("latin1"))
|
|
118
|
-
return 0
|
|
119
|
-
return 0 if ok else 1
|
|
120
|
-
|
|
121
|
-
if args.repack:
|
|
122
|
-
if not src:
|
|
123
|
-
p.error("repack requires -i <archive>")
|
|
124
|
-
outpath = args.output or "-"
|
|
125
|
-
ok = P.repack_neo(src, outpath, formatspecs=None, checksumtypes=("crc32","crc32","crc32"),
|
|
126
|
-
compression=args.compression, compression_level=args.level)
|
|
127
|
-
if outpath in (None, "-") and isinstance(ok, (bytes, bytearray)):
|
|
128
|
-
if hasattr(sys.stdout, "buffer"):
|
|
129
|
-
sys.stdout.buffer.write(ok)
|
|
130
|
-
else:
|
|
131
|
-
sys.stdout.write(ok.decode("latin1"))
|
|
132
|
-
return 0
|
|
133
|
-
return 0 if ok else 1
|
|
134
|
-
|
|
135
|
-
return 0
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if __name__ == "__main__":
|
|
139
|
-
sys.exit(main())
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
pyneofile.py,sha256=7kPgyzWV_yfS0bpND1sOno1QaE2aeykqWK6sHTwBRko,59541
|
|
2
|
-
pyneofile-0.27.0.data/scripts/neofile.py,sha256=X0kZrcKJsjo4K5Rp_IEpFMjQ-lu6OAhX2wDSJJPbvT4,5481
|
|
3
|
-
pyneofile-0.27.0.dist-info/licenses/LICENSE,sha256=G22gXt50FuCPBLneMraT2Q6-G5pAjFEqS4q9xP-DKWs,1500
|
|
4
|
-
pyneofile-0.27.0.dist-info/METADATA,sha256=lMxzfl96E6F1Y9OnwbTZE52XmYCh_ngwrDVupOZk3WI,915
|
|
5
|
-
pyneofile-0.27.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
6
|
-
pyneofile-0.27.0.dist-info/top_level.txt,sha256=_-bBDCun16INq_ibkGkMIpnjvoBZ3KbKcgR6meoPsb8,10
|
|
7
|
-
pyneofile-0.27.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
8
|
-
pyneofile-0.27.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|