Exemple #1
0
    def register_filetype(self, filetypes, file_key=None):
        print(f'\nNew Filetype discovered!  |  {self.filename}')
        if file_key is None:
            file_key = self.ask_file_key()
            filetypes['file_keys'][file_key] = []

        # Find the header(s)
        sheet_number = self.ask_sheet()
        if sheet_number is not None:
            sheet = self.excel_file.parse(self.excel_file.sheet_names[sheet_number])
        else:
            sheet = self.excel_file

        header_value = self.remove_unnamed_columns(sheet.columns.tolist())
        header_value = [self.strip_date(v) for v in header_value]
        self.print_header(header_value)

        if input("Does this header exist? ") == '1':
            header_id = input('  header_id: ')
        else:
            header_id = str(len(list(filetypes['headers'].keys())))

            instruct = instructions.Instructions()
            instruct.ask_instructions(header_id)
            filetypes['headers'][header_id] = instruct.jsonify()

        filetypes['file_keys'][file_key].append({'header_id': header_id, 'header_value': header_value})

        with open('filetypes.json', 'w') as f:
            json.dump(filetypes, f, indent=2)
        return file_key, filetypes
    def test_empty_init(self):
        """Test default Instructions creation"""

        # 1. Create default Jumps object
        myinsts = instructions.Instructions()

        # 2. Make sure it has the default values
        self.assertEqual(myinsts.part2, False)
        self.assertEqual(myinsts.insts, [])
    def test_value_init(self):
        """Test Instructions creation with values"""

        # 1. Create Instructions object with values
        myinsts = instructions.Instructions(text=[
            "b inc 5 if a > 1", "a inc 1 if b < 5", "c dec -10 if a >= 1",
            "c inc -20 if c == 10"
        ])

        # 2. Make sure it has the specified values
        self.assertEqual(myinsts.part2, False)
        self.assertEqual(len(myinsts.insts), 4)
    def test_text_init(self):
        """Test Instructs creation from text"""

        # 1. Create Jumps object from text
        myinsts = instructions.Instructions(
            text=aoc_08.from_text(P1_EXAMPLES_TEXT))

        # 2. Make sure it has the specified values
        self.assertEqual(myinsts.part2, False)
        self.assertEqual(len(myinsts.insts), 4)

        # 3. Check methods
        self.assertEqual(myinsts.largest(verbose=False), 1)
def part_two(args, input_lines):
    "Process part two of the puzzle"

    # 1. Create the puzzle solver
    solver = instructions.Instructions(part2=True,
                                       text=input_lines)

    # 2. Determine name of the bottom probram
    solution = solver.highest(verbose=args.verbose, limit=args.limit)
    if solution is None:
        print("There is no highest value")
    else:
        print("The highest value held in any register was %d" % (solution))

    # 3. Return result
    return solution is not None
    def test_part_two(self):
        """Test Discs creation from text"""

        # 1. Create Jumps object from text
        myinsts = instructions.Instructions(
            text=aoc_08.from_text(P1_EXAMPLES_TEXT), part2=True)

        # 2. Make sure it has the specified values
        self.assertEqual(myinsts.part2, True)
        self.assertEqual(len(myinsts.insts), 4)

        # 3. Check methods
        self.assertEqual(myinsts.largest(verbose=False), 1)

        # 4. Check part two methods
        self.assertEqual(myinsts.highest(verbose=False), 10)
Exemple #7
0
idFrame = ttk.Frame(root, borderwidth=5, relief="sunken")
tickFrame = ttk.Frame(root, borderwidth=5, relief="sunken")
logoFrame = ttk.Frame(root, borderwidth=5, relief="sunken")

#place frames
infoFrame.grid(column=0, row=0, columnspan=6, rowspan=5, sticky=(N, W, E, S))
songFrame.grid(column=0, row=5, columnspan=6, rowspan=5, sticky=(N, W, E, S))
psaFrame.grid(column=6, row=5, columnspan=6, rowspan=5, sticky=(N, W, E, S))
idFrame.grid(column=6, row=0, columnspan=6, rowspan=5, sticky=(N, W, E, S))
tickFrame.grid(column=0, row=10, columnspan=18, rowspan=5, sticky=(N, W, E, S))
logoFrame.grid(column=12, row=0, columnspan=6, rowspan=10, sticky=(N, W, E, S))

#CREATE NEW INSTANCE OF SHOWS AND PSAS
showList = shows.Shows()
psas = psa.PSA()
instructions = instructions.Instructions()

