How to use the aeidon.is_frame 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 / aeidon / calculator.py View on Github external
def round(self, pos, ndigits):
        """
        Round `pos` to given precision in decimal digits.

        `ndigits` may be negative. For frames zero will be used
        if given `ndigits` is greater than zero.
        """
        if aeidon.is_time(pos):
            pos = self.time_to_seconds(pos)
            pos = round(pos, ndigits)
            return self.seconds_to_time(pos)
        if aeidon.is_frame(pos):
            ndigits = min(0, ndigits)
            pos = round(pos, ndigits)
            return aeidon.as_frame(pos)
        if aeidon.is_seconds(pos):
            pos = round(pos, ndigits)
            return aeidon.as_seconds(pos)
        raise ValueError("Invalid type for pos: {!r}"
                         .format(type(pos)))
github otsaloma / gaupol / aeidon / calculator.py View on Github external
def is_later(self, x, y):
        """Return ``True`` if `x` is later than `y`."""
        if aeidon.is_time(x):
            x = self.time_to_seconds(x)
            return self.is_later(x, y)
        if aeidon.is_frame(x):
            return (x > self.to_frame(y))
        if aeidon.is_seconds(x):
            return (x > self.to_seconds(y))
        raise ValueError("Invalid type for x: {!r}"
                         .format(type(x)))
github otsaloma / gaupol / aeidon / subtitle.py View on Github external
def _convert_position(self, value):
        """Return `value` of position in correct mode."""
        if aeidon.is_time(value):
            if self._mode == aeidon.modes.TIME:
                return value
            if self._mode == aeidon.modes.FRAME:
                return self.calc.time_to_frame(value)
        if aeidon.is_frame(value):
            if self._mode == aeidon.modes.TIME:
                return self.calc.frame_to_time(value)
            if self._mode == aeidon.modes.FRAME:
                return value
        if aeidon.is_seconds(value):
            if self._mode == aeidon.modes.TIME:
                return self.calc.seconds_to_time(value)
            if self._mode == aeidon.modes.FRAME:
                return self.calc.seconds_to_frame(value)
        raise ValueError("Invalid type for value: {!r}"
                         .format(type(value)))
github otsaloma / gaupol / aeidon / calculator.py View on Github external
def to_seconds(self, pos):
        """Convert `pos` to seconds."""
        if aeidon.is_time(pos):
            return self.time_to_seconds(pos)
        if aeidon.is_frame(pos):
            return self.frame_to_seconds(pos)
        if aeidon.is_seconds(pos):
            return pos
        raise ValueError("Invalid type for pos: {!r}"
                         .format(type(pos)))
github otsaloma / gaupol / aeidon / calculator.py View on Github external
def add(self, x, y):
        """Add position `y` to `x`."""
        if aeidon.is_time(x):
            x = self.to_seconds(x)
            y = self.to_seconds(y)
            return self.seconds_to_time(x + y)
        if aeidon.is_frame(x):
            return x + self.to_frame(y)
        if aeidon.is_seconds(x):
            return x + self.to_seconds(y)
        raise ValueError("Invalid type for x: {!r}"
                         .format(type(x)))
github otsaloma / gaupol / aeidon / calculator.py View on Github external
def to_frame(self, pos):
        """Convert `pos` to frame."""
        if aeidon.is_time(pos):
            return self.time_to_frame(pos)
        if aeidon.is_frame(pos):
            return pos
        if aeidon.is_seconds(pos):
            return self.seconds_to_frame(pos)
        raise ValueError("Invalid type for pos: {!r}"
                         .format(type(pos)))