[Python-checkins] python/dist/src/Lib/plat-mac findertools.py,1.2,1.3
jackjansen@users.sourceforge.net
jackjansen@users.sourceforge.net
Fri, 21 Feb 2003 15:14:34 -0800
Update of /cvsroot/python/python/dist/src/Lib/plat-mac
In directory sc8-pr-cvs1:/tmp/cvs-serv3780
Modified Files:
findertools.py
Log Message:
Get rid of macfs.
Index: findertools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/findertools.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** findertools.py 21 Jan 2003 15:30:21 -0000 1.2
--- findertools.py 21 Feb 2003 23:14:30 -0000 1.3
***************
*** 20,24 ****
import MacOS
import sys
! import macfs
import aetypes
from types import *
--- 20,25 ----
import MacOS
import sys
! import Carbon.File
! import Carbon.Folder
import aetypes
from types import *
***************
*** 41,45 ****
"""Open a file thru the finder. Specify file by name or fsspec"""
finder = _getfinder()
! fss = macfs.FSSpec(file)
return finder.open(fss)
--- 42,46 ----
"""Open a file thru the finder. Specify file by name or fsspec"""
finder = _getfinder()
! fss = Carbon.File.FSSpec(file)
return finder.open(fss)
***************
*** 47,51 ****
"""Print a file thru the finder. Specify file by name or fsspec"""
finder = _getfinder()
! fss = macfs.FSSpec(file)
return finder._print(fss)
--- 48,52 ----
"""Print a file thru the finder. Specify file by name or fsspec"""
finder = _getfinder()
! fss = Carbon.File.FSSpec(file)
return finder._print(fss)
***************
*** 56,63 ****
src_fss = []
for s in src:
! src_fss.append(macfs.FSSpec(s))
else:
! src_fss = macfs.FSSpec(src)
! dst_fss = macfs.FSSpec(dstdir)
return finder.duplicate(src_fss, to=dst_fss)
--- 57,64 ----
src_fss = []
for s in src:
! src_fss.append(Carbon.File.FSSpec(s))
else:
! src_fss = Carbon.File.FSSpec(src)
! dst_fss = Carbon.File.FSSpec(dstdir)
return finder.duplicate(src_fss, to=dst_fss)
***************
*** 68,75 ****
src_fss = []
for s in src:
! src_fss.append(macfs.FSSpec(s))
else:
! src_fss = macfs.FSSpec(src)
! dst_fss = macfs.FSSpec(dstdir)
return finder.move(src_fss, to=dst_fss)
--- 69,76 ----
src_fss = []
for s in src:
! src_fss.append(Carbon.File.FSSpec(s))
else:
! src_fss = Carbon.File.FSSpec(src)
! dst_fss = Carbon.File.FSSpec(dstdir)
return finder.move(src_fss, to=dst_fss)
***************
*** 95,117 ****
def reveal(file):
! """Reveal a file in the finder. Specify file by name or fsspec."""
finder = _getfinder()
! fss = macfs.FSSpec(file)
! file_alias = fss.NewAlias()
return finder.reveal(file_alias)
def select(file):
! """select a file in the finder. Specify file by name or fsspec."""
finder = _getfinder()
! fss = macfs.FSSpec(file)
! file_alias = fss.NewAlias()
return finder.select(file_alias)
def update(file):
"""Update the display of the specified object(s) to match
! their on-disk representation. Specify file by name or fsspec."""
finder = _getfinder()
! fss = macfs.FSSpec(file)
! file_alias = fss.NewAlias()
return finder.update(file_alias)
--- 96,118 ----
def reveal(file):
! """Reveal a file in the finder. Specify file by name, fsref or fsspec."""
finder = _getfinder()
! fsr = Carbon.File.FSRef(file)
! file_alias = fsr.FSNewAliasMinimal()
return finder.reveal(file_alias)
def select(file):
! """select a file in the finder. Specify file by name, fsref or fsspec."""
finder = _getfinder()
! fsr = Carbon.File.FSRef(file)
! file_alias = fsr.FSNewAliasMinimal()
return finder.select(file_alias)
def update(file):
"""Update the display of the specified object(s) to match
! their on-disk representation. Specify file by name, fsref or fsspec."""
finder = _getfinder()
! fsr = Carbon.File.FSRef(file)
! file_alias = fsr.FSNewAliasMinimal()
return finder.update(file_alias)
***************
*** 123,129 ****
def comment(object, comment=None):
"""comment: get or set the Finder-comment of the item, displayed in the 'Get Info' window."""
! object = macfs.FSSpec(object)
! fss = macfs.FSSpec(object)
! object_alias = fss.NewAlias()
if comment == None:
return _getcomment(object_alias)
--- 124,129 ----
def comment(object, comment=None):
"""comment: get or set the Finder-comment of the item, displayed in the 'Get Info' window."""
! object = Carbon.File.FSRef(object)
! object_alias = object.FSNewAliasMonimal()
if comment == None:
return _getcomment(object_alias)
***************
*** 261,267 ****
"""Open a Finder window for object, Specify object by name or fsspec."""
finder = _getfinder()
! object = macfs.FSSpec(object)
! fss = macfs.FSSpec(object)
! object_alias = fss.NewAlias()
args = {}
attrs = {}
--- 261,266 ----
"""Open a Finder window for object, Specify object by name or fsspec."""
finder = _getfinder()
! object = Carbon.File.FSRef(object)
! object_alias = object.FSNewAliasMinimal()
args = {}
attrs = {}
***************
*** 277,282 ****
"""Close a Finder window for folder, Specify by path."""
finder = _getfinder()
! fss = macfs.FSSpec(object)
! object_alias = fss.NewAlias()
args = {}
attrs = {}
--- 276,281 ----
"""Close a Finder window for folder, Specify by path."""
finder = _getfinder()
! object = Carbon.File.FSRef(object)
! object_alias = object.FSNewAliasMinimal()
args = {}
attrs = {}
***************
*** 292,297 ****
"""Set the position of a Finder window for folder to pos=(w, h). Specify file by name or fsspec.
If pos=None, location will return the current position of the object."""
! fss = macfs.FSSpec(object)
! object_alias = fss.NewAlias()
if not pos:
return _getlocation(object_alias)
--- 291,296 ----
"""Set the position of a Finder window for folder to pos=(w, h). Specify file by name or fsspec.
If pos=None, location will return the current position of the object."""
! object = Carbon.File.FSRef(object)
! object_alias = object.FSNewAliasMinimal()
if not pos:
return _getlocation(object_alias)
***************
*** 329,334 ****
def label(object, index=None):
"""label: set or get the label of the item. Specify file by name or fsspec."""
! fss = macfs.FSSpec(object)
! object_alias = fss.NewAlias()
if index == None:
return _getlabel(object_alias)
--- 328,333 ----
def label(object, index=None):
"""label: set or get the label of the item. Specify file by name or fsspec."""
! object = Carbon.File.FSRef(object)
! object_alias = object.FSNewAliasMinimal()
if index == None:
return _getlabel(object_alias)
***************
*** 375,380 ****
2 = by button
"""
! fss = macfs.FSSpec(folder)
! folder_alias = fss.NewAlias()
if view == None:
return _getwindowview(folder_alias)
--- 374,379 ----
2 = by button
"""
! fsr = Carbon.File.FSRef(folder)
! folder_alias = fsr.FSNewAliasMinimal()
if view == None:
return _getwindowview(folder_alias)
***************
*** 433,439 ****
Specify file by name or fsspec.
"""
! fss = macfs.FSSpec(folder)
! folder_alias = fss.NewAlias()
! openwindow(fss)
if not size:
return _getwindowsize(folder_alias)
--- 432,438 ----
Specify file by name or fsspec.
"""
! fsr = Carbon.File.FSRef(folder)
! folder_alias = fsr.FSNewAliasMinimal()
! openwindow(fsr)
if not size:
return _getwindowsize(folder_alias)
***************
*** 481,487 ****
def windowposition(folder, pos=None):
"""Set the position of a Finder window for folder to pos=(w, h)."""
! fss = macfs.FSSpec(folder)
! folder_alias = fss.NewAlias()
! openwindow(fss)
if not pos:
return _getwindowposition(folder_alias)
--- 480,486 ----
def windowposition(folder, pos=None):
"""Set the position of a Finder window for folder to pos=(w, h)."""
! fsr = Carbon.File.FSRef(folder)
! folder_alias = fsr.FSNewAliasMinimal()
! openwindow(fsr)
if not pos:
return _getwindowposition(folder_alias)
***************
*** 533,538 ****
If left untouched, this data can be used to paste the icon on another file.
Development opportunity: get and set the data as PICT."""
! fss = macfs.FSSpec(object)
! object_alias = fss.NewAlias()
if icondata == None:
return _geticon(object_alias)
--- 532,537 ----
If left untouched, this data can be used to paste the icon on another file.
Development opportunity: get and set the data as PICT."""
! fsr = Carbon.File.FSRef(object)
! object_alias = fsr.FSNewAliasMinimal()
if icondata == None:
return _geticon(object_alias)
***************
*** 680,685 ****
def movetotrash(path):
"""move the object to the trash"""
! fss = macfs.FSSpec(path)
! trashfolder = macfs.FSSpec(macfs.FindFolder(fss.as_tuple()[0], 'trsh', 0) + ("",)).as_pathname()
move(path, trashfolder)
--- 679,684 ----
def movetotrash(path):
"""move the object to the trash"""
! fss = Carbon.File.FSSpec(path)
! trashfolder = Carbon.Folder.FSFindFolder(fss.as_tuple()[0], 'trsh', 0)
move(path, trashfolder)
***************
*** 696,704 ****
def _test():
print 'Original findertools functionality test...'
print 'Testing launch...'
! fss, ok = macfs.PromptGetFile('File to launch:')
! if ok:
! result = launch(fss)
if result:
print 'Result: ', result
--- 695,704 ----
def _test():
+ import EasyDialogs
print 'Original findertools functionality test...'
print 'Testing launch...'
! pathname = EasyDialogs.AskFileForOpen('File to launch:')
! if pathname:
! result = launch(pathname)
if result:
print 'Result: ', result
***************
*** 706,712 ****
sys.stdin.readline()
print 'Testing print...'
! fss, ok = macfs.PromptGetFile('File to print:')
! if ok:
! result = Print(fss)
if result:
print 'Result: ', result
--- 706,712 ----
sys.stdin.readline()
print 'Testing print...'
! pathname = EasyDialogs.AskFileForOpen('File to print:')
! if pathname:
! result = Print(pathname)
if result:
print 'Result: ', result
***************
*** 714,722 ****
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
--- 714,722 ----
sys.stdin.readline()
print 'Testing copy...'
! pathname = EasyDialogs.AskFileForOpen('File to copy:')
! if pathname:
! destdir = EasyDialogs.AskFolder('Destination:')
! if destdir:
! result = copy(pathname, destdir)
if result:
print 'Result:', result
***************
*** 724,737 ****
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:
--- 724,736 ----
sys.stdin.readline()
print 'Testing move...'
! pathname = EasyDialogs.AskFileForOpen('File to move:')
! if pathname:
! destdir = EasyDialogs.AskFolder('Destination:')
! if destdir:
! result = move(pathname, destdir)
if result:
print 'Result:', result
print 'Press return-',
sys.stdin.readline()
print 'Testing sleep...'
if EasyDialogs.AskYesNoCancel('Sleep?') > 0:
***************
*** 773,777 ****
# Finder's windows, file location, file attributes
open("@findertoolstest", "w")
! f = macfs.FSSpec("@findertoolstest").as_pathname()
reveal(f) # reveal this file in a Finder window
select(f) # select this file
--- 772,776 ----
# Finder's windows, file location, file attributes
open("@findertoolstest", "w")
! f = "@findertoolstest"
reveal(f) # reveal this file in a Finder window
select(f) # select this file