Example #1
0
 def test_two_replacements(self):
     """Test a target with a two replacement editors
     Basically copied from test_one_replacement, did not bother to factor
     out common code.
     """
     sample = os.path.join(self.test_files_dir, "two_replacements.sample")
     targetfile = os.path.join(self.test_files_dir, "two_replacements.conf")
     expected = os.path.join(self.test_files_dir,
                             "two_replacements.expected")
     thisincr = mock.Mock()
     thisincr.is_current.return_value = True
     thisincr.__int__ = mock.Mock()
     thisincr.__int__.return_value = 22
     backupfile = "{0}.backup.{1}".format(targetfile, int(thisincr))
     shutil.copy(sample, targetfile)
     tgt = target.Target()
     tgt.targetfile = targetfile
     tgt.edlist.append(
         editor.Editor("replace", 22, ("email", "*****@*****.**")))
     tgt.edlist.append(editor.Editor("replace", 22, ("myip", "1.2.3.4")))
     tgt.run_editors(thisincr)
     result = filecmp.cmp(targetfile, expected)
     self.assertTrue(result)
     if not result:
         print >> sys.stderr, "Failed result in {}".format(targetfile)
     else:
         os.unlink(targetfile)
     self.assertTrue(filecmp.cmp(backupfile, sample))
     os.unlink(backupfile)
Example #2
0
def Editor():
    NUMBER = editor.ListStore(
        ("is smaller than", 'lt', editor.SpinButton),
        ("is greater than", 'gt', editor.SpinButton),
        )
    Number = lambda: editor.ComboBox(NUMBER)

    STRING = editor.ListStore(
        ("contains", 'contains', editor.Entry),
        )
    String = lambda: editor.ComboBox(STRING)

    DATE = editor.ListStore(
        ("after", 'gt', editor.Calendar),
        ("before", 'lt', editor.Calendar),
        )
    Date = lambda: editor.ComboBox(DATE)

    FIELD = editor.ListStore(
        ("Date", 'day', Date),
        ("Revision", 'revision', Number),
        ("Author", 'author', String),
        )
    Field = lambda: editor.ComboBox(FIELD)

    return editor.Editor(Field)
Example #3
0
    def __init__(self):
        """
        On initialise le menu principal et les variables nécessaires au bon fonctionnement du client.
        """

        self.move_inputs = [0, 0]

        self.play = "Jouer"
        self.editor = "Editeur de niveaux"
        self.parameters = "Paramètres"
        self.main_menu = "Menu principal"

        self.mainMenu = draw.Menu(width / 4, height / 4, width / 2, height / 2,
                                  "NamCap", 20)
        self.mainMenu.addButton(self.play)
        self.mainMenu.addButton(self.editor)
        self.mainMenu.addButton(self.parameters)
        self.state = self.play

        self.div_x = 28
        self.div_y = 28

        self.game = objects.Game(self.div_x, self.div_y, "level.json")

        self.socket = None
        self.start_game()
        origin_x, origin_y, view_width, view_height, block_size = draw.define_viewport(
            self.div_x, self.div_y, True)
        self.editor_instance = editor.Editor(block_size, origin_x, origin_y,
                                             view_width, view_height,
                                             self.div_x, self.div_y)

        draw.set_viewport(self.div_x, self.div_y, True)
Example #4
0
 def test_one_replacement(self):
     """Test a target with a single replacement editor
     Before the test execution we copy the target file from a sample each
     time. Target will be removed on successful test execution. On
     failure it will be kept for debugging and overwritten on next test
     execution (no checks)
     """
     sample = os.path.join(self.test_files_dir, "one_replacement.sample")
     targetfile = os.path.join(self.test_files_dir, "one_replacement.conf")
     expected = os.path.join(self.test_files_dir,
                             "one_replacement.expected")
     thisincr = 10
     backupfile = "{0}.backup.{1}".format(targetfile, thisincr)
     shutil.copy(sample, targetfile)
     tgt = target.Target()
     tgt.targetfile = targetfile
     tgt.edlist.append(
         editor.Editor("replace", 10, ("email", "*****@*****.**")))
     thisincr = mock.Mock()
     thisincr.is_current.return_value = True
     thisincr.__int__ = mock.Mock()
     thisincr.__int__.return_value = 10
     tgt.run_editors(thisincr)
     result = filecmp.cmp(targetfile, expected)
     self.assertTrue(result)
     if not result:
         print >> sys.stderr, "Failed result in {}".format(targetfile)
     else:
         os.unlink(targetfile)
     self.assertTrue(filecmp.cmp(backupfile, sample))
     os.unlink(backupfile)
 def _insertar_editor(self, fuente, scope):
     componente = editor.Editor(self.main, scope, self)
     componente.definir_fuente(fuente)
     self.editor_placeholder.addWidget(componente)
     self.editor_placeholder.setCurrentWidget(componente)
     self.editor = componente
     self._cargar_resaltador_de_sintaxis()
