<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def action(args):
 """Updates a Refpkg with new files. *args* should be an argparse object with fields refpkg (giving the path to the refpkg to operate on) and changes (a series of strings of the form 'key=file' giving the key to update in the refpkg and the file to store under that key)." """

    log.info('loading reference package')

    pairs = [p.split('=', 1) for p in args.changes]
    if args.metadata:
        rp = refpkg.Refpkg(args.refpkg, create=False)
        rp.start_transaction()
        for key, value in pairs:
            rp.update_metadata(key, value)
        rp.commit_transaction('Updated metadata: ' +
                              ', '.join(['%s=%s' % (a, b)
                                         for a, b in pairs]))
    else:
        for key, filename in pairs:
            if not(os.path.exists(filename)):
                print("No such file: %s" % filename)
                exit(1)

        rp = refpkg.Refpkg(args.refpkg, create=False)
        rp.start_transaction()
        for key, filename in pairs:
            if key == 'tree_stats':
                with warnings.catch_warnings():
                    warnings.simplefilter(
                        "ignore", refpkg.DerivedFileNotUpdatedWarning)
                    rp.update_file(key, os.path.abspath(filename))
                # Trigger model update
                log.info('Updating phylo_model to match tree_stats')
                rp.update_phylo_model(args.stats_type, filename,
                                      args.frequency_type)
            else:
                rp.update_file(key, os.path.abspath(filename))

        rp.commit_transaction('Updates files: ' +
                              ', '.join(['%s=%s' % (a, b)
                                         for a, b in pairs]))
    return 0