1# Python script to get both the data and resource fork from a BinHex encoded 2# file. 3# Author: MURAOKA Taro <[email protected]> 4# Last Change: 2018 Mar 27 5# 6# Copyright (C) 2003,12 MURAOKA Taro <[email protected]> 7# THIS FILE IS DISTRIBUTED UNDER THE VIM LICENSE. 8 9import sys 10import binhex 11 12input = sys.argv[1] 13conv = binhex.HexBin(input) 14info = conv.FInfo 15out = conv.FName 16out_data = out 17out_rsrc = out + '.rsrcfork' 18 19# This uses the print statement on Python 2, print function on Python 3. 20#print('out_rsrc=' + out_rsrc) 21print('In file: ' + input) 22 23outfile = open(out_data, 'wb') 24print(' Out data fork: ' + out_data) 25while 1: 26 d = conv.read(128000) 27 if not d: break 28 outfile.write(d) 29outfile.close() 30conv.close_data() 31 32d = conv.read_rsrc(128000) 33if d: 34 print(' Out rsrc fork: ' + out_rsrc) 35 outfile = open(out_rsrc, 'wb') 36 outfile.write(d) 37 while 1: 38 d = conv.read_rsrc(128000) 39 if not d: break 40 outfile.write(d) 41 outfile.close() 42 43conv.close() 44 45# vim:set ts=8 sts=4 sw=4 et: 46