Example #6
0
 def create_editor(self, parent):
     panel = wx.Panel(parent)
     self.editor = editor.Editor(panel)
     self.editor.Bind(stc.EVT_STC_CHANGE, self.on_text)
     sizer = wx.BoxSizer(wx.VERTICAL)
     sizer.Add(self.editor, 1, wx.EXPAND | wx.ALL, 5)
     panel.SetSizer(sizer)
     return panel
Example #7
0
 def new_editor(self, fpathname=''):
     ed = editor.Editor(self, fpathname)
     self.editors.append(ed)
     self.add(ed)
     # switch to newly opened tab
     index = self.editors.index(ed)
     self.select(index)
     self.after_click()
Example #8
0
 def test_contradicting_backup(self):
     """Exception must be raised if editor with contradicting backup
     policy on same target
     """
     tgt = target.Target()
     tgt.targetfile = "contradictive"
     tgt.edlist.append(editor.Editor("replace", 10, ("foo", "bar")))
     tgt.edlist.append(
         editor.Editor("copy_file", 10, ("location", "inputFile")))
     self.assertRaises(ValueError, tgt.backup)
     # in Python 2.7 we could have used assertRaises as context manager,
     # in the first place, but we need to support Python 2.6
     # (of course this could be coded differently using try, but the
     # assertRaises conveys the idea what we are doing)
     try:
         tgt.backup()
     except ValueError as exc:
         self.assertEqual( "Editors with incompatible backup policy for " \
                          "contradictive", str(exc))
Example #9
0
 def __init__(self):
     self.editor = editor.Editor()
     self.walker = walker.Walker(focus_attr='dropdown_walk')
     super(DropDown,
           self).__init__(header=urwid.AttrMap(self.editor,
                                               attr_map='dropdown_editor'),
                          body=urwid.AttrMap(self.walker,
                                             attr_map='dropdown_plain'),
                          focus_part='header')
     # The longest string in the options range. Updated in set_content()
     self.max_width = 1
     self.selection = ''  # The selected option returned to handling widget
     self._selectable = False
Example #10
0
 def edit(self, path):
     """Edits Song obj with path."""
     song = [song for song in self.book
             if song.data()[0] == path][0]  # find obj
     editor = e.Editor()  # create editor window
     new_data = editor.load(*song.data())  # returned data from editor
     if new_data[1] == 'code 01: restore default':
         # 'Restore' pressed in editor
         song.id3_data()
     else:
         # 'Save' pressed in editor
         song.song_data = new_data
         song.edit_flag = True  # flag that obj edited
Example #11
0
    def __init__(self):
        Gtk.Window.__init__(self, title="Noted")
        self.set_border_width(5)
        self.set_size_request(1100, 900)
        self.set_resizable(False)
        # Header Bar
        hbar = hb.Headerbar()
        hbar.connect("destroy", self.close_database)
        self.set_titlebar(hbar)

        # Notebook button
        hbar.notebook_button.connect("clicked", self.create_notebook)

        # Create Button
        hbar.create_button.connect("clicked", self.create_note)

        # Save button
        hbar.save_button.connect("clicked", self.save_note)

        # Delete Button
        hbar.delete_button.connect("clicked", self.delete_note)

        #shortcuts
        self.connect("key-press-event", self.on_key_press)

        # MAIN WINDOW
        main_window = Gtk.Grid(column_homogeneous=False, column_spacing=5)

        # SIDEBAR
        self.sidebar = sb.Sidebar()
        self.sidebar.view.connect("row_activated", self.show_note)
        self.sidebar.view.connect('button-release-event',
                                  self.show_sidebar_options)
        self.sidebar.sidebar_options['new'].connect('activate',
                                                    self.create_note)
        self.sidebar.sidebar_options['delete'].connect('activate',
                                                       self.delete_note)
        self.sidebar.sidebar_options['restore'].connect(
            'activate', self.restore_note)

        # EDITOR
        self.editor = editor.Editor(self)

        # loads the storage file and creates the dict db
        self.start_database()

        main_window.attach(self.sidebar, 0, 0, 1, 2)
        main_window.attach(self.editor, 1, 0, 2, 1)
        self.add(main_window)
