Mercurial > cpython-lru_cache-weakref
diff Mac/Tools/IDE/PyEdit.py @ 27737:4367f805db09 legacy-trunk
Got rid of macfs and FSSpecs in general (pathnames or FSRefs are now
used everywhere).
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Thu, 06 Feb 2003 22:32:35 +0000 |
| parents | ea5ee3e7bfb1 |
| children | b51970ba2180 |
line wrap: on
line diff
--- a/Mac/Tools/IDE/PyEdit.py Thu Feb 06 21:25:12 2003 +0000 +++ b/Mac/Tools/IDE/PyEdit.py Thu Feb 06 22:32:35 2003 +0000 @@ -4,14 +4,13 @@ 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 marshal import re +smAllScripts = -3 + if hasattr(Win, "FrontNonFloatingWindow"): MyFrontWindow = Win.FrontNonFloatingWindow else: @@ -61,8 +62,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 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)
