# Buggy code
def __init__(
    self, language: str, treebank: Optional[str] = None, stanza_debug_level="ERROR"
) -> None:
    """Constructor for ``get_stanza_models`` wrapper class.

    TODO: Do tests for all langs and available models for each

    >>> stanza_wrapper = StanzaWrapper(language='grc', stanza_debug_level="INFO")
    >>> isinstance(stanza_wrapper, StanzaWrapper)
    True
    >>> stanza_wrapper.language
    'grc'
    >>> stanza_wrapper.treebank
    'proiel'

    >>> stanza_wrapper = StanzaWrapper(language="grc", treebank="perseus", stanza_debug_level="INFO")
    >>> isinstance(stanza_wrapper, StanzaWrapper)
    True
    >>> stanza_wrapper.language
    'grc'
    >>> stanza_wrapper.treebank
    'perseus'
    >>> from cltkv1.languages.example_texts import get_example_text
    >>> stanza_doc = stanza_wrapper.parse(get_example_text("grc"))

    >>> StanzaWrapper(language="xxx", stanza_debug_level="INFO")
    Traceback (most recent call last):
      ...
    cltkv1.core.exceptions.UnknownLanguageError: Language 'xxx' either not in scope for CLTK or not supported by Stanza.

    >>> stanza_wrapper = StanzaWrapper(language="grc", treebank="proiel", stanza_debug_level="INFO")
    >>> stanza_doc = stanza_wrapper.parse(get_example_text("grc"))

    >>> stanza_wrapper = StanzaWrapper(language="lat", treebank="perseus", stanza_debug_level="INFO")
    >>> stanza_doc = stanza_wrapper.parse(get_example_text("lat"))

    >>> stanza_wrapper = StanzaWrapper(language="lat", treebank="proiel", stanza_debug_level="INFO")
    >>> stanza_doc = stanza_wrapper.parse(get_example_text("lat"))

    >>> stanza_wrapper = StanzaWrapper(language="chu", stanza_debug_level="INFO")
    >>> stanza_doc = stanza_wrapper.parse(get_example_text("chu"))

    >>> stanza_wrapper = StanzaWrapper(language="cop", stanza_debug_level="INFO")
    >>> stanza_doc = stanza_wrapper.parse(get_example_text("cop"))

    >>> stanza_wrapper = StanzaWrapper(language="lzh", stanza_debug_level="INFO")
    >>> stanza_doc = stanza_wrapper.parse(get_example_text("lzh"))

    >>> stanza_wrapper = StanzaWrapper(language="lat", treebank="xxx", stanza_debug_level="INFO")
    Traceback (most recent call last):
      ...
    cltkv1.core.exceptions.UnimplementedAlgorithmError: Invalid treebank 'xxx' for language 'lat'.
    """
    self.language = language
    self.treebank = treebank
    self.stanza_debug_level = stanza_debug_level

    # Setup language
    self.map_langs_cltk_stanza = {
        "chu": "Old_Church_Slavonic",
        "cop": "Coptic",
        "fro": "Old_French",
        "grc": "Ancient_Greek",
        "got": "Gothic",
        "lat": "Latin",
        "lzh": "Classical_Chinese",
    }

    self.wrapper_available = self.is_wrapper_available()  # type: bool
    if not self.wrapper_available:
        raise UnknownLanguageError(
            "Language '{}' either not in scope for CLTK or not supported by Stanza.".format(
                self.language
            )
        )
    self.stanza_code = self._get_stanza_code()

    # Setup optional treebank if specified
    # TODO: Write tests for all treebanks
    self.map_code_treebanks = dict(
        grc=["proiel", "perseus"], la=["perseus", "proiel", "ittb"]
    )
    # if not specified, will use the default treebank chosen by stanza
    if self.treebank:
        valid_treebank = self._is_valid_treebank()
        if not valid_treebank:
            raise UnimplementedAlgorithmError(
                f"Invalid treebank '{self.treebank}' for language '{self.language}'."
            )
    else:
        self.treebank = self._get_default_treebank()

    # check if model present
    # this fp is just to confirm that some model has already been downloaded.
    # TODO: This is a weak check for the models actually being downloaded and valid
    # TODO: Use ``models_dir`` var from below and make self. or global to module
    self.model_path = os.path.expanduser(
        f"~/stanza_resources/{self.stanza_code}/tokenize/{self.treebank}.pt"
    )
    if not self._is_model_present():
        # download model if necessary
        self._download_model()

    # instantiate actual stanza class
    # Note: `suppress_stdout` is used to prevent `stanza`
    # from printing a long log of its parameters to screen.
    # Though we should capture these, within `_load_pipeline()`,
    # for the log file.
    with suppress_stdout():
        self.nlp = self._load_pipeline()


