def setup(caller): global name_entry, exclude_patterns, compression_combobox, compression_level_label, remove_button global compression_level_spinbutton, checkpoint_re, include_liststore, preview_not_setup, filetree_obj checkpoint_re = re.compile(r'.*\.checkpoint(\.[0-9]+)?') builder = Gtk.Builder.new_from_file('../data/ui/create.ui') common.stack.add_named(builder.get_object('form_grid'), 'create_form') name_entry = builder.get_object('name_entry') name_entry.empty_popover = common.error_popover(name_entry, 'A name is required', Gtk.PositionType.TOP) name_entry.checkpoint_popover = common.error_popover( name_entry, "The '.checkpoint' and '.checkpoint.N' phrases are not allowed", Gtk.PositionType.TOP) name_entry.exists_popover = common.error_popover( name_entry, 'This archive already exists', Gtk.PositionType.TOP) exclude_patterns = patterns.Patterns() patterns_grid = builder.get_object('patterns_grid') patterns_grid.attach(exclude_patterns.grid, 0, 4, 1, 1) compression_combobox = builder.get_object('compression_combobox') compression_level_label = builder.get_object('compression_level_label') compression_level_spinbutton = builder.get_object( 'compression_level_spinbutton') include_liststore = builder.get_object('include_liststore') path_selection = builder.get_object('path_selection') remove_button = builder.get_object('remove_button') filetree_obj = filetree.FileTree(True) process.write_add_tree(filetree_obj) preview_not_setup = True builder.connect_signals({ 'block_slash': common.block_slash, 'compression_set': compression_set, 'start': start, 'preview': preview, 'add_path': add_path, 'selection_changed': (patterns.selection_changed, remove_button), 'remove_path': (patterns.remove_pattern, path_selection) }) caller.disconnect(button_signal_id) caller.connect('clicked', transitions.to_create_form) transitions.to_create_form(caller)
def test_part_one(self): "Test part one example of Patterns object" # 1. Create Patterns object from text myobj = patterns.Patterns(text=aoc_08.from_text(PART_ONE_TEXT)) # 2. Check the part one result self.assertEqual(myobj.part_one(verbose=False), PART_ONE_RESULT)
def test_part_two(self): "Test part two example of Patterns object" # 1. Create Patterns object from text myobj = patterns.Patterns(part2=True, text=aoc_08.from_text(PART_TWO_TEXT)) # 2. Check the part two result self.assertEqual(myobj.part_two(verbose=False), PART_TWO_RESULT)
def test_empty_init(self): "Test the default Patterns creation" # 1. Create default Patterns object myobj = patterns.Patterns() # 2. Make sure it has the default values self.assertEqual(myobj.part2, False) self.assertEqual(myobj.text, None)
def test_text_init(self): "Test the Patterns object creation from text" # 1. Create Patterns object from text myobj = patterns.Patterns(text=aoc_08.from_text(EXAMPLE_TEXT)) # 2. Make sure it has the expected values self.assertEqual(myobj.part2, False) self.assertEqual(len(myobj.text), 10) # 3. Check methods self.assertEqual(myobj.one_four_seven_eight(), 26)
def part_two(args, input_lines): "Process part two of the puzzle" # 1. Create the puzzle solver solver = patterns.Patterns(part2=True, text=input_lines) # 2. Determine the solution for part two solution = solver.part_two(verbose=args.verbose, limit=args.limit) if solution is None: print("There is no solution") else: print("The solution for part two is %s" % (solution)) # 3. Return result return solution is not None
intents: discord.Intents = discord.Intents.default() # Block out all the stuff we don't care about intents.typing = False intents.integrations = False intents.webhooks = False intents.invites = False intents.voice_states = False # Sign on for these privileged intents intents.members = True intents.presences = True # create the bot bot = commands.Bot(command_prefix=command_prefix, intents=intents) # initialise some of my own stuffs patterns = patterns.Patterns(bot) scriptProcessor = PipelineProcessor(bot, pipe_prefix) @bot.event async def on_ready(): print() print('---------------- BOT READY ----------------') print(' Username:'******' ID:', bot.user.id) print(' Servers:', ', '.join(g.name for g in bot.guilds)) print(' Running discord.py %s' % discord.__version__) print(' Time: ' + datetime.now().strftime('%c')) print('-------------------------------------------') print()