<commit_before>import os
import subprocess
import errno
import re
import sys
import shutil
import urllib2
import glob
from distutils import dir_util
from distutils import file_util
import zipfile
import fnmatch
import inspect
import time

# evil globals
_ = None
bild_completed = set()  # which *targets* have been built.
BILD = os.path.expanduser("~/.bild")
JARCACHE = os.path.join(BILD, "jars")
# CLASSPATH = JARCACHE + "/*" + os.pathsep + os.environ['CLASSPATH']

def findjdks_win():
	return {}


def findjdks_linux():
	"""
	CentOS: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.55.x86_64/jre/bin/java
					/usr/java/jdk1.7.0_51
	ubuntu: /usr/lib/jvm/java-6-openjdk/ for OpenJDK
					/usr/lib/jvm/* for Oracle JDK
	"""
	versions = {}
	for jdk in glob.glob("/usr/lib/jvm/*") + glob.glob("/usr/java/*"):
		name = os.path.basename(jdk)
		if name.startswith("java-1.6") or name.startswith("jdk1.6"):
			versions["1.6"] = jdk
		if name.startswith("java-1.7") or name.startswith("jdk1.7"):
			versions["1.7"] = jdk
		if name.startswith("java-1.8") or name.startswith("jdk1.8"):
			versions["1.8"] = jdk
	return versions


def findjdks_mac():
	"""find Java installations on a mac"""
	versions = {}
	dirs = []
	for jdk in glob.glob("/Library/Java/JavaVirtualMachines/*"):
		dirs.append(jdk)
	for jdk in glob.glob("/System/Library/Java/JavaVirtualMachines/*"):
		dirs.append(jdk)
	for jdk in dirs:
		name = os.path.basename(jdk)
		if name.startswith("1.6."):
			versions["1.6"] = jdk + "/Contents/Home"
		elif name.startswith("jdk1.7."):
			versions["1.7"] = jdk + "/Contents/Home"
		elif name.startswith("jdk1.8."):
			versions["1.8"] = jdk + "/Contents/Home"
	return versions


def findjdks():
	if sys.platform == 'win32':
		return findjdks_win()
	if sys.platform == 'darwin':
		return findjdks_mac()
	if sys.platform == 'linux2':
		return findjdks_linux()


jdk = findjdks()
#print sys.platform + " java =", jdk


def modtime(fname):
	try:
		return os.path.getmtime(fname)
	except:
		return 0  # mod date of epoch means ancient  sys.float_info.max  # meaning mod date in future if file not there


def uniformpath(dir):<commit_msg>add code for finding python/java execs later<commit_after>import os
import subprocess
import errno
import re
import sys
import shutil
import urllib2
import glob
from distutils import dir_util
from distutils import file_util
import zipfile
import fnmatch
import inspect
import time

# evil globals
_ = None
bild_completed = set()  # which *targets* have been built.
BILD = os.path.expanduser("~/.bild")
JARCACHE = os.path.join(BILD, "jars")
# CLASSPATH = JARCACHE + "/*" + os.pathsep + os.environ['CLASSPATH']

def findjdks_win():
	return {}


def findjdks_linux():
	"""
	CentOS: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.55.x86_64/jre/bin/java
					/usr/java/jdk1.7.0_51
	ubuntu: /usr/lib/jvm/java-6-openjdk/ for OpenJDK
					/usr/lib/jvm/* for Oracle JDK
	"""
	versions = {}
	for jdk in glob.glob("/usr/lib/jvm/*") + glob.glob("/usr/java/*"):
		name = os.path.basename(jdk)
		if name.startswith("java-1.6") or name.startswith("jdk1.6"):
			versions["1.6"] = jdk
		if name.startswith("java-1.7") or name.startswith("jdk1.7"):
			versions["1.7"] = jdk
		if name.startswith("java-1.8") or name.startswith("jdk1.8"):
			versions["1.8"] = jdk
	return versions


def findjdks_mac():
	"""find Java installations on a mac"""
	versions = {}
	dirs = []
	for jdk in glob.glob("/Library/Java/JavaVirtualMachines/*"):
		dirs.append(jdk)
	for jdk in glob.glob("/System/Library/Java/JavaVirtualMachines/*"):
		dirs.append(jdk)
	for jdk in dirs:
		name = os.path.basename(jdk)
		if name.startswith("1.6."):
			versions["1.6"] = jdk + "/Contents/Home"
		elif name.startswith("jdk1.7."):
			versions["1.7"] = jdk + "/Contents/Home"
		elif name.startswith("jdk1.8."):
			versions["1.8"] = jdk + "/Contents/Home"
	return versions


def findjdks():
	if sys.platform == 'win32':
		return findjdks_win()
	if sys.platform == 'darwin':
		return findjdks_mac()
	if sys.platform == 'linux2':
		return findjdks_linux()


jdk = findjdks()
#print sys.platform + " java =", jdk

todo = """
def chkjava(version):
	"""
	Version in {1.6,1.7,1.8}
	"""
	javahome = 'JAVA' + version
	if os.environ.get(javahome):
		jdk[version] = os.environ[javahome]
		print "Setting java to "+jdk[version]+""
	else:
		jdk = findjdks()
		if version in jdk:
			print javahome+" not set, using "+jdk[version]
		else:
			p = subprocess.Popen(["java", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
			out,err = p.communicate()
			# java version "1.7.0_65"
			vline = err.split("\n")[0]
			vquote = vline.split(" ")[2]
			v = vquote.replace('"',"")
			print javahome+" not set, using system default: "+v
"""

def modtime(fname):
	try:
		return os.path.getmtime(fname)
	except:
		return 0  # mod date of epoch means ancient  sys.float_info.max  # meaning mod date in future if file not there


def uniformpath(dir):
{'fraction_non_alphanumeric': 0.16509819967266776, 'fraction_numerical': 0.02434533551554828, 'mean_word_length': 3.8358061325420376, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '5774016', 'n_tokens_mistral': 2042, 'n_tokens_neox': 1932, 'n_words': 436}