I think the modern Mac equivalent goes something like this: def uti_for_file(path):
import os from AppKit import NSWorkspace uti, err = NSWorkspace.sharedWorkspace().typeOfFile_error_( os.path.realpath(path), None) if err: raise Exception(unicode(err)) else: return uti Bill Henning Hraban Ramm <[EMAIL PROTECTED]> wrote: > 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) > > > > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG@python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig