File: subscription.py

package info (click to toggle)
python-rx 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,204 kB
  • sloc: python: 39,525; javascript: 77; makefile: 24
file content (25 lines) | stat: -rw-r--r-- 701 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import sys
from typing import Any, Optional


class Subscription:
    def __init__(self, start: int, end: Optional[int] = None):
        self.subscribe = start
        self.unsubscribe = end or sys.maxsize

    def equals(self, other: Any) -> bool:
        return (
            self.subscribe == other.subscribe and self.unsubscribe == other.unsubscribe
        )

    def __eq__(self, other: Any) -> bool:
        return self.equals(other)

    def __repr__(self) -> str:
        return str(self)

    def __str__(self) -> str:
        unsubscribe = (
            "Infinite" if self.unsubscribe == sys.maxsize else self.unsubscribe
        )
        return "(%s, %s)" % (self.subscribe, unsubscribe)