How to use aeidon - 10 common examples

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 / __init__.py View on Github external
import os

# Disable gst-vaapi as it doesn't seem to work with gtksink.
# https://github.com/otsaloma/gaupol/issues/79
os.environ["LIBVA_DRIVER_NAME"] = "null"
os.environ["LIBVA_DRIVERS_PATH"] = "/dev/null"

gi.require_version("Gdk", "3.0")
gi.require_version("Gtk", "3.0")

for module, version in {
    "Gst": "1.0",
    "GstPbutils": "1.0",
    "GstVideo": "1.0",
}.items():
    with aeidon.util.silent(Exception):
        gi.require_version(module, version)

with aeidon.util.silent(Exception):
    from gi.repository import Gst
    Gst.init(None)

from gaupol.urls import * # noqa
from gaupol import util # noqa
from gaupol.enums import * # noqa
from gaupol.errors import * # noqa
from gaupol.attrdict import * # noqa
from gaupol.config import ConfigurationStore # noqa
conf = ConfigurationStore()
from gaupol import style # noqa
from gaupol import ruler # noqa
from gaupol.entries import * # noqa
github otsaloma / gaupol / gaupol / agents / save.py View on Github external
def save_main_as(self, page, file=None):
        """Save the main document of `page` to a selected file."""
        if file is None:
            file = page.project.main_file
            file = self._select_file(_("Save As"), page, file)
        self._save_document(page, aeidon.documents.MAIN, file)
        self.emit("page-saved", self, page)
        path = page.project.main_file.path
        format = page.project.main_file.format
        self.add_to_recent_files(path, format, aeidon.documents.MAIN)
        self.flash_message(_('Saved main document as "{}"')
                           .format(os.path.basename(path)))
github otsaloma / gaupol / aeidon / agents / save.py View on Github external
def save_translation(self, file=None, keep_changes=True):
        """
        Write subtitle data from translation document to `file`.

        `file` can be ``None`` to use :attr:`tran_file`.
        Raise :exc:`IOError` if writing fails.
        Raise :exc:`UnicodeError` if encoding fails.
        """
        file = file or self.tran_file
        if file is not None and self.tran_file is not None:
            file.copy_from(self.tran_file)
        indices = self._save(aeidon.documents.TRAN, file, keep_changes)
        if keep_changes:
            self.tran_file = file
            self.tran_changed = 0
            self.emit("translation-texts-changed", indices)
        self.emit("translation-file-saved", file)
github otsaloma / gaupol / aeidon / agents / save.py View on Github external
def save_main(self, file=None, keep_changes=True):
        """
        Write subtitle data from main document to `file`.

        `file` can be ``None`` to use :attr:`main_file`.
        Raise :exc:`IOError` if writing fails.
        Raise :exc:`UnicodeError` if encoding fails.
        """
        file = file or self.main_file
        if file is not None and self.main_file is not None:
            file.copy_from(self.main_file)
        indices = self._save(aeidon.documents.MAIN, file, keep_changes)
        if keep_changes:
            if (self.main_file is not None and
                file.mode != self.main_file.mode):
                # Apply possibly changed mode (times vs. frames).
                for i, subtitle in enumerate(self.subtitles):
                    subtitle.mode = file.mode
                self.emit("positions-changed", self.get_all_indices())
            self.main_file = file
            self.main_changed = 0
            self.emit("main-texts-changed", indices)
        self.emit("main-file-saved", file)
github otsaloma / gaupol / aeidon / files / mpsub.py View on Github external
def set_header(self, header):
        """
        Parse and set header, mode and framerate.

        Raise :exc:`ValueError` if ``FORMAT`` line is invalid.
        """
        mode = aeidon.modes.NONE
        framerates = dict((x.mpsub, x) for x in aeidon.framerates)
        for line in header.split("\n"):
            if line.startswith("FORMAT="):
                mode = line[7:].strip()
        if mode == "TIME":
            self.mode = aeidon.modes.TIME
            self.framerate = aeidon.framerates.NONE
            return setattr(self, "header", header)
        if mode in list(framerates.keys()):
            self.mode = aeidon.modes.FRAME
            self.framerate = framerates[mode]
            return setattr(self, "header", header)
        raise ValueError("Invalid FORMAT line: {}"
                         .format(repr(header)))
github otsaloma / gaupol / gaupol / agents / save.py View on Github external
def save_main(self, page):
        """Save the main document of `page` to file."""
        if (page.project.main_file is None or
            page.project.main_file.path is None or
            page.project.main_file.encoding is None):
            return self.save_main_as(page)
        self._save_document(page, aeidon.documents.MAIN)
        self.emit("page-saved", self, page)
github otsaloma / gaupol / gaupol / agents / save.py View on Github external
def save_main_as(self, page, file=None):
        """Save the main document of `page` to a selected file."""
        if file is None:
            file = page.project.main_file
            file = self._select_file(_("Save As"), page, file)
        self._save_document(page, aeidon.documents.MAIN, file)
        self.emit("page-saved", self, page)
        path = page.project.main_file.path
        format = page.project.main_file.format
        self.add_to_recent_files(path, format, aeidon.documents.MAIN)
        self.flash_message(_('Saved main document as "{}"')
                           .format(os.path.basename(path)))
github otsaloma / gaupol / aeidon / agents / set.py View on Github external
    @aeidon.deco.revertable
    def set_text(self, index, doc, value, register=-1):
        """Set the value of `doc`'s text."""
        subtitle = self.subtitles[index]
        orig_value = subtitle.get_text(doc)
        if value == orig_value: return
        subtitle.set_text(doc, value)
        action = aeidon.RevertableAction(register=register)
        action.docs = (doc,)
        action.description = _("Editing text")
        action.revert_function = self.set_text
        action.revert_args = (index, doc, orig_value)
        self.register_action(action)
        signal = self.get_text_signal(doc)
        self.emit(signal, (index,))
github otsaloma / gaupol / aeidon / agents / edit.py View on Github external
    @aeidon.deco.revertable
    @aeidon.deco.notify_frozen
    def replace_texts(self, indices, doc, texts, register=-1):
        """Replace texts in `doc`'s `indices` with `texts`."""
        orig_texts = [self.subtitles[i].get_text(doc) for i in indices]
        for i, index in enumerate(indices):
            self.subtitles[index].set_text(doc, texts[i])
        action = aeidon.RevertableAction(register=register)
        action.docs = (doc,)
        action.description = _("Replacing texts")
        action.revert_function = self.replace_texts
        action.revert_args = (indices, doc, orig_texts)
        self.register_action(action)
        self.emit(self.get_text_signal(doc), indices)