Example #1
0
def start():

    opener()

    while (True):
        spacer()
        if (switch(False) == "okay apollo"):
            print("")
            spacer()
            type = switch(True)
            spacer()

            if (type == "tuner"):
                noise_tuner(parse_tuner_frequency(tuner()))

            elif (type == "synthesizer"):
                sound(parse_input(synthesizer()))

            elif (type == "settings"):
                cont = parse_settings(do_settings())
                while (cont):
                    cont = parse_settings(do_settings())

            elif (type == "triad"):
                play_triad(triad())

            elif (type == "quit"):
                print("Exiting...")
                sleep(0.75)
                quit()
Example #2
0
 def edit_map(self):
     map_name = self.select_map.get()
     if map_name == None or len(map_name) == 0 or len(self.maps) == 0:
         eprint("error: no map selected")
         return
     map_file = open(self.maps[map_name])
     lmap, lc = lemin_map_parser(map_file)
     map_file.close()
     if lmap == None or lemin_map_checker(lmap):
         eprint("error: invalid map")
         return
     switch(M_EDITOR, lmap)
Example #3
0
def await_action():
    input = raw_input("> ").split()

    for case in switch(input[0]):
        if case('quit'):
            print "Bye!"
            return

        if case('go','move'):
            if len(input) > 1:
                move(input[1])
            else:
                print "Where to?"
            break

        if case('look'):
            if len(input) > 1:
                look(input[1])
            else:
                look()
            break

        # We have a custom action
        perform_action(input)
    
    await_action()
Example #4
0
File: ytpy.py Project: mac389/ytpy
def save(video,format='txt'):
	for case in switch(format):
		if case('xls'):
			import xlwt
			if len(video['comments']) > 0:
				wbk = xlwt.Workbook()
				sheet = wbk.add_sheet(tech.validate(video['title']))
				bigs = wbk.add_sheet('Bigrams')
				tris = wbk.add_sheet('Trigrams')
				context = wbk.add_sheet('Context')
				for_nlp = tech.flatten(video['comments'][0])
				for idx,comment in enumerate(video['comments'][0]):
					sheet.write(idx,0,' '.join(comment))
				for idx,bigram in enumerate(tech.bigrams(for_nlp,self.term)):
					bigs.write(idx,0,' '.join(bigram))
				for idx,trigram in enumerate(tech.trigrams(for_nlp,self.term)):
					tris.write(idx,0,' '.join(trigram))
				for idx,con in enumerate(tech.context(for_nlp,self.term)):
					context.write(idx,0,' '.join(con))
				wbk.save(tech.validate(video['title'])+'.xls')
			print 'Videos, trigrams, bigrams, and contexts saved to XLS files.'
					#indexing is zero-based, row then column
			break
		if case('txt'):
			if len(video['comments']) > 0:
				with open(path.join(dir_path, tech.validate(video['title'])),'a') as f:
		 			f.write(video['comments'])
			print 'Saved %s as text' % video['title']
			break
 def exportModeSetting(self, index):
     self.index = index
     for case in switch(self.index):
         if case(0):
             self.getOptionStatus()
             # check all (path name namespace)
             self.exportPath = self.checkExportPath()
             self.exportName = ''
             self.exportNamespace = self.checkExportNamespace()
             break
         if case(1):
             self.getOptionStatus()
             # check all (path name namespace)
             self.exportName = self.checkExportName()
             self.exportPath = self.checkExportPath()
             self.exportNamespace = self.checkExportNamespace()
             break
         if case(2):
             self.readyExportOption = [
                 "Camera", "Character", "Prop", "Scene"
             ]
             # check all (path name namespace)
             self.exportPath = self.checkExportPath()
             self.exportNamespace = ''
             self.exportName = ''
             break
         if case():
             break
Example #6
0
def __haunted_forest_sing(input):
    if input:
        for case in switch(input[0]):
            if case('halelujah'):
                print "The world has become a brighter place!"
                haunted_forest.set_state(2)
                break
            else:
                print "*sings* " + input[1]
    else:
                print "I'm siiiiiiingin' in the rain!"
def getTopoObj(topo):
    for case in switch(topo):
        if case('torus'):
            return topoTorus()
        if case('fattree'):
            return topoFatTree()
        if case('dragonfly'):
            return topoDrgonFly()
        if case('dragonfly2'):
            return topoDrgonFly2()

    sys.exit("how did we get here")