Example #12
0
 def __init__(self):
     self.e_ratio = base.SCREEN_WIDTH//self.e_ratio - \
         (base.SCREEN_WIDTH // self.e_ratio) % 3
     econ_dim = base.Vec2d(self.e_ratio - self.econ_offset*2,
                           base.SCREEN_HEIGHT - self.econ_offset*2)
     bcon_dim = base.Vec2d(base.SCREEN_WIDTH-self.e_ratio - self.bcon_offset*2,
                           base.SCREEN_HEIGHT - self.bcon_offset*2)
     board_con = tcod.console.Console(bcon_dim.x,
                                      bcon_dim.y)
     editor_con = tcod.console.Console(econ_dim.x,
                                       econ_dim.y)
     self.board = board.Board(board_con, self.e_ratio, bcon_dim)
     self.editor = editor.Editor(editor_con, 0, econ_dim)
     self.editor.update_keymap(self.board.get_prop_at(self.editor.cursor),
                               self.board.get_name_at(self.editor.cursor))
Example #13
0
    def checar_colisoes(self):
        self.jogador.status["Moedas"] += self.checar_colisao_de_um_ator(
            self.jogador, self.lista_atores[3], 1)

        if self.checar_colisao_de_um_ator(self.jogador, self.lista_atores[4],
                                          0):
            self.jogador.kill()
            self.sair = True
            dados.parar_musica()
            self.lista_sons["game_over"].play()
            ed = editor.Editor(self.screen, self.jogador.status["Distancia"],
                               self.jogador.status["Moedas"])
            nome = ed.loop()
            dados.add_jogador_ranking(nome, self.jogador.status["Distancia"],
                                      self.jogador.status["Moedas"])
Example #14
0
 def test_replacement_input_missing(self):
     """Call a replacement editor without the target existing"""
     targetfile = os.path.join(self.test_files_dir, "one_replacement.conf")
     thisincr = mock.Mock()
     tgt = target.Target()
     tgt.targetfile = targetfile
     tgt.edlist.append(
         editor.Editor("replace", 10, ("email", "*****@*****.**")))
     self.assertRaises(IOError, tgt.run_editors, thisincr)
     # see comment about Python 2.7 above
     try:
         tgt.run_editors(thisincr)
     except IOError as exc:
         self.assertEqual(
             "Target file {0} does not exist or is not "
             "a regular file".format(targetfile), str(exc))
  def test_invokeEditor(self):
    # lets just reuse the files from TestEdfuncs.test_replaceSucessful
    # we could also use a mock object for edfuncs, but the real one
    # seems to be reasonably simple so we don't
    iFileName = os.path.join( self.testFilesDir , "replace1.in" )
    oFileName = os.path.join( self.testFilesDir , "editor.out-"
                                        + datetime.datetime.now().isoformat())

    edi = editor.Editor( "replace" , 10 , ( "toBeReplaced" , "replacement" ))
    edi.run_it( iFileName , oFileName )

    oFileNameExpected = os.path.join( self.testFilesDir , "replace1.out.expected" )
    result = filecmp.cmp( oFileName , oFileNameExpected )
    if result:
      os.unlink(oFileName)
    else:
      print >>sys.stderr , "\nUnexpected result in" , oFileName
    self.assertTrue( result )
Example #16
0
    def run(self):

        error_msg = self.read_settings()

        if error_msg != 0:
            print error_msg
            return

        r = praw.Reddit(client_id=self.CLIENT_ID,
                        client_secret=self.CLIENT_SECRET,
                        redirect_uri=self.REDIRECT_URI,
                        user_agent=self.USER_AGENT)
        
        r.refresh_access_information(self.REFRESH_TOKEN)        

        if self.TEAM_TIME_ZONE == 'ET':
            time_info = (self.TEAM_TIME_ZONE,0)
        elif self.TEAM_TIME_ZONE == 'CT':
            time_info = (self.TEAM_TIME_ZONE,1)
        elif self.TEAM_TIME_ZONE == 'MT':
            time_info = (self.TEAM_TIME_ZONE,2)
        elif self.TEAM_TIME_ZONE == 'PT':
            time_info = (self.TEAM_TIME_ZONE,3)
        else:
            print "Invalid time zone settings."
            return

        edit = editor.Editor(time_info, self.PRE_THREAD_SETTINGS,
                self.THREAD_SETTINGS, self.POST_THREAD_SETTINGS)

        if self.BOT_TIME_ZONE == 'ET':
            time_before = self.POST_TIME * 60 * 60
        elif self.BOT_TIME_ZONE == 'CT':
            time_before = (1 + self.POST_TIME) * 60 * 60
        elif self.BOT_TIME_ZONE == 'MT':
            time_before = (2 + self.POST_TIME) * 60 * 60
        elif self.BOT_TIME_ZONE == 'PT':
            time_before = (3 + self.POST_TIME) * 60 * 60
        else:
            print "Invalid bot time zone settings."
            return
Example #17
0
    def run(self):

        error_msg = self.read_settings()

        if error_msg != 0:
            print error_msg
            return

        r = praw.Reddit('OAuth Baseball-GDT-Bot V. 3.0.1'
                        'https://github.com/mattabullock/Baseball-GDT-Bot')
        r.set_oauth_app_info(client_id=self.CLIENT_ID,
                            client_secret=self.CLIENT_SECRET,
                            redirect_uri=self.REDIRECT_URI)        
        r.refresh_access_information(self.REFRESH_TOKEN)        

        if self.TEAM_TIME_ZONE == 'ET':
            time_info = (self.TEAM_TIME_ZONE,0)
        elif self.TEAM_TIME_ZONE == 'CT':
            time_info = (self.TEAM_TIME_ZONE,1)
        elif self.TEAM_TIME_ZONE == 'MT':
            time_info = (self.TEAM_TIME_ZONE,2)
        elif self.TEAM_TIME_ZONE == 'PT':
            time_info = (self.TEAM_TIME_ZONE,3)
        else:
            print "Invalid time zone settings."
            return

        edit = editor.Editor(time_info, self.PRE_THREAD_SETTINGS,
                self.THREAD_SETTINGS, self.POST_THREAD_SETTINGS)

        if self.BOT_TIME_ZONE == 'ET':
            time_before = self.POST_TIME * 60 * 60
        elif self.BOT_TIME_ZONE == 'CT':
            time_before = (1 + self.POST_TIME) * 60 * 60
        elif self.BOT_TIME_ZONE == 'MT':
            time_before = (2 + self.POST_TIME) * 60 * 60
        elif self.BOT_TIME_ZONE == 'PT':
            time_before = (3 + self.POST_TIME) * 60 * 60
        else:
            print "Invalid bot time zone settings."
            return
Example #18
0
 def test_copy_file_exists(self):
     """Make sure and editor with backup = False fails if the target
     file exists already before.
     """
     # Just reuse some files from before.
     infile = os.path.join(self.test_files_dir, "two_replacements.sample")
     targetfile = os.path.join(self.test_files_dir,
                               "two_replacements.expected")
     thisincr = mock.Mock()
     tgt = target.Target()
     tgt.targetfile = targetfile
     tgt.edlist.append(
         editor.Editor("copy_file", thisincr, ("location", infile)))
     self.assertRaises(IOError, tgt.run_editors, thisincr)
     # see comment about Python 2.7 above
     try:
         tgt.run_editors(thisincr)
     except IOError as exc:
         self.assertEqual(
             "Target file {0} already "
             "exists".format(targetfile), str(exc))
Example #19
0
def process(folders,
            output,
            fixed_columns,
            merge_columns,
            ignore_columns,
            remove_content,
            custom_headers,
            custom_columns,
            expect_new_columns,
            new_columns_regex,
            separator=u','):
    ed = editor.Editor()
    sp = splitter.Splitter(separator)
    mg = merger.Merger(separator=separator,
                       fixed_columns=fixed_columns,
                       ignore_columns=ignore_columns,
                       merge_columns=merge_columns,
                       expect_new_columns=expect_new_columns,
                       new_columns_regex=new_columns_regex)

    ed.remove_content_in_processing(remove_content)
    ed.remove_empty_columns_in_processing()
    ed.trim_in_processing()
    ed.expand_rows_in_processing()
    ed.skip_files_in_processing(output)
    ed.set_headers_in_processing(custom_headers)

    for column in custom_columns:
        ed.add_columns_in_processing(*column)

    ed.collapse_headers_in_processing(fixed_columns, merge_columns,
                                      ignore_columns)

    for folder in folders:
        csvs = sp.split_folder(folder)
        ed.process(folder)
        mg.merge_folder(folder, output)
        for files in csvs:
            easyio.remove(csvs[files])
Example #20
0
    def __init__(self):
        Gtk.Window.__init__(self, title="Noted")
        self.set_border_width(5)
        self.set_size_request(1000, 800)

        #Header Bar
        hbar = hb.Headerbar()
        hbar.connect("destroy", self.close_database)
        self.set_titlebar(hbar)

        #Notebook button
        hbar.notebook_button.connect("clicked", self.create_notebook)

        #Create Button
        hbar.create_button.connect("clicked", self.create_note)

        #Save button
        hbar.save_button.connect("clicked", self.save_note)

        #Delete Button
        hbar.delete_button.connect("clicked", self.delete_note)

        # MAIN WINDOW
        main_window = Gtk.Grid(column_homogeneous=False, column_spacing=5)

        #SIDEBAR
        self.sidebar = sb.Sidebar()
        self.sidebar.view.connect("row_activated", self.show_note)

        #EDITOR
        self.editor = editor.Editor()

        #loads the storage file and creates the dict db
        self.start_database()

        main_window.attach(self.sidebar, 0, 0, 1, 2)
        main_window.attach(self.editor, 1, 0, 2, 1)
        self.add(main_window)
Example #21
0
    def on_key_press(self, symbol, modifiers):
        if globals.game.player.input_disabled:
            return

        if symbol == key.ESCAPE:
            if globals.game.in_menu:
                globals.game.leave_menu()
            else:
                globals.game.go_menu('menu')
                globals.game.enter_menu()
        elif symbol == key.SPACE:
            if globals.game.in_menu:
                globals.game.leave_menu()
            else:
                globals.game.go_menu('flipbook')
                globals.game.enter_menu()
        elif symbol == key.N and modifiers & key.MOD_ACCEL:
            globals.game.new_game()
            globals.game.leave_menu()
        elif symbol == key.E and modifiers & key.MOD_ACCEL:  # CHEAT
            self.push_handlers(editor.Editor())
        elif globals.game.in_menu:
            globals.game.menu_advance()
Example #22
0
 def __init__(self, templatefile, mcfgfile):
     self.targetlist = []
     template_ini = ConfigParser.SafeConfigParser()
     files = template_ini.read(templatefile)
     if files != [templatefile]:
         # in theory there could also be more than one, but let's keep 
         # the error message simple
         raise IOError, "Template {0} not found".format(templatefile)
     master_ini = ConfigParser.SafeConfigParser()
     files = master_ini.read(mcfgfile)
     if files != [ mcfgfile ] :
         # as above
         raise IOError, "Master config file {0} not found".format(mcfgfile)
     for sec in template_ini.sections():
         tgt = target.Target()
         for (name, value) in template_ini.items(sec):
             if name == self.SPECIAL_FILENAME:
                 tgt.targetfile = value
             else:
                 incr, edname = self.parsevalue(value)
                 edi = editor.Editor(edname, incr,
                                     (name, master_ini.get(sec, name)))
                 tgt.edlist.append(edi)
         self.targetlist.append(tgt)
Example #23
0
    def run(self):

        error_msg = self.read_settings()

        if error_msg != 0:
            print error_msg
            return

        r = praw.Reddit('OAuth Baseball-GDT-Bot V. 3.0.1'
                        'https://github.com/mattabullock/Baseball-GDT-Bot')
        r.set_oauth_app_info(client_id=self.CLIENT_ID,
                             client_secret=self.CLIENT_SECRET,
                             redirect_uri=self.REDIRECT_URI)
        r.refresh_access_information(self.REFRESH_TOKEN)

        if self.TEAM_TIME_ZONE == 'ET':
            time_info = (self.TEAM_TIME_ZONE, 0)
        elif self.TEAM_TIME_ZONE == 'CT':
            time_info = (self.TEAM_TIME_ZONE, 1)
        elif self.TEAM_TIME_ZONE == 'MT':
            time_info = (self.TEAM_TIME_ZONE, 2)
        elif self.TEAM_TIME_ZONE == 'PT':
            time_info = (self.TEAM_TIME_ZONE, 3)
        else:
            print "Invalid time zone settings."
            return

        edit = editor.Editor(time_info, self.PRE_THREAD_SETTINGS,
                             self.THREAD_SETTINGS, self.POST_THREAD_SETTINGS)

        if self.BOT_TIME_ZONE == 'ET':
            time_before = self.POST_TIME * 60 * 60
        elif self.BOT_TIME_ZONE == 'CT':
            time_before = (1 + self.POST_TIME) * 60 * 60
        elif self.BOT_TIME_ZONE == 'MT':
            time_before = (2 + self.POST_TIME) * 60 * 60
        elif self.BOT_TIME_ZONE == 'PT':
            time_before = (3 + self.POST_TIME) * 60 * 60
        else:
            print "Invalid bot time zone settings."
            return

        timechecker = timecheck.TimeCheck(time_before)

        while True:
            today = datetime.today()

            url = "http://gd2.mlb.com/components/game/mlb/"
            url = url + "year_" + today.strftime(
                "%Y") + "/month_" + today.strftime(
                    "%m") + "/day_" + today.strftime("%d") + "/"

            response = ""
            while not response:
                try:
                    response = urllib2.urlopen(url)
                except:
                    print "Couldn't find URL, trying again..."
                    time.sleep(20)

            html = response.readlines()
            directories = []
            for v in html:
                if self.TEAM_CODE in v:
                    v = v[v.index("\"") + 1:len(v)]
                    v = v[0:v.index("\"")]
                    directories.append(url + v)

            if self.PREGAME_THREAD and len(directories) > 0:
                timechecker.pregamecheck(self.PRE_THREAD_SETTINGS[1])
                title = edit.generate_title(directories[0], "pre")
                while True:
                    try:
                        posted = False
                        subreddit = r.get_subreddit(self.SUBREDDIT)
                        for submission in subreddit.get_new():
                            if submission.title == title:
                                print "Pregame thread already posted, getting submission..."
                                submission.edit(
                                    edit.generate_pre_code(directories))
                                posted = True
                                break
                        if not posted:
                            print "Submitting pregame thread..."
                            if self.STICKY and 'sub' in locals():
                                sub.unsticky()
                            sub = r.submit(self.SUBREDDIT, title,
                                           edit.generate_pre_code(directories))
                            print "Pregame thread submitted..."
                            if self.STICKY:
                                print "Stickying submission..."
                                sub.sticky()
                                print "Submission stickied..."
                            print "Sleeping for two minutes..."
                            print datetime.strftime(datetime.today(),
                                                    "%d %I:%M %p")
                            time.sleep(5)
                        break
                    except Exception, err:
                        print err
                        time.sleep(300)

            for d in directories:
                timechecker.gamecheck(d)
                title = edit.generate_title(d, "game")
                if not timechecker.ppcheck(d):
                    while True:
                        check = datetime.today()
                        try:
                            posted = False
                            subreddit = r.get_subreddit(self.SUBREDDIT)
                            for submission in subreddit.get_new():
                                if submission.title == title:
                                    print "Thread already posted, getting submission..."
                                    sub = submission
                                    posted = True
                                    break
                            if not posted:
                                if self.STICKY and 'sub' in locals():
                                    sub.unsticky()

                                print "Submitting game thread..."
                                sub = r.submit(self.SUBREDDIT, title,
                                               edit.generate_code(d, "game"))
                                print "Game thread submitted..."

                                if self.STICKY:
                                    print "Stickying submission..."
                                    sub.sticky()
                                    print "Submission stickied..."

                                if self.SUGGESTED_SORT != None:
                                    print "Setting suggested sort to " + self.SUGGESTED_SORT + "..."
                                    sub.set_suggested_sort(self.SUGGESTED_SORT)
                                    print "Suggested sort set..."

                                if self.MESSAGE:
                                    print "Messaging Baseballbot..."
                                    r.send_message('baseballbot',
                                                   'Gamethread posted',
                                                   sub.short_link)
                                    print "Baseballbot messaged..."

                            print "Sleeping for two minutes..."
                            print datetime.strftime(check, "%d %I:%M %p")
                            time.sleep(5)
                            break
                        except Exception, err:
                            print err
                            time.sleep(300)

                    pgt_submit = False

                    while True:
                        check = datetime.today()
                        str = edit.generate_code(d, "game")
                        while True:
                            try:
                                sub.edit(str)
                                print "Edits submitted..."
                                print "Sleeping for two minutes..."
                                print datetime.strftime(check, "%d %I:%M %p")
                                time.sleep(120)
                                break
                            except Exception, err:
                                print "Couldn't submit edits, trying again..."
                                print datetime.strftime(check, "%d %I:%M %p")
                                time.sleep(10)

                        if "|Decisions|" in str:
                            check = datetime.today()
                            print datetime.strftime(check, "%d %I:%M %p")
                            print "Game final..."
                            pgt_submit = True
                        elif "##COMPLETED EARLY" in str:
                            check = datetime.today()
                            print datetime.strftime(check, "%d %I:%M %p")
                            print "Completed Early..."
                            pgt_submit = True
                        elif "##FINAL: TIE" in str:
                            check = datetime.today()
                            print datetime.strftime(check, "%d %I:%M %p")
                            print "Game final (tie)..."
                            pgt_submit = True
                        elif "##POSTPONED" in str:
                            check = datetime.today()
                            print datetime.strftime(check, "%d %I:%M %p")
                            print "Game postponed..."
                            pgt_submit = True
                        elif "##SUSPENDED" in str:
                            check = datetime.today()
                            print datetime.strftime(check, "%d %I:%M %p")
                            print "Game suspended..."
                            pgt_submit = True
                        elif "##CANCELLED" in str:
                            check = datetime.today()
                            print datetime.strftime(check, "%d %I:%M %p")
                            print "Game cancelled..."
                            pgt_submit = True
                        if pgt_submit:
                            if self.STICKY and 'sub' in locals():
                                sub.unsticky()

                            if self.POST_GAME_THREAD:
                                print "Submitting postgame thread..."
                                posttitle = edit.generate_title(d, "post")
                                sub = r.submit(self.SUBREDDIT, posttitle,
                                               edit.generate_code(d, "post"))
                                print "Postgame thread submitted..."

                                if self.STICKY:
                                    print "Stickying submission..."
                                    sub.sticky()
                                    print "Submission stickied..."
                            break
                        time.sleep(10)
Example #24
0
 def widget(self, dlg):
     import editor
     return editor.Editor(dlg)
Example #25
0
 def browseImage(self):
     filter = "JPG (*.jpg);;PNG (*.png);;JPEG (*.jpeg)"
     name = QFileDialog.getOpenFileName(self, 'Select Image', '', filter)
     if name[0]:
         self.obj = editor.Editor(name[0])
Example #26
0
'''
Created on May 20, 2020M

@author: christophe
'''
import editor

if __name__ == '__main__':
    pass

editor.Editor()
Example #27
0
 def open_note(self, event):
     a = self.note_list.GetString(self.note_list.GetSelection())
     editor.Editor(None, note_name=a)
Example #28
0
try:
    import editor

except ImportError as e:
    import sys
    sys.exit("editor.py module missing.")

if __name__ == '__main__':
    edit = editor.Editor()
    edit.editor()
Example #29
0
        "SpamRespawnFall", "LaserMaze", "EarlyJump"
    ] + levels_with_number("Escalator", 1, 3) +
    levels_with_number("DeathlockIntro", 1, 4) + ["DeathlockTiming"] +
    levels_with_number("DeathlockMomentum", 1, 5) + ["DeathlockBlock"] +
    ["DeadMansTrampoline", "DeadMansRightPuncher", "AvoidTheFirst"] +
    levels_with_number("Pole", 1, 2) +
    levels_with_number("DoubleFallPunch", 1, 2) +
    levels_with_number("Ledge", 1, 2) +
    ["DeathlockHeadBonk", "DoubleTriple", "EverythingClimb"] +
    levels_with_number("Haul", 1, 4) + [
        "DoublePunchHaul", "CheckpointHaul", "BackAndForthHaul",
        "UsefulSpawnHaul"
    ] + levels_with_number("End", 1, 6))
