def main(): parser = argparse.ArgumentParser( epilog=""" Docs at http://genomeannotation.github.io/GAG/ Bugs and feature requests at https://github.com/genomeannotation/GAG/issues """, formatter_class=argparse.RawDescriptionHelpFormatter ) parser.add_argument('-f', '--fasta', required=True) parser.add_argument('-g', '--gff', required=True) parser.add_argument('-a', '--anno') parser.add_argument('-t', '--trim') parser.add_argument('-o', '--out') parser.add_argument('--fix_start_stop', action='store_true') parser.add_argument('--fix_terminal_ns', action='store_true') parser.add_argument('-rcs', '--remove_cds_shorter_than') parser.add_argument('-rcl', '--remove_cds_longer_than') parser.add_argument('-res', '--remove_exons_shorter_than') parser.add_argument('-rel', '--remove_exons_longer_than') parser.add_argument('-ris', '--remove_introns_shorter_than') parser.add_argument('-ril', '--remove_introns_longer_than') parser.add_argument('-rgs', '--remove_genes_shorter_than') parser.add_argument('-rgl', '--remove_genes_longer_than') parser.add_argument('-fcs', '--flag_cds_shorter_than') parser.add_argument('-fcl', '--flag_cds_longer_than') parser.add_argument('-fes', '--flag_exons_shorter_than') parser.add_argument('-fel', '--flag_exons_longer_than') parser.add_argument('-fis', '--flag_introns_shorter_than') parser.add_argument('-fil', '--flag_introns_longer_than') parser.add_argument('-fgs', '--flag_genes_shorter_than') parser.add_argument('-fgl', '--flag_genes_longer_than') parser.add_argument('-ses', '--skip_empty_scaffolds', action='store_true') args = parser.parse_args() controller = Controller() controller.execute(args)
def __init__(self, loop): self.loop = loop controller = Controller() model = Model(controller=controller) self.view = View(controller=controller) controller.segundo_init(model=model, view=self.view)
def run_agent(layout: str): agent = GeneticAgent(layout) agent.load_net() controller = Controller(layout_name=layout, act_sound=True, act_state=False, ai_agent=agent) controller.load_menu()
def run_agent(layout: str): agent = LinQAgent(layout=layout, version='1') agent.load_approximator() controller = Controller(layout_name=layout, act_sound=True, act_state=False, ai_agent=agent) controller.load_menu()
def __init__(self, *args, **kwargs): QMainWindow.__init__(self, *args, **kwargs) self.extension = '.jpg' self.image_width, self.image_height = 1280, 720 # self.image_width, self.image_height = 640, 360 # Widget de Imagen. self.image_widget = ImageWidget(self.image_width, self.image_height) # Widget de seleccion de tracker. self.tracker_combobox = ComboBoxWidget('./config/tracker_list.txt') self.tracker_groupBox = self.create_groupBox_from_widget('Tracker', self.tracker_combobox) # Widget de seleccion de clase. self.class_list = ListWidget('./config/class_list.txt') self.class_groupBox = self.create_groupBox_from_widget('Classes', self.class_list) # Botones de acciones. self.radio_track = QRadioButton(utils.MODE_DICT[utils.MODE_TRACK]) self.radio_rtrack = QRadioButton(utils.MODE_DICT[utils.MODE_RTRACK]) self.radio_copy = QRadioButton(utils.MODE_DICT[utils.MODE_COPYBBOX]) self.radio_empty = QRadioButton(utils.MODE_DICT[utils.MODE_EMPTY]) self.radio_nothing = QRadioButton(utils.MODE_DICT[utils.MODE_NOTHING]) self.group_box = self.create_button_group() # Botones de ejecucion. self.button_prev = QPushButton('Prev') self.button_next = QPushButton('Next') self.button_run = QPushButton('Run') self.button_stop = QPushButton('Stop') # Folder reader. self.folder_reader = FolderReader() # Exportar txt a xml. self.xml_creator = XMLCreator('./imagen', self.extension) # Main controller. self.controller = Controller(self, self.extension) self.controller.set_classes(self.class_list.get_items()) # Shortcuts. self.shortcut_next = QShortcut(QKeySequence('D'), self) self.shortcut_prev = QShortcut(QKeySequence('A'), self) self.shortcut_1 = QShortcut(QKeySequence('1'), self) self.shortcut_2 = QShortcut(QKeySequence('2'), self) self.shortcut_3 = QShortcut(QKeySequence('3'), self) self.shortcut_4 = QShortcut(QKeySequence('4'), self) self.shortcut_5 = QShortcut(QKeySequence('5'), self) self.shortcut_6 = QShortcut(QKeySequence('6'), self) self.shortcut_7 = QShortcut(QKeySequence('7'), self) self.shortcut_8 = QShortcut(QKeySequence('8'), self) self.shortcut_9 = QShortcut(QKeySequence('9'), self) self.setup_ui() self.setup_signals()
def __init__(self, _character, inputGroupName=None): Controller.__init__(self) self.character = _character self.inputGroup = inputGroupName if inputGroupName is not None else CHARACTER_INPUT_GROUP self.add(self.character) pass
def test_controller(qtbot): controller = Controller() with qtbot.waitSignal(controller.stopped, timeout=5000) as blocker: controller.stopped.connect(stopped_callback) controller.errored.connect(errored_callback) controller.work()
class ControllerThread(Thread): def __init__(self, thread_id, name): Thread.__init__(self) self.threadID = thread_id self.name = name self.controller = Controller() def run(self) -> None: self.controller.run()
def __init__(self): super(Ui_MainWindow, self).__init__() splash_pix = QPixmap(':/imgs/imgs/splash.png') self.splash = QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint) self.splash.show() self.controller = Controller(self) self.progress = 0 self.timer = QBasicTimer()
def proof(players_num, samples_num): controller = Controller(players_num) points, win_statistics = controller.make_experiment(samples_num) points = [round(elem, DECIMALS) for elem in points] win_statistics = [round(elem * 100, 1) for elem in win_statistics] click.echo('The points: {}'.format(points)) click.echo( 'Respectively won in percent of cases: {}'.format(win_statistics))
class ControllerTest(TestCase): # test needs updating due to removing boto3 client from controller class @mock.patch("boto3.client") def test_controller_initialises_s3_client(self, mock_client): self.controller = Controller() self.controller.run_steps(mock_event) mock_client.assert_called_with("s3")
def test_order(self): # given id = "" controller = Controller("order") # when response = controller.get(id) body = json.loads(response["body"]) # then self.assertEqual(response["statusCode"], 200)
def setUp(self): unittest.TestCase.setUp(self) self.repository = FileRepository(SentenceValidator, "emptyFile") self.sentence1 = Sentence(["ana", "are", "mere"]) self.sentence2 = Sentence(["Dana", "are", "pere"]) self.sentence3 = Sentence(["Oana", "are", "bere"]) self.repository.save(self.sentence1) self.repository.save(self.sentence2) self.repository.save(self.sentence3) self.controller = Controller(self.repository)
def test_cmd_enable_statistics(self): """ Location: 'python_controller.py-Controller-Lines (68-70, 122-139)' Testing whether statistics can be enabled by the command method Author: Jake """ controller = Controller() m = mock.MagicMock(name='input') m.side_effect = ['enable_statistics', 'quit'] builtins.input = m controller.run_console() actual = controller.statistics self.assertIsNotNone(actual)
def main(input_file, output_file, capacity): if input_file: input = input_file.read() else: input = click.prompt('Enter an input stream', type=str) controller = Controller(capacity) result = controller.run(input.replace('\\n', '\n')) if output_file: output_file.write(result) else: click.echo(result)
def test_cmd_set_input_file(self): """ Location: 'python_controller.py-Controller-whole file' Testing whether input files can be selected by gui Author: Jake """ controller = Controller() m = mock.MagicMock(name='input') m.side_effect = ['set_input_file', 'quit'] builtins.input = m controller.run_console() actual = controller.files self.assertIsNotNone(actual)
def test_output_file(self): """ Location: 'python_controller.py-Controller-whole file' Testing whether file will be output to destination Author: Jake """ controller = Controller() m = mock.MagicMock(name='input') m.side_effect = ['output_to_file E:\ARA work', 'quit'] builtins.input = m controller.run_console() actual = Path('E:\ARA work\class.png').exists() self.assertTrue(actual)
def optimal_strategy(players_num): controller = Controller(players_num) # Optimal points for the first player point = round(controller.get_optimal_point(), DECIMALS) points = [ round(elem, DECIMALS) for elem in controller.get_optimal_points() ] click.echo('The optimal strategy for the first player: {}'.format(point)) click.echo( 'Was randomly chosen from the several optimal points: {}'.format( points))
def onMenuItem_Inf_load(self, event): try: sys.stdin = urllib.urlopen(STUNDENPLAN_URL_Inf) self.ctrl = Controller(inFileName=None, outFileName=None) self.infoString.SetLabel(self.space + "HAW-Kalender: " + self.ctrl.getInfoString()) self.fillTrees() self.updateExportButton() self.menuItem_AlleSemUndDoz.Enable() except IOError as e: print "Couldn't open Inf-url: " + str(e)
def test_cmd_set_input_file_args(self): """ Location: 'python_controller.py-Controller-whole file' Testing whether input files can be selected by arguments Author: Jake """ expected = ["plants.py"] controller = Controller() m = mock.MagicMock(name='input') m.side_effect = ['set_input_file plants.py', 'quit'] builtins.input = m controller.run_console() actual = controller.files self.assertEqual(actual, expected)
def run_game(): pygame.init() game_settings = Settings() screen = Screen(game_settings) pygame.display.set_caption("BOMBERMAN") character = Character(game_settings, screen.screen, (0, 0)) character2 = Character(game_settings, screen.screen, (1, 1)) bombs_handler = BombsHandler(Group(), Group()) obstacles = Group() hard_obstacles = Group() explosions = Group() treasures = Group() obstacle_placer = ObstaclePlacer() obstacle_placer.create_obstacles(game_settings, screen.screen, obstacles) obstacle_placer.create_hard_obstacles(game_settings, screen.screen, hard_obstacles) joystick = Joystick() smile_of_fate = SmileOfFate(game_settings) latest_choices = (0, 0) controller = Controller() while True: pygame.event.pump() controller.check_events(game_settings, screen.screen, character, bombs_handler.bombs[0], character2, bombs_handler.bombs[1]) character.update(obstacles, hard_obstacles) if joystick.is_joystick(): latest_choices = controller.check_joystick_events( character2, joystick.is_joystick(), latest_choices) character2.update(obstacles, hard_obstacles) bombs_handler.update_bombs(bombs_handler.bombs[0], game_settings, screen.screen, explosions, obstacles, treasures, smile_of_fate) bombs_handler.update_bombs(bombs_handler.bombs[1], game_settings, screen.screen, explosions, obstacles, treasures, smile_of_fate) bombs_handler.kill_your_heroes(explosions, character, character2) if len(obstacles.sprites()) < 5: treasures.empty() character.reset_character_status() character2.reset_character_status() obstacle_placer.create_obstacles(game_settings, screen.screen, obstacles) smile_of_fate.player_collected_treasure(character, treasures) smile_of_fate.player_collected_treasure(character2, treasures) screen.update_screen(game_settings, character, obstacles, bombs_handler.bombs[0], character2, bombs_handler.bombs[1], hard_obstacles, explosions, treasures)
def run(): config = Config('configs.yaml') database = Database(config.database) controller = Controller() while True: controller.fill_wall_post_trigger(database) controller.fill_comment_trigger(database) controller.fill_wall_post_emotion(database) controller.fill_comment_emotion(database) sleep(60 * 60)
def main(): parser = argparse.ArgumentParser( epilog=""" Name changing tool for replacing scaffold names. Latest version At: https://github.com/genomeannotation/name_change """, formatter_class=argparse.RawDescriptionHelpFormatter ) parser.add_argument('-d', '--dictionary', required=True, help='two column file with [new names]\\t[old names]') parser.add_argument('-f', '--file', required=True, help='file with names to be changed') parser.add_argument('-o', '--out', help='output folder name') args = parser.parse_args() controller = Controller() controller.execute(args)
def main(): while True: try: choice = int( input( '>> Enter 1. to Train, 2. to Translate, 3. to plot graph, 4. to Exit! \n' )) if choice == 1 or choice == 2 or choice == 3: Controller.main(choice) elif choice == 4: break except Exception as e: print('*** Error: ' + str(e) + '. Try Again ***') pass
class TestController(TestCase): def setUp(self): self.controller = Controller("test") def test_save(self): self.controller.save() with open(self.controller.file_manager.saved_app_file, 'rb') as f: saved_controller: Controller = dill.load(f) assert type(self.controller) is type(saved_controller) for attr in self.controller.__dict__: field = getattr(self.controller, attr) for field_attr in field.__dict__: if field_attr == "controller": continue self.assertEqual(getattr(field, field_attr), getattr(getattr(saved_controller, attr), field_attr))
def onButton_Load(self, event): dlg = wx.FileDialog(self, "txt-Version des Semesterplans auswählen") dlg.SetWildcard("nur Textdateien (*.txt)|*.txt|alle Dateien|*") if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() self.ctrl = Controller(inFileName=path, outFileName=None) self.infoString.SetLabel(self.space + "HAW-Kalender: " + self.ctrl.getInfoString()) self.fillTrees() dlg.Destroy() self.updateExportButton() self.menuItem_AlleSemUndDoz.Enable()
def control(self): """ cat: edit desc: turn this property's value into a controller, which allows it to be changed over time """ val = self.get_val() if self.cont_type == "c": if val is not None: markers = {0: ContinuousMarker(Units.beats("0b"), val, "hard")} else: markers = None cont = ContinuousController( name=self.name, val_units=self.inpt_mode, val_allowed=self.allowed, markers=markers, change_types=self.change_types, parent=self.caller ) else: if val is not None: markers = {0: DiscreteMarker(Units.beats("0b"), val)} else: markers = None cont = Controller( name=self.name, val_units=self.inpt_mode, val_allowed=self.allowed, markers=markers, parent=self.caller ) setattr(self.caller, self.attrname(), cont) add_reldata(cont.rename, "public", False) process(cont)
def post(): parser = reqparse.RequestParser() parser.add_argument('channel', required=True) parser.add_argument('separator', required=True) parser.add_argument('artist_before_title', required=True) args = parser.parse_args() return {'message': 'Channel has been added.', 'data': Controller.new_channel(args)}, 201
def post(): parser = reqparse.RequestParser() parser.add_argument('replace', required=True) parser.add_argument('replace_by', required=True) parser.add_argument('priority', required=True) args = parser.parse_args() return {'message': 'Naming rule has been added.', 'data': Controller.new_naming_rule(args)}, 201
def post(identifier): parser = reqparse.RequestParser() parser.add_argument('title', required=True) parser.add_argument('artist', required=True) parser.add_argument('new', required=True) args = parser.parse_args() return {'message': 'Music has been updated.', 'data': Controller.update_music(identifier, args)}, 201
def post(identifier): parser = reqparse.RequestParser() parser.add_argument('folder', required=True) # Parse the arguments into an object args = parser.parse_args() return {'message': 'Playlist has been updated.', 'data': Controller.update_playlist(identifier, args)}, 201
def main(): parser = argparse.ArgumentParser( epilog=""" Formatting tool for structure and pedigree output.\n Latest version at:\n https://github.com/genomeannotation/reformat """, formatter_class=argparse.RawDescriptionHelpFormatter ) parser.add_argument('-hmp', '--hapmap') parser.add_argument('-v', '--vcf') parser.add_argument('-p', '--plink_ped') parser.add_argument('-m', '--plink_map') parser.add_argument('-f', '--family') parser.add_argument('-o', '--out') args = parser.parse_args() controller = Controller() controller.execute(args)
def main(): parser = argparse.ArgumentParser( epilog=""" PySTACKS: Python STACKS pipeline\n Latest version at:\n https://github.com/genomeannotation/PySTACKS """, formatter_class=argparse.RawDescriptionHelpFormatter ) parser.add_argument('-sp', '--species_name', help='species name | for output files naming structure') parser.add_argument('-b', '--batch_id', help='integer value for batch id | default is 1') parser.add_argument('-d', '--raw_data', required=True, help='full path to raw read data (fastq) | Use one data.fq file, or .txt file with one data.fq file per line') parser.add_argument('-r', '--reference_genome', help='reference genome (fasta)') parser.add_argument('-i', '--index_file', required=True, help='full path to raw read index file | use one index.txt index file, or .txt file with one index.txt file per line (with same order as raw_data)') parser.add_argument('-s', '--single_end_data', help='set this flag if raw data is SINGLE-END samples') parser.add_argument('-p', '--paired_end_data', help='set this flag if raw data is PAIRED-END samples') parser.add_argument('-pm', '--population_map', required=True, help='path to population map for all individuals') parser.add_argument('-np', '--num_populations', required=True, help='number of separate populations in the population_map') args = parser.parse_args() controller = Controller() controller.execute(args)
def onMenuItem_EuI_load(self, event): try: sys.stdin = urllib.urlopen("http://www.etech.haw-hamburg.de/Stundenplan/Sem_IuE.txt") self.ctrl = Controller(inFileName=None, outFileName=None) self.infoString.SetLabel(self.space + self.ctrl.getInfoString()) self.fillTrees() self.updateExportButton() self.menuItem_AlleSemUndDoz.Enable() except IOError as e: print "Could not open EuI-url: " + str(e)
def onMenuItem_Inf_load(self, event): try: sys.stdin = urllib.urlopen("http://www.informatik.haw-hamburg.de/fileadmin/Homepages/ProfPadberg/stundenplaene/Sem_I.txt") self.ctrl = Controller(inFileName=None, outFileName=None) self.infoString.SetLabel(self.space + self.ctrl.getInfoString()) self.fillTrees() self.updateExportButton() self.menuItem_AlleSemUndDoz.Enable() except IOError as e: print "Couldn't open Inf-url: " + str(e)
class Maximus: def __init__(self, game_type, player_starts=False): self._controller = Controller(game_type, player_starts) def current_state(self): return self._controller.grid def make_move(self, transition_id): self._controller.make_move(transition_id) def ai_move(self): self._controller.ai_move() def undo_move(self): self._controller.undo_move() def reset(self): self._controller.reset()
def __init__(self, game_type, player_starts=False): self._controller = Controller(game_type, player_starts)
class MyFrame(wx.Frame): def __init__(self, *args, **kwds): # begin wxGlade: MyFrame.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.notebook_1 = wx.Notebook(self, -1, style=wx.NB_BOTTOM) self.notebook_1_pane_2 = wx.Panel(self.notebook_1, -1) self.notebook_1_pane_1 = wx.Panel(self.notebook_1, -1) self.panel_1 = wx.Panel(self, -1) # Menu Bar self.menuBar = wx.MenuBar() menu = wx.Menu() menu.Append(ITEM_BATCH_EXPORT_ID, u"für alle Semestergruppen und Dozenten exportieren", "", wx.ITEM_NORMAL) self.menuBar.Append(menu, "Batch") menu = wx.Menu() menu.Append(ITEM_EUI_ID, "Elektrotechnik und Informatik", "", wx.ITEM_NORMAL) menu.Append(ITEM_EUI_LOAD_ID, " -> direkt einlesen", "", wx.ITEM_NORMAL) menu.Append(ITEM_INF_ID, "Informatik", "", wx.ITEM_NORMAL) menu.Append(ITEM_INF_LOAD_ID, " -> direkt einlesen", "", wx.ITEM_NORMAL) menu.AppendSeparator() menu.Append(ITEM_GOOGLE_CALENDAR_ID, "Google Calendar", "", wx.ITEM_NORMAL) menu.AppendSeparator() menu.Append(ITEM_RFC5545_ID, "iCalendar rfc5545", "", wx.ITEM_NORMAL) self.menuBar.Append(menu, "Links") menu = wx.Menu() menu.Append(ITEM_HELP_ID, "Anleitung", "", wx.ITEM_NORMAL) menu.Append(ITEM_GPL_ID, "GPL", "", wx.ITEM_NORMAL) menu.Append(ITEM_ABOUT_ID, "About", "", wx.ITEM_NORMAL) self.menuBar.Append(menu, "Hilfe") self.SetMenuBar(self.menuBar) # frame pane self.button_Load = wx.Button(self, BTN_LOAD_ID, "HAW-Kalender einlesen") self.button_Export = wx.Button(self, BTN_EXPORT_ID, "Termin-Auswahl als iCalendar exportieren") self.infoString = wx.StaticText(self.panel_1, TXT_INFO_STRING_ID, " Bitte eine HAW-Kalender Textdatei einlesen ") self.treeCtrl_Stud = wx.TreeCtrl(self.notebook_1_pane_1, TREE_CTRL_STUD_ID, style=wx.TR_HIDE_ROOT|wx.TR_HAS_BUTTONS|wx.TR_NO_LINES|wx.TR_DEFAULT_STYLE|wx.SUNKEN_BORDER|wx.TR_MULTIPLE) self.treeCtrl_Doz = wx.TreeCtrl(self.notebook_1_pane_2, TREE_CTRL_DOZ_ID, style=wx.TR_HIDE_ROOT|wx.TR_HAS_BUTTONS|wx.TR_NO_LINES|wx.TR_DEFAULT_STYLE|wx.SUNKEN_BORDER|wx.TR_MULTIPLE) self.__doLayout() self.__doFrameBindings() self.__doMenuBindings() self.menuItem_AlleSemUndDoz = self.menuBar.FindItemById(ITEM_BATCH_EXPORT_ID) self.menuItem_AlleSemUndDoz.Enable(False) self.space = " " def __doLayout(self): sizer_1 = wx.BoxSizer(wx.VERTICAL) sizer_3 = wx.BoxSizer(wx.HORIZONTAL) sizer_2 = wx.BoxSizer(wx.HORIZONTAL) sizer_4 = wx.BoxSizer(wx.HORIZONTAL) sizer_5 = wx.BoxSizer(wx.HORIZONTAL) sizer_4.Add(self.button_Load, 0, 0, 0) sizer_4.Add(self.button_Export, 0, 0, 0) sizer_5.Add(self.infoString, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 0) self.panel_1.SetSizer(sizer_5) sizer_4.Add(self.panel_1, 1, wx.EXPAND|wx.ALIGN_RIGHT, 0) sizer_1.Add(sizer_4, 0, 0, 0) sizer_2.Add(self.treeCtrl_Stud, 1, wx.EXPAND, 0) self.notebook_1_pane_1.SetSizer(sizer_2) sizer_3.Add(self.treeCtrl_Doz, 1, wx.EXPAND, 0) self.notebook_1_pane_2.SetSizer(sizer_3) self.notebook_1.AddPage(self.notebook_1_pane_1, "Studentensicht") self.notebook_1.AddPage(self.notebook_1_pane_2, "Dozentensicht") sizer_1.Add(self.notebook_1, 1, wx.EXPAND, 0) self.SetSizer(sizer_1) sizer_1.Fit(self) self.Layout() def __doFrameBindings(self): self.button_Load.Bind(wx.EVT_BUTTON, self.onButton_Load) self.button_Export.Bind(wx.EVT_BUTTON, self.onButton_Export) self.button_Export.Disable() self.treeCtrl_Stud.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.onDoubleClick_Stud) self.treeCtrl_Doz.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.onDoubleClick_Doz) def __doMenuBindings(self): self.Bind(wx.EVT_MENU, self.onMenuItem_BatchStudUndDoz, id=ITEM_BATCH_EXPORT_ID) self.Bind(wx.EVT_MENU, self.onMenuItem_EuI, id=ITEM_EUI_ID) self.Bind(wx.EVT_MENU, self.onMenuItem_EuI_load, id=ITEM_EUI_LOAD_ID) self.Bind(wx.EVT_MENU, self.onMenuItem_Inf, id=ITEM_INF_ID) self.Bind(wx.EVT_MENU, self.onMenuItem_Inf_load, id=ITEM_INF_LOAD_ID) self.Bind(wx.EVT_MENU, self.onMenuItem_GoogleCalendar, id=ITEM_GOOGLE_CALENDAR_ID) self.Bind(wx.EVT_MENU, self.onMenuItem_rfc5545, id=ITEM_RFC5545_ID) self.Bind(wx.EVT_MENU, self.onMenuItem_Anleitung, id=ITEM_HELP_ID) self.Bind(wx.EVT_MENU, self.onMenuItem_GPL, id=ITEM_GPL_ID) self.Bind(wx.EVT_MENU, self.onMenuItem_About, id=ITEM_ABOUT_ID) def onButton_Load(self, event): dlg = wx.FileDialog(self, "txt-Version des Semesterplans auswählen") dlg.SetWildcard("nur Textdateien (*.txt)|*.txt|alle Dateien|*") if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() self.ctrl = Controller(inFileName=path, outFileName=None) self.infoString.SetLabel(self.space + "HAW-Kalender: " + self.ctrl.getInfoString()) self.fillTrees() dlg.Destroy() self.updateExportButton() self.menuItem_AlleSemUndDoz.Enable() def fillTrees(self): def fillTree(treeCtrl): font = wx.Font(12, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Courier New') treeCtrl.SetFont(font) groups = sorted(self.ctrl.getKeys()) treeCtrl.DeleteAllItems() rootName = "root" rootName_unicode = rootName.decode("utf-8") root = treeCtrl.AddRoot(rootName_unicode) for key in groups: key_unicode = key.decode("utf-8") parent = treeCtrl.AppendItem(root, key_unicode) veranstaltungen = sorted(self.ctrl.getVeranstaltungen(key)) maxLen = len(reduce(lambda x,y: max(x,y, key=len), veranstaltungen)) formatter = "{0:<" + str(maxLen+3) + "}" for veranstaltung in veranstaltungen: leftAlignedVeranstaltung = formatter.format(veranstaltung) #FIXME: dirty hack (a 'Ü' is represented in utf-8 by 2 byte) if 'Ü' in leftAlignedVeranstaltung: leftAlignedVeranstaltung += " " s = leftAlignedVeranstaltung + self.ctrl.tryGetFullName(veranstaltung) s_unicode = s.decode("utf-8") treeCtrl.AppendItem(parent, s_unicode) self.ctrl.tupleKeyIndex = DOZENT fillTree(self.treeCtrl_Doz) self.ctrl.tupleKeyIndex = self.ctrl.optimalGruppenKeyIndex() fillTree(self.treeCtrl_Stud) def onButton_Export(self, event): style = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT dlg = wx.FileDialog(self, message="iCalendar (.ics) speichern unter", style=style) dlg.SetWildcard("iCalendar-Dateien (*.ics)|*.ics") if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() if not path.endswith(".ics"): path = path + ".ics" self.ctrl.setOutFileName(path) self.ctrl.writeIcalendar() dlg.Destroy() def onDoubleClick_Stud(self, wxTreeEvent): self.ctrl.tupleKeyIndex = self.ctrl.optimalGruppenKeyIndex() self.onDoubleClick(wxTreeEvent, self.treeCtrl_Stud) def onDoubleClick_Doz(self, wxTreeEvent): self.ctrl.tupleKeyIndex = DOZENT self.onDoubleClick(wxTreeEvent, self.treeCtrl_Doz) def onDoubleClick(self, wxTreeEvent, treeCtrl): itemId = wxTreeEvent.GetItem() text_unicode = treeCtrl.GetItemText(itemId) text_utf8 = text_unicode.encode("utf-8") isVeranstaltung = not treeCtrl.ItemHasChildren(itemId) if not isVeranstaltung: key = text_utf8 veranstaltungen = self.ctrl.getVeranstaltungen(key) if self.groupFullSelected(key): self.ctrl.unselectVeranstaltungen(veranstaltungen) else: self.ctrl.selectVeranstaltungen(veranstaltungen) else: veranstaltung = text_utf8.split(" ")[0] #FIXME: dirty if veranstaltung in self.ctrl.selectedVeranstaltungen: self.ctrl.selectedVeranstaltungen.remove(veranstaltung) else: self.ctrl.selectedVeranstaltungen.add(veranstaltung) self.updateTrees() self.updateExportButton() def updateTrees(self): def updateTree(treeCtrl): for keyItemId in iterChildren(treeCtrl, treeCtrl.GetRootItem()): allSelected = True for veranstItemId in iterChildren(treeCtrl, keyItemId): text_unicode = treeCtrl.GetItemText(veranstItemId) veranstaltung = text_unicode.encode("utf-8").split(" ")[0] #FIXME: dirty if not veranstaltung in self.ctrl.selectedVeranstaltungen: treeCtrl.SetItemBold(veranstItemId, False) allSelected = False else: treeCtrl.SetItemBold(veranstItemId) treeCtrl.SetItemBold(keyItemId, allSelected) treeCtrl.Refresh() updateTree(self.treeCtrl_Stud) updateTree(self.treeCtrl_Doz) def updateExportButton(self): if len(self.ctrl.selectedVeranstaltungen) > 0: self.button_Export.Enable() else: self.button_Export.Disable() def groupFullSelected(self, key): return (self.ctrl.selectedVeranstaltungen & set(self.ctrl.getVeranstaltungen(key)) == set(self.ctrl.getVeranstaltungen(key))) def onMenuItem_BatchStudUndDoz(self, event): dlg = wx.DirDialog(self, "Verzeichnis für Batch-Export auswählen") if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() dlg.Destroy() batchCtrl = copy.deepcopy(self.ctrl) dlg = RunningBatchExportDialog(parent=self, text="Batch-Export gestartet:\n\n", title="Batch-Export", ctrl=batchCtrl, path=path) dlg.ShowModal() dlg.Destroy() def onMenuItem_EuI(self, event): webbrowser.open(STUNDENPLAN_SITE_EuI, autoraise=True) def onMenuItem_EuI_load(self, event): try: sys.stdin = urllib.urlopen(STUNDENPLAN_URL_EuI) self.ctrl = Controller(inFileName=None, outFileName=None) self.infoString.SetLabel(self.space + "HAW-Kalender: " + self.ctrl.getInfoString()) self.fillTrees() self.updateExportButton() self.menuItem_AlleSemUndDoz.Enable() except IOError as e: print "Could not open EuI-url: " + str(e) def onMenuItem_Inf(self, event): webbrowser.open(STUNDENPLAN_SITE_Inf, autoraise=True) def onMenuItem_Inf_load(self, event): try: sys.stdin = urllib.urlopen(STUNDENPLAN_URL_Inf) self.ctrl = Controller(inFileName=None, outFileName=None) self.infoString.SetLabel(self.space + "HAW-Kalender: " + self.ctrl.getInfoString()) self.fillTrees() self.updateExportButton() self.menuItem_AlleSemUndDoz.Enable() except IOError as e: print "Couldn't open Inf-url: " + str(e) def onMenuItem_GoogleCalendar(self, event): webbrowser.open("http://www.google.com/calendar", autoraise=True) def onMenuItem_rfc5545(self, event): webbrowser.open("http://tools.ietf.org/html/rfc5545/", autoraise=True) def onMenuItem_Anleitung(self, event): text_unicode = texts.anleitung.decode("utf-8") dlg = ScrollableDialog(None, text_unicode, title="Anleitung") dlg.ShowModal() dlg.Destroy() def onMenuItem_GPL(self, event): text = texts.gpl text = " " + text.replace("\n", "\n ") text_unicode = text.decode("utf-8") dlg = ScrollableDialog(self, text_unicode, title="GPL") dlg.ShowModal() dlg.Destroy() def onMenuItem_About(self, event): text = texts.version + "\n\n" + texts.homepage + "\n\n" + texts.about text_unicode = text.decode("utf-8") dlg = wx.MessageDialog(self, text_unicode, caption="About", style=wx.OK) dlg.ShowModal() dlg.Destroy()