# Traceback (TypeError)
In [1]: from cltk.corpus.utils.importer import CorpusImporter

In [2]: corpus_importer = CorpusImporter('latin')

In [3]: corpus_importer.
corpus_importer.import_corpus  corpus_importer.list_corpora
corpus_importer.language

In [3]: corpus_importer.
corpus_importer.import_corpus  corpus_importer.list_corpora
corpus_importer.language

In [3]: corpus_importer.list_corpora
Out[3]:
['latin_text_perseus',
'latin_treebank_perseus',
'latin_text_lacus_curtius',
'latin_text_latin_library',
'phi5',
'phi7',
'latin_proper_names',
'cltk_linguistic_data',
'latin_pos']

In [4]: corpus_importer.import_corpus('phi5', '/Users/kyle/Downloads/corpora/PH/')
/Users/kyle/Downloads/corpora/PHI5/  /Users/kyle/Downloads/corpora/PHI7/

In [4]: corpus_importer.import_corpus('phi5', '/Users/kyle/Downloads/corpora/PHI/')
/Users/kyle/Downloads/corpora/PHI5/  /Users/kyle/Downloads/corpora/PHI7/

In [4]: corpus_importer.import_corpus('phi5', '/Users/kyle/Downloads/corpora/PHI/')
/Users/kyle/Downloads/corpora/PHI5/  /Users/kyle/Downloads/corpora/PHI7/

In [4]: corpus_importer.import_corpus('phi5', '/Users/kyle/Downloads/corpora/PHI5/')
--- Logging error ---
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 971, in emit
msg = self.format(record)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 821, in format
return fmt.format(record)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 558, in format
record.message = record.getMessage()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 321, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File "/Users/kyle/Downloads/cltk/venv/bin/ipython", line 11, in <module>
sys.exit(start_ipython())
File "/Users/kyle/Downloads/cltk/venv/lib/python3.4/site-packages/IPython/__init__.py", line 120, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/Users/kyle/Downloads/cltk/venv/lib/python3.4/site-packages/IPython/config/application.py", line 564, in launch_instance
app.start()
File "/Users/kyle/Downloads/cltk/venv/lib/python3.4/site-packages/IPython/terminal/ipapp.py", line 371, in start
self.shell.mainloop()
File "/Users/kyle/Downloads/cltk/venv/lib/python3.4/site-packages/IPython/terminal/interactiveshell.py", line 443, in mainloop
self.interact(display_banner=display_banner)
File "/Users/kyle/Downloads/cltk/venv/lib/python3.4/site-packages/IPython/terminal/interactiveshell.py", line 567, in interact
self.run_cell(source_raw, store_history=True)
File "/Users/kyle/Downloads/cltk/venv/lib/python3.4/site-packages/IPython/core/interactiveshell.py", line 2741, in run_cell
interactivity=interactivity, compiler=compiler)
File "/Users/kyle/Downloads/cltk/venv/lib/python3.4/site-packages/IPython/core/interactiveshell.py", line 2833, in run_ast_nodes
if self.run_code(code):
File "/Users/kyle/Downloads/cltk/venv/lib/python3.4/site-packages/IPython/core/interactiveshell.py", line 2883, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-4-b2bc3206f5ea>", line 1, in <module>
corpus_importer.import_corpus('phi5', '/Users/kyle/Downloads/corpora/PHI5/')
File "/Users/kyle/Downloads/cltk/cltk/corpus/utils/importer.py", line 188, in import_corpus
logger.info('Incoming path:', path)
Message: 'Incoming path:'
Arguments: ('/Users/kyle/Downloads/corpora/PHI5/',)

