def main():
    try:
        args = docopt(__doc__, version=__version__)
        output_dir = None
        input_dir, output_dir = get_dirs(args)
        
        filenames = [
            ('alternatives.xml', False),
            ('outranking.xml', False),
            ('nonoutranking.xml', True),
            ('method_parameters.xml', False),
        ]
        params = [
            'alternatives',
            'outranking',
            'nonoutranking',
            'crisp_outranking'
        ]
        
        d = get_input_data(input_dir, filenames, params)
    
        alternativesId = d.alternatives
        outranking = d.outranking
        nonoutranking = d.nonoutranking
        crisp_outranking = d.crisp_outranking
        
        alg = algorithm(alternativesId, outranking, nonoutranking, crisp_outranking)
        result = alg.Run()
        
        type = 'real'
        if crisp_outranking == "true": type = 'integer'
        
        xmcda = ranks_to_xmcda(result[0], type, None)
        write_xmcda(xmcda, os.path.join(output_dir, 'nfs.xml'))
        xmcda = ranks_to_xmcda(result[1], type, None)
        write_xmcda(xmcda, os.path.join(output_dir, 'strength.xml'))
        xmcda = ranks_to_xmcda(result[2], type, None)
        write_xmcda(xmcda, os.path.join(output_dir, 'weakness.xml'))
        
        create_messages_file(None, ('Everything OK.',), output_dir)    
        return 0
    
    except Exception, err:
        err_msg = get_error_message(err)
        log_msg = traceback.format_exc()
        print(log_msg.strip())
        create_messages_file((err_msg, ), (log_msg, ), output_dir)
        return 1            
def main():
    try:
        args = docopt(__doc__, version=__version__)
        output_dir = None
        input_dir, output_dir = get_dirs(args)
        
        filenames = [
            ('alternatives.xml', False),
            ('downwards.xml', False),
            ('upwards.xml', False),
        ]
        params = [
            'alternatives',
            'downwards',
            'upwards',
        ]
        
        d = get_input_data(input_dir, filenames, params)
    
        alternativesId = d.alternatives
        downwards = d.downwards
        upwards = d.upwards

        alg = algorithm(alternativesId, downwards, upwards)
        result = alg.Run()
        
        comparables = (alternativesId, alternativesId)
        #xmcda = comparisons_to_xmcda(result[0], comparables)
        xmcda = outranking_to_xmcda(result[0])
        write_xmcda(xmcda, os.path.join(output_dir, 'intersection.xml'))
        xmcda = ranks_to_xmcda(result[1], 'integer', None)
        write_xmcda(xmcda, os.path.join(output_dir, 'rank.xml'))
        xmcda = ranks_to_xmcda(result[2], 'integer', None)
        write_xmcda(xmcda, os.path.join(output_dir, 'median.xml'))
        
        create_messages_file(None, ('Everything OK.',), output_dir)    
        return 0
    
    except Exception, err:
        err_msg = get_error_message(err)
        log_msg = traceback.format_exc()
        print(log_msg.strip())
        create_messages_file((err_msg, ), (log_msg, ), output_dir)
        return 1            
def main():
    try:
        args = docopt(__doc__, version=__version__)
        output_dir = None
        input_dir, output_dir = get_dirs(args)
        
        filenames = [
            ('alternatives.xml', False),
            ('outranking.xml', False),
            ('preorder.xml', True),
            ('method_parameters.xml', True),
        ]
        params = [
            'alternatives',
            'outranking',
            'preorder',
            'direction',
        ]
        
        d = get_input_data(input_dir, filenames, params)
    
        alternatives = d.alternatives
        
        preorder = None
        if (d.preorder is not None):
            preorder = d.preorder
        
        outranking = d.outranking
        direction = d.direction
        
        alg = algorithm(alternatives, outranking, preorder, direction)
        result = alg.Run()
        
        xmcda = ranks_to_xmcda(result, 'integer', None)
        write_xmcda(xmcda, os.path.join(output_dir, 'ranking.xml'))
        create_messages_file(None, ('Everything OK.',), output_dir)    
        return 0
    
    except Exception, err:
        err_msg = get_error_message(err)
        log_msg = traceback.format_exc()
        print(log_msg.strip())
        create_messages_file((err_msg, ), (log_msg, ), output_dir)
        return 1            
def main():
    try:
        args = docopt(__doc__, version=__version__)
        output_dir = None
        input_dir, output_dir = get_dirs(args)
        
        filenames = [
            ('alternatives.xml', False),
            ('credibility.xml', False),
            ('method_parameters.xml', True),
        ]
        params = [
            'alternatives',
            'credibility',
            'direction',
            'alpha',
            'beta'
        ]
        
        d = get_input_data(input_dir, filenames, params)
    
        alternativesId = d.alternatives
        credibility = d.credibility
        direction = d.direction
        alpha = d.alpha
        beta = d.beta
        
        alg = algorithm(alternativesId, credibility, direction, alpha, beta)
        result = alg.Run()
        
        xmcda = ranks_to_xmcda(result, 'integer', None)
        write_xmcda(xmcda, os.path.join(output_dir, 'ranking.xml'))
        
        create_messages_file(None, ('Everything OK.',), output_dir)    
        return 0
    
    except Exception, err:
        err_msg = get_error_message(err)
        log_msg = traceback.format_exc()
        print(log_msg.strip())
        create_messages_file((err_msg, ), (log_msg, ), output_dir)
        return 1