<commit_before>import sys
#sys.path.append("/usr/lib/python2.6/")
#sys.path.append("/usr/lib/python2.6/lib-dynload")

import sublime, sublime_plugin
import subprocess, time
import tempfile
import os, signal
#import xml.parsers.expat
import re
import codecs
import glob
import hashlib
import shutil
import functools

from xml.etree import ElementTree
from xml.etree.ElementTree import XMLTreeBuilder
#from xml.etree import ElementTree
from elementtree import SimpleXMLTreeBuilder # part of your codebase
ElementTree.XMLTreeBuilder = SimpleXMLTreeBuilder.TreeBuilder

from subprocess import Popen, PIPE
from datetime import datetime

stexec = __import__("exec")

try:
  STARTUP_INFO = subprocess.STARTUPINFO()
  STARTUP_INFO.dwFlags |= subprocess.STARTF_USESHOWWINDOW
  STARTUP_INFO.wShowWindow = subprocess.SW_HIDE
except (AttributeError):
	STARTUP_INFO = None

def runcmd( args, input=None ):
	#print(args)
	try:
		p = Popen([a.encode(sys.getfilesystemencoding()) for a in args], stdout=PIPE, stderr=PIPE, stdin=PIPE, startupinfo=STARTUP_INFO)
		if isinstance(input, unicode):
			input = input.encode('utf-8')
		out, err = p.communicate(input=input)
		return (out.decode('utf-8') if out else '', err.decode('utf-8') if err else '')
	except (OSError, ValueError) as e:
		err = u'Error while running %s: %s' % (args[0], e)
		return ("", err.decode('utf-8'))

compilerOutput = re.compile("^([^:]+):([0-9]+): (characters?|lines?) ([0-9]+)-?([0-9]+)? : (.*)", re.M)
compactFunc = re.compile("\(.*\)")
compactProp = re.compile(":.*\.([a-z_0-9]+)", re.I)
spaceChars = re.compile("\s")
wordChars = re.compile("[a-z0-9._]", re.I)
importLine = re.compile("^([ \t]*)import\s+([a-z0-9._]+);", re.I | re.M)
packageLine = re.compile("package\s*([a-z0-9.]*);", re.I)
libLine = re.compile("([^:]*):[^\[]*\[(dev\:)?(.*)\]")
classpathLine = re.compile("Classpath : (.*)")
typeDecl = re.compile("(class|typedef|enum|typedef)\s+([A-Z][a-zA-Z0-9_]*)\s*(<[a-zA-Z0-9_,]+>)?" , re.M )
libFlag = re.compile("-lib\s+(.*?)")
skippable = re.compile("^[a-zA-Z0-9_\s]*$")
inAnonymous = re.compile("[{,]\s*([a-zA-Z0-9_\"\']+)\s*:\s*$" , re.M | re.U )
extractTag = re.compile("<([a-z0-9_-]+).*\s(name|main|path)=\"([a-z0-9_./-]+)\"", re.I)
variables = re.compile("var\s+([^:;\s]*)", re.I)
functions = re.compile("function\s+([^;\.\(\)\s]*)", re.I)
functionParams = re.compile("function\s+[a-zA-Z0-9_]+\s*\(([^\)]*)", re.M)
paramDefault = re.compile("(=\s*\"*[^\"]*\")", re.M)
isType = re.compile("^[A-Z][a-zA-Z0-9_]*$")
comments = re.compile("(//[^\n\r]*?[\n\r]|/\*(.*?)\*/)", re.MULTILINE | re.DOTALL )

haxeVersion = re.compile("(Haxe|haXe) Compiler ([0-9]\.[0-9])",re.M)
bundleFile = __file__
bundlePath = os.path.abspath(bundleFile)
bundleDir = os.path.dirname(bundlePath)
#haxeFileRegex = "^([^:]*):([0-9]+): characters? ([0-9]+)-?[0-9]* :(.*)$"
haxeFileRegex = "^([^:]*\.hx):([0-9]+):.*$"
controlStruct = re.compile( "\s*(if|switch|for|while)\($" );

class HaxeLib :

	available = {}
	basePath = None

	def __init__( self , name , dev , version ):
 		self.name = name
 		self.dev = dev
 		self.version = version
		self.classes = None
		self.packages = None

 		if self.dev :
 			self.path = self.version
 			self.version = "dev"
 		else :
 			self.path = os.path.join( HaxeLib.basePath , self.name , ",".join(self.version.split(".")) )

 		#print(self.name + " => " + self.path)

	def extract_types( self ):

		if self.dev is True or ( self.classes is None and self.packages is None ):
			self.classes, self.packages = HaxeComplete.inst.extract_types( self.path )

		return self.classes, self.packages

	@staticmethod
	def get( name ) :
		if( name in HaxeLib.available.keys()):
			return HaxeLib.available[name]
		else :
			sublime.status_message( "Haxelib : "+ name +" project not installed" )
			return None

	@staticmethod
	def get_completions() :
		comps = []
		for l in HaxeLib.available :
			lib = HaxeLib.available[l]
			comps.append( ( lib.name + " [" + lib.version + "]" , lib.name ) )

		return comps

	@staticmethod
	def scan() :
		hlout, hlerr = runcmd( ["haxelib" , "config" ] )
		HaxeLib.basePath = hlout.strip()

		HaxeLib.available = {}

		hlout, hlerr = runcmd( ["haxelib" , "list" ] )

		for l in hlout.split("\n") :
			found = libLine.match( l )
			if found is not None :
				name, dev, version = found.groups()
				lib = HaxeLib( name , dev is not None , version )

				HaxeLib.available[ name ] = lib



