def manage_tutorials(tutorials):
    """
    Takes a list of Tutorial Schedule Objects,
    asks the user which tutorials are applicable
    and returns this subset list of tutorials
    """
    tutorial_dict = organise_by_module(tutorials)
    sorted_tutorials = tutorial_dict.values()
    tutorials_out = set()
    for module in sorted_tutorials:
        module.sort(key=lambda y: [y.day_number, y.time_hour])
        clear()
        verifying = True
        while verifying:
            print "Please Input Values (comma separated) of the Non-Lecture Items that Apply to You"
            print_outs = []
            for tutorial in module:
                if tutorial.to_string() not in print_outs:
                    print str(module.index(tutorial)+1)+"."+tutorial.to_string()
                    print_outs.append(tutorial.to_string())
            string_values = get_input("Input Values:")
            try:
                values = [int(x) for x in string_values.split(",")]
                verifying = False
                for x in values:
                    tutorials_out.add(module[x-1])
            except:
                print "InputError:"
                print string_values
                print "Invalid Input, try again"
                verifying = True
    return list(tutorials_out)
def make_spreadsheet(schedule_items):
    workbook, worksheets = get_default_book()
    styles = {
        1: get_color_style('red'),
        2: get_color_style('light_orange'),
        3: get_color_style('yellow'),
        4: get_color_style('bright_green'),
        5: get_color_style('ocean_blue'),
        6: get_color_style('violet')
        }
    for schedule_item in schedule_items:
        for week in schedule_item.weeks:
            try:
                worksheets[week].write(schedule_item.time_hour+1,
                                       schedule_item.day_number+1,
                                       schedule_item.module_name,
                                       styles[schedule_item.module_number])
            except Exception, e:
                clear()
                print str(e)
                print schedule_item.to_string()
                get_input('')
            if schedule_item.duration != 1:
                worksheets[week].merge(schedule_item.time_hour+1,
                                       schedule_item.time_hour+schedule_item.duration,
                                       schedule_item.day_number+1,
                                       schedule_item.day_number+1)
Пример #3
0
	def load_plugins(self):
		'''
			Function that load plugins from specific path. Generator function load one at the time.

			Raises:
				ImportError : if module or plugins folder don't exists
		'''

		for file in self.files_generator(self.path):
			file, ext = clear(file)
			if PY_EXT in ext:
				yield self.get_from_path(file, self.path)
def check_clashes(schedule_items):
    """
    Iterates through schedule objects currently registered
    and checks which weeks those schedule objects clash (if any).
    For each week that the two clash, ask the user which item to keep
    """
    clear()
    for comp1 in schedule_items:
        for comp2 in schedule_items:
            clash_weeks = comp1.clash(comp2)
            if clash_weeks is not None:
                for week in clash_weeks:
                    print "TimeTable Clash on week: %s" % str(week)
                    print "1." + comp1.to_string()[0,2:]
                    print "2." + comp2.to_string()[0,2:]
                    keep = get_input("Input Item to Keep: ")
                    if keep[0] + " " == "1":
                        comp2.weeks.remove(week)
                    else:
                        comp1.weeks.remove(week)
    clear()
    return schedule_items
Пример #5
0
 def run(self):
     clear()
     while not self.currentScreen.exit():
         self.currentScreen = self.currentScreen.display()
         clear()
     self.currentScreen.display()
Пример #6
0
def update(ctx):
    clear()
    c = ob('Cube')
    voxelize(c)  # XXX: expensive, try caching somehow
Пример #7
0
#!/usr/local/bin/python
from website import app
from utils import clear, load, load_images, add_zips
import sys


if __name__ == '__main__':
    if len(sys.argv) == 1:
        app.debug = True
        app.run(host='0.0.0.0', port=5000)

    elif len(sys.argv) == 2:
        if sys.argv[1] == 'clear':
            clear()
        elif sys.argv[1] == 'load':
            load()
        elif sys.argv[1] == 'load_images':
            load_images()
        elif sys.argv[1] == 'add_zips':
            add_zips()
        else:
            print "error starting server: could not interpret argument"
    else:
        print "error starting server: too many arguments"