# Fixed code
def __init__(
    self, language: str, treebank: Optional[str] = None, stanza_debug_level="ERROR"
) -> None:
    """Constructor for ``get_stanza_models`` wrapper class.

    TODO: Do tests for all langs and available models for each

    >>> stanza_wrapper = StanzaWrapper(language='grc', stanza_debug_level="INFO")
    >>> isinstance(stanza_wrapper, StanzaWrapper)
    True
    >>> stanza_wrapper.language
    'grc'
    >>> stanza_wrapper.treebank
    'proiel'

    >>> stanza_wrapper = StanzaWrapper(language="grc", treebank="perseus", stanza_debug_level="INFO")
    >>> isinstance(stanza_wrapper, StanzaWrapper)
    True
    >>> stanza_wrapper.language
    'grc'
    >>> stanza_wrapper.treebank
    'perseus'
    >>> from cltkv1.languages.example_texts import get_example_text
    >>> stanza_doc = stanza_wrapper.parse(get_example_text("grc"))

    >>> StanzaWrapper(language="xxx", stanza_debug_level="INFO")
    Traceback (most recent call last):
      ...
    cltkv1.core.exceptions.UnknownLanguageError: Language 'xxx' either not in scope for CLTK or not supported by Stanza.

    >>> stanza_wrapper = StanzaWrapper(language="grc", treebank="proiel", stanza_debug_level="INFO")
    >>> stanza_doc = stanza_wrapper.parse(get_example_text("grc"))

    >>> stanza_wrapper = StanzaWrapper(language="lat", treebank="perseus", stanza_debug_level="INFO")
    >>> stanza_doc = stanza_wrapper.parse(get_example_text("lat"))

    >>> stanza_wrapper = StanzaWrapper(language="lat", treebank="proiel", stanza_debug_level="INFO")
    >>> stanza_doc = stanza_wrapper.parse(get_example_text("lat"))

    >>> stanza_wrapper = StanzaWrapper(language="chu", stanza_debug_level="INFO")
    >>> stanza_doc = stanza_wrapper.parse(get_example_text("chu"))

    # >>> stanza_wrapper = StanzaWrapper(language="cop", stanza_debug_level="INFO")
    # >>> stanza_doc = stanza_wrapper.parse(get_example_text("cop"))

    >>> stanza_wrapper = StanzaWrapper(language="lzh", stanza_debug_level="INFO")
    >>> stanza_doc = stanza_wrapper.parse(get_example_text("lzh"))

    >>> stanza_wrapper = StanzaWrapper(language="lat", treebank="xxx", stanza_debug_level="INFO")
    Traceback (most recent call last):
      ...
    cltkv1.core.exceptions.UnimplementedAlgorithmError: Invalid treebank 'xxx' for language 'lat'.
    """
    self.language = language
    self.treebank = treebank
    self.stanza_debug_level = stanza_debug_level

    # Setup language
    self.map_langs_cltk_stanza = {
        "chu": "Old_Church_Slavonic",
        "cop": "Coptic",
        "fro": "Old_French",
        "grc": "Ancient_Greek",
        "got": "Gothic",
        "lat": "Latin",
        "lzh": "Classical_Chinese",
    }

    self.wrapper_available = self.is_wrapper_available()  # type: bool
    if not self.wrapper_available:
        raise UnknownLanguageError(
            "Language '{}' either not in scope for CLTK or not supported by Stanza.".format(
                self.language
            )
        )
    self.stanza_code = self._get_stanza_code()

    # Setup optional treebank if specified
    # TODO: Write tests for all treebanks
    self.map_code_treebanks = dict(
        grc=["proiel", "perseus"], la=["perseus", "proiel", "ittb"]
    )
    # if not specified, will use the default treebank chosen by stanza
    if self.treebank:
        valid_treebank = self._is_valid_treebank()
        if not valid_treebank:
            raise UnimplementedAlgorithmError(
                f"Invalid treebank '{self.treebank}' for language '{self.language}'."
            )
    else:
        self.treebank = self._get_default_treebank()

    # check if model present
    # this fp is just to confirm that some model has already been downloaded.
    # TODO: This is a weak check for the models actually being downloaded and valid
    # TODO: Use ``models_dir`` var from below and make self. or global to module
    self.model_path = os.path.expanduser(
        f"~/stanza_resources/{self.stanza_code}/tokenize/{self.treebank}.pt"
    )
    if not self._is_model_present():
        # download model if necessary
        self._download_model()

    # instantiate actual stanza class
    # Note: `suppress_stdout` is used to prevent `stanza`
    # from printing a long log of its parameters to screen.
    # Though we should capture these, within `_load_pipeline()`,
    # for the log file.
    with suppress_stdout():
        self.nlp = self._load_pipeline()