summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Mac/Tools/IDE/MacPrefs.py13
-rw-r--r--Mac/Tools/IDE/ProfileBrowser.py1
-rw-r--r--Mac/Tools/IDE/PyBrowser.py4
-rw-r--r--Mac/Tools/IDE/PyConsole.py6
-rw-r--r--Mac/Tools/IDE/PyDocSearch.py1
-rw-r--r--Mac/Tools/IDE/PyEdit.py33
-rw-r--r--Mac/Tools/IDE/PythonIDEMain.py45
-rw-r--r--Mac/Tools/IDE/Wapplication.py9
-rw-r--r--Mac/Tools/IDE/Wquicktime.py11
9 files changed, 55 insertions, 68 deletions
diff --git a/Mac/Tools/IDE/MacPrefs.py b/Mac/Tools/IDE/MacPrefs.py
index 6c7c553..25dda4f 100644
--- a/Mac/Tools/IDE/MacPrefs.py
+++ b/Mac/Tools/IDE/MacPrefs.py
@@ -1,8 +1,7 @@
-import macfs
import marshal
import types
-
-from MACFS import kOnSystemDisk
+from Carbon import Folder
+from Carbon import Folders
class PrefObject:
@@ -71,8 +70,7 @@ class PrefFile(PrefObject):
prefdict[key] = value
marshal.dump(prefdict, open(self.__path, 'wb'))
try:
- fss = macfs.FSSpec(macfs.FSRef(self.__path))
- fss.SetCreatorType(self.__creator, 'pref')
+ MacOS.SetCreatorAndType(self.__path, self.__creator, 'pref')
except:
pass
@@ -98,9 +96,8 @@ def GetPrefs(prefname, creator = 'Pyth'):
if _prefscache.has_key(prefname):
return _prefscache[prefname]
# Find the preferences folder and our prefs file, create if needed.
- vrefnum, dirid = macfs.FindFolder(kOnSystemDisk, 'pref', 0)
- prefsfolder_fss = macfs.FSSpec((vrefnum, dirid, ''))
- prefsfolder = macfs.FSRef(prefsfolder_fss).as_fsspec().as_pathname()
+ fsr = Folder.FSFindFolder(Folders.kOnSystemDisk, 'pref', 1)
+ prefsfolder = fsr.as_pathname()
path = os.path.join(prefsfolder, prefname)
head, tail = os.path.split(path)
# make sure the folder(s) exist
diff --git a/Mac/Tools/IDE/ProfileBrowser.py b/Mac/Tools/IDE/ProfileBrowser.py
index c7a81cc..a19641c 100644
--- a/Mac/Tools/IDE/ProfileBrowser.py
+++ b/Mac/Tools/IDE/ProfileBrowser.py
@@ -83,7 +83,6 @@ def main():
stats = pstats.Stats(i)
browser = ProfileBrowser(stats)
else:
- import macfs
filename = EasyDialogs.AskFileForOpen(message='Profiler data')
if not filename: sys.exit(0)
stats = pstats.Stats(filename)
diff --git a/Mac/Tools/IDE/PyBrowser.py b/Mac/Tools/IDE/PyBrowser.py
index d81c46f..19ddbef 100644
--- a/Mac/Tools/IDE/PyBrowser.py
+++ b/Mac/Tools/IDE/PyBrowser.py
@@ -322,9 +322,7 @@ class BrowserWidget(W.CustomList):
editor.select()
return
elif os.path.exists(value) and os.path.isfile(value):
- import macfs
- fss = macfs.FSSpec(value)
- if fss.GetCreatorType()[1] == 'TEXT':
+ if MacOS.GetCreatorAndType(value)[1] in ('TEXT', '\0\0\0\0'):
W.getapplication().openscript(value)
def itemrepr(self, (key, value, arrow, indent), str = str, double_repr = double_repr,
diff --git a/Mac/Tools/IDE/PyConsole.py b/Mac/Tools/IDE/PyConsole.py
index 27fc0cd..2bad07d 100644
--- a/Mac/Tools/IDE/PyConsole.py
+++ b/Mac/Tools/IDE/PyConsole.py
@@ -85,7 +85,6 @@ class ConsoleTextWidget(W.EditText):
self._inputstart = selstart
def domenu_save_as(self, *args):
- import macfs
filename = EasyDialogs.AskFileForSave(message='Save console text as:',
savedFileName='console.txt')
if not filename:
@@ -93,7 +92,7 @@ class ConsoleTextWidget(W.EditText):
f = open(filename, 'wb')
f.write(self.get())
f.close()
- fss.SetCreatorType(W._signature, 'TEXT')
+ MacOS.SetCreatorAndType(filename, W._signature, 'TEXT')
def write(self, text):
self._buf = self._buf + text
@@ -242,7 +241,6 @@ class OutputTextWidget(W.EditText):
def domenu_save_as(self, *args):
title = self._parentwindow.gettitle()
- import macfs
filename = EasyDialogs.AskFileForSave(message='Save %s text as:' % title,
savedFileName=title + '.txt')
if not filename:
@@ -250,7 +248,7 @@ class OutputTextWidget(W.EditText):
f = open(filename, 'wb')
f.write(self.get())
f.close()
- fss.SetCreatorType(W._signature, 'TEXT')
+ MacOS.SetCreatorAndType(filename, W._signature, 'TEXT')
def domenu_cut(self, *args):
self.domenu_copy(*args)
diff --git a/Mac/Tools/IDE/PyDocSearch.py b/Mac/Tools/IDE/PyDocSearch.py
index 61d3959..f9d2cb5 100644
--- a/Mac/Tools/IDE/PyDocSearch.py
+++ b/Mac/Tools/IDE/PyDocSearch.py
@@ -1,6 +1,5 @@
import re
import W
-import macfs
import os
import MacPrefs
import MacOS
diff --git a/Mac/Tools/IDE/PyEdit.py b/Mac/Tools/IDE/PyEdit.py
index cd3f3cc..aa2f808 100644
--- a/Mac/Tools/IDE/PyEdit.py
+++ b/Mac/Tools/IDE/PyEdit.py
@@ -4,14 +4,13 @@ import W
import Wtraceback
from Wkeys import *
-import macfs
-import MACFS
import MacOS
import EasyDialogs
from Carbon import Win
from Carbon import Res
from Carbon import Evt
from Carbon import Qd
+from Carbon import File
import os
import imp
import sys
@@ -19,6 +18,8 @@ import string
import marshal
import re
+smAllScripts = -3
+
if hasattr(Win, "FrontNonFloatingWindow"):
MyFrontWindow = Win.FrontNonFloatingWindow
else:
@@ -61,8 +62,7 @@ class Editor(W.Window):
f = open(path, "rb")
text = f.read()
f.close()
- fss = macfs.FSSpec(path)
- self._creator, filetype = fss.GetCreatorType()
+ self._creator, filetype = MacOS.GetCreatorAndType(path)
else:
raise IOError, "file '%s' does not exist" % path
self.path = path
@@ -134,7 +134,7 @@ class Editor(W.Window):
try:
resref = Res.FSpOpenResFile(self.path, 3)
except Res.Error:
- Res.FSpCreateResFile(self.path, self._creator, 'TEXT', MACFS.smAllScripts)
+ Res.FSpCreateResFile(self.path, self._creator, 'TEXT', smAllScripts)
resref = Res.FSpOpenResFile(self.path, 3)
try:
data = Res.Resource(marshal.dumps(self.settings))
@@ -389,8 +389,7 @@ class Editor(W.Window):
fp = open(self.path, 'wb') # open file in binary mode, data has '\r' line-endings
fp.write(data)
fp.close()
- fss = macfs.FSSpec(self.path)
- fss.SetCreatorType(self._creator, 'TEXT')
+ MacOS.SetCreatorAndType(self.path, self._creator, 'TEXT')
self.getsettings()
self.writewindowsettings()
self.editgroup.editor.changed = 0
@@ -419,8 +418,8 @@ class Editor(W.Window):
app.makeopenwindowsmenu()
if hasattr(app, 'makescriptsmenu'):
app = W.getapplication()
- fss, fss_changed = app.scriptsfolder.Resolve()
- path = fss.as_pathname()
+ fsr, changed = app.scriptsfolder.FSResolveAlias(None)
+ path = fsr.as_pathname()
if path == self.path[:len(path)]:
W.getapplication().makescriptsmenu()
@@ -546,14 +545,8 @@ class Editor(W.Window):
interp_path = os.path.join(sys.exec_prefix, "bin", "python")
file_path = self.path
if not os.path.exists(interp_path):
- # This "can happen" if we are running IDE under MacPython. Try
- # the standard location.
- interp_path = "/Library/Frameworks/Python.framework/Versions/2.3/bin/python"
- try:
- fsr = macfs.FSRef(interp_path)
- except macfs.Error:
- raise W.AlertError, "Can't find command-line Python"
- file_path = macfs.FSRef(macfs.FSSpec(self.path)).as_pathname()
+ # This "can happen" if we are running IDE under MacPython-OS9.
+ raise W.AlertError, "Can't find command-line Python"
cmd = '"%s" "%s" ; exit' % (interp_path, file_path)
t = Terminal.Terminal()
t.do_script(with_command=cmd)
@@ -1368,8 +1361,10 @@ def EditorDefaultSettings():
def resolvealiases(path):
try:
- return macfs.ResolveAliasFile(path)[0].as_pathname()
- except (macfs.error, ValueError), (error, str):
+ fsr, d1, d2 = File.FSResolveAliasFile(path, 1)
+ path = fsr.as_pathname()
+ return path
+ except (File.Error, ValueError), (error, str):
if error <> -120:
raise
dir, file = os.path.split(path)
diff --git a/Mac/Tools/IDE/PythonIDEMain.py b/Mac/Tools/IDE/PythonIDEMain.py
index 765d988..365082d 100644
--- a/Mac/Tools/IDE/PythonIDEMain.py
+++ b/Mac/Tools/IDE/PythonIDEMain.py
@@ -7,9 +7,10 @@ import Wapplication
import W
import os
import sys
-import macfs
import MacOS
import EasyDialogs
+from Carbon import File
+from Carbon import Files
if MacOS.runtimemodel == 'macho':
ELIPSES = '...'
@@ -23,6 +24,10 @@ def runningOnOSX():
value = gestalt("menu") & gestaltMenuMgrAquaLayoutMask
return not not value
+def getmodtime(file):
+ file = File.FSRef(file)
+ catinfo, d1, d2, d3 = file.FSGetCatalogInfo(Files.kFSCatInfoContentMod)
+ return catinfo.contentModDate
class PythonIDE(Wapplication.Application):
@@ -125,21 +130,21 @@ class PythonIDE(Wapplication.Application):
prefs = self.getprefs()
try:
- fss, fss_changed = macfs.RawAlias(prefs.scriptsfolder).Resolve()
- self.scriptsfolder = fss.NewAlias()
+ fsr, d = File.Alias(rawdata=prefs.scriptsfolder).FSResolveAlias(None)
+ self.scriptsfolder = fsr.FSNewAliasMinimal()
except:
- path = os.path.join(os.getcwd(), ":Mac:IDE scripts")
+ path = os.path.join(os.getcwd(), "Mac", "IDE scripts")
if not os.path.exists(path):
path = os.path.join(os.getcwd(), "Scripts")
if not os.path.exists(path):
os.mkdir(path)
f = open(os.path.join(path, "Place your scripts here"+ELIPSES), "w")
f.close()
- fss = macfs.FSSpec(path)
- self.scriptsfolder = fss.NewAlias()
- self.scriptsfoldermodtime = fss.GetDates()[1]
+ fsr = File.FSRef(path)
+ self.scriptsfolder = fsr.FSNewAliasMinimal()
+ self.scriptsfoldermodtime = getmodtime(fsr)
else:
- self.scriptsfoldermodtime = fss.GetDates()[1]
+ self.scriptsfoldermodtime = getmodtime(fsr)
prefs.scriptsfolder = self.scriptsfolder.data
self._scripts = {}
self.scriptsmenu = None
@@ -153,9 +158,9 @@ class PythonIDE(Wapplication.Application):
def suspendresume(self, onoff):
if onoff:
- fss, fss_changed = self.scriptsfolder.Resolve()
- modtime = fss.GetDates()[1]
- if self.scriptsfoldermodtime <> modtime or fss_changed:
+ fsr, changed = self.scriptsfolder.FSResolveAlias(None)
+ modtime = getmodtime(fsr)
+ if self.scriptsfoldermodtime <> modtime or changed:
self.scriptsfoldermodtime = modtime
W.SetCursor('watch')
self.makescriptsmenu()
@@ -171,12 +176,12 @@ class PythonIDE(Wapplication.Application):
if type(docs) <> type([]):
docs = [docs]
for doc in docs:
- fss, a = doc.Resolve()
- path = fss.as_pathname()
+ fsr, a = doc.FSResolveAlias(None)
+ path = fsr.as_pathname()
self.opendoc(path)
def opendoc(self, path):
- fcreator, ftype = macfs.FSSpec(path).GetCreatorType()
+ fcreator, ftype = MacOS.GetCreatorAndType(path)
if ftype == 'TEXT':
self.openscript(path)
elif ftype == '\0\0\0\0' and path[-3:] == '.py':
@@ -191,11 +196,11 @@ class PythonIDE(Wapplication.Application):
Splash.about()
def do_setscriptsfolder(self, *args):
- fss = EasyDialogs.AskFolder(message="Select Scripts Folder",
- wanted=macfs.FSSpec)
- if fss:
+ fsr = EasyDialogs.AskFolder(message="Select Scripts Folder",
+ wanted=File.FSRef)
+ if fsr:
prefs = self.getprefs()
- alis = fss.NewAlias()
+ alis = fsr.FSNewAliasMinimal()
prefs.scriptsfolder = alis.data
self.scriptsfolder = alis
self.makescriptsmenu()
@@ -246,8 +251,8 @@ class PythonIDE(Wapplication.Application):
self.scriptsmenu = FrameWork.Menu(self.menubar, "Scripts")
#FrameWork.MenuItem(self.scriptsmenu, "New script", None, self.domenu_new)
#self.scriptsmenu.addseparator()
- fss, fss_changed = self.scriptsfolder.Resolve()
- self.scriptswalk(fss.as_pathname(), self.scriptsmenu)
+ fsr, d1 = self.scriptsfolder.FSResolveAlias(None)
+ self.scriptswalk(fsr.as_pathname(), self.scriptsmenu)
def makeopenwindowsmenu(self):
for i in range(len(self.openwindowsmenu.items)):
diff --git a/Mac/Tools/IDE/Wapplication.py b/Mac/Tools/IDE/Wapplication.py
index 5ad5589..abeee60 100644
--- a/Mac/Tools/IDE/Wapplication.py
+++ b/Mac/Tools/IDE/Wapplication.py
@@ -8,6 +8,7 @@ import traceback
from types import *
from Carbon import Menu; MenuToolbox = Menu; del Menu
import macresource
+from Carbon import File
if hasattr(Win, "FrontNonFloatingWindow"):
MyFrontWindow = Win.FrontNonFloatingWindow
@@ -273,7 +274,7 @@ class Application(FrameWork.Application):
if done.has_key(top):
return
done[top] = 1
- import os, macfs, string
+ import os, string
try:
names = os.listdir(top)
except os.error:
@@ -285,11 +286,11 @@ class Application(FrameWork.Application):
if name == "CVS":
continue
try:
- fss, isdir, isalias = macfs.ResolveAliasFile(name)
+ fsr, isdir, isalias = File.FSResolveAliasFile(name, 1)
except:
# maybe a broken alias
continue
- path = fss.as_pathname()
+ path = fsr.as_pathname()
if done.has_key(path):
continue
name = string.strip(name)
@@ -301,7 +302,7 @@ class Application(FrameWork.Application):
submenu = FrameWork.SubMenu(menu, name)
self.scriptswalk(path, submenu, done)
else:
- creator, type = fss.GetCreatorType()
+ creator, type = MacOS.GetCreatorAndType(path)
if type == 'TEXT':
if name[-3:] == '.py':
name = name[:-3]
diff --git a/Mac/Tools/IDE/Wquicktime.py b/Mac/Tools/IDE/Wquicktime.py
index 7170cd7..421d558 100644
--- a/Mac/Tools/IDE/Wquicktime.py
+++ b/Mac/Tools/IDE/Wquicktime.py
@@ -3,7 +3,7 @@ from Carbon import Qd
from Carbon import Win
from Carbon import Qt, QuickTime
import W
-import macfs
+from Carbon import File
from Carbon import Evt, Events
_moviesinitialized = 0
@@ -33,14 +33,9 @@ class Movie(W.Widget):
if self.movie:
#self.GetWindow().InvalWindowRect(self.movie.GetMovieBox())
Qd.PaintRect(self.movie.GetMovieBox())
- if type(path_or_fss) == type(''):
- path = path_or_fss
- fss = macfs.FSSpec(path)
- else:
- path = path_or_fss.as_pathname()
- fss = path_or_fss
+ path = File.pathname(path)
self.movietitle = os.path.basename(path)
- movieResRef = Qt.OpenMovieFile(fss, 1)
+ movieResRef = Qt.OpenMovieFile(path_or_fss, 1)
self.movie, dummy, dummy = Qt.NewMovieFromFile(movieResRef, 0, QuickTime.newMovieActive)
self.moviebox = self.movie.GetMovieBox()
self.calcmoviebox()