import platform, sys, ctypes

if 'Linux' in platform.system():
    dlflags = sys.getdlopenflags()
    sys.setdlopenflags(dlflags | ctypes.RTLD_GLOBAL)

import maca

__author__ = 'blaz'
if 'Linux' in platform.system():
    # get back to default dlopen policy
    sys.setdlopenflags(dlflags)


def get_maca_string_reader(input_text, maca_config):
    """
    Get maca plain text reader

    @param input_text: plain text
    @param maca_config: (optional) maca config
    @return: reader
    """
    return maca.PlainTextReader.create_string_reader(input_text,
                                                     maca_config)


def get_maca_file_premorph_reader(input, maca_config):
    """
    Method returns maca premorph reader.

    @type input: str
    @type maca_config: str
    """
    return maca.PremorphTextReader_create_file_reader(input,
                                                      maca_config)