summaryrefslogtreecommitdiffstats
path: root/Mac/Demo/resources
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-07-01 18:23:09 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-07-01 18:23:09 (GMT)
commitde9c869fb8c1f842bc3dfc4d51f287cb6b644ab2 (patch)
treeda0b9c0e9d56288354f936b59021d94018a172a8 /Mac/Demo/resources
parentbbfd71d7ac02bc2053a0ba494a3f055fbec8deee (diff)
downloadcpython-de9c869fb8c1f842bc3dfc4d51f287cb6b644ab2.zip
cpython-de9c869fb8c1f842bc3dfc4d51f287cb6b644ab2.tar.gz
cpython-de9c869fb8c1f842bc3dfc4d51f287cb6b644ab2.tar.bz2
Hopefully fix make framework install on Mac (see 3174)
Removal of the Mac modules broke many of the Mac scripts (including BuildApplet.py) so the building of the Python launcher and IDLE.app was broken. I manually copied built versions of those apps into Mac. Everything else which used Mac modules had to die.
Diffstat (limited to 'Mac/Demo/resources')
-rw-r--r--Mac/Demo/resources/copyres.py63
-rw-r--r--Mac/Demo/resources/listres.py60
2 files changed, 0 insertions, 123 deletions
diff --git a/Mac/Demo/resources/copyres.py b/Mac/Demo/resources/copyres.py
deleted file mode 100644
index 6c8a3c0..0000000
--- a/Mac/Demo/resources/copyres.py
+++ /dev/null
@@ -1,63 +0,0 @@
-from Carbon.Res import *
-from Carbon.Resources import *
-import MacOS
-
-READ = 1
-WRITE = 2
-smAllScripts = -3
-
-def raw_input(prompt):
- import sys
- sys.stdout.write(prompt)
- sys.stdout.flush()
- return sys.stdin.readline()
-
-def copyres(src, dst):
- """Copy resource from src file to dst file."""
-
- cur = CurResFile()
- ctor, type = MacOS.GetCreatorAndType(src)
- input = FSpOpenResFile(src, READ)
- try:
- FSpCreateResFile(dst, ctor, type, smAllScripts)
- except:
- raw_input("%s already exists... CR to write anyway! " % dst)
- output = FSpOpenResFile(dst, WRITE)
- UseResFile(input)
- ntypes = Count1Types()
- for itype in range(1, 1+ntypes):
- type = Get1IndType(itype)
- nresources = Count1Resources(type)
- for ires in range(1, 1+nresources):
- res = Get1IndResource(type, ires)
- res.LoadResource()
- id, type, name = res.GetResInfo()
- size = res.SizeResource()
- attrs = res.GetResAttrs()
- print(id, type, name, size, hex(attrs))
- res.DetachResource()
- UseResFile(output)
- try:
- res2 = Get1Resource(type, id)
- except (RuntimeError, Res.Error) as msg:
- res2 = None
- if res2:
- print("Duplicate type+id, not copied")
- print (res2.size, res2.data)
- print(res2.GetResInfo())
- if res2.HomeResFile() == output:
- 'OK'
- elif res2.HomeResFile() == input:
- 'BAD!'
- else:
- print('Home:', res2.HomeResFile())
- else:
- res.AddResource(type, id, name)
- #res.SetResAttrs(attrs)
- res.WriteResource()
- UseResFile(input)
- UseResFile(cur)
- CloseResFile(output)
- CloseResFile(input)
-
-copyres('::python.¹.rsrc', '::foo.rsrc')
diff --git a/Mac/Demo/resources/listres.py b/Mac/Demo/resources/listres.py
deleted file mode 100644
index 8f391eb..0000000
--- a/Mac/Demo/resources/listres.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# List all resources
-
-from Carbon import Res
-from Carbon.Resources import *
-
-def list1resources():
- ntypes = Res.Count1Types()
- for itype in range(1, 1+ntypes):
- type = Res.Get1IndType(itype)
- print("Type:", repr(type))
- nresources = Res.Count1Resources(type)
- for i in range(1, 1 + nresources):
- Res.SetResLoad(0)
- res = Res.Get1IndResource(type, i)
- Res.SetResLoad(1)
- info(res)
-
-def listresources():
- ntypes = Res.CountTypes()
- for itype in range(1, 1+ntypes):
- type = Res.GetIndType(itype)
- print("Type:", repr(type))
- nresources = Res.CountResources(type)
- for i in range(1, 1 + nresources):
- Res.SetResLoad(0)
- res = Res.GetIndResource(type, i)
- Res.SetResLoad(1)
- info(res)
-
-def info(res):
- print(res.GetResInfo(), res.SizeResource(), decodeattrs(res.GetResAttrs()))
-
-attrnames = {
- resChanged: 'Changed',
- resPreload: 'Preload',
- resProtected: 'Protected',
- resLocked: 'Locked',
- resPurgeable: 'Purgeable',
- resSysHeap: 'SysHeap',
-}
-
-def decodeattrs(attrs):
- names = []
- for bit in range(16):
- mask = 1<<bit
- if attrs & mask:
- if attrnames.has_key(mask):
- names.append(attrnames[mask])
- else:
- names.append(hex(mask))
- return names
-
-def test():
- print("=== Local resourcess ===")
- list1resources()
- print("=== All resources ===")
- listresources()
-
-if __name__ == '__main__':
- test()