Skip to content

Commit 0f2ca32

Browse files
Add new compatibility layer for Python 2 and 3 #295
This module used in condition to apply on Python 2 and Python 3 Signed-off-by: Abhishek Kumar <abhishek.kasyap09@gmail.com>
1 parent cd326ef commit 0f2ca32

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

src/commoncode/compat.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#
2+
# Copyright (c) 2019 nexB Inc. and others. All rights reserved.
3+
# http://nexb.com and https://github.com/nexB/scancode-toolkit/
4+
# The ScanCode software is licensed under the Apache License version 2.0.
5+
# Data generated with ScanCode require an acknowledgment.
6+
# ScanCode is a trademark of nexB Inc.
7+
#
8+
# You may not use this software except in compliance with the License.
9+
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0
10+
# Unless required by applicable law or agreed to in writing, software distributed
11+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
13+
# specific language governing permissions and limitations under the License.
14+
#
15+
# When you publish or redistribute any data created with ScanCode or any ScanCode
16+
# derivative work, you must accompany this data with the following acknowledgment:
17+
#
18+
# Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES
19+
# OR CONDITIONS OF ANY KIND, either express or implied. No content created from
20+
# ScanCode should be considered or used as legal advice. Consult an Attorney
21+
# for any legal advice.
22+
# ScanCode is a free software code scanning tool from nexB Inc. and others.
23+
# Visit https://github.com/nexB/scancode-toolkit/ for support and download.
24+
25+
from __future__ import absolute_import
26+
from __future__ import print_function
27+
from __future__ import unicode_literals
28+
29+
try:
30+
# Python 2
31+
unicode = unicode # NOQA
32+
33+
except NameError: # pragma: nocover
34+
# Python 3
35+
unicode = str # NOQA
36+
37+
string_types = str, bytes, unicode,
38+
39+
try:
40+
# Python 2
41+
long = long # NOQA
42+
43+
except NameError: # pragma: nocover
44+
# Python 3
45+
long = int # NOQA
46+
47+
integer_types = int, long,

0 commit comments

Comments
 (0)