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
df976caa
Commit
df976caa
authored
Jan 26, 2003
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new file dialogs.
parent
db5ab804
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
39 deletions
+34
-39
Mac/Demo/example0/checktext.py
Mac/Demo/example0/checktext.py
+2
-4
Mac/scripts/BuildApplet.py
Mac/scripts/BuildApplet.py
+2
-3
Mac/scripts/gensuitemodule.py
Mac/scripts/gensuitemodule.py
+30
-32
No files found.
Mac/Demo/example0/checktext.py
View file @
df976caa
"""checktext - Check that a text file has macintosh-style newlines"""
import
macfs
import
sys
import
EasyDialogs
import
string
def
main
():
fsspec
,
ok
=
macfs
.
PromptGetFile
(
'File to check end-of-lines in:'
,
'TEXT
'
)
if
not
ok
:
pathname
=
EasyDialogs
.
AskFileForOpen
(
message
=
'File to check end-of-lines in:
'
)
if
not
pathname
:
sys
.
exit
(
0
)
pathname
=
fsspec
.
as_pathname
()
fp
=
open
(
pathname
,
'rb'
)
try
:
data
=
fp
.
read
()
...
...
Mac/scripts/BuildApplet.py
View file @
df976caa
...
...
@@ -11,7 +11,6 @@ import sys
sys
.
stdout
=
sys
.
stderr
import
os
import
macfs
import
MacOS
import
EasyDialogs
import
buildtools
...
...
@@ -36,7 +35,7 @@ def buildapplet():
if
not
sys
.
argv
[
1
:]:
filename
=
EasyDialogs
.
AskFileForOpen
(
message
=
'Select Python source or applet:'
,
fileTypes
=
(
'TEXT'
,
'APPL'
))
typeList
=
(
'TEXT'
,
'APPL'
))
if
not
filename
:
return
tp
,
tf
=
os
.
path
.
split
(
filename
)
...
...
@@ -86,7 +85,7 @@ def buildapplet():
verbose
=
'default'
# Loop over all files to be processed
for
filename
in
args
:
cr
,
tp
=
MacOS
.
GetCreatorAndType
(
macfs
.
FSRef
(
filename
)
)
cr
,
tp
=
MacOS
.
GetCreatorAndType
(
filename
)
if
tp
==
'APPL'
:
buildtools
.
update
(
template
,
filename
,
dstfilename
)
else
:
...
...
Mac/scripts/gensuitemodule.py
View file @
df976caa
...
...
@@ -7,29 +7,29 @@ Reading and understanding this code is left as an exercise to the reader.
"""
import
MacOS
import
EasyDialogs
import
os
import
string
import
sys
import
types
import
StringIO
import
macfs
import
keyword
import
macresource
from
aetools
import
unpack
from
Carbon.Res
import
*
DEFAULT_PACKAGEFOLDER
=
os
.
path
.
join
(
sys
.
prefix
,
'
Mac'
,
'Lib
'
,
'lib-scriptpackages'
)
DEFAULT_PACKAGEFOLDER
=
os
.
path
.
join
(
sys
.
prefix
,
'
Lib'
,
'plat-mac
'
,
'lib-scriptpackages'
)
def
main
():
if
len
(
sys
.
argv
)
>
1
:
for
filename
in
sys
.
argv
[
1
:]:
processfile
(
filename
)
else
:
f
ss
,
ok
=
macfs
.
PromptGetFile
(
'Select file with aeut/aete resource:'
)
if
not
ok
:
f
ilename
=
EasyDialogs
.
AskFileForOpen
(
message
=
'Select file with aeut/aete resource:'
)
if
not
filename
:
sys
.
exit
(
0
)
processfile
(
f
ss
.
as_pathname
()
)
processfile
(
f
ilename
)
def
processfile
(
fullname
):
"""Process all resources in a single file"""
...
...
@@ -231,8 +231,7 @@ def compileaete(aete, resinfo, fname):
"""Generate code for a full aete resource. fname passed for doc purposes"""
[
version
,
language
,
script
,
suites
]
=
aete
major
,
minor
=
divmod
(
version
,
256
)
fss
=
macfs
.
FSSpec
(
fname
)
creatorsignature
,
dummy
=
fss
.
GetCreatorType
()
creatorsignature
,
dummy
=
MacOS
.
GetCreatorAndType
(
fname
)
packagename
=
identify
(
os
.
path
.
splitext
(
os
.
path
.
basename
(
fname
))[
0
])
if
language
:
packagename
=
packagename
+
'_lang%d'
%
language
...
...
@@ -240,39 +239,39 @@ def compileaete(aete, resinfo, fname):
packagename
=
packagename
+
'_script%d'
%
script
if
len
(
packagename
)
>
27
:
packagename
=
packagename
[:
27
]
macfs
.
SetFolder
(
DEFAULT_PACKAGEFOLDER
)
fss
,
ok
=
macfs
.
GetDirectory
(
'Create and select package folder for %s'
%
packagename
)
if
not
ok
:
pathname
=
EasyDialogs
.
AskFolder
(
message
=
'Create and select package folder for %s'
%
packagename
,
defaultLocation
=
DEFAULT_PACKAGEFOLDER
)
if
not
pathname
:
return
pathname
=
fss
.
as_pathname
()
packagename
=
os
.
path
.
split
(
os
.
path
.
normpath
(
pathname
))[
1
]
fss
,
ok
=
macfs
.
GetDirectory
(
'Package folder for base suite (usually StdSuites)'
)
if
ok
:
dirname
,
basepkgname
=
os
.
path
.
split
(
os
.
path
.
normpath
(
fss
.
as_pathname
()))
basepkgname
=
EasyDialogs
.
AskFolder
(
message
=
'Package folder for base suite (usually StdSuites)'
,
defaultLocation
=
DEFAULT_PACKAGEFOLDER
)
if
basepkgname
:
dirname
,
basepkgname
=
os
.
path
.
split
(
os
.
path
.
normpath
(
basepkgname
))
if
not
dirname
in
sys
.
path
:
sys
.
path
.
insert
(
0
,
dirname
)
basepackage
=
__import__
(
basepkgname
)
else
:
basepackage
=
None
macfs
.
SetFolder
(
pathname
)
suitelist
=
[]
allprecompinfo
=
[]
allsuites
=
[]
for
suite
in
suites
:
code
,
suite
,
fss
,
modname
,
precompinfo
=
precompilesuite
(
suite
,
basepackage
)
code
,
suite
,
pathname
,
modname
,
precompinfo
=
precompilesuite
(
suite
,
basepackage
)
if
not
code
:
continue
allprecompinfo
=
allprecompinfo
+
precompinfo
suiteinfo
=
suite
,
fss
,
modname
suiteinfo
=
suite
,
pathname
,
modname
suitelist
.
append
((
code
,
modname
))
allsuites
.
append
(
suiteinfo
)
for
suiteinfo
in
allsuites
:
compilesuite
(
suiteinfo
,
major
,
minor
,
language
,
script
,
fname
,
basepackage
,
allprecompinfo
)
fss
,
ok
=
macfs
.
StandardPutFile
(
'Package module'
,
'__init__.py'
)
if
not
ok
:
initfilename
=
EasyDialogs
.
AskFileForSave
(
message
=
'Package module'
,
savedFileName
=
'__init__.py'
)
if
not
initfilename
:
return
fp
=
open
(
fss
.
as_pathname
()
,
'w'
)
fss
.
SetCreatorType
(
'Pyth'
,
'TEXT'
)
fp
=
open
(
initfilename
,
'w'
)
MacOS
.
SetCreatorAndType
(
initfilename
,
'Pyth'
,
'TEXT'
)
fp
.
write
(
'"""
\
n
'
)
fp
.
write
(
"Package generated from %s
\
n
"
%
fname
)
if
resinfo
:
...
...
@@ -339,11 +338,11 @@ def precompilesuite(suite, basepackage=None):
modname
=
identify
(
name
)
if
len
(
modname
)
>
28
:
modname
=
modname
[:
27
]
fss
,
ok
=
macfs
.
StandardPutFile
(
'Python output file'
,
modname
+
'.py'
)
if
not
ok
:
pathname
=
EasyDialogs
.
AskFileForSave
(
message
=
'Python output file'
,
savedFileName
=
modname
+
'.py'
)
if
not
pathname
:
return
None
,
None
,
None
,
None
,
None
pathname
=
fss
.
as_pathname
()
modname
=
os
.
path
.
splitext
(
os
.
path
.
split
(
pathname
)[
1
])[
0
]
if
basepackage
and
basepackage
.
_code_to_module
.
has_key
(
code
):
...
...
@@ -375,15 +374,14 @@ def precompilesuite(suite, basepackage=None):
precompinfo
=
objc
.
getprecompinfo
(
modname
)
return
code
,
suite
,
fss
,
modname
,
precompinfo
return
code
,
suite
,
pathname
,
modname
,
precompinfo
def
compilesuite
((
suite
,
fss
,
modname
),
major
,
minor
,
language
,
script
,
fname
,
basepackage
,
precompinfo
):
def
compilesuite
((
suite
,
pathname
,
modname
),
major
,
minor
,
language
,
script
,
fname
,
basepackage
,
precompinfo
):
"""Generate code for a single suite"""
[
name
,
desc
,
code
,
level
,
version
,
events
,
classes
,
comps
,
enums
]
=
suite
pathname
=
fss
.
as_pathname
()
fp
=
open
(
fss
.
as_pathname
(),
'w'
)
fss
.
SetCreatorType
(
'Pyth'
,
'TEXT'
)
fp
=
open
(
pathname
,
'w'
)
MacOS
.
SetCreatorAndType
(
pathname
,
'Pyth'
,
'TEXT'
)
fp
.
write
(
'"""Suite %s: %s
\
n
'
%
(
ascii
(
name
),
ascii
(
desc
)))
fp
.
write
(
"Level %d, version %d
\
n
\
n
"
%
(
level
,
version
))
...
...
@@ -676,9 +674,9 @@ class ObjectCompiler:
self
.
namemappers
.
append
(
mapper
)
def
askdefinitionmodule
(
self
,
type
,
code
):
fss
,
ok
=
macfs
.
PromptGetFile
(
'Where is %s %s declared?'
%
(
type
,
code
))
if
not
ok
:
return
path
,
file
=
os
.
path
.
split
(
fss
.
as_pathname
()
)
path
=
EasyDialogs
.
AskFileForSave
(
message
=
'Where is %s %s declared?'
%
(
type
,
code
))
if
not
path
:
return
path
,
file
=
os
.
path
.
split
(
path
)
modname
=
os
.
path
.
splitext
(
file
)[
0
]
if
not
path
in
sys
.
path
:
sys
.
path
.
insert
(
0
,
path
)
...
...
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