xref: /vim-8.2.3635/src/dehqx.py (revision 2bf24176)
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: 2012 Jun 29
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#print 'out_rsrc=' + out_rsrc
19print 'In file: ' + input
20
21outfile = open(out_data, 'wb')
22print '  Out data fork: ' + out_data
23while 1:
24    d = conv.read(128000)
25    if not d: break
26    outfile.write(d)
27outfile.close()
28conv.close_data()
29
30d = conv.read_rsrc(128000)
31if d:
32    print '  Out rsrc fork: ' + out_rsrc
33    outfile = open(out_rsrc, 'wb')
34    outfile.write(d)
35    while 1:
36        d = conv.read_rsrc(128000)
37        if not d: break
38        outfile.write(d)
39    outfile.close()
40
41conv.close()
42
43# vim:set ts=8 sts=4 sw=4 et:
44