File: utils.py

package info (click to toggle)
python-directv 0.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 324 kB
  • sloc: python: 1,067; sh: 5; makefile: 3
file content (21 lines) | stat: -rw-r--r-- 537 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""Helpers for DirecTV."""
from typing import Tuple


def parse_channel_number(channel: str) -> Tuple[str, str]:
    """Convert a channel number into its major and minor."""
    try:
        major, minor = channel.split("-")
    except ValueError:
        major = channel
        minor = "65535"

    return major, minor


def combine_channel_number(major: int, minor: int) -> str:
    """Create a combined channel number from its major and minor."""
    if minor == 65535:
        return str(major)

    return "%d-%d" % (major, minor)