Skip to content

Commit

Permalink
scc: change SccCode class hierarchy to fix incompatibility with Pytho…
Browse files Browse the repository at this point in the history
…n 3.11 (#386)

Bump ubuntu version on CI
  • Loading branch information
palemieux authored May 17, 2023
1 parent 3c4d479 commit e080ddd
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 24 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ on: [push, pull_request]

jobs:
run:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install python3.7 python3-pip
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 10
python3.7 -m pip install pipenv

- uses: actions/setup-python@v4
with:
python-version: '3.7'

- name: Initialize pip environment
run: python -m pip install pipenv

- name: Checkout repo
uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ contextmanager-decorators=contextlib.contextmanager
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=
generated-members=SccAttributeCode.BMS.value

# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
Expand Down
6 changes: 4 additions & 2 deletions src/main/python/ttconv/scc/codes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

"""SCC Codes"""

from enum import Enum
from typing import Tuple
from ttconv.style_properties import NamedColors

SCC_COLOR_MAPPING = {
Expand All @@ -45,7 +47,7 @@
}


class SccCode:
class SccCode(Enum):
"""SCC codes base definition class"""

def __init__(self, channel_1: int, channel_2: int):
Expand All @@ -55,7 +57,7 @@ def __init__(self, channel_1: int, channel_2: int):
self._channel_1 = channel_1
self._channel_2 = channel_2

def get_values(self) -> (int, int):
def get_values(self) -> Tuple[int, int]:
"""Returns SCC Code values"""
return self._channel_1, self._channel_2

Expand Down
3 changes: 1 addition & 2 deletions src/main/python/ttconv/scc/codes/attribute_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@

from __future__ import annotations

from enum import Enum
from typing import Optional

from ttconv.scc.codes import SccCode
from ttconv.style_properties import ColorType, NamedColors, TextDecorationType


class SccAttributeCode(SccCode, Enum):
class SccAttributeCode(SccCode):
"""SCC Foreground and Background Attribute Codes definition"""
BWO = (0x1020, 0x1820, ColorType((0xFF, 0xFF, 0xFF, 0xFF))) # Background White, Opaque
BWS = (0x1021, 0x1821, ColorType((0xFF, 0xFF, 0xFF, 0x88))) # Background White, Semi-transparent
Expand Down
5 changes: 2 additions & 3 deletions src/main/python/ttconv/scc/codes/control_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
from __future__ import annotations

import typing
from enum import Enum

from ttconv.scc.codes import SccCode


class SccControlCode(SccCode, Enum):
class SccControlCode(SccCode):
"""SCC Control Code definition"""
AOF = (0x1422, 0x1C22, 0x1522, 0x1D22) # Reserved (formerly Alarm Off)
AON = (0x1423, 0x1C23, 0x1523, 0x1D23) # Reserved (formerly Alarm On)
Expand Down Expand Up @@ -64,7 +63,7 @@ def get_name(self) -> str:
"""Retrieves Control Code name"""
return self.name

def get_values(self) -> (int, int, int, int):
def get_values(self) -> typing.Tuple[int, int, int, int]:
"""Returns SCC Control Code values"""
return self._channel_1, self._channel_2, self._channel_1_field_2, self._channel_2_field_2

Expand Down
3 changes: 1 addition & 2 deletions src/main/python/ttconv/scc/codes/mid_row_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@
from __future__ import annotations

import typing
from enum import Enum

from ttconv.scc.codes import SccCode, SCC_COLOR_MAPPING
from ttconv.style_properties import FontStyleType, TextDecorationType, ColorType


class SccMidRowCode(SccCode, Enum):
class SccMidRowCode(SccCode):
"""SCC Mid-Row Code values"""
WHITE = (0x1120, 0x1920)
WHITE_UNDERLINE = (0x1121, 0x1921)
Expand Down
5 changes: 2 additions & 3 deletions src/main/python/ttconv/scc/codes/special_characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
from __future__ import annotations

import typing
from enum import Enum

from ttconv.scc.codes import SccCode


class SccSpecialCharacter(SccCode, Enum):
class SccSpecialCharacter(SccCode):
"""SCC Special character definition"""

# Special characters specified in CEA-608
Expand Down Expand Up @@ -71,7 +70,7 @@ def find(value: int) -> typing.Optional[SccSpecialCharacter]:
return None


class SccExtendedCharacter(SccCode, Enum):
class SccExtendedCharacter(SccCode):
"""SCC Extended character definition"""

# Spanish extended characters
Expand Down
4 changes: 2 additions & 2 deletions src/main/python/ttconv/scc/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import copy
import logging
from typing import Optional
from typing import Optional, Tuple

from ttconv.model import ContentDocument, Body, Div, CellResolutionType, ActiveAreaType
from ttconv.scc.codes.attribute_codes import SccAttributeCode
Expand Down Expand Up @@ -76,7 +76,7 @@ def __init__(self, config: Optional[SccReaderConfiguration] = None):
self.roll_up_depth: int = 0

# Cursor position in the active area
self.active_cursor: (int, int) = (0, 0)
self.active_cursor: Tuple[int, int] = (0, 0)

self.current_text_decoration = None
self.current_color = None
Expand Down

0 comments on commit e080ddd

Please sign in to comment.