<commit_before>import argparse

import PIL
from PIL import Image
import subprocess
import os
import glob

def get_image(filename):
    p = Image.open(filename)
    docker_image = p.info['im2sim_image']
    return subprocess.call('docker pull {}'.format(docker_image), shell=True)
    print('Pulled docker image {}'.format(docker_image))

def tag_images(docker_image):
    subprocess.call(['mkdir', '-p', 'figures'])
    subprocess.call("docker run --rm -v {}/figures:/figures "
    "{} make figures".format(os.getcwd(), docker_image), shell=True)

    figures = glob.glob('{}/figures/*.png'.format(os.getcwd()))
    for filename in figures:
        p = Image.open(filename)
        info = PIL.PngImagePlugin.PngInfo()
        info.add_text('im2sim_image', docker_image)
        p.save(filename, pnginfo = info)

    return None

parser = argparse.ArgumentParser()
parser.add_argument("action", help="'pull', 'tag'")
parser.add_argument("object", help="Figure file (if pulling)"
                                   " or docker container (if tagging)")
args = parser.parse_args()

print("Action {}, Object {}".format(args.action, args.object))

if args.action == 'pull':<commit_msg>Completely untest implementation in XMP.<commit_after>import argparse

import libxmp
from libxmp import XMPFiles, XMPMeta
from libxmp.utils import file_to_dict
import ast

import subprocess
import os
import glob

def get_image(filename):
    xmp = file_to_dict(filename)
    dc = xmp[libxmp.consts.XMP_NS_DC]
    docker_image = None
    for name, value, d in dc:
        if name.find('creator') >= 0:
            if value.find('im2sim') >= 0:
                d = ast.literal_eval(value)
                docker_image = d['im2sim']
                print('From file {} found dc {} and image {}'.format(filename, dc, docker_image))
    return subprocess.call('docker pull {}'.format(docker_image), shell=True)
    print('Pulled docker image {}'.format(docker_image))

def tag_images(docker_image):
    subprocess.call(['mkdir', '-p', 'figures'])
    subprocess.call("docker run --rm -v {}/figures:/figures "
    "{} make figures".format(os.getcwd(), docker_image), shell=True)

    figures = glob.glob('{}/figures/*.png'.format(os.getcwd()))
    for filename in figures:
        xmpfile = XMPFiles(file_path=filename, open_forupdate=True)
        xmp = xmpfile.get_xmp()
        if xmp == None:
            xmp = XMPMeta()
        xmp.append_array_item(libxmp.consts.XMP_NS_DC, 'creator', '{ "im2sim : {}" }'.format(docker_image), {'prop_array_is_ordered': True, 'prop_value_is_array': True})
        xmpfile.put_xmp(xmp)
        xmpfile.close_file()

    return None

parser = argparse.ArgumentParser()
parser.add_argument("action", help="'pull', 'tag'")
parser.add_argument("object", help="Figure file (if pulling)"
                                   " or docker container (if tagging)")
args = parser.parse_args()

print("Action {}, Object {}".format(args.action, args.object))

if args.action == 'pull':
{'fraction_non_alphanumeric': 0.1448692152917505, 'fraction_numerical': 0.002347417840375587, 'mean_word_length': 3.4924698795180724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3242950', 'n_tokens_mistral': 991, 'n_tokens_neox': 938, 'n_words': 216}