File: compat.py

package info (click to toggle)
pysrt 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 144 kB
  • sloc: python: 579; makefile: 3
file content (24 lines) | stat: -rw-r--r-- 359 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

import sys

# Syntax sugar.
_ver = sys.version_info

#: Python 2.x?
is_py2 = (_ver[0] == 2)

#: Python 3.x?
is_py3 = (_ver[0] == 3)

from io import open as io_open

if is_py2:
    builtin_str = str
    basestring = basestring
    str = unicode
    open = io_open
elif is_py3:
    builtin_str = str
    basestring = (str, bytes)
    str = str
    open = open