コード例 #1
0
ファイル: _impl.py プロジェクト: ppawlak/pystacia
def get_options():
    options = {}

    size = c_size_t()
    keys = c_call('magick_', 'query_configure_options', '*', byref(size))
    for key in [native_str(keys[i]) for i in range(size.value)]:
        options[key] = c_call('magick_', 'query_configure_option', key)

    return options
コード例 #2
0
ファイル: compat_tests.py プロジェクト: ppawlak/pystacia
    def test(self):
        if version_info < (2, 6):
            from stringformat import FormattableString  # @UnresolvedImport
            self.assertEqual(formattable, FormattableString)
        else:
            self.assertEqual(formattable, str)

        if version_info < (3,):
            value = 'abc'
        else:
            value = 'abc'.encode('utf-8')

        self.assertIsInstance(native_str(value), str)
        self.assertEqual(native_str(value), 'abc')

        if version_info < (2, 7):
            from unittest2 import TestCase as TestCase_  # @UnresolvedImport
            self.assertEqual(TestCase, TestCase_)
        else:
            from unittest import TestCase as TestCase_py
            self.assertEqual(TestCase, TestCase_py)
コード例 #3
0
ファイル: compat_tests.py プロジェクト: ppawlak/pystacia
    def test(self):
        if version_info < (2, 6):
            from stringformat import FormattableString  # @UnresolvedImport
            self.assertEqual(formattable, FormattableString)
        else:
            self.assertEqual(formattable, str)

        if version_info < (3, ):
            value = 'abc'
        else:
            value = 'abc'.encode('utf-8')

        self.assertIsInstance(native_str(value), str)
        self.assertEqual(native_str(value), 'abc')

        if version_info < (2, 7):
            from unittest2 import TestCase as TestCase_  # @UnresolvedImport
            self.assertEqual(TestCase, TestCase_)
        else:
            from unittest import TestCase as TestCase_py
            self.assertEqual(TestCase, TestCase_py)
コード例 #4
0
def handle_result(result, restype, args, argtypes):
    if restype == c_char_p:
        result = native_str(result)
    if restype in (c_uint, c_ssize_t, c_size_t):
        result = int(result)
    elif restype == enum and not jython:
        result = result.value
    elif restype == MagickBoolean and not result:
        exc_type = ExceptionType()

        if argtypes[0] == MagickWand_p:
            klass = 'magick'
        elif argtypes[0] == PixelWand_p:
            klass = 'pixel'

        description = c_call(klass, 'get_exception', args[0], byref(exc_type))
        try:
            raise PystaciaException(native_str(string_at(description)))
        finally:
            c_call('magick_', 'relinquish_memory', description)

    return result
コード例 #5
0
ファイル: _impl.py プロジェクト: ppawlak/pystacia
def get_formats():
    size = c_size_t()
    formats = c_call('magick_', 'query_formats', '*', byref(size))

    return [native_str(formats[i]).lower() for i in range(size.value)]