コード例 #1
0
ファイル: Main.py プロジェクト: henrikmnm/projectGVD
    def run(self):
        glutInit()
        glutInitDisplayMode(GLUT_RGBA , GLUT_ALPHA , GLUT_DOUBLE , GLUT_DEPTH )

        glutInitWindowSize(800, 600) #Set the window size
        self.window_width = 800
        self.window_height = 600

        self.board = Board.Board(4, 4, -4, -4)

        self.filer = fileHandler.fileHandler("centers3.txt", 4, 4)
        self.filer.readPieces()

        pieces = self.filer.getPecies()


        for p in pieces:
            self.board.addPiece(p)

        self.initialBoard = copy.deepcopy(self.board.getPieces())

        self.currentPiece = self.board.getPieces()[0]

        #Create the window
        glutCreateWindow("Project 2015")

        #Set handler functions for drawing, keypresses, and window resizes

        glutDisplayFunc(self.drawScene)
        glutKeyboardFunc(self.handleKeypress)
        glutReshapeFunc(self.handleResize)
        glutSpecialFunc(self.specialPressed)
        glutIdleFunc(self.Idle)

        glutMainLoop() #Start the main loop
コード例 #2
0
 def __init__(self, filename):
     if filename.find(".asm") == -1:
         print("File type error, .asm file expected.")
         return
     self.filename = filename
     self.filehandler = fileHandler.fileHandler(filename)
     self.asmList = asmList.asmList(self.filehandler.fileContent)
     self.asmList.convert()
     self.filehandler.refreshContent(self.asmList.binCode)
コード例 #3
0
ファイル: Main.py プロジェクト: henrikmnm/projectGVD
    def addPieces(self):
        fHandler = fileHandler.fileHandler("centers.txt")

        fHandler.readPieces()

        pieces = fHandler.getPecies()

        for piece in pieces:
            self.board.addPiece(piece)
コード例 #4
0
def make_database(folder, template):  #, tmp):

    database = template
    unknown_birds = {}
    #wrong_group_log = open("wrong_group_log.txt", 'wb')

    #counters for file inclusion reports
    f_included = 0  # counts files included
    f_w_errors = 0  # counts files with some error
    f_unreadable = 0  # counts files that were unreadable inside fileHandler
    f_total = 0  # counts all files processed
    f_o_exception = 0  # counts files with some other exception
    f_u_exception = 0  # counts files that really should have been included.
    # ^ This is a final catch-all for files that are to be excluded

    # an empty list for checking/comparing table values for accuracy
    check = []

    for filename in os.listdir(folder):

        #This counts the total number of files processed.
        f_total = f_total + 1

        #this is defaulted to false until file is verified/evaluated
        storing = False
        file = folder + "\%s" % (filename)

        try:

            handler = fileHandler.fileHandler()
            handler.loadFile(file)
            print("successfully loaded " + filename + ".")

            #debug marker
            dcounter = 1

            #This section prevents tables containing an error from being stored in the database.
            if (handler.session["contains_error"]):
                print("file %s contains at least one error code," % (filename))
                print("%s not included in database" % (filename))

                #counter block
                phz = filename[4]
                grp = filename[3]

                dcounter = 2

                ephase[phz] = ephase[phz] + 1
                egroup[grp] = egroup[grp] + 1

                dcounter = 3

                f_w_errors = f_w_errors + 1
                #/end counter block

                dcounter = 4

            else:
                storing = True

        except:
            print("error loading or reading file %s." % (filename))

            #reports which section of try block failed
            print dcounter

            #counts the number of unreadable files, most likely they are corrupted
            f_unreadable = f_unreadable + 1

        if (storing):

            #  naming convention:
            #  123|A|A|12|.|123  --> Format
            #  012|3|4|56|7|8910 --> String Indices
            #  exp|g|p|sn|.|brd  --> Key -- experiment | group | phase | session | . | bird

            name = handler.name
            phase = name[4]
            group = name[3]
            bird = name[-3:]
            session = int(name[5:7])
            print name

            #Phase C is an extension of phase B
            #adjust session numbers to continue from 99.
            if phase == 'C':
                phase = 'B'
                session = session + 99
                #TODO update the session's name as well, so handler.name  == ("%d" % (session))

            try:
                #event-table database with line numbers for keys
                database[phase][group][bird][session] = handler.session

                print("successfully loaded and read file '%s.'" % filename)

                #Counts the number of files stored in the database
                f_included = f_included + 1

            except:

                #Counts the files that cause an (key?) error upon adding them to the database
                f_o_exception = f_o_exception + 1

                print("could not store %s in database" % (name))
                print(" Phase: %s\n Group: %s\n Bird: %s\n Session: %s" %
                      (phase, group, bird, session))
                if phase not in database:
                    print("need handling for phase %s..." % phase)
                    os.system("pause")

                elif (bird not in (database[phase][group])):
                    if bird not in birdlist:
                        if bird not in unknown_birds:
                            unknown_birds[bird] = [bird]
                        unknown_birds[bird].append(filename)

                    else:
                        #wrong_group_log.write('\n Bird %s in Group %s.\n\n' % (bird, group))
                        print(
                            "bird '%s' not found in group '%s' (according to database)."
                            % (name[-3:], name[4]))
                        os.system("pause")
                else:
                    print("not sure why this file isn't included...")
                    f_u_exception = f_u_exception + 1

            #TODO need to figure out how to move and copy files to new folders

        handler = fileHandler.fileHandler()

    #summary
    print("\n\n")
    print("processed all files in " + folder + ".")
    print("Total in folder: %d" % (f_total))
    print("Included  files: %d" % (f_included))
    print("Files corrupted: %d (?)" % (f_unreadable))
    print("Files w/ errors: %d" % (f_w_errors))
    print("Other files n/i: %d" % (f_o_exception))

    print("Unknown file ex: %d" % (f_u_exception))
    percent_included = float(f_included) / float(f_total) * 100
    percent_included = ('%.2f' % percent_included)
    print("Percent success: %s" % (percent_included))
    print("\n\n")
    '''
	# this prints all the unknown birds
	for b in unknown_birds:
		for item in unknown_birds[b]:
			print item
	'''

    return database