Example #8
0
 def play(self):
     map_name = self.select_map.get()
     solver_name = self.select_solver.get()
     if len(map_name) == 0 or len(solver_name) == 0\
             or len(self.maps) == 0 or len(self.solvers) == 0:
         eprint("error: no map or solver")
         return
     map_file = self.maps[map_name]
     solver_file = self.solvers[solver_name]
     proc = subprocess.run(solver_file + ' < ' + map_file,\
             stdout=subprocess.PIPE, shell=True)
     output = proc.stdout.decode("utf-8").splitlines(keepends=True)
     lmap, lc = lemin_map_parser(output)
     if lmap == None or lemin_map_checker(lmap):
         eprint("error: invalid map")
         return
     game = lemin_game_parser(lmap, lc, output[lc:])
     if game == None or lemin_game_checker(game, lmap):
         eprint("error: invalid solution")
         return
     switch(M_PLAYER, lmap, game)
def getTopoInfo( topo, shape ):
	for case in switch(topo):
		if case('torus'):
			return TorusInfo(shape)   
		if case('fattree'):
			return FattreeInfo(shape)   
		if case('dragonfly'):
			return DragonFlyInfo(shape)   
		if case('dragonfly2'):
			return DragonFly2Info(shape)   
			
	sys.exit("how did we get here")
def getTopoObj( topo ):
	for case in switch(topo):
		if case('torus'):
			return topoTorus()
		if case('fattree'):
			return topoFatTree()
		if case('dragonfly'):
			return topoDrgonFly()
		if case('dragonfly2'):
			return topoDrgonFly2()
			
	sys.exit("how did we get here")
def getTopoInfo(topo, shape):
    for case in switch(topo):
        if case('torus'):
            return TorusInfo(shape)
        if case('fattree'):
            return FattreeInfo(shape)
        if case('dragonfly'):
            return DragonFlyInfo(shape)
        if case('dragonfly2'):
            return DragonFly2Info(shape)

    sys.exit("how did we get here")
Example #12
0
def __haunted_forest_pick(input):
    if input:
        for case in switch(input[0]):
            if case('mushroom', 'mushrooms'):
                if haunted_forest.current_state_ix == 0:
                    print "Mmm... Mushrooms!\n"
                    haunted_forest.set_state(1)
                else:
                    print "Where have all the mushrooms gone? Young girls picked them everyone!"
                break
            if case('tree','trees'):
                print "You're not that strong, silly!"
                break
            if case('stuff'):
                print "Some stuff stuffed away."
                break
            else:
                print "Ain't no " + input[0] + " around here"
    else:
        print "Pick-pickety-pick... pickaxe?"
    def setExportMode(self, index):
        # 0 - Option
        # 1 - ByName
        # 2 - All
        self.index = index
        for case in switch(self.index):
            if case(0):
                self.checkBox_camera.setEnabled(True)
                self.checkBox_prop.setEnabled(True)
                self.checkBox_chracter.setEnabled(True)
                self.checkBox_scene.setEnabled(True)
                self.lineEdit_exportname.setEnabled(False)
                self.lineEdit_namespace.setEnabled(True)
                self.lineEdit_exportpath.setEnabled(True)
                break
            if case(1):
                self.lineEdit_exportname.setEnabled(True)
                self.lineEdit_exportpath.setEnabled(True)
                self.lineEdit_namespace.setEnabled(True)
                self.checkBox_camera.setEnabled(True)
                self.checkBox_prop.setEnabled(True)
                self.checkBox_chracter.setEnabled(True)
                self.checkBox_scene.setEnabled(True)
                break
            if case(2):
                self.lineEdit_exportname.setEnabled(False)
                self.lineEdit_namespace.setEnabled(False)
                self.lineEdit_exportpath.setEnabled(True)
                self.checkBox_camera.setEnabled(False)
                self.checkBox_prop.setEnabled(False)
                self.checkBox_chracter.setEnabled(False)
                self.checkBox_scene.setEnabled(False)

                break
            if case():
                print "something else!"
Example #14
0
import sys
from smart_plug import *
from switch import *
from dali_lights import *
import time

ip = '192.168.81.1'
port = '3480'

dali_ip = '192.168.1.250'
dali_port = '50000'

switch4 = switch(ip, port, id=4)

