~ubuntu-branches/ubuntu/maverick/fonttools/maverick

« back to all changes in this revision

Viewing changes to Lib/fontTools/misc/macCreatorType.py

  • Committer: Bazaar Package Importer
  • Author(s): Paul Wise
  • Date: 2008-07-24 00:03:02 UTC
  • mfrom: (2.1.8 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080724000302-0tediu4ysxkn6dyy
Tags: 2.2-2
* Fix dependencies to use Numpy instead of Numeric (Closes: #492010)
* Drop unneeded quilt build-dependency
* Support noopt in DEB_BUILD_OPTIONS
* Complies with policy 3.8.0, update Standards-Version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import sys
 
2
try:
 
3
        import MacOS
 
4
except ImportError:
 
5
        MacOS = None
 
6
 
 
7
def _reverseString(s):
 
8
        s = list(s)
 
9
        s.reverse()
 
10
        return "".join(s)
 
11
 
 
12
 
 
13
def getMacCreatorAndType(path):
 
14
        if MacOS is not None:
 
15
                fileCreator, fileType = MacOS.GetCreatorAndType(path)
 
16
                if sys.byteorder == "little":
 
17
                        # work around bug in MacOS.GetCreatorAndType() on intel:
 
18
                        # http://bugs.python.org/issue1594
 
19
                        fileCreator = _reverseString(fileCreator)
 
20
                        fileType = _reverseString(fileType)
 
21
                return fileCreator, fileType
 
22
        else:
 
23
                return None, None
 
24
 
 
25
 
 
26
def setMacCreatorAndType(path, fileCreator, fileType):
 
27
        if MacOS is not None:
 
28
                if sys.byteorder == "little":
 
29
                        # work around bug in MacOS.SetCreatorAndType() on intel:
 
30
                        # http://bugs.python.org/issue1594
 
31
                        fileCreator = _reverseString(fileCreator)
 
32
                        fileType = _reverseString(fileType)
 
33
                MacOS.SetCreatorAndType(path, fileCreator, fileType)