-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop Python 2 support; move to Python 3.7
- added type hints - added explicit keyword arguments to `SSAEvent`, `SSAStyle` - bumped year in license statement
- Loading branch information
Showing
24 changed files
with
230 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
- "3.4" | ||
- "3.5" | ||
- "3.6" | ||
- "3.7" | ||
- "3.8" | ||
- "3.9" | ||
install: pip install . | ||
script: nosetests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,26 @@ | ||
from collections import namedtuple | ||
import sys | ||
from typing import Union | ||
|
||
|
||
_Color = namedtuple("Color", "r g b a") | ||
|
||
|
||
class Color(_Color): | ||
""" | ||
(r, g, b, a) namedtuple for 8-bit RGB color with alpha channel. | ||
All values are ints from 0 to 255. | ||
""" | ||
def __new__(cls, r, g, b, a=0): | ||
def __new__(cls, r: int, g: int, b: int, a: int=0): | ||
for value in r, g, b, a: | ||
if value not in range(256): | ||
raise ValueError("Color channels must have values 0-255") | ||
|
||
return _Color.__new__(cls, r, g, b, a) | ||
|
||
|
||
#: Version of the pysubs2 library. | ||
VERSION = "0.2.4" | ||
|
||
|
||
PY3 = sys.version_info.major == 3 | ||
|
||
if PY3: | ||
text_type = str | ||
binary_string_type = bytes | ||
else: | ||
text_type = unicode | ||
binary_string_type = str | ||
IntOrFloat = Union[int, float] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
class Pysubs2Error(Exception): | ||
"""Base class for pysubs2 exceptions.""" | ||
|
||
|
||
class UnknownFPSError(Pysubs2Error): | ||
"""Framerate was not specified and couldn't be inferred otherwise.""" | ||
|
||
|
||
class UnknownFileExtensionError(Pysubs2Error): | ||
"""File extension does not pertain to any known subtitle format.""" | ||
|
||
|
||
class UnknownFormatIdentifierError(Pysubs2Error): | ||
"""Unknown subtitle format identifier (ie. string like ``"srt"``).""" | ||
|
||
|
||
class FormatAutodetectionError(Pysubs2Error): | ||
"""Subtitle format is ambiguous or unknown.""" | ||
|
||
|
||
class ContentNotUsable(Pysubs2Error): | ||
"""Current content not usable for specified format""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.