How to use the aeidon.deco.silent function in aeidon

To help you get started, we’ve selected a few aeidon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github otsaloma / gaupol / gaupol / dialogs / multi_save.py View on Github external
    @aeidon.deco.silent(gaupol.Default)
    def _save_all_documents_as(self):
        """Save all documents with selected properties."""
        pages = self._get_pages()
        files = [None for x in pages]
        for i, page in enumerate(pages):
            if self._framerate_combo.get_visible():
                # Set framerate to the selected one.
                framerate = self.get_framerate()
                self.application.set_current_page(page)
                action = self.application.get_action("set-framerate")
                action.activate(str(framerate))
            path = os.path.basename(page.project.main_file.path)
            path = aeidon.util.replace_extension(path, self.get_format())
            path = os.path.join(self.get_directory(), path)
            files[i] = aeidon.files.new(self.get_format(),
                                        path,
github otsaloma / gaupol / gaupol / dialogs / search.py View on Github external
    @aeidon.deco.silent(gaupol.Default)
    def previous(self):
        """Find the previous match of pattern."""
        page = self.application.get_current_page()
        row, doc, pos = self._get_position(next=False)
        pages = self.application.pages[::-1]
        i = pages.index(page)
        # Loop twice over the current page,
        # since starting in the middle.
        for page in (pages[i:] + pages[:i+1]):
            self._set_pattern(page)
            try:
                # Return match in page before position.
                row, doc, span = page.project.find_previous(row, doc, pos)
                return self._set_success_state(page, row, doc, span, next=False)
            except StopIteration:
                target = gaupol.conf.search.target
github otsaloma / gaupol / gaupol / agents / open.py View on Github external
    @aeidon.deco.silent(gaupol.Default)
    def _on_open_main_files_activate(self, *args):
        """Open main files."""
        doc = aeidon.documents.MAIN
        paths, encoding = self._select_files(_("Open"), doc)
        self.open_main(paths, encoding)
github otsaloma / gaupol / gaupol / agents / open.py View on Github external
    @aeidon.deco.silent(gaupol.Default)
    def open_main(self, path, encoding=None):
        """Open file at `path` as a main file."""
        if gaupol.fields.TRAN_TEXT in gaupol.conf.editor.visible_fields:
            gaupol.conf.editor.visible_fields.remove(gaupol.fields.TRAN_TEXT)
        encodings = self._get_encodings(encoding)
        gaupol.util.set_cursor_busy(self.window)
        for path in aeidon.util.flatten([path]):
            try:
                # Skip files that are already open,
                # but show a status message when that happens.
                self._check_file_not_open(path)
            except gaupol.Default:
                continue
            try:
                page = self._open_file(path, encodings, aeidon.documents.MAIN)
            except gaupol.Default:
github otsaloma / gaupol / gaupol / agents / save.py View on Github external
    @aeidon.deco.silent(gaupol.Default)
    def _on_save_main_document_activate(self, *args):
        """Save the current main document."""
        page = self.get_current_page()
        self.save_main(page)
        self.update_gui()
github otsaloma / gaupol / gaupol / dialogs / search.py View on Github external
    @aeidon.deco.silent(gaupol.Default)
    def next(self):
        """Find the next match of pattern."""
        page = self.application.get_current_page()
        row, doc, pos = self._get_position(next=True)
        pages = self.application.pages[:]
        i = pages.index(page)
        # Loop twice over the current page,
        # since starting in the middle.
        for page in (pages[i:] + pages[:i+1]):
            self._set_pattern(page)
            try:
                # Return match in page after position.
                row, doc, span = page.project.find_next(row, doc, pos)
                return self._set_success_state(page, row, doc, span, next=True)
            except StopIteration:
                target = gaupol.conf.search.target
github otsaloma / gaupol / gaupol / dialogs / multi_close.py View on Github external
    @aeidon.deco.silent(gaupol.Default)
    def _save_and_close_page(self, page):
        """Save the selected documents and close `page`."""
        store = self._main_tree_view.get_model()
        pages = [x for x in store if x[0] is page]
        if pages and pages[0][1]:
            self.application.save_main(page)
        store = self._tran_tree_view.get_model()
        pages = [x for x in store if x[0] is page]
        if pages and pages[0][1]:
            self.application.save_translation(page)
        self.application.close(page, confirm=False)
github otsaloma / gaupol / gaupol / dialogs / search.py View on Github external
    @aeidon.deco.silent(gaupol.Default)
    def replace_all(self):
        """Replace all matches of pattern."""
        count = 0
        target = gaupol.conf.search.target
        for page in self.application.get_target_pages(target):
            self._set_pattern(page)
            self._set_replacement(page)
            try:
                count += page.project.replace_all()
            except re.error as error:
                self._show_regex_error_dialog_replacement(str(error))
                break
        self._reset_properties()
        self._statuslabel.flash_text(n_(
            "Found and replaced {:d} occurence",
            "Found and replaced {:d} occurences",
github otsaloma / gaupol / gaupol / extensionman.py View on Github external
    @aeidon.deco.silent(ImportError, tb=True)
    def setup_extension(self, module, slave=False):
        """Import and setup extension by module name."""
        if module in self._active: return
        metadata = self._metadata[module]
        for dependency in metadata.get_field_list("Requires", ()):
            if not dependency in self._active:
                self.setup_extension(dependency, slave=True)
                self._slaves.append(dependency)
            self._dependants[dependency].append(module)
        directory = os.path.dirname(metadata.path)
        name = "gaupol.extension.{:s}".format(module)
        path = os.path.join(directory, "{}.py".format(module))
        loader = importlib.machinery.SourceFileLoader(name, path)
        module_object = loader.load_module(name)
        for attribute in dir(module_object):
            if attribute.startswith("_"): continue