コード例 #5
0
import fileHandler
import time
#import analysis

#import file management libraries/tools
import json
import os
import shutil

#pickling experiment
import pickle

handler = fileHandler.fileHandler()

#error counters
error_PA = 0
error_PB = 0
error_PC = 0

error_GA = 0
error_GB = 0
error_GC = 0
error_GD = 0

ephase = {}
ephase['A'] = error_PA
ephase['B'] = error_PB
ephase['C'] = error_PC

egroup = {}
egroup['A'] = error_GA
コード例 #6
0
ファイル: main.py プロジェクト: Jamppa93/budjetointityokaly
 def __init__(self):
     self.checkNfile = []
     self.tempfileName = ''
     self.fileLocDirectories = ['newFiles', 'usedFiles', 'dbFile']
     self.etlManagerInst = etlManager()
     self.fileHandlerInst = fileHandler()
コード例 #7
0
ファイル: supportbank.py プロジェクト: AConroyUK/SupportBank
import sys
import re
import logging
import transactionHandler
import fileHandler

files = ['Transactions2014.csv','DodgyTransactions2015.csv','Transactions2012.xml','Transactions2013.json']
tHandler = transactionHandler.transactionHandler()
fHandler = fileHandler.fileHandler(tHandler)

DEBUG_LEVEL, EXPORT_FILENAME, EXPORT_FORMAT = fHandler.loadconfig()

logging.basicConfig(filename='SupportBank.log',filemode='w',
level=eval(DEBUG_LEVEL))



def main(argv):
    for file in files:
        fHandler.importfile(file)
    response = ""
    print()
    while response != "Quit":
        print("Enter a command(List All/List[accountname]/Import filename/Export[accountname]/Quit):")
        response = input()
        if response == "List All":
            logging.info("user command: " + str(response))
            tHandler.listAll()
        elif re.fullmatch("List\[[A-Z][a-z]+ ?[A-Z]?\]",response) != None:
            logging.info("user command: " + str(response))
            account = response.split("[")[len(response.split("["))-1]