def convert(args, parser):
    filenames = args.filename
    if len(filenames) > 1:
        parser.error('Please specify no more than one filename to convert')
        # The return is only reached with a test parser from the unit tests.
        return 1

    filename = (filenames and filenames[0]) or STDIN
    xcodeproj = data_from_filename(filename)
    root, parseinfo = parse(xcodeproj, parsertype=args.parser)
    report_parse_status(root, parseinfo, filename=filename)
    if root is None:
        return PARSING_FAILED

    # Set objectVersion if requested
    if args.objectversion != 'same':
        if args.objectversion == 'latest':
            version = text_type(LATEST_OBJECT_VERSION)
        else:
            version = args.objectversion
        root['objectVersion'] = version

    projectname = projectname_from_args(args, parser, filename, parseinfo.get('projectname'))
    proj = unparse(root,
                   format=args.convert,
                   projectname=projectname,
                   disable_comments=args.comments == 'no',
                   parseinfo=parseinfo)

    if args.outputfile is not None:
        destfilename = args.outputfile
    elif filename == STDIN:
        destfilename = STDOUT
    else:
        destfilename = filename

    if destfilename == STDOUT:
        buf = sys.stdout
        try:
            numbytes = buf.write(proj)
        except TypeError:
            # We are probably writing to a io.StringIO here.
            numbytes = len(proj)
            buf.write(unistr(proj))
    else:
        with open(destfilename, 'wb') as f:
            numbytes = f.write(proj)

    if numbytes is not None and numbytes != len(proj):
        reporterror('Incomplete output, only %d of %d bytes written' % (numbytes, len(proj)))
        return CONVERT_OUTPUT_FAILED

    return OK


# ----------------------------------------------------------------------
dataset/ETHPy150Open mikr/xcodeprojer/xcodeprojer.py/convert/original