mirror of https://github.com/python/cpython.git
Got rid of macfs and FSSpecs in general (pathnames or FSRefs are now
used everywhere).
This commit is contained in:
parent
85233bf746
commit
e7ee17c58e
|
@ -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 @@ def save(self):
|
|||
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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -322,9 +322,7 @@ def openselection(self):
|
|||
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,
|
||||
|
|
|
@ -85,7 +85,6 @@ def key(self, char, event):
|
|||
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 @@ def domenu_save_as(self, *args):
|
|||
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 @@ def domenu_save_as(self, *args):
|
|||
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)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import re
|
||||
import W
|
||||
import macfs
|
||||
import os
|
||||
import MacPrefs
|
||||
import MacOS
|
||||
|
|
|
@ -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 @@ def __init__(self, path = "", title = ""):
|
|||
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 @@ def writewindowsettings(self):
|
|||
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 @@ def domenu_save(self, *args):
|
|||
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 @@ def domenu_save_as(self, *args):
|
|||
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 @@ def _run_with_cl_interpreter(self):
|
|||
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)
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
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 @@ def makeusermenus(self):
|
|||
|
||||
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 @@ def quitevent(self, theAppleEvent, theReply):
|
|||
|
||||
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 @@ def opendocsevent(self, theAppleEvent, theReply):
|
|||
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 @@ def do_about(self, id, item, window, event):
|
|||
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 @@ def makescriptsmenu(self):
|
|||
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)):
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
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 @@ def scriptswalk(self, top, menu, done=None):
|
|||
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 @@ def scriptswalk(self, top, menu, done=None):
|
|||
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 @@ def scriptswalk(self, top, menu, done=None):
|
|||
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]
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
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 @@ def set(self, path_or_fss, start = 0):
|
|||
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()
|
||||
|
|
Loading…
Reference in New Issue