# Buggy code
def main(args, error):
    """
    Makes sure that the assets have been converted,
    and jumps into the C++ main method.
    """
    del error  # unused

    # we have to import stuff inside the function
    # as it depends on generated/compiled code
    from .main_cpp import run_game
    from .. import config
    from ..assets import get_asset_path
    from ..convert.main import conversion_required, convert_assets
    from ..cppinterface.setup import setup as cpp_interface_setup
    from ..cvar.location import get_config_path
    from ..util.fslike.union import Union

    # initialize libopenage
    cpp_interface_setup(args)

    info("launching openage {}".format(config.VERSION))
    info("compiled by {}".format(config.COMPILER))

    if config.DEVMODE:
        info("running in DEVMODE")

    # create virtual file system for data paths
    root = Union().root

    # mount the assets folder union at "assets/"
    root["assets"].mount(get_asset_path(args))

    # mount the config folder at "cfg/"
    root["cfg"].mount(get_config_path(args))

    # ensure that the assets have been converted
    if conversion_required(root["assets"], args):
        if not convert_assets(root["assets"], args):
            err("game asset conversion failed")
            return 1

    # start the game, continue in main_cpp.pyx!
    return run_game(args, root)


# Traceback (ValueError)
dev@openage:~/openage$ python3 -m openage convert-file /home/dev/aoe1/data/Border.drs 20000.slp /home/dev/aoe1/data/test.png
INFO opening slp in drs '/home/dev/aoe1/data/Border.drs:20000.slp'...
INFO parsing slp image...
INFO opening palette in drs '/home/dev/aoe1/data/interfac.drs:50500.bin'...
INFO parsing palette data...
INFO packing texture...
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/dev/openage/openage/__main__.py", line 128, in <module>
exit(main())
File "/home/dev/openage/openage/__main__.py", line 121, in main
return args.entrypoint(args, cli.error)
File "/home/dev/openage/openage/convert/singlefile.py", line 72, in main
tex.save(Directory(path).root, filename)
File "/home/dev/openage/openage/convert/texture.py", line 170, in save
raise ValueError("Texture must be saved as name.png. got: %s" % filename)
ValueError: Texture must be saved as name.png. got: test

# Fixed code
def main(args, error):
    """
    Makes sure that the assets have been converted,
    and jumps into the C++ main method.
    """
    del error  # unused

    # we have to import stuff inside the function
    # as it depends on generated/compiled code
    from .main_cpp import run_game
    from .. import config
    from ..assets import get_asset_path
    from ..convert.main import conversion_required, convert_assets
    from ..cppinterface.setup import setup as cpp_interface_setup
    from ..cvar.location import get_config_path
    from ..util.fslike.union import Union

    # initialize libopenage
    cpp_interface_setup(args)

    info("launching openage {}".format(config.VERSION))
    info("compiled by {}".format(config.COMPILER))

    if config.DEVMODE:
        info("running in DEVMODE")

    # create virtual file system for data paths
    root = Union().root

    # mount the assets folder union at "assets/"
    root["assets"].mount(get_asset_path(args.asset_dir))

    # mount the config folder at "cfg/"
    root["cfg"].mount(get_config_path(args.cfg_dir))

    # ensure that the assets have been converted
    if conversion_required(root["assets"], args):
        if not convert_assets(root["assets"], args):
            err("game asset conversion failed")
            return 1

    # start the game, continue in main_cpp.pyx!
    return run_game(args, root)