def main():
        short_options = 'o:r:v'
        long_options = [
            'output-file=',
            'render-mode=',
            'processes=',
            'verbose',
        ]
        options = dict({
            'level-file':None,
            'render-mode':'overhead',
            'output-file':'map.png',
            'verbose':False,
            'processes':multiprocessing.cpu_count(),
        })
        render_options = dict({
            'slices':None,
            'blocks':None,
        })

        try:
            opts, args = getopt.gnu_getopt(sys.argv[1:], short_options, long_options)
            try:
                options['level-file'] = args[0]
            except IndexError:
                raise getopt.GetoptError('Missing level-file argument')
            for opt,arg in opts:
                if opt in ('-o', '--output-file'):
                    options['output-file'] = arg
                elif opt in ('-r', '--render-mode'):
                    if arg in render_modes:
                        options['render-mode'] = arg
                    else:
                        raise getopt.GetoptError('Invalid option (%s) argument (%s)' %
                            (opt, arg))
                elif opt in ('-v', '--verbose'):
                    options['verbose'] = True
                elif opt == '--processes':
                    options['processes'] = max(int(arg), 1)
                else:
                    pass
        except getopt.GetoptError, error:
            print error
            usage()
            return None

        def _get_chunk_args(chunk_file):
            return (chunk_file, level.level_size, render_options)

        def _init_multiprocess(array):
            global image_array
            image_array = array

        level = Level(level_file=options['level-file'])
        if options['verbose']: print level

        if options['render-mode'] == 'oblique':
            map_image_size_addon = (0,Level.chunk_size_Y)
        else:
            map_image_size_addon = (0,0)
        map_image_size = (
            (level.level_size['x_max'] + abs(level.level_size['x_min']) + 1) * Level.chunk_size_X + map_image_size_addon[0],
            (level.level_size['z_max'] + abs(level.level_size['z_min']) + 1) * Level.chunk_size_Z + map_image_size_addon[1],
        )
        global image_array
        image_array = init_image_array(map_image_size)

        pool = multiprocessing.Pool(options['processes'], _init_multiprocess, (image_array,))
        if options['verbose']: print 'Rendering...'
        pool.map(render_modes[options['render-mode']], map(_get_chunk_args, level.chunk_files), level.chunk_count/options['processes'])
        #for x in range(5): render_oblique_chunk((level.chunk_files[x], level.level_size, render_options))
        Image.fromarray(image_array, 'RGBA').save(options['output-file'])
dataset/ETHPy150Open aheadley/pynemap/pynemap.py/main/original