summaryrefslogtreecommitdiffstats
path: root/Mac/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Mac/Lib')
-rw-r--r--Mac/Lib/EasyDialogs.py16
-rw-r--r--Mac/Lib/buildtools.py57
-rw-r--r--Mac/Lib/dialogs.rsrcbin0 -> 19016 bytes
-rw-r--r--Mac/Lib/errors.rsrcbin0 -> 86868 bytes
-rw-r--r--Mac/Lib/macresource.py5
5 files changed, 35 insertions, 43 deletions
diff --git a/Mac/Lib/EasyDialogs.py b/Mac/Lib/EasyDialogs.py
index 52aad97..8b81063 100644
--- a/Mac/Lib/EasyDialogs.py
+++ b/Mac/Lib/EasyDialogs.py
@@ -27,6 +27,15 @@ import MacOS
import string
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):
if '\r' in text:
@@ -47,7 +56,7 @@ def Message(msg, id=260, ok=None):
The MESSAGE string can be at most 255 characters long.
"""
-
+ _initialize()
d = GetNewDialog(id, -1)
if not d:
print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
@@ -79,6 +88,7 @@ def AskString(prompt, default = "", id=261, ok=None, cancel=None):
can be at most 255 characters long.
"""
+ _initialize()
d = GetNewDialog(id, -1)
if not d:
print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
@@ -119,6 +129,7 @@ def AskPassword(prompt, default='', id=264, ok=None, cancel=None):
The PROMPT and DEFAULT strings, as well as the return value,
can be at most 255 characters long.
"""
+ _initialize()
d = GetNewDialog(id, -1)
if not d:
print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
@@ -161,6 +172,7 @@ def AskYesNoCancel(question, default = 0, yes=None, no=None, cancel=None, id=262
The QUESTION string can be at most 255 characters.
"""
+ _initialize()
d = GetNewDialog(id, -1)
if not d:
print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
@@ -221,6 +233,7 @@ class ProgressBar:
def __init__(self, title="Working...", maxval=0, label="", id=263):
self.w = None
self.d = None
+ _initialize()
self.d = GetNewDialog(id, -1)
self.w = self.d.GetDialogWindow()
self.label(label)
@@ -391,6 +404,7 @@ def _selectoption(d, optionlist, idx):
def GetArgv(optionlist=None, commandlist=None, addoldfile=1, addnewfile=1, addfolder=1, id=ARGV_ID):
+ _initialize()
d = GetNewDialog(id, -1)
if not d:
print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
diff --git a/Mac/Lib/buildtools.py b/Mac/Lib/buildtools.py
index a02c609..163f19a 100644
--- a/Mac/Lib/buildtools.py
+++ b/Mac/Lib/buildtools.py
@@ -353,58 +353,31 @@ def process_common_macho(template, progress, code, rsrcname, destname, is_update
ofp.close()
- 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
try:
input = macresource.open_pathname(rsrcname)
except (MacOS.Error, ValueError):
- pass
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)
-
- # 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)
+ Res.CloseResFile(output)
if code:
if raw:
diff --git a/Mac/Lib/dialogs.rsrc b/Mac/Lib/dialogs.rsrc
new file mode 100644
index 0000000..711bd5b
--- /dev/null
+++ b/Mac/Lib/dialogs.rsrc
Binary files differ
diff --git a/Mac/Lib/errors.rsrc b/Mac/Lib/errors.rsrc
new file mode 100644
index 0000000..61c487e
--- /dev/null
+++ b/Mac/Lib/errors.rsrc
Binary files differ
diff --git a/Mac/Lib/macresource.py b/Mac/Lib/macresource.py
index 3a1161b..26f90940 100644
--- a/Mac/Lib/macresource.py
+++ b/Mac/Lib/macresource.py
@@ -95,6 +95,11 @@ def open_pathname(pathname, verbose=0):
raise
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.
newpathname = pathname + '.df.rsrc'