HaxeLib.scan()

inst = None
class HaxeBuild :

	#auto = None
	targets = ["js","cpp","swf","neko","php","java","cs"]
	nme_targets = [("Flash","flash -debug","test"),("HTML5","html5 -debug","test"),("C++","cpp -debug","test"),("Linux","linux -debug","test"), ("Linux 64","linux -64 -debug","test"),("iOS - iPhone Simulator","ios -simulator -debug","test"),("iOS - iPad Simulator","ios -simulator -ipad -debug","test"),("iOS - Update XCode Project","ios -debug","update"),( "Android","android -debug","test"),("WebOS", "webos -debug","test"),("Neko","neko -debug","test"),("Neko 64","neko -64 -debug","test"),("BlackBerry","blackberry -debug","test"), ("Flash Debug","flash -debug","test"),("HTML5 Debug","html5 -debug","test"),("C++ Debug","cpp -debug","test"),("Linux 64 Debug","linux -64 -debug","test "),("Linux  Debug","linux -debug","test "),("iOS - iPhone Simulator Debug","ios -simulator -debug","test"),("iOS - iPad Simulator Debug","ios -simulator -ipad -debug","test"),("iOS - Update XCode Project Debug","ios -debug","update"),( "Android Debug","android -debug","test"),("WebOS Debug", "webos -debug","test"),("Neko Debug","neko -64","test"),("Neko 64 Debug","neko -64 -debug","test"),("BlackBerry Debug","blackberry -debug","test")]
	nme_target = ("Flash","flash","test")

	def __init__(self) :

		self.args = []
		self.main = None
		self.target = None
		self.output = "dummy.js"
		self.hxml = None
		self.nmml = None
		self.classpaths = []
		self.libs = []
		self.classes = None
		self.packages = None

	def to_string(self) :
		out = os.path.basename(self.output)<commit_msg>added "build only" targets to NME builds<commit_after>import sys
#sys.path.append("/usr/lib/python2.6/")
#sys.path.append("/usr/lib/python2.6/lib-dynload")

import sublime, sublime_plugin
import subprocess, time
import tempfile
import os, signal
#import xml.parsers.expat
import re
import codecs
import glob
import hashlib
import shutil
import functools

from xml.etree import ElementTree
from xml.etree.ElementTree import XMLTreeBuilder
#from xml.etree import ElementTree
from elementtree import SimpleXMLTreeBuilder # part of your codebase
ElementTree.XMLTreeBuilder = SimpleXMLTreeBuilder.TreeBuilder

from subprocess import Popen, PIPE
from datetime import datetime

stexec = __import__("exec")

try:
  STARTUP_INFO = subprocess.STARTUPINFO()
  STARTUP_INFO.dwFlags |= subprocess.STARTF_USESHOWWINDOW
  STARTUP_INFO.wShowWindow = subprocess.SW_HIDE
except (AttributeError):
	STARTUP_INFO = None

def runcmd( args, input=None ):
	#print(args)
	try:
		p = Popen([a.encode(sys.getfilesystemencoding()) for a in args], stdout=PIPE, stderr=PIPE, stdin=PIPE, startupinfo=STARTUP_INFO)
		if isinstance(input, unicode):
			input = input.encode('utf-8')
		out, err = p.communicate(input=input)
		return (out.decode('utf-8') if out else '', err.decode('utf-8') if err else '')
	except (OSError, ValueError) as e:
		err = u'Error while running %s: %s' % (args[0], e)
		return ("", err.decode('utf-8'))

compilerOutput = re.compile("^([^:]+):([0-9]+): (characters?|lines?) ([0-9]+)-?([0-9]+)? : (.*)", re.M)
compactFunc = re.compile("\(.*\)")
compactProp = re.compile(":.*\.([a-z_0-9]+)", re.I)
spaceChars = re.compile("\s")
wordChars = re.compile("[a-z0-9._]", re.I)
importLine = re.compile("^([ \t]*)import\s+([a-z0-9._]+);", re.I | re.M)
packageLine = re.compile("package\s*([a-z0-9.]*);", re.I)
libLine = re.compile("([^:]*):[^\[]*\[(dev\:)?(.*)\]")
classpathLine = re.compile("Classpath : (.*)")
typeDecl = re.compile("(class|typedef|enum|typedef)\s+([A-Z][a-zA-Z0-9_]*)\s*(<[a-zA-Z0-9_,]+>)?" , re.M )
libFlag = re.compile("-lib\s+(.*?)")
skippable = re.compile("^[a-zA-Z0-9_\s]*$")
inAnonymous = re.compile("[{,]\s*([a-zA-Z0-9_\"\']+)\s*:\s*$" , re.M | re.U )
extractTag = re.compile("<([a-z0-9_-]+).*\s(name|main|path)=\"([a-z0-9_./-]+)\"", re.I)
variables = re.compile("var\s+([^:;\s]*)", re.I)
functions = re.compile("function\s+([^;\.\(\)\s]*)", re.I)
functionParams = re.compile("function\s+[a-zA-Z0-9_]+\s*\(([^\)]*)", re.M)
paramDefault = re.compile("(=\s*\"*[^\"]*\")", re.M)
isType = re.compile("^[A-Z][a-zA-Z0-9_]*$")
comments = re.compile("(//[^\n\r]*?[\n\r]|/\*(.*?)\*/)", re.MULTILINE | re.DOTALL )

haxeVersion = re.compile("(Haxe|haXe) Compiler ([0-9]\.[0-9])",re.M)
bundleFile = __file__
bundlePath = os.path.abspath(bundleFile)
bundleDir = os.path.dirname(bundlePath)
#haxeFileRegex = "^([^:]*):([0-9]+): characters? ([0-9]+)-?[0-9]* :(.*)$"
haxeFileRegex = "^([^:]*\.hx):([0-9]+):.*$"
controlStruct = re.compile( "\s*(if|switch|for|while)\($" );

class HaxeLib :

	available = {}
	basePath = None

	def __init__( self , name , dev , version ):
 		self.name = name
 		self.dev = dev
 		self.version = version
		self.classes = None
		self.packages = None

 		if self.dev :
 			self.path = self.version
 			self.version = "dev"
 		else :
 			self.path = os.path.join( HaxeLib.basePath , self.name , ",".join(self.version.split(".")) )

 		#print(self.name + " => " + self.path)

	def extract_types( self ):

		if self.dev is True or ( self.classes is None and self.packages is None ):
			self.classes, self.packages = HaxeComplete.inst.extract_types( self.path )

		return self.classes, self.packages

	@staticmethod
	def get( name ) :
		if( name in HaxeLib.available.keys()):
			return HaxeLib.available[name]
		else :
			sublime.status_message( "Haxelib : "+ name +" project not installed" )
			return None

	@staticmethod
	def get_completions() :
		comps = []
		for l in HaxeLib.available :
			lib = HaxeLib.available[l]
			comps.append( ( lib.name + " [" + lib.version + "]" , lib.name ) )

		return comps

	@staticmethod
	def scan() :
		hlout, hlerr = runcmd( ["haxelib" , "config" ] )
		HaxeLib.basePath = hlout.strip()

		HaxeLib.available = {}

		hlout, hlerr = runcmd( ["haxelib" , "list" ] )

		for l in hlout.split("\n") :
			found = libLine.match( l )
			if found is not None :
				name, dev, version = found.groups()
				lib = HaxeLib( name , dev is not None , version )

				HaxeLib.available[ name ] = lib



HaxeLib.scan()

inst = None
class HaxeBuild :

	#auto = None
	targets = ["js","cpp","swf","neko","php","java","cs"]
	nme_targets = [
		("Flash - test","flash -debug","test"),
		("Flash - build only","flash -debug","build"),
		("HTML5 - test","html5 -debug","test"),
		("HTML5 - build only","html5 -debug","build"),
		("C++ - test","cpp -debug","test"),
		("C++ - build only","cpp -debug","build"),
		("Linux - test","linux -debug","test"), 
		("Linux - build only","linux -debug","build"), 
		("Linux 64 - test","linux -64 -debug","test"),
		("Linux 64 - build only","linux -64 -debug","build"),
		("iOS - test in iPhone simulator","ios -simulator -debug","test"),
		("iOS - test in iPad simulator","ios -simulator -ipad -debug","test"),
		("iOS - update XCode project","ios -debug","update"),
		("Android - test","android -debug","test"),
		("Android - build only","android -debug","build"),
		("WebOS - test", "webos -debug","test"),
		("WebOS - build only", "webos -debug","build"),
		("Neko - test","neko -debug","test"),
		("Neko - build only","neko -debug","build"),
		("Neko 64 - test","neko -64 -debug","test"),
		("Neko 64 - build only","neko -64 -debug","build"),
		("BlackBerry - test","blackberry -debug","test"),
		("BlackBerry - build only","blackberry -debug","build")
	]
	nme_target = ("Flash - test","flash -debug","test")

	def __init__(self) :

		self.args = []
		self.main = None
		self.target = None
		self.output = "dummy.js"
		self.hxml = None
		self.nmml = None
		self.classpaths = []
		self.libs = []
		self.classes = None
		self.packages = None

	def to_string(self) :
		out = os.path.basename(self.output)
{'fraction_non_alphanumeric': 0.2259643301534633, 'fraction_numerical': 0.01194525093322273, 'mean_word_length': 4.2145328719723185, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '1624887', 'n_tokens_mistral': 4881, 'n_tokens_neox': 4528, 'n_words': 921}