switch4.setOn()
time.sleep(10)
switch4.setOff()
'''
k=switch4.getId()
print k

l=switch4.Increase_val(78)

m=switch4.getIntensity()
print m


#switch4.setId(4)
switch5 = smart_plug(ip,port)
switch5.setId(5)
Example #15
0
# load PDF data, J = P(t)/P(0)
pdf = pyfits.open('derivs.fit')

J_phi = pdf[0].data
J_chi = pdf[1].data
J_pip = pdf[2].data
J_pic = pdf[3].data
J_a = pdf[4].data
J_p = pdf[5].data

# load Kolmogorov-Sinai entropy
kse = pyfits.open('entropy.fit')
S = kse[0].data

# variable being plotted
for case in switch(expr):
    if case("phi"):
        q = a * phi
        break
    if case("chi"):
        q = a * chi
        break
    if case("pip"):
        q = pip / a
        break
    if case("pic"):
        q = pic / a
        break
    if case("lna"):
        q = np.log(a)
        break
Example #16
0
# load PDF data, J = P(t)/P(0)
pdf = pyfits.open('derivs.fit')

J_phi = pdf[0].data
J_chi = pdf[1].data
J_pip = pdf[2].data
J_pic = pdf[3].data
J_a   = pdf[4].data
J_p   = pdf[5].data

# load Kolmogorov-Sinai entropy
kse = pyfits.open('entropy.fit')
S   = kse[0].data

# variable being plotted
for case in switch(expr):
	if case("phi"): q = a*phi; break
	if case("chi"): q = a*chi; break
	if case("pip"): q = pip/a; break
	if case("pic"): q = pic/a; break
	if case("lna"): q = np.log(a); break
	if case("p"):   q = -p/6.0; break
	if case("lnF(phi)"): q = -np.log(1.0/np.square(J_phi) + 1.0e-16)/2.0; break
	if case("lnF(chi)"): q = -np.log(1.0/np.square(J_chi) + 1.0e-16)/2.0; break
	if case("lnF(pip)"): q = -np.log(1.0/np.square(J_pip) + 1.0e-16)/2.0; break
	if case("lnF(pic)"): q = -np.log(1.0/np.square(J_pic) + 1.0e-16)/2.0; break
	if case("lnF(a)"):   q = -np.log(1.0/np.square(J_a)   + 1.0e-16)/2.0; break
	if case("lnF(p)"):   q = -np.log(1.0/np.square(J_p)   + 1.0e-16)/2.0; break
	if case("entropy"):  q = np.cumsum(S, axis=0); break
	if case("lyapunov"): q = S; break
Example #17
0
import sys
from smart_plug import *
from switch import *
from dali_lights import *
import time

ip='192.168.81.1'
port='3480'

dali_ip='192.168.1.250'
dali_port='50000'

switch4 = switch(ip,port,id=4)

switch4.setOn()
time.sleep(10)
switch4.setOff()

'''
k=switch4.getId()
print k

l=switch4.Increase_val(78)

m=switch4.getIntensity()
print m


#switch4.setId(4)
switch5 = smart_plug(ip,port)
switch5.setId(5)
Example #18
0
 def new_map(self):
     switch(M_EDITOR, None)
     #TODO: switch to edit mode instead of this
     #file_name = edit_lemin_map(None)
     #self.add_map_file(file_name)
     pass
Example #19
0
game = None
if command_line_mode:
    if len(args) == 0:
        lmap, lc = lemin_map_parser()
        if lmap == None or lemin_map_checker(lmap):
            eprint("error: invalid map")
            exit()  # TODO: replace this with the main_menu when it is done
        game = lemin_game_parser(lmap, lc)
        if game == None or lemin_game_checker(game, lmap):
            eprint("error: invalid solution")
            exit()  # TODO: replace this with the main_menu when it is done
        mode = M_PLAYER
    else:
        map_file = open(args[0])
        lmap, lc = lemin_map_parser(map_file)
        map_file.close()
        if lmap == None or lemin_map_checker(lmap):
            eprint("error: invalid map")
            exit()  # TODO: replace this with the main_menu when it is done
        mode = M_EDITOR
else:
    mode = M_MENU

lda = lemin_data(command_line_mode)
switch(lda=lda)
set_style()
lda.load_data(mode, lmap, game)
if lda.lwin.redrawf:
    lda.lwin.redrawf()  #TODO: REMOVE THIS (OR AT LEAST MOVE IT)
lda.lwin.win.mainloop()
Example #20
0
from switch import *

x = 5

switch(x)

if case(4):
    assert False

if case(5):
    assert True
    fallthrough()

if case(5):
    assert True

if case(5):
    assert False

if case(6):
    assert False


switch(3)

if case(lambda x: x > 5):
    assert False

if default():
    assert True