Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e7ee17c5
Commit
e7ee17c5
authored
Feb 06, 2003
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Got rid of macfs and FSSpecs in general (pathnames or FSRefs are now
used everywhere).
parent
85233bf7
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
55 additions
and
68 deletions
+55
-68
Mac/Tools/IDE/MacPrefs.py
Mac/Tools/IDE/MacPrefs.py
+5
-8
Mac/Tools/IDE/ProfileBrowser.py
Mac/Tools/IDE/ProfileBrowser.py
+0
-1
Mac/Tools/IDE/PyBrowser.py
Mac/Tools/IDE/PyBrowser.py
+1
-3
Mac/Tools/IDE/PyConsole.py
Mac/Tools/IDE/PyConsole.py
+2
-4
Mac/Tools/IDE/PyDocSearch.py
Mac/Tools/IDE/PyDocSearch.py
+0
-1
Mac/Tools/IDE/PyEdit.py
Mac/Tools/IDE/PyEdit.py
+14
-19
Mac/Tools/IDE/PythonIDEMain.py
Mac/Tools/IDE/PythonIDEMain.py
+25
-20
Mac/Tools/IDE/Wapplication.py
Mac/Tools/IDE/Wapplication.py
+5
-4
Mac/Tools/IDE/Wquicktime.py
Mac/Tools/IDE/Wquicktime.py
+3
-8
No files found.
Mac/Tools/IDE/MacPrefs.py
View file @
e7ee17c5
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
...
...
Mac/Tools/IDE/ProfileBrowser.py
View file @
e7ee17c5
...
...
@@ -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
)
...
...
Mac/Tools/IDE/PyBrowser.py
View file @
e7ee17c5
...
...
@@ -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
,
...
...
Mac/Tools/IDE/PyConsole.py
View file @
e7ee17c5
...
...
@@ -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
)
...
...
Mac/Tools/IDE/PyDocSearch.py
View file @
e7ee17c5
import
re
import
W
import
macfs
import
os
import
MacPrefs
import
MacOS
...
...
Mac/Tools/IDE/PyEdit.py
View file @
e7ee17c5
...
...
@@ -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
()
fs
s
,
fss_changed
=
app
.
scriptsfolder
.
Resolve
(
)
path
=
fs
s
.
as_pathname
()
fs
r
,
changed
=
app
.
scriptsfolder
.
FSResolveAlias
(
None
)
path
=
fs
r
.
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
)
...
...
Mac/Tools/IDE/PythonIDEMain.py
View file @
e7ee17c5
...
...
@@ -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
:
fs
s
,
fss_changed
=
macfs
.
RawAlias
(
prefs
.
scriptsfolder
).
Resolve
(
)
self
.
scriptsfolder
=
fs
s
.
NewAlias
()
fs
r
,
d
=
File
.
Alias
(
rawdata
=
prefs
.
scriptsfolder
).
FSResolveAlias
(
None
)
self
.
scriptsfolder
=
fs
r
.
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
()
fs
s
=
macfs
.
FSSpec
(
path
)
self
.
scriptsfolder
=
fs
s
.
NewAlias
()
self
.
scriptsfoldermodtime
=
fss
.
GetDates
()[
1
]
fs
r
=
File
.
FSRef
(
path
)
self
.
scriptsfolder
=
fs
r
.
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
:
fs
s
,
fss_changed
=
self
.
scriptsfolder
.
Resolve
(
)
modtime
=
fss
.
GetDates
()[
1
]
if
self
.
scriptsfoldermodtime
<>
modtime
or
fss_
changed
:
fs
r
,
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
:
fs
s
,
a
=
doc
.
Resolve
(
)
path
=
fs
s
.
as_pathname
()
fs
r
,
a
=
doc
.
FSResolveAlias
(
None
)
path
=
fs
r
.
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
):
fs
s
=
EasyDialogs
.
AskFolder
(
message
=
"Select Scripts Folder"
,
wanted
=
macfs
.
FSSpec
)
if
fs
s
:
fs
r
=
EasyDialogs
.
AskFolder
(
message
=
"Select Scripts Folder"
,
wanted
=
File
.
FSRef
)
if
fs
r
:
prefs
=
self
.
getprefs
()
alis
=
fs
s
.
NewAlias
()
alis
=
fs
r
.
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()
fs
s
,
fss_changed
=
self
.
scriptsfolder
.
Resolve
(
)
self
.
scriptswalk
(
fs
s
.
as_pathname
(),
self
.
scriptsmenu
)
fs
r
,
d1
=
self
.
scriptsfolder
.
FSResolveAlias
(
None
)
self
.
scriptswalk
(
fs
r
.
as_pathname
(),
self
.
scriptsmenu
)
def
makeopenwindowsmenu
(
self
):
for
i
in
range
(
len
(
self
.
openwindowsmenu
.
items
)):
...
...
Mac/Tools/IDE/Wapplication.py
View file @
e7ee17c5
...
...
@@ -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
:
fs
s
,
isdir
,
isalias
=
macfs
.
ResolveAliasFile
(
name
)
fs
r
,
isdir
,
isalias
=
File
.
FSResolveAliasFile
(
name
,
1
)
except
:
# maybe a broken alias
continue
path
=
fs
s
.
as_pathname
()
path
=
fs
r
.
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
]
...
...
Mac/Tools/IDE/Wquicktime.py
View file @
e7ee17c5
...
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment