[Pythonmac-SIG] Creator, type and other means of file detection
Henning Hraban Ramm
hraban at fiee.net
Sat Nov 29 21:45:24 CET 2008
Am 2008-11-29 um 20:15 schrieb Bill Janssen:
> 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
Thank you, I even found out what a UTI is supposed to be.
http://developer.apple.com/documentation/Carbon/Conceptual/understanding_utis/understand_utis_conc/chapter_2_section_2.html
But e.g. an InDesign document gives me a dynamical UTI like
"dyn.ah62d4rv4ge80w5xequ" instead of something reckognizable like
"IDd4" or "application/x-indesign".
OpenOffice documents give nice UTIs like "org.oasis-
open.opendocument.spreadsheet", but some widespread formats like RTF
and PDF just give nothing at all!
Very strange.
Could you please tell my how I apply the "OSType" method to an UTI?
Something like LaunchServices.UTType.UTGetOSTypeFromString(UTI) ?
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