forked from buriy/python-readability
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
26 lines (21 loc) · 683 Bytes
/
__init__.py
File metadata and controls
26 lines (21 loc) · 683 Bytes
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
26
"""
This module contains compatibility helpers for Python 2/3 interoperability.
It mainly exists because their are certain incompatibilities in the Python
syntax that can only be solved by conditionally importing different functions.
"""
import sys
from lxml.etree import tostring
if sys.version_info[0] == 2:
bytes_ = str
str_ = unicode
def tostring_(s):
return tostring(s, encoding='utf-8').decode('utf-8')
elif sys.version_info[0] == 3:
bytes_ = bytes
str_ = str
def tostring_(s):
return tostring(s, encoding='utf-8')
try:
from re import Pattern as pattern_type
except ImportError:
from re import _pattern_type as pattern_type