sequence = sequences.Sequence(level_names)

editor = editor.Editor(sequence)

SWAP_TO_EDITOR = 0
NEXT_LEVEL = 1
level_beat_mode = NEXT_LEVEL

main_cam = camera.Camera()
main_cam.base_x = 0
main_cam.base_y = 0

player = entities.player.Player(sequence.current, main_cam)

entity_handler = entities.handler.Handler()
entity_handler.list = [player]

static_level_surf = pygame.Surface((const.SCRN_W, const.SCRN_H))
Example #30
0
    def start(self):
        pygame.init()
        pygame.display.set_caption("New map info")
        self.bg.fill(pygame.Color("#14005e"))
        while True:
            self.timer.tick(200)
            for e in pygame.event.get():
                if e.type == pygame.QUIT:
                    sys.exit()
                if e.type == pygame.KEYDOWN and e.key == pygame.K_ESCAPE:
                    menu.Menu()
                if e.type == pygame.KEYDOWN and e.key == pygame.K_LEFT:
                    self.active -= 1
                if e.type == pygame.KEYDOWN and e.key == pygame.K_RIGHT:
                    self.active += 1
                if e.type == pygame.KEYDOWN and e.key == pygame.K_RETURN:
                    self.width = int(self.width_text)
                    self.height = int(self.height_text)
                    if 5 <= self.width <= 25 and 5 <= self.height <= 25:
                        ed = editor.Editor(self.width, self.height)
                elif e.type == pygame.KEYDOWN:
                    if e.key == pygame.K_BACKSPACE:
                        if self.active % 2 == 1:
                            self.width_text = self.width_text[:-1]
                        else:
                            self.height_text = self.height_text[:-1]
                    else:
                        if self.active % 2 == 1:
                            self.width_text += e.unicode
                        else:
                            self.height_text += e.unicode
            self.screen.blit(self.bg, (0, 0))
            font = pygame.font.Font(None, 25)
            text = font.render("Input count of blocks in field",
                               True, (255, 255, 255))
            self.screen.blit(text, [10, 15])
            text = font.render("min = 5, max = 25", True, (255, 255, 255))
            self.screen.blit(text, [10, 40])
            text = font.render("Width", True, (255, 255, 255))
            self.screen.blit(text, [10, 70])
            text = font.render("Height", True, (255, 255, 255))
            self.screen.blit(text, [100, 70])
            if self.active % 2 == 1:
                font = pygame.font.Font(None, 40)

                pf = pygame.Surface((80, 50))
                pf.fill(pygame.Color(self.active_color))
                self.screen.blit(pf, (10, 100))

                text = font.render(self.width_text, True, (255, 255, 255))
                self.screen.blit(text, [30, 110])

                pf.fill(pygame.Color(self.inactive_color))
                self.screen.blit(pf, (100, 100))

                text = font.render(self.height_text, True, (255, 255, 255))
                self.screen.blit(text, [120, 110])
            else:
                font = pygame.font.Font(None, 40)

                pf = pygame.Surface((80, 50))
                pf.fill(pygame.Color(self.inactive_color))
                self.screen.blit(pf, (10, 100))

                text = font.render(self.width_text, True, (255, 255, 255))
                self.screen.blit(text, [30, 110])

                pf.fill(pygame.Color(self.active_color))
                self.screen.blit(pf, (100, 100))

                text = font.render(self.height_text, True, (255, 255, 255))
                self.screen.blit(text, [120, 110])

            try:
                self.width = int(self.width_text)
                if not 5 <= self.width <= 25:
                    pf = pygame.Surface((80, 50))
                    pf.fill(pygame.Color("#ff0000"))
                    self.screen.blit(pf, (10, 100))
                    text = font.render(self.width_text, True, (255, 255, 255))
                    self.screen.blit(text, [30, 110])
            except:
                pf = pygame.Surface((80, 50))
                pf.fill(pygame.Color("#ff0000"))
                self.screen.blit(pf, (10, 100))
                text = font.render(self.width_text, True, (255, 255, 255))
                self.screen.blit(text, [30, 110])

            try:
                self.height = int(self.height_text)
                if not 5 <= self.height <= 25:
                    pf = pygame.Surface((80, 50))
                    pf.fill(pygame.Color("#ff0000"))
                    self.screen.blit(pf, (100, 100))
                    text = font.render(self.height_text, True, (255, 255, 255))
                    self.screen.blit(text, [120, 110])
            except:
                pf = pygame.Surface((80, 50))
                pf.fill(pygame.Color("#ff0000"))
                self.screen.blit(pf, (100, 100))
                text = font.render(self.height_text, True, (255, 255, 255))
                self.screen.blit(text, [120, 110])
            pygame.display.update()