mirror of
https://github.com/elliotnunn/macresources.git
synced 2024-12-12 18:30:08 +00:00
Expand > extract
This commit is contained in:
parent
408ff20637
commit
5a318f78ef
@ -16,7 +16,7 @@ parser = argparse.ArgumentParser(description='''
|
||||
parser.add_argument('resourceFile', help='file to be decompiled')
|
||||
parser.add_argument('-ascii', action='store_true', help='[!] guarantee ASCII output')
|
||||
parser.add_argument('-fakehdr', action='store_true', help='[!] save 225b file header as fake resource')
|
||||
parser.add_argument('-extract', action='store_true', help='[!] extract Sys7-style compressed resources')
|
||||
parser.add_argument('-expand', action='store_true', help='[!] expand Sys7-style compressed resources')
|
||||
parser.add_argument('-useDF', action='store_true', help='ignored: data fork is always used')
|
||||
|
||||
args = parser.parse_args()
|
||||
@ -25,7 +25,7 @@ with open(args.resourceFile, 'rb') as f:
|
||||
resources = macresources.parse_file(f.read(), fake_header_rsrc=args.fakehdr)
|
||||
|
||||
try:
|
||||
rez = macresources.make_rez_code(resources, ascii_clean=args.ascii, extract=args.extract)
|
||||
rez = macresources.make_rez_code(resources, ascii_clean=args.ascii, expand=args.expand)
|
||||
sys.stdout.buffer.write(rez)
|
||||
except BrokenPipeError:
|
||||
pass # like we get when we pipe into head
|
||||
|
@ -170,10 +170,10 @@ class Resource:
|
||||
self._cache = CompressResource(self.data, self.compression_format)
|
||||
self._cache_hash = hash_mutable(self.data)
|
||||
|
||||
def _rez_repr(self, extract=False):
|
||||
def _rez_repr(self, expand=False):
|
||||
# decide now: what raw data will we slap down?
|
||||
if self.compression_format:
|
||||
if extract:
|
||||
if expand:
|
||||
if self.compression_format == 'UnknownCompression':
|
||||
attribs = ResourceAttrs(self.attribs | 1) # at lease Rez will produce the right file
|
||||
data = self.data # will throw a warning
|
||||
@ -415,7 +415,7 @@ def make_file(from_iter, align=1):
|
||||
return bytes(accum)
|
||||
|
||||
|
||||
def make_rez_code(from_iter, ascii_clean=False, extract=False):
|
||||
def make_rez_code(from_iter, ascii_clean=False, expand=False):
|
||||
"""Express an iterator of Resource objects as Rez code (bytes).
|
||||
|
||||
This will match the output of the deprecated Rez utility, unless the
|
||||
@ -429,7 +429,7 @@ def make_rez_code(from_iter, ascii_clean=False, extract=False):
|
||||
|
||||
lines = []
|
||||
for resource in from_iter:
|
||||
data, attribs, compression_format = resource._rez_repr(extract=extract)
|
||||
data, attribs, compression_format = resource._rez_repr(expand=expand)
|
||||
|
||||
args = []
|
||||
args.append(str(resource.id).encode('ascii'))
|
||||
|
Loading…
Reference in New Issue
Block a user