Пример #8
0
def tuto(cube, mouvements):
    """
    tuto

    :Args:
        cube        {Cube}      Un cube à la sortie de lecture_cube
        mouvements  {List}      Suite de mouvements à appliquer sur le cube
                                pour le résoudre, calculée par algo_cfop()
    """

    #lecture des paramètres
    params = readArgs()
    speed = float(params['speed']) if 'speed' in params else SPEED

    resolution = " ".join([translate_mvt(x) for x in mouvements])

    mouvementsDone = []
    mouvementsRestants = list(mouvements)

    clear()
    if 'auto' in params:
        print('Positionnez la face bleue face à vous et la face blanche face au sol\n')
        print('Le tuto en mode auto va bientôt commencer, tenez vous prêt !')
        sleep(3)
    clear()
    sleep(1)
    print("Exécution de la manoeuvre : {}".format(resolution) )
    print(cube)

    for m in mouvements:
        clear()
        mouvementsRestants.remove(m)
        method = getattr(cube, 'rot_' + m)
        method()

        print(
            "Exécution de la manoeuvre : "

            #les mouvements effectués
            + TermColors.green + \
            "{}".format(" ".join([translate_mvt(x) for x in mouvementsDone]))+ \
            TermColors.end + ' ' +

            #le mouvement actuel
            TermColors.bgGreen + translate_mvt(m) + TermColors.end + \

            #les mouvements restant
            " {}".format(" ".join([translate_mvt(x) \
                for x in mouvementsRestants])
            ) + '\n'
        )

        if 'moves' not in params:
            print(cube)
        else:
            #L'utilisateur a demandé de voir l'aide des mouvements
            print(aideMouvements(cube, m))
            print("Rotation : ", translate_mvt(m) +'\n\n')

        mouvementsDone.append(m)

        if 'auto' not in params:
            print('Press any key to continue . . .\n')
            newGetch()
        else:
            sleep(1 / speed)
Пример #9
0
Файл: main.py Проект: shreq/OE
from platypus.operators import UniformMutation
from platypus.core import nondominated
from pymoo.factory import get_problem, get_performance_indicator
from scipy.interpolate import interp1d
from sklearn.metrics import mean_squared_error

from utils import clear
from argument_parser import ArgumentParser

args = ArgumentParser()

algorithm_name = args.get_algorithm()
population_size = args.get_population()
problem_name = args.get_problem()

clear()

variator = UniformMutation(probability=args.get_probability(),
                           perturbation=0.5)

problem = {
    'zdt1': ZDT1(),
    'zdt2': ZDT2(),
    'zdt3': ZDT3(),
    'zdt4': ZDT4(),
}[problem_name]

