Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
binhex Namespace Reference

Data Structures

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

Functions

def FInfo
 
def getfileinfo
 
def openrsrc
 
def binhex
 
def hexbin
 

Variables

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

Detailed Description

Macintosh binhex compression/decompression.

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

Function Documentation

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

Definition at line 257 of file binhex.py.

References getfileinfo(), and aifc.open().

258 def binhex(inp, out):
259  """(infilename, outfilename) - Create binhex-encoded copy of a file"""
260  finfo = getfileinfo(inp)
261  ofp = BinHex(finfo, out)
262 
263  ifp = open(inp, 'rb')
264  # XXXX Do textfile translation on non-mac systems
265  while 1:
266  d = ifp.read(128000)
267  if not d: break
268  ofp.write(d)
269  ofp.close_data()
270  ifp.close()
271 
272  ifp = openrsrc(inp, 'rb')
273  while 1:
274  d = ifp.read(128000)
275  if not d: break
276  ofp.write_rsrc(d)
277  ofp.close()
278  ifp.close()
def binhex.FInfo ( )

Definition at line 56 of file binhex.py.

56 
57  def FInfo():
58  return macfs.FInfo()
def getfileinfo (   name)

Definition at line 59 of file binhex.py.

References aifc.open(), and openrf.

59 
60  def getfileinfo(name):
61  finfo = macfs.FSSpec(name).GetFInfo()
62  dir, file = os.path.split(name)
63  # XXXX Get resource/data sizes
64  fp = open(name, 'rb')
65  fp.seek(0, 2)
66  dlen = fp.tell()
67  fp = openrf(name, '*rb')
68  fp.seek(0, 2)
69  rlen = fp.tell()
70  return file, finfo, dlen, rlen
def binhex.hexbin (   inp,
  out 
)
(infilename, outfilename) - Decode binhexed file

Definition at line 479 of file binhex.py.

References aifc.open().

480 def hexbin(inp, out):
481  """(infilename, outfilename) - Decode binhexed file"""
482  ifp = HexBin(inp)
483  finfo = ifp.FInfo
484  if not out:
485  out = ifp.FName
486  if os.name == 'mac':
487  ofss = macfs.FSSpec(out)
488  out = ofss.as_pathname()
489 
490  ofp = open(out, 'wb')
491  # XXXX Do translation on non-mac systems
492  while 1:
493  d = ifp.read(128000)
494  if not d: break
495  ofp.write(d)
496  ofp.close()
497  ifp.close_data()
498 
499  d = ifp.read_rsrc(128000)
500  if d:
501  ofp = openrsrc(out, 'wb')
502  ofp.write(d)
503  while 1:
504  d = ifp.read_rsrc(128000)
505  if not d: break
506  ofp.write(d)
507  ofp.close()
508 
509  if os.name == 'mac':
510  nfinfo = ofss.GetFInfo()
511  nfinfo.Creator = finfo.Creator
512  nfinfo.Type = finfo.Type
513  nfinfo.Flags = finfo.Flags
514  ofss.SetFInfo(nfinfo)
515 
516  ifp.close()
def binhex.openrsrc (   name,
  mode 
)

Definition at line 71 of file binhex.py.

References openrf.

71 
72  def openrsrc(name, *mode):
73  if not mode:
74  mode = '*rb'
75  else:
76  mode = '*' + mode[0]
77  return openrf(name, mode)
78 
else:

Variable Documentation

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

Definition at line 29 of file binhex.py.

openrf = MacOS.openrf

Definition at line 51 of file binhex.py.