summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2007-05-20 23:17:38 (GMT)
committerBrett Cannon <bcannon@gmail.com>2007-05-20 23:17:38 (GMT)
commit5e2635103c34ca1d4226f64c84c6bdf54d528d75 (patch)
tree1da233d88d33946de18f4e696b6c9013ada049ac /Lib
parent7e93587746374693b10b3c8cade7a0bc8c7eb100 (diff)
downloadcpython-5e2635103c34ca1d4226f64c84c6bdf54d528d75.zip
cpython-5e2635103c34ca1d4226f64c84c6bdf54d528d75.tar.gz
cpython-5e2635103c34ca1d4226f64c84c6bdf54d528d75.tar.bz2
Remove the macfs module. This led to the deprecation of macostools.touched();
it completely relied on macfs and is a no-op on OS X according to code comments.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/binhex.py9
-rw-r--r--Lib/plat-mac/macfs.py198
-rw-r--r--Lib/plat-mac/macostools.py17
-rwxr-xr-xLib/test/regrtest.py6
-rw-r--r--Lib/test/test_macfs.py78
-rw-r--r--Lib/test/test_macostools.py6
6 files changed, 9 insertions, 305 deletions
diff --git a/Lib/binhex.py b/Lib/binhex.py
index 0f3e3c4..9059880 100644
--- a/Lib/binhex.py
+++ b/Lib/binhex.py
@@ -510,14 +510,7 @@ def hexbin(inp, out):
ifp.close()
def _test():
- if os.name == 'mac':
- import macfs
- fss, ok = macfs.PromptGetFile('File to convert:')
- if not ok:
- sys.exit(0)
- fname = fss.as_pathname()
- else:
- fname = sys.argv[1]
+ fname = sys.argv[1]
binhex(fname, fname+'.hqx')
hexbin(fname+'.hqx', fname+'.viahqx')
#hexbin(fname, fname+'.unpacked')
diff --git a/Lib/plat-mac/macfs.py b/Lib/plat-mac/macfs.py
deleted file mode 100644
index 73815ae..0000000
--- a/Lib/plat-mac/macfs.py
+++ /dev/null
@@ -1,198 +0,0 @@
-"""macfs - Pure Python module designed to be backward compatible with
-macfs and MACFS.
-"""
-import sys
-import struct
-import Carbon.Res
-import Carbon.File
-import warnings
-
-warnings.warn("macfs is deprecated, use Carbon.File, Carbon.Folder or EasyDialogs",
- DeprecationWarning, stacklevel=2)
-
-# First step: ensure we also emulate the MACFS module, which contained
-# all the constants
-
-sys.modules['MACFS'] = sys.modules[__name__]
-
-# Import all those constants
-from Carbon.Files import *
-from Carbon.Folders import *
-
-# For some obscure historical reason these are here too:
-READ = 1
-WRITE = 2
-smAllScripts = -3
-
-#
-# Find the epoch conversion for file dates in a way that works on OS9 and OSX
-import time
-if time.gmtime(0)[0] == 1970:
- _EPOCHCONVERT = -((1970-1904)*365 + 17) * (24*60*60) + 0x100000000L
- def _utc2time(utc):
- t = utc[1] + _EPOCHCONVERT
- return int(t)
- def _time2utc(t):
- t = int(t) - _EPOCHCONVERT
- if t < -0x7fffffff:
- t = t + 0x10000000L
- return (0, int(t), 0)
-else:
- def _utc2time(utc):
- t = utc[1]
- if t < 0:
- t = t + 0x100000000L
- return t
- def _time2utc(t):
- if t > 0x7fffffff:
- t = t - 0x100000000L
- return (0, int(t), 0)
-
-# The old name of the error object:
-error = Carbon.File.Error
-
-#
-# The various objects macfs used to export. We override them here, because some
-# of the method names are subtly different.
-#
-class FSSpec(Carbon.File.FSSpec):
- def as_fsref(self):
- return FSRef(self)
-
- def NewAlias(self, src=None):
- return Alias(Carbon.File.NewAlias(src, self))
-
- def GetCreatorType(self):
- finfo = self.FSpGetFInfo()
- return finfo.Creator, finfo.Type
-
- def SetCreatorType(self, ctor, tp):
- finfo = self.FSpGetFInfo()
- finfo.Creator = ctor
- finfo.Type = tp
- self.FSpSetFInfo(finfo)
-
- def GetFInfo(self):
- return self.FSpGetFInfo()
-
- def SetFInfo(self, info):
- return self.FSpSetFInfo(info)
-
- def GetDates(self):
- catInfoFlags = kFSCatInfoCreateDate|kFSCatInfoContentMod|kFSCatInfoBackupDate
- catinfo, d1, d2, d3 = FSRef(self).FSGetCatalogInfo(catInfoFlags)
- cdate = catinfo.createDate
- mdate = catinfo.contentModDate
- bdate = catinfo.backupDate
- return _utc2time(cdate), _utc2time(mdate), _utc2time(bdate)
-
- def SetDates(self, cdate, mdate, bdate):
- catInfoFlags = kFSCatInfoCreateDate|kFSCatInfoContentMod|kFSCatInfoBackupDate
- catinfo = Carbon.File.FSCatalogInfo(
- createDate = _time2utc(cdate),
- contentModDate = _time2utc(mdate),
- backupDate = _time2utc(bdate))
- FSRef(self).FSSetCatalogInfo(catInfoFlags, catinfo)
-
-class FSRef(Carbon.File.FSRef):
- def as_fsspec(self):
- return FSSpec(self)
-
-class Alias(Carbon.File.Alias):
-
- def GetInfo(self, index):
- return self.GetAliasInfo(index)
-
- def Update(self, *args):
- pass # print "Alias.Update not yet implemented"
-
- def Resolve(self, src=None):
- fss, changed = self.ResolveAlias(src)
- return FSSpec(fss), changed
-
-from Carbon.File import FInfo
-
-# Backward-compatible type names:
-FSSpecType = FSSpec
-FSRefType = FSRef
-AliasType = Alias
-FInfoType = FInfo
-
-# Global functions:
-def ResolveAliasFile(fss, chain=1):
- fss, isdir, isalias = Carbon.File.ResolveAliasFile(fss, chain)
- return FSSpec(fss), isdir, isalias
-
-def RawFSSpec(data):
- return FSSpec(rawdata=data)
-
-def RawAlias(data):
- return Alias(rawdata=data)
-
-def FindApplication(*args):
- raise NotImplementedError, "FindApplication no longer implemented"
-
-def NewAliasMinimalFromFullPath(path):
- return Alias(Carbon.File.NewAliasMinimalFromFullPath(path, '', ''))
-
-# Another global function:
-from Carbon.Folder import FindFolder
-
-#
-# Finally the old Standard File routine emulators.
-#
-
-_curfolder = None
-
-def StandardGetFile(*typelist):
- """Ask for an input file, optionally specifying 4-char file types that are
- allowable"""
- return PromptGetFile('', *typelist)
-
-def PromptGetFile(prompt, *typelist):
- """Ask for an input file giving the user a prompt message. Optionally you can
- specifying 4-char file types that are allowable"""
- import EasyDialogs
- warnings.warn("macfs.StandardGetFile and friends are deprecated, use EasyDialogs.AskFileForOpen",
- DeprecationWarning, stacklevel=2)
- if not typelist:
- typelist = None
- fss = EasyDialogs.AskFileForOpen(message=prompt, wanted=FSSpec,
- typeList=typelist, defaultLocation=_handleSetFolder())
- return fss, not fss is None
-
-def StandardPutFile(prompt, default=None):
- """Ask the user for an output file, with a prompt. Optionally you cn supply a
- default output filename"""
- import EasyDialogs
- warnings.warn("macfs.StandardGetFile and friends are deprecated, use EasyDialogs.AskFileForOpen",
- DeprecationWarning, stacklevel=2)
- fss = EasyDialogs.AskFileForSave(wanted=FSSpec, message=prompt,
- savedFileName=default, defaultLocation=_handleSetFolder())
- return fss, not fss is None
-
-def SetFolder(folder):
- global _curfolder
- warnings.warn("macfs.StandardGetFile and friends are deprecated, use EasyDialogs.AskFileForOpen",
- DeprecationWarning, stacklevel=2)
- if _curfolder:
- rv = FSSpec(_curfolder)
- else:
- rv = None
- _curfolder = folder
- return rv
-
-def _handleSetFolder():
- global _curfolder
- rv = _curfolder
- _curfolder = None
- return rv
-
-def GetDirectory(prompt=None):
- """Ask the user to select a folder. Optionally you can give a prompt."""
- import EasyDialogs
- warnings.warn("macfs.StandardGetFile and friends are deprecated, use EasyDialogs.AskFileForOpen",
- DeprecationWarning, stacklevel=2)
- fss = EasyDialogs.AskFolder(message=prompt, wanted=FSSpec,
- defaultLocation=_handleSetFolder())
- return fss, not fss is None
diff --git a/Lib/plat-mac/macostools.py b/Lib/plat-mac/macostools.py
index f7ce468..fc4861e 100644
--- a/Lib/plat-mac/macostools.py
+++ b/Lib/plat-mac/macostools.py
@@ -65,21 +65,9 @@ def mkdirs(dst):
def touched(dst):
"""Tell the finder a file has changed. No-op on MacOSX."""
- if sys.platform != 'mac': return
import warnings
- warnings.filterwarnings("ignore", "macfs.*", DeprecationWarning, __name__)
- import macfs
- file_fss = macfs.FSSpec(dst)
- vRefNum, dirID, name = file_fss.as_tuple()
- dir_fss = macfs.FSSpec((vRefNum, dirID, ''))
- crdate, moddate, bkdate = dir_fss.GetDates()
- now = time.time()
- if now == moddate:
- now = now + 1
- try:
- dir_fss.SetDates(crdate, now, bkdate)
- except macfs.error:
- pass
+ warnings.warn("macostools.touched() has been deprecated",
+ DeprecationWarning, 2)
def touched_ae(dst):
"""Tell the finder a file has changed"""
@@ -129,7 +117,6 @@ def copy(src, dst, createpath=0, copydates=1, forcetype=None):
dstfsr = File.FSRef(dst)
catinfo, _, _, _ = srcfsr.FSGetCatalogInfo(Files.kFSCatInfoAllDates)
dstfsr.FSSetCatalogInfo(Files.kFSCatInfoAllDates, catinfo)
- touched(dstfss)
def copytree(src, dst, copydates=1):
"""Copy a complete file tree to a new destination"""
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index cba70ed..01484be 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -1198,7 +1198,6 @@ _expectations = {
test_imgfile
test_linuxaudiodev
test_locale
- test_macfs
test_macostools
test_nis
test_ossaudiodev
@@ -1235,7 +1234,6 @@ _expectations = {
test_gzip
test_imgfile
test_linuxaudiodev
- test_macfs
test_macostools
test_nis
test_ossaudiodev
@@ -1264,7 +1262,6 @@ _expectations = {
test_imgfile
test_linuxaudiodev
test_locale
- test_macfs
test_macostools
test_nis
test_normalization
@@ -1298,7 +1295,6 @@ _expectations = {
test_imgfile
test_linuxaudiodev
test_locale
- test_macfs
test_macostools
test_nis
test_ossaudiodev
@@ -1340,7 +1336,7 @@ class _ExpectedSkips:
self.expected.add('test_imageop')
if not sys.platform in ("mac", "darwin"):
- MAC_ONLY = ["test_macostools", "test_macfs", "test_aepack",
+ MAC_ONLY = ["test_macostools", "test_aepack",
"test_plistlib", "test_scriptpackages"]
for skip in MAC_ONLY:
self.expected.add(skip)
diff --git a/Lib/test/test_macfs.py b/Lib/test/test_macfs.py
deleted file mode 100644
index 9c0e3a1..0000000
--- a/Lib/test/test_macfs.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright (C) 2003 Python Software Foundation
-
-import unittest
-import warnings
-warnings.filterwarnings("ignore", "macfs.*", DeprecationWarning, __name__)
-import macfs
-import os
-import sys
-import tempfile
-from test import test_support
-
-class TestMacfs(unittest.TestCase):
-
- def setUp(self):
- fp = open(test_support.TESTFN, 'w')
- fp.write('hello world\n')
- fp.close()
-
- def tearDown(self):
- try:
- os.unlink(test_support.TESTFN)
- except:
- pass
-
- def test_fsspec(self):
- fss = macfs.FSSpec(test_support.TESTFN)
- self.assertEqual(os.path.realpath(test_support.TESTFN), fss.as_pathname())
-
- def test_fsref(self):
- fsr = macfs.FSRef(test_support.TESTFN)
- self.assertEqual(os.path.realpath(test_support.TESTFN), fsr.as_pathname())
-
- def test_fsref_unicode(self):
- if sys.getfilesystemencoding():
- testfn_unicode = unicode(test_support.TESTFN)
- fsr = macfs.FSRef(testfn_unicode)
- self.assertEqual(os.path.realpath(test_support.TESTFN), fsr.as_pathname())
-
- def test_coercion(self):
- fss = macfs.FSSpec(test_support.TESTFN)
- fsr = macfs.FSRef(test_support.TESTFN)
- fss2 = fsr.as_fsspec()
- fsr2 = fss.as_fsref()
- self.assertEqual(fss.as_pathname(), fss2.as_pathname())
- self.assertEqual(fsr.as_pathname(), fsr2.as_pathname())
-
- def test_dates(self):
- import time
- fss = macfs.FSSpec(test_support.TESTFN)
- now = int(time.time())
- fss.SetDates(now, now+1, now+2)
- dates = fss.GetDates()
- self.assertEqual(dates, (now, now+1, now+2))
-
- def test_ctor_type(self):
- fss = macfs.FSSpec(test_support.TESTFN)
- fss.SetCreatorType('Pyth', 'TEXT')
- filecr, filetp = fss.GetCreatorType()
- self.assertEqual((filecr, filetp), ('Pyth', 'TEXT'))
-
- def test_alias(self):
- fss = macfs.FSSpec(test_support.TESTFN)
- alias = fss.NewAlias()
- fss2, changed = alias.Resolve()
- self.assertEqual(changed, 0)
- self.assertEqual(fss.as_pathname(), fss2.as_pathname())
-
-
- def test_fss_alias(self):
- fss = macfs.FSSpec(test_support.TESTFN)
-
-
-def test_main():
- test_support.run_unittest(TestMacfs)
-
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_macostools.py b/Lib/test/test_macostools.py
index f3292ce..40b690a 100644
--- a/Lib/test/test_macostools.py
+++ b/Lib/test/test_macostools.py
@@ -51,7 +51,11 @@ class TestMacostools(unittest.TestCase):
def test_touched(self):
# This really only tests that nothing unforeseen happens.
- macostools.touched(test_support.TESTFN)
+ import warnings
+ with test_support.guard_warnings_filter():
+ warnings.filterwarnings('ignore', 'macostools.touched*',
+ DeprecationWarning)
+ macostools.touched(test_support.TESTFN)
def test_copy(self):
try: