Ejemplo n.º 1
0
def parse(structSignature: str, bindingGrammar: Grammar) -> list:
    contents = fileHandler.readFile(filename)
    struct = fileHandler.findStructSignature(structSignature, contents)
    parsed = bindingGrammar.parse(struct)
    if parsed.is_valid:
        parsed_list = TreeParser(parsed)
        return parsed_list.getBindings()
    print(parsed.as_str())
    return []
def checkForTableID(moduleID):
	#string = "@PersistenceCapable(detachable = \"true\", table = \"foo_account\")"
	flag = True
	
	task_dict = {}

	table_dict = {}
	for f in fileHandler.getAllFilesMatching('*.java'):
		contents = fileHandler.readFile(f)

# Initial work on checking task/config names
#		try:
#			method = javaHandler.readMethod(contents, "public String getDisplayLabel()")
#			print method
#		except:
#			False
		try:
			method = javaHandler.readMethod(contents, "public TaskConfigIf getTaskConfigImplementation")
			if (method[0].split()[2] in task_dict.keys()):
				log.critical("Task config re-used: " + method[0].split()[2] + " in files: " + f + " & " + task_dict[method[0].split()[2]])
				flag = False
			else:
				task_dict[method[0].split()[2]] = f
		except:
			False
		for line in contents:
			if(("@PersistenceCapable" in line) and ("table" in line)):

				inBrackets = gstring.getTargetBetweenBrackets(line)
				attributes = inBrackets.split(",")
				tableAttribute = [s for s in attributes if "table" in s]
				a = re.findall('"([^"]*)"', tableAttribute[0])[0]
				if (a in table_dict.keys()):
					log.critical("\tTable already used: " + a + " (files: " + table_dict.get(str(a)) + " & " + f)
					flag = False
				else:
					table_dict[str(a)] = f

				if(not a.startswith((moduleID + "_"))):
					log.critical("\tThe table ID in class " + f + " is not prefixed the moduleID and an underscore: " + moduleID + "_")
	
	if (flag == False):
		log.critical("Table checking failed")
		exit(1)










	'''
def getClassesListedForEnhancement():
	files = fileHandler.getAllFilesMatching("jdo.files")
	#Go through and get all of the files that are LISTED for enhancement
	newList = []
	for f in files:
		if("src" in f):
			newList.append(f)

	files = newList

	listOfClasses = []
	for f in files:
		fileContents = fileHandler.readFile(f)
		classes = getJDOClassesInFile(fileContents)
		for c in classes:
			listOfClasses.append(c)




	return listOfClasses
Ejemplo n.º 4
0
        reminderList['items'] = []
        writeFile("reminderlist.txt", reminderList)


def reminderQuit():
    """
    This function has to be called when shutting down. It terminates all waiting threads.
    """
    try:
        for index, el in timerList.iteritems():
            el.cancel()
    except:
        for index, el in timerList.items():
            el.cancel()


timerList = {}
reminderList = readFile("reminderlist.txt", {'items': []})
reminderList['items'] = sort(reminderList['items'])
reminderList['items'] = [i for i in reminderList['items'] if not i['hidden']]
for e in reminderList['items']:
    e['time'] = str2date(e['time'])
    waitTime = e['time'] - dt.now()
    n = Notify.Notification.new(e['name'])
    n.set_urgency(Notify.Urgency.LOW)
    timerList[e['uuid']] = Timer(waitTime.total_seconds(), showAlarm,
                                 [n, e['name']])
    timerList[e['uuid']].start()

Notify.init("Jarvis")
Ejemplo n.º 5
0
from fileHandler import readFile, separator
from Regressao_Logistica import constroi_modelo
import numpy as np
import matplotlib.pyplot as plt

matrix = readFile('tic-tac-toe.data')

X_treino, Y_treino, X_teste, Y_teste = separator(0.3, matrix)

X_treino = np.array(X_treino).T.astype(np.float)
Y_treino = np.array([Y_treino]).astype(np.float)
X_teste = np.array(X_teste).T.astype(np.float)
Y_teste = np.array([Y_teste]).astype(np.float)

print(X_treino.shape)
print(Y_treino.shape)
print(X_teste.shape)
print(Y_teste.shape)


def raioGraficalizador(dados, intervalo, numeroIteracoes, taxaAprendizado):
    fig, ax = plt.subplots()
    x = [None] * dados.__len__()

    for i in range(dados.__len__()):
        x[i] = i * intervalo

    ax.plot(x, dados)
    plt.scatter(x, dados)  # scatter são os quadradinhos na linha

    titulo = 'Taxa de aprendizado: {0} | Número de iterações: {1}'
def hasAnnotations(filePath):
	sub = "import javax.jdo.annotations"
	contents = fileHandler.readFile(filePath)
	return len([s for s in contents if sub in s]) != 0
Ejemplo n.º 7
0
    # Select the best trigger match from the actions list
    for key in actions:
        foundMatch = False
        for trigger in actions[key]['trigger']:
            newScore, indexList = scoreSentence(data, trigger, distancePenalty = 0.5, additionalTargetPenalty = 0, wordMatchPenalty = 0.5)
            if foundMatch and len(indexList) > len(indices):
                # A match for this action was already found.
                # But this trigger matches more words.
                indices = indexList
            if newScore < score:
                if not foundMatch:
                    indices = indexList
                    minArgs = actions[key]['minArgs']
                    foundMatch = True
                score = newScore
                action = key
    if not action:
        return
    data = data.split();
    for i in sorted(indices, reverse=True):
        del data[i]
    if len(data) < minArgs:
        warning("Not enough arguments for specified command {0}".format(action))
        return
    data = " ".join(data)
    globals()[action](data)

todoList = readFile("todolist.txt", {'items':[]})
todoList['items'] = fixTypes(sort(todoList['items']))