summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1996-10-22 15:33:02 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1996-10-22 15:33:02 (GMT)
commit84872293dd94067a3dec8036466073520125e110 (patch)
tree1e526de97c47e32abdf5defed1f1364e666fcbd4 /Mac
parentd09deac2da5460ffaa3627b69574813e3e1e0670 (diff)
downloadcpython-84872293dd94067a3dec8036466073520125e110.zip
cpython-84872293dd94067a3dec8036466073520125e110.tar.gz
cpython-84872293dd94067a3dec8036466073520125e110.tar.bz2
Get preference file name from a resource.
Changed for 1.8.0 CWGUSI release
Diffstat (limited to 'Mac')
-rw-r--r--Mac/scripts/EditPythonPrefs.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/Mac/scripts/EditPythonPrefs.py b/Mac/scripts/EditPythonPrefs.py
index 7cabfa1..eda4bf7 100644
--- a/Mac/scripts/EditPythonPrefs.py
+++ b/Mac/scripts/EditPythonPrefs.py
@@ -14,6 +14,9 @@ import os
import sys
import Res # For Res.Error
+# Resource in the Python resource chain
+PREFNAME_NAME="PythonPreferenceFileName"
+
# resource IDs in our own resources (dialogs, etc)
MESSAGE_ID = 256
@@ -53,7 +56,9 @@ GUSIPOS_TYPE=0
GUSIPOS_CREATOR=4
GUSIPOS_SKIP=8
GUSIPOS_FLAGS=9
-GUSIFLAGS_DELAY=0x04 # Mask
+GUSIPOS_VERSION=10
+GUSIVERSION='0181'
+GUSIFLAGS_DELAY=0x20 # Mask
READ = 1
WRITE = 2
@@ -201,23 +206,37 @@ def getgusioptions(id):
type = data[GUSIPOS_TYPE:GUSIPOS_TYPE+4]
creator = data[GUSIPOS_CREATOR:GUSIPOS_CREATOR+4]
flags = ord(data[GUSIPOS_FLAGS])
+ version = data[GUSIPOS_VERSION:GUSIPOS_VERSION+4]
+ if version <> GUSIVERSION:
+ message('GU\267I resource version "%s", fixing to "%s"'%(version, GUSIVERSION))
+ flags = 0
delay = (not not (flags & GUSIFLAGS_DELAY))
return creator, type, delay, opr
def setgusioptions(opr, creator, type, delay):
data = opr.data
flags = ord(data[GUSIPOS_FLAGS])
+ version = data[GUSIPOS_VERSION:GUSIPOS_VERSION+4]
+ if version <> GUSIVERSION:
+ flags = 0x88
+ version = GUSIVERSION
if delay:
flags = flags | GUSIFLAGS_DELAY
else:
flags = flags & ~GUSIFLAGS_DELAY
- data = type + creator + data[GUSIPOS_SKIP] + chr(flags) + data[GUSIPOS_FLAGS+1:]
+ data = type + creator + data[GUSIPOS_SKIP] + chr(flags) + GUSIVERSION + data[GUSIPOS_VERSION+4:]
return data
def openpreffile(rw):
# Find the preferences folder and our prefs file, create if needed.
vrefnum, dirid = macfs.FindFolder(kOnSystemDisk, 'pref', 0)
- preff_fss = macfs.FSSpec((vrefnum, dirid, 'Python Preferences'))
+ try:
+ pnhandle = GetNamedResource('STR ', PREFNAME_NAME)
+ except Res.Error:
+ message("No %s resource (old Python?)"%PREFNAME_NAME)
+ sys.exit(1)
+ prefname = pnhandle.data[1:]
+ preff_fss = macfs.FSSpec((vrefnum, dirid, prefname))
try:
preff_handle = FSpOpenResFile(preff_fss, rw)
except Res.Error: