Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4d9bd9c8
Commit
4d9bd9c8
authored
May 24, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
This is the last time I fix binhex. If it breaks again it goes in the dustbin.
parent
8474f01c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
Lib/binhex.py
Lib/binhex.py
+8
-10
No files found.
Lib/binhex.py
View file @
4d9bd9c8
...
@@ -53,7 +53,7 @@ try:
...
@@ -53,7 +53,7 @@ try:
finfo
=
FSSpec
(
name
).
FSpGetFInfo
()
finfo
=
FSSpec
(
name
).
FSpGetFInfo
()
dir
,
file
=
os
.
path
.
split
(
name
)
dir
,
file
=
os
.
path
.
split
(
name
)
# XXX Get resource/data sizes
# XXX Get resource/data sizes
fp
=
open
(
name
,
'rb'
)
fp
=
io
.
open
(
name
,
'rb'
)
fp
.
seek
(
0
,
2
)
fp
.
seek
(
0
,
2
)
dlen
=
fp
.
tell
()
dlen
=
fp
.
tell
()
fp
=
openrf
(
name
,
'*rb'
)
fp
=
openrf
(
name
,
'*rb'
)
...
@@ -172,11 +172,11 @@ class BinHex:
...
@@ -172,11 +172,11 @@ class BinHex:
name
,
finfo
,
dlen
,
rlen
=
name_finfo_dlen_rlen
name
,
finfo
,
dlen
,
rlen
=
name_finfo_dlen_rlen
if
isinstance
(
ofp
,
basestring
):
if
isinstance
(
ofp
,
basestring
):
ofname
=
ofp
ofname
=
ofp
ofp
=
open
(
ofname
,
'w
'
)
ofp
=
io
.
open
(
ofname
,
'wb
'
)
if
os
.
name
==
'mac'
:
if
os
.
name
==
'mac'
:
fss
=
FSSpec
(
ofname
)
fss
=
FSSpec
(
ofname
)
fss
.
SetCreatorType
(
'BnHq'
,
'TEXT'
)
fss
.
SetCreatorType
(
'BnHq'
,
'TEXT'
)
ofp
.
write
(
'(This file must be converted with BinHex 4.0)
\
n
\
n
:'
)
ofp
.
write
(
b'(This file must be converted with BinHex 4.0)
\
r
\
r
:'
)
hqxer
=
_Hqxcoderengine
(
ofp
)
hqxer
=
_Hqxcoderengine
(
ofp
)
self
.
ofp
=
_Rlecoderengine
(
hqxer
)
self
.
ofp
=
_Rlecoderengine
(
hqxer
)
self
.
crc
=
0
self
.
crc
=
0
...
@@ -253,7 +253,7 @@ def binhex(inp, out):
...
@@ -253,7 +253,7 @@ def binhex(inp, out):
finfo
=
getfileinfo
(
inp
)
finfo
=
getfileinfo
(
inp
)
ofp
=
BinHex
(
finfo
,
out
)
ofp
=
BinHex
(
finfo
,
out
)
ifp
=
open
(
inp
,
'rb'
)
ifp
=
io
.
open
(
inp
,
'rb'
)
# XXXX Do textfile translation on non-mac systems
# XXXX Do textfile translation on non-mac systems
while
1
:
while
1
:
d
=
ifp
.
read
(
128000
)
d
=
ifp
.
read
(
128000
)
...
@@ -371,7 +371,7 @@ class _Rledecoderengine:
...
@@ -371,7 +371,7 @@ class _Rledecoderengine:
class
HexBin
:
class
HexBin
:
def
__init__
(
self
,
ifp
):
def
__init__
(
self
,
ifp
):
if
isinstance
(
ifp
,
basestring
):
if
isinstance
(
ifp
,
basestring
):
ifp
=
open
(
ifp
)
ifp
=
io
.
open
(
ifp
,
'rb'
)
#
#
# Find initial colon.
# Find initial colon.
#
#
...
@@ -381,12 +381,10 @@ class HexBin:
...
@@ -381,12 +381,10 @@ class HexBin:
raise
Error
,
"No binhex data found"
raise
Error
,
"No binhex data found"
# Cater for \r\n terminated lines (which show up as \n\r, hence
# Cater for \r\n terminated lines (which show up as \n\r, hence
# all lines start with \r)
# all lines start with \r)
if
ch
==
'
\
r
'
:
if
ch
==
b
'
\
r
'
:
continue
continue
if
ch
==
':'
:
if
ch
==
b
':'
:
break
break
if
ch
!=
'
\
n
'
:
dummy
=
ifp
.
readline
()
hqxifp
=
_Hqxdecoderengine
(
ifp
)
hqxifp
=
_Hqxdecoderengine
(
ifp
)
self
.
ifp
=
_Rledecoderengine
(
hqxifp
)
self
.
ifp
=
_Rledecoderengine
(
hqxifp
)
...
@@ -480,7 +478,7 @@ def hexbin(inp, out):
...
@@ -480,7 +478,7 @@ def hexbin(inp, out):
ofss
=
FSSpec
(
out
)
ofss
=
FSSpec
(
out
)
out
=
ofss
.
as_pathname
()
out
=
ofss
.
as_pathname
()
ofp
=
open
(
out
,
'wb'
)
ofp
=
io
.
open
(
out
,
'wb'
)
# XXXX Do translation on non-mac systems
# XXXX Do translation on non-mac systems
while
1
:
while
1
:
d
=
ifp
.
read
(
128000
)
d
=
ifp
.
read
(
128000
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment