Merge pull request #2014 from simoncozens/remove-macos-module

Remove MacOS module references. Fixes #1978.
This commit is contained in:
Simon Cozens 2020-07-07 09:36:42 +01:00 committed by GitHub
commit 26072943c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,10 +4,6 @@ try:
import xattr
except ImportError:
xattr = None
try:
import MacOS
except ImportError:
MacOS = None
def _reverseString(s):
@ -36,17 +32,7 @@ def getMacCreatorAndType(path):
fileType = Tag(finderInfo[:4])
fileCreator = Tag(finderInfo[4:8])
return fileCreator, fileType
if MacOS is not None:
fileCreator, fileType = MacOS.GetCreatorAndType(path)
if sys.version_info[:2] < (2, 7) and sys.byteorder == "little":
# work around bug in MacOS.GetCreatorAndType() on intel:
# http://bugs.python.org/issue1594
# (fixed with Python 2.7)
fileCreator = _reverseString(fileCreator)
fileType = _reverseString(fileType)
return fileCreator, fileType
else:
return None, None
return None, None
def setMacCreatorAndType(path, fileCreator, fileType):
@ -67,5 +53,3 @@ def setMacCreatorAndType(path, fileCreator, fileType):
raise TypeError('arg must be string of 4 chars')
finderInfo = pad(bytesjoin([fileType, fileCreator]), 32)
xattr.setxattr(path, 'com.apple.FinderInfo', finderInfo)
if MacOS is not None:
MacOS.SetCreatorAndType(path, fileCreator, fileType)