Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
0585d411
Kaydet (Commit)
0585d411
authored
Eyl 20, 1996
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Convenience routines: wrappers around some of the scriptable finder
functionality.
üst
924ca855
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
138 additions
and
0 deletions
+138
-0
findertools.py
Mac/Lib/findertools.py
+138
-0
No files found.
Mac/Lib/findertools.py
0 → 100644
Dosyayı görüntüle @
0585d411
"""Utility routines depending on the finder."""
import
Finder_7_0_Suite
import
aetools
import
MacOS
import
sys
import
macfs
SIGNATURE
=
'MACS'
class
Finder
(
aetools
.
TalkTo
,
Finder_7_0_Suite
.
Finder_7_0_Suite
):
pass
_finder_talker
=
None
def
_getfinder
():
global
_finder_talker
if
not
_finder_talker
:
_finder_talker
=
Finder
(
SIGNATURE
)
return
_finder_talker
def
launch
(
file
):
"""Open a file thru the finder. Specify file by name or fsspec"""
finder
=
_getfinder
()
fss
=
macfs
.
FSSpec
(
file
)
vRefNum
,
parID
,
name
=
fss
.
as_tuple
()
dir_fss
=
macfs
.
FSSpec
((
vRefNum
,
parID
,
''
))
file_alias
=
fss
.
NewAlias
()
dir_alias
=
dir_fss
.
NewAlias
()
return
finder
.
open
(
dir_alias
,
items
=
[
file_alias
])
def
Print
(
file
):
"""Print a file thru the finder. Specify file by name or fsspec"""
finder
=
_getfinder
()
fss
=
macfs
.
FSSpec
(
file
)
vRefNum
,
parID
,
name
=
fss
.
as_tuple
()
dir_fss
=
macfs
.
FSSpec
((
vRefNum
,
parID
,
''
))
file_alias
=
fss
.
NewAlias
()
dir_alias
=
dir_fss
.
NewAlias
()
return
finder
.
_print
(
dir_alias
,
items
=
[
file_alias
])
def
copy
(
src
,
dstdir
):
"""Copy a file to a folder"""
finder
=
_getfinder
()
src_fss
=
macfs
.
FSSpec
(
src
)
dst_fss
=
macfs
.
FSSpec
(
dstdir
)
src_alias
=
src_fss
.
NewAlias
()
dst_alias
=
dst_fss
.
NewAlias
()
return
finder
.
copy_to
(
dst_alias
,
_from
=
[
src_alias
])
def
move
(
src
,
dstdir
):
"""Move a file to a folder"""
finder
=
_getfinder
()
src_fss
=
macfs
.
FSSpec
(
src
)
dst_fss
=
macfs
.
FSSpec
(
dstdir
)
src_alias
=
src_fss
.
NewAlias
()
dst_alias
=
dst_fss
.
NewAlias
()
return
finder
.
move_to
(
dst_alias
,
_from
=
[
src_alias
])
def
sleep
():
"""Put the mac to sleep"""
finder
=
_getfinder
()
finder
.
sleep
()
def
shutdown
():
"""Shut the mac down"""
finder
=
_getfinder
()
finder
.
shut_down
()
def
restart
():
"""Restart the mac"""
finder
=
_getfinder
()
finder
.
restart
()
def
main
():
print
'Testing launch...'
fss
,
ok
=
macfs
.
PromptGetFile
(
'File to launch:'
)
if
ok
:
result
=
launch
(
fss
)
if
result
:
print
'Result: '
,
result
print
'Press return-'
,
sys
.
stdin
.
readline
()
print
'Testing print...'
fss
,
ok
=
macfs
.
PromptGetFile
(
'File to print:'
)
if
ok
:
result
=
Print
(
fss
)
if
result
:
print
'Result: '
,
result
print
'Press return-'
,
sys
.
stdin
.
readline
()
print
'Testing copy...'
fss
,
ok
=
macfs
.
PromptGetFile
(
'File to copy:'
)
if
ok
:
dfss
,
ok
=
macfs
.
GetDirectory
()
if
ok
:
result
=
copy
(
fss
,
dfss
)
if
result
:
print
'Result:'
,
result
print
'Press return-'
,
sys
.
stdin
.
readline
()
print
'Testing move...'
fss
,
ok
=
macfs
.
PromptGetFile
(
'File to move:'
)
if
ok
:
dfss
,
ok
=
macfs
.
GetDirectory
()
if
ok
:
result
=
move
(
fss
,
dfss
)
if
result
:
print
'Result:'
,
result
print
'Press return-'
,
sys
.
stdin
.
readline
()
import
EasyDialogs
print
'Testing sleep...'
if
EasyDialogs
.
AskYesNoCancel
(
'Sleep?'
)
>
0
:
result
=
sleep
()
if
result
:
print
'Result:'
,
result
print
'Press return-'
,
sys
.
stdin
.
readline
()
print
'Testing shutdown...'
if
EasyDialogs
.
AskYesNoCancel
(
'Shut down?'
)
>
0
:
result
=
shutdown
()
if
result
:
print
'Result:'
,
result
print
'Press return-'
,
sys
.
stdin
.
readline
()
print
'Testing restart...'
if
EasyDialogs
.
AskYesNoCancel
(
'Restart?'
)
>
0
:
result
=
restart
()
if
result
:
print
'Result:'
,
result
print
'Press return-'
,
sys
.
stdin
.
readline
()
if
__name__
==
'__main__'
:
main
()
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