[Pythonmac-SIG] Creator, type and other means of file detection

Henning Hraban Ramm hraban at fiee.net
Sat Nov 29 15:30:47 CET 2008


I know the MacOS module is deprecated, and now I know at least one 
detail of "why":
If I use MacOS.GetCreatorAndType(filename) on my Intel machine, I get 
for an EPS:
('09HF', 'FSPE')
That should read ('FH09', 'EPSF').
I didn't knew endian-ness affects the order of strings.
Very funny! ;-)
I'm trying once again to write a tool to detect the type of a file - 
my colleagues don't know what to do if a file lacks an extension or 
has a wrong one.
Unfortunately the "file" command and its Python counterparts don't 
know enough and the right types, e.g. for them a XPress or InDesign 
document is just "data".
(There are two different approaches of "magic.py": Jason Petrone's, 
updated by Gabriel Wicke, uses its own, pythonized list of magic 
numbers; the other by Thomas Mangin reads the usual Unix/Linux magic 
files and thus acts like the "file" command. I guess the first is much 
faster, but the second is more versatile.)
Anyway, the traditional MacOS type and creator would be a nice 
addition. The MacOS module is deprecated. I could ask the Finder via 
appscript, but I wonder if there's a more direct way - I'm surprised 
the mactypes module's Alias and File classes don't know type and 
creator.
Any ideas on that?
Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net
https://www.cacert.org (I'm an assurer)


More information about the Pythonmac-SIG mailing list

AltStyle によって変換されたページ (->オリジナル) /