algorithm = {
    'nsga2': NSGAII(problem, population_size, variator=variator),
    'ibea': IBEA(problem, population_size, variator=variator),
    'spea2': SPEA2(problem, population_size, variator=variator),
Пример #10
0
#!/usr/bin/env python3

import utils

utils.check_version((3, 7))  # make sure we are running at least Python 3.7
utils.clear()  # clear the screen

print('Greetings!')
color = ''
while (color != 'red'):
    color = input("What is my favorite color? ")
while (color != 'red'):
    color = color.lower().strip()
    if (color == 'red'):
        print('Correct!')
    elif (color == 'pink'):
        print('Close!')
    else:
        print('Sorry, try again.')
Пример #11
0
# -*- coding: utf-8 -*-
import utils
import graph
import string

g = utils.build_graph()

utils.clear()
ans = "s"

print("Welcome to Network of Thrones")
while ans == "s" or ans == "S":
	print("""
Faça sua escolha:

1) Distância entre 2 personagens.
2) Caminho entre 2 personagens.
3) Encontrar Pontos de Articulação.
4) Encontrar Pontes.

0) Sair""")
	choice = int(input(">>> "))
	utils.clear()

	if choice == 0:
		break
	if choice == 3:
		points = graph.articulation_point(g)
		print("Os pontos de articulação são:")
		print("\n".join(points))
	elif choice == 4:
Пример #12
0
def main():
    '''
    The main function for this file. It is run if this file is not used as a module.
    '''
    utils.check_version((3,7))          # make sure we are running at least Python 3.7
    utils.clear()                       # clear the screen

    print("Adding some numbers")
    print(add(1,2))
    print(add(1,-2))
    print(add(1.1,5))

    print("Subtracting")
    print(sub(1,2))
    print(sub(1,-2))
    print(sub(1.1,5))

    print("Multiplication")
    print(mult(4,2))
    print(mult(7,-2))
    print(mult(9.3,5))

    print("Division")
    print(div(1,2))
    print(div(10,-2))
    print(div(1.2,5))

    print("Integer or floor division")
    print(floorDiv(1,2))
    print(floorDiv(11,-2))
    print(floorDiv(16.4,5))

    print("Modulo: getting the remainder after division")
    print(mod(15,2))
    print(mod(16,-2))
    print(mod(16.2,5))

    print("Exponents")
    print(exp(10,2))
    print(exp(6,-2))
    print(exp(2.2,5))

    print("Changing the order of operations (with parenthesis)")
    print(orderOperations(1,2,3))
    print(orderOperations(1,-2,-6))
    print(orderOperations(1.5,5,0.2))

    print("Checking data types")
    print(whichType(1))
    print(whichType(1.0))
    print(whichType('1'))
    print(whichType(True))
    print(whichType(False))
    print(whichType((1,2)))
    print(whichType([1,2]))
    print(whichType({1:2}))

    print("Converting to integers")
    print(convertInt(5.2))
    print(convertInt('1'))

    print("Converting to floats")
    print(convertFloat(44))
    print(convertFloat('1'))

    print("Converting to strings")
    print(convertStr(5.2))
    print(convertStr(100))

    print("String concatenation")
    print(concat('This is a ','test'))
    print(concat('Hello,',' World!'))

    print("Slicing")
    print(whichChar('This is a test of the emergency broadcast system.',1))
    print(whichChar('This is a test of the emergency broadcast system.',2))
    print(whichChar('This is a test of the emergency broadcast system.',10))
    print(whichChar('This is a test of the emergency broadcast system.',-1))

    print("Slicing substrings")
    print(substr('This is a test of the emergency broadcast system.',0,100))
    print(substr('This is a test of the emergency broadcast system.',2,5))
    print(substr('This is a test of the emergency broadcast system.',10,12))
    print(substr('This is a test of the emergency broadcast system.',-5,-1))

    print("Reversing strings")
    print(reverseStr('This is a test of the emergency broadcast system.'))
    print(reverseStr('Hello, World!'))

    print("Finding list items")
    print(isIn([1,2,3,4,5,6,7,8],5))
    print(isIn(['A','B','C','D'],'C'))
    print(isIn([1,2,3,4,5,6,7,8],10))
    print(isIn(['A','B','C','D'],'E'))

    print("Returning random list elements")
    print(randomElement([1,2,3,4,5,6,7,8]))
    print(randomElement(['A','B','C','D']))
    print(randomElement(['G','Hello',1.5,(5,5)]))

    print("Random numbers")
    print(randomNumber())
    print(randomNumber())
    print(randomNumber())

    print("Reversing lists")
    print(reverseList([1,2,3,4,5,6]))
    print(reverseList(['a','b','c','d','e','f']))
    print(reverseList(['G','Hello',1.5,(5,5)]))

    print("Randomizing lists")
    print(shuffleList([1,2,3,4,5,6]))
    print(shuffleList(['a','b','c','d','e','f']))
    print(shuffleList(['G','Hello',1.5,(5,5)]))

    print("Making new lists of sequential numbers")
    print(listUntil(10))
    print(listUntil(50))
    print(listUntil(4))
    print(listUntil(-5))
Пример #13
0
def main():
    clear()
    title_screen()
    return