How to use the aeidon.deco.export 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 / agents / save.py View on Github external
    @aeidon.deco.export
    def save_translation_as(self, page, file=None):
        """Save the translation document of `page` to a selected file."""
        if file is None:
            file = page.project.tran_file
            file = self._select_file(_("Save Translation As"), page, file)
        self._save_document(page, aeidon.documents.TRAN, file)
        self.emit("page-saved", self, page)
        path = page.project.tran_file.path
        format = page.project.tran_file.format
        self.add_to_recent_files(path, format, aeidon.documents.TRAN)
        self.flash_message(_('Saved translation document as "{}"')
                           .format(os.path.basename(path)))
github otsaloma / gaupol / gaupol / agents / tools.py View on Github external
    @aeidon.deco.export
    def _on_check_spelling_activate(self, *args):
        """Check for incorrect spelling."""
        gaupol.util.set_cursor_busy(self.window)
        try:
            dialog = gaupol.SpellCheckDialog(self.window, self)
        except Exception as error:
            gaupol.util.set_cursor_normal(self.window)
            title = _('Failed to load dictionary for language "{}"')
            title = title.format(gaupol.conf.spell_check.language)
            dialog = gaupol.ErrorDialog(self.window, title, str(error))
            dialog.add_button(_("_OK"), Gtk.ResponseType.OK)
            dialog.set_default_response(Gtk.ResponseType.OK)
            return gaupol.util.flash_dialog(dialog)
        gaupol.util.set_cursor_normal(self.window)
        gaupol.util.flash_dialog(dialog)
github otsaloma / gaupol / aeidon / agents / register.py View on Github external
    @aeidon.deco.export
    def set_action_description(self, register, description):
        """Set the description of the most recent registered action."""
        if register is None: return
        stack = self._get_destination_stack(register)
        stack[0].description = description
github otsaloma / gaupol / gaupol / agents / util.py View on Github external
    @aeidon.deco.export
    def get_target_rows(self, target):
        """Return rows corresponding to `target` or ``None`` for all."""
        if target == gaupol.targets.SELECTED:
            page = self.get_current_page()
            return page.view.get_selected_rows()
        if target == gaupol.targets.SELECTED_TO_END:
            page = self.get_current_page()
            rows = page.view.get_selected_rows()
            return list(range(min(rows), len(page.project.subtitles)))
        if target == gaupol.targets.CURRENT: return None
        if target == gaupol.targets.ALL: return None
        raise ValueError("Invalid target: {!r}"
                         .format(target))
github otsaloma / gaupol / aeidon / agents / util.py View on Github external
    @aeidon.deco.export
    def get_changed(self, doc):
        """Return the changed value corresponding to `doc`."""
        if doc == aeidon.documents.MAIN:
            return self.main_changed
        if doc == aeidon.documents.TRAN:
            return self.tran_changed
        raise ValueError("Invalid document: {!r}"
                         .format(doc))
github otsaloma / gaupol / gaupol / agents / tools.py View on Github external
    @aeidon.deco.export
    def _on_shift_positions_activate(self, *args):
        """Make subtitles appear earlier or later."""
        page = self.get_current_page()
        if page.edit_mode == aeidon.modes.TIME:
            dialog = gaupol.TimeShiftDialog(self.window, self)
        if page.edit_mode == aeidon.modes.FRAME:
            dialog = gaupol.FrameShiftDialog(self.window, self)
        gaupol.util.flash_dialog(dialog)
github otsaloma / gaupol / aeidon / agents / save.py View on Github external
    @aeidon.deco.export
    def save(self, doc, file=None, keep_changes=True):
        """
        Write subtitle data from `doc` to `file`.

        `file` can be ``None`` to use existing file.
        Raise :exc:`IOError` if writing fails.
        Raise :exc:`UnicodeError` if encoding fails.
        """
        if doc == aeidon.documents.MAIN:
            return self.save_main(file, keep_changes)
        if doc == aeidon.documents.TRAN:
            return self.save_translation(file, keep_changes)
        raise ValueError("Invalid document: {!r}".format(doc))
github otsaloma / gaupol / gaupol / agents / video.py View on Github external
    @aeidon.deco.export
    def _on_seek_selection_start_activate(self, *args):
        """Seek to the start of selection."""
        page = self.get_current_page()
        rows = page.view.get_selected_rows()
        pos = page.project.subtitles[rows[0]].start_seconds
        offset = gaupol.conf.video_player.context_length
        self.player.seek(max(pos - offset, 0))
github otsaloma / gaupol / aeidon / agents / util.py View on Github external
    @aeidon.deco.export
    def new_temp_file(self, doc, encoding=None):
        """
        Return path to a new temporary file with subtitles from `doc`.

        Raise :exc:`IOError` if writing to temporary file fails.
        Raise :exc:`UnicodeError` if encoding temporary file fails.
        """
        file = self.get_file(doc)
        if file is None and doc == aeidon.documents.TRAN:
            # For an unsaved translation document,
            # fall back to main document's properties.
            file = self.get_file(aeidon.documents.MAIN)
        if file is not None:
            path = aeidon.temp.create(file.format.extension)
            encoding = encoding or file.encoding
            temp_file = aeidon.files.new(file.format, path, encoding)
github otsaloma / gaupol / aeidon / agents / preview.py View on Github external
    @aeidon.deco.export
    def preview(self, position, doc, command, offset, encoding=None, temp=False):
        """
        Start video player with `command` from `position`.

        `command` can have variables ``$MILLISECONDS``, ``$SECONDS``,
        ``$SUBFILE`` and ``$VIDEOFILE``. `offset` should be the amount
        of seconds before `position` to start. `encoding` can be specified
        if different from `doc` file encoding. Use ``True`` for `temp` to
        always use a temporary file for preview regardless of whether
        the file is changed or not.

        Return a three tuple of :class:`subprocess.POpen` instance, command
        with variables expanded and a file object to which process standard
        output and standard error are directed.

        Raise :exc:`IOError` if writing to temporary file fails.