def load_plugins(self): logger.info("Loading slack plugins...") plugin_files = glob.glob(self.plugins_dir + os.sep + "**" + os.sep + "[!__]*.py", recursive=True) for plugin_path in plugin_files: relative_path = os.path.relpath(plugin_path, os.getcwd()) import_path = relative_path.replace(".py", "").replace(os.sep, ".") for event_type in self.event_types: plugin = Plugin(event_type, importlib.import_module(import_path)) if plugin.callback is not None: if hasattr(self.bolt, plugin.type): event_handler: callable = getattr( self.bolt, plugin.type) event_handler(plugin.keyword)(plugin.callback) self.plugins.append(plugin)
def test_apply_cutting_overlap(self): """Test Plugin.apply_cutting_overlap()!""" overlap = 20 plugin = Plugin() g = Graphic("arrow.svg") g.set_scale(HPGL.HPGL_SCALE, HPGL.HPGL_SCALE) paths = g.get_polyline() lengths = [] for path in paths: lengths.append(g.get_path_length(path=path)) plugin.apply_cutting_overlap(paths, overlap) for path, length in zip(paths, lengths): if path_is_closed(path): new_length = g.get_path_length(path=path) assert round(length + overlap, 10) == round(new_length, 10), "%s != %s" % (round( length + overlap, 10), round(new_length, 10)) else: assert round(length, 10) == round(new_length, 10), "%s != %s" % (round( length, 10), round(new_length, 10))