diff --git a/bin/SimpleDeRez b/bin/SimpleDeRez index 26a372f..62ca3a3 100755 --- a/bin/SimpleDeRez +++ b/bin/SimpleDeRez @@ -16,7 +16,6 @@ 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('-compcmt', action='store_true', help='[!] helpfully comment compressed resources') parser.add_argument('-useDF', action='store_true', help='ignored: data fork is always used') args = parser.parse_args() @@ -25,7 +24,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, cmt_unsupported_attrib=args.compcmt) + rez = macresources.make_rez_code(resources, ascii_clean=args.ascii) sys.stdout.buffer.write(rez) except BrokenPipeError: pass # like we get when we pipe into head diff --git a/macresources/main.py b/macresources/main.py index ebc9654..7897ead 100644 --- a/macresources/main.py +++ b/macresources/main.py @@ -91,13 +91,10 @@ class ResourceAttrs(enum.IntFlag): _changed = 0x02 # marks a resource that has been changes since loading from file (should not be seen on disk) _compressed = 0x01 # "indicates that the resource data is compressed" (only documented in https://github.com/kreativekorp/ksfl/wiki/Macintosh-Resource-File-Format) - def _for_derez(self, cmt_unsupported=True): - mylist = [p.name for p in self.__class__ if self & p] - if any(p.startswith('_') for p in mylist): - arg = '$%02X' % self - if cmt_unsupported: arg += ' /*%s*/' % ', '.join(mylist) - mylist = [arg] - return mylist + def _for_derez(self): + for possible in self.__class__: + if not possible.name.startswith('_') and self & possible: + yield possible.name class Resource: @@ -188,11 +185,6 @@ def parse_rez_code(from_rezcode): for line in from_rezcode.split(b'\n'): line = line.lstrip() - while b'/*' in line: - a, b, c = line.partition(b'/*') - d, e, f = c.partition(b'*/') - line = a + f - if line.startswith(b'data '): try: yield cur_resource @@ -337,7 +329,7 @@ def make_file(from_iter, align=1): return bytes(accum) -def make_rez_code(from_iter, ascii_clean=False, cmt_unsupported_attrib=False): +def make_rez_code(from_iter, ascii_clean=False): """Express an iterator of Resource objects as Rez code (bytes). This will match the output of the deprecated Rez utility, unless the @@ -355,7 +347,7 @@ def make_rez_code(from_iter, ascii_clean=False, cmt_unsupported_attrib=False): args.append(str(resource.id).encode('ascii')) if resource.name is not None: args.append(_rez_escape(resource.name.encode('mac_roman'), singlequote=False, ascii_clean=ascii_clean)) - args.extend(x.encode('ascii') for x in resource.attribs._for_derez(cmt_unsupported=cmt_unsupported_attrib)) + args.extend(x.encode('ascii') for x in resource.attribs._for_derez()) args = b', '.join(args) fourcc = _rez_escape(resource.type, singlequote=True, ascii_clean=ascii_clean)