1. liquibits
  2. pystacia


pystacia / pystacia / magick / __init__.py

# coding: utf-8

# pystacia/magick/__init__.py
# Copyright (C) 2011-2012 by Paweł Piotr Przeradowski

# This module is part of Pystacia and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php

from pystacia.util import memoized

from os.path import dirname, join, exists
    from xml.etree.cElementTree import ElementTree
except ImportError:
    from xml.etree.ElementTree import ElementTree  # NOQA

def get_version():
    options = get_options()

        version = options['LIB_VERSION_NUMBER']
    except KeyError:
            version = options['VERSION']
        except KeyError:
            return None
            return tuple(int(x) for x in version.split('.'))
        return tuple(int(x) for x in version.split(','))

def get_options():
    def get_options_hack(path):
        options = {}

        parser = ElementTree()
        root = parser.parse(path)
        for element in root.findall('configure'):
            attrs = element.attrib
            options[attrs['name']] = attrs['value']

        return options

    dll_path = dirname(get_dll()._name)
    config_path = join(dll_path, 'configure.xml')

    if exists(config_path):
        return get_options_hack(config_path)
        return impl.get_options()

def get_version_str():
    return c_call('magick_', 'get_version', None)

def get_delegates():
        delegates = get_options()['DELEGATES']
    except KeyError:
        return []

    return delegates.split()

def get_depth():
    depth = get_options().get('QuantumDepth')
    return int(depth) if depth else None

def get_formats():
    return impl.get_formats()

def info():
    return {'options': get_options(),
            'formats': get_formats(),
            'dll': get_dll()._name}

from pystacia.api import get_dll
from pystacia.api.func import c_call
from pystacia.magick import _impl as impl