diff options
| author | Adam Hupp <adam@hupp.org> | 2010-11-21 23:20:18 -0800 |
|---|---|---|
| committer | Adam Hupp <adam@hupp.org> | 2010-11-21 23:20:18 -0800 |
| commit | a2153f745d8c3bd0d8220c2b474aacf52f07ae38 (patch) | |
| tree | 3eb30ba002f03e12384970a613835cd9a50c4b13 | |
| parent | 2f5d66706d1ea0d20445baab3a66d353a5e5edbf (diff) | |
| download | python-magic-a2153f745d8c3bd0d8220c2b474aacf52f07ae38.tar.gz | |
Consolidate darwin/win32 library loading. Tested on OSX.
| -rw-r--r-- | magic.py | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -115,19 +115,12 @@ if dll: if not libmagic or not libmagic._name: import sys - if sys.platform == "darwin": + platform_to_lib = {'darwin': '/opt/local/lib/libmagic.dylib', + 'win32': 'magic1.dll'} + if sys.platform in platform_to_lib: try: - # try mac ports location - libmagic = ctypes.CDLL('/opt/local/lib/libmagic.dylib') - # Should we catch just OSError exceptions? - except: - pass - elif sys.platform == "win32": - try: - # try local magic1.dll - libmagic = ctypes.CDLL('magic1.dll') - # Should we catch just OSError exceptions? - except: + libmagic = ctypes.CDLL(platform_to_lib[sys.platform]) + except OSError: pass if not libmagic or not libmagic._name: |
