Back to index

python3.2  3.2.2
Classes | Functions | Variables
binhex Namespace Reference

Classes

class  Error
class  FInfo
class  openrsrc
class  _Hqxcoderengine
class  _Rlecoderengine
class  BinHex
class  _Hqxdecoderengine
class  _Rledecoderengine
class  HexBin

Functions

def getfileinfo
def binhex
def hexbin

Variables

list __all__ = ["binhex","hexbin","Error"]
int REASONABLY_LARGE = 32768
int LINELEN = 64
string RUNCHAR = "\x90"

Detailed Description

Macintosh binhex compression/decompression.

easy interface:
binhex(inputfilename, outputfilename)
hexbin(inputfilename, outputfilename)

Function Documentation

def binhex.binhex (   inp,
  out 
)
binhex(infilename, outfilename): create binhex-encoded copy of a file

Definition at line 228 of file binhex.py.

00228 
00229 def binhex(inp, out):
00230     """binhex(infilename, outfilename): create binhex-encoded copy of a file"""
00231     finfo = getfileinfo(inp)
00232     ofp = BinHex(finfo, out)
00233 
00234     ifp = io.open(inp, 'rb')
00235     # XXXX Do textfile translation on non-mac systems
00236     while True:
00237         d = ifp.read(128000)
00238         if not d: break
00239         ofp.write(d)
00240     ofp.close_data()
00241     ifp.close()
00242 
00243     ifp = openrsrc(inp, 'rb')
00244     while True:
00245         d = ifp.read(128000)
00246         if not d: break
00247         ofp.write_rsrc(d)
00248     ofp.close()
00249     ifp.close()

Here is the call graph for this function:

Here is the caller graph for this function:

def binhex.getfileinfo (   name)

Definition at line 53 of file binhex.py.

00053 
00054 def getfileinfo(name):
00055     finfo = FInfo()
00056     with io.open(name, 'rb') as fp:
00057         # Quick check for textfile
00058         data = fp.read(512)
00059         if 0 not in data:
00060             finfo.Type = 'TEXT'
00061         fp.seek(0, 2)
00062         dsize = fp.tell()
00063     dir, file = os.path.split(name)
00064     file = file.replace(':', '-', 1)
00065     return file, finfo, dsize, 0

Here is the caller graph for this function:

def binhex.hexbin (   inp,
  out 
)
hexbin(infilename, outfilename) - Decode binhexed file

Definition at line 446 of file binhex.py.

00446 
00447 def hexbin(inp, out):
00448     """hexbin(infilename, outfilename) - Decode binhexed file"""
00449     ifp = HexBin(inp)
00450     finfo = ifp.FInfo
00451     if not out:
00452         out = ifp.FName
00453 
00454     ofp = io.open(out, 'wb')
00455     # XXXX Do translation on non-mac systems
00456     while True:
00457         d = ifp.read(128000)
00458         if not d: break
00459         ofp.write(d)
00460     ofp.close()
00461     ifp.close_data()
00462 
00463     d = ifp.read_rsrc(128000)
00464     if d:
00465         ofp = openrsrc(out, 'wb')
00466         ofp.write(d)
00467         while True:
00468             d = ifp.read_rsrc(128000)
00469             if not d: break
00470             ofp.write(d)
00471         ofp.close()
00472 
00473     ifp.close()

Here is the caller graph for this function:


Variable Documentation

list binhex.__all__ = ["binhex","hexbin","Error"]

Definition at line 30 of file binhex.py.

Definition at line 40 of file binhex.py.

Definition at line 39 of file binhex.py.

Definition at line 41 of file binhex.py.