#Create the variables
showName = StringVar()
showName.set(showList.list[0])

psaName = StringVar()
psaName.set(psas.list[0])

songName = StringVar()
songArtist = StringVar()
songComposer = StringVar()

#Create text boxes
songName_entry = ttk.Entry(songFrame, width=7, textvariable=songName)
songArtist_entry = ttk.Entry(songFrame, width=7, textvariable=songArtist)
Exemple #8
0
import argparse
import sys
import re

import cpu
import memory
import instructions

c = cpu.CPU()  #### Initializing CPU instance.
m = memory.Mem()  #### Initializing Mem instance.
i = instructions.Instructions(
    c, m
)  #### Initializing Instructions instance and passing CPU and Mem instance.

parser = argparse.ArgumentParser(
    description='Runtime for hiperbolt\'s 6502ad Emulator.')

parser.add_argument('-f', help='File mode - Interpret a binary 6502ad file.')
parser.add_argument('-b', help='Binary mode - For Raspberry Pi only.')

args = parser.parse_args()


def exitShell():
    print("Exiting.\n")
    exit()


def peekMem(address):
    print("Byte at address " + str(address) + ": " + str(m.get(address)))
    def __init__(self):

        self.running = True
        self.sub_running = False

        self.button_choosen_id = 0
        self.button_choosen = {
            0: 'images/titlescreen_play.png',
            1: 'images/titlescreen_instructions.png',
            2: 'images/titlescreen_highscores.png',
            3: 'images/titlescreen_exit.png'
        }

        self.backToMenu = py.image.load('images/do_menu.png').convert()
        self.again = py.image.load('images/again.png').convert()

        imagePath = self.button_choosen[self.button_choosen_id]
        img = py.image.load(imagePath).convert()
        config.screen.blit(img, (0, 0))
        py.display.flip()

        while self.running:
            py.init()
            config.screen  # = py.display.set_mode((1024, 768))
            py.display.set_caption("Bomberman")

            icon = py.image.load('images/icon.png')
            py.display.set_icon(icon)

            vol = py.mixer.music.get_volume()
            text = config.font.render(str(round(vol, 1)), True, (255, 245, 1),
                                      (81, 81, 81))
            textRect = text.get_rect()
            textRect.center = (950, 726)
            config.screen.blit(text, textRect)
            py.display.update()

            config.fps

            for event in py.event.get():
                if event.type == py.QUIT:
                    self.running = False
                    py.quit()
                elif event.type == py.KEYDOWN:
                    if event.key == py.K_DOWN and not self.sub_running:
                        self.button_choosen_id += 1
                        if self.button_choosen_id == 4:
                            self.button_choosen_id -= 4
                        imagePath = self.button_choosen[self.button_choosen_id]
                        img = py.image.load(imagePath).convert()
                        config.screen.blit(img, (0, 0))
                        py.display.flip()

                    if event.key == py.K_UP and not self.sub_running:
                        self.button_choosen_id -= 1
                        if self.button_choosen_id < 0:
                            self.button_choosen_id += 4
                        imagePath = self.button_choosen[self.button_choosen_id]
                        img = py.image.load(imagePath).convert()
                        config.screen.blit(img, (0, 0))
                        py.display.flip()

                    if event.key == py.K_RIGHT:
                        if vol < 1:
                            vol += 0.1
                            py.mixer.music.set_volume(round(vol, 1))
                            config.volume += 0.1
                        else:
                            pass

                    if event.key == py.K_LEFT:
                        if vol > 0:
                            vol -= 0.1
                            config.volume -= 0.1
                            py.mixer.music.set_volume(round(vol, 1))
                        else:
                            pass

                    if event.key == py.K_RETURN:
                        if self.button_choosen_id == 3:
                            self.running = False
                            py.quit()

                        if self.button_choosen_id == 2:
                            self.sub_running = True
                            h = highscore.Highscore()
                            h.displayScore()
                            self.running = False

                        if self.button_choosen_id == 1:
                            self.sub_running = True
                            instructions.Instructions()
                            self.running = False

                        if self.button_choosen_id == 0:
                            self.sub_running = True
                            play.Play(1)
                            self.running = False
Exemple #10
0
 def __init__(self, processorId, chipId, L1):
     self.processorId = processorId
     self.chipId = chipId
     self.instructions = instructions.Instructions(processorId, chipId)
     self.L1 = L1
Exemple #11
0
 def select_instructions(self, header_data, filetypes):
     i = instructions.Instructions()
     i.load_from_json(filetypes['headers'][str(header_data['header_id'])])
     return i