<commit_before>package aQute.lib.deployer;

import java.io.*;
import java.security.*;
import java.util.*;
import java.util.jar.*;
import java.util.regex.*;

import aQute.bnd.header.*;
import aQute.bnd.osgi.*;
import aQute.bnd.service.*;
import aQute.bnd.version.*;
import aQute.lib.io.*;
import aQute.libg.command.*;
import aQute.service.reporter.*;

public class FileRepo implements Plugin, RepositoryPlugin, Refreshable, RegistryPlugin {
	public final static String	LOCATION		= "location";
	public final static String	READONLY		= "readonly";
	public final static String	NAME			= "name";
	public static final String	CMD_PATH		= "cmd.path";
	public static final String	CMD_INIT		= "cmd.init";
	public static final String	CMD_AFTER_PUT	= "cmd.after.put";
	public static final String	CMD_REFRESH		= "cmd.refresh";
	public static final String	CMD_BEFORE_PUT	= "cmd.before.put";
	public static final String	CMD_ABORT_PUT	= "cmd.abort.put";
	public static final String	CMD_SHELL		= "cmd.shell";
	static final PutOptions		DEFAULTOPTIONS	= new PutOptions();

	String						before;
	String						refresh;
	String						after;
	String						path;
	String						init;
	String						abort;
	String						shell;

	File[]						EMPTY_FILES		= new File[0];
	protected File				root;
	Registry					registry;
	boolean						canWrite		= true;
	Pattern						REPO_FILE		= Pattern.compile("([-a-zA-z0-9_\\.]+)-([0-9\\.]+|latest)\\.(jar|lib)");
	Reporter					reporter;
	boolean						dirty;
	String						name;
	boolean						inited;

	public FileRepo() {}

	public FileRepo(String name, File location, boolean canWrite) {
		this.name = name;
		this.root = location;
		this.canWrite = canWrite;
	}

	protected void init() throws Exception {
		if (inited)
			return;

		inited = true;
		if (!getRoot().isDirectory()) {
			getRoot().mkdirs();
		}
		exec(init, null);
	}

	public void setProperties(Map<String,String> map) {
		String location = map.get(LOCATION);
		if (location == null)
			throw new IllegalArgumentException("Location must be set on a FileRepo plugin");

		root = new File(location);

		String readonly = map.get(READONLY);
		if (readonly != null && Boolean.valueOf(readonly).booleanValue())
			canWrite = false;

		name = map.get(NAME);
		before = map.get(CMD_BEFORE_PUT);
		refresh = map.get(CMD_REFRESH);
		after = map.get(CMD_AFTER_PUT);
		init = map.get(CMD_INIT);
		path = map.get(CMD_PATH);
		abort = map.get(CMD_ABORT_PUT);
		shell = map.get(CMD_SHELL);
	}

	/**
	 * Get a list of URLs to bundles that are constrained by the bsn and
	 * versionRange.
	 */
	private File[] get(String bsn, String versionRange) throws Exception {
		init();
<commit_msg>FileRepo: relative paths are relative to the user's home<commit_after>package aQute.lib.deployer;

import java.io.*;
import java.security.*;
import java.util.*;
import java.util.jar.*;
import java.util.regex.*;

import aQute.bnd.header.*;
import aQute.bnd.osgi.*;
import aQute.bnd.service.*;
import aQute.bnd.version.*;
import aQute.lib.io.*;
import aQute.libg.command.*;
import aQute.service.reporter.*;

public class FileRepo implements Plugin, RepositoryPlugin, Refreshable, RegistryPlugin {
	public final static String	LOCATION		= "location";
	public final static String	READONLY		= "readonly";
	public final static String	NAME			= "name";
	public static final String	CMD_PATH		= "cmd.path";
	public static final String	CMD_INIT		= "cmd.init";
	public static final String	CMD_AFTER_PUT	= "cmd.after.put";
	public static final String	CMD_REFRESH		= "cmd.refresh";
	public static final String	CMD_BEFORE_PUT	= "cmd.before.put";
	public static final String	CMD_ABORT_PUT	= "cmd.abort.put";
	public static final String	CMD_SHELL		= "cmd.shell";
	static final PutOptions		DEFAULTOPTIONS	= new PutOptions();

	String						before;
	String						refresh;
	String						after;
	String						path;
	String						init;
	String						abort;
	String						shell;

	File[]						EMPTY_FILES		= new File[0];
	protected File				root;
	Registry					registry;
	boolean						canWrite		= true;
	Pattern						REPO_FILE		= Pattern.compile("([-a-zA-z0-9_\\.]+)-([0-9\\.]+|latest)\\.(jar|lib)");
	Reporter					reporter;
	boolean						dirty;
	String						name;
	boolean						inited;

	public FileRepo() {}

	public FileRepo(String name, File location, boolean canWrite) {
		this.name = name;
		this.root = location;
		this.canWrite = canWrite;
	}

	protected void init() throws Exception {
		if (inited)
			return;

		inited = true;
		if (!getRoot().isDirectory()) {
			getRoot().mkdirs();
		}
		exec(init, null);
	}

	public void setProperties(Map<String,String> map) {
		String location = map.get(LOCATION);
		if (location == null)
			throw new IllegalArgumentException("Location must be set on a FileRepo plugin");

		root = IO.getFile(IO.home, location);

		String readonly = map.get(READONLY);
		if (readonly != null && Boolean.valueOf(readonly).booleanValue())
			canWrite = false;

		name = map.get(NAME);
		before = map.get(CMD_BEFORE_PUT);
		refresh = map.get(CMD_REFRESH);
		after = map.get(CMD_AFTER_PUT);
		init = map.get(CMD_INIT);
		path = map.get(CMD_PATH);
		abort = map.get(CMD_ABORT_PUT);
		shell = map.get(CMD_SHELL);
	}

	/**
	 * Get a list of URLs to bundles that are constrained by the bsn and
	 * versionRange.
	 */
	private File[] get(String bsn, String versionRange) throws Exception {
		init();

{'fraction_non_alphanumeric': 0.1235933983495874, 'fraction_numerical': 0.0018754688672168042, 'mean_word_length': 3.6495204882301655, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5391098', 'n_tokens_mistral': 2043, 'n_tokens_neox': 1824, 'n_words': 486}