<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import ctypes <EOL> import datetime <EOL> import re <EOL> import sys <EOL> try : <EOL> from . api import libmagick , library <EOL> except ImportError : <EOL> libmagick = None <EOL> from . compat import binary , string_type , text <EOL> __all__ = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> VERSION_INFO = ( <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:3> ) <EOL> VERSION = '<STR_LIT>' . format ( * VERSION_INFO ) <EOL> if libmagick : <EOL> c_magick_version = ctypes . c_size_t ( ) <EOL> MAGICK_VERSION = text ( <EOL> libmagick . GetMagickVersion ( ctypes . byref ( c_magick_version ) ) <EOL> ) <EOL> MAGICK_VERSION_NUMBER = c_magick_version . value <EOL> _match = re . match ( r'<STR_LIT>' , <EOL> MAGICK_VERSION ) <EOL> MAGICK_VERSION_INFO = tuple ( int ( v or <NUM_LIT:0> ) for v in _match . groups ( ) ) <EOL> MAGICK_RELEASE_DATE_STRING = text ( libmagick . GetMagickReleaseDate ( ) ) <EOL> MAGICK_RELEASE_DATE = datetime . date ( <EOL> * map ( int , MAGICK_RELEASE_DATE_STRING . split ( '<STR_LIT:->' ) ) ) <EOL> c_quantum_depth = ctypes . c_size_t ( ) <EOL> libmagick . GetMagickQuantumDepth ( ctypes . byref ( c_quantum_depth ) ) <EOL> QUANTUM_DEPTH = c_quantum_depth . value <EOL> del c_magick_version , _match , c_quantum_depth <EOL> def configure_options ( pattern = '<STR_LIT:*>' ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( pattern , string_type ) : <EOL> raise TypeError ( '<STR_LIT>' + repr ( pattern ) ) <EOL> pattern_p = ctypes . create_string_buffer ( binary ( pattern ) ) <EOL> config_count = ctypes . c_size_t ( <NUM_LIT:0> ) <EOL> configs = { } <EOL> configs_p = library . MagickQueryConfigureOptions ( pattern_p , <EOL> ctypes . byref ( config_count ) ) <EOL> cursor = <NUM_LIT:0> <EOL> while cursor < config_count . value : <EOL> config = configs_p [ cursor ] . value <EOL> value = library . MagickQueryConfigureOption ( config ) <EOL> configs [ text ( config ) ] = text ( value . value ) <EOL> cursor += <NUM_LIT:1> <EOL> return configs <EOL> def fonts ( pattern = '<STR_LIT:*>' ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( pattern , string_type ) : <EOL> raise TypeError ( '<STR_LIT>' + repr ( pattern ) ) <EOL> pattern_p = ctypes . create_string_buffer ( binary ( pattern ) ) <EOL> number_fonts = ctypes . c_size_t ( <NUM_LIT:0> ) <EOL> fonts = [ ] <EOL> fonts_p = library . MagickQueryFonts ( pattern_p , <EOL> ctypes . byref ( number_fonts ) ) <EOL> cursor = <NUM_LIT:0> <EOL> while cursor < number_fonts . value : <EOL> font = fonts_p [ cursor ] . value <EOL> fonts . append ( text ( font ) ) <EOL> cursor += <NUM_LIT:1> <EOL> return fonts <EOL> def formats ( pattern = '<STR_LIT:*>' ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( pattern , string_type ) : <EOL> raise TypeError ( '<STR_LIT>' + repr ( pattern ) ) <EOL> pattern_p = ctypes . create_string_buffer ( binary ( pattern ) ) <EOL> number_formats = ctypes . c_size_t ( <NUM_LIT:0> ) <EOL> formats = [ ] <EOL> formats_p = library . MagickQueryFormats ( pattern_p , <EOL> ctypes . byref ( number_formats ) ) <EOL> cursor = <NUM_LIT:0> <EOL> while cursor < number_formats . value : <EOL> value = formats_p [ cursor ] . value <EOL> formats . append ( text ( value ) ) <EOL> cursor += <NUM_LIT:1> <EOL> return formats <EOL> if __doc__ is not None : <EOL> __doc__ = __doc__ . replace ( '<STR_LIT>' , VERSION ) <EOL> del libmagick <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> options = frozenset ( sys . argv [ <NUM_LIT:1> : ] ) <EOL> if '<STR_LIT>' in options or '<STR_LIT>' in options : <EOL> print ( '<STR_LIT>' , VERSION ) <EOL> try : <EOL> print ( MAGICK_VERSION ) <EOL> except NameError : <EOL> pass <EOL> elif '<STR_LIT>' in options : <EOL> for font in fonts ( ) : <EOL> print ( font ) <EOL> elif '<STR_LIT>' in options : <EOL> for supported_format in formats ( ) : <EOL> print ( supported_format ) <EOL> elif '<STR_LIT>' in options : <EOL> config_options = configure_options ( ) <EOL> for key in config_options : <EOL> print ( '<STR_LIT>' . format ( key , config_options [ key ] ) ) <EOL> else : <EOL> print ( VERSION ) </s>
