[Python-checkins] python/dist/src/Mac/Lib dialogs.rsrc,NONE,1.1 errors.rsrc,NONE,1.1 EasyDialogs.py,1.38,1.39 buildtools.py,1.18,1.19 macresource.py,1.8,1.9
jackjansen@users.sourceforge.net
jackjansen@users.sourceforge.net
Thu, 07 Nov 2002 15:07:08 -0800
Update of /cvsroot/python/python/dist/src/Mac/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv8033/Mac/Lib
Modified Files:
EasyDialogs.py buildtools.py macresource.py
Added Files:
dialogs.rsrc errors.rsrc
Log Message:
Got rid of the python.rsrc resource file. The error message strings and
dialogs are now stored in Mac/Lib, and loaded on demand through macresource.
Not only does this simplify a MacPython based on Apple's Python, but
it also makes Mac error codes come out symbolically when running command
line python (if you have Mac/Lib in your path).
The resource files are copied from Mac/Resources. The old ones will disappear
after the OS9 build procedure has been adjusted.
--- NEW FILE: dialogs.rsrc ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: errors.rsrc ---
(This appears to be a binary file; contents omitted.)
Index: EasyDialogs.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Lib/EasyDialogs.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** EasyDialogs.py 2 Aug 2002 11:03:19 -0000 1.38
--- EasyDialogs.py 7 Nov 2002 23:07:04 -0000 1.39
***************
*** 28,31 ****
--- 28,40 ----
from Carbon.ControlAccessor import * # Also import Controls constants
import macfs
+ import macresource
+
+ _initialized = 0
+
+ def _initialize():
+ global _initialized
+ if _initialized: return
+ macresource.need("DLOG", 260, "dialogs.rsrc", __name__)
+
def cr2lf(text):
***************
*** 48,52 ****
The MESSAGE string can be at most 255 characters long.
"""
!
d = GetNewDialog(id, -1)
if not d:
--- 57,61 ----
The MESSAGE string can be at most 255 characters long.
"""
! _initialize()
d = GetNewDialog(id, -1)
if not d:
***************
*** 80,83 ****
--- 89,93 ----
"""
+ _initialize()
d = GetNewDialog(id, -1)
if not d:
***************
*** 120,123 ****
--- 130,134 ----
can be at most 255 characters long.
"""
+ _initialize()
d = GetNewDialog(id, -1)
if not d:
***************
*** 162,165 ****
--- 173,177 ----
"""
+ _initialize()
d = GetNewDialog(id, -1)
if not d:
***************
*** 222,225 ****
--- 234,238 ----
self.w = None
self.d = None
+ _initialize()
self.d = GetNewDialog(id, -1)
self.w = self.d.GetDialogWindow()
***************
*** 392,395 ****
--- 405,409 ----
def GetArgv(optionlist=None, commandlist=None, addoldfile=1, addnewfile=1, addfolder=1, id=ARGV_ID):
+ _initialize()
d = GetNewDialog(id, -1)
if not d:
Index: buildtools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Lib/buildtools.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** buildtools.py 29 Aug 2002 20:20:24 -0000 1.18
--- buildtools.py 7 Nov 2002 23:07:04 -0000 1.19
***************
*** 354,371 ****
- if progress:
- progress.label("Copy resources...")
- progress.set(20)
- resfilename = 'python.rsrc' # XXXX later: '%s.rsrc' % shortname
- try:
- output = Res.FSOpenResourceFile(
- os.path.join(destname, 'Contents', 'Resources', resfilename),
- u'', WRITE)
- except MacOS.Error:
- fsr, dummy = Res.FSCreateResourceFile(
- os.path.join(destname, 'Contents', 'Resources'),
- unicode(resfilename), '')
- output = Res.FSOpenResourceFile(fsr, u'', WRITE)
-
# Copy the resources from the target specific resource template, if any
typesfound, ownertype = [], None
--- 354,357 ----
***************
*** 373,409 ****
input = macresource.open_pathname(rsrcname)
except (MacOS.Error, ValueError):
- pass
if progress:
progress.inc(50)
else:
typesfound, ownertype = copyres(input, output, [], 0, progress)
Res.CloseResFile(input)
!
! # Check which resource-types we should not copy from the template
! skiptypes = []
! ## if 'vers' in typesfound: skiptypes.append('vers')
! ## if 'SIZE' in typesfound: skiptypes.append('SIZE')
! ## if 'BNDL' in typesfound: skiptypes = skiptypes + ['BNDL', 'FREF', 'icl4',
! ## 'icl8', 'ics4', 'ics8', 'ICN#', 'ics#']
! ## if not copy_codefragment:
! ## skiptypes.append('cfrg')
! ## skipowner = (ownertype <> None)
!
! # Copy the resources from the template
!
! input = Res.FSOpenResourceFile(
! os.path.join(template, 'Contents', 'Resources', 'python.rsrc'), u'', READ)
! if progress:
! progress.label("Copy standard resources...")
! progress.inc(0)
! ## dummy, tmplowner = copyres(input, output, skiptypes, 1, progress)
! dummy, tmplowner = copyres(input, output, skiptypes, 1, None)
!
! Res.CloseResFile(input)
! ## if ownertype == None:
! ## raise BuildError, "No owner resource found in either resource file or template"
! # Make sure we're manipulating the output resource file now
!
! Res.CloseResFile(output)
if code:
--- 359,382 ----
input = macresource.open_pathname(rsrcname)
except (MacOS.Error, ValueError):
if progress:
progress.inc(50)
else:
+ if progress:
+ progress.label("Copy resources...")
+ progress.set(20)
+ resfilename = 'python.rsrc' # XXXX later: '%s.rsrc' % shortname
+ try:
+ output = Res.FSOpenResourceFile(
+ os.path.join(destname, 'Contents', 'Resources', resfilename),
+ u'', WRITE)
+ except MacOS.Error:
+ fsr, dummy = Res.FSCreateResourceFile(
+ os.path.join(destname, 'Contents', 'Resources'),
+ unicode(resfilename), '')
+ output = Res.FSOpenResourceFile(fsr, u'', WRITE)
+
typesfound, ownertype = copyres(input, output, [], 0, progress)
Res.CloseResFile(input)
! Res.CloseResFile(output)
if code:
Index: macresource.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Lib/macresource.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** macresource.py 9 Aug 2002 13:44:03 -0000 1.8
--- macresource.py 7 Nov 2002 23:07:05 -0000 1.9
***************
*** 96,99 ****
--- 96,104 ----
return refno
+ def open_error_resource():
+ """Open the resource file containing the error code to error message
+ mapping."""
+ need('Estr', 1, filename="errors.rsrc", modname=__name__)
+
def _decode(pathname, verbose=0):
# Decode an AppleSingle resource